Set<KiWiTriple> added = new HashSet<KiWiTriple>();
for(Resource context : contextSet) {
KiWiResource kcontext = valueFactory.convert(context);
KiWiTriple triple = (KiWiTriple)valueFactory.createStatement(ksubj,kpred,kobj,kcontext, databaseConnection);
triple.setInferred(inferred);
if(triple.getId() == null) {
databaseConnection.storeTriple(triple);
triplesAdded = true;
notifyStatementAdded(triple);
} else if(deletedStatementsLog.contains(triple.getId())) {
// this is a hack for a concurrency problem that may occur in case the triple is removed in the
// transaction and then added again; in these cases the createStatement method might return
// an expired state of the triple because it uses its own database connection
databaseConnection.undeleteTriple(triple);