Source:
private void checkUiChangesOverlapWithFileChanges(Model baseModel, Model userModel, Model changesModel) { log.debug("Beginn check if subtractions from Backup-firsttime model to current state of firsttime-files were changed in user-model (via UI)"); Model changesUserModel = userModel.difference(baseModel); List<Statement> changedInUIandFileStatements = new ArrayList<Statement>(); if(!changesUserModel.isEmpty()) { removeBlankTriples(changesUserModel); StringWriter out3 = new StringWriter(); changesUserModel.write(out3, "TTL"); log.debug("There were changes in the user-model via UI which have also changed in the firsttime files, the following triples will not be updated"); StmtIterator iter = changesUserModel.listStatements(); while (iter.hasNext()) { Statement stmt = iter.nextStatement(); Resource subject = stmt.getSubject(); Property predicate = stmt.getPredicate(); RDFNode object = stmt.getObject(); StmtIterator iter2 = changesModel.listStatements(); while (iter2.hasNext()) { Statement stmt2 = iter2.nextStatement(); Resource subject2 = stmt2.getSubject(); Property predicate2 = stmt2.getPredicate(); RDFNode object2 = stmt2.getObject(); if(subject.equals(subject2) && predicate.equals(predicate2) && !object.equals(object2) ) { if (object.isLiteral() && object2.isLiteral()) { if(object.asLiteral().getLanguage().equals(object2.asLiteral().getLanguage())) { log.debug("This two triples changed UI and files: \n UI: " + stmt.toString() + " \n file: " +stmt2.toString()); changedInUIandFileStatements.add(stmt2); } } else { log.debug("This two triples changed UI and files: \n UI: " + stmt.toString() + " \n file: " +stmt2.toString()); changedInUIandFileStatements.add(stmt2); } } } } changesModel.remove(changedInUIandFileStatements); } else { log.debug("There were no changes in the user-model via UI compared to the backup-firsttime-model"); } }

Target:
private void checkUiChangesOverlapWithFileChanges(Model baseModel, Model userModel, Model changesModel) { log.debug("Beginn check if subtractions from Backup-firsttime model to current state of firsttime-files were changed in user-model (via UI)"); Model changesUserModel = userModel.difference(baseModel); List<Statement> changedInUIandFileStatements = new ArrayList<Statement>(); if(!changesUserModel.isEmpty()) { removeBlankTriples(changesUserModel); StringWriter out3 = new StringWriter(); changesUserModel.write(out3, "TTL"); log.debug("There were changes in the user-model via UI which have also changed in the firsttime files, the following triples will not be updated"); StmtIterator iter = changesUserModel.listStatements(); while (iter.hasNext()) { Statement stmt = iter.nextStatement(); Resource subject = stmt.getSubject(); Property predicate = stmt.getPredicate(); RDFNode object = stmt.getObject(); StmtIterator iter2 = changesModel.listStatements(); while (iter2.hasNext()) { Statement stmt2 = iter2.nextStatement(); Resource subject2 = stmt2.getSubject(); Property predicate2 = stmt2.getPredicate(); RDFNode object2 = stmt2.getObject(); if(subject.equals(subject2) && predicate.equals(predicate2) && !object.equals(object2) ) { if (object.isLiteral() && object2.isLiteral()) { if(object.asLiteral().getLanguage().equals(object2.asLiteral().getLanguage())) { log.debug("This two triples changed UI and files: \n UI: " + stmt + " \n file: " +stmt2); changedInUIandFileStatements.add(stmt2); } } else { log.debug("This two triples changed UI and files: \n UI: " + stmt + " \n file: " +stmt2); changedInUIandFileStatements.add(stmt2); } } } } changesModel.remove(changedInUIandFileStatements); } else { log.debug("There were no changes in the user-model via UI compared to the backup-firsttime-model"); } }