improvements to model listener registration
This commit is contained in:
parent
53de388998
commit
7149091c75
3 changed files with 91 additions and 15 deletions
|
@ -21,6 +21,7 @@ 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.WebappDaoFactoryFiltering;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.filtering.filters.VitroFilterUtils;
|
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.filtering.filters.VitroFilters;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.dao.jena.ModelContext;
|
||||||
import edu.cornell.mannlib.vitro.webapp.flags.PortalFlag;
|
import edu.cornell.mannlib.vitro.webapp.flags.PortalFlag;
|
||||||
import edu.cornell.mannlib.vitro.webapp.search.beans.ProhibitedFromSearch;
|
import edu.cornell.mannlib.vitro.webapp.search.beans.ProhibitedFromSearch;
|
||||||
import edu.cornell.mannlib.vitro.webapp.web.DisplayVocabulary;
|
import edu.cornell.mannlib.vitro.webapp.web.DisplayVocabulary;
|
||||||
|
@ -55,16 +56,11 @@ public class BrowseController extends FreemarkerHttpServlet {
|
||||||
super.init(servletConfig);
|
super.init(servletConfig);
|
||||||
ServletContext sContext = servletConfig.getServletContext();
|
ServletContext sContext = servletConfig.getServletContext();
|
||||||
|
|
||||||
//BJL23: I'll work on a strategy for avoiding all this craziness.
|
|
||||||
OntModel model = (OntModel)sContext.getAttribute("jenaOntModel");
|
|
||||||
OntModel baseModel = (OntModel)sContext.getAttribute("baseOntModel");
|
|
||||||
OntModel infModel = (OntModel)sContext.getAttribute("inferenceOntModel");
|
|
||||||
|
|
||||||
|
|
||||||
BrowseControllerChangeListener bccl = new BrowseControllerChangeListener(this);
|
BrowseControllerChangeListener bccl = new BrowseControllerChangeListener(this);
|
||||||
model.register(bccl);
|
ModelContext.getJenaOntModel(sContext).register(bccl);
|
||||||
baseModel.register(bccl);
|
ModelContext.getBaseOntModel(sContext).register(bccl);
|
||||||
infModel.register(bccl);
|
ModelContext.getInferenceOntModel(sContext).register(bccl);
|
||||||
|
ModelContext.getUnionOntModelSelector(sContext).getABoxModel().register(bccl);
|
||||||
|
|
||||||
_rebuildQueue.add(REBUILD_EVERY_PORTAL);
|
_rebuildQueue.add(REBUILD_EVERY_PORTAL);
|
||||||
_cacheRebuildThread = new RebuildGroupCacheThread(this);
|
_cacheRebuildThread = new RebuildGroupCacheThread(this);
|
||||||
|
|
|
@ -0,0 +1,78 @@
|
||||||
|
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||||
|
|
||||||
|
package edu.cornell.mannlib.vitro.webapp.dao.jena;
|
||||||
|
|
||||||
|
import javax.servlet.ServletContext;
|
||||||
|
|
||||||
|
import com.hp.hpl.jena.ontology.OntModel;
|
||||||
|
|
||||||
|
public class ModelContext {
|
||||||
|
|
||||||
|
private static final String ONT_MODEL_SELECTOR = "ontModelSelector";
|
||||||
|
private static final String UNION_ONT_MODEL_SELECTOR = "unionOntModelSelector";
|
||||||
|
private static final String BASE_ONT_MODEL_SELECTOR = "baseOntModelSelector";
|
||||||
|
private static final String INFERENCE_ONT_MODEL_SELECTOR = "inferenceOntModelSelector";
|
||||||
|
|
||||||
|
private static final String JENA_ONT_MODEL = "jenaOntModel";
|
||||||
|
private static final String BASE_ONT_MODEL = "baseOntModel";
|
||||||
|
private static final String INFERENCE_ONT_MODEL = "inferenceOntModel";
|
||||||
|
|
||||||
|
public 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -31,6 +31,8 @@ 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.WebappDaoFactoryFiltering;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.filtering.filters.VitroFilterUtils;
|
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.filtering.filters.VitroFilters;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.dao.jena.ModelContext;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.dao.jena.OntModelSelector;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.SearchReindexingListener;
|
import edu.cornell.mannlib.vitro.webapp.dao.jena.SearchReindexingListener;
|
||||||
import edu.cornell.mannlib.vitro.webapp.search.beans.ObjectSourceIface;
|
import edu.cornell.mannlib.vitro.webapp.search.beans.ObjectSourceIface;
|
||||||
import edu.cornell.mannlib.vitro.webapp.search.beans.ProhibitedFromSearch;
|
import edu.cornell.mannlib.vitro.webapp.search.beans.ProhibitedFromSearch;
|
||||||
|
@ -115,13 +117,13 @@ public class LuceneSetup implements javax.servlet.ServletContextListener {
|
||||||
context.setAttribute(IndexBuilder.class.getName(), builder);
|
context.setAttribute(IndexBuilder.class.getName(), builder);
|
||||||
|
|
||||||
// set up listeners so search index builder is notified of changes to model
|
// set up listeners so search index builder is notified of changes to model
|
||||||
OntModel baseOntModel = (OntModel) sce.getServletContext().getAttribute("baseOntModel");
|
ServletContext ctx = sce.getServletContext();
|
||||||
OntModel jenaOntModel = (OntModel) sce.getServletContext().getAttribute("jenaOntModel");
|
|
||||||
OntModel inferenceModel = (OntModel) sce.getServletContext().getAttribute("inferenceOntModel");
|
|
||||||
SearchReindexingListener srl = new SearchReindexingListener(builder);
|
SearchReindexingListener srl = new SearchReindexingListener(builder);
|
||||||
baseOntModel.getBaseModel().register(srl);
|
ModelContext.getBaseOntModel(ctx).getBaseModel().register(srl);
|
||||||
jenaOntModel.getBaseModel().register(srl);
|
ModelContext.getJenaOntModel(ctx).getBaseModel().register(srl);
|
||||||
inferenceModel.register(srl);
|
ModelContext.getInferenceOntModel(ctx).register(srl);
|
||||||
|
ModelContext.getUnionOntModelSelector(ctx).getABoxModel()
|
||||||
|
.getBaseModel().register(srl);
|
||||||
|
|
||||||
// set the classes that the indexBuilder ignores
|
// set the classes that the indexBuilder ignores
|
||||||
OntModel displayOntModel = (OntModel) sce.getServletContext().getAttribute("displayOntModel");
|
OntModel displayOntModel = (OntModel) sce.getServletContext().getAttribute("displayOntModel");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue