VIVO-212 Add unfiltered WADFs to ModelAccess
Create two new FactoryIDs: UNFILTERED_BASE and UNFILTERED_UNION Modify VitroRequest so the unfiltered WADF is no longer stored in an attribute on the request. Initialize them in the context - same as the BASE and UNION Initialize them in the request - same as the BASE, but UNION will be filtered.
This commit is contained in:
parent
614d338257
commit
c3a0568114
4 changed files with 24 additions and 20 deletions
|
@ -16,6 +16,7 @@ import com.hp.hpl.jena.query.Dataset;
|
|||
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.ApplicationBean;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess.FactoryID;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.OntModelSelector;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.VitroModelSource.ModelName;
|
||||
|
@ -76,16 +77,12 @@ public class VitroRequest extends HttpServletRequestWrapper {
|
|||
return ModelAccess.on(this).getWebappDaoFactory();
|
||||
}
|
||||
|
||||
public void setUnfilteredWebappDaoFactory(WebappDaoFactory wdf) {
|
||||
setAttribute("unfilteredWebappDaoFactory", wdf);
|
||||
}
|
||||
|
||||
/** Gets a WebappDaoFactory with request-specific dataset but no filtering.
|
||||
* Use this for any servlets that need to bypass filtering.
|
||||
* @return
|
||||
*/
|
||||
public WebappDaoFactory getUnfilteredWebappDaoFactory() {
|
||||
return (WebappDaoFactory) getAttribute("unfilteredWebappDaoFactory");
|
||||
return ModelAccess.on(this).getWebappDaoFactory(FactoryID.UNFILTERED_UNION);
|
||||
}
|
||||
|
||||
public Dataset getDataset() {
|
||||
|
@ -103,7 +100,7 @@ public class VitroRequest extends HttpServletRequestWrapper {
|
|||
|
||||
/** gets assertions-only WebappDaoFactory with no filtering */
|
||||
public WebappDaoFactory getAssertionsWebappDaoFactory() {
|
||||
return ModelAccess.on(this).getBaseWebappDaoFactory();
|
||||
return ModelAccess.on(this).getWebappDaoFactory(FactoryID.UNFILTERED_BASE);
|
||||
}
|
||||
|
||||
//Method that retrieves write model, returns special model in case of write model
|
||||
|
|
|
@ -29,7 +29,6 @@ import edu.cornell.mannlib.vitro.webapp.dao.jena.OntModelSelector;
|
|||
* VitroRequest.getUnfilteredRDFService()
|
||||
* VitroRequest.getWebappDaoFactory()
|
||||
* VitroRequest.getWriteModel()
|
||||
* vreq.setUnfilteredWebappDaoFactory(wadf);
|
||||
*
|
||||
* OntModelSelector.getABoxModel
|
||||
* OntModelSelector.getFullModel()
|
||||
|
@ -68,7 +67,7 @@ public class ModelAccess {
|
|||
}
|
||||
|
||||
public enum FactoryID {
|
||||
BASE, UNION
|
||||
BASE, UNION, UNFILTERED_BASE, UNFILTERED_UNION
|
||||
}
|
||||
|
||||
private enum Scope {
|
||||
|
|
|
@ -30,6 +30,7 @@ import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties;
|
|||
import edu.cornell.mannlib.vitro.webapp.controller.VitroHttpServlet;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess.FactoryID;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess.ModelID;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactoryConfig;
|
||||
|
@ -140,19 +141,10 @@ public class RequestModelsPrep implements Filter {
|
|||
|
||||
WebappDaoFactoryConfig config = createWadfConfig(langs, req);
|
||||
|
||||
WebappDaoFactory assertions = new WebappDaoFactorySDB(rdfService,
|
||||
ModelAccess.on(ctx).getBaseOntModelSelector(), config,
|
||||
SDBDatasetMode.ASSERTIONS_ONLY);
|
||||
ModelAccess.on(vreq).setBaseWebappDaoFactory(assertions);
|
||||
|
||||
ModelAccess.on(vreq).setJenaOntModel(
|
||||
ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM,
|
||||
dataset.getDefaultModel()));
|
||||
|
||||
OntModelSelector oms = ModelAccess.on(ctx).getUnionOntModelSelector();
|
||||
WebappDaoFactory wadf = new WebappDaoFactorySDB(rdfService, oms, config);
|
||||
vreq.setUnfilteredWebappDaoFactory(wadf);
|
||||
|
||||
addLanguageAwarenessToRequestModel(req, ModelID.DISPLAY);
|
||||
addLanguageAwarenessToRequestModel(req, ModelID.APPLICATION_METADATA);
|
||||
addLanguageAwarenessToRequestModel(req, ModelID.UNION_TBOX);
|
||||
|
@ -160,7 +152,21 @@ public class RequestModelsPrep implements Filter {
|
|||
addLanguageAwarenessToRequestModel(req, ModelID.BASE_TBOX);
|
||||
addLanguageAwarenessToRequestModel(req, ModelID.BASE_FULL);
|
||||
|
||||
wadf = new WebappDaoFactorySDB(rdfService, ModelAccess.on(vreq).getUnionOntModelSelector(), config);
|
||||
WebappDaoFactory unfilteredWadf = new WebappDaoFactorySDB(rdfService,
|
||||
ModelAccess.on(ctx).getUnionOntModelSelector(), config);
|
||||
ModelAccess.on(vreq).setWebappDaoFactory(FactoryID.UNFILTERED_UNION,
|
||||
unfilteredWadf);
|
||||
|
||||
WebappDaoFactory unfilteredAssertionsWadf = new WebappDaoFactorySDB(
|
||||
rdfService, ModelAccess.on(vreq).getBaseOntModelSelector(),
|
||||
config, SDBDatasetMode.ASSERTIONS_ONLY);
|
||||
ModelAccess.on(vreq).setWebappDaoFactory(FactoryID.BASE,
|
||||
unfilteredAssertionsWadf);
|
||||
ModelAccess.on(vreq).setWebappDaoFactory(FactoryID.UNFILTERED_BASE,
|
||||
unfilteredAssertionsWadf);
|
||||
|
||||
WebappDaoFactory wadf = new WebappDaoFactorySDB(rdfService, ModelAccess
|
||||
.on(vreq).getUnionOntModelSelector(), config);
|
||||
|
||||
// Do model switching and replace the WebappDaoFactory with
|
||||
// a different version if requested by parameters
|
||||
|
@ -172,7 +178,7 @@ public class RequestModelsPrep implements Filter {
|
|||
ServletPolicyList.getPolicies(ctx));
|
||||
WebappDaoFactoryFiltering filteredWadf = new WebappDaoFactoryFiltering(
|
||||
switchedWadf, filter);
|
||||
ModelAccess.on(vreq).setWebappDaoFactory(filteredWadf);
|
||||
ModelAccess.on(vreq).setWebappDaoFactory(FactoryID.UNION, filteredWadf);
|
||||
}
|
||||
|
||||
private WebappDaoFactoryConfig createWadfConfig(List<String> langs, HttpServletRequest req) {
|
||||
|
|
|
@ -110,11 +110,13 @@ public class ContentModelSetup extends JenaDataSourceSetupBase
|
|||
|
||||
OntModelSelector baseOms = models.getBaseOntModelSelector();
|
||||
WebappDaoFactory baseWadf = new WebappDaoFactorySDB(rdfService, baseOms, config, ASSERTIONS_ONLY);
|
||||
ModelAccess.on(ctx).setBaseWebappDaoFactory(baseWadf);
|
||||
ModelAccess.on(ctx).setWebappDaoFactory(FactoryID.BASE, baseWadf);
|
||||
ModelAccess.on(ctx).setWebappDaoFactory(FactoryID.UNFILTERED_BASE, baseWadf);
|
||||
|
||||
OntModelSelector unionOms = models.getUnionOntModelSelector();
|
||||
WebappDaoFactory wadf = new WebappDaoFactorySDB(rdfService, unionOms, config);
|
||||
ModelAccess.on(ctx).setWebappDaoFactory(FactoryID.UNION, wadf);
|
||||
ModelAccess.on(ctx).setWebappDaoFactory(FactoryID.UNFILTERED_UNION, wadf);
|
||||
|
||||
log.info("Model makers set up");
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue