]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.structural2/src/org/simantics/structural2/queries/ConnectionPointMapOfResource.java
Replaceable Defined Component Types
[simantics/platform.git] / bundles / org.simantics.structural2 / src / org / simantics / structural2 / queries / ConnectionPointMapOfResource.java
index 3b2e42ae77f184f9e77bd141a9eef634eb495a9f..2cfc97296655c1c41d15df484e7cf4c22951320a 100644 (file)
@@ -13,6 +13,7 @@ package org.simantics.structural2.queries;
 
 import java.util.Collection;
 import java.util.Collections;
+import java.util.HashMap;
 import java.util.Map;
 
 import org.simantics.db.ReadGraph;
@@ -26,47 +27,45 @@ import org.simantics.db.service.QueryControl;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import gnu.trove.map.hash.THashMap;
-
-public class ConnectionPointMapOfResource extends TransientResourceRead<Map<String, Resource>> {
+public class ConnectionPointMapOfResource extends TransientResourceRead<Map<String, PropertyInfo>> {
 
     private static final Logger LOGGER = LoggerFactory.getLogger(ConnectionPointMapOfResource.class);
 
-       public ConnectionPointMapOfResource(ReadGraph graph, Resource resource) throws DatabaseException {
-           super(graph, resource);
-       }
-       
-       public ConnectionPointMapOfResource(ReadGraph graph, QueryControl qc, Resource resource) throws DatabaseException {
-               super(graph, qc, resource);
-       }
-
-       @Override
-       public Map<String,Resource> perform(ReadGraph graph, Resource resource) throws DatabaseException {
-           
-               Collection<Resource> predicates = graph.getPredicates(resource);
-               
-               THashMap<String,Resource> result = null;
-               
-               for(Resource predicate : predicates) {
-                       
-                       PropertyInfo info = graph.syncRequest(new PossibleConnectionPointInfo(predicate), TransientCacheAsyncListener.<PropertyInfo>instance());
-                       if(info != null) {
-                               if (result == null) result = new THashMap<String,Resource>(predicates.size());
-                               if (result.put(info.name, predicate) != null)
-                                   LOGGER.error("The database contains siblings with the same name " + info.name + " (resource=$" + resource.getResourceId() + ").");
-                       }                               
-                       
-               }
-
-               if(result != null) return result;
-               
-               else return Collections.emptyMap();
-                       
-       }
-       
-       @Override
-       public int getType() {
-               return RequestFlags.INVALIDATE;
-       }
-       
+    public ConnectionPointMapOfResource(ReadGraph graph, Resource resource) throws DatabaseException {
+        super(graph, resource);
+    }
+
+    public ConnectionPointMapOfResource(ReadGraph graph, QueryControl qc, Resource resource) throws DatabaseException {
+        super(graph, qc, resource);
+    }
+
+    @Override
+    public Map<String,PropertyInfo> perform(ReadGraph graph, Resource resource) throws DatabaseException {
+        
+        Collection<Resource> predicates = graph.getPredicates(resource);
+
+        HashMap<String,PropertyInfo> result = null;
+
+        for(Resource predicate : predicates) {
+
+            PropertyInfo info = graph.syncRequest(new PossibleConnectionPointInfo(predicate), TransientCacheAsyncListener.<PropertyInfo>instance());
+            if(info != null) {
+                if (result == null) result = new HashMap<>(predicates.size());
+                if (result.put(info.name, info) != null)
+                LOGGER.error("The database contains siblings with the same name " + info.name + " (resource=$" + resource.getResourceId() + ").");
+            }
+
+        }
+
+        if(result != null) return result;
+
+        else return Collections.emptyMap();
+
+    }
+
+    @Override
+    public int getType() {
+        return RequestFlags.INVALIDATE;
+    }
+
 }