X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.structural2%2Fsrc%2Forg%2Fsimantics%2Fstructural2%2Fscl%2FReadComponentTypeInterfaceRequest.java;h=a93cbe8d4237abc857aa5bbbaa742d6c9b2b7929;hp=8180b3f1b13c6986f1a18a0fb24536180467f575;hb=refs%2Fchanges%2F38%2F238%2F2;hpb=24e2b34260f219f0d1644ca7a138894980e25b14 diff --git a/bundles/org.simantics.structural2/src/org/simantics/structural2/scl/ReadComponentTypeInterfaceRequest.java b/bundles/org.simantics.structural2/src/org/simantics/structural2/scl/ReadComponentTypeInterfaceRequest.java index 8180b3f1b..a93cbe8d4 100644 --- a/bundles/org.simantics.structural2/src/org/simantics/structural2/scl/ReadComponentTypeInterfaceRequest.java +++ b/bundles/org.simantics.structural2/src/org/simantics/structural2/scl/ReadComponentTypeInterfaceRequest.java @@ -1,64 +1,64 @@ -package org.simantics.structural2.scl; - -import gnu.trove.map.hash.THashMap; - -import java.util.Map; - -import org.simantics.databoard.Bindings; -import org.simantics.db.ReadGraph; -import org.simantics.db.Resource; -import org.simantics.db.common.request.ResourceRead; -import org.simantics.db.exception.DatabaseException; -import org.simantics.db.layer0.util.Layer0Utils; -import org.simantics.layer0.Layer0; -import org.simantics.scl.compiler.environment.Environment; -import org.simantics.scl.compiler.environment.Environments; -import org.simantics.scl.compiler.top.SCLExpressionCompilationException; -import org.simantics.scl.compiler.types.Type; - -public class ReadComponentTypeInterfaceRequest extends ResourceRead> { - - Environment environment; - - public ReadComponentTypeInterfaceRequest(Resource resource, Environment environment) { - super(resource); - this.environment = environment; - } - - private void collect(ReadGraph graph, Resource t, THashMap result) throws DatabaseException { - Layer0 L0 = Layer0.getInstance(graph); - Map domain = Layer0Utils.getDomainOf(graph, t); - for(Map.Entry entry : domain.entrySet()) { - String name = entry.getKey(); - Resource relation = entry.getValue(); - if(graph.isSubrelationOf(relation, L0.HasProperty)) { - String typeName = graph.getPossibleRelatedValue(relation, L0.RequiresValueType, Bindings.STRING); - if(typeName == null) continue; - Type type; - try { - type = Environments.getType(environment, typeName); - } catch(SCLExpressionCompilationException e) { - e.printStackTrace(); - continue; - } - ComponentTypeProperty property = new ComponentTypeProperty(relation, type); - result.put(name, property); - } - } - } - - @Override - public Map perform(ReadGraph graph) - throws DatabaseException { - - THashMap result = - new THashMap(); - - collect(graph, resource, result); - //for(Resource t : graph.getSupertypes(resource)) collect(graph, t, result); - - return result; - - } - -} +package org.simantics.structural2.scl; + +import gnu.trove.map.hash.THashMap; + +import java.util.Map; + +import org.simantics.databoard.Bindings; +import org.simantics.db.ReadGraph; +import org.simantics.db.Resource; +import org.simantics.db.common.request.ResourceRead; +import org.simantics.db.exception.DatabaseException; +import org.simantics.db.layer0.util.Layer0Utils; +import org.simantics.layer0.Layer0; +import org.simantics.scl.compiler.environment.Environment; +import org.simantics.scl.compiler.environment.Environments; +import org.simantics.scl.compiler.top.SCLExpressionCompilationException; +import org.simantics.scl.compiler.types.Type; + +public class ReadComponentTypeInterfaceRequest extends ResourceRead> { + + Environment environment; + + public ReadComponentTypeInterfaceRequest(Resource resource, Environment environment) { + super(resource); + this.environment = environment; + } + + private void collect(ReadGraph graph, Resource t, THashMap result) throws DatabaseException { + Layer0 L0 = Layer0.getInstance(graph); + Map domain = Layer0Utils.getDomainOf(graph, t); + for(Map.Entry entry : domain.entrySet()) { + String name = entry.getKey(); + Resource relation = entry.getValue(); + if(graph.isSubrelationOf(relation, L0.HasProperty)) { + String typeName = graph.getPossibleRelatedValue(relation, L0.RequiresValueType, Bindings.STRING); + if(typeName == null) continue; + Type type; + try { + type = Environments.getType(environment, typeName); + } catch(SCLExpressionCompilationException e) { + e.printStackTrace(); + continue; + } + ComponentTypeProperty property = new ComponentTypeProperty(relation, type); + result.put(name, property); + } + } + } + + @Override + public Map perform(ReadGraph graph) + throws DatabaseException { + + THashMap result = + new THashMap(); + + collect(graph, resource, result); + //for(Resource t : graph.getSupertypes(resource)) collect(graph, t, result); + + return result; + + } + +}