VIVO-870 Make IndexingUriFinders configurable.

Use no-argument constructors, supplying data through the ContextModelsUser interface as needed.

Add toString() methods to IndexingUriFinders, DocumentModifiers and SearchIndexExcluders
This commit is contained in:
j2blake 2015-01-07 17:26:07 -05:00
parent 5b89014105
commit 69711960bc
8 changed files with 109 additions and 93 deletions

View file

@ -1,46 +0,0 @@
@prefix : <http://vitro.mannlib.cornell.edu/ns/vitro/ApplicationSetup#> .
#
# Specify the SearchIndexExcluders and DocumentModifiers for VIVO.
# These are in addition to the ones specified for VIVO.
#
:vivoSearchExcluder_namespaceExcluder
a <java:edu.cornell.mannlib.vitro.webapp.search.documentBuilding.ExcludeBasedOnNamespace> ,
<java:edu.cornell.mannlib.vitro.webapp.search.documentBuilding.SearchIndexExcluder> ;
:excludes
"http://purl.obolibrary.org/obo/" .
# ------------------------------------
:vivodocumentModifier_calculateParameters
a <java:edu.cornell.mannlib.vitro.webapp.search.documentBuilding.CalculateParameters> ,
<java:edu.cornell.mannlib.vitro.webapp.search.documentBuilding.DocumentModifier> .
:vivodocumentModifier_valuesFromVcards
a <java:edu.cornell.mannlib.vitro.webapp.search.documentBuilding.VIVOValuesFromVcards> ,
<java:edu.cornell.mannlib.vitro.webapp.search.documentBuilding.DocumentModifier> .
:vivodocumentModifier_ISFBasicFields
a <java:edu.cornell.mannlib.vitro.webapp.search.documentBuilding.VivoISFBasicFields> ,
<java:edu.cornell.mannlib.vitro.webapp.search.documentBuilding.DocumentModifier> .
:vivodocumentModifier_ISFAdvisingFields
a <java:edu.cornell.mannlib.vitro.webapp.search.documentBuilding.VivoISFAdvisingFields> ,
<java:edu.cornell.mannlib.vitro.webapp.search.documentBuilding.DocumentModifier> .
:vivodocumentModifier_ISFEducationFields
a <java:edu.cornell.mannlib.vitro.webapp.search.documentBuilding.VivoISFEducationFields> ,
<java:edu.cornell.mannlib.vitro.webapp.search.documentBuilding.DocumentModifier> .
:vivodocumentModifier_ISFGrantFields
a <java:edu.cornell.mannlib.vitro.webapp.search.documentBuilding.VivoISFGrantFields> ,
<java:edu.cornell.mannlib.vitro.webapp.search.documentBuilding.DocumentModifier> .
:vivodocumentModifier_ISFMemberFields
a <java:edu.cornell.mannlib.vitro.webapp.search.documentBuilding.VivoISFMemberFields> ,
<java:edu.cornell.mannlib.vitro.webapp.search.documentBuilding.DocumentModifier> .
:vivodocumentModifier_informationResourceContextNodeFields
a <java:edu.cornell.mannlib.vitro.webapp.search.documentBuilding.VivoInformationResourceContextNodeFields> ,
<java:edu.cornell.mannlib.vitro.webapp.search.documentBuilding.DocumentModifier> .

View file

@ -0,0 +1,56 @@
@prefix : <http://vitro.mannlib.cornell.edu/ns/vitro/ApplicationSetup#> .
#
# Specify the SearchIndexExcluders, DocumentModifiers and IndexingUriFinders for VIVO.
# These are in addition to the ones specified for VIVO.
#
:vivoSearchExcluder_namespaceExcluder
a <java:edu.cornell.mannlib.vitro.webapp.searchindex.exclusions.ExcludeBasedOnNamespace> ,
<java:edu.cornell.mannlib.vitro.webapp.searchindex.exclusions.SearchIndexExcluder> ;
:excludes
"http://purl.obolibrary.org/obo/" .
# ------------------------------------
:vivodocumentModifier_calculateParameters
a <java:edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.CalculateParameters> ,
<java:edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.DocumentModifier> .
:vivodocumentModifier_valuesFromVcards
a <java:edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.VIVOValuesFromVcards> ,
<java:edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.DocumentModifier> .
:vivodocumentModifier_ISFBasicFields
a <java:edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.VivoISFBasicFields> ,
<java:edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.DocumentModifier> .
:vivodocumentModifier_ISFAdvisingFields
a <java:edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.VivoISFAdvisingFields> ,
<java:edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.DocumentModifier> .
:vivodocumentModifier_ISFEducationFields
a <java:edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.VivoISFEducationFields> ,
<java:edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.DocumentModifier> .
:vivodocumentModifier_ISFGrantFields
a <java:edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.VivoISFGrantFields> ,
<java:edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.DocumentModifier> .
:vivodocumentModifier_ISFMemberFields
a <java:edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.VivoISFMemberFields> ,
<java:edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.DocumentModifier> .
:vivodocumentModifier_informationResourceContextNodeFields
a <java:edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.VivoInformationResourceContextNodeFields> ,
<java:edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.DocumentModifier> .
# ------------------------------------
:uriFinder_forContextNodes
a <java:edu.cornell.mannlib.vitro.webapp.searchindex.indexing.IndexingUriFinder> ,
<java:edu.cornell.mannlib.vitro.webapp.searchindex.indexing.AdditionalURIsForContextNodes> .
:uriFinder_forVCards
a <java:edu.cornell.mannlib.vitro.webapp.searchindex.indexing.IndexingUriFinder> ,
<java:edu.cornell.mannlib.vitro.webapp.searchindex.indexing.AdditionalUrisForVCards> .

View file

@ -254,6 +254,13 @@ public class CalculateParameters implements DocumentModifier, ContextModelsUser
public void shutdown(){ public void shutdown(){
shutdown=true; shutdown=true;
} }
@Override
public String toString() {
return this.getClass().getSimpleName() + "[]";
}
} }
class TotalInd implements Runnable{ class TotalInd implements Runnable{

View file

@ -122,6 +122,12 @@ public class VIVOValuesFromVcards implements DocumentModifier, ContextModelsUser
shutdown = true; shutdown = true;
} }
@Override
public String toString() {
return this.getClass().getSimpleName() + "[]";
}
private abstract static class ResultParser { private abstract static class ResultParser {
public abstract void parse(String uri, QuerySolution solution, SearchInputDocument doc); public abstract void parse(String uri, QuerySolution solution, SearchInputDocument doc);

View file

@ -21,24 +21,26 @@ import com.hp.hpl.jena.rdf.model.ResourceFactory;
import com.hp.hpl.jena.rdf.model.Statement; import com.hp.hpl.jena.rdf.model.Statement;
import edu.cornell.mannlib.vitro.webapp.dao.jena.QueryUtils; import edu.cornell.mannlib.vitro.webapp.dao.jena.QueryUtils;
import edu.cornell.mannlib.vitro.webapp.modelaccess.ContextModelAccess;
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService; import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
import edu.cornell.mannlib.vitro.webapp.utils.configuration.ContextModelsUser;
public class AdditionalURIsForContextNodes implements StatementToURIsToUpdate { public class AdditionalURIsForContextNodes implements IndexingUriFinder, ContextModelsUser {
private Log log = LogFactory.getLog(AdditionalURIsForContextNodes.class);
private final RDFService rdfService;
private Set<String> alreadyChecked;
private long accumulatedTime = 0;
private static final List<String> multiValuedQueriesForAgent = new ArrayList<String>(); private static final List<String> multiValuedQueriesForAgent = new ArrayList<String>();
private static final String multiValuedQueryForInformationContentEntity; private static final String multiValuedQueryForInformationContentEntity;
private static final List<String> multiValuedQueriesForRole = new ArrayList<String>(); private static final List<String> multiValuedQueriesForRole = new ArrayList<String>();
private static final List<String>queryList; private static final List<String>queryList;
private Log log = LogFactory.getLog(AdditionalURIsForContextNodes.class); private RDFService rdfService;
private Set<String> alreadyChecked;
private long accumulatedTime = 0;
public AdditionalURIsForContextNodes( RDFService rdfService){ @Override
this.rdfService = rdfService; public void setContextModels(ContextModelAccess models) {
this.rdfService = models.getRDFService();
} }
@Override @Override
@ -78,7 +80,7 @@ public class AdditionalURIsForContextNodes implements StatementToURIsToUpdate {
} }
@Override @Override
public void endIndxing() { public void endIndexing() {
log.debug( "Accumulated time for this run of the index: " + accumulatedTime + " msec"); log.debug( "Accumulated time for this run of the index: " + accumulatedTime + " msec");
alreadyChecked = null; alreadyChecked = null;
} }
@ -765,4 +767,9 @@ public class AdditionalURIsForContextNodes implements StatementToURIsToUpdate {
queryList = Collections.unmodifiableList(tmpList); queryList = Collections.unmodifiableList(tmpList);
} }
@Override
public String toString() {
return this.getClass().getSimpleName();
}
} }

View file

@ -1,29 +0,0 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package edu.cornell.mannlib.vitro.webapp.searchindex.indexing;
import java.util.ArrayList;
import java.util.List;
import edu.cornell.mannlib.vitro.webapp.dao.IndividualDao;
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
/**
* Make a list of StatementToURIsToUpdate objects for use by the
* IndexBuidler.
*/
public class AdditionalUriFinders {
public static List<StatementToURIsToUpdate> getList(RDFService rdfService,
IndividualDao indDao) {
List<StatementToURIsToUpdate> uriFinders = new ArrayList<>();
uriFinders.add(new AdditionalURIsForDataProperties());
uriFinders.add(new AdditionalURIsForObjectProperties(rdfService));
uriFinders.add(new AdditionalURIsForContextNodes(rdfService));
uriFinders.add(new AdditionalURIsForTypeStatements());
uriFinders.add(new URIsForClassGroupChange(indDao));
uriFinders.add(new AdditionalUrisForVCards(rdfService));
return uriFinders;
}
}

View file

@ -18,13 +18,15 @@ import com.hp.hpl.jena.rdf.model.ResourceFactory;
import com.hp.hpl.jena.rdf.model.Statement; import com.hp.hpl.jena.rdf.model.Statement;
import edu.cornell.mannlib.vitro.webapp.dao.jena.QueryUtils; import edu.cornell.mannlib.vitro.webapp.dao.jena.QueryUtils;
import edu.cornell.mannlib.vitro.webapp.modelaccess.ContextModelAccess;
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService; import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
import edu.cornell.mannlib.vitro.webapp.utils.configuration.ContextModelsUser;
/** /**
* If the property of a VCard object is changed, we should re-index the owner of * If the property of a VCard object is changed, we should re-index the owner of
* that VCard. * that VCard.
*/ */
public class AdditionalUrisForVCards implements StatementToURIsToUpdate { public class AdditionalUrisForVCards implements IndexingUriFinder, ContextModelsUser {
private static final Log log = LogFactory private static final Log log = LogFactory
.getLog(AdditionalUrisForVCards.class); .getLog(AdditionalUrisForVCards.class);
@ -37,10 +39,11 @@ public class AdditionalUrisForVCards implements StatementToURIsToUpdate {
+ " ?uri obo:ARG_2000028 ?contactInfo . \n " // + " ?uri obo:ARG_2000028 ?contactInfo . \n " //
+ "}"; + "}";
private final RDFService rdfService; private RDFService rdfService;
public AdditionalUrisForVCards(RDFService rdfService) { @Override
this.rdfService = rdfService; public void setContextModels(ContextModelAccess models) {
this.rdfService = models.getRDFService();
} }
@Override @Override
@ -113,8 +116,13 @@ public class AdditionalUrisForVCards implements StatementToURIsToUpdate {
} }
@Override @Override
public void endIndxing() { public void endIndexing() {
// Nothing to tear down. // Nothing to tear down.
} }
@Override
public String toString() {
return this.getClass().getSimpleName();
}
} }

View file

@ -9,9 +9,12 @@ import java.util.List;
import org.junit.Test; import org.junit.Test;
import stubs.edu.cornell.mannlib.vitro.webapp.modelaccess.ContextModelAccessStub;
import com.hp.hpl.jena.ontology.OntModel; import com.hp.hpl.jena.ontology.OntModel;
import com.hp.hpl.jena.rdf.model.ModelFactory; import com.hp.hpl.jena.rdf.model.ModelFactory;
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess.WhichService;
import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.jena.model.RDFServiceModel; import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.jena.model.RDFServiceModel;
@ -598,7 +601,11 @@ public class AdditionalURIsForContextNodesTest {
private void populateModelAndCreateUriFinder(String n3String) { private void populateModelAndCreateUriFinder(String n3String) {
OntModel model = ModelFactory.createOntologyModel(); OntModel model = ModelFactory.createOntologyModel();
model.read(new StringReader(n3String), null, "N3"); model.read(new StringReader(n3String), null, "N3");
uriFinder = new AdditionalURIsForContextNodes(
new RDFServiceModel(model)); ContextModelAccessStub cmas = new ContextModelAccessStub();
cmas.setRDFService(WhichService.CONTENT, new RDFServiceModel(model));
uriFinder = new AdditionalURIsForContextNodes();
uriFinder.setContextModels(cmas);
} }
} }