VIVO-1009 Rely less on JenaDataSourceSetupBase.isFirstStartup()
In general, we can read firsttime files iff a model is empty. This provides more flexibility than relying on isFirstStartup(). However, the KnowledgeBaseUpdater still relies on isFirstStartup(), so we need to be sure that we set it when appropriate.
This commit is contained in:
parent
0362770961
commit
6981838348
3 changed files with 22 additions and 14 deletions
|
@ -53,24 +53,22 @@ public class ContentModelSetup extends JenaDataSourceSetupBase
|
||||||
|
|
||||||
Model applicationMetadataModel = models.getOntModel(APPLICATION_METADATA);
|
Model applicationMetadataModel = models.getOntModel(APPLICATION_METADATA);
|
||||||
if (applicationMetadataModel.size()== 0) {
|
if (applicationMetadataModel.size()== 0) {
|
||||||
thisIsFirstStartup();
|
initializeApplicationMetadata(ctx, applicationMetadataModel);
|
||||||
|
} else {
|
||||||
|
checkForNamespaceMismatch( applicationMetadataModel, ctx );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
OntModel baseABoxModel = models.getOntModel(ABOX_ASSERTIONS);
|
OntModel baseABoxModel = models.getOntModel(ABOX_ASSERTIONS);
|
||||||
OntModel baseTBoxModel = models.getOntModel(TBOX_ASSERTIONS);
|
if (baseABoxModel.size() == 0) {
|
||||||
|
|
||||||
if (isFirstStartup()) {
|
|
||||||
initializeApplicationMetadata(ctx, applicationMetadataModel);
|
|
||||||
RDFFilesLoader.loadFirstTimeFiles("abox", baseABoxModel, true);
|
RDFFilesLoader.loadFirstTimeFiles("abox", baseABoxModel, true);
|
||||||
RDFFilesLoader.loadFirstTimeFiles("tbox", baseTBoxModel, true);
|
|
||||||
} else {
|
|
||||||
checkForNamespaceMismatch( applicationMetadataModel, ctx );
|
|
||||||
}
|
}
|
||||||
RDFFilesLoader.loadEveryTimeFiles("abox", baseABoxModel);
|
RDFFilesLoader.loadEveryTimeFiles("abox", baseABoxModel);
|
||||||
RDFFilesLoader.loadEveryTimeFiles("tbox", baseTBoxModel);
|
|
||||||
|
|
||||||
log.info("Setting up DAO factories");
|
OntModel baseTBoxModel = models.getOntModel(TBOX_ASSERTIONS);
|
||||||
|
if (baseTBoxModel.size() == 0) {
|
||||||
|
RDFFilesLoader.loadFirstTimeFiles("tbox", baseTBoxModel, true);
|
||||||
|
}
|
||||||
|
RDFFilesLoader.loadEveryTimeFiles("tbox", baseTBoxModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
private long secondsSince(long startTime) {
|
private long secondsSince(long startTime) {
|
||||||
|
|
|
@ -67,9 +67,10 @@ public class RDFFilesLoader {
|
||||||
public static void loadFirstTimeFiles(String modelPath, Model model,
|
public static void loadFirstTimeFiles(String modelPath, Model model,
|
||||||
boolean firstTime) {
|
boolean firstTime) {
|
||||||
if (firstTime) {
|
if (firstTime) {
|
||||||
Set<Path> paths = getPaths(locateHomeDirectory(), RDF, modelPath,
|
String home = locateHomeDirectory();
|
||||||
FIRST_TIME);
|
Set<Path> paths = getPaths(home, RDF, modelPath, FIRST_TIME);
|
||||||
for (Path p : paths) {
|
for (Path p : paths) {
|
||||||
|
log.info("Loading " + relativePath(p, home));
|
||||||
readOntologyFileIntoModel(p, model);
|
readOntologyFileIntoModel(p, model);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -10,6 +10,7 @@ import com.hp.hpl.jena.tdb.TDB;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.RDFServiceDataset;
|
import edu.cornell.mannlib.vitro.webapp.dao.jena.RDFServiceDataset;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.RDFServiceModelMaker;
|
import edu.cornell.mannlib.vitro.webapp.dao.jena.RDFServiceModelMaker;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames;
|
||||||
import edu.cornell.mannlib.vitro.webapp.modelaccess.adapters.ListCachingModelMaker;
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.adapters.ListCachingModelMaker;
|
||||||
import edu.cornell.mannlib.vitro.webapp.modelaccess.adapters.MemoryMappingModelMaker;
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.adapters.MemoryMappingModelMaker;
|
||||||
import edu.cornell.mannlib.vitro.webapp.modelaccess.ontmodels.OntModelCache;
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ontmodels.OntModelCache;
|
||||||
|
@ -21,6 +22,7 @@ import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceFactory;
|
||||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.RDFServiceFactorySingle;
|
import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.RDFServiceFactorySingle;
|
||||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.jena.tdb.RDFServiceTDB;
|
import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.jena.tdb.RDFServiceTDB;
|
||||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.logging.LoggingRDFServiceFactory;
|
import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.logging.LoggingRDFServiceFactory;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.servlet.setup.JenaDataSourceSetupBase;
|
||||||
import edu.cornell.mannlib.vitro.webapp.utils.configuration.Property;
|
import edu.cornell.mannlib.vitro.webapp.utils.configuration.Property;
|
||||||
import edu.cornell.mannlib.vitro.webapp.utils.configuration.Validation;
|
import edu.cornell.mannlib.vitro.webapp.utils.configuration.Validation;
|
||||||
import edu.cornell.mannlib.vitro.webapp.utils.logging.ToString;
|
import edu.cornell.mannlib.vitro.webapp.utils.logging.ToString;
|
||||||
|
@ -75,6 +77,7 @@ public class ContentTripleSourceTDB extends ContentTripleSource {
|
||||||
this.unclosableRdfService = this.rdfServiceFactory.getRDFService();
|
this.unclosableRdfService = this.rdfServiceFactory.getRDFService();
|
||||||
this.dataset = new RDFServiceDataset(this.unclosableRdfService);
|
this.dataset = new RDFServiceDataset(this.unclosableRdfService);
|
||||||
this.modelMaker = createModelMaker();
|
this.modelMaker = createModelMaker();
|
||||||
|
checkForFirstTimeStartup();
|
||||||
ss.info("Initialized the RDF source for TDB");
|
ss.info("Initialized the RDF source for TDB");
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException(
|
throw new RuntimeException(
|
||||||
|
@ -102,6 +105,12 @@ public class ContentTripleSourceTDB extends ContentTripleSource {
|
||||||
this.unclosableRdfService), SMALL_CONTENT_MODELS)));
|
this.unclosableRdfService), SMALL_CONTENT_MODELS)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void checkForFirstTimeStartup() {
|
||||||
|
if (this.dataset.getNamedModel(ModelNames.TBOX_ASSERTIONS).size() == 0) {
|
||||||
|
JenaDataSourceSetupBase.thisIsFirstStartup();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RDFServiceFactory getRDFServiceFactory() {
|
public RDFServiceFactory getRDFServiceFactory() {
|
||||||
return this.rdfServiceFactory;
|
return this.rdfServiceFactory;
|
||||||
|
|
Loading…
Add table
Reference in a new issue