X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.structural2%2Fsrc%2Forg%2Fsimantics%2Fstructural2%2Fqueries%2FConnectionPointMapOfResource.java;fp=bundles%2Forg.simantics.structural2%2Fsrc%2Forg%2Fsimantics%2Fstructural2%2Fqueries%2FConnectionPointMapOfResource.java;h=3b2e42ae77f184f9e77bd141a9eef634eb495a9f;hb=0ae2b770234dfc3cbb18bd38f324125cf0faca07;hp=2924b3dac14dea30174526ab7d141c30fac457a6;hpb=24e2b34260f219f0d1644ca7a138894980e25b14;p=simantics%2Fplatform.git 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 2924b3dac..3b2e42ae7 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 @@ -1,72 +1,72 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.structural2.queries; - -import java.util.Collection; -import java.util.Collections; -import java.util.Map; - -import org.simantics.db.ReadGraph; -import org.simantics.db.Resource; -import org.simantics.db.common.procedure.adapter.TransientCacheAsyncListener; -import org.simantics.db.common.request.TransientResourceRead; -import org.simantics.db.exception.DatabaseException; -import org.simantics.db.layer0.request.PropertyInfo; -import org.simantics.db.request.RequestFlags; -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> { - - 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; - } - -} +/******************************************************************************* + * Copyright (c) 2007, 2010 Association for Decentralized Information Management + * in Industry THTH ry. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * VTT Technical Research Centre of Finland - initial API and implementation + *******************************************************************************/ +package org.simantics.structural2.queries; + +import java.util.Collection; +import java.util.Collections; +import java.util.Map; + +import org.simantics.db.ReadGraph; +import org.simantics.db.Resource; +import org.simantics.db.common.procedure.adapter.TransientCacheAsyncListener; +import org.simantics.db.common.request.TransientResourceRead; +import org.simantics.db.exception.DatabaseException; +import org.simantics.db.layer0.request.PropertyInfo; +import org.simantics.db.request.RequestFlags; +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> { + + 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; + } + +}