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%2FSubstructureMapRequest.java;h=75aacc475874eba5a468275195bb8bf8b45f2a63;hp=2aafa7c25c5643bd672c0ac6ec90ffd1b7073eaf;hb=c0941146a40af9df766b514fd4238aa20ec2ff4f;hpb=969bd23cab98a79ca9101af33334000879fb60c5 diff --git a/bundles/org.simantics.modeling/src/org/simantics/modeling/SubstructureMapRequest.java b/bundles/org.simantics.modeling/src/org/simantics/modeling/SubstructureMapRequest.java index 2aafa7c25..75aacc475 100644 --- a/bundles/org.simantics.modeling/src/org/simantics/modeling/SubstructureMapRequest.java +++ b/bundles/org.simantics.modeling/src/org/simantics/modeling/SubstructureMapRequest.java @@ -1,62 +1,62 @@ -package org.simantics.modeling; - -import gnu.trove.map.hash.THashMap; - -import java.util.Map; - -import org.simantics.db.ReadGraph; -import org.simantics.db.Resource; -import org.simantics.db.common.request.ResourceRead; -import org.simantics.db.common.uri.UnescapedChildMapOfResource; -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.UnescapedPropertyMapOfResource; -import org.simantics.layer0.Layer0; -import org.simantics.scl.compiler.types.Type; -import org.simantics.structural.stubs.StructuralResource2; -import org.simantics.utils.datastructures.Pair; - -/** - * Deprecated: Use ComponentTypeSubstructure that supports deep references - */ -@Deprecated -public class SubstructureMapRequest extends ResourceRead>>{ - - public SubstructureMapRequest(Resource type) { - super(type); - } - - private void collect(ReadGraph graph, Resource t, THashMap> result) throws DatabaseException { - Layer0 L0 = Layer0.getInstance(graph); - for(Resource relation : graph.getObjects(t, L0.DomainOf)) { - if(graph.isSubrelationOf(relation, L0.HasProperty)) { - PropertyInfo propertyInfo = graph.syncRequest(new PropertyInfoRequest(relation)); - result.put(propertyInfo.name, Pair.make("#" + propertyInfo.name, SCLTypeUtils.getType(propertyInfo))); - } - } - } - - @Override - public THashMap> perform(ReadGraph graph) throws DatabaseException { - THashMap> propertyMap = new THashMap>(); - StructuralResource2 STR = StructuralResource2.getInstance(graph); - Resource composite = graph.getPossibleObject(resource, STR.IsDefinedBy); - if(composite != null) { - for(Map.Entry child : graph.sync(new UnescapedChildMapOfResource(composite)).entrySet()) { - for(PropertyInfo property : graph.sync(new UnescapedPropertyMapOfResource(child.getValue())).values()) { - propertyMap.put(child.getKey() + "." + property.name, - Pair.make("/" + child.getKey() + "#" + property.name, - SCLTypeUtils.getType(property))); - } - } - } - - collect(graph, resource, propertyMap); - for(Resource t : graph.getSupertypes(resource)) collect(graph, t, propertyMap); - - return propertyMap; - - } - -} +package org.simantics.modeling; + +import gnu.trove.map.hash.THashMap; + +import java.util.Map; + +import org.simantics.db.ReadGraph; +import org.simantics.db.Resource; +import org.simantics.db.common.request.ResourceRead; +import org.simantics.db.common.uri.UnescapedChildMapOfResource; +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.UnescapedPropertyMapOfResource; +import org.simantics.layer0.Layer0; +import org.simantics.scl.compiler.types.Type; +import org.simantics.structural.stubs.StructuralResource2; +import org.simantics.utils.datastructures.Pair; + +/** + * Deprecated: Use ComponentTypeSubstructure that supports deep references + */ +@Deprecated +public class SubstructureMapRequest extends ResourceRead>>{ + + public SubstructureMapRequest(Resource type) { + super(type); + } + + private void collect(ReadGraph graph, Resource t, THashMap> result) throws DatabaseException { + Layer0 L0 = Layer0.getInstance(graph); + for(Resource relation : graph.getObjects(t, L0.DomainOf)) { + if(graph.isSubrelationOf(relation, L0.HasProperty)) { + PropertyInfo propertyInfo = graph.syncRequest(new PropertyInfoRequest(relation)); + result.put(propertyInfo.name, Pair.make("#" + propertyInfo.name, SCLTypeUtils.getType(propertyInfo))); + } + } + } + + @Override + public THashMap> perform(ReadGraph graph) throws DatabaseException { + THashMap> propertyMap = new THashMap>(); + StructuralResource2 STR = StructuralResource2.getInstance(graph); + Resource composite = graph.getPossibleObject(resource, STR.IsDefinedBy); + if(composite != null) { + for(Map.Entry child : graph.sync(new UnescapedChildMapOfResource(composite)).entrySet()) { + for(PropertyInfo property : graph.sync(new UnescapedPropertyMapOfResource(child.getValue())).values()) { + propertyMap.put(child.getKey() + "." + property.name, + Pair.make("/" + child.getKey() + "#" + property.name, + SCLTypeUtils.getType(property))); + } + } + } + + collect(graph, resource, propertyMap); + for(Resource t : graph.getSupertypes(resource)) collect(graph, t, propertyMap); + + return propertyMap; + + } + +}