]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/variable/ValueProxyVariable.java
Merge "Revert "Prime SCL BindingRegistry to shave ~0.5s from startup""
[simantics/platform.git] / bundles / org.simantics.db.layer0 / src / org / simantics / db / layer0 / variable / ValueProxyVariable.java
index 1f6b18030e6747339179b0b99fde35443aa5f33d..d2d4ebef0ce404b7ae5fe3e9edbb8058b6e61885 100644 (file)
@@ -12,6 +12,10 @@ import org.simantics.db.Resource;
 import org.simantics.db.WriteGraph;
 import org.simantics.db.common.utils.NameUtils;
 import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.layer0.exception.InvalidVariableException;
+import org.simantics.db.layer0.exception.MissingVariableException;
+import org.simantics.db.layer0.exception.MissingVariableValueException;
+import org.simantics.db.layer0.exception.NonWritableVariableException;
 import org.simantics.db.layer0.request.PropertyInfo;
 import org.simantics.db.layer0.variable.RVI.RVIPart;
 import org.simantics.db.layer0.variable.Variables.Role;
@@ -40,37 +44,37 @@ public abstract class ValueProxyVariable implements Variable {
 
        @Override
        public <T> T getPropertyValue(ReadGraph graph, String name) throws DatabaseException {
-               throw new DatabaseException("Could not resolve property " + name);
+               throw new MissingVariableValueException("Could not resolve property " + name);
        }
 
        @Override
        public <T> T getPropertyValue(ReadGraph graph, Resource property) throws DatabaseException {
-               throw new DatabaseException("Could not resolve property " + NameUtils.getSafeName(graph, property, true));
+               throw new MissingVariableValueException("Could not resolve property " + NameUtils.getSafeName(graph, property, true));
        }
 
        @Override
        public <T> T getPossiblePropertyValue(ReadGraph graph, String name) throws DatabaseException {
-               throw new DatabaseException("Could not resolve property " + name);
+               throw new MissingVariableValueException("Could not resolve property " + name);
        }
 
        @Override
        public <T> T getPossiblePropertyValue(ReadGraph graph, Resource property) throws DatabaseException {
-               throw new DatabaseException("Could not resolve property " + NameUtils.getSafeName(graph, property, true));
+               throw new MissingVariableValueException("Could not resolve property " + NameUtils.getSafeName(graph, property, true));
        }
 
        @Override
        public <T> T getPropertyValue(ReadGraph graph, String name, Binding binding) throws DatabaseException {
-               throw new DatabaseException("Could not resolve property " + name);
+               throw new MissingVariableValueException("Could not resolve property " + name);
        }
 
        @Override
        public <T> T getPropertyValue(ReadGraph graph, Resource property, Binding binding) throws DatabaseException {
-               throw new DatabaseException("Could not resolve property " + NameUtils.getSafeName(graph, property, true));
+               throw new MissingVariableValueException("Could not resolve property " + NameUtils.getSafeName(graph, property, true));
        }
 
        @Override
        public <T> T getPossiblePropertyValue(ReadGraph graph, String name, Binding binding) throws DatabaseException {
-               throw new DatabaseException("Could not resolve property " + name);
+               throw new MissingVariableValueException("Could not resolve property " + name);
        }
 
        @Override
@@ -102,37 +106,37 @@ public abstract class ValueProxyVariable implements Variable {
 
        @Override
        public void setValue(WriteGraph graph, Object value, Binding binding) throws DatabaseException {
-               throw new DatabaseException("Not supported");
+               throw new NonWritableVariableException("Not supported");
        }
 
        @Override
        public void setValue(WriteGraph graph, Object value) throws DatabaseException {
-               throw new DatabaseException("Not supported");
+               throw new NonWritableVariableException("Not supported");
        }
 
        @Override
        public void setPropertyValue(WriteGraph graph, String name, Object value, Binding binding) throws DatabaseException {
-               throw new DatabaseException("Not supported");
+               throw new NonWritableVariableException("Not supported");
        }
 
        @Override
        public void setPropertyValue(WriteGraph graph, Resource property, Object value, Binding binding) throws DatabaseException {
-               throw new DatabaseException("Not supported");
+               throw new NonWritableVariableException("Not supported");
        }
 
        @Override
        public void setPropertyValue(WriteGraph graph, String name, Object value) throws DatabaseException {
-               throw new DatabaseException("Not supported");
+               throw new NonWritableVariableException("Not supported");
        }
 
        @Override
        public void setPropertyValue(WriteGraph graph, Resource property, Object value) throws DatabaseException {
-               throw new DatabaseException("Not supported");
+               throw new NonWritableVariableException("Not supported");
        }
 
        @Override
        public Variable getChild(ReadGraph graph, String name) throws DatabaseException {
-               throw new DatabaseException("Could not resolve child " + name);
+               throw new MissingVariableException("Could not resolve child " + name, getPossibleRepresents(graph));
        }
 
        @Override
@@ -142,12 +146,12 @@ public abstract class ValueProxyVariable implements Variable {
 
        @Override
        public Variable getProperty(ReadGraph graph, String name) throws DatabaseException {
-               throw new DatabaseException("Could not resolve property " + name);
+               throw new MissingVariableException("Could not resolve property " + name, getPossibleRepresents(graph));
        }
 
        @Override
        public Variable getProperty(ReadGraph graph, Resource property) throws DatabaseException {
-               throw new DatabaseException("Could not resolve property " + NameUtils.getSafeName(graph, property, true));
+               throw new MissingVariableException("Could not resolve property " + NameUtils.getSafeName(graph, property, true), getPossibleRepresents(graph));
        }
 
        @Override
@@ -194,7 +198,7 @@ public abstract class ValueProxyVariable implements Variable {
        public Variable browse(ReadGraph graph, String suffix) throws DatabaseException {
                if (suffix.isEmpty())
                        return this;
-               throw new DatabaseException("Could not browse with suffix '" + suffix + "'");
+               throw new MissingVariableException("Could not browse with suffix '" + suffix + "'", getPossibleRepresents(graph));
        }
 
        @Override
@@ -206,7 +210,7 @@ public abstract class ValueProxyVariable implements Variable {
 
        @Override
        public Variable browse(ReadGraph graph, Resource config) throws DatabaseException {
-               throw new DatabaseException("Could not browse '" + NameUtils.getSafeName(graph, config, true) + "'");
+               throw new MissingVariableException("Could not browse '" + NameUtils.getSafeName(graph, config, true) + "'", getPossibleRepresents(graph));
        }
 
        @Override
@@ -240,7 +244,7 @@ public abstract class ValueProxyVariable implements Variable {
 
        @Override
        public Variable resolve(ReadGraph graph, RVIPart part) throws DatabaseException {
-               throw new DatabaseException("not supported");
+               throw new InvalidVariableException("not supported");
        }
 
        @Override
@@ -253,7 +257,7 @@ public abstract class ValueProxyVariable implements Variable {
 
        @Override
        public String getLabel(ReadGraph graph) throws DatabaseException {
-               throw new DatabaseException("not supported");
+               throw new InvalidVariableException("not supported");
        }
 
        @Override
@@ -270,17 +274,17 @@ public abstract class ValueProxyVariable implements Variable {
 
        @Override
        public Variable getPredicate(ReadGraph graph) throws DatabaseException {
-               throw new DatabaseException("not supported");
+               throw new InvalidVariableException("not supported");
        }
 
        @Override
        public Variable getPossiblePredicate(ReadGraph graph) throws DatabaseException {
-               throw new DatabaseException("not supported");
+               throw new InvalidVariableException("not supported");
        }
 
        @Override
        public Resource getPredicateResource(ReadGraph graph) throws DatabaseException {
-               throw new DatabaseException("not supported");
+               throw new InvalidVariableException("not supported");
        }
 
        @Override
@@ -299,7 +303,7 @@ public abstract class ValueProxyVariable implements Variable {
 
        @Override
        public Resource getRepresents(ReadGraph graph) throws DatabaseException {
-               throw new DatabaseException("no resource representation");
+               throw new InvalidVariableException("no resource representation");
        }
 
        @Override
@@ -309,7 +313,7 @@ public abstract class ValueProxyVariable implements Variable {
 
        @Override
        public Resource getType(ReadGraph graph) throws DatabaseException {
-               throw new DatabaseException("not supported");
+               throw new InvalidVariableException("not supported");
        }
 
        @Override
@@ -319,7 +323,7 @@ public abstract class ValueProxyVariable implements Variable {
 
        @Override
        public Resource getType(ReadGraph graph, Resource baseType) throws DatabaseException {
-               throw new DatabaseException("not supported");
+               throw new InvalidVariableException("not supported");
        }
 
        @Override