+ // compare the original and the new model
+ Pair<GraphComparator,String> result3 = getChanges(originalModel,newModel);
+ GraphComparator comparator3 = result3.first;
+ if (result3.second != null)
+ showWarning(result3.second);
+ comparator3.test(getSession());
+ changes3 = comparator3.getChanges();
+ changes3 = getSession().syncRequest(new FilterChangesRead(changes3));
+ }
+
+ Pair<GraphComparator,String> result = getChanges(oldModel,newModel);
+ GraphComparator comparator = result.first;
+ if (result.second != null)
+ showWarning(result.second);
+ if (originalModel != null) {
+ // three-way comparison: use change information to configure
+ // the comparison between the old and the new model.
+
+ // 1. map comparable resources
+ for (Entry<Resource, Resource> origToOld : changes2.getComparable().getEntries()) {
+ Resource oldR = origToOld.getValue();
+ Resource newR = changes3.getComparable().getRight(origToOld.getKey());
+ if (newR != null) {
+ comparator.addComparableResources(oldR, newR);
+ }
+ }
+ // 2. mark removed resources as distinct, so that comparison does not pair them
+ for (Statement s : changes2.getDeletions()) {
+ if (changes3.getComparable().containsLeft(s.getObject()))
+ comparator.addNonMatchedRight(changes3.getComparable().getRight(s.getObject()));
+ }
+
+ for (Statement s : changes3.getDeletions()) {
+ if (changes2.getComparable().containsLeft(s.getObject()))
+ comparator.addNonMatchedLeft(changes2.getComparable().getRight(s.getObject()));
+ }
+ if (uei.isNewDistinct()) {
+ // 3. mark added resources as distinct, so that comparison does not pair them
+ for (Statement s : changes2.getAdditions()) {
+ comparator.addNonMatchedLeft(s.getObject());
+ }
+
+ for (Statement s : changes3.getAdditions()) {
+ comparator.addNonMatchedRight(s.getObject());
+ }
+ }
+ }
+ comparator.test(getSession());
+ changes = comparator.getChanges();
+ changes = getSession().syncRequest(new FilterChangesRead(changes));
+ updateTree = getUpdateTree(changes);
+ updateList = getUpdateList(changes);
+
+ if (originalModel != null) {