]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/variable/StandardGraphPropertyVariable.java
Initial version of validating derived properties formulas
[simantics/platform.git] / bundles / org.simantics.db.layer0 / src / org / simantics / db / layer0 / variable / StandardGraphPropertyVariable.java
index 582277c905bbcbd19a2a1308021f5f71c66510f6..9b0befc78442fa47d02022ca9e8863f01d1b5647 100644 (file)
@@ -17,13 +17,16 @@ import org.simantics.db.WriteGraph;
 import org.simantics.db.common.procedure.adapter.TransientCacheAsyncListener;
 import org.simantics.db.common.validation.L0Validations;
 import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.exception.DatatypeNotFoundException;
 import org.simantics.db.exception.ValidationException;
+import org.simantics.db.exception.VariableException;
+import org.simantics.db.layer0.exception.InvalidVariableException;
 import org.simantics.db.layer0.exception.MissingVariableValueException;
 import org.simantics.db.layer0.exception.PendingVariableException;
-import org.simantics.db.layer0.exception.VariableException;
 import org.simantics.db.layer0.function.All;
 import org.simantics.db.layer0.request.PropertyInfo;
 import org.simantics.db.layer0.request.PropertyInfoRequest;
+import org.simantics.db.layer0.scl.SCLDatabaseException;
 import org.simantics.db.layer0.util.Layer0Utils;
 import org.simantics.layer0.Layer0;
 import org.simantics.utils.Development;
@@ -147,9 +150,11 @@ public class StandardGraphPropertyVariable extends AbstractPropertyVariable {
         
                try {
                        
-                       return (T)getValueAccessor(graph).getValue(graph, this, binding);
-               } catch (PendingVariableException e) {
-                   throw e;
+                       return (T) getValueAccessor(graph).getValue(graph, this, binding);
+               } catch (SCLDatabaseException e) { // these can be thrown when compiling e.g. derived properties
+                       throw e;
+               } catch (MissingVariableValueException | PendingVariableException e) {
+                       throw e;
                } catch (Throwable t) {
                        throw new MissingVariableValueException(t);
                }
@@ -159,7 +164,7 @@ public class StandardGraphPropertyVariable extends AbstractPropertyVariable {
        @Override
        public Resource getRepresents(ReadGraph graph) throws DatabaseException {
                if(represents == null)
-                       throw new VariableException("Variable is not represented by any resource (URI=" + getPossibleURI(graph) + ").");
+                       throw new InvalidVariableException("Variable is not represented by any resource (URI=" + getPossibleURI(graph) + ").");
                return represents;
 //             return graph.getSingleObject(parentResource, property.predicate);
        }
@@ -233,9 +238,9 @@ public class StandardGraphPropertyVariable extends AbstractPropertyVariable {
                if (type == null) {
                        String uri = this.getPossibleURI(graph);
                        if (uri != null)
-                               throw new DatabaseException("No data type for " + uri);
+                               throw new DatatypeNotFoundException("No data type for " + uri);
                        else
-                               throw new DatabaseException("No data type for " + this.getIdentifier());
+                               throw new DatatypeNotFoundException("No data type for " + this.getIdentifier());
                }
                
                return type;