]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/variable/StandardGraphPropertyVariable.java
Move debugging options under DevelopmentKeys
[simantics/platform.git] / bundles / org.simantics.db.layer0 / src / org / simantics / db / layer0 / variable / StandardGraphPropertyVariable.java
index 2dcb6e00ab08871f296c7af6d5a498115edf7d60..ed58556c7e570814bd4ce25e5473a6821f2c33bc 100644 (file)
@@ -11,6 +11,7 @@ import org.simantics.databoard.accessor.reference.ChildReference;
 import org.simantics.databoard.binding.Binding;
 import org.simantics.databoard.binding.impl.ObjectVariantBinding;
 import org.simantics.databoard.type.Datatype;
+import org.simantics.db.DevelopmentKeys;
 import org.simantics.db.ReadGraph;
 import org.simantics.db.Resource;
 import org.simantics.db.WriteGraph;
@@ -19,13 +20,13 @@ 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.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;
@@ -121,10 +122,12 @@ public class StandardGraphPropertyVariable extends AbstractPropertyVariable {
        public <T> T getValue(ReadGraph graph) throws DatabaseException {
                
                if(Development.DEVELOPMENT) {
-                       String error = L0Validations.checkValueType(graph, parentResource, property.predicate);
-                       if(error != null) {
-                           LOGGER.error(error);
-                               //throw new ValidationException(error);
+                       if(Development.<Boolean>getProperty(DevelopmentKeys.L0_VALIDATION, Bindings.BOOLEAN)) {
+                               String error = L0Validations.checkValueType(graph, parentResource, property.predicate);
+                               if(error != null) {
+                                   LOGGER.error(error);
+                                       throw new ValidationException(error);
+                               }
                        }
                }
                
@@ -140,18 +143,22 @@ public class StandardGraphPropertyVariable extends AbstractPropertyVariable {
                        return getValue(graph);         
 
                if(Development.DEVELOPMENT) {
-                       String error = L0Validations.checkValueType(graph, parentResource, property.predicate);
-                       if(error != null) {
-                           LOGGER.error(error);
-                               throw new ValidationException(error);
+                       if(Development.<Boolean>getProperty(DevelopmentKeys.L0_VALIDATION, Bindings.BOOLEAN)) {
+                               String error = L0Validations.checkValueType(graph, parentResource, property.predicate);
+                               if(error != null) {
+                                       LOGGER.error(error);
+                                       throw new ValidationException(error);
+                               }
                        }
                }
         
                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);
                }
@@ -177,10 +184,12 @@ public class StandardGraphPropertyVariable extends AbstractPropertyVariable {
        public void setValue(WriteGraph graph, Object value, Binding binding) throws DatabaseException {
                
                if(Development.DEVELOPMENT) {
-                       String error = L0Validations.checkValueType(graph, parentResource, property.predicate);
-                       if(error != null) {
-                           LOGGER.error(error);
-                               //throw new ValidationException(error);
+                       if(Development.<Boolean>getProperty(DevelopmentKeys.L0_VALIDATION, Bindings.BOOLEAN)) {
+                               String error = L0Validations.checkValueType(graph, parentResource, property.predicate);
+                               if(error != null) {
+                                       LOGGER.error(error);
+                                       throw new ValidationException(error);
+                               }
                        }
                }
                
@@ -192,10 +201,12 @@ public class StandardGraphPropertyVariable extends AbstractPropertyVariable {
        public void setValue(WriteGraph graph, Object value) throws DatabaseException {
                
                if(Development.DEVELOPMENT) {
-                       String error = L0Validations.checkValueType(graph, parentResource, property.predicate);
-                       if(error != null) {
-                           LOGGER.error(error);
-                               throw new ValidationException(error);
+                       if(Development.<Boolean>getProperty(DevelopmentKeys.L0_VALIDATION, Bindings.BOOLEAN)) {
+                               String error = L0Validations.checkValueType(graph, parentResource, property.predicate);
+                               if(error != null) {
+                                       LOGGER.error(error);
+                                       throw new ValidationException(error);
+                               }
                        }
                }