merging in 1.1 branch changes
This commit is contained in:
parent
8bef6badf4
commit
802e5bc1ab
3 changed files with 88 additions and 33 deletions
|
@ -267,7 +267,7 @@ public class ABoxUpdater {
|
|||
|
||||
if (count > 0) {
|
||||
//TODO - take out the detailed logging after our internal testing is completed.
|
||||
logger.log("There " + ((count > 1) ? "are" : "is") + " " + count + " individuals in the model that are of type " + parentOfAddedClass.getURI() + "," +
|
||||
logger.log("There " + ((count > 1) ? "are" : "is") + " " + count + " individual" + ((count > 1) ? "s" : "") + " in the model that " + ((count > 1) ? "are" : "is") + " of type " + parentOfAddedClass.getURI() + "," +
|
||||
" and a new subclass of that class has been added: " + addedClass.getURI() + ". " +
|
||||
"Please review " + ((count > 1) ? "these" : "this") + " individual" + ((count > 1) ? "s" : "") + " to see whether " + ((count > 1) ? "they" : "it") + " should be of type: " + addedClass.getURI() );
|
||||
}
|
||||
|
|
|
@ -81,6 +81,7 @@ public class OntologyUpdater {
|
|||
private void performUpdate() throws IOException {
|
||||
|
||||
performSparqlConstructAdditions(settings.getSparqlConstructAdditionsDir(), settings.getOntModelSelector().getABoxModel());
|
||||
performSparqlConstructRetractions(settings.getSparqlConstructDeletionsDir(), settings.getOntModelSelector().getABoxModel());
|
||||
|
||||
List<AtomicOntologyChange> rawChanges = getAtomicOntologyChanges();
|
||||
|
||||
|
@ -128,9 +129,38 @@ public class OntologyUpdater {
|
|||
aboxModel.leaveCriticalSection();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void performSparqlConstructRetractions(String sparqlConstructDir, OntModel aboxModel) throws IOException {
|
||||
|
||||
Model retractions = performSparqlConstructs(sparqlConstructDir, aboxModel);
|
||||
|
||||
if (retractions == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
aboxModel.enterCriticalSection(Lock.WRITE);
|
||||
try {
|
||||
Model actualRetractions = ModelFactory.createDefaultModel();
|
||||
StmtIterator stmtIt = retractions.listStatements();
|
||||
while (stmtIt.hasNext()) {
|
||||
Statement stmt = stmtIt.nextStatement();
|
||||
if (aboxModel.contains(stmt)) {
|
||||
actualRetractions.add(stmt);
|
||||
}
|
||||
}
|
||||
aboxModel.remove(actualRetractions);
|
||||
if (actualRetractions.size() > 0) {
|
||||
logger.log("Removed " + actualRetractions.size() + " statement"
|
||||
+ ((actualRetractions.size() > 1) ? "s" : "") +
|
||||
" using SPARQL CONSTRUCT queries.");
|
||||
}
|
||||
record.recordRetractions(actualRetractions);
|
||||
} finally {
|
||||
aboxModel.leaveCriticalSection();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs a set of arbitrary SPARQL CONSTRUCT queries on the
|
||||
|
|
|
@ -31,6 +31,7 @@ public class TBoxUpdater {
|
|||
private OntModel siteModel;
|
||||
private OntologyChangeLogger logger;
|
||||
private OntologyChangeRecord record;
|
||||
private boolean detailLogs = false;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -160,31 +161,53 @@ public class TBoxUpdater {
|
|||
continue;
|
||||
}
|
||||
|
||||
// If a subject-property pair occurs in the old annotation TBox and the new annotations
|
||||
// TBox, but not in the site model, then it is considered an erroneous deletion and
|
||||
// the value from the new TBox is added into the site model.
|
||||
// sjm: 7-16-2010. We want this here now to add back in annotations mistakenly dropped
|
||||
// in the .9 to 1.0 migration, but I'm not sure we would want this here permanently.
|
||||
// Shouldn't a site be allowed to delete annotations if they want to?
|
||||
|
||||
NodeIterator siteObjects = siteModel.listObjectsOfProperty(subject,predicate);
|
||||
|
||||
if (siteObjects == null || !siteObjects.hasNext()) {
|
||||
try {
|
||||
additions.add(subject, predicate, newObject);
|
||||
|
||||
if (detailLogs) {
|
||||
logger.log( "adding Statement: subject = " + subject.getURI() +
|
||||
" property = " + predicate.getURI() +
|
||||
" object = " + (newObject.isLiteral() ? ((Literal)newObject).getLexicalForm()
|
||||
: ((Resource)newObject).getURI()));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.logError("Error trying to add statement with property " + predicate.getURI() +
|
||||
" of class = " + subject.getURI() + " in the knowledge base:\n" + e.getMessage());
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if (!newObject.equals(oldObject)) {
|
||||
NodeIterator siteObjects = siteModel.listObjectsOfProperty(subject,predicate);
|
||||
|
||||
RDFNode siteObject = null;
|
||||
RDFNode siteObject = siteObjects.next();
|
||||
|
||||
if (siteObjects != null && siteObjects.hasNext()) {
|
||||
|
||||
siteObject = siteObjects.next();
|
||||
|
||||
i = 1;
|
||||
while (siteObjects.hasNext()) {
|
||||
i++;
|
||||
siteObjects.next();
|
||||
}
|
||||
|
||||
if (i > 1) {
|
||||
logger.log("WARNING: found " + i +
|
||||
" statements with subject = " + subject.getURI() +
|
||||
" and property = " + predicate.getURI() +
|
||||
" in the site annotations model. (maximum of one is expected). ");
|
||||
continue;
|
||||
}
|
||||
i = 1;
|
||||
while (siteObjects.hasNext()) {
|
||||
i++;
|
||||
siteObjects.next();
|
||||
}
|
||||
|
||||
if (siteObject == null || siteObject.equals(oldObject)) {
|
||||
if (i > 1) {
|
||||
logger.log("WARNING: found " + i +
|
||||
" statements with subject = " + subject.getURI() +
|
||||
" and property = " + predicate.getURI() +
|
||||
" in the site annotations model. (maximum of one is expected). ");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (siteObject.equals(oldObject)) {
|
||||
try {
|
||||
StmtIterator it = siteModel.listStatements(subject, predicate, (RDFNode)null);
|
||||
while (it.hasNext()) {
|
||||
|
@ -199,13 +222,15 @@ public class TBoxUpdater {
|
|||
try {
|
||||
additions.add(subject, predicate, newObject);
|
||||
|
||||
logger.log("Changed the value of property " + predicate.getURI() +
|
||||
if (detailLogs) {
|
||||
logger.log("Changed the value of property " + predicate.getURI() +
|
||||
" of subject = " + subject.getURI() +
|
||||
" from " +
|
||||
(oldObject.isResource() ? ((Resource)oldObject).getURI() : ((Literal)oldObject).getLexicalForm()) +
|
||||
" to " +
|
||||
(newObject.isResource() ? ((Resource)newObject).getURI() : ((Literal)newObject).getLexicalForm()) +
|
||||
" in the knowledge base:\n");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.logError("Error trying to change the value of property " + predicate.getURI() +
|
||||
" of class = " + subject.getURI() + " in the knowledge base:\n" + e.getMessage());
|
||||
|
@ -230,7 +255,7 @@ public class TBoxUpdater {
|
|||
long numRemoved = actualRetractions.size() - actualAdditions.size();
|
||||
if (numRemoved > 0) {
|
||||
logger.log("Removed " + numRemoved +
|
||||
" superfluous vitro annotation property setting" + ((numRemoved > 1) ? "s" : "") + " from the knowledge base.");
|
||||
" outdated vitro annotation property setting" + ((numRemoved > 1) ? "s" : "") + " from the knowledge base.");
|
||||
}
|
||||
|
||||
// Copy annotation property settings that were introduced in the new ontology
|
||||
|
@ -245,19 +270,19 @@ public class TBoxUpdater {
|
|||
if (!siteModel.contains(stmt)) {
|
||||
newAnnotationSettingsToAdd.add(stmt);
|
||||
|
||||
// TODO remove this for production
|
||||
logger.log( "adding Statement: subject = " + stmt.getSubject().getURI() +
|
||||
" property = " + stmt.getPredicate().getURI() +
|
||||
" object = " + (stmt.getObject().isLiteral() ? ((Literal)stmt.getObject()).getLexicalForm()
|
||||
if (detailLogs) {
|
||||
logger.log( "adding Statement: subject = " + stmt.getSubject().getURI() +
|
||||
" property = " + stmt.getPredicate().getURI() +
|
||||
" object = " + (stmt.getObject().isLiteral() ? ((Literal)stmt.getObject()).getLexicalForm()
|
||||
: ((Resource)stmt.getObject()).getURI()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
siteModel.add(newAnnotationSettingsToAdd);
|
||||
record.recordAdditions(newAnnotationSettingsToAdd);
|
||||
|
||||
// log the additions
|
||||
//summary
|
||||
// log the additions - summary
|
||||
if (newAnnotationSettingsToAdd.size() > 0) {
|
||||
boolean plural = (newAnnotationSettingsToAdd.size() > 1);
|
||||
logger.log("Added " + newAnnotationSettingsToAdd.size() + " new annotation property setting" + (plural ? "s" : "") + " to the knowledge base. This includes " +
|
||||
|
|
Loading…
Add table
Reference in a new issue