}
}
- protected static void copyProperties(WriteGraph g, Resource source, Resource destination) throws DatabaseException {
+ public static void copyProperties(WriteGraph g, Resource source, Resource destination) throws DatabaseException {
Layer0 l0 = Layer0.getInstance(g);
for (Statement s : g.getStatements(source, l0.HasProperty)) {
if (s.isAsserted(source))
import org.simantics.db.WriteGraph;
import org.simantics.db.exception.DatabaseException;
import org.simantics.interop.test.GraphChanges;
+import org.simantics.layer0.Layer0;
import org.simantics.utils.datastructures.Pair;
public class PropertyChange {
graph.deny(leftSubject, pair.first.getPredicate(),pair.first.getObject());
return;
}
+ Layer0 L0 = Layer0.getInstance(graph);
Resource s = leftSubject;
- Object value = 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 (value != null) {
+ if (graph.isInstanceOf(pair.second.getObject(), L0.Literal)) {
+ Object value = 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 (value != null) {
+ graph.deny(s, pred);
+ graph.claimLiteral(s, pred, value);
+ } else {
+ graph.deny(s,pred);
+ }
+ } else if (graph.isInstanceOf(pair.second.getObject(), L0.SCLValue)) {
+ Resource pred = pair.second.getPredicate();
graph.deny(s, pred);
- graph.claimLiteral(s, pred, value);
- } else {
- 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;
}