X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.db.layer0%2Fsrc%2Forg%2Fsimantics%2Fdb%2Flayer0%2Fvariable%2FStandardGraphChildVariable.java;h=bd0184e86af9f413931f512d223b6be1e234dcf7;hb=035118aa5f35c9e5acd1f34d22065055dfdee486;hp=17fc21ebb911bb2130ff3cd10c662f9a083b9162;hpb=3c2807a26920491016a1887d2c1a95609c082a19;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/variable/StandardGraphChildVariable.java b/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/variable/StandardGraphChildVariable.java index 17fc21ebb..bd0184e86 100644 --- a/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/variable/StandardGraphChildVariable.java +++ b/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/variable/StandardGraphChildVariable.java @@ -13,7 +13,6 @@ import org.simantics.db.common.procedure.adapter.TransientCacheAsyncListener; import org.simantics.db.exception.AssumptionException; import org.simantics.db.exception.DatabaseException; import org.simantics.db.layer0.exception.InvalidVariableException; -import org.simantics.db.layer0.exception.VariableException; import org.simantics.db.layer0.function.All; import org.simantics.db.layer0.request.ClassificationsRequest; import org.simantics.db.layer0.request.VariableURI; @@ -24,7 +23,7 @@ import org.simantics.db.layer0.variable.Variables.Role; import org.simantics.layer0.Layer0; import org.simantics.simulator.variable.exceptions.NodeManagerException; -public class StandardGraphChildVariable extends AbstractChildVariable { +public class StandardGraphChildVariable extends AbstractChildVariable implements ProxyVariableSupport { /* * Extension points @@ -107,7 +106,7 @@ public class StandardGraphChildVariable extends AbstractChildVariable { return node.support.manager.getName(node.node); } String unescapedName = graph.getPossibleRelatedValue(resource, graph.getService(Layer0.class).HasName, Bindings.STRING); - if(unescapedName == null) return "r" + resource.getResourceId(); + if(unescapedName == null) return VariableUtils.unnamedResourceName(resource); return unescapedName; } @@ -150,7 +149,7 @@ public class StandardGraphChildVariable extends AbstractChildVariable { @Override final public Resource getRepresents(ReadGraph graph) throws DatabaseException { if(resource == null) - throw new VariableException("Variable is not represented by any resource (URI=" + getPossibleURI(graph) + ")."); + throw new InvalidVariableException("Variable is not represented by any resource (URI=" + getPossibleURI(graph) + ")."); return resource; // Layer0X L0X = Layer0X.getInstance(graph); // Resource represents = graph.getPossibleObject(resource, L0X.Represents); @@ -264,7 +263,9 @@ public class StandardGraphChildVariable extends AbstractChildVariable { protected VariableMap getPossibleChildVariableMap(ReadGraph graph) throws DatabaseException { if(resource == null) return All.standardChildDomainChildren; - return graph.getPossibleRelatedValue2(resource, Layer0.getInstance(graph).domainChildren, this); + Resource domainChildren = Layer0.getInstance(graph).domainChildren; + return graph.getPossibleRelatedValue2(resource, domainChildren, + new StandardGraphPropertyVariable(graph, this, domainChildren)); } @Override @@ -333,5 +334,20 @@ public class StandardGraphChildVariable extends AbstractChildVariable { public Resource getPossiblePredicateResource(ReadGraph graph) throws DatabaseException { return null; } - + + @Override + public Variable attachTo(ReadGraph graph, Variable parent) { + return new StandardGraphChildVariable(parent, node, resource); + } + + @Override + public Variable attachToRenamed(ReadGraph graph, Variable parent, String name) { + return new StandardGraphChildVariable(parent, node, resource) { + @Override + public String getName(ReadGraph graph) throws DatabaseException { + return name; + } + }; + } + }