From: Antti Villberg Date: Mon, 26 Aug 2019 07:28:35 +0000 (+0300) Subject: Improved constraint modelling utilities X-Git-Tag: v1.43.0~136^2~92^2 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F56%2F3156%2F1;p=simantics%2Fplatform.git Improved constraint modelling utilities gitlab #348 Change-Id: If1409441816c3d29b9f87829be965bda19f5280f --- diff --git a/bundles/org.simantics.db.common/src/org/simantics/db/common/validation/L0Validations.java b/bundles/org.simantics.db.common/src/org/simantics/db/common/validation/L0Validations.java index 99ef91b7a..1ff6e5fbc 100644 --- a/bundles/org.simantics.db.common/src/org/simantics/db/common/validation/L0Validations.java +++ b/bundles/org.simantics.db.common/src/org/simantics/db/common/validation/L0Validations.java @@ -12,7 +12,7 @@ import org.simantics.scl.compiler.types.Type; public class L0Validations { public static String checkValueType(ReadGraph graph, Resource subject, Resource predicate) throws DatabaseException { - + if (subject == null) return null; if (predicate == null) @@ -25,9 +25,34 @@ public class L0Validations { String valueTypeText = graph.getPossibleRelatedValue(predicate, L0.RequiresValueType, Bindings.STRING); if(valueTypeText != null) { Type valueType = CommonDBUtils.getSCLType(graph, subject, valueTypeText); + if(valueType == null) { + Resource range = graph.getPossibleObject(predicate, L0.HasRange); + if(range != null) { + return null; + } else { + StringBuilder sb = new StringBuilder() + .append("The value type ") + .append(valueType) + .append(" of predicate ") + .append(NameUtils.getSafeName(graph, predicate, true)) + .append(" cannot be resolved.") + .append(NameUtils.getSafeName(graph, object, true)) + .append("."); + return sb.toString(); + } + } String valueTypeText2 = graph.getPossibleRelatedValue(object, L0.HasValueType, Bindings.STRING); if(valueTypeText2 != null) { Type valueType2 = CommonDBUtils.getSCLType(graph, subject, valueTypeText2); + if(valueType2 == null) { + StringBuilder sb = new StringBuilder() + .append("The value type ") + .append(valueType2) + .append(" of object ") + .append(NameUtils.getSafeName(graph, object, true)) + .append(" cannot be resolved."); + return sb.toString(); + } if(!valueType.equals(valueType2)) { StringBuilder sb = new StringBuilder() .append("The value type ") @@ -44,9 +69,9 @@ public class L0Validations { } } } - + return null; - + } - + }