From cbe654a30ed5bf36e97175df117a22a0174f6a33 Mon Sep 17 00:00:00 2001 From: luukkainen Date: Thu, 29 Sep 2011 12:18:03 +0000 Subject: [PATCH] git-svn-id: https://www.simantics.org/svn/simantics/interoperability/trunk@22479 ac1ea38d-2e2b-0410-8846-a27921b304fc --- .../interop/test/GraphComparator.java | 88 ++++++++----------- 1 file changed, 38 insertions(+), 50 deletions(-) diff --git a/org.simantics.interop/src/org/simantics/interop/test/GraphComparator.java b/org.simantics.interop/src/org/simantics/interop/test/GraphComparator.java index 163dda4..3c59b50 100644 --- a/org.simantics.interop/src/org/simantics/interop/test/GraphComparator.java +++ b/org.simantics.interop/src/org/simantics/interop/test/GraphComparator.java @@ -626,7 +626,6 @@ public class GraphComparator { } } js++; - } } @@ -678,7 +677,6 @@ public class GraphComparator { i2 += same2; } - } } @@ -773,10 +771,8 @@ public class GraphComparator { Statement s2 = ss2.get(i2+off2); if (objectsLeft != null) { - - objectsLeft.add(s1.getObject()); - objectsRight.add(s2.getObject()); - + objectsLeft.add(s1.getObject()); + objectsRight.add(s2.getObject()); } comparableStatements.map(s1, s2); //comparableResources.map(s1.getObject(), s2.getObject()); @@ -852,8 +848,6 @@ public class GraphComparator { ss1.addAll(g.getStatements(r1, b.HasProperty)); ss2.addAll(g.getStatements(r2, b.HasProperty)); sortStatement(ss1, ss2); -// Collections.sort(ss1, scomp); -// Collections.sort(ss2, scomp); int i1 = 0; int i2 = 0; @@ -882,47 +876,46 @@ public class GraphComparator { Statement s2 = ss2.get(i2); int c = scomp.compare(s1, s2); switch (c) { - case 0:{ - boolean b1 = g.hasValue(s1.getObject()); - boolean b2 = g.hasValue(s2.getObject()); - if (b1 == b2) { - if (b1) { - Object v1 = g.getValue(s1.getObject()); - Object v2 = g.getValue(s2.getObject()); - boolean eq = compareValue(v1, v2); - if (!eq) { - addModification(s1, s2); - comparableStatements.map(s1, s2); - comparableResources.map(s1.getObject(),s2.getObject()); + case 0:{ + boolean b1 = g.hasValue(s1.getObject()); + boolean b2 = g.hasValue(s2.getObject()); + if (b1 == b2) { + if (b1) { + Object v1 = g.getValue(s1.getObject()); + Object v2 = g.getValue(s2.getObject()); + boolean eq = compareValue(v1, v2); + if (!eq) { + addModification(s1, s2); + comparableStatements.map(s1, s2); + comparableResources.map(s1.getObject(),s2.getObject()); + } + } else { + compareProps(s1.getObject(), s2.getObject()); } } else { - compareProps(s1.getObject(), s2.getObject()); + addModification(s1, s2); + comparableStatements.map(s1, s2); + comparableResources.map(s1.getObject(),s2.getObject()); } - } else { - addModification(s1, s2); - comparableStatements.map(s1, s2); - comparableResources.map(s1.getObject(),s2.getObject()); + i1++; + i2++; + break; + } + case -1:{ + System.out.println("Compare Prop diff1s " + printStatement(g,s1)); + addDeletion(s1); + i1++; + break; + } + + case 1:{ + System.out.println("Compare Prop diff2s " + printStatement(g,s2)); + addAddition(s2); + i2++; + break; } - i1++; - i2++; - break; - } - case -1:{ - System.out.println("Compare Prop diff1s " + printStatement(g,s1)); - addDeletion(s1); - i1++; - break; - } - - case 1:{ - System.out.println("Compare Prop diff2s " + printStatement(g,s2)); - addAddition(s2); - i2++; - break; - } } - - + } ss1.clear(); @@ -930,7 +923,6 @@ public class GraphComparator { } - public static boolean compareValue(Object v1, Object v2) { if (v1 instanceof Object[] && v2 instanceof Object[]) return Arrays.deepEquals((Object[])v1, (Object[])v2); @@ -951,7 +943,6 @@ public class GraphComparator { } - public class PredicateComparator implements Comparator { @Override public int compare(Statement o1, Statement o2) { @@ -1010,8 +1001,6 @@ public class GraphComparator { } } - - public class ResComparator implements Comparator { @Override public int compare(Resource o1, Resource o2) { @@ -1024,6 +1013,5 @@ public class GraphComparator { return 0; } } - - + } -- 2.47.1