NIHVIVO-2804 individuals deleted in error during kb migration
This commit is contained in:
parent
8ad216644b
commit
45ff2441c6
4 changed files with 10 additions and 56 deletions
|
@ -344,46 +344,21 @@ public class ABoxUpdater {
|
|||
|
||||
Model retractions = ModelFactory.createDefaultModel();
|
||||
|
||||
// Remove statements where the deleted class is the subject (e.g. statements with vitro annotation properties as the predicate)
|
||||
aboxModel.enterCriticalSection(Lock.WRITE);
|
||||
try {
|
||||
int count = 0;
|
||||
StmtIterator iter = aboxModel.listStatements(deletedClass, (Property) null, (RDFNode) null);
|
||||
|
||||
while (iter.hasNext()) {
|
||||
Statement oldStatement = iter.next();
|
||||
count++;
|
||||
retractions.add(oldStatement);
|
||||
//logChange(oldStatement, false);
|
||||
}
|
||||
|
||||
if (count > 0) {
|
||||
logger.log("Removed " + count + " subject reference" + ((count > 1) ? "s" : "") + " to the " + deletedClass.getURI() + " class");
|
||||
}
|
||||
} finally {
|
||||
aboxModel.leaveCriticalSection();
|
||||
}
|
||||
|
||||
// Remove instances of the deleted class
|
||||
aboxModel.enterCriticalSection(Lock.WRITE);
|
||||
try {
|
||||
int count = 0;
|
||||
StmtIterator iter = aboxModel.listStatements((Resource) null, RDF.type, deletedClass);
|
||||
int count = 0;
|
||||
StmtIterator iter = aboxModel.listStatements((Resource) null, RDF.type, deletedClass);
|
||||
|
||||
while (iter.hasNext()) {
|
||||
while (iter.hasNext()) {
|
||||
count++;
|
||||
Statement typeStmt = iter.next();
|
||||
retractions.add(typeStmt);
|
||||
|
||||
StmtIterator iter2 = aboxModel.listStatements(typeStmt.getSubject(), (Property) null, (RDFNode) null);
|
||||
while (iter2.hasNext()) {
|
||||
retractions.add(iter2.next());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//log summary of changes
|
||||
if (count > 0) {
|
||||
logger.log("Removed " + count + " instance" + ((count > 1) ? "s" : "") + " of the " + deletedClass.getURI() + " class");
|
||||
logger.log("Removed " + count + " " + deletedClass.getURI() + " type assertion" + ((count > 1) ? "s" : ""));
|
||||
}
|
||||
|
||||
aboxModel.remove(retractions);
|
||||
|
@ -392,30 +367,6 @@ public class ABoxUpdater {
|
|||
} finally {
|
||||
aboxModel.leaveCriticalSection();
|
||||
}
|
||||
|
||||
// Remove other object references to the deleted class - what would these be? nothing, I think.
|
||||
aboxModel.enterCriticalSection(Lock.WRITE);
|
||||
try {
|
||||
int count = 0;
|
||||
StmtIterator iter = aboxModel.listStatements((Resource) null, (Property) null, deletedClass);
|
||||
|
||||
while (iter.hasNext()) {
|
||||
count++;
|
||||
Statement oldStatement = iter.next();
|
||||
retractions.add(oldStatement);
|
||||
//logChange(oldStatement, false);
|
||||
}
|
||||
|
||||
//log summary of changes
|
||||
if (count > 0) {
|
||||
logger.log("Removed " + count + " object reference" + ((count > 1) ? "s" : "") + " to the " + deletedClass.getURI() + " class");
|
||||
}
|
||||
|
||||
aboxModel.remove(retractions);
|
||||
record.recordRetractions(retractions);
|
||||
} finally {
|
||||
aboxModel.leaveCriticalSection();
|
||||
}
|
||||
}
|
||||
|
||||
public void processPropertyChanges(List<AtomicOntologyChange> changes) throws IOException {
|
||||
|
|
|
@ -91,7 +91,7 @@ public class KnowledgeBaseUpdater {
|
|||
|
||||
log.info("\tperforming SPARQL construct additions (abox)");
|
||||
performSparqlConstructAdditions(settings.getSparqlConstructAdditionsDir(), settings.getAssertionOntModelSelector().getABoxModel());
|
||||
log.info("\tperforming SPARQL construct deletions (infenences)");
|
||||
log.info("\tperforming SPARQL construct deletions (inferences)");
|
||||
performSparqlConstructRetractions(settings.getSparqlConstructDeletionsDir(), settings.getInferenceOntModelSelector().getABoxModel());
|
||||
|
||||
List<AtomicOntologyChange> rawChanges = getAtomicOntologyChanges();
|
||||
|
|
|
@ -933,6 +933,7 @@ public class SimpleReasoner extends StatementListener {
|
|||
setMostSpecificTypes(stmt.getSubject(), inferenceRebuildModel);
|
||||
}
|
||||
|
||||
/*
|
||||
log.info("Computing property-based ABox inferences");
|
||||
iter = tboxModel.listStatements((Resource) null, RDFS.subPropertyOf, (RDFNode) null);
|
||||
int numStmts = 0;
|
||||
|
@ -974,6 +975,7 @@ public class SimpleReasoner extends StatementListener {
|
|||
log.info("Still computing property-based ABox inferences...");
|
||||
}
|
||||
}
|
||||
*/
|
||||
} catch (Exception e) {
|
||||
log.error("Exception while recomputing ABox inference model", e);
|
||||
inferenceRebuildModel.removeAll(); // don't do this in the finally, it's needed in the case
|
||||
|
@ -985,6 +987,7 @@ public class SimpleReasoner extends StatementListener {
|
|||
inferenceRebuildModel.leaveCriticalSection();
|
||||
}
|
||||
|
||||
|
||||
// reflect the recomputed inferences into the application inference
|
||||
// model.
|
||||
inferenceRebuildModel.enterCriticalSection(Lock.WRITE);
|
||||
|
|
|
@ -245,7 +245,7 @@ public class UpdateKnowledgeBase implements ServletContextListener {
|
|||
|
||||
private static String timestampedFileName(String prefix, String suffix) {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH-mm-sss");
|
||||
return prefix + "." + sdf.format(new Date()) + suffix;
|
||||
return prefix + "." + sdf.format(new Date()) + "." + suffix;
|
||||
}
|
||||
|
||||
private class ModelDirectoryNotFoundException extends RuntimeException {
|
||||
|
|
Loading…
Add table
Reference in a new issue