From: Marko Luukkainen Date: Wed, 18 Dec 2019 18:49:03 +0000 (+0200) Subject: Copying SCLValues X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F23%2F3723%2F1;p=simantics%2Finterop.git Copying SCLValues gitlab #20 Change-Id: I2e46e71ba0c5df147bd1362eb23af082950fa455 --- diff --git a/org.simantics.interop.update/src/org/simantics/interop/update/model/AddDeleteUpdateOp.java b/org.simantics.interop.update/src/org/simantics/interop/update/model/AddDeleteUpdateOp.java index 854ad54..54e91b8 100644 --- a/org.simantics.interop.update/src/org/simantics/interop/update/model/AddDeleteUpdateOp.java +++ b/org.simantics.interop.update/src/org/simantics/interop/update/model/AddDeleteUpdateOp.java @@ -60,20 +60,29 @@ public abstract class AddDeleteUpdateOp extends UpdateOp { 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()); } } }