1 package org.simantics.structural2.variables;
3 import java.util.Collection;
5 import org.simantics.db.ReadGraph;
6 import org.simantics.db.common.procedure.adapter.TransientCacheAsyncListener;
7 import org.simantics.db.common.request.UnaryRead;
8 import org.simantics.db.exception.DatabaseException;
9 import org.simantics.db.layer0.request.PropertyInfo;
10 import org.simantics.db.layer0.request.PropertyInfoRequest;
11 import org.simantics.db.layer0.variable.Variable;
12 import org.simantics.db.layer0.variable.Variables;
13 import org.simantics.structural2.Functions;
14 import org.simantics.structural2.Functions.InterfaceResolution;
16 abstract public class AbstractVariableConnectionPointDescriptor implements VariableConnectionPointDescriptor {
18 static class ComputeInterfaceDescription extends UnaryRead<AbstractVariableConnectionPointDescriptor, Collection<InterfaceResolution>> {
20 public ComputeInterfaceDescription(AbstractVariableConnectionPointDescriptor desc) {
25 public Collection<InterfaceResolution> perform(ReadGraph graph) throws DatabaseException {
26 return Functions.computeInterfacePaths(graph, parameter.getVariable(graph).getParent(graph));
32 public Collection<InterfaceResolution> getInterfaceDescription(ReadGraph graph) throws DatabaseException {
33 return graph.syncRequest(new ComputeInterfaceDescription(this), TransientCacheAsyncListener.<Collection<InterfaceResolution>>instance());
37 public boolean isLeaf(ReadGraph graph) throws DatabaseException {
39 Collection<InterfaceResolution> inf = getInterfaceDescription(graph);
40 if(inf == null) return true;
46 public boolean hasClassification(ReadGraph graph, String classification) throws DatabaseException {
48 PropertyInfo info = graph.syncRequest(new PropertyInfoRequest(getConnectionPointResource(graph)), TransientCacheAsyncListener.<PropertyInfo>instance());
49 return info.hasClassification(classification);
54 public String getRelativeRVI(ReadGraph graph, Variable base) throws DatabaseException {
56 String var = getURI(graph);
57 String baseURI = base.getURI(graph);
58 return Variables.getRelativeRVI(baseURI, var);