for (Statement s : g.getStatements(source, l0.HasProperty)) {
if (s.isAsserted(source))
continue;
- Object value = g.getPossibleValue(s.getObject());
- System.out.println(NameUtils.getSafeName(g, s.getSubject()) + " " + NameUtils.getSafeName(g, s.getPredicate()) + " " + NameUtils.getSafeName(g, s.getObject()) + " " + value);
- if (value != null) {
- Statement valueStm = g.getPossibleStatement(destination, s.getPredicate());
- Resource valueResource = null;
- if (valueStm != null && !valueStm.isAsserted(destination))
- valueResource = valueStm.getObject();
- if (valueResource == null) {
- valueResource = g.newResource();
- g.claim(valueResource, l0.InstanceOf, g.getSingleObject(s.getObject(), l0.InstanceOf));
- g.claim(destination, s.getPredicate(), valueResource);
+ if (g.isInstanceOf(s.getObject(), l0.Literal)) {
+ Object value = g.getPossibleValue(s.getObject());
+ System.out.println(NameUtils.getSafeName(g, s.getSubject()) + " " + NameUtils.getSafeName(g, s.getPredicate()) + " " + NameUtils.getSafeName(g, s.getObject()) + " " + value);
+ if (value != null) {
+ Statement valueStm = g.getPossibleStatement(destination, s.getPredicate());
+ Resource valueResource = null;
+ if (valueStm != null && !valueStm.isAsserted(destination))
+ valueResource = valueStm.getObject();
+ if (valueResource == null) {
+ valueResource = g.newResource();
+ g.claim(valueResource, l0.InstanceOf, g.getSingleObject(s.getObject(), l0.InstanceOf));
+ g.claim(destination, s.getPredicate(), valueResource);
+ }
+ g.claimValue(valueResource, value);
+ //g.claimLiteral(destination, s.getPredicate(), value);
}
- g.claimValue(valueResource, value);
- //g.claimLiteral(destination, s.getPredicate(), value);
+ } else if (g.isInstanceOf(s.getObject(), l0.SCLValue)) {
+ Resource valueResource = g.newResource();
+ g.claim(valueResource, l0.InstanceOf, g.getSingleObject(s.getObject(), l0.InstanceOf));
+ g.claim(destination, s.getPredicate(), valueResource);
+ copyProperties(g, s.getObject(), valueResource);
+ } else {
+ throw new DatabaseException("Expected to copy property resource " + s.getObject());
}
}
}