data migration improvements

This commit is contained in:
brianjlowe 2013-09-23 15:56:27 -04:00
parent f76ee886d5
commit 32925441bc

View file

@ -134,13 +134,11 @@ public class UpdateKnowledgeBase implements ServletContextListener {
tryMigrateDisplay = false; tryMigrateDisplay = false;
} }
try {
KnowledgeBaseUpdater ontologyUpdater = new KnowledgeBaseUpdater(settings); KnowledgeBaseUpdater ontologyUpdater = new KnowledgeBaseUpdater(settings);
boolean requiredUpdate = ontologyUpdater.updateRequired(ctx);
try { try {
if (!ontologyUpdater.updateRequired(ctx)) {
log.info("No data migration required.");
} else {
ctx.setAttribute(KBM_REQURIED_AT_STARTUP, Boolean.TRUE); ctx.setAttribute(KBM_REQURIED_AT_STARTUP, Boolean.TRUE);
log.info("Data migration required"); log.info("Data migration required");
migrationChangesMade = ontologyUpdater.update(ctx); migrationChangesMade = ontologyUpdater.update(ctx);
@ -155,26 +153,18 @@ public class UpdateKnowledgeBase implements ServletContextListener {
// reload the display model since the TBoxUpdater may have // reload the display model since the TBoxUpdater may have
// modified it // modified it
new ApplicationModelSetup().contextInitialized(sce); new ApplicationModelSetup().contextInitialized(sce);
}
} catch (Exception ioe) { } catch (Exception ioe) {
ss.fatal(this, "Exception updating knowledge base for ontology changes: ", ioe); ss.fatal(this, "Exception updating knowledge base for ontology changes: ", ioe);
} }
} catch (Throwable t){
ss.fatal(this, "Exception updating knowledge base for ontology changes: ", t);
}
} catch (Throwable t) {
ss.fatal(this, "Exception updating knowledge base for ontology changes: ", t);
}
if (SimpleReasonerSetup.isRecomputeRequired(sce.getServletContext())) {
log.info("ABox inference recompute required.");
SimpleReasoner simpleReasoner = (SimpleReasoner) sce.getServletContext() SimpleReasoner simpleReasoner = (SimpleReasoner) sce.getServletContext()
.getAttribute(SimpleReasoner.class.getName()); .getAttribute(SimpleReasoner.class.getName());
if (simpleReasoner != null) { if (simpleReasoner != null) {
if (JenaDataSourceSetupBase.isFirstStartup() || migrationChangesMade) { if ( (requiredUpdate && migrationChangesMade)
|| JenaDataSourceSetupBase.isFirstStartup()) {
log.info("ABox inference recompute required.");
simpleReasoner.recompute(); simpleReasoner.recompute();
} else { } else if (SimpleReasonerSetup.isRecomputeRequired(sce.getServletContext()) || migrationChangesMade) {
log.info("starting ABox inference recompute in a separate thread."); log.info("starting ABox inference recompute in a separate thread.");
new Thread( new Thread(
new ABoxRecomputer( new ABoxRecomputer(
@ -182,8 +172,12 @@ public class UpdateKnowledgeBase implements ServletContextListener {
} }
} }
} catch (Throwable t){
ss.fatal(this, "Exception updating knowledge base for ontology changes: ", t);
} }
} }
private class ABoxRecomputer implements Runnable { private class ABoxRecomputer implements Runnable {