1 /*******************************************************************************
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.structural2;
14 import java.util.Collection;
17 import org.simantics.db.ReadGraph;
18 import org.simantics.db.Resource;
19 import org.simantics.db.exception.DatabaseException;
20 import org.simantics.db.layer0.variable.Variable;
21 import org.simantics.structural2.variables.Connection;
22 import org.simantics.structural2.variables.ConnectionBrowser;
23 import org.simantics.structural2.variables.VariableConnectionPointDescriptor;
25 import gnu.trove.set.hash.THashSet;
27 public class ConnectionImpl2 implements Connection {
29 private final Variable component;
30 private final Resource predicate;
32 public ConnectionImpl2(Variable component, Resource predicate) {
33 this.component = component;
34 this.predicate = predicate;
38 public int hashCode() {
41 result = prime * result + ((predicate == null) ? 0 : predicate.hashCode());
46 public boolean equals(Object obj) {
51 if (getClass() != obj.getClass())
53 ConnectionImpl2 other = (ConnectionImpl2) obj;
54 if (predicate == null) {
55 if (other.predicate != null)
57 } else if (!predicate.equals(other.predicate))
63 public Collection<Variable> getConnectionPoints(ReadGraph graph, Resource relationType) throws DatabaseException {
64 Set<Variable> result = new THashSet<Variable>();
65 for(VariableConnectionPointDescriptor desc : ConnectionBrowser.flatten(graph, component, predicate, relationType)) {
66 result.add(desc.getVariable(graph));
72 public Collection<String> getConnectionPointURIs(ReadGraph graph, Resource relationType) throws DatabaseException {
73 Set<String> result = new THashSet<String>();
74 for(VariableConnectionPointDescriptor desc : ConnectionBrowser.flatten(graph, component, predicate, relationType)) {
75 result.add(desc.getURI(graph));
81 public Collection<VariableConnectionPointDescriptor> getConnectionPointDescriptors(ReadGraph graph, Resource relationType) throws DatabaseException {
82 return ConnectionBrowser.flatten(graph, component, predicate, relationType);