Merging r8871 from 1.3 maint branch
This commit is contained in:
parent
7abaa39fa3
commit
9599e512c6
2 changed files with 45 additions and 11 deletions
|
@ -628,19 +628,38 @@ public class WebappDaoFactoryJena implements WebappDaoFactory {
|
||||||
this.dwf = base.dwf;
|
this.dwf = base.dwf;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Method for using special model for webapp dao factory, such as display model
|
/**
|
||||||
|
* Method for using special model for webapp dao factory, such as display model.
|
||||||
|
* The goal here is to modify this WebappDaoFactory so that it is using the
|
||||||
|
* specialModel, specialTboxModel and the specialDisplayModel for individual
|
||||||
|
* editing.
|
||||||
|
*
|
||||||
|
* DAOs related to the application configuration, user accounts, and namespaces
|
||||||
|
* should remain unchanged.
|
||||||
|
*/
|
||||||
public void setSpecialDataModel(OntModel specialModel, OntModel specialTboxModel, OntModel specialDisplayModel) {
|
public void setSpecialDataModel(OntModel specialModel, OntModel specialTboxModel, OntModel specialDisplayModel) {
|
||||||
|
if( specialModel == null )
|
||||||
|
throw new IllegalStateException( "specialModel must not be null");
|
||||||
|
|
||||||
//Can we get the "original" models here from somewhere?
|
//Can we get the "original" models here from somewhere?
|
||||||
OntModelSelector originalSelector = this.getOntModelSelector();
|
OntModelSelector originalSelector = this.getOntModelSelector();
|
||||||
//Set up model selector for the new webapp dao factory object with the input model
|
|
||||||
//The selector is used by the object property dao, therefore should be set up even though we
|
//Set up model selector for this special WDF
|
||||||
|
//The selector is used by the object property DAO, therefore should be set up even though we
|
||||||
//use the new webapp dao factory object to generate portions to overwrite the regular webapp dao factory
|
//use the new webapp dao factory object to generate portions to overwrite the regular webapp dao factory
|
||||||
|
|
||||||
|
//The WDF expects the full model in the OntModelSelect that has
|
||||||
|
//both the ABox and TBox. This is used to run SPARQL queries against.
|
||||||
|
OntModel unionModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
|
||||||
|
unionModel.addSubModel(specialModel);
|
||||||
|
|
||||||
OntModelSelectorImpl specialSelector = new OntModelSelectorImpl();
|
OntModelSelectorImpl specialSelector = new OntModelSelectorImpl();
|
||||||
specialSelector.setFullModel(specialModel);
|
specialSelector.setFullModel(unionModel);
|
||||||
specialSelector.setApplicationMetadataModel(specialModel);
|
specialSelector.setApplicationMetadataModel(specialModel);
|
||||||
|
|
||||||
if(specialDisplayModel != null) {
|
if(specialDisplayModel != null) {
|
||||||
specialSelector.setDisplayModel(specialDisplayModel);
|
specialSelector.setDisplayModel(specialDisplayModel);
|
||||||
|
unionModel.addSubModel(specialDisplayModel);
|
||||||
} else {
|
} else {
|
||||||
OntModel selectorDisplayModel = originalSelector.getDisplayModel();
|
OntModel selectorDisplayModel = originalSelector.getDisplayModel();
|
||||||
if(selectorDisplayModel != null) {
|
if(selectorDisplayModel != null) {
|
||||||
|
@ -648,14 +667,15 @@ public class WebappDaoFactoryJena implements WebappDaoFactory {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(specialTboxModel != null) {
|
if(specialTboxModel != null) {
|
||||||
|
unionModel.addSubModel(specialTboxModel);
|
||||||
specialSelector.setTBoxModel(specialTboxModel);
|
specialSelector.setTBoxModel(specialTboxModel);
|
||||||
} else {
|
} else {
|
||||||
OntModel selectorTboxModel = originalSelector.getTBoxModel();
|
OntModel selectorTboxModel = originalSelector.getTBoxModel();
|
||||||
if(selectorTboxModel != null) {
|
if(selectorTboxModel != null) {
|
||||||
specialSelector.setTBoxModel(originalSelector.getTBoxModel());
|
specialSelector.setTBoxModel(originalSelector.getTBoxModel());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
specialSelector.setABoxModel(specialModel);
|
specialSelector.setABoxModel(specialModel);
|
||||||
specialSelector.setUserAccountsModel(specialModel);
|
specialSelector.setUserAccountsModel(specialModel);
|
||||||
//although we're only use part of the new wadf and copy over below, the object property dao
|
//although we're only use part of the new wadf and copy over below, the object property dao
|
||||||
|
@ -675,6 +695,7 @@ public class WebappDaoFactoryJena implements WebappDaoFactory {
|
||||||
dataPropertyStatementDao = specialWadfj.getDataPropertyStatementDao();
|
dataPropertyStatementDao = specialWadfj.getDataPropertyStatementDao();
|
||||||
//Why can't we set the selector to be the same?
|
//Why can't we set the selector to be the same?
|
||||||
ontModelSelector = specialSelector;
|
ontModelSelector = specialSelector;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -137,17 +137,20 @@ public class VitroRequestPrep implements Filter {
|
||||||
WebappDaoFactory wdf = getWebappDaoFactory(vreq);
|
WebappDaoFactory wdf = getWebappDaoFactory(vreq);
|
||||||
//TODO: get accept-language from request and set as preferred languages
|
//TODO: get accept-language from request and set as preferred languages
|
||||||
|
|
||||||
|
// if there is a WebappDaoFactory in the session, use it
|
||||||
Object o = req.getSession().getAttribute("webappDaoFactory");
|
Object o = req.getSession().getAttribute("webappDaoFactory");
|
||||||
if (o instanceof WebappDaoFactory) {
|
if (o instanceof WebappDaoFactory) {
|
||||||
wdf = (WebappDaoFactory) o;
|
wdf = (WebappDaoFactory) o;
|
||||||
log.debug("Found a WebappDaoFactory in the session and using it for this request");
|
log.debug("Found a WebappDaoFactory in the session and using it for this request");
|
||||||
}
|
}
|
||||||
//This will replace the WebappDaoFactory with a different version if menu management parameter is found
|
|
||||||
|
//replace the WebappDaoFactory with a different version if menu management parameter is found
|
||||||
wdf = checkForSpecialWDF(vreq, wdf);
|
wdf = checkForSpecialWDF(vreq, wdf);
|
||||||
|
|
||||||
|
//get any filters from the ContextFitlerFactory
|
||||||
VitroFilters filters = getFiltersFromContextFilterFactory(req, wdf);
|
VitroFilters filters = getFiltersFromContextFilterFactory(req, wdf);
|
||||||
if( filters != null ){
|
if( filters != null ){
|
||||||
log.debug("Wrapping WebappDaoFactory in filters");
|
log.debug("Wrapping WebappDaoFactory in filters from ContextFitlerFactory");
|
||||||
wdf = new WebappDaoFactoryFiltering(wdf, filters);
|
wdf = new WebappDaoFactoryFiltering(wdf, filters);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -212,6 +215,9 @@ public class VitroRequestPrep implements Filter {
|
||||||
* model and tbox if uris are passed.
|
* model and tbox if uris are passed.
|
||||||
*/
|
*/
|
||||||
private WebappDaoFactory checkForSpecialWDF(VitroRequest vreq, WebappDaoFactory inputWadf) {
|
private WebappDaoFactory checkForSpecialWDF(VitroRequest vreq, WebappDaoFactory inputWadf) {
|
||||||
|
//TODO: Does the dataset in the vreq get set when using a special WDF? Does it need to?
|
||||||
|
//TODO: Does the unfiltered WDF get set when using a special WDF? Does it need to?
|
||||||
|
|
||||||
// If this isn't a Jena WADF, then there's nothing to be done.
|
// If this isn't a Jena WADF, then there's nothing to be done.
|
||||||
if (!(inputWadf instanceof WebappDaoFactoryJena)) {
|
if (!(inputWadf instanceof WebappDaoFactoryJena)) {
|
||||||
log.warn("Can't set special models: " +
|
log.warn("Can't set special models: " +
|
||||||
|
@ -295,12 +301,19 @@ public class VitroRequestPrep implements Filter {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a copy of the WADF, and set the special models onto it.
|
* The goal here is to return a new WDF that is set to
|
||||||
|
* have the mainOntModel as its ABox, the tboxOntModel as it
|
||||||
|
* TBox and displayOntModel as it display model.
|
||||||
|
*
|
||||||
|
* Right now this is achieved by creating a copy of
|
||||||
|
* the WADF, and setting the special models onto it.
|
||||||
|
*
|
||||||
* If a model is null, it will have no effect.
|
* If a model is null, it will have no effect.
|
||||||
*/
|
*/
|
||||||
private WebappDaoFactory createNewWebappDaoFactory(
|
private WebappDaoFactory createNewWebappDaoFactory(
|
||||||
WebappDaoFactoryJena inputWadf, OntModel mainOntModel,
|
WebappDaoFactoryJena inputWadf, OntModel mainOntModel,
|
||||||
OntModel tboxOntModel, OntModel displayOntModel) {
|
OntModel tboxOntModel, OntModel displayOntModel) {
|
||||||
|
|
||||||
WebappDaoFactoryJena wadfj = new WebappDaoFactoryJena(inputWadf);
|
WebappDaoFactoryJena wadfj = new WebappDaoFactoryJena(inputWadf);
|
||||||
wadfj.setSpecialDataModel(mainOntModel, tboxOntModel, displayOntModel);
|
wadfj.setSpecialDataModel(mainOntModel, tboxOntModel, displayOntModel);
|
||||||
return wadfj;
|
return wadfj;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue