]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.structural2/src/org/simantics/structural2/ConnectionImpl2.java
Variable optimizations for documents (Simupedia)
[simantics/platform.git] / bundles / org.simantics.structural2 / src / org / simantics / structural2 / ConnectionImpl2.java
index e4b898a6b18cccef2d66ab26c00e0ada365594da..af17eeebbd25ec974858fff53f8b953360eec48e 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2007, 2010 Association for Decentralized Information Management
+ * Copyright (c) 2007, 2018 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
@@ -19,21 +19,20 @@ import org.simantics.db.Resource;
 import org.simantics.db.exception.DatabaseException;
 import org.simantics.db.layer0.variable.Variable;
 import org.simantics.structural2.variables.Connection;
+import org.simantics.structural2.variables.Connection2;
 import org.simantics.structural2.variables.ConnectionBrowser;
 import org.simantics.structural2.variables.VariableConnectionPointDescriptor;
 
 import gnu.trove.set.hash.THashSet;
 
-public class ConnectionImpl2 implements Connection {
+public class ConnectionImpl2 implements Connection, Connection2 {
 
-    private final Variable component;
     private final Resource predicate;
-    
-    public ConnectionImpl2(Variable component, Resource predicate) {
-        this.component = component;
+
+    public ConnectionImpl2(Resource predicate) {
         this.predicate = predicate;
     }
-    
+
     @Override
     public int hashCode() {
         final int prime = 31;
@@ -60,26 +59,50 @@ public class ConnectionImpl2 implements Connection {
     }
 
     @Override
-    public Collection<Variable> getConnectionPoints(ReadGraph graph, Resource relationType) throws DatabaseException {
-        Set<Variable> result = new THashSet<Variable>();
+    public Collection<String> getConnectionPointURIs(ReadGraph graph, Variable component, Resource relationType)
+            throws DatabaseException {
+        Set<String> result = new THashSet<String>();
         for(VariableConnectionPointDescriptor desc : ConnectionBrowser.flatten(graph, component, predicate, relationType)) {
-            result.add(desc.getVariable(graph));
+            result.add(desc.getURI(graph));
         }
         return result;
     }
-    
+
     @Override
-    public Collection<String> getConnectionPointURIs(ReadGraph graph, Resource relationType) throws DatabaseException {
-        Set<String> result = new THashSet<String>();
+    public Collection<Variable> getConnectionPoints(ReadGraph graph, Variable component, Resource relationType)
+            throws DatabaseException {
+        Set<Variable> result = new THashSet<Variable>();
         for(VariableConnectionPointDescriptor desc : ConnectionBrowser.flatten(graph, component, predicate, relationType)) {
-            result.add(desc.getURI(graph));
+            result.add(desc.getVariable(graph));
         }
         return result;
     }
 
     @Override
-    public Collection<VariableConnectionPointDescriptor> getConnectionPointDescriptors(ReadGraph graph, Resource relationType) throws DatabaseException {
+    public Collection<VariableConnectionPointDescriptor> getConnectionPointDescriptors(ReadGraph graph,
+            Variable component, Resource relationType) throws DatabaseException {
         return ConnectionBrowser.flatten(graph, component, predicate, relationType);
     }
 
+    @Override
+    public Collection<String> getConnectionPointURIs(ReadGraph graph, Resource relationType) throws DatabaseException {
+        throw new IllegalStateException();
+    }
+
+    @Override
+    public Collection<Variable> getConnectionPoints(ReadGraph graph, Resource relationType) throws DatabaseException {
+        throw new IllegalStateException();
+    }
+
+    @Override
+    public Collection<VariableConnectionPointDescriptor> getConnectionPointDescriptors(ReadGraph graph,
+            Resource relationType) throws DatabaseException {
+        throw new IllegalStateException();
+    }
+
+    @Override
+    public Connection2 getConnection2() {
+        return this;
+    }
+
 }
\ No newline at end of file