1 package org.simantics.structural2;
3 import java.util.Collection;
6 import org.simantics.db.ReadGraph;
7 import org.simantics.db.Resource;
8 import org.simantics.db.exception.DatabaseException;
9 import org.simantics.db.layer0.variable.Variable;
10 import org.simantics.structural2.variables.Connection;
11 import org.simantics.structural2.variables.ConnectionBrowser;
12 import org.simantics.structural2.variables.VariableConnectionPointDescriptor;
14 import gnu.trove.set.hash.THashSet;
16 public class ConnectionImpl implements Connection {
19 public int hashCode() {
22 result = prime * result + ((predicate == null) ? 0 : predicate.hashCode());
27 public boolean equals(Object obj) {
32 if (getClass() != obj.getClass())
34 ConnectionImpl other = (ConnectionImpl) obj;
35 if (predicate == null) {
36 if (other.predicate != null)
38 } else if (!predicate.equals(other.predicate))
43 final private Resource predicate;
45 public ConnectionImpl(Resource predicate) {
46 this.predicate = predicate;
50 public Collection<Variable> getConnectionPoints(ReadGraph graph, Variable component, Resource relationType) throws DatabaseException {
51 Set<Variable> result = new THashSet<Variable>();
52 for(VariableConnectionPointDescriptor desc : ConnectionBrowser.flatten(graph, component, predicate, relationType)) {
53 result.add(desc.getVariable(graph));
59 public Collection<String> getConnectionPointURIs(ReadGraph graph, Variable component, Resource relationType) throws DatabaseException {
60 Set<String> result = new THashSet<String>();
61 for(VariableConnectionPointDescriptor desc : ConnectionBrowser.flatten(graph, component, predicate, relationType)) {
62 result.add(desc.getURI(graph));
68 public Collection<VariableConnectionPointDescriptor> getConnectionPointDescriptors(ReadGraph graph, Variable component, Resource relationType) throws DatabaseException {
69 System.err.println("getConnectionPointDescriptors " + component.getURI(graph));
70 return ConnectionBrowser.flatten(graph, component, predicate, relationType);