]> gerrit.simantics Code Review - simantics/interop.git/blobdiff - org.simantics.interop/src/org/simantics/interop/test/GraphComparator.java
Use named Comparator return values for most common cases
[simantics/interop.git] / org.simantics.interop / src / org / simantics / interop / test / GraphComparator.java
index 61d7128c5de031a9d3aa83f5e0756cb8b0ed2b28..052a9a9ee19ad7bce23cba188e2bc923fbd76a2d 100644 (file)
@@ -52,7 +52,7 @@ import org.simantics.utils.datastructures.Pair;
  */
 public class GraphComparator {
        
-       private static final boolean DEBUG = false;
+       private static final boolean DEBUG = true;
 
        private Resource r1;
        private Resource r2;
@@ -152,10 +152,16 @@ public class GraphComparator {
        }
        
        public void addComparableResources(Resource r1, Resource r2) {
+               if (DEBUG)
+                       System.out.println("Preset " + r1 + " = " + r2);
                comparableResources.map(r1, r2);
        }
        
        public void addComparableResources(BijectionMap<Resource, Resource> matching) {
+               if (DEBUG) {
+                       for (Entry<Resource, Resource> entry : matching.getEntries())
+                               System.out.println("Preset " + entry.getKey() + " = " + entry.getValue());
+               }
                comparableResources.addAll(matching);
        }
        
@@ -269,6 +275,11 @@ public class GraphComparator {
                                                // These cases have longer path than one to identified objects.
                                                processUnreliableDeep(unreliableLeft, unreliableRight, objectsLeft, objectsRight);
                                        }
+                                       if (objectsLeft.isEmpty() && unreliableLeft.size() > 0 && unreliableRight.size() > 0) {
+                                               // comparison is ending, but we have still unprocessed unidentified resources left.
+                                               // These cases have longer path than one to identified objects.
+                                               processUnreliableDeep(unreliableLeft, unreliableRight, objectsLeft, objectsRight);
+                                       }
                                }
                        });
                        
@@ -277,8 +288,6 @@ public class GraphComparator {
                }
                for (Statement s : unreliableLeft) {
                        if (!comparableStatements.containsLeft(s))
-                               if (s.getObject().getResourceId() == 303248)
-                                       System.out.println();
                                addDeletion(s);
                }
                for (Statement s : unreliableRight) {
@@ -299,7 +308,8 @@ public class GraphComparator {
                        
                        if (r1.equals(r2))
                                continue;
-                       
+                       if (r1.getResourceId() == 610446L)
+                               System.out.println();
                        if (processedResources.contains(r1))
                                continue;
                        processedResources.add(r1);
@@ -779,7 +789,9 @@ public class GraphComparator {
                                throw new DatabaseException("Comparator error: Trying to map " + left + " to " + right + " while mappings " + left + " to " + comparableResources.getRight(left) + " and " + comparableResources.getLeft(right) + " to " + right + " exist.");
                        } else {
                                if (DEBUG) System.out.println(left + " = " + right);
-                               comparableResources.map(left, right);   
+                               if (left.getResourceId() == 610381L)
+                                       System.out.println();
+                               comparableResources.map(left, right);
                        }
                }
                
@@ -838,6 +850,8 @@ public class GraphComparator {
                if (!changes1Set.contains(s)) {
                        changes1Set.add(s);
                        changes1.add(s);
+                       if (s.getObject().getResourceId() == 532631L)
+                               System.out.println();
                }
        }