incremental development of release 1.2 knowledge base migration.
This commit is contained in:
parent
446b4474de
commit
d1f000c772
2 changed files with 26 additions and 14 deletions
|
@ -7,6 +7,7 @@ import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.hp.hpl.jena.ontology.DatatypeProperty;
|
||||||
import com.hp.hpl.jena.ontology.OntClass;
|
import com.hp.hpl.jena.ontology.OntClass;
|
||||||
import com.hp.hpl.jena.ontology.OntModel;
|
import com.hp.hpl.jena.ontology.OntModel;
|
||||||
import com.hp.hpl.jena.ontology.OntModelSpec;
|
import com.hp.hpl.jena.ontology.OntModelSpec;
|
||||||
|
@ -297,8 +298,7 @@ public class ABoxUpdater {
|
||||||
OntClass deletedClass = oldTboxModel.getOntClass(change.getSourceURI());
|
OntClass deletedClass = oldTboxModel.getOntClass(change.getSourceURI());
|
||||||
|
|
||||||
if (deletedClass == null) {
|
if (deletedClass == null) {
|
||||||
logger.logError("didn't find the deleted class " +
|
logger.log("WARNING: didn't find the deleted class " + change.getSourceURI() + " in the old model. Skipping updates for this deletion");
|
||||||
change.getSourceURI() + " in the old model.");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -309,6 +309,7 @@ public class ABoxUpdater {
|
||||||
namedClassList.add(ontClass);
|
namedClassList.add(ontClass);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
OntClass parent = (!namedClassList.isEmpty())
|
OntClass parent = (!namedClassList.isEmpty())
|
||||||
? namedClassList.get(0)
|
? namedClassList.get(0)
|
||||||
: OWL_THING;
|
: OWL_THING;
|
||||||
|
@ -317,11 +318,16 @@ public class ABoxUpdater {
|
||||||
|
|
||||||
while (replacementClass == null) {
|
while (replacementClass == null) {
|
||||||
parent = parent.getSuperClass();
|
parent = parent.getSuperClass();
|
||||||
|
|
||||||
|
if (parent == null) {
|
||||||
|
replacementClass = OWL_THING;
|
||||||
|
} else {
|
||||||
replacementClass = newTboxModel.getOntClass(parent.getURI());
|
replacementClass = newTboxModel.getOntClass(parent.getURI());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//log summary of changes
|
//log summary of changes
|
||||||
logger.log("Class " + deletedClass.getURI() + " has been deleted. Any references to it in the knowledge base will be changed to " + replacementClass.getURI());
|
logger.log("Class " + deletedClass.getURI() + " has been deleted. Any references to it in the knowledge base have been changed to " + replacementClass.getURI());
|
||||||
|
|
||||||
AtomicOntologyChange chg = new AtomicOntologyChange(deletedClass.getURI(), replacementClass.getURI(), AtomicChangeType.RENAME, change.getNotes());
|
AtomicOntologyChange chg = new AtomicOntologyChange(deletedClass.getURI(), replacementClass.getURI(), AtomicChangeType.RENAME, change.getNotes());
|
||||||
renameClass(chg);
|
renameClass(chg);
|
||||||
|
@ -407,20 +413,26 @@ public class ABoxUpdater {
|
||||||
"a new subproperty " + propObj.getDestinationURI() +
|
"a new subproperty " + propObj.getDestinationURI() +
|
||||||
" in the new ontology version. ");
|
" in the new ontology version. ");
|
||||||
logger.log("Please review uses of this property to see if " + propObj.getDestinationURI() + " is a more appropriate choice.");
|
logger.log("Please review uses of this property to see if " + propObj.getDestinationURI() + " is a more appropriate choice.");
|
||||||
}*/
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
private void deleteProperty(AtomicOntologyChange propObj) throws IOException{
|
private void deleteProperty(AtomicOntologyChange propObj) throws IOException{
|
||||||
|
|
||||||
OntProperty deletedProperty = oldTboxModel.getOntProperty(propObj.getSourceURI());
|
OntProperty deletedProperty = oldTboxModel.getOntProperty(propObj.getSourceURI());
|
||||||
|
|
||||||
if (deletedProperty == null) {
|
if (deletedProperty == null && "Prop".equals(propObj.getNotes())) {
|
||||||
logger.logError("expected to find property "
|
deletedProperty = (ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM)).createOntProperty(propObj.getSourceURI());
|
||||||
+ propObj.getSourceURI() + " in oldTBoxModel");
|
}
|
||||||
|
|
||||||
|
if (deletedProperty == null ) {
|
||||||
|
logger.log("WARNING: didn't find deleted property " + propObj.getSourceURI() + " in oldTBoxModel");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
OntProperty replacementProperty = null;
|
OntProperty replacementProperty = null;
|
||||||
OntProperty parent = deletedProperty.getSuperProperty();
|
OntProperty parent = deletedProperty.getSuperProperty();
|
||||||
|
|
||||||
if (parent != null) {
|
if (parent != null) {
|
||||||
replacementProperty = newTboxModel.getOntProperty(parent.getURI());
|
replacementProperty = newTboxModel.getOntProperty(parent.getURI());
|
||||||
|
|
||||||
|
@ -436,10 +448,10 @@ public class ABoxUpdater {
|
||||||
Model deletePropModel = ModelFactory.createDefaultModel();
|
Model deletePropModel = ModelFactory.createDefaultModel();
|
||||||
|
|
||||||
if (replacementProperty == null) {
|
if (replacementProperty == null) {
|
||||||
|
|
||||||
aboxModel.enterCriticalSection(Lock.WRITE);
|
aboxModel.enterCriticalSection(Lock.WRITE);
|
||||||
try {
|
try {
|
||||||
deletePropModel.add(aboxModel.listStatements(
|
deletePropModel.add(aboxModel.listStatements((Resource) null, deletedProperty, (RDFNode) null));
|
||||||
(Resource) null, deletedProperty, (RDFNode) null));
|
|
||||||
aboxModel.remove(deletePropModel);
|
aboxModel.remove(deletePropModel);
|
||||||
} finally {
|
} finally {
|
||||||
aboxModel.leaveCriticalSection();
|
aboxModel.leaveCriticalSection();
|
||||||
|
|
|
@ -91,7 +91,7 @@ public class OntologyUpdater {
|
||||||
AtomicOntologyChangeLists changes = new AtomicOntologyChangeLists(rawChanges,settings.getNewTBoxModel(),settings.getOldTBoxModel());
|
AtomicOntologyChangeLists changes = new AtomicOntologyChangeLists(rawChanges,settings.getNewTBoxModel(),settings.getOldTBoxModel());
|
||||||
|
|
||||||
//process the TBox before the ABox
|
//process the TBox before the ABox
|
||||||
//TODO: uncomment updateTBoxAnnotations(); 12/27/2010 - commented out just for testing abox updater
|
updateTBoxAnnotations();
|
||||||
|
|
||||||
updateABox(changes);
|
updateABox(changes);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue