]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.structural2/src/org/simantics/structural2/variables/FixedConnection.java
Fix errors with procedural user components for computational values
[simantics/platform.git] / bundles / org.simantics.structural2 / src / org / simantics / structural2 / variables / FixedConnection.java
index 7257ca4c5c137a5f8dc88fbc4bf7ca7d0e78c0cc..ecafac42f6eba7e7c4b78b18419753f93ea717ba 100644 (file)
@@ -93,13 +93,14 @@ public class FixedConnection implements Connection, Connection2 {
         for (Pair<String, Resource> cp : cps) {
             Variable component = cp.first == null ? procedural : procedural.getChild(graph, cp.first);
             Variable cp2 = component.getPossibleProperty(graph, cp.second);
         for (Pair<String, Resource> cp : cps) {
             Variable component = cp.first == null ? procedural : procedural.getChild(graph, cp.first);
             Variable cp2 = component.getPossibleProperty(graph, cp.second);
-            if (cp2 != null)
+            if (cp2 != null) {
                 for (VariableConnectionPointDescriptor desc : ConnectionBrowser.flatten(graph, component, cp.second,
                         relationType)) {
                     result.add(desc.getURI(graph));
                 }
                 for (VariableConnectionPointDescriptor desc : ConnectionBrowser.flatten(graph, component, cp.second,
                         relationType)) {
                     result.add(desc.getURI(graph));
                 }
-            else
-                LOGGER.warn("no cp " + cp.first + " for " + component.getURI(graph));
+            } else {
+                logWarn(graph, cp, component, procedural);
+            }
         }
         return result;
     }
         }
         return result;
     }
@@ -107,14 +108,15 @@ public class FixedConnection implements Connection, Connection2 {
     @Override
     public Collection<VariableConnectionPointDescriptor> getConnectionPointDescriptors(ReadGraph graph,
             Resource relationType) throws DatabaseException {
     @Override
     public Collection<VariableConnectionPointDescriptor> getConnectionPointDescriptors(ReadGraph graph,
             Resource relationType) throws DatabaseException {
-        Set<VariableConnectionPointDescriptor> result = new THashSet<VariableConnectionPointDescriptor>();
+        Set<VariableConnectionPointDescriptor> result = new THashSet<>();
         for (Pair<String, Resource> cp : cps) {
             Variable component = cp.first == null ? procedural : procedural.getChild(graph, cp.first);
             Variable cp2 = component.getPossibleProperty(graph, cp.second);
         for (Pair<String, Resource> cp : cps) {
             Variable component = cp.first == null ? procedural : procedural.getChild(graph, cp.first);
             Variable cp2 = component.getPossibleProperty(graph, cp.second);
-            if (cp2 != null)
+            if (cp2 != null) {
                 result.addAll(ConnectionBrowser.flatten(graph, component, cp.second, relationType));
                 result.addAll(ConnectionBrowser.flatten(graph, component, cp.second, relationType));
-            else
-                LOGGER.warn("no cp " + cp.first + " for " + component.getURI(graph));
+            } else {
+                logWarn(graph, cp, component, procedural);
+            }
         }
         return result;
     }
         }
         return result;
     }
@@ -153,14 +155,16 @@ public class FixedConnection implements Connection, Connection2 {
     @Override
     public Collection<VariableConnectionPointDescriptor> getConnectionPointDescriptors(ReadGraph graph,
             Variable component, Resource relationType) throws DatabaseException {
     @Override
     public Collection<VariableConnectionPointDescriptor> getConnectionPointDescriptors(ReadGraph graph,
             Variable component, Resource relationType) throws DatabaseException {
-        Set<VariableConnectionPointDescriptor> result = new THashSet<VariableConnectionPointDescriptor>();
+        Set<VariableConnectionPointDescriptor> result = new THashSet<>();
+        Variable procedural = component.getParent(graph);
         for (Pair<String, Resource> cp : cps) {
         for (Pair<String, Resource> cp : cps) {
-            Variable base = cp.first == null ? component.getParent(graph) : component;
+            Variable base = cp.first == null ? procedural : procedural.getChild(graph, cp.first);
             Variable cp2 = base.getPossibleProperty(graph, cp.second);
             Variable cp2 = base.getPossibleProperty(graph, cp.second);
-            if (cp2 != null)
+            if (cp2 != null) {
                 result.addAll(ConnectionBrowser.flatten(graph, base, cp.second, relationType));
                 result.addAll(ConnectionBrowser.flatten(graph, base, cp.second, relationType));
-            else
-                LOGGER.warn("no cp " + cp.first + " for " + base.getURI(graph));
+            } else {
+                logWarn(graph, cp, base, procedural);
+            }
         }
         return result;
     }
         }
         return result;
     }
@@ -168,17 +172,19 @@ public class FixedConnection implements Connection, Connection2 {
     @Override
     public Collection<Variable> getConnectionPoints(ReadGraph graph, Variable component, Resource relationType)
             throws DatabaseException {
     @Override
     public Collection<Variable> getConnectionPoints(ReadGraph graph, Variable component, Resource relationType)
             throws DatabaseException {
-        Set<Variable> result = new THashSet<Variable>();
+        Set<Variable> result = new THashSet<>();
+        Variable procedural = component.getParent(graph);
         for (Pair<String, Resource> cp : cps) {
         for (Pair<String, Resource> cp : cps) {
-            Variable base = cp.first == null ? component.getParent(graph) : component;
+            Variable base = cp.first == null ? procedural : procedural.getChild(graph, cp.first);
             Variable cp2 = base.getPossibleProperty(graph, cp.second);
             Variable cp2 = base.getPossibleProperty(graph, cp.second);
-            if (cp2 != null)
+            if (cp2 != null) {
                 for (VariableConnectionPointDescriptor desc : ConnectionBrowser.flatten(graph, base, cp.second,
                         relationType)) {
                     result.add(desc.getVariable(graph));
                 }
                 for (VariableConnectionPointDescriptor desc : ConnectionBrowser.flatten(graph, base, cp.second,
                         relationType)) {
                     result.add(desc.getVariable(graph));
                 }
-            else
-                LOGGER.warn("no cp " + cp.first + " for " + base.getURI(graph));
+            } else {
+                logWarn(graph, cp, base, procedural);
+            }
         }
         return result;
     }
         }
         return result;
     }
@@ -186,17 +192,19 @@ public class FixedConnection implements Connection, Connection2 {
     @Override
     public Collection<String> getConnectionPointURIs(ReadGraph graph, Variable component, Resource relationType)
             throws DatabaseException {
     @Override
     public Collection<String> getConnectionPointURIs(ReadGraph graph, Variable component, Resource relationType)
             throws DatabaseException {
-        Set<String> result = new THashSet<String>();
+        Set<String> result = new THashSet<>();
+        Variable procedural = component.getParent(graph);
         for (Pair<String, Resource> cp : cps) {
         for (Pair<String, Resource> cp : cps) {
-            Variable base = cp.first == null ? component.getParent(graph) : component;
+            Variable base = cp.first == null ? procedural : procedural.getChild(graph, cp.first);
             Variable cp2 = base.getPossibleProperty(graph, cp.second);
             Variable cp2 = base.getPossibleProperty(graph, cp.second);
-            if (cp2 != null)
+            if (cp2 != null) {
                 for (VariableConnectionPointDescriptor desc : ConnectionBrowser.flatten(graph, base, cp.second,
                         relationType)) {
                     result.add(desc.getURI(graph));
                 }
                 for (VariableConnectionPointDescriptor desc : ConnectionBrowser.flatten(graph, base, cp.second,
                         relationType)) {
                     result.add(desc.getURI(graph));
                 }
-            else
-                LOGGER.warn("no cp " + cp.first + " for " + base.getURI(graph));
+            } else {
+                logWarn(graph, cp, base, procedural);
+            }
         }
         return result;
     }
         }
         return result;
     }
@@ -206,4 +214,11 @@ public class FixedConnection implements Connection, Connection2 {
         return this;
     }
 
         return this;
     }
 
+    private static void logWarn(ReadGraph graph, Pair<String, Resource> cp, Variable base, Variable procedural) throws DatabaseException {
+        LOGGER.warn("no cp " + cp.first + " for " + base.getURI(graph));
+        LOGGER.warn("    proc: " + procedural.getURI(graph));
+        LOGGER.warn("    rel: " + graph.getURI(cp.second));
+        LOGGER.warn("    base: " + base.getURI(graph));
+    }
+
 }
\ No newline at end of file
 }
\ No newline at end of file