]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Use Layer0Utils.getDomainOf 39/139/1
authorAntti Villberg <antti.villberg@semantum.fi>
Wed, 9 Nov 2016 10:13:36 +0000 (12:13 +0200)
committerAntti Villberg <antti.villberg@semantum.fi>
Wed, 9 Nov 2016 10:13:36 +0000 (12:13 +0200)
The result can be cached by several uses.

refs #6800

Change-Id: I65c32408b1afdc1ca96de126e7ac86c46896b250

bundles/org.simantics.structural2/src/org/simantics/structural2/scl/ReadComponentTypeInterfaceRequest.java

index 2c2f0f7b2176e1e60785be6014918be6936bd06d..8180b3f1b13c6986f1a18a0fb24536180467f575 100644 (file)
@@ -9,6 +9,7 @@ import org.simantics.db.ReadGraph;
 import org.simantics.db.Resource;\r
 import org.simantics.db.common.request.ResourceRead;\r
 import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.util.Layer0Utils;\r
 import org.simantics.layer0.Layer0;\r
 import org.simantics.scl.compiler.environment.Environment;\r
 import org.simantics.scl.compiler.environment.Environments;\r
@@ -26,9 +27,11 @@ public class ReadComponentTypeInterfaceRequest extends ResourceRead<Map<String,
 \r
        private void collect(ReadGraph graph, Resource t, THashMap<String, ComponentTypeProperty> result) throws DatabaseException {\r
                Layer0 L0 = Layer0.getInstance(graph);\r
-               for(Resource relation : graph.getObjects(t, L0.DomainOf)) {\r
+               Map<String,Resource> domain = Layer0Utils.getDomainOf(graph, t); \r
+               for(Map.Entry<String, Resource> entry : domain.entrySet()) {\r
+                       String name = entry.getKey();\r
+                       Resource relation = entry.getValue();\r
                        if(graph.isSubrelationOf(relation, L0.HasProperty)) {\r
-                               String name = graph.getRelatedValue(relation, L0.HasName, Bindings.STRING);\r
                                String typeName = graph.getPossibleRelatedValue(relation, L0.RequiresValueType, Bindings.STRING);\r
                                if(typeName == null) continue;\r
                                Type type;\r
@@ -52,7 +55,7 @@ public class ReadComponentTypeInterfaceRequest extends ResourceRead<Map<String,
                                new THashMap<String, ComponentTypeProperty>();\r
                \r
                collect(graph, resource, result);\r
-               for(Resource t : graph.getSupertypes(resource)) collect(graph, t, result);\r
+               //for(Resource t : graph.getSupertypes(resource)) collect(graph, t, result);\r
                \r
                return result;\r
                \r