X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=org.simantics.interop%2Fsrc%2Forg%2Fsimantics%2Finterop%2Ftest%2FGraphComparator.java;fp=org.simantics.interop%2Fsrc%2Forg%2Fsimantics%2Finterop%2Ftest%2FGraphComparator.java;h=ab0d437f496cbca99041ef14aeb2c0f6ca5ec169;hb=6718dcb0ea746fcdc9234cc66ac50e99b0dadbc4;hp=ab9c67943d481fce82f8f64a73217790341c7ae8;hpb=240c4a4d8efbb302feedccac76edd5c28d6d7150;p=simantics%2Finterop.git 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 ab9c679..ab0d437 100644 --- a/org.simantics.interop/src/org/simantics/interop/test/GraphComparator.java +++ b/org.simantics.interop/src/org/simantics/interop/test/GraphComparator.java @@ -68,7 +68,7 @@ public class GraphComparator { private BijectionMap comparableStatements = new BijectionMap(); private BijectionMap comparableResources = new BijectionMap(); - + private Set processedResources = new HashSet(); private ResourceComparator comparator; @@ -160,12 +160,6 @@ public class GraphComparator { strong.addAll(rels); } - public void clearRels() { - traversed.clear(); - tested.clear(); - nonTraversed.clear(); - nonTested.clear(); - } public void test(ReadGraph g) throws DatabaseException { this.g = g; @@ -177,9 +171,6 @@ public class GraphComparator { objectsLeft.push(r1); objectsRight.push(r2); - - - Set unreliableLeft = new HashSet(); Set unreliableRight = new HashSet(); @@ -221,23 +212,17 @@ public class GraphComparator { Resource r1 = objectsLeft.pop(); Resource r2 = objectsRight.pop(); -// if (r1.getResourceId() == 42543612 || -// r1.getResourceId() == 42729524 || -// r1.getResourceId() == 42729506) { -// System.out.println("test " + r1 + " " + r2); -// } - if (r1.equals(r2)) continue; - - if (comparableResources.contains(r1, r2)) { - //System.out.println("already tested " + NameUtils.getSafeName(g, r1) + " " + NameUtils.getSafeName(g, r2)); + + if (processedResources.contains(r1)) continue; - } - if (comparableResources.containsLeft(r1) || comparableResources.containsRight(r2)) { + processedResources.add(r1); + + + if(!comparableResources.contains(r1, r2) && (comparableResources.containsLeft(r1)||comparableResources.containsRight(r2))) { throw new DatabaseException("Comparator error: Trying to map " + r1 + " to " + r2 + " while mappings " + r1 + " to " + comparableResources.getRight(r1) + " and " + comparableResources.getLeft(r2) + " to " + r2 + " exist."); } - comparableResources.map(r1, r2); //System.out.println("test " + NameUtils.getSafeName(g, r1) + " " + NameUtils.getSafeName(g, r2)); compareProps(r1, r2); @@ -329,9 +314,6 @@ public class GraphComparator { } for (Resource ol : objectLeft.getKeys()) { -// if (ol.getResourceId() == 42729506) { -// System.out.println(); -// } // all statements to the left side object List left = objectLeft.getValues(ol); // all subjects that have statements to the left side object (ol) @@ -462,7 +444,7 @@ public class GraphComparator { List right = matchingOR.getValues(or); Pair indices = matchingStatements.get(or); - //comparableResources.map(ol, or); + comparableResources.map(ol, or); objectsLeft.add(ol); objectsRight.add(or); for (int l = 0; l < left.size(); l++) { @@ -538,13 +520,14 @@ public class GraphComparator { Resource or = matchingPaths.keySet().iterator().next(); objectsLeft.add(ol); objectsRight.add(or); + comparableResources.map(ol, or); Collection statementsLeft = objectLeft.getValues(ol); Collection statementsRight = objectRight.getValues(or); unreliableLeft.removeAll(statementsLeft); unreliableRight.removeAll(statementsRight); - System.out.println(); + System.out.println("Compare not implemented"); } else { - System.out.println(); + System.out.println("Compare not implemented"); } } } @@ -606,15 +589,8 @@ public class GraphComparator { } private void addComparable(Statement left, Statement right, boolean process) { -// if (left.getObject().getResourceId() == 42543612 || -// left.getObject().getResourceId() == 42729524 || -// left.getObject().getResourceId() == 42729506) { -// System.out.println("test " + r1 + " " + r2); -// } comparableStatements.map(left, right); - if (!process) { - comparableResources.map(left.getObject(), right.getObject()); - } + comparableResources.map(left.getObject(), right.getObject()); } public List filterAsserted(Resource r, Collection in) throws ServiceException {