From 66e555b0bf0c7eb8d5cdd878715d414c73203e63 Mon Sep 17 00:00:00 2001 From: bjl23 Date: Thu, 8 Apr 2010 15:26:13 +0000 Subject: [PATCH] copying changes to trunk for NIHVIVO-322 'Statements added by SPARQL CONSTRUCTs in the ontology updater are not recorded in the log or added statements file' --- .../ontology/update/OntologyUpdater.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/ontology/update/OntologyUpdater.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/ontology/update/OntologyUpdater.java index 0eac83462..08ff48964 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/ontology/update/OntologyUpdater.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/ontology/update/OntologyUpdater.java @@ -30,6 +30,8 @@ import com.hp.hpl.jena.rdf.model.ModelFactory; import com.hp.hpl.jena.rdf.model.RDFNode; import com.hp.hpl.jena.rdf.model.Resource; import com.hp.hpl.jena.rdf.model.ResourceFactory; +import com.hp.hpl.jena.rdf.model.Statement; +import com.hp.hpl.jena.rdf.model.StmtIterator; import com.hp.hpl.jena.shared.Lock; import edu.cornell.mannlib.vitro.webapp.utils.jena.JenaIngestUtils; @@ -159,8 +161,20 @@ public class OntologyUpdater { aboxModel.enterCriticalSection(Lock.WRITE); try { JenaIngestUtils jiu = new JenaIngestUtils(); - aboxModel.add(jiu.renameBNodes(anonModel, settings.getDefaultNamespace() + "n", - aboxModel)); + Model additions = jiu.renameBNodes(anonModel, settings.getDefaultNamespace() + "n", + aboxModel); + Model actualAdditions = ModelFactory.createDefaultModel(); + StmtIterator stmtIt = additions.listStatements(); + while (stmtIt.hasNext()) { + Statement stmt = stmtIt.nextStatement(); + if (!aboxModel.contains(stmt)) { + actualAdditions.add(stmt); + } + } + aboxModel.add(actualAdditions); + logger.log("Constructed " + actualAdditions.size() + " new " + + "statements using SPARQL CONSTRUCT queries."); + record.recordAdditions(actualAdditions); } finally { aboxModel.leaveCriticalSection(); }