]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/request/IndexedInstances.java
Added resourceId and GUID to diagram DnD content
[simantics/platform.git] / bundles / org.simantics.db.layer0 / src / org / simantics / db / layer0 / request / IndexedInstances.java
index 1177f3a30f984881b1bef0398687bf6802662850..09a1fc9021c77ee6440e93aeb84c87a68baf175d 100644 (file)
@@ -1,49 +1,50 @@
-package org.simantics.db.layer0.request;\r
-\r
-import java.util.Collection;\r
-import java.util.Collections;\r
-import java.util.HashSet;\r
-import java.util.Map;\r
-import java.util.Set;\r
-\r
-import org.simantics.db.ReadGraph;\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.common.request.ResourceRead2;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.layer0.Layer0;\r
-import org.simantics.operation.Layer0X;\r
-import org.simantics.scl.runtime.function.Function;\r
-\r
-public class IndexedInstances extends ResourceRead2<Set<Resource>> {\r
-\r
-       public IndexedInstances(Resource type, Resource indexRoot) {\r
-               super(type, indexRoot);\r
-       }\r
-\r
-       @Override\r
-       public Set<Resource> perform(ReadGraph graph) throws DatabaseException {\r
-               \r
-        Layer0 L0 = Layer0.getInstance(graph);\r
-        Layer0X L0X = Layer0X.getInstance(graph);\r
-\r
-        String typeName = graph.getRelatedValue(resource, L0.HasName);\r
-\r
-        Function dependencies = graph.adapt(L0X.Dependencies, Function.class);\r
-        \r
-        Collection<Map<String, Object>> results = (Collection<Map<String, Object>>)dependencies.apply(graph, resource2, "Types:*" + typeName);\r
-        if (results == null)\r
-            return Collections.emptySet();\r
-\r
-        HashSet<Resource> result = new HashSet<Resource>(results.size());\r
-        for(Map<String, Object> entry : results) {\r
-            Resource res = (Resource)entry.get("Resource");\r
-            if(res != null) {\r
-               if (graph.isInstanceOf(res, resource))\r
-                       result.add(res);\r
-            }\r
-        }\r
-        return result;\r
-               \r
-       }\r
-\r
-}\r
+package org.simantics.db.layer0.request;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.simantics.db.ReadGraph;
+import org.simantics.db.Resource;
+import org.simantics.db.common.request.ResourceRead2;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.layer0.genericrelation.IndexQueries;
+import org.simantics.layer0.Layer0;
+import org.simantics.operation.Layer0X;
+import org.simantics.scl.runtime.function.Function;
+
+public class IndexedInstances extends ResourceRead2<Set<Resource>> {
+
+       public IndexedInstances(Resource type, Resource indexRoot) {
+               super(type, indexRoot);
+       }
+
+       @Override
+       public Set<Resource> perform(ReadGraph graph) throws DatabaseException {
+               
+        Layer0 L0 = Layer0.getInstance(graph);
+        Layer0X L0X = Layer0X.getInstance(graph);
+
+        String typeName = graph.getRelatedValue(resource, L0.HasName);
+
+        Function dependencies = graph.adapt(L0X.Dependencies, Function.class);
+        
+        Collection<Map<String, Object>> results = (Collection<Map<String, Object>>)dependencies.apply(graph, resource2, "Types:" + IndexQueries.quoteTerm(typeName));
+        if (results == null)
+            return Collections.emptySet();
+
+        HashSet<Resource> result = new HashSet<Resource>(results.size());
+        for(Map<String, Object> entry : results) {
+            Resource res = (Resource)entry.get("Resource");
+            if(res != null) {
+               if (graph.isInstanceOf(res, resource))
+                       result.add(res);
+            }
+        }
+        return result;
+               
+       }
+
+}