X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.modeling%2Fsrc%2Forg%2Fsimantics%2Fmodeling%2FProceduralSubstructureMapRequest.java;h=6256891b82ae17a96391e7a05399b2ef9ae3f640;hp=4a87bc29f221cda8cfac71afa223c15f53654382;hb=209d3c557147c8c2c8ae4d8500d1b9a8c5c3166d;hpb=969bd23cab98a79ca9101af33334000879fb60c5 diff --git a/bundles/org.simantics.modeling/src/org/simantics/modeling/ProceduralSubstructureMapRequest.java b/bundles/org.simantics.modeling/src/org/simantics/modeling/ProceduralSubstructureMapRequest.java index 4a87bc29f..6256891b8 100644 --- a/bundles/org.simantics.modeling/src/org/simantics/modeling/ProceduralSubstructureMapRequest.java +++ b/bundles/org.simantics.modeling/src/org/simantics/modeling/ProceduralSubstructureMapRequest.java @@ -1,40 +1,50 @@ -package org.simantics.modeling; - -import gnu.trove.map.hash.THashMap; - -import org.simantics.db.ReadGraph; -import org.simantics.db.exception.DatabaseException; -import org.simantics.db.layer0.request.PropertyInfo; -import org.simantics.db.layer0.request.PropertyInfoRequest; -import org.simantics.db.layer0.request.VariableRead; -import org.simantics.db.layer0.variable.Variable; -import org.simantics.scl.compiler.types.Type; -import org.simantics.utils.datastructures.Pair; - -public class ProceduralSubstructureMapRequest extends VariableRead>>{ - - public ProceduralSubstructureMapRequest(Variable composite) { - super(composite); - } - - @Override - public THashMap> perform(ReadGraph graph) throws DatabaseException { - THashMap> propertyMap = new THashMap>(); - for(Variable child : variable.getChildren(graph)) { - for(Variable property : child.getProperties(graph)) { - PropertyInfo propertyInfo = graph.syncRequest(new PropertyInfoRequest(property.getPredicateResource(graph))); - propertyMap.put(child.getName(graph) + "." + propertyInfo.name, - Pair.make("/" + child.getName(graph) + "#" + propertyInfo.name, - SCLTypeUtils.getType(propertyInfo))); - } - } - for(Variable property : variable.getProperties(graph)) { - PropertyInfo propertyInfo = graph.syncRequest(new PropertyInfoRequest(property.getPredicateResource(graph))); - propertyMap.put(propertyInfo.name, - Pair.make("#" + propertyInfo.name, - SCLTypeUtils.getType(propertyInfo))); - } - return propertyMap; - } - -} +package org.simantics.modeling; + +import gnu.trove.map.hash.THashMap; + +import org.simantics.db.ReadGraph; +import org.simantics.db.Resource; +import org.simantics.db.exception.DatabaseException; +import org.simantics.db.layer0.request.PropertyInfo; +import org.simantics.db.layer0.request.PropertyInfoRequest; +import org.simantics.db.layer0.request.VariableRead; +import org.simantics.db.layer0.variable.Variable; +import org.simantics.scl.compiler.types.Type; +import org.simantics.utils.datastructures.Pair; + +public class ProceduralSubstructureMapRequest extends VariableRead>>{ + + public ProceduralSubstructureMapRequest(Variable composite) { + super(composite); + } + + @Override + public THashMap> perform(ReadGraph graph) throws DatabaseException { + THashMap> propertyMap = new THashMap>(); + for(Variable child : variable.getChildren(graph)) { + for(Variable property : child.getProperties(graph)) { + Resource predicate = property.getPossiblePredicateResource(graph); + if (predicate == null) + continue; + + PropertyInfo propertyInfo = graph.syncRequest(new PropertyInfoRequest(predicate)); + propertyMap.put(child.getName(graph) + "." + propertyInfo.name, + Pair.make("/" + child.getName(graph) + "#" + propertyInfo.name, + SCLTypeUtils.getType(propertyInfo))); + } + } + for(Variable property : variable.getProperties(graph)) { + Resource predicate = property.getPossiblePredicateResource(graph); + if (predicate == null) + continue; + + PropertyInfo propertyInfo = graph.syncRequest(new PropertyInfoRequest(predicate)); + propertyMap.put(propertyInfo.name, + Pair.make("#" + propertyInfo.name, + SCLTypeUtils.getType(propertyInfo))); + } + + return propertyMap; + } + +}