incremental development of knowledge base migration for release 1.2
This commit is contained in:
parent
85db1c3ba0
commit
5618118d85
4 changed files with 67 additions and 10 deletions
|
@ -37,13 +37,17 @@ public class DateTimeMigration {
|
||||||
|
|
||||||
private static final String dateTimeURI = "http://vivoweb.org/ontology/core#dateTime";
|
private static final String dateTimeURI = "http://vivoweb.org/ontology/core#dateTime";
|
||||||
private static final String dateTimePrecisionURI = "http://vivoweb.org/ontology/core#dateTimePrecision";
|
private static final String dateTimePrecisionURI = "http://vivoweb.org/ontology/core#dateTimePrecision";
|
||||||
|
private static final String hasTimeIntervalURI = "http://vivoweb.org/ontology/core#hasTimeInterval";
|
||||||
|
private static final String dateTimeIntervalURI = "http://vivoweb.org/ontology/core#dateTimeInterval";
|
||||||
|
|
||||||
private static final String yPrecisionURI = "http://vivoweb.org/ontology/core#yearPrecision";
|
private static final String yPrecisionURI = "http://vivoweb.org/ontology/core#yearPrecision";
|
||||||
private static final String ymPrecisionURI = "http://vivoweb.org/ontology/core#yearMonthPrecision";
|
private static final String ymPrecisionURI = "http://vivoweb.org/ontology/core#yearMonthPrecision";
|
||||||
private static final String ymdPrecisionURI = "http://vivoweb.org/ontology/core#yearMonthDayPrecision";
|
private static final String ymdPrecisionURI = "http://vivoweb.org/ontology/core#yearMonthDayPrecision";
|
||||||
private static final String ymdtPrecisionURI = "http://vivoweb.org/ontology/core#yearMonthDayTimePrecision";
|
private static final String ymdtPrecisionURI = "http://vivoweb.org/ontology/core#yearMonthDayTimePrecision";
|
||||||
|
|
||||||
private DatatypeProperty dateTimeProp = (ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM)).createDatatypeProperty(dateTimeURI);
|
private DatatypeProperty dateTimeProp = (ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM)).createDatatypeProperty(dateTimeURI);
|
||||||
|
private ObjectProperty hasTimeIntervalProp = (ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM)).createObjectProperty(hasTimeIntervalURI);
|
||||||
|
private ObjectProperty dateTimeIntervalProp = (ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM)).createObjectProperty(dateTimeIntervalURI);
|
||||||
private ObjectProperty dateTimePrecisionProp = (ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM)).createObjectProperty(dateTimePrecisionURI);
|
private ObjectProperty dateTimePrecisionProp = (ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM)).createObjectProperty(dateTimePrecisionURI);
|
||||||
|
|
||||||
|
|
||||||
|
@ -65,11 +69,57 @@ public class DateTimeMigration {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Update a knowledge base to align with changes in the Date/Time class
|
* Update the abox to align with changes in the Date/Time class
|
||||||
* and property definitions in the transition from version 1.1 to 1.2.
|
* and property definitions in the transition from version 1.1 to 1.2.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void updateABox() throws IOException {
|
public void updateABox() throws IOException {
|
||||||
|
|
||||||
|
updateAcademicIntervals();
|
||||||
|
updateLiterals();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public void updateAcademicIntervals() throws IOException {
|
||||||
|
|
||||||
|
aboxModel.enterCriticalSection(Lock.WRITE);
|
||||||
|
|
||||||
|
try {
|
||||||
|
Model additions = ModelFactory.createDefaultModel();
|
||||||
|
Model retractions = ModelFactory.createDefaultModel();
|
||||||
|
|
||||||
|
StmtIterator iter = aboxModel.listStatements((Resource) null, hasTimeIntervalProp, (RDFNode) null);
|
||||||
|
|
||||||
|
while (iter.hasNext()) {
|
||||||
|
|
||||||
|
Statement stmt = iter.next();
|
||||||
|
|
||||||
|
Statement stmt2 = aboxModel.getProperty(stmt.getObject().asResource(), dateTimeIntervalProp);
|
||||||
|
|
||||||
|
if (stmt2 != null) {
|
||||||
|
retractions.add(stmt2);
|
||||||
|
additions.add(stmt.getSubject(), dateTimeIntervalProp, stmt2.getObject());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
aboxModel.remove(retractions);
|
||||||
|
record.recordRetractions(retractions);
|
||||||
|
aboxModel.add(additions);
|
||||||
|
record.recordAdditions(additions);
|
||||||
|
|
||||||
|
} finally {
|
||||||
|
aboxModel.leaveCriticalSection();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public void updateLiterals() throws IOException {
|
||||||
|
|
||||||
// note: not handling timezones - they are not expected to be in the 1.1.1 data
|
// note: not handling timezones - they are not expected to be in the 1.1.1 data
|
||||||
DateFormat yearFormat = new SimpleDateFormat("yyyy");
|
DateFormat yearFormat = new SimpleDateFormat("yyyy");
|
||||||
|
|
|
@ -10,6 +10,7 @@ public class OntologyUpdateSettings {
|
||||||
|
|
||||||
private String dataDir;
|
private String dataDir;
|
||||||
private String sparqlConstructAdditionsDir;
|
private String sparqlConstructAdditionsDir;
|
||||||
|
private String sparqlConstructAdditionsPass2Dir;
|
||||||
private String sparqlConstructDeletionsDir;
|
private String sparqlConstructDeletionsDir;
|
||||||
private String askQueryFile;
|
private String askQueryFile;
|
||||||
private String successAssertionsFile;
|
private String successAssertionsFile;
|
||||||
|
@ -35,6 +36,12 @@ public class OntologyUpdateSettings {
|
||||||
public String getSparqlConstructAdditionsDir() {
|
public String getSparqlConstructAdditionsDir() {
|
||||||
return sparqlConstructAdditionsDir;
|
return sparqlConstructAdditionsDir;
|
||||||
}
|
}
|
||||||
|
public void setSparqlConstructAdditionsPass2Dir(String sparqlConstructAdditionsDir) {
|
||||||
|
this.sparqlConstructAdditionsPass2Dir = sparqlConstructAdditionsDir;
|
||||||
|
}
|
||||||
|
public String getSparqlConstructAdditionsPass2Dir() {
|
||||||
|
return sparqlConstructAdditionsPass2Dir;
|
||||||
|
}
|
||||||
public void setSparqlConstructAdditionsDir(String sparqlConstructAdditionsDir) {
|
public void setSparqlConstructAdditionsDir(String sparqlConstructAdditionsDir) {
|
||||||
this.sparqlConstructAdditionsDir = sparqlConstructAdditionsDir;
|
this.sparqlConstructAdditionsDir = sparqlConstructAdditionsDir;
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,23 +81,21 @@ public class OntologyUpdater {
|
||||||
|
|
||||||
performSparqlConstructAdditions(settings.getSparqlConstructAdditionsDir(), settings.getOntModelSelector().getABoxModel());
|
performSparqlConstructAdditions(settings.getSparqlConstructAdditionsDir(), settings.getOntModelSelector().getABoxModel());
|
||||||
performSparqlConstructRetractions(settings.getSparqlConstructDeletionsDir(), settings.getOntModelSelector().getABoxModel());
|
performSparqlConstructRetractions(settings.getSparqlConstructDeletionsDir(), settings.getOntModelSelector().getABoxModel());
|
||||||
|
performSparqlConstructAdditions(settings.getSparqlConstructAdditionsPass2Dir(), settings.getOntModelSelector().getABoxModel());
|
||||||
|
|
||||||
DateTimeMigration dtMigration = new DateTimeMigration(settings.getOntModelSelector().getABoxModel(), logger, record);
|
DateTimeMigration dtMigration = new DateTimeMigration(settings.getOntModelSelector().getABoxModel(), logger, record);
|
||||||
dtMigration.updateABox();
|
dtMigration.updateABox();
|
||||||
|
|
||||||
List<AtomicOntologyChange> rawChanges = getAtomicOntologyChanges();
|
List<AtomicOntologyChange> rawChanges = getAtomicOntologyChanges();
|
||||||
|
|
||||||
AtomicOntologyChangeLists changes = new AtomicOntologyChangeLists(rawChanges,
|
AtomicOntologyChangeLists changes = new AtomicOntologyChangeLists(rawChanges,settings.getNewTBoxModel(),settings.getOldTBoxModel());
|
||||||
settings.getNewTBoxModel(),
|
|
||||||
settings.getOldTBoxModel());
|
|
||||||
//process the TBox before the ABox
|
|
||||||
//TODO: uncomment updateTBoxAnnotations();
|
|
||||||
|
|
||||||
updateABox(changes);
|
|
||||||
|
|
||||||
|
//process the TBox before the ABox
|
||||||
|
//TODO: uncomment updateTBoxAnnotations(); 12/27/2010 - commented out just for testing abox updater
|
||||||
|
|
||||||
|
updateABox(changes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void performSparqlConstructAdditions(String sparqlConstructDir, OntModel aboxModel) throws IOException {
|
private void performSparqlConstructAdditions(String sparqlConstructDir, OntModel aboxModel) throws IOException {
|
||||||
|
|
||||||
Model anonModel = performSparqlConstructs(sparqlConstructDir, aboxModel);
|
Model anonModel = performSparqlConstructs(sparqlConstructDir, aboxModel);
|
||||||
|
|
|
@ -53,6 +53,7 @@ public class UpdateKnowledgeBase implements ServletContextListener {
|
||||||
private final String REMOVED_DATA_FILE = DATA_DIR + CHANGED_DATA_DIR + "removedData.n3";
|
private final String REMOVED_DATA_FILE = DATA_DIR + CHANGED_DATA_DIR + "removedData.n3";
|
||||||
private final String ADDED_DATA_FILE = DATA_DIR + CHANGED_DATA_DIR + "addedData.n3";
|
private final String ADDED_DATA_FILE = DATA_DIR + CHANGED_DATA_DIR + "addedData.n3";
|
||||||
private final String SPARQL_CONSTRUCT_ADDITIONS_DIR = DATA_DIR + "sparqlConstructs/additions/";
|
private final String SPARQL_CONSTRUCT_ADDITIONS_DIR = DATA_DIR + "sparqlConstructs/additions/";
|
||||||
|
private final String SPARQL_CONSTRUCT_ADDITIONS_PASS2_DIR = DATA_DIR + "sparqlConstructs/additions-pass2/";
|
||||||
private final String SPARQL_CONSTRUCT_DELETIONS_DIR = DATA_DIR + "sparqlConstructs/deletions/";
|
private final String SPARQL_CONSTRUCT_DELETIONS_DIR = DATA_DIR + "sparqlConstructs/deletions/";
|
||||||
private final String MISC_REPLACEMENTS_FILE = DATA_DIR + "miscReplacements.rdf";
|
private final String MISC_REPLACEMENTS_FILE = DATA_DIR + "miscReplacements.rdf";
|
||||||
private final String OLD_TBOX_MODEL_DIR = DATA_DIR + "oldVersion/";
|
private final String OLD_TBOX_MODEL_DIR = DATA_DIR + "oldVersion/";
|
||||||
|
@ -74,6 +75,7 @@ public class UpdateKnowledgeBase implements ServletContextListener {
|
||||||
settings.setAskQueryFile(ctx.getRealPath(ASK_QUERY_FILE));
|
settings.setAskQueryFile(ctx.getRealPath(ASK_QUERY_FILE));
|
||||||
settings.setDataDir(ctx.getRealPath(DATA_DIR));
|
settings.setDataDir(ctx.getRealPath(DATA_DIR));
|
||||||
settings.setSparqlConstructAdditionsDir(ctx.getRealPath(SPARQL_CONSTRUCT_ADDITIONS_DIR));
|
settings.setSparqlConstructAdditionsDir(ctx.getRealPath(SPARQL_CONSTRUCT_ADDITIONS_DIR));
|
||||||
|
settings.setSparqlConstructAdditionsPass2Dir(ctx.getRealPath(SPARQL_CONSTRUCT_ADDITIONS_PASS2_DIR));
|
||||||
settings.setSparqlConstructDeletionsDir(ctx.getRealPath(SPARQL_CONSTRUCT_DELETIONS_DIR));
|
settings.setSparqlConstructDeletionsDir(ctx.getRealPath(SPARQL_CONSTRUCT_DELETIONS_DIR));
|
||||||
settings.setDiffFile(ctx.getRealPath(DIFF_FILE));
|
settings.setDiffFile(ctx.getRealPath(DIFF_FILE));
|
||||||
settings.setSuccessAssertionsFile(ctx.getRealPath(SUCCESS_ASSERTIONS_FILE));
|
settings.setSuccessAssertionsFile(ctx.getRealPath(SUCCESS_ASSERTIONS_FILE));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue