Resource s = leftSubject;
if (graph.isInstanceOf(pair.second.getObject(), L0.Literal)) {
Object value = null;
+ Resource type = null;
if (customValue != null)
value = customValue;
else if (graph.hasValue(pair.second.getObject())) {
value = graph.getValue(pair.second.getObject());
}
- Resource pred = pair.second.getPredicate();
- if (getChanges().getComparable().containsRight(pred))
- pred = getChanges().getComparable().getLeft(pred);
+ type = graph.getPossibleType(pair.second.getObject(), L0.Literal);
+ Resource pred = _getPredicate();
if (value != null) {
graph.deny(s, pred);
- graph.claimLiteral(s, pred, value);
+ if (type != null) {
+ graph.claimLiteral(s, pred, type, value);
+ } else {
+ graph.claimLiteral(s, pred, value);
+ }
} else {
graph.deny(s,pred);
}
+ applied = true;
} else if (graph.isInstanceOf(pair.second.getObject(), L0.SCLValue)) {
- Resource pred = pair.second.getPredicate();
+ Resource pred = _getPredicate();
graph.deny(s, pred);
Resource valueResource = graph.newResource();
graph.claim(valueResource, L0.InstanceOf, graph.getSingleObject(pair.second.getObject(), L0.InstanceOf));
AddDeleteUpdateOp.copyProperties(graph, pair.second.getObject(), valueResource);
graph.claim(s, pred, valueResource);
+ applied = true;
+ } else {
+ Resource type = graph.getPossibleType(pair.second.getObject(), L0.Value);
+ if (type != null && graph.hasStatement(type, L0.Enumeration, type)) {
+ Resource pred = _getPredicate();
+ graph.deny(s, pred);
+ graph.claim(s, pred, pair.second.getObject());
+ applied = true;
+ }
+
}
- applied = true;
+
+ }
+
+ private Resource _getPredicate() {
+ Resource pred = pair.second.getPredicate();
+ if (getChanges().getComparable().containsRight(pred))
+ pred = getChanges().getComparable().getLeft(pred);
+ return pred;
}
/**
}
public void setCustomValue(Object customValue) {
+ if (applied) {
+ throw new RuntimeException("Cannot change already applied value");
+ }
this.customValue = customValue;
}