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 Variable var = parameter.getVariable(graph);
27 System.err.println("ComputeInterfaceDescription " + var.getURI(graph));
28 Collection<InterfaceResolution> res = Functions.computeInterfacePaths(graph, var.getParent(graph));
29 for(InterfaceResolution r : res)
30 System.err.println("-res " + r);
37 public Collection<InterfaceResolution> getInterfaceDescription(ReadGraph graph) throws DatabaseException {
38 return graph.syncRequest(new ComputeInterfaceDescription(this), TransientCacheAsyncListener.<Collection<InterfaceResolution>>instance());
42 public boolean isLeaf(ReadGraph graph) throws DatabaseException {
44 Collection<InterfaceResolution> inf = getInterfaceDescription(graph);
45 if(inf == null) return true;
51 public boolean hasClassification(ReadGraph graph, String classification) throws DatabaseException {
53 PropertyInfo info = graph.syncRequest(new PropertyInfoRequest(getConnectionPointResource(graph)), TransientCacheAsyncListener.<PropertyInfo>instance());
54 return info.hasClassification(classification);
59 public String getRelativeRVI(ReadGraph graph, Variable base) throws DatabaseException {
61 String var = getURI(graph);
62 String baseURI = base.getURI(graph);
63 return Variables.getRelativeRVI(baseURI, var);