various migration improvements
This commit is contained in:
parent
06bdb86f8a
commit
9e09da9871
4 changed files with 8 additions and 49 deletions
|
@ -64,7 +64,7 @@ public class KnowledgeBaseUpdater {
|
||||||
}
|
}
|
||||||
|
|
||||||
long startTime = System.currentTimeMillis();
|
long startTime = System.currentTimeMillis();
|
||||||
log.info("Migrating the knowledge base");
|
log.info("Performing any necessary data migration");
|
||||||
logger.log("Started knowledge base migration");
|
logger.log("Started knowledge base migration");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -104,12 +104,6 @@ public class KnowledgeBaseUpdater {
|
||||||
log.error(e,e);
|
log.error(e,e);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
|
||||||
migrateMigrationMetadata(servletContext);
|
|
||||||
logger.log("Migrated migration metadata");
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("unable to migrate migration metadata " + e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// update ABox data any time
|
// update ABox data any time
|
||||||
|
@ -264,39 +258,6 @@ public class KnowledgeBaseUpdater {
|
||||||
aboxUpdater.processClassChanges(changes.getAtomicClassChanges());
|
aboxUpdater.processClassChanges(changes.getAtomicClassChanges());
|
||||||
}
|
}
|
||||||
|
|
||||||
// special for 1.5 - temporary code
|
|
||||||
// migrate past migration indicators to not use blank nodes and move them to app metadata model
|
|
||||||
// changing structure for pre 1.5 ones in the process
|
|
||||||
private void migrateMigrationMetadata(ServletContext servletContext) throws Exception {
|
|
||||||
|
|
||||||
String baseResourceURI = "http://vitro.mannlib.cornell.edu/ns/vitro/metadata/migration/";
|
|
||||||
String queryFile = "MigrationData.sparql";
|
|
||||||
|
|
||||||
RDFService rdfService = RDFServiceUtils.getRDFServiceFactory(servletContext).getRDFService();
|
|
||||||
|
|
||||||
String fmQuery = FileUtils.readFileToString(new File(settings.getSparqlConstructDeletionsDir() + "/" + queryFile));
|
|
||||||
Model toRemove = ModelFactory.createDefaultModel();
|
|
||||||
toRemove.read(rdfService.sparqlConstructQuery(fmQuery, RDFService.ModelSerializationFormat.RDFXML), null);
|
|
||||||
|
|
||||||
String cmQuery = FileUtils.readFileToString(new File(settings.getSparqlConstructAdditionsDir() + "/" + queryFile));
|
|
||||||
Model toAdd = ModelFactory.createDefaultModel();
|
|
||||||
toAdd.read(rdfService.sparqlConstructQuery(cmQuery, RDFService.ModelSerializationFormat.RDFXML), null);
|
|
||||||
|
|
||||||
ByteArrayOutputStream outAdd = new ByteArrayOutputStream();
|
|
||||||
toAdd.write(outAdd);
|
|
||||||
InputStream inAdd = new ByteArrayInputStream(outAdd.toByteArray());
|
|
||||||
ChangeSet addChangeSet = rdfService.manufactureChangeSet();
|
|
||||||
addChangeSet.addAddition(inAdd, RDFService.ModelSerializationFormat.RDFXML, JenaDataSourceSetupBase.JENA_APPLICATION_METADATA_MODEL);
|
|
||||||
rdfService.changeSetUpdate(addChangeSet);
|
|
||||||
|
|
||||||
ByteArrayOutputStream outRemove = new ByteArrayOutputStream();
|
|
||||||
toRemove.write(outRemove);
|
|
||||||
InputStream inRemove = new ByteArrayInputStream(outRemove.toByteArray());
|
|
||||||
ChangeSet removeChangeSet = rdfService.manufactureChangeSet();
|
|
||||||
removeChangeSet.addRemoval(inRemove, RDFService.ModelSerializationFormat.RDFXML, JenaDataSourceSetupBase.JENA_DB_MODEL);
|
|
||||||
rdfService.changeSetUpdate(removeChangeSet);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateTBoxAnnotations() {
|
private void updateTBoxAnnotations() {
|
||||||
TBoxUpdater tboxUpdater = new TBoxUpdater(settings, logger, record);
|
TBoxUpdater tboxUpdater = new TBoxUpdater(settings, logger, record);
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -88,10 +88,6 @@ public class TBoxUpdater {
|
||||||
public void modifyPropertyQualifications() throws IOException {
|
public void modifyPropertyQualifications() throws IOException {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Model mergeConfigurations(Model oldConfig, Model newConfig) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void updateDefaultAnnotationValues() throws IOException {
|
public void updateDefaultAnnotationValues() throws IOException {
|
||||||
updateDefaultAnnotationValues(null);
|
updateDefaultAnnotationValues(null);
|
||||||
|
@ -528,7 +524,8 @@ public class TBoxUpdater {
|
||||||
" OPTIONAL { <" + oldPropertyURI + "> vitro:inPropertyGroupAnnot ?group . \n" +
|
" OPTIONAL { <" + oldPropertyURI + "> vitro:inPropertyGroupAnnot ?group . \n" +
|
||||||
" ?configuration config:propertyGroup ?rgroup } \n" +
|
" ?configuration config:propertyGroup ?rgroup } \n" +
|
||||||
" OPTIONAL { <" + oldPropertyURI + "> <" + RDFS.label.getURI() + "> ?label . \n" +
|
" OPTIONAL { <" + oldPropertyURI + "> <" + RDFS.label.getURI() + "> ?label . \n" +
|
||||||
" ?configuration config:displayName ?rlabel } \n " +
|
" ?configuration config:displayName ?rlabel . \n " +
|
||||||
|
" FILTER(?rlabel != ?label) } \n " +
|
||||||
" OPTIONAL { <" + oldPropertyURI + "> vitro:displayRankAnnot ?displayRank . \n" +
|
" OPTIONAL { <" + oldPropertyURI + "> vitro:displayRankAnnot ?displayRank . \n" +
|
||||||
" ?configuration vitro:displayRantAnnot ?rdisplayRank } \n " +
|
" ?configuration vitro:displayRantAnnot ?rdisplayRank } \n " +
|
||||||
" OPTIONAL { <" + oldPropertyURI + "> vitro:customEntryFormAnnot ?customForm . \n" +
|
" OPTIONAL { <" + oldPropertyURI + "> vitro:customEntryFormAnnot ?customForm . \n" +
|
||||||
|
|
|
@ -81,6 +81,8 @@ public class SimpleReasonerSetup implements ServletContextListener {
|
||||||
|
|
||||||
log.info("Pellet reasoner connected for the TBox");
|
log.info("Pellet reasoner connected for the TBox");
|
||||||
|
|
||||||
|
waitForTBoxReasoning(sce);
|
||||||
|
|
||||||
// set up simple reasoning for the ABox
|
// set up simple reasoning for the ABox
|
||||||
|
|
||||||
RDFService rdfService = RDFServiceUtils.getRDFServiceFactory(ctx).getRDFService();
|
RDFService rdfService = RDFServiceUtils.getRDFServiceFactory(ctx).getRDFService();
|
||||||
|
@ -131,7 +133,7 @@ public class SimpleReasonerSetup implements ServletContextListener {
|
||||||
int sleeps = 0;
|
int sleeps = 0;
|
||||||
// sleep at least once to make sure the TBox reasoning gets started
|
// sleep at least once to make sure the TBox reasoning gets started
|
||||||
while ((0 == sleeps) || ((sleeps < 1000) && pelletListener.isReasoning())) {
|
while ((0 == sleeps) || ((sleeps < 1000) && pelletListener.isReasoning())) {
|
||||||
if ((sleeps % 10) == 0) { // print message at 10 second intervals
|
if (((sleeps - 1) % 10) == 0) { // print message at 10 second intervals
|
||||||
log.info("Waiting for initial TBox reasoning to complete");
|
log.info("Waiting for initial TBox reasoning to complete");
|
||||||
}
|
}
|
||||||
Thread.sleep(1000);
|
Thread.sleep(1000);
|
||||||
|
|
|
@ -141,7 +141,6 @@ public class UpdateKnowledgeBase implements ServletContextListener {
|
||||||
if(!JenaDataSourceSetupBase.isFirstStartup()) {
|
if(!JenaDataSourceSetupBase.isFirstStartup()) {
|
||||||
try {
|
try {
|
||||||
ctx.setAttribute(KBM_REQURIED_AT_STARTUP, Boolean.TRUE);
|
ctx.setAttribute(KBM_REQURIED_AT_STARTUP, Boolean.TRUE);
|
||||||
log.info("Data migration required");
|
|
||||||
migrationChangesMade = ontologyUpdater.update(ctx);
|
migrationChangesMade = ontologyUpdater.update(ctx);
|
||||||
if (tryMigrateDisplay) {
|
if (tryMigrateDisplay) {
|
||||||
try {
|
try {
|
||||||
|
@ -221,8 +220,8 @@ public class UpdateKnowledgeBase implements ServletContextListener {
|
||||||
StartupStatus.getBean(ctx).info(this, "Updating knowledge base: reports are in '" + dataDir + "'");
|
StartupStatus.getBean(ctx).info(this, "Updating knowledge base: reports are in '" + dataDir + "'");
|
||||||
|
|
||||||
Path changedDir = createDirectory(dataDir, "changedData");
|
Path changedDir = createDirectory(dataDir, "changedData");
|
||||||
settings.setAddedDataFile(changedDir.resolve("addedData.n3").toString());
|
settings.setAddedDataFile(changedDir.resolve(timestampedFileName("addedData", "n3")).toString());
|
||||||
settings.setRemovedDataFile(changedDir.resolve("removedData.n3").toString());
|
settings.setRemovedDataFile(changedDir.resolve(timestampedFileName("removedData", "n3")).toString());
|
||||||
|
|
||||||
Path logDir = createDirectory(dataDir, "logs");
|
Path logDir = createDirectory(dataDir, "logs");
|
||||||
settings.setLogFile(logDir.resolve(timestampedFileName("knowledgeBaseUpdate", "log")).toString());
|
settings.setLogFile(logDir.resolve(timestampedFileName("knowledgeBaseUpdate", "log")).toString());
|
||||||
|
|
Loading…
Add table
Reference in a new issue