Removed EntityChangeListener, it was no longer in use. Moved ModelListener registration from JenaDatasourceSetup to LuceneSetup. NIHVIVO-643
This commit is contained in:
parent
3527b1c948
commit
2ada3b7c35
6 changed files with 48 additions and 84 deletions
|
@ -21,14 +21,12 @@ import org.joda.time.DateTime;
|
|||
import edu.cornell.mannlib.vedit.beans.LoginFormBean;
|
||||
import edu.cornell.mannlib.vedit.controller.BaseEditController;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.Property;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.PropertyInstance;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.IndividualDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.PropertyInstanceDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
||||
import edu.cornell.mannlib.vitro.webapp.utils.EntityChangeListener;
|
||||
|
||||
/**
|
||||
* NOTE:does not work yet under semweb-align - gets tricky here
|
||||
|
@ -169,19 +167,6 @@ throws ServletException, IOException {
|
|||
doPost(request,response);
|
||||
}
|
||||
|
||||
|
||||
private void addIndividualToLuceneIndex( ServletContext context, String uri ){
|
||||
try{
|
||||
Object obj = context.getAttribute(EntityChangeListener.class.getName());
|
||||
if(obj != null && obj instanceof EntityChangeListener ){
|
||||
EntityChangeListener listener = (EntityChangeListener) obj;
|
||||
listener.entityUpdated( uri );
|
||||
}
|
||||
}catch(Throwable t){
|
||||
log.error("GenericDBUpdate.checkForEntityChange() error:" + t);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempts to clone a tab.
|
||||
* This will check for the parameter 'tabId' and if it exists
|
||||
|
|
|
@ -20,7 +20,6 @@ import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
|||
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
||||
import edu.cornell.mannlib.vitro.webapp.search.IndexingException;
|
||||
import edu.cornell.mannlib.vitro.webapp.search.beans.ObjectSourceIface;
|
||||
import edu.cornell.mannlib.vitro.webapp.utils.EntityChangeListener;
|
||||
|
||||
/**
|
||||
* The IndexBuilder is used to rebuild or update a search index.
|
||||
|
@ -39,7 +38,7 @@ import edu.cornell.mannlib.vitro.webapp.utils.EntityChangeListener;
|
|||
* @author bdc34
|
||||
*
|
||||
*/
|
||||
public class IndexBuilder implements Runnable, EntityChangeListener{
|
||||
public class IndexBuilder implements Runnable {
|
||||
List<ObjectSourceIface> sourceList = new LinkedList<ObjectSourceIface>();
|
||||
IndexerIface indexer = null;
|
||||
ServletContext context = null;
|
||||
|
@ -60,10 +59,6 @@ public class IndexBuilder implements Runnable, EntityChangeListener{
|
|||
this.context = context;
|
||||
|
||||
changedUris = new LinkedList<String>();
|
||||
|
||||
//add this to the context as a EntityChangeListener so that we can
|
||||
//be notified of entity changes.
|
||||
context.setAttribute(EntityChangeListener.class.getName(), this);
|
||||
}
|
||||
|
||||
public void addObjectSource(ObjectSourceIface osi) {
|
||||
|
@ -262,15 +257,7 @@ public class IndexBuilder implements Runnable, EntityChangeListener{
|
|||
}
|
||||
return ;
|
||||
}
|
||||
|
||||
/* These methods are so that the IndexBuilder may register for entity changes */
|
||||
public void entityAdded(String entityURI) {
|
||||
if( log.isDebugEnabled())
|
||||
log.debug("IndexBuilder.entityAdded() " + entityURI);
|
||||
addToChangedUris(entityURI);
|
||||
(new Thread(this)).start();
|
||||
}
|
||||
|
||||
|
||||
public void entityDeleted(String entityURI) {
|
||||
if( log.isDebugEnabled())
|
||||
log.debug("IndexBuilder.entityDeleted() " + entityURI);
|
||||
|
@ -282,13 +269,6 @@ public class IndexBuilder implements Runnable, EntityChangeListener{
|
|||
}
|
||||
}
|
||||
|
||||
public void entityUpdated(String entityURI) {
|
||||
if( log.isDebugEnabled())
|
||||
log.debug("IndexBuilder.entityUpdate() " + entityURI);
|
||||
addToChangedUris(entityURI);
|
||||
(new Thread(this)).start();
|
||||
}
|
||||
|
||||
public synchronized void addToChangedUris(String uri){
|
||||
changedUris.add(uri);
|
||||
}
|
||||
|
|
|
@ -2,28 +2,32 @@
|
|||
|
||||
package edu.cornell.mannlib.vitro.webapp.search.lucene;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
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.lucene.analysis.Analyzer;
|
||||
import org.apache.lucene.search.BooleanQuery;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
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.lucene.analysis.Analyzer;
|
||||
import org.apache.lucene.search.BooleanQuery;
|
||||
|
||||
import com.hp.hpl.jena.ontology.OntModel;
|
||||
import com.hp.hpl.jena.rdf.model.Model;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.ConfigurationProperties;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.BaseResourceBean.RoleLevel;
|
||||
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.VitroFilterUtils;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.filtering.filters.VitroFilters;
|
||||
import edu.cornell.mannlib.vitro.webapp.search.beans.Searcher;
|
||||
import edu.cornell.mannlib.vitro.webapp.search.indexing.IndexBuilder;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.BaseResourceBean.RoleLevel;
|
||||
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.VitroFilterUtils;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.filtering.filters.VitroFilters;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.SearchReindexingListener;
|
||||
import edu.cornell.mannlib.vitro.webapp.search.beans.Searcher;
|
||||
import edu.cornell.mannlib.vitro.webapp.search.indexing.IndexBuilder;
|
||||
|
||||
/**
|
||||
* Setup objects for lucene searching and indexing.
|
||||
|
@ -107,7 +111,14 @@ public class LuceneSetup implements javax.servlet.ServletContextListener {
|
|||
// here we add the IndexBuilder with the LuceneIndexer
|
||||
// to the servlet context so we can access it later in the webapp.
|
||||
context.setAttribute(IndexBuilder.class.getName(),builder);
|
||||
|
||||
|
||||
//set up listeners so search index builder is notified of changes to model
|
||||
OntModel baseOntModel = (OntModel)sce.getServletContext().getAttribute("baseOntModel");
|
||||
OntModel jenaOntModel = (OntModel)sce.getServletContext().getAttribute("jenaOntModel");
|
||||
SearchReindexingListener srl = new SearchReindexingListener(baseOntModel, sce.getServletContext());
|
||||
baseOntModel.getBaseModel().register(srl);
|
||||
jenaOntModel.getBaseModel().register(srl);
|
||||
|
||||
log.debug("**** End of "+this.getClass().getName()+".contextInitialized()");
|
||||
} catch (Throwable t) {
|
||||
log.error(t);
|
||||
|
|
|
@ -16,6 +16,8 @@ import org.apache.commons.logging.LogFactory;
|
|||
import org.apache.lucene.analysis.Analyzer;
|
||||
import org.apache.lucene.analysis.cjk.CJKAnalyzer;
|
||||
import org.apache.lucene.search.BooleanQuery;
|
||||
|
||||
import com.hp.hpl.jena.ontology.OntModel;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.ConfigurationProperties;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.BaseResourceBean.RoleLevel;
|
||||
|
@ -23,6 +25,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.filters.VitroFilterUtils;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.filtering.filters.VitroFilters;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.SearchReindexingListener;
|
||||
import edu.cornell.mannlib.vitro.webapp.search.beans.Searcher;
|
||||
import edu.cornell.mannlib.vitro.webapp.search.indexing.IndexBuilder;
|
||||
|
||||
|
@ -104,7 +107,15 @@ public class LuceneSetupCJK implements javax.servlet.ServletContextListener {
|
|||
|
||||
// here we add the IndexBuilder with the LuceneIndexer
|
||||
// to the servlet context so we can access it later in the webapp.
|
||||
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
|
||||
OntModel baseOntModel = (OntModel)sce.getServletContext().getAttribute("baseOntModel");
|
||||
OntModel jenaOntModel = (OntModel)sce.getServletContext().getAttribute("jenaOntModel");
|
||||
SearchReindexingListener srl = new SearchReindexingListener(baseOntModel, sce.getServletContext());
|
||||
baseOntModel.getBaseModel().register(srl);
|
||||
jenaOntModel.getBaseModel().register(srl);
|
||||
|
||||
}catch(Exception ex){
|
||||
log.error("Could not setup lucene full text search." , ex);
|
||||
}
|
||||
|
|
|
@ -94,11 +94,7 @@ public class JenaDataSourceSetup extends JenaDataSourceSetupBase implements java
|
|||
}
|
||||
}
|
||||
|
||||
ensureEssentialInterfaceData(memModel, sce, wadf);
|
||||
|
||||
SearchReindexingListener srl = new SearchReindexingListener(memModel, sce.getServletContext());
|
||||
unionModel.getBaseModel().register(srl);
|
||||
memModel.getBaseModel().register(srl);
|
||||
ensureEssentialInterfaceData(memModel, sce, wadf);
|
||||
|
||||
NamespaceMapper namespaceMapper = new NamespaceMapperJena(unionModel, unionModel, defaultNamespace);
|
||||
sce.getServletContext().setAttribute("NamespaceMapper", namespaceMapper);
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||
|
||||
package edu.cornell.mannlib.vitro.webapp.utils;
|
||||
|
||||
/**
|
||||
* This interface is to be implemented by classes that want to know
|
||||
* when entities change. A class that imeplements this will be able
|
||||
* to register with classes that change entities.
|
||||
*
|
||||
* These can be thought of as callbacks.
|
||||
*
|
||||
* @author bdc34
|
||||
*
|
||||
*/
|
||||
public interface EntityChangeListener {
|
||||
public void entityAdded(String entityURI );
|
||||
public void entityDeleted(String entityURI);
|
||||
public void entityUpdated(String entityURI);
|
||||
}
|
Loading…
Add table
Reference in a new issue