]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
(refs #7461) Fix to StructuralRVIResolver.getPossibleRVI 18/918/1
authorHannu Niemistö <hannu.niemisto@semantum.fi>
Tue, 5 Sep 2017 14:13:53 +0000 (17:13 +0300)
committerHannu Niemistö <hannu.niemisto@semantum.fi>
Tue, 5 Sep 2017 14:13:53 +0000 (17:13 +0300)
Call getPossibleRVI instead of getRVI.

Change-Id: I1638f0a08c78ac784f7c3d2e3a6f9ce4e9670f43

bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/variable/StandardRVIResolver.java
bundles/org.simantics.structural2/src/org/simantics/structural2/StructuralRVIResolver.java

index 7c632f3f43b26bdc4c40f5f161cad268f962ff98..b01aeb32b3c810c6347b96aa01bb6bc2e8feb41c 100644 (file)
@@ -32,9 +32,9 @@ public class StandardRVIResolver implements RVIResolver {
     
     @Override
     public RVI getRVI(ReadGraph graph, Variable variable) throws DatabaseException {
-        Databoard databoard = graph.getService( Databoard.class );
-        Binding rviBinding = databoard.getBindingUnchecked( RVI.class );
         if(Variables.isContext(graph, variable)) {
+            Databoard databoard = graph.getService( Databoard.class );
+            Binding rviBinding = databoard.getBindingUnchecked( RVI.class );
             return RVI.empty( rviBinding );
         } else {
             Variable parent = variable.getParent(graph);
@@ -49,9 +49,9 @@ public class StandardRVIResolver implements RVIResolver {
 
     @Override
     public RVI getPossibleRVI(ReadGraph graph, Variable variable) throws DatabaseException {
-        Databoard databoard = graph.getService( Databoard.class );
-        Binding rviBinding = databoard.getBindingUnchecked( RVI.class );
         if(Variables.isContext(graph, variable)) {
+            Databoard databoard = graph.getService( Databoard.class );
+            Binding rviBinding = databoard.getBindingUnchecked( RVI.class );
             return RVI.empty( rviBinding );
         } else {
             Variable parent = variable.getParent(graph);
index b2913f3203eccc550c799d3632282c2372fd7d6c..8cf61b3e0ade8e4dc74ed2e44ca334d655a6ee0c 100644 (file)
@@ -40,10 +40,12 @@ public class StructuralRVIResolver extends StandardRVIResolver {
             Binding rviBinding = databoard.getBindingUnchecked( RVI.class );
             return RVI.empty(rviBinding);
         }
-        Variable base = variable.getParent(graph);
-        while(!isRVIBase(graph, base)) base = base.getParent(graph);
-        RVIPart part = getRVIPart(graph, variable);
-        return new RVIBuilder(base.getRVI(graph)).append(part).toRVI();
+        else {
+            Variable base = variable.getParent(graph);
+            while(!isRVIBase(graph, base)) base = base.getParent(graph);
+            RVIPart part = getRVIPart(graph, variable);
+            return new RVIBuilder(base.getRVI(graph)).append(part).toRVI();
+        }
     }
     
     @Override
@@ -53,15 +55,19 @@ public class StructuralRVIResolver extends StandardRVIResolver {
             Binding rviBinding = databoard.getBindingUnchecked( RVI.class );
             return RVI.empty(rviBinding);
         }
-        Variable base = variable.getParent(graph);
-        if(base == null) return null;
-        while(!isRVIBase(graph, base)) {
-            base = base.getParent(graph);
+        else {
+            Variable base = variable.getParent(graph);
             if(base == null) return null;
+            while(!isRVIBase(graph, base)) {
+                base = base.getParent(graph);
+                if(base == null) return null;
+            }
+            RVIPart part = getRVIPart(graph, variable);
+            if(part == null) return null;
+            RVI baseRVI = base.getPossibleRVI(graph);
+            if(baseRVI == null) return null;
+            return new RVIBuilder(baseRVI).append(part).toRVI();
         }
-        RVIPart part = getRVIPart(graph, variable);
-        if(part == null) return null;
-        return new RVIBuilder(base.getRVI(graph)).append(part).toRVI();
     }
 
     protected boolean isPartOfComponentType(ReadGraph graph, Resource resource)