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;
@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);
}
if(Development.DEVELOPMENT) {
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);
+ if (property.predicate != null) {
+ String error = L0Validations.checkValueType(graph, parentResource, property.predicate);
+ if(error != null) {
+ LOGGER.error(error);
+ throw new ValidationException(error);
+ }
}
}
}
if(Development.DEVELOPMENT) {
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);
+ if (property.predicate != null) {
+ String error = L0Validations.checkValueType(graph, parentResource, property.predicate);
+ if(error != null) {
+ LOGGER.error(error);
+ throw new ValidationException(error);
+ }
}
}
}
if(Development.DEVELOPMENT) {
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);
+ if (property.predicate != null) {
+ String error = L0Validations.checkValueType(graph, parentResource, property.predicate);
+ if(error != null) {
+ LOGGER.error(error);
+ throw new ValidationException(error);
+ }
}
}
}
if(Development.DEVELOPMENT) {
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);
+ if (property.predicate != null) {
+ String error = L0Validations.checkValueType(graph, parentResource, property.predicate);
+ if(error != null) {
+ LOGGER.error(error);
+ throw new ValidationException(error);
+ }
}
}
}
@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;
}