X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.db.layer0%2Fsrc%2Forg%2Fsimantics%2Fdb%2Flayer0%2Fvariable%2FConstantPropertyVariable.java;h=14db2cbfed491e3209e14aceaa33d75717c44469;hb=refs%2Fchanges%2F68%2F568%2F2;hp=b3eaf7e21de713826d2f08ffc1ac83899ded1638;hpb=c8cce62f9952ab3f6db451d2f22d969b4e777eaa;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/variable/ConstantPropertyVariable.java b/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/variable/ConstantPropertyVariable.java index b3eaf7e21..14db2cbfe 100644 --- a/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/variable/ConstantPropertyVariable.java +++ b/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/variable/ConstantPropertyVariable.java @@ -12,6 +12,7 @@ import org.simantics.db.ReadGraph; import org.simantics.db.Resource; import org.simantics.db.WriteGraph; import org.simantics.db.exception.DatabaseException; +import org.simantics.db.layer0.function.All; import org.simantics.utils.ObjectUtils; public class ConstantPropertyVariable extends AbstractPropertyVariable { @@ -21,26 +22,32 @@ public class ConstantPropertyVariable extends AbstractPropertyVariable { final Object value; final Binding binding; final Map properties; + final private Resource predicate; - public ConstantPropertyVariable(Variable parent, String name, Object value, Binding binding, Collection propertyBuilders, Set classifications) { + public ConstantPropertyVariable(Variable parent, String name, Object value, Binding binding, Resource predicate, Collection propertyBuilders, Set classifications) { assert parent != null; assert name != null; this.parent = parent; this.name = name; this.value = value; this.binding = binding; + this.predicate = predicate; this.properties = new HashMap(propertyBuilders.size()); for(ConstantPropertyVariableBuilder builder : propertyBuilders) { - properties.put(builder.getName(), builder.build(this)); + properties.put(builder.getName(), builder.build(this)); } if(!classifications.isEmpty()) - properties.put(Variables.CLASSIFICATIONS, new ConstantPropertyVariable(this, Variables.CLASSIFICATIONS, classifications, null)); + properties.put(Variables.CLASSIFICATIONS, new ConstantPropertyVariable(this, Variables.CLASSIFICATIONS, classifications, null)); } - public ConstantPropertyVariable(Variable parent, String name, Object value, Binding binding) { - this(parent, name, value, binding, Collections.emptyList(), Collections.emptySet()); + public ConstantPropertyVariable(Variable parent, String name, Object value, Binding binding, Collection propertyBuilders, Set classifications) { + this(parent, name, value, binding, null, Collections.emptyList(), Collections.emptySet()); } + public ConstantPropertyVariable(Variable parent, String name, Object value, Binding binding) { + this(parent, name, value, binding, Collections.emptyList(), Collections.emptySet()); + } + @Override public T getValue(ReadGraph graph) throws DatabaseException { return (T)value; @@ -105,7 +112,7 @@ public class ConstantPropertyVariable extends AbstractPropertyVariable { @Override public Resource getPropertyResource(ReadGraph graph) throws DatabaseException { - return null; + return predicate; } @Override @@ -121,7 +128,14 @@ public class ConstantPropertyVariable extends AbstractPropertyVariable { @Override protected Variable getPossibleDomainProperty(ReadGraph graph, String name) throws DatabaseException { - return properties.get(name); + Variable result = properties.get(name); + if(result != null) return result; + if(predicate != null) { + HashMap ps = new HashMap(); + All.collectPropertiesFromContext(graph, this, predicate, ps); + return ps.get(name); + } + return null; } @Override @@ -131,6 +145,7 @@ public class ConstantPropertyVariable extends AbstractPropertyVariable { if(properties == null) properties = new HashMap(this.properties.size()); properties.putAll(this.properties); } + if(predicate != null) All.collectPropertiesFromContext(graph, this, predicate, properties); return properties; }