import java.util.Collection;
import java.util.Collections;
+import java.util.HashMap;
import java.util.Map;
import org.simantics.db.ReadGraph;
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;
+ }
+
}