From 6718dcb0ea746fcdc9234cc66ac50e99b0dadbc4 Mon Sep 17 00:00:00 2001 From: luukkainen Date: Wed, 26 Oct 2011 12:44:20 +0000 Subject: [PATCH] git-svn-id: https://www.simantics.org/svn/simantics/interoperability/trunk@22965 ac1ea38d-2e2b-0410-8846-a27921b304fc --- .../interop/test/GraphComparator.java | 48 +++++-------------- 1 file changed, 12 insertions(+), 36 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 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 { -- 2.47.1