Merging 9412 9377 and 9372 from vitro 1.4 branch
This commit is contained in:
parent
a30e1d5842
commit
96f172d52b
6 changed files with 78 additions and 239 deletions
|
@ -44,7 +44,8 @@ public class ProhibitedFromSearch implements ClassProhibitedFromSearch{
|
|||
public synchronized boolean isClassProhibitedFromSearch(String classURI){
|
||||
if( classURI != null ){
|
||||
boolean p = prohibitedClasses.contains(classURI);
|
||||
log.debug( classURI + " is " + (p?"prohibited":"not prohibited"));
|
||||
if( p )
|
||||
log.debug( classURI + " is prohibited from search");
|
||||
return p;
|
||||
}else{
|
||||
return false;
|
||||
|
|
|
@ -260,9 +260,10 @@ public class IndexBuilder extends VitroBackgroundThread {
|
|||
try {
|
||||
Individual ind = indDao.getIndividualByURI(uri);
|
||||
if (ind != null) {
|
||||
log.debug("uri to update or add to search index: " + uri);
|
||||
uriLists.updatedUris.add(uri);
|
||||
} else {
|
||||
log.debug("found delete in changed uris");
|
||||
log.debug("found delete in changed uris: " + uri);
|
||||
uriLists.deletedUris.add(uri);
|
||||
}
|
||||
} catch (QueryParseException ex) {
|
||||
|
|
|
@ -0,0 +1,65 @@
|
|||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||
package edu.cornell.mannlib.vitro.webapp.search.indexing;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import com.hp.hpl.jena.rdf.model.Statement;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.IndividualDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
||||
import edu.cornell.mannlib.vitro.webapp.search.beans.StatementToURIsToUpdate;
|
||||
|
||||
/**
|
||||
* if a class's classgroup changes, reindex all individuals in that class.
|
||||
*/
|
||||
public class URIsForClassGroupChange implements StatementToURIsToUpdate {
|
||||
|
||||
IndividualDao indDao;
|
||||
|
||||
public URIsForClassGroupChange(IndividualDao individualDao){
|
||||
this.indDao = individualDao;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> findAdditionalURIsToIndex(Statement stmt) {
|
||||
if( stmt == null || stmt.getPredicate() == null)
|
||||
return Collections.emptyList();
|
||||
|
||||
//if it is a change in classgroup of a class
|
||||
if( VitroVocabulary.IN_CLASSGROUP.equals( stmt.getPredicate().getURI() ) &&
|
||||
stmt.getSubject() != null &&
|
||||
stmt.getSubject().isURIResource() ){
|
||||
|
||||
//get individuals in class
|
||||
List<Individual>indsInClass =
|
||||
indDao.getIndividualsByVClassURI(stmt.getSubject().getURI());
|
||||
if( indsInClass == null )
|
||||
return Collections.emptyList();
|
||||
|
||||
//convert individuals to list of uris
|
||||
List<String> uris = new ArrayList<String>();
|
||||
for( Individual ind : indsInClass){
|
||||
uris.add( ind.getURI() );
|
||||
}
|
||||
return uris;
|
||||
}else{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startIndexing() {
|
||||
// Do nothing
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endIndxing() {
|
||||
// Do nothing
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -18,16 +18,14 @@ 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.query.Dataset;
|
||||
import com.hp.hpl.jena.query.DatasetFactory;
|
||||
|
||||
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.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.JenaBaseDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.ModelContext;
|
||||
import edu.cornell.mannlib.vitro.webapp.search.beans.FileBasedProhibitedFromSearch;
|
||||
import edu.cornell.mannlib.vitro.webapp.search.beans.IndividualProhibitedFromSearchImpl;
|
||||
|
@ -39,6 +37,7 @@ import edu.cornell.mannlib.vitro.webapp.search.indexing.AdditionalURIsForObjectP
|
|||
import edu.cornell.mannlib.vitro.webapp.search.indexing.AdditionalURIsForTypeStatements;
|
||||
import edu.cornell.mannlib.vitro.webapp.search.indexing.IndexBuilder;
|
||||
import edu.cornell.mannlib.vitro.webapp.search.indexing.SearchReindexingListener;
|
||||
import edu.cornell.mannlib.vitro.webapp.search.indexing.URIsForClassGroupChange;
|
||||
import edu.cornell.mannlib.vitro.webapp.startup.StartupStatus;
|
||||
|
||||
public class SolrSetup implements javax.servlet.ServletContextListener{
|
||||
|
@ -85,14 +84,7 @@ public class SolrSetup implements javax.servlet.ServletContextListener{
|
|||
context.setAttribute(SOLR_SERVER, server);
|
||||
|
||||
/* set up the individual to solr doc translation */
|
||||
// OntModel displayOntModel = (OntModel) sce.getServletContext().getAttribute("displayOntModel");
|
||||
//
|
||||
// OntModel abox = ModelContext.getBaseOntModelSelector(context).getABoxModel();
|
||||
// OntModel inferences = (OntModel)context.getAttribute( JenaBaseDao.INFERENCE_ONT_MODEL_ATTRIBUTE_NAME);
|
||||
// Dataset dataset = DatasetFactory.create(ModelContext.getJenaOntModel(context));
|
||||
|
||||
OntModel jenaOntModel = ModelContext.getJenaOntModel(context);
|
||||
|
||||
OntModel jenaOntModel = ModelContext.getJenaOntModel(context);
|
||||
|
||||
/* try to get context attribute DocumentModifiers
|
||||
* and use that as the start of the list of DocumentModifier
|
||||
|
@ -128,7 +120,7 @@ public class SolrSetup implements javax.servlet.ServletContextListener{
|
|||
wadf = new WebappDaoFactoryFiltering(wadf, vf);
|
||||
|
||||
// make objects that will find additional URIs for context nodes etc
|
||||
List<StatementToURIsToUpdate> uriFinders = makeURIFinders(jenaOntModel);
|
||||
List<StatementToURIsToUpdate> uriFinders = makeURIFinders(jenaOntModel,wadf.getIndividualDao());
|
||||
|
||||
// Make the IndexBuilder
|
||||
IndexBuilder builder = new IndexBuilder( solrIndexer, wadf, uriFinders );
|
||||
|
@ -150,13 +142,15 @@ public class SolrSetup implements javax.servlet.ServletContextListener{
|
|||
/**
|
||||
* Make a list of StatementToURIsToUpdate objects for use by the
|
||||
* IndexBuidler.
|
||||
* @param indDao
|
||||
*/
|
||||
public List<StatementToURIsToUpdate> makeURIFinders( OntModel jenaOntModel ){
|
||||
public List<StatementToURIsToUpdate> makeURIFinders( OntModel jenaOntModel, IndividualDao indDao ){
|
||||
List<StatementToURIsToUpdate> uriFinders = new ArrayList<StatementToURIsToUpdate>();
|
||||
uriFinders.add( new AdditionalURIsForDataProperties() );
|
||||
uriFinders.add( new AdditionalURIsForObjectProperties(jenaOntModel) );
|
||||
uriFinders.add( new AdditionalURIsForContextNodes(jenaOntModel) );
|
||||
uriFinders.add( new AdditionalURIsForTypeStatements() );
|
||||
uriFinders.add( new URIsForClassGroupChange( indDao ));
|
||||
return uriFinders;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue