Source:
private boolean applyChanges(Model baseModel, Model newModel, Model userModel, String modelIdString) { boolean updatedFiles = false; StringWriter out = new StringWriter(); StringWriter out2 = new StringWriter(); Model difOldNew = baseModel.difference(newModel); Model difNewOld = newModel.difference(baseModel); if(modelIdString.equals("applicationMetadata")) { Property p = userModel.createProperty("<LINK_0>", "rootTab"); difOldNew.removeAll(null, p, null); difNewOld.removeAll(null, p, null); } if (difOldNew.isEmpty() && difNewOld.isEmpty()) { log.debug("For the " + modelIdString + " model, there is no difference in both directions. So do nothing."); } else { if (!difOldNew.isEmpty()) { difOldNew.write(out, "TTL"); log.debug("Difference for " + modelIdString + " (old -> new), these triples should be removed: " + out.toStringtoString()); checkUiChangesOverlapWithFileChanges(baseModel, userModel, difOldNew); if (userModel.containsAny(difOldNew)) { log.debug("Some of these triples are in the user triples store, so they will be removed now"); userModel.remove(difOldNew); updatedFiles = true; } baseModel.remove(difOldNew); } if (!difNewOld.isEmpty()) { difNewOld.write(out2, "TTL"); log.debug("Difference for " + modelIdString + " (new -> old), these triples should be added: " + out2); checkUiChangesOverlapWithFileChanges(baseModel, userModel, difNewOld); if (!userModel.containsAll(difNewOld)) { log.debug("Some of these triples are not in the user triples store, so they will be added now"); Model tmp = difNewOld.difference(userModel); userModel.add(tmp); updatedFiles = true; } baseModel.add(difNewOld); } } return updatedFiles; }

Target:
private boolean applyChanges(Model baseModel, Model newModel, Model userModel, String modelIdString) { boolean updatedFiles = false; StringWriter out = new StringWriter(); StringWriter out2 = new StringWriter(); Model difOldNew = baseModel.difference(newModel); Model difNewOld = newModel.difference(baseModel); if(modelIdString.equals("applicationMetadata")) { Property p = userModel.createProperty("<LINK_0>", "rootTab"); difOldNew.removeAll(null, p, null); difNewOld.removeAll(null, p, null); } if (difOldNew.isEmpty() && difNewOld.isEmpty()) { log.debug("For the " + modelIdString + " model, there is no difference in both directions. So do nothing."); } else { if (!difOldNew.isEmpty()) { difOldNew.write(out, "TTL"); log.debug("Difference for " + modelIdString + " (old -> new), these triples should be removed: " + out); checkUiChangesOverlapWithFileChanges(baseModel, userModel, difOldNew); if (userModel.containsAny(difOldNew)) { log.debug("Some of these triples are in the user triples store, so they will be removed now"); userModel.remove(difOldNew); updatedFiles = true; } baseModel.remove(difOldNew); } if (!difNewOld.isEmpty()) { difNewOld.write(out2, "TTL"); log.debug("Difference for " + modelIdString + " (new -> old), these triples should be added: " + out2); checkUiChangesOverlapWithFileChanges(baseModel, userModel, difNewOld); if (!userModel.containsAll(difNewOld)) { log.debug("Some of these triples are not in the user triples store, so they will be added now"); Model tmp = difNewOld.difference(userModel); userModel.add(tmp); updatedFiles = true; } baseModel.add(difNewOld); } } return updatedFiles; }