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%2Fqueries%2FConnectionPointMapOfResource.java;h=2cfc97296655c1c41d15df484e7cf4c22951320a;hp=3b2e42ae77f184f9e77bd141a9eef634eb495a9f;hb=7402926f3949dbb38e9f8f45e864ba4dd65b59b9;hpb=bc24b049b5ec56feb66793df675a6db78860e28f diff --git a/bundles/org.simantics.structural2/src/org/simantics/structural2/queries/ConnectionPointMapOfResource.java b/bundles/org.simantics.structural2/src/org/simantics/structural2/queries/ConnectionPointMapOfResource.java index 3b2e42ae7..2cfc97296 100644 --- a/bundles/org.simantics.structural2/src/org/simantics/structural2/queries/ConnectionPointMapOfResource.java +++ b/bundles/org.simantics.structural2/src/org/simantics/structural2/queries/ConnectionPointMapOfResource.java @@ -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> { +public class ConnectionPointMapOfResource extends TransientResourceRead> { 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 perform(ReadGraph graph, Resource resource) throws DatabaseException { - - Collection predicates = graph.getPredicates(resource); - - THashMap result = null; - - for(Resource predicate : predicates) { - - PropertyInfo info = graph.syncRequest(new PossibleConnectionPointInfo(predicate), TransientCacheAsyncListener.instance()); - if(info != null) { - if (result == null) result = new THashMap(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 perform(ReadGraph graph, Resource resource) throws DatabaseException { + + Collection predicates = graph.getPredicates(resource); + + HashMap result = null; + + for(Resource predicate : predicates) { + + PropertyInfo info = graph.syncRequest(new PossibleConnectionPointInfo(predicate), TransientCacheAsyncListener.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; + } + }