X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=org.simantics.interop%2Fsrc%2Forg%2Fsimantics%2Finterop%2Ftest%2FNameComparator.java;fp=org.simantics.interop%2Fsrc%2Forg%2Fsimantics%2Finterop%2Ftest%2FNameComparator.java;h=5bdb3f041f55f954f271059ee93864185b7bfa00;hb=4399a40e11996b9a373f522af995a19a05493dd3;hp=abc2ab2cbd29263538d869b719416c53c189fb0c;hpb=65dc4008773b79bd9672956204512fb87edb4f23;p=simantics%2Finterop.git diff --git a/org.simantics.interop/src/org/simantics/interop/test/NameComparator.java b/org.simantics.interop/src/org/simantics/interop/test/NameComparator.java index abc2ab2..5bdb3f0 100644 --- a/org.simantics.interop/src/org/simantics/interop/test/NameComparator.java +++ b/org.simantics.interop/src/org/simantics/interop/test/NameComparator.java @@ -3,6 +3,8 @@ package org.simantics.interop.test; import org.simantics.db.ReadGraph; import org.simantics.db.Resource; import org.simantics.db.exception.DatabaseException; +import org.simantics.db.exception.ManyObjectsForFunctionalRelationException; +import org.simantics.db.exception.ServiceException; import org.simantics.layer0.Layer0; /** @@ -21,18 +23,22 @@ public class NameComparator extends TypeComparator { if (!compareType(g,o1, o2)) { return Integer.MAX_VALUE; } + if(!compareName(g, o1, o2)) + return Integer.MAX_VALUE; + + return propsDiffCount(g,o1, o2); + } + + protected boolean compareName(ReadGraph g, Resource o1, Resource o2) throws ManyObjectsForFunctionalRelationException, ServiceException { Layer0 l0 = Layer0.getInstance(g); String n1 = g.getPossibleRelatedValue(o1, l0.HasName); String n2 = g.getPossibleRelatedValue(o2, l0.HasName); - if (n1 != null && n2 != null) { - if (!n1.equals(n2)) - return Integer.MAX_VALUE; - } else if (n1 == null && n2 == null) { + if (n1 != null && n2 != null) + return n1.equals(n2); + if (n1 == null && n2 == null) + return true; + return false; - } else { - return Integer.MAX_VALUE; - } - return propsDiffCount(g,o1, o2); } }