bugfixes for NIHVIVO-177 and NIHVIVO-205

This commit is contained in:
bjl23 2010-04-05 12:37:40 +00:00
parent 40dbf58377
commit c8172a49ea
2 changed files with 16 additions and 11 deletions

View file

@ -159,8 +159,8 @@ public class OntologyUpdater {
aboxModel.enterCriticalSection(Lock.WRITE); aboxModel.enterCriticalSection(Lock.WRITE);
try { try {
JenaIngestUtils jiu = new JenaIngestUtils(); JenaIngestUtils jiu = new JenaIngestUtils();
jiu.renameBNodes(anonModel, settings.getDefaultNamespace() + "n", aboxModel.add(jiu.renameBNodes(anonModel, settings.getDefaultNamespace() + "n",
aboxModel); aboxModel));
} finally { } finally {
aboxModel.leaveCriticalSection(); aboxModel.leaveCriticalSection();
} }

View file

@ -132,21 +132,26 @@ public class UpdateKnowledgeBase implements ServletContextListener {
OntModel applicationMetadataModel = oms.getApplicationMetadataModel(); OntModel applicationMetadataModel = oms.getApplicationMetadataModel();
FileInputStream fis = new FileInputStream(new File(filename)); FileInputStream fis = new FileInputStream(new File(filename));
replacementValues.read(fis, null); replacementValues.read(fis, null);
Model retractions = ModelFactory.createDefaultModel();
Model additions = ModelFactory.createDefaultModel();
StmtIterator replaceIt = replacementValues.listStatements(); StmtIterator replaceIt = replacementValues.listStatements();
while (replaceIt.hasNext()) { while (replaceIt.hasNext()) {
Statement replacement = replaceIt.nextStatement(); Statement replacement = replaceIt.nextStatement();
applicationMetadataModel.enterCriticalSection(Lock.WRITE); applicationMetadataModel.enterCriticalSection(Lock.WRITE);
try { try {
Iterator<Resource> resIt = StmtIterator stmtIt =
applicationMetadataModel.listSubjectsWithProperty( applicationMetadataModel.listStatements(
replacement.getPredicate(), replacement.getObject()); (Resource) null, replacement.getPredicate(),
while (resIt.hasNext()) { (RDFNode) null);
Resource subj = resIt.next(); while (stmtIt.hasNext()) {
applicationMetadataModel.removeAll( Statement stmt = stmtIt.nextStatement();
subj, replacement.getPredicate(), (RDFNode) null); retractions.add(stmt);
applicationMetadataModel.add( additions.add(stmt.getSubject(),
subj, replacement.getPredicate(), replacement.getObject()); replacement.getPredicate(),
replacement.getObject());
} }
applicationMetadataModel.remove(retractions);
applicationMetadataModel.add(additions);
} finally { } finally {
applicationMetadataModel.leaveCriticalSection(); applicationMetadataModel.leaveCriticalSection();
} }