]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/variable/StandardRVIResolver.java
Merge "Fixed ProfileObserver.update race with multiple query threads"
[simantics/platform.git] / bundles / org.simantics.db.layer0 / src / org / simantics / db / layer0 / variable / StandardRVIResolver.java
index 7c632f3f43b26bdc4c40f5f161cad268f962ff98..7c7ba292d851d8bfde2cbf1f13d2fe3713885848 100644 (file)
@@ -32,15 +32,15 @@ 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);
             if (parent == null)
                 // TODO: consider using a more suitable exception here to better convey the situation.
-                throw new MissingVariableException("no parent for variable " + variable + " (URI=" + variable.getURI(graph) + ")");
+                throw new MissingVariableException("no parent for variable " + variable + " (URI=" + variable.getURI(graph) + ")", variable.getPossibleRepresents(graph));
             RVI base = graph.syncRequest(new VariableRVIRequest(parent));
             RVIPart part = getRVIPart(graph, variable);
             return new RVIBuilder(base).append(part).toRVI();
@@ -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);
@@ -90,7 +90,7 @@ public class StandardRVIResolver implements RVIResolver {
                                return child;
                }
        }
-       throw new DatabaseException("Could not resolve child " + part);
+       throw new MissingVariableException("Could not resolve child " + part, variable.getPossibleRepresents(graph));
     }
 
     public static Variable resolvePropertyDefault(ReadGraph graph, Variable variable, GuidRVIPart part) throws DatabaseException {
@@ -102,7 +102,7 @@ public class StandardRVIResolver implements RVIResolver {
                                return child;
                }
        }
-       throw new DatabaseException("Could not resolve property " + part);
+       throw new MissingVariableException("Could not resolve property " + part, variable.getPossibleRepresents(graph));
     }
 
     @Override
@@ -120,7 +120,7 @@ public class StandardRVIResolver implements RVIResolver {
             if(Role.CHILD.equals(grp.getRole())) return resolveChild(graph, context, grp);
             else if(Role.PROPERTY.equals(grp.getRole())) return resolveProperty(graph, context, grp);
         }
-        throw new DatabaseException("Unrecognized RVIPart: " + part);
+        throw new MissingVariableException("Unrecognized RVIPart: " + part, context.getPossibleRepresents(graph));
     }
 
 }