VIVO-82 Use ModelAccess to get or set the Display Model

This commit is contained in:
j2blake 2013-05-16 18:05:50 -04:00
parent 416e98f5ab
commit 4764751905
13 changed files with 351 additions and 71 deletions

View file

@ -2,7 +2,6 @@
package edu.cornell.mannlib.vitro.webapp.controller;
import static edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary.DISPLAY_ONT_MODEL;
import java.util.Map;
@ -17,6 +16,7 @@ import com.hp.hpl.jena.ontology.OntModel;
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.WebappDaoFactory;
import edu.cornell.mannlib.vitro.webapp.dao.jena.JenaBaseDao;
import edu.cornell.mannlib.vitro.webapp.dao.jena.OntModelSelector;
@ -215,13 +215,7 @@ public class VitroRequest extends HttpServletRequestWrapper {
//Get the display and editing configuration model
public OntModel getDisplayModel(){
Object value = _req.getAttribute(DISPLAY_ONT_MODEL);
if (value instanceof OntModel) {
return (OntModel) value;
} else {
log.error("No display model on the VitroRequest. Expecting an OntModel but found " + value);
return null;
}
return ModelAccess.on(_req).getDisplayModel();
}
/**

View file

@ -119,9 +119,6 @@ public class DisplayVocabulary {
public static final String CONTEXT_DISPLAY_TBOX = "displayOntModelTBOX";
public static final String CONTEXT_DISPLAY_DISPLAY = "displayOntModelDisplayModel";
/** Key for display model in request, session or context attributes */
public static final String DISPLAY_ONT_MODEL = "displayOntModel";
//URL for menu management
public static final String PROCESS_MENU_MANAGEMENT_URL = "/menuManagementEdit";
public static final String REORDER_MENU_URL = PROCESS_MENU_MANAGEMENT_URL + "?cmd=Reorder&" + SWITCH_TO_DISPLAY_MODEL + "=true";

View file

@ -0,0 +1,315 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package edu.cornell.mannlib.vitro.webapp.dao;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import com.hp.hpl.jena.ontology.OntModel;
/**
* Hierarchical storage for models. TODO
*/
public class ModelAccess {
/** These attributes should only be accessed through this class. */
private static final String ATTRIBUTE_NAME = ModelAccess.class.getName();
public enum ModelID {
APPLICATION_METADATA,
USER_ACCOUNTS,
DISPLAY, DISPLAY_DISPLAY, DISPLAY_TBOX,
BASE_ABOX, BASE_TBOX, BASE_FULL,
INFERRED_ABOX, INFERRED_TBOX, INFERRED_FULL,
UNION_ABOX, UNION_TBOX, UNION_FULL
}
// ----------------------------------------------------------------------
// Factory methods
// ----------------------------------------------------------------------
public static ModelAccess on(HttpServletRequest req) {
Object o = req.getAttribute(ATTRIBUTE_NAME);
if (o instanceof ModelAccess) {
return (ModelAccess) o;
} else {
ModelAccess parent = on(req.getSession());
ModelAccess ma = new ModelAccess(parent);
req.setAttribute(ATTRIBUTE_NAME, ma);
return ma;
}
}
public static ModelAccess on(HttpSession session) {
Object o = session.getAttribute(ATTRIBUTE_NAME);
if (o instanceof ModelAccess) {
return (ModelAccess) o;
} else {
ModelAccess parent = on(session.getServletContext());
ModelAccess ma = new ModelAccess(parent);
session.setAttribute(ATTRIBUTE_NAME, ma);
return ma;
}
}
public static ModelAccess on(ServletContext ctx) {
Object o = ctx.getAttribute(ATTRIBUTE_NAME);
if (o instanceof ModelAccess) {
return (ModelAccess) o;
} else {
ModelAccess ma = new ModelAccess(null);
ctx.setAttribute(ATTRIBUTE_NAME, ma);
return ma;
}
}
// ----------------------------------------------------------------------
// Instance methods
// ----------------------------------------------------------------------
private final ModelAccess parent;
private final Map<String, OntModel> modelMap = new HashMap<>();
public ModelAccess(ModelAccess parent) {
this.parent = parent;
}
public void setDisplayModel(OntModel m) {
setOntModel(ModelID.DISPLAY, m);
}
public OntModel getDisplayModel() {
return getOntModel(ModelID.DISPLAY);
}
// /** Is this the same as Assertions model? */
// // public OntModel getBaseOntModel() {
// // throw new RuntimeException(
// // "ModelAccess.getBaseOntModel not implemented.");
// // }
//
// public OntModel getAssertionsOntModel() {
// throw new RuntimeException(
// "ModelAccess.getAssertionsOntModel not implemented.");
// }
//
// public void setUserAccountsModel(OntModel m) {
// setOntModel(ModelID.USER_ACCOUNTS, m);
// }
//
// public OntModel getUserAccountsModel() {
// return getOntModel(ModelID.USER_ACCOUNTS);
// }
//
// public OntModel getDisplayTboxOntModel() {
// throw new RuntimeException(
// "ModelAccess.getDisplayTboxOntModel not implemented.");
// }
//
// public OntModel getDisplayModelDisplayOntModel() {
// throw new RuntimeException(
// "ModelAccess.getDisplayModelDisplayOntModel not implemented.");
// }
//
// public OntModelSelector getOntModelSelector() {
// return getUnionOntModelSelector();
// }
//
// public OntModelSelector getBaseOntModelSelector() {
// return new FacadeOntModelSelector(this, ModelID.BASE_ABOX,
// ModelID.BASE_TBOX, ModelID.BASE_FULL);
// }
//
// public OntModelSelector getInferenceOntModelSelector() {
// return new FacadeOntModelSelector(this, ModelID.INFERRED_ABOX,
// ModelID.INFERRED_TBOX, ModelID.INFERRED_FULL);
// }
//
// public OntModelSelector getUnionOntModelSelector() {
// return new FacadeOntModelSelector(this, ModelID.UNION_ABOX,
// ModelID.UNION_TBOX, ModelID.UNION_FULL);
// }
//
// private static class FacadeOntModelSelector implements OntModelSelector {
// private final ModelAccess parent;
// private final ModelID aboxID;
// private final ModelID tboxID;
// private final ModelID fullID;
//
// public FacadeOntModelSelector(ModelAccess parent, ModelID aboxID,
// ModelID tboxID, ModelID fullID) {
// this.parent = parent;
// this.aboxID = aboxID;
// this.tboxID = tboxID;
// this.fullID = fullID;
// }
//
// @Override
// public OntModel getABoxModel() {
// return parent.getOntModel(aboxID);
// }
//
// @Override
// public OntModel getTBoxModel() {
// return parent.getOntModel(tboxID);
// }
//
// @Override
// public OntModel getTBoxModel(String ontologyURI) {
// return parent.getOntModel(tboxID);
// }
//
// @Override
// public OntModel getFullModel() {
// return parent.getOntModel(fullID);
// }
//
// @Override
// public OntModel getApplicationMetadataModel() {
// return parent.getOntModel(ModelID.APPLICATION_METADATA);
// }
//
// @Override
// public OntModel getUserAccountsModel() {
// return parent.getOntModel(ModelID.USER_ACCOUNTS);
// }
//
// @Override
// public OntModel getDisplayModel() {
// return parent.getOntModel(ModelID.DISPLAY);
// }
// }
/**
* <pre>
* From ModelContext
*
* public static OntModelSelector getOntModelSelector(ServletContext ctx) {
* return (OntModelSelector) ctx.getAttribute(ONT_MODEL_SELECTOR);
* }
*
* public static void setOntModelSelector(OntModelSelector oms, ServletContext ctx) {
* ctx.setAttribute(ONT_MODEL_SELECTOR, oms);
* }
*
* public static OntModelSelector getUnionOntModelSelector(ServletContext ctx) {
* return (OntModelSelector) ctx.getAttribute(UNION_ONT_MODEL_SELECTOR);
* }
*
* public static void setUnionOntModelSelector(OntModelSelector oms, ServletContext ctx) {
* ctx.setAttribute(UNION_ONT_MODEL_SELECTOR, oms);
* }
*
* public static OntModelSelector getBaseOntModelSelector(ServletContext ctx) {
* return (OntModelSelector) ctx.getAttribute(BASE_ONT_MODEL_SELECTOR);
* }
*
* public static void setBaseOntModelSelector(OntModelSelector oms, ServletContext ctx) {
* ctx.setAttribute(BASE_ONT_MODEL_SELECTOR, oms);
* }
*
* public static OntModelSelector getInferenceOntModelSelector(ServletContext ctx) {
* return (OntModelSelector) ctx.getAttribute(INFERENCE_ONT_MODEL_SELECTOR);
* }
*
* public static void setInferenceOntModelSelector(OntModelSelector oms, ServletContext ctx) {
* ctx.setAttribute(INFERENCE_ONT_MODEL_SELECTOR, oms);
* }
*
* public static OntModel getJenaOntModel(ServletContext ctx) {
* return (OntModel) ctx.getAttribute(JENA_ONT_MODEL);
* }
*
* public static void setJenaOntModel(OntModel ontModel, ServletContext ctx) {
* ctx.setAttribute(JENA_ONT_MODEL, ontModel);
* }
*
* public static OntModel getBaseOntModel(ServletContext ctx) {
* return (OntModel) ctx.getAttribute(BASE_ONT_MODEL);
* }
*
* public static void setBaseOntModel(OntModel ontModel, ServletContext ctx) {
* ctx.setAttribute(BASE_ONT_MODEL, ontModel);
* }
*
* public static OntModel getInferenceOntModel(ServletContext ctx) {
* return (OntModel) ctx.getAttribute(INFERENCE_ONT_MODEL);
* }
*
* public static void setInferenceOntModel(OntModel ontModel, ServletContext ctx) {
* ctx.setAttribute(INFERENCE_ONT_MODEL, ontModel);
* }
*
* </pre>
*/
/**
* <pre>
* VitroRequest.getAssertionsWebappDaoFactory()
* VitroRequest.getDeductionsWebappDaoFactory()
* VitroRequest.getFullWebappDaoFactory()
* VitroRequest.getJenaOntModel()
* VitroRequest.getRDFService()
* VitroRequest.getUnfilteredRDFService()
* VitroRequest.getWebappDaoFactory()
* VitroRequest.getWriteModel()
* ModelContext.getBaseOntModelSelector()
* ModelContext.getInferenceOntModel()
* ModelContext.getInferenceOntModelSelector()
* ModelContext.getJenaOntModel()
* ModelContext.getOntModelSelector()
* ModelContext.getUnionOntModelSelector()
* OntModelSelector.getAboxModel
* OntModelSelector.getApplicationMetadataModel()
* OntModelSelector.getFullModel()
* OntModelSelector.getTBoxModel()
* OntModelSelector.getTBoxModel(ontologyURI)
* OntModelSelector.getUserAccountsModel()
* VitroModelSource.getModel(URL)
* VitroModelSource.getModel(URL, loadIfAbsent)
* VitroModelSource.openModel(name)
* VitroModelSource.openModelIfPresent(string)
* ServletContext.getAttribute("assertionsWebappDaoFactory")
* ServletContext.getAttribute("baseOntModelSelector")
* ServletContext.getAttribute("jenaOntModel")
* ServletContext.getAttribute("jenaPersistentOntModel")
* ServletContext.getAttribute("pelletOntModel")
* ServletContext.getAttribute("webappDaoFactory")
* VitroJenaModelMaker
* VitroJenaSpecialModelMaker
* JenaDataSourceSetupBase.getApplicationDataSource(ctx)
* JenaDataSourceSetupBase.getStartupDataset()
* HttpSession.getAttribute("jenaAuditModel")
* HttpSession.getAttribute("jenaOntModel")
* ServletRequest.getAttribute("jenaOntModel")
* </pre>
*/
public void setOntModel(ModelID id, OntModel ontModel) {
String key = id.toString();
if (ontModel == null) {
modelMap.remove(key);
} else {
modelMap.put(key, ontModel);
}
}
public OntModel getOntModel(ModelID id) {
String key = id.toString();
if (modelMap.containsKey(key)) {
return modelMap.get(key);
} else if (parent != null) {
return parent.getOntModel(id);
} else {
return null;
}
}
}

View file

@ -113,10 +113,4 @@ public class ModelContext {
}
public static OntModel getDisplayModel(ServletContext ctx){
return(OntModel) ctx.getAttribute( DisplayVocabulary.DISPLAY_ONT_MODEL );
}
public static void setDisplayModel(OntModel ontModel, ServletContext ctx){
ctx.setAttribute(DisplayVocabulary.DISPLAY_ONT_MODEL,ontModel);
}
}

View file

@ -10,6 +10,7 @@ import com.hp.hpl.jena.rdf.model.ModelReader;
import com.hp.hpl.jena.rdf.model.ModelSource;
import edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary;
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
/**
* ModelSource that will handle specially named Vitro models such
@ -110,7 +111,7 @@ public class VitroModelSource implements ModelSource {
case TBOX:
return (Model) context.getAttribute("tboxmodel???");
case DISPLAY:
return (Model) context.getAttribute(DisplayVocabulary.DISPLAY_ONT_MODEL );
return ModelAccess.on(context).getDisplayModel();
case DISPLAY_TBOX:
return (Model) context.getAttribute(DisplayVocabulary.CONTEXT_DISPLAY_TBOX);
case DISPLAY_DISPLAY:

View file

@ -31,6 +31,7 @@ import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty;
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary;
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationUtils;
@ -408,16 +409,11 @@ public class DefaultObjectPropertyFormGenerator implements EditConfigurationGene
if(isSelectFromExisting(vreq)) {
// set ProhibitedFromSearch object so picklist doesn't show
// individuals from classes that should be hidden from list views
//TODO: Check how model is retrieved
OntModel displayOntModel =
(OntModel) session.getServletContext()
.getAttribute(DISPLAY_ONT_MODEL);
if (displayOntModel != null) {
ProhibitedFromSearch pfs = new ProhibitedFromSearch(
DisplayVocabulary.SEARCH_INDEX_URI, displayOntModel);
if( editConfig != null )
editConfig.setProhibitedFromSearch(pfs);
}
OntModel displayOntModel = ModelAccess.on(session).getDisplayModel();
ProhibitedFromSearch pfs = new ProhibitedFromSearch(
DisplayVocabulary.SEARCH_INDEX_URI, displayOntModel);
if( editConfig != null )
editConfig.setProhibitedFromSearch(pfs);
}
}

View file

@ -4,14 +4,12 @@ package edu.cornell.mannlib.vitro.webapp.filters;
import static edu.cornell.mannlib.vitro.webapp.controller.VitroRequest.SPECIAL_WRITE_MODEL;
import static edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary.CONTEXT_DISPLAY_TBOX;
import static edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary.DISPLAY_ONT_MODEL;
import static edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary.SWITCH_TO_DISPLAY_MODEL;
import static edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary.USE_DISPLAY_MODEL_PARAM;
import static edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary.USE_MODEL_PARAM;
import static edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary.USE_TBOX_MODEL_PARAM;
import java.io.IOException;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -42,20 +40,18 @@ import edu.cornell.mannlib.vitro.webapp.auth.policy.ServletPolicyList;
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.WebappDaoFactory;
import edu.cornell.mannlib.vitro.webapp.dao.filtering.WebappDaoFactoryFiltering;
import edu.cornell.mannlib.vitro.webapp.dao.filtering.filters.FilterFactory;
import edu.cornell.mannlib.vitro.webapp.dao.filtering.filters.HideFromDisplayByPolicyFilter;
import edu.cornell.mannlib.vitro.webapp.dao.filtering.filters.VitroFilters;
import edu.cornell.mannlib.vitro.webapp.dao.jena.ModelContext;
import edu.cornell.mannlib.vitro.webapp.dao.jena.RDFServiceGraph;
import edu.cornell.mannlib.vitro.webapp.dao.jena.VitroModelSource;
import edu.cornell.mannlib.vitro.webapp.dao.jena.WebappDaoFactoryJena;
import edu.cornell.mannlib.vitro.webapp.dao.jena.WebappDaoFactorySDB;
import edu.cornell.mannlib.vitro.webapp.rdfservice.filter.LanguageFilteringRDFService;
import edu.cornell.mannlib.vitro.webapp.rdfservice.filter.LanguageFilteringUtils;
import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.RDFServiceUtils;
import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.jena.model.RDFServiceModel;
import edu.cornell.mannlib.vitro.webapp.servlet.setup.JenaDataSourceSetupBase;
/**
@ -138,21 +134,14 @@ public class VitroRequestPrep implements Filter {
log.debug("Found a WebappDaoFactory in the session and using it for this request");
}
// Set up the DisplayModel, with language filtering if appropriate.
OntModel displayModel;
Object displayModelObject = req.getSession().getAttribute(DISPLAY_ONT_MODEL);
if (displayModelObject instanceof OntModel) {
displayModel = (OntModel) displayModelObject;
} else {
displayModel = (OntModel) _context.getAttribute(DISPLAY_ONT_MODEL);
}
if (Boolean.valueOf(ConfigurationProperties.getBean(vreq).getProperty(
"RDFService.languageFilter", "true"))) {
displayModel = LanguageFilteringUtils.wrapOntModelInALanguageFilter(displayModel, req);
// Set up the DisplayModel with language filtering, if appropriate.
ConfigurationProperties props = ConfigurationProperties.getBean(req);
Boolean languageFilteringEnabled = Boolean.valueOf(props.getProperty("RDFService.languageFilter", "true"));
if (languageFilteringEnabled) {
OntModel displayModel = ModelAccess.on(req.getSession()).getDisplayModel();
OntModel filteredDisplayModel = LanguageFilteringUtils.wrapOntModelInALanguageFilter(displayModel, req);
ModelAccess.on(req).setDisplayModel(filteredDisplayModel);
}
vreq.setAttribute(DISPLAY_ONT_MODEL, displayModel);
//Do model switching and replace the WebappDaoFactory with
//a different version if requested by parameters
@ -245,7 +234,7 @@ public class VitroRequestPrep implements Filter {
// If they asked for the display model, give it to them.
if (isParameterPresent(vreq, SWITCH_TO_DISPLAY_MODEL)) {
OntModel mainOntModel = (OntModel)_context.getAttribute( DISPLAY_ONT_MODEL);
OntModel mainOntModel = ModelAccess.on(_context).getDisplayModel();
OntModel tboxOntModel = (OntModel) _context.getAttribute(CONTEXT_DISPLAY_TBOX);
setSpecialWriteModel(vreq, mainOntModel);

View file

@ -2,7 +2,6 @@
package edu.cornell.mannlib.vitro.webapp.search.solr;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
@ -11,19 +10,16 @@ import java.util.List;
import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.solr.client.solrj.SolrServer;
import org.apache.solr.client.solrj.impl.CommonsHttpSolrServer;
import org.apache.solr.client.solrj.impl.XMLResponseParser;
import com.hp.hpl.jena.ontology.OntModel;
import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.vocabulary.OWL;
import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties;
import edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary;
import edu.cornell.mannlib.vitro.webapp.dao.IndividualDao;
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
import edu.cornell.mannlib.vitro.webapp.dao.filtering.WebappDaoFactoryFiltering;
@ -31,8 +27,6 @@ import edu.cornell.mannlib.vitro.webapp.dao.filtering.filters.VitroFilterUtils;
import edu.cornell.mannlib.vitro.webapp.dao.filtering.filters.VitroFilters;
import edu.cornell.mannlib.vitro.webapp.dao.jena.ModelContext;
import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.RDFServiceUtils;
import edu.cornell.mannlib.vitro.webapp.search.beans.FileBasedProhibitedFromSearch;
import edu.cornell.mannlib.vitro.webapp.search.beans.ProhibitedFromSearch;
import edu.cornell.mannlib.vitro.webapp.search.beans.StatementToURIsToUpdate;
import edu.cornell.mannlib.vitro.webapp.search.indexing.AdditionalURIsForContextNodes;
import edu.cornell.mannlib.vitro.webapp.search.indexing.AdditionalURIsForDataProperties;
@ -120,7 +114,7 @@ public class SolrSetup implements javax.servlet.ServletContextListener{
/* set up the individual to solr doc translation */
OntModel jenaOntModel = ModelContext.getJenaOntModel(context);
Model displayModel = ModelContext.getDisplayModel(context);
OntModel displayModel = ModelAccess.on(context).getDisplayModel();
/* try to get context attribute DocumentModifiers
* and use that as the start of the list of DocumentModifier

View file

@ -9,7 +9,6 @@ import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.sql.DataSource;
import org.apache.commons.dbcp.BasicDataSource;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.joda.time.DateTime;
@ -23,7 +22,7 @@ import com.hp.hpl.jena.query.QueryFactory;
import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.ModelFactory;
import edu.cornell.mannlib.vitro.webapp.dao.jena.ModelContext;
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
import edu.cornell.mannlib.vitro.webapp.dao.jena.ModelSynchronizer;
import edu.cornell.mannlib.vitro.webapp.startup.StartupStatus;
@ -63,8 +62,8 @@ implements ServletContextListener {
}
OntModel displayModel = ModelFactory.createOntologyModel(MEM_ONT_MODEL_SPEC);
displayModel.add(displayDbModel);
displayModel.getBaseModel().register(new ModelSynchronizer(displayDbModel));
ModelContext.setDisplayModel(displayModel, ctx);
displayModel.getBaseModel().register(new ModelSynchronizer(displayDbModel));
ModelAccess.on(ctx).setDisplayModel(displayModel);
//at each startup load all RDF files from directory to sub-models of display model
initializeDisplayLoadedAtStartup(ctx, displayModel);

View file

@ -2,7 +2,6 @@
package edu.cornell.mannlib.vitro.webapp.servlet.setup;
import static edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary.DISPLAY_ONT_MODEL;
import static edu.cornell.mannlib.vitro.webapp.dao.jena.WebappDaoFactorySDB.SDBDatasetMode.ASSERTIONS_ONLY;
import static edu.cornell.mannlib.vitro.webapp.dao.jena.WebappDaoFactorySDB.SDBDatasetMode.INFERENCES_ONLY;
@ -28,6 +27,7 @@ import com.hp.hpl.jena.shared.Lock;
import com.hp.hpl.jena.util.ResourceUtils;
import com.hp.hpl.jena.vocabulary.RDF;
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactoryConfig;
import edu.cornell.mannlib.vitro.webapp.dao.jena.ModelContext;
@ -72,7 +72,7 @@ public class ContentModelSetup extends JenaDataSourceSetupBase
}
OntModel userAccountsModel = ontModelFromContextAttribute(ctx, "userAccountsOntModel");
OntModel displayModel = ontModelFromContextAttribute(ctx,DISPLAY_ONT_MODEL);
OntModel displayModel = ModelAccess.on(ctx).getDisplayModel();
OntModel baseABoxModel = createNamedModelFromDataset(dataset, JENA_DB_MODEL);
OntModel inferenceABoxModel = createNamedModelFromDataset(dataset, JENA_INF_MODEL);
OntModel baseTBoxModel = createdMemoryMappedModel(dataset, JENA_TBOX_ASSERTIONS_MODEL, "tbox assertions");

View file

@ -32,6 +32,7 @@ import com.hp.hpl.jena.vocabulary.RDF;
import com.hp.hpl.jena.vocabulary.RDFS;
import edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary;
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
import edu.cornell.mannlib.vitro.webapp.dao.jena.ModelContext;
import edu.cornell.mannlib.vitro.webapp.ontology.update.KnowledgeBaseUpdater;
@ -106,7 +107,7 @@ public class UpdateKnowledgeBase implements ServletContextListener {
settings.setUnionOntModelSelector(ModelContext.getUnionOntModelSelector(ctx));
boolean tryMigrateDisplay = true;
try {
settings.setDisplayModel(ModelContext.getDisplayModel(ctx));
settings.setDisplayModel(ModelAccess.on(ctx).getDisplayModel());
OntModel oldTBoxModel = loadModelFromDirectory(ctx.getRealPath(OLD_TBOX_MODEL_DIR));
settings.setOldTBoxModel(oldTBoxModel);
OntModel newTBoxModel = loadModelFromDirectory(ctx.getRealPath(NEW_TBOX_MODEL_DIR));

View file

@ -5,6 +5,8 @@ package edu.cornell.mannlib.vitro.webapp.utils;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.ServletContext;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@ -21,6 +23,7 @@ import com.hp.hpl.jena.rdf.model.Resource;
import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
import edu.cornell.mannlib.vitro.webapp.dao.jena.ModelContext;
public class ApplicationConfigurationOntologyUtils {
@ -28,8 +31,9 @@ public class ApplicationConfigurationOntologyUtils {
private static final Log log = LogFactory.getLog(ApplicationConfigurationOntologyUtils.class);
public static List<ObjectProperty> getAdditionalFauxSubpropertiesForList(List<ObjectProperty> propList, VitroRequest vreq) {
Model displayModel = ModelContext.getDisplayModel(vreq.getSession().getServletContext());
Model tboxModel = ModelContext.getUnionOntModelSelector(vreq.getSession().getServletContext()).getTBoxModel();
ServletContext ctx = vreq.getSession().getServletContext();
Model displayModel = ModelAccess.on(ctx).getDisplayModel();
Model tboxModel = ModelContext.getUnionOntModelSelector(ctx).getTBoxModel();
return getAdditionalFauxSubpropertiesForList(propList, displayModel, tboxModel);
}

View file

@ -1,8 +1,6 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package edu.cornell.mannlib.vitro.webapp.utils.dataGetter;
import java.util.Map;
import javax.servlet.ServletContext;
import org.apache.commons.lang.StringUtils;
@ -11,9 +9,7 @@ import com.hp.hpl.jena.rdf.model.Model;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.controller.jena.JenaIngestController;
import edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary;
import edu.cornell.mannlib.vitro.webapp.dao.jena.VitroJenaModelMaker;
import edu.cornell.mannlib.vitro.webapp.dao.jena.VitroJenaSDBModelMaker;
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
public abstract class DataGetterBase implements DataGetter {
@ -29,7 +25,7 @@ public abstract class DataGetterBase implements DataGetter {
}else if( REQUEST_JENA_ONT_MODEL.equals(modelName)){
return vreq.getJenaOntModel();
}else if( CONTEXT_DISPLAY_MODEL.equals(modelName)){
return (Model)context.getAttribute( DisplayVocabulary.DISPLAY_ONT_MODEL);
return ModelAccess.on(context).getDisplayModel();
}else if( ! StringUtils.isEmpty( modelName)){
Model model = JenaIngestController.getModel( modelName, vreq, context);
if( model == null )