From: Tuukka Lehtonen Date: Tue, 30 Oct 2018 11:55:18 +0000 (+0000) Subject: Merge "Fixed invalid comparisons which were identified by Eclipse IDE 2018-09" X-Git-Tag: v1.43.0~136^2~301 X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=commitdiff_plain;h=8c029a9e23802007d0c9701fbfbcca7e6cc16b03;hp=3598f987e691cb4f35ab8f283d4dfd760bcdd410 Merge "Fixed invalid comparisons which were identified by Eclipse IDE 2018-09" --- diff --git a/bundles/org.simantics.modeling/src/org/simantics/modeling/userComponent/ComponentTypeCommands.java b/bundles/org.simantics.modeling/src/org/simantics/modeling/userComponent/ComponentTypeCommands.java index ea4de26b2..74ae599e3 100644 --- a/bundles/org.simantics.modeling/src/org/simantics/modeling/userComponent/ComponentTypeCommands.java +++ b/bundles/org.simantics.modeling/src/org/simantics/modeling/userComponent/ComponentTypeCommands.java @@ -334,12 +334,12 @@ public class ComponentTypeCommands { return; } + Layer0 L0 = Layer0.getInstance(graph); Layer0X L0X = Layer0X.getInstance(graph); boolean hasRequiresDataType = graph.hasStatement(relation, L0X.RequiresDataType); if (hasRequiresDataType) { Datatype dt = graph.getDataType(object); if (dt instanceof NumberType) { - Layer0 L0 = Layer0.getInstance(graph); NumberType nt = (NumberType) Bindings.DATATYPE.cloneUnchecked(dt); nt.setUnit(unit); graph.claimLiteral(object, L0.HasDataType, L0.DataType, nt, Bindings.DATATYPE); @@ -348,7 +348,11 @@ public class ComponentTypeCommands { } String oldUnit = graph.getPossibleRelatedValue2(relation, L0X.HasUnit, Bindings.STRING); - graph.claimLiteral(relation, L0X.HasUnit, unit, Bindings.STRING); + if (unit != null) { + graph.claimLiteral(relation, L0X.HasUnit, L0.String, unit, Bindings.STRING); + } else { + graph.denyValue(relation, L0X.HasUnit); + } CommentMetadata cm = graph.getMetadata(CommentMetadata.class); graph.addMetadata(cm.add("Set unit from " + oldUnit + " to " + unit + " for component/annotation " + type + " property " + relation));