Merging r8871 from 1.3 maint branch

This commit is contained in:
briancaruso 2011-07-27 14:08:05 +00:00
parent 7abaa39fa3
commit 9599e512c6
2 changed files with 45 additions and 11 deletions

View file

@ -628,19 +628,38 @@ public class WebappDaoFactoryJena implements WebappDaoFactory {
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) {
if( specialModel == null )
throw new IllegalStateException( "specialModel must not be null");
//Can we get the "original" models here from somewhere?
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
//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();
specialSelector.setFullModel(specialModel);
specialSelector.setApplicationMetadataModel(specialModel);
specialSelector.setFullModel(unionModel);
specialSelector.setApplicationMetadataModel(specialModel);
if(specialDisplayModel != null) {
specialSelector.setDisplayModel(specialDisplayModel);
unionModel.addSubModel(specialDisplayModel);
} else {
OntModel selectorDisplayModel = originalSelector.getDisplayModel();
if(selectorDisplayModel != null) {
@ -648,14 +667,15 @@ public class WebappDaoFactoryJena implements WebappDaoFactory {
}
}
if(specialTboxModel != null) {
unionModel.addSubModel(specialTboxModel);
specialSelector.setTBoxModel(specialTboxModel);
} else {
OntModel selectorTboxModel = originalSelector.getTBoxModel();
if(selectorTboxModel != null) {
specialSelector.setTBoxModel(originalSelector.getTBoxModel());
}
}
}
specialSelector.setABoxModel(specialModel);
specialSelector.setUserAccountsModel(specialModel);
//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();
//Why can't we set the selector to be the same?
ontModelSelector = specialSelector;
}
}

View file

@ -137,17 +137,20 @@ public class VitroRequestPrep implements Filter {
WebappDaoFactory wdf = getWebappDaoFactory(vreq);
//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");
if (o instanceof WebappDaoFactory) {
wdf = (WebappDaoFactory) o;
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);
//get any filters from the ContextFitlerFactory
VitroFilters filters = getFiltersFromContextFilterFactory(req, wdf);
if( filters != null ){
log.debug("Wrapping WebappDaoFactory in filters");
log.debug("Wrapping WebappDaoFactory in filters from ContextFitlerFactory");
wdf = new WebappDaoFactoryFiltering(wdf, filters);
}
@ -212,6 +215,9 @@ public class VitroRequestPrep implements Filter {
* model and tbox if uris are passed.
*/
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 (!(inputWadf instanceof WebappDaoFactoryJena)) {
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.
*/
private WebappDaoFactory createNewWebappDaoFactory(
WebappDaoFactoryJena inputWadf, OntModel mainOntModel,
OntModel tboxOntModel, OntModel displayOntModel) {
WebappDaoFactoryJena wadfj = new WebappDaoFactoryJena(inputWadf);
wadfj.setSpecialDataModel(mainOntModel, tboxOntModel, displayOntModel);
return wadfj;