VIVO-906 Explicitly configure the SearchIndexExcluders and DocumentModifiers.
This commit is contained in:
parent
78241be685
commit
68b06322fb
15 changed files with 106 additions and 154 deletions
|
@ -12,6 +12,7 @@ import org.apache.commons.logging.Log;
|
|||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import com.hp.hpl.jena.query.Dataset;
|
||||
import com.hp.hpl.jena.query.DatasetFactory;
|
||||
import com.hp.hpl.jena.query.Query;
|
||||
import com.hp.hpl.jena.query.QueryExecution;
|
||||
import com.hp.hpl.jena.query.QueryExecutionFactory;
|
||||
|
@ -26,12 +27,13 @@ import com.hp.hpl.jena.rdf.model.ResourceFactory;
|
|||
import com.hp.hpl.jena.shared.Lock;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
||||
import edu.cornell.mannlib.vitro.webapp.modelaccess.ContextModelAccess;
|
||||
import edu.cornell.mannlib.vitro.webapp.modules.searchEngine.SearchInputDocument;
|
||||
import edu.cornell.mannlib.vitro.webapp.search.VitroSearchTermNames;
|
||||
import edu.cornell.mannlib.vitro.webapp.search.documentBuilding.DocumentModifier;
|
||||
import edu.cornell.mannlib.vitro.webapp.utils.configuration.ContextModelsUser;
|
||||
|
||||
|
||||
public class CalculateParameters implements DocumentModifier {
|
||||
public class CalculateParameters implements DocumentModifier, ContextModelsUser {
|
||||
|
||||
private boolean shutdown = false;
|
||||
private Dataset dataset;
|
||||
|
@ -60,15 +62,11 @@ public class CalculateParameters implements DocumentModifier {
|
|||
|
||||
private static Log log = LogFactory.getLog(CalculateParameters.class);
|
||||
|
||||
public CalculateParameters(Dataset dataset){
|
||||
this.dataset =dataset;
|
||||
// new Thread(new TotalInd(this.dataset,totalCountQuery)).start();
|
||||
@Override
|
||||
public void setContextModels(ContextModelAccess models) {
|
||||
this.dataset = DatasetFactory.create(models.getOntModel());
|
||||
}
|
||||
|
||||
public CalculateParameters(){
|
||||
super();
|
||||
}
|
||||
|
||||
|
||||
public float calculateBeta(String uri){
|
||||
float beta=0;
|
||||
int Conn=0;
|
||||
|
|
|
@ -15,11 +15,11 @@ import com.hp.hpl.jena.query.ResultSet;
|
|||
import com.hp.hpl.jena.rdf.model.RDFNode;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
||||
import edu.cornell.mannlib.vitro.webapp.modelaccess.ContextModelAccess;
|
||||
import edu.cornell.mannlib.vitro.webapp.modules.searchEngine.SearchInputDocument;
|
||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
|
||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceFactory;
|
||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.RDFServiceUtils;
|
||||
import edu.cornell.mannlib.vitro.webapp.search.documentBuilding.DocumentModifier;
|
||||
import edu.cornell.mannlib.vitro.webapp.utils.configuration.ContextModelsUser;
|
||||
|
||||
/**
|
||||
* If there are any VCards on this Individual with Title objects, store the text
|
||||
|
@ -28,7 +28,7 @@ import edu.cornell.mannlib.vitro.webapp.search.documentBuilding.DocumentModifier
|
|||
* If there are any VCards on this Individual with EMail objects, store the text
|
||||
* in the ALL_TEXT field.
|
||||
*/
|
||||
public class VIVOValuesFromVcards implements DocumentModifier {
|
||||
public class VIVOValuesFromVcards implements DocumentModifier, ContextModelsUser {
|
||||
private static final Log log = LogFactory
|
||||
.getLog(VIVOValuesFromVcards.class);
|
||||
|
||||
|
@ -77,11 +77,12 @@ public class VIVOValuesFromVcards implements DocumentModifier {
|
|||
}
|
||||
}};
|
||||
|
||||
private RDFServiceFactory rdfServiceFactory;
|
||||
private RDFService rdfService;
|
||||
private boolean shutdown = false;
|
||||
|
||||
public VIVOValuesFromVcards(RDFServiceFactory rdfServiceFactory) {
|
||||
this.rdfServiceFactory = rdfServiceFactory;
|
||||
@Override
|
||||
public void setContextModels(ContextModelAccess models) {
|
||||
this.rdfService = models.getRDFService();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -100,7 +101,6 @@ public class VIVOValuesFromVcards implements DocumentModifier {
|
|||
String query = queryTemplate.replaceAll("\\?uri", uri);
|
||||
|
||||
try {
|
||||
RDFService rdfService = rdfServiceFactory.getRDFService();
|
||||
ResultSet results = RDFServiceUtils.sparqlSelectQuery(query,
|
||||
rdfService);
|
||||
if (results != null) {
|
||||
|
|
|
@ -4,9 +4,6 @@ package edu.cornell.mannlib.vitro.webapp.search.documentBuilding;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceFactory;
|
||||
import edu.cornell.mannlib.vitro.webapp.search.documentBuilding.ContextNodeFields;
|
||||
|
||||
/**
|
||||
* Class that adds text from context nodes to Search Documents for
|
||||
* foaf:Agent individuals.
|
||||
|
@ -15,8 +12,8 @@ public class VivoAgentContextNodeFields extends ContextNodeFields{
|
|||
|
||||
static List<String> queriesForAgent = new ArrayList<String>();
|
||||
|
||||
public VivoAgentContextNodeFields(RDFServiceFactory rdfServiceFactory){
|
||||
super(queriesForAgent,rdfServiceFactory);
|
||||
public VivoAgentContextNodeFields(){
|
||||
super(queriesForAgent);
|
||||
}
|
||||
|
||||
protected static final String prefix =
|
||||
|
|
|
@ -1,72 +0,0 @@
|
|||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||
package edu.cornell.mannlib.vitro.webapp.search.documentBuilding;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.ServletContextEvent;
|
||||
|
||||
import com.hp.hpl.jena.query.Dataset;
|
||||
import com.hp.hpl.jena.query.DatasetFactory;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess;
|
||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceFactory;
|
||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.RDFServiceUtils;
|
||||
|
||||
public class VivoDocumentModifiers implements javax.servlet.ServletContextListener{
|
||||
|
||||
/**
|
||||
* Exclude from the search index individuals who's URIs start with these namespaces.
|
||||
*/
|
||||
private static final String[] INDIVIDUAL_NS_EXCLUDES={
|
||||
//bdc34: seems that there are a lot of odd OBO things in the search, exclude them
|
||||
"http://purl.obolibrary.org/obo/"
|
||||
};
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void contextInitialized(ServletContextEvent sce) {
|
||||
|
||||
ServletContext context = sce.getServletContext();
|
||||
RDFServiceFactory rdfServiceFactory = RDFServiceUtils.getRDFServiceFactory(context);
|
||||
|
||||
Dataset dataset = DatasetFactory.create(ModelAccess.on(context).getOntModel());
|
||||
|
||||
/* Put DocumentModifiers into servlet context for use later in startup by SearchSetup
|
||||
* This adds the code for VIVO specific additions to the building
|
||||
* of search input Documents. */
|
||||
List<DocumentModifier> modifiers = (List<DocumentModifier>)context.getAttribute("DocumentModifiers");
|
||||
if( modifiers == null ){
|
||||
modifiers = new ArrayList<DocumentModifier>();
|
||||
context.setAttribute("DocumentModifiers", modifiers);
|
||||
}
|
||||
|
||||
modifiers.add(new CalculateParameters(dataset));
|
||||
modifiers.add( new VIVOValuesFromVcards( rdfServiceFactory ));
|
||||
modifiers.add( new VivoISFBasicFields( rdfServiceFactory ));
|
||||
modifiers.add( new VivoISFAdvisingFields( rdfServiceFactory ));
|
||||
modifiers.add( new VivoISFEducationFields( rdfServiceFactory ));
|
||||
modifiers.add( new VivoISFGrantFields( rdfServiceFactory ));
|
||||
modifiers.add( new VivoISFMemberFields( rdfServiceFactory ));
|
||||
modifiers.add(new VivoInformationResourceContextNodeFields(rdfServiceFactory));
|
||||
|
||||
/*
|
||||
* Add VIVO specific code that excludes Individuals from the search index.
|
||||
*/
|
||||
List<SearchIndexExcluder> excludes =
|
||||
(List<SearchIndexExcluder>)context.getAttribute("SearchIndexExcludes");
|
||||
|
||||
if( excludes == null ){
|
||||
excludes = new ArrayList<SearchIndexExcluder>();
|
||||
context.setAttribute("SearchIndexExcludes", excludes);
|
||||
}
|
||||
|
||||
excludes.add(new ExcludeBasedOnNamespace(INDIVIDUAL_NS_EXCLUDES ));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void contextDestroyed(ServletContextEvent arg0) {
|
||||
// do nothing.
|
||||
}
|
||||
}
|
|
@ -5,9 +5,6 @@ package edu.cornell.mannlib.vitro.webapp.search.documentBuilding;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceFactory;
|
||||
import edu.cornell.mannlib.vitro.webapp.search.documentBuilding.ContextNodeFields;
|
||||
|
||||
/**
|
||||
* DocumentModifier for adding rdfs:labels of individuals related via
|
||||
* a advising relationship.
|
||||
|
@ -31,8 +28,8 @@ public class VivoISFAdvisingFields extends ContextNodeFields {
|
|||
queries.add( makeQueryForPeople() );
|
||||
}
|
||||
|
||||
public VivoISFAdvisingFields(RDFServiceFactory rdfServiceFactory){
|
||||
super(queries,rdfServiceFactory);
|
||||
public VivoISFAdvisingFields(){
|
||||
super(queries);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -5,9 +5,6 @@ package edu.cornell.mannlib.vitro.webapp.search.documentBuilding;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceFactory;
|
||||
import edu.cornell.mannlib.vitro.webapp.search.documentBuilding.ContextNodeFields;
|
||||
|
||||
/**
|
||||
* DocumentModifier to populate Search index fields for the basic ISF relationships.
|
||||
*
|
||||
|
@ -32,8 +29,8 @@ public class VivoISFBasicFields extends ContextNodeFields {
|
|||
|
||||
static List<String> queries = new ArrayList<String>();
|
||||
|
||||
public VivoISFBasicFields(RDFServiceFactory rdfServiceFactory){
|
||||
super(queries,rdfServiceFactory);
|
||||
public VivoISFBasicFields(){
|
||||
super(queries);
|
||||
}
|
||||
|
||||
protected static final String prefix =
|
||||
|
|
|
@ -5,9 +5,6 @@ package edu.cornell.mannlib.vitro.webapp.search.documentBuilding;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceFactory;
|
||||
import edu.cornell.mannlib.vitro.webapp.search.documentBuilding.ContextNodeFields;
|
||||
|
||||
public class VivoISFEducationFields extends ContextNodeFields {
|
||||
private static String VIVONS = "http://vivoweb.org/ontology/core#";
|
||||
|
||||
|
@ -18,8 +15,8 @@ public class VivoISFEducationFields extends ContextNodeFields {
|
|||
+ " prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n"
|
||||
+ " prefix obo: <http://purl.obolibrary.org/obo/> \n" ;
|
||||
|
||||
public VivoISFEducationFields(RDFServiceFactory rdfServiceFactory){
|
||||
super(queries,rdfServiceFactory);
|
||||
public VivoISFEducationFields(){
|
||||
super(queries);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -5,9 +5,6 @@ package edu.cornell.mannlib.vitro.webapp.search.documentBuilding;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceFactory;
|
||||
import edu.cornell.mannlib.vitro.webapp.search.documentBuilding.ContextNodeFields;
|
||||
|
||||
/*
|
||||
* This DocumentModifier is for the ISF style grants.
|
||||
* It will
|
||||
|
@ -30,8 +27,8 @@ public class VivoISFGrantFields extends ContextNodeFields {
|
|||
+ " prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n"
|
||||
+ " prefix obo: <http://purl.obolibrary.org/obo/> \n" ;
|
||||
|
||||
public VivoISFGrantFields(RDFServiceFactory rdfServiceFactory){
|
||||
super(queries,rdfServiceFactory);
|
||||
public VivoISFGrantFields(){
|
||||
super(queries);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -5,9 +5,6 @@ package edu.cornell.mannlib.vitro.webapp.search.documentBuilding;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceFactory;
|
||||
import edu.cornell.mannlib.vitro.webapp.search.documentBuilding.ContextNodeFields;
|
||||
|
||||
/**
|
||||
* This class will:
|
||||
* add people's names to organization's search Documents.
|
||||
|
@ -26,8 +23,8 @@ public class VivoISFMemberFields extends ContextNodeFields {
|
|||
+ " prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n"
|
||||
+ " prefix obo: <http://purl.obolibrary.org/obo/> \n" ;
|
||||
|
||||
public VivoISFMemberFields(RDFServiceFactory rdfServiceFactory){
|
||||
super(queries,rdfServiceFactory);
|
||||
public VivoISFMemberFields(){
|
||||
super(queries);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -4,9 +4,6 @@ package edu.cornell.mannlib.vitro.webapp.search.documentBuilding;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceFactory;
|
||||
import edu.cornell.mannlib.vitro.webapp.search.documentBuilding.ContextNodeFields;
|
||||
|
||||
/**
|
||||
* Class that adds text from context nodes to search index Documents for
|
||||
* obo:IAO_0000030 individuals.
|
||||
|
@ -18,8 +15,8 @@ public class VivoInformationResourceContextNodeFields extends ContextNodeFields{
|
|||
|
||||
static List<String> queriesForInformationResource = new ArrayList<String>();
|
||||
|
||||
public VivoInformationResourceContextNodeFields(RDFServiceFactory rdfServiceFactory){
|
||||
super(queriesForInformationResource, rdfServiceFactory);
|
||||
public VivoInformationResourceContextNodeFields(){
|
||||
super(queriesForInformationResource);
|
||||
}
|
||||
|
||||
protected static final String prefix =
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue