annotation data migration

This commit is contained in:
brianjlowe 2013-09-18 16:21:36 -04:00
parent e739a94222
commit c062201a9a
7 changed files with 569 additions and 402 deletions

View file

@ -12,6 +12,8 @@ public class VitroVocabulary {
public static final String VITRO_AUTH = "http://vitro.mannlib.cornell.edu/ns/vitro/authorization#"; public static final String VITRO_AUTH = "http://vitro.mannlib.cornell.edu/ns/vitro/authorization#";
public static final String VITRO_PUBLIC = "http://vitro.mannlib.cornell.edu/ns/vitro/public#"; public static final String VITRO_PUBLIC = "http://vitro.mannlib.cornell.edu/ns/vitro/public#";
public static final String VITRO_PUBLIC_ONTOLOGY = "http://vitro.mannlib.cornell.edu/ns/vitro/public"; public static final String VITRO_PUBLIC_ONTOLOGY = "http://vitro.mannlib.cornell.edu/ns/vitro/public";
// TODO change the following before 1.6 release
public static final String PROPERTY_CONFIG_DATA = "http://example.org/appConfig/";
/** BJL23 2008-02-25: /** BJL23 2008-02-25:

View file

@ -949,7 +949,6 @@ public class ObjectPropertyDaoJena extends PropertyDaoJena implements ObjectProp
" { ?property display:listViewConfigFile ?filename \n" + " { ?property display:listViewConfigFile ?filename \n" +
" } UNION { \n" + " } UNION { \n" +
" ?configuration config:listViewConfigFile ?filename . \n " + " ?configuration config:listViewConfigFile ?filename . \n " +
// " ?configuration config:hasListView ?lv . " +
" ?context config:hasConfiguration ?configuration . \n" + " ?context config:hasConfiguration ?configuration . \n" +
" ?context config:configContextFor ?property . \n" + " ?context config:configContextFor ?property . \n" +
" ?context config:qualifiedBy ?range . \n" + " ?context config:qualifiedBy ?range . \n" +

View file

@ -44,6 +44,7 @@ public class ABoxUpdater {
private Dataset dataset; private Dataset dataset;
private RDFService rdfService; private RDFService rdfService;
private OntModel newTBoxAnnotationsModel; private OntModel newTBoxAnnotationsModel;
private TBoxUpdater tboxUpdater;
private ChangeLogger logger; private ChangeLogger logger;
private ChangeRecord record; private ChangeRecord record;
private OntClass OWL_THING = (ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM)).createClass(OWL.Thing.getURI()); private OntClass OWL_THING = (ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM)).createClass(OWL.Thing.getURI());
@ -61,20 +62,19 @@ public class ABoxUpdater {
* and the retractions model. * and the retractions model.
* *
*/ */
public ABoxUpdater(OntModel oldTboxModel, public ABoxUpdater(UpdateSettings settings,
OntModel newTboxModel,
RDFService rdfService,
OntModel newAnnotationsModel,
ChangeLogger logger, ChangeLogger logger,
ChangeRecord record) { ChangeRecord record) {
this.oldTboxModel = oldTboxModel; this.oldTboxModel = settings.getOldTBoxModel();
this.newTboxModel = newTboxModel; this.newTboxModel = settings.getNewTBoxModel();
RDFService rdfService = settings.getRDFService();
this.dataset = new RDFServiceDataset(rdfService); this.dataset = new RDFServiceDataset(rdfService);
this.rdfService = rdfService; this.rdfService = rdfService;
this.newTBoxAnnotationsModel = newAnnotationsModel; this.newTBoxAnnotationsModel = settings.getNewTBoxAnnotationsModel();
this.logger = logger; this.logger = logger;
this.record = record; this.record = record;
this.tboxUpdater = new TBoxUpdater(settings, logger, record);
} }
/** /**
@ -632,6 +632,8 @@ public class ABoxUpdater {
propObj.getDestinationURI() + " instead"); propObj.getDestinationURI() + " instead");
} }
} }
tboxUpdater.renameProperty(propObj);
} }
public void logChanges(Statement oldStatement, Statement newStatement) throws IOException { public void logChanges(Statement oldStatement, Statement newStatement) throws IOException {

View file

@ -64,7 +64,6 @@ public class KnowledgeBaseUpdater {
} }
long startTime = System.currentTimeMillis(); long startTime = System.currentTimeMillis();
System.out.println("Migrating the knowledge base");
log.info("Migrating the knowledge base"); log.info("Migrating the knowledge base");
logger.log("Started knowledge base migration"); logger.log("Started knowledge base migration");
@ -84,7 +83,6 @@ public class KnowledgeBaseUpdater {
logger.closeLogs(); logger.closeLogs();
long elapsedSecs = (System.currentTimeMillis() - startTime)/1000; long elapsedSecs = (System.currentTimeMillis() - startTime)/1000;
System.out.println("Finished knowledge base migration in " + elapsedSecs + " second" + (elapsedSecs != 1 ? "s" : ""));
log.info("Finished knowledge base migration in " + elapsedSecs + " second" + (elapsedSecs != 1 ? "s" : "")); log.info("Finished knowledge base migration in " + elapsedSecs + " second" + (elapsedSecs != 1 ? "s" : ""));
return; return;
@ -111,20 +109,15 @@ public class KnowledgeBaseUpdater {
log.error("unable to migrate migration metadata " + e.getMessage()); log.error("unable to migrate migration metadata " + e.getMessage());
} }
log.warn("KnowledgeBaseUpdater needs to be modified to work on all graphs!");
OntModel readModel = settings.getUnionOntModelSelector().getABoxModel();
OntModel writeModel = settings.getAssertionOntModelSelector().getABoxModel();
// TODO make sure the ABox update applies to all graphs
log.info("\tupdating the abox");
updateABox(changes);
log.info("performing SPARQL CONSTRUCT additions"); log.info("performing SPARQL CONSTRUCT additions");
performSparqlConstructs(settings.getSparqlConstructAdditionsDir(), settings.getRDFService(), ADD); performSparqlConstructs(settings.getSparqlConstructAdditionsDir(), settings.getRDFService(), ADD);
log.info("performing SPARQL CONSTRUCT retractions"); log.info("performing SPARQL CONSTRUCT retractions");
performSparqlConstructs(settings.getSparqlConstructDeletionsDir(), settings.getRDFService(), RETRACT); performSparqlConstructs(settings.getSparqlConstructDeletionsDir(), settings.getRDFService(), RETRACT);
log.info("\tupdating the abox");
updateABox(changes);
} }
private static final boolean ADD = true; private static final boolean ADD = true;
@ -249,10 +242,8 @@ public class KnowledgeBaseUpdater {
private void updateABox(AtomicOntologyChangeLists changes) private void updateABox(AtomicOntologyChangeLists changes)
throws IOException { throws IOException {
OntModel oldTBoxModel = settings.getOldTBoxModel();
OntModel newTBoxModel = settings.getNewTBoxModel(); ABoxUpdater aboxUpdater = new ABoxUpdater(settings, logger, record);
RDFService rdfService = settings.getRDFService();
ABoxUpdater aboxUpdater = new ABoxUpdater(oldTBoxModel, newTBoxModel, rdfService, settings.getNewTBoxAnnotationsModel(), logger, record);
aboxUpdater.processPropertyChanges(changes.getAtomicPropertyChanges()); aboxUpdater.processPropertyChanges(changes.getAtomicPropertyChanges());
aboxUpdater.processClassChanges(changes.getAtomicClassChanges()); aboxUpdater.processClassChanges(changes.getAtomicClassChanges());
} }
@ -290,14 +281,18 @@ public class KnowledgeBaseUpdater {
rdfService.changeSetUpdate(removeChangeSet); rdfService.changeSetUpdate(removeChangeSet);
} }
private void updateTBoxAnnotations() throws IOException { private void updateTBoxAnnotations() {
TBoxUpdater tboxUpdater = new TBoxUpdater(settings, logger, record);
TBoxUpdater tboxUpdater = new TBoxUpdater(settings.getOldTBoxAnnotationsModel(), try {
settings.getNewTBoxAnnotationsModel(), tboxUpdater.modifyPropertyQualifications();
settings.getAssertionOntModelSelector().getTBoxModel(), logger, record); } catch (Exception e) {
log.error("Unable to modify qualified property config file ", e);
}
try {
tboxUpdater.updateDefaultAnnotationValues(); tboxUpdater.updateDefaultAnnotationValues();
//tboxUpdater.updateAnnotationModel(); } catch (Exception e) {
log.error("Unable to update default annotation values ", e);
}
} }
/** /**

View file

@ -2,11 +2,22 @@
package edu.cornell.mannlib.vitro.webapp.ontology.update; package edu.cornell.mannlib.vitro.webapp.ontology.update;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
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;
import com.hp.hpl.jena.query.Dataset;
import com.hp.hpl.jena.query.Query;
import com.hp.hpl.jena.query.QueryExecution;
import com.hp.hpl.jena.query.QueryExecutionFactory;
import com.hp.hpl.jena.query.QueryFactory;
import com.hp.hpl.jena.rdf.model.Literal; import com.hp.hpl.jena.rdf.model.Literal;
import com.hp.hpl.jena.rdf.model.Model; import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.ModelFactory; import com.hp.hpl.jena.rdf.model.ModelFactory;
@ -14,6 +25,7 @@ import com.hp.hpl.jena.rdf.model.NodeIterator;
import com.hp.hpl.jena.rdf.model.Property; import com.hp.hpl.jena.rdf.model.Property;
import com.hp.hpl.jena.rdf.model.RDFNode; import com.hp.hpl.jena.rdf.model.RDFNode;
import com.hp.hpl.jena.rdf.model.Resource; import com.hp.hpl.jena.rdf.model.Resource;
import com.hp.hpl.jena.rdf.model.ResourceFactory;
import com.hp.hpl.jena.rdf.model.Statement; import com.hp.hpl.jena.rdf.model.Statement;
import com.hp.hpl.jena.rdf.model.StmtIterator; import com.hp.hpl.jena.rdf.model.StmtIterator;
import com.hp.hpl.jena.shared.Lock; import com.hp.hpl.jena.shared.Lock;
@ -21,6 +33,8 @@ import com.hp.hpl.jena.vocabulary.RDF;
import com.hp.hpl.jena.vocabulary.RDFS; import com.hp.hpl.jena.vocabulary.RDFS;
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary; import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
import edu.cornell.mannlib.vitro.webapp.dao.jena.RDFServiceDataset;
import edu.cornell.mannlib.vitro.webapp.servlet.setup.JenaDataSourceSetupBase;
/** /**
* Performs knowledge base updates to the tbox to align with a new ontology version * Performs knowledge base updates to the tbox to align with a new ontology version
@ -28,6 +42,9 @@ import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
*/ */
public class TBoxUpdater { public class TBoxUpdater {
private static final Log log = LogFactory.getLog(TBoxUpdater.class);
private UpdateSettings settings;
private OntModel oldTboxAnnotationsModel; private OntModel oldTboxAnnotationsModel;
private OntModel newTboxAnnotationsModel; private OntModel newTboxAnnotationsModel;
private OntModel siteModel; private OntModel siteModel;
@ -53,19 +70,33 @@ public class TBoxUpdater {
* and the retractions model. * and the retractions model.
* *
*/ */
public TBoxUpdater(OntModel oldTboxAnnotationsModel, public TBoxUpdater(UpdateSettings settings,
OntModel newTboxAnnotationsModel,
OntModel siteModel,
ChangeLogger logger, ChangeLogger logger,
ChangeRecord record) { ChangeRecord record) {
this.settings = settings;
this.oldTboxAnnotationsModel = oldTboxAnnotationsModel; this.oldTboxAnnotationsModel = settings.getOldTBoxAnnotationsModel();
this.newTboxAnnotationsModel = newTboxAnnotationsModel; this.newTboxAnnotationsModel = settings.getNewTBoxAnnotationsModel();
this.siteModel = siteModel; this.siteModel = settings.getAssertionOntModelSelector().getTBoxModel();
this.logger = logger; this.logger = logger;
this.record = record; this.record = record;
} }
/**
* Update application ontology data for domain and range-qualified properties
* to use any applicable settings from obsolete subproperties
*/
public void modifyPropertyQualifications() throws IOException {
}
private Model mergeConfigurations(Model oldConfig, Model newConfig) {
return null;
}
public void updateDefaultAnnotationValues() throws IOException {
updateDefaultAnnotationValues(null);
}
/** /**
* *
* Update a knowledge base to align with changes to vitro annotation property default * Update a knowledge base to align with changes to vitro annotation property default
@ -91,7 +122,7 @@ public class TBoxUpdater {
* Note: as specified, this method for now assumes that no new vitro annotation * Note: as specified, this method for now assumes that no new vitro annotation
* properties have been introduced. This should be updated for future versions. * properties have been introduced. This should be updated for future versions.
*/ */
public void updateDefaultAnnotationValues() throws IOException { public void updateDefaultAnnotationValues(String subjectURI) throws IOException {
siteModel.enterCriticalSection(Lock.WRITE); siteModel.enterCriticalSection(Lock.WRITE);
@ -109,7 +140,9 @@ public class TBoxUpdater {
return; return;
} }
StmtIterator iter = oldTboxAnnotationsModel.listStatements(); Resource subj = (subjectURI == null) ? null : ResourceFactory.createResource(subjectURI);
StmtIterator iter = oldTboxAnnotationsModel.listStatements(subj, null, (RDFNode) null);
while (iter.hasNext()) { while (iter.hasNext()) {
@ -420,4 +453,119 @@ public void removeObsoleteAnnotations() throws IOException {
} }
} }
public void renameProperty(AtomicOntologyChange changeObj) throws IOException {
if(changeObj.getNotes() != null && changeObj.getNotes().startsWith("cc:")) {
mergePropertyAnnotationsToPropertyConfig(changeObj);
}
}
private void mergePropertyAnnotationsToPropertyConfig(AtomicOntologyChange changeObj) throws IOException {
String contextURI = VitroVocabulary.PROPERTY_CONFIG_DATA + changeObj.getNotes().substring(3);
String oldPropertyURI = changeObj.getSourceURI();
Model oldAnnotationsModel = settings.getOldTBoxAnnotationsModel();
Dataset dataset = new RDFServiceDataset(settings.getRDFService());
Model userAnnotationsModel = dataset.getNamedModel(
JenaDataSourceSetupBase.JENA_TBOX_ASSERTIONS_MODEL);
String propertyAnnotationsQuery =
"PREFIX config: <" + VitroVocabulary.configURI + "> \n" +
"PREFIX vitro: <" + VitroVocabulary.vitroURI + "> \n" +
"CONSTRUCT { \n" +
" <" + oldPropertyURI + "> vitro:inPropertyGroupAnnot ?group . \n" +
" <" + oldPropertyURI + "> <" + RDFS.label.getURI() + "> ?label . \n" +
" <" + oldPropertyURI + "> vitro:displayRankAnnot ?displayRank . \n" +
" <" + oldPropertyURI + "> vitro:customEntryFormAnnot ?customForm . \n" +
" <" + oldPropertyURI + "> vitro:hiddenFromDisplayBelowRoleLevelAnnot ?displayLevel . \n" +
" <" + oldPropertyURI + "> vitro:prohibitedFromUpdateBelowRoleLevelAnnot ?updateLevel . \n " +
"} WHERE { \n" +
" { <" + oldPropertyURI + "> vitro:inPropertyGroupAnnot ?group } \n" +
" UNION { <" + oldPropertyURI + "> <" + RDFS.label.getURI() + "> ?label } \n" +
" UNION { <" + oldPropertyURI + "> vitro:displayRankAnnot ?displayRank } \n" +
" UNION { <" + oldPropertyURI + "> vitro:customEntryFormAnnot ?customForm } \n" +
" UNION { <" + oldPropertyURI + "> vitro:hiddenFromDisplayBelowRoleLevelAnnot ?displayLevel } \n" +
" UNION { <" + oldPropertyURI + "> vitro:prohibitedFromUpdateBelowRoleLevelAnnot ?updateLevel } \n " +
"} \n" ;
Model userChangesModel = construct(
propertyAnnotationsQuery, userAnnotationsModel).difference(
construct(propertyAnnotationsQuery, oldAnnotationsModel));
String addQuery = "PREFIX config: <" + VitroVocabulary.configURI + "> \n" +
"PREFIX vitro: <" + VitroVocabulary.vitroURI + "> \n" +
"CONSTRUCT { \n" +
" ?configuration config:propertyGroup ?group . \n" +
" ?configuration config:displayName ?label . \n" +
" ?configuration vitro:displayRankAnnot ?displayRank . \n" +
" ?configuration vitro:customEntryFormAnnot ?customForm . \n" +
" ?configuration vitro:hiddenFromDisplayBelowRoleLevelAnnot ?displayLevel . \n" +
" ?configuration vitro:prohibitedFromUpdateBelowRoleLevelAnnot ?updateLevel . \n " +
"} WHERE { \n" +
" <" + contextURI + "> config:hasConfiguration ?configuration . \n" +
" OPTIONAL { <" + oldPropertyURI + "> vitro:inPropertyGroupAnnot ?group } \n" +
" OPTIONAL { <" + oldPropertyURI + "> <" + RDFS.label.getURI() + "> ?label } \n" +
" OPTIONAL { <" + oldPropertyURI + "> vitro:displayRankAnnot ?displayRank } \n" +
" OPTIONAL { <" + oldPropertyURI + "> vitro:customEntryFormAnnot ?customForm } \n" +
" OPTIONAL { <" + oldPropertyURI + "> vitro:hiddenFromDisplayBelowRoleLevelAnnot ?displayLevel } \n" +
" OPTIONAL { <" + oldPropertyURI + "> vitro:prohibitedFromUpdateBelowRoleLevelAnnot ?updateLevel } \n " +
"} \n" ;
String retractQuery = "PREFIX config: <" + VitroVocabulary.configURI + "> \n" +
"PREFIX vitro: <" + VitroVocabulary.vitroURI + "> \n" +
"CONSTRUCT { \n" +
" <" + oldPropertyURI + "> config:propertyGroup ?rgroup . \n" +
" ?configuration config:displayName ?rlabel . \n" +
" ?configuration vitro:displayRankAnnot ?rdisplayRank . \n" +
" ?configuration vitro:customEntryFormAnnot ?rcustomForm . \n" +
" ?configuration vitro:hiddenFromDisplayBelowRoleLevelAnnot ?rdisplayLevel . \n" +
" ?configuration vitro:prohibitedFromUpdateBelowRoleLevelAnnot ?rupdateLevel . \n " +
"} WHERE { \n" +
" <" + contextURI + "> config:hasConfiguration ?configuration . \n" +
" OPTIONAL { <" + oldPropertyURI + "> vitro:inPropertyGroupAnnot ?group . \n" +
" ?configuration config:propertyGroup ?rgroup } \n" +
" OPTIONAL { <" + oldPropertyURI + "> <" + RDFS.label.getURI() + "> ?label . \n" +
" ?configuration config:displayName ?rlabel } \n " +
" OPTIONAL { <" + oldPropertyURI + "> vitro:displayRankAnnot ?displayRank . \n" +
" ?configuration vitro:displayRantAnnot ?rdisplayRank } \n " +
" OPTIONAL { <" + oldPropertyURI + "> vitro:customEntryFormAnnot ?customForm . \n" +
" ?configuration vitro:customEntryFormAnnot ?rcustomForm } \n" +
" OPTIONAL { <" + oldPropertyURI + "> vitro:hiddenFromDisplayBelowRoleLevelAnnot ?displayLevel . \n" +
" ?configuration vitro:hiddenFromDisplayBelowRoleLevelAnnot ?rdisplayLevel } \n" +
" OPTIONAL { <" + oldPropertyURI + "> vitro:prohibitedFromUpdateBelowRoleLevelAnnot ?updateLevel . \n " +
" ?configuration vitro:prohibitedFromUpdateBelowRoleLevelAnnot ?updateLevel } " +
"} \n" ;
Model configModel = ModelFactory.createDefaultModel();
String configFileName = settings.getQualifiedPropertyConfigFile();
File file = new File(configFileName);
FileInputStream fis = new FileInputStream(file);
configModel.read(fis, null, "N3");
Model union = ModelFactory.createUnion(configModel,
userChangesModel);
Model additions = construct(addQuery, union);
Model retractions = construct(retractQuery, union);
if (additions.size() > 0 || retractions.size() > 0) {
configModel.remove(retractions);
log.info("Removing " + retractions.size() + " statements from " + contextURI);
configModel.add(additions);
log.info("Adding " + additions.size() + " statements from " + contextURI);
FileOutputStream fos = new FileOutputStream(file);
configModel.write(fos, "N3");
}
}
private Model construct(String queryStr, Model model) {
Query query = QueryFactory.create(queryStr);
QueryExecution qe = QueryExecutionFactory.create(query, model);
try {
return qe.execConstruct();
} finally {
qe.close();
}
}
} }

View file

@ -21,6 +21,7 @@ public class UpdateSettings {
private String errorLogFile; private String errorLogFile;
private String addedDataFile; private String addedDataFile;
private String removedDataFile; private String removedDataFile;
private String qualifiedPropertyConfigFile;
private String defaultNamespace; private String defaultNamespace;
private OntModelSelector assertionOntModelSelector; private OntModelSelector assertionOntModelSelector;
private OntModelSelector inferenceOntModelSelector; private OntModelSelector inferenceOntModelSelector;
@ -121,6 +122,12 @@ public class UpdateSettings {
public void setRemovedDataFile(String removedDataFile) { public void setRemovedDataFile(String removedDataFile) {
this.removedDataFile = removedDataFile; this.removedDataFile = removedDataFile;
} }
public String getQualifiedPropertyConfigFile() {
return qualifiedPropertyConfigFile;
}
public void setQualifiedPropertyConfigFile(String qualifiedPropertyConfigFile) {
this.qualifiedPropertyConfigFile = qualifiedPropertyConfigFile;
}
public String getDefaultNamespace() { public String getDefaultNamespace() {
return defaultNamespace; return defaultNamespace;
} }

View file

@ -96,7 +96,7 @@ public class UpdateKnowledgeBase implements ServletContextListener {
settings.setNewTBoxModel(newTBoxModel); settings.setNewTBoxModel(newTBoxModel);
OntModel oldTBoxAnnotationsModel = loadModelFromDirectory(ctx.getRealPath(OLD_TBOX_ANNOTATIONS_DIR)); OntModel oldTBoxAnnotationsModel = loadModelFromDirectory(ctx.getRealPath(OLD_TBOX_ANNOTATIONS_DIR));
settings.setOldTBoxAnnotationsModel(oldTBoxAnnotationsModel); settings.setOldTBoxAnnotationsModel(oldTBoxAnnotationsModel);
OntModel newTBoxAnnotationsModel = loadModelFromDirectory(createDirectory(homeDir, "rdf", "tbox", "everytime").toString()); OntModel newTBoxAnnotationsModel = loadModelFromDirectory(createDirectory(homeDir, "rdf", "tbox", "firsttime").toString());
settings.setNewTBoxAnnotationsModel(newTBoxAnnotationsModel); settings.setNewTBoxAnnotationsModel(newTBoxAnnotationsModel);
settings.setRDFService(RDFServiceUtils.getRDFServiceFactory(ctx).getRDFService()); settings.setRDFService(RDFServiceUtils.getRDFServiceFactory(ctx).getRDFService());
@ -145,6 +145,9 @@ public class UpdateKnowledgeBase implements ServletContextListener {
log.warn("unable to successfully update display model: " + e.getMessage()); log.warn("unable to successfully update display model: " + e.getMessage());
} }
} }
// reload the display model since the TBoxUpdater may have
// modified it
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);
@ -189,6 +192,17 @@ public class UpdateKnowledgeBase implements ServletContextListener {
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());
settings.setErrorLogFile(logDir.resolve(timestampedFileName("knowledgeBaseUpdate.error", "log")).toString()); settings.setErrorLogFile(logDir.resolve(timestampedFileName("knowledgeBaseUpdate.error", "log")).toString());
Path qualifiedPropertyConfigFile = getFilePath(homeDir, "rdf", "display", "everytime", "PropertyConfig.n3");
settings.setQualifiedPropertyConfigFile(qualifiedPropertyConfigFile.toString());
}
private Path getFilePath(Path parent, String... children) throws IOException {
Path path = parent;
for (String child : children) {
path = path.resolve(child);
}
return path;
} }
private Path createDirectory(Path parent, String... children) throws IOException { private Path createDirectory(Path parent, String... children) throws IOException {