X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.db.layer0%2Fsrc%2Forg%2Fsimantics%2Fdb%2Flayer0%2Fvariable%2FStandardGraphPropertyVariable.java;h=c9214e398c69577da69642536c8b932e67e5bc69;hp=b7eaf075edea1c1e051981662954629f70673cf1;hb=23f635e618eac5952aa6fe400b81c0cb8260ff01;hpb=d971cb77af378e93db25a568319525bd86bf9660 diff --git a/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/variable/StandardGraphPropertyVariable.java b/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/variable/StandardGraphPropertyVariable.java index b7eaf075e..c9214e398 100644 --- a/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/variable/StandardGraphPropertyVariable.java +++ b/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/variable/StandardGraphPropertyVariable.java @@ -21,6 +21,7 @@ import org.simantics.db.exception.DatabaseException; import org.simantics.db.exception.DatatypeNotFoundException; import org.simantics.db.exception.ValidationException; 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.PendingVariableException; import org.simantics.db.layer0.function.All; @@ -100,11 +101,15 @@ public class StandardGraphPropertyVariable extends AbstractPropertyVariable { @Override public String getPossibleLabel(ReadGraph graph) throws DatabaseException { + if (property.predicate == null) + return null; return graph.getPossibleRelatedValue2(property.predicate, graph.getService(Layer0.class).HasLabel, parent, Bindings.STRING); } @Override public String getLabel(ReadGraph graph) throws DatabaseException { + if (property.predicate == null) + throw new NoPredicateResourceException("No predicate resource for property " + getName(graph)); return graph.getRelatedValue2(property.predicate, graph.getService(Layer0.class).HasLabel, parent, Bindings.STRING); } @@ -124,10 +129,12 @@ public class StandardGraphPropertyVariable extends AbstractPropertyVariable { if(Development.DEVELOPMENT) { if(Development.getProperty(DevelopmentKeys.L0_VALIDATION, Bindings.BOOLEAN)) { - String error = L0Validations.checkValueType(graph, parentResource, property.predicate); - if(error != null) { - LOGGER.error(error); - throw new ValidationException(error); + if (property.predicate != null) { + String error = L0Validations.checkValueType(graph, parentResource, property.predicate); + if(error != null) { + LOGGER.error(error); + throw new ValidationException(error); + } } } } @@ -145,10 +152,12 @@ public class StandardGraphPropertyVariable extends AbstractPropertyVariable { if(Development.DEVELOPMENT) { if(Development.getProperty(DevelopmentKeys.L0_VALIDATION, Bindings.BOOLEAN)) { - String error = L0Validations.checkValueType(graph, parentResource, property.predicate); - if(error != null) { - LOGGER.error(error); - throw new ValidationException(error); + if (property.predicate != null) { + String error = L0Validations.checkValueType(graph, parentResource, property.predicate); + if(error != null) { + LOGGER.error(error); + throw new ValidationException(error); + } } } } @@ -183,10 +192,12 @@ public class StandardGraphPropertyVariable extends AbstractPropertyVariable { if(Development.DEVELOPMENT) { if(Development.getProperty(DevelopmentKeys.L0_VALIDATION, Bindings.BOOLEAN)) { - String error = L0Validations.checkValueType(graph, parentResource, property.predicate); - if(error != null) { - LOGGER.error(error); - throw new ValidationException(error); + if (property.predicate != null) { + String error = L0Validations.checkValueType(graph, parentResource, property.predicate); + if(error != null) { + LOGGER.error(error); + throw new ValidationException(error); + } } } } @@ -200,10 +211,12 @@ public class StandardGraphPropertyVariable extends AbstractPropertyVariable { if(Development.DEVELOPMENT) { if(Development.getProperty(DevelopmentKeys.L0_VALIDATION, Bindings.BOOLEAN)) { - String error = L0Validations.checkValueType(graph, parentResource, property.predicate); - if(error != null) { - LOGGER.error(error); - throw new ValidationException(error); + if (property.predicate != null) { + String error = L0Validations.checkValueType(graph, parentResource, property.predicate); + if(error != null) { + LOGGER.error(error); + throw new ValidationException(error); + } } } } @@ -324,11 +337,15 @@ public class StandardGraphPropertyVariable extends AbstractPropertyVariable { @Override public Variable getPredicate(ReadGraph graph) throws DatabaseException { + if (property.predicate == null) + throw new MissingVariableException("No predicate for property " + getName(graph)); return Variables.getVariable(graph, graph.getURI(property.predicate)); } @Override public Resource getPredicateResource(ReadGraph graph) throws DatabaseException { + if (property.predicate == null) + throw new NoPredicateResourceException("No predicate for property " + getName(graph)); return property.predicate; }