From 69711960bc8b9db59c455d83ec902d315133631a Mon Sep 17 00:00:00 2001 From: j2blake Date: Wed, 7 Jan 2015 17:26:07 -0500 Subject: [PATCH] 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 --- .../VivoSearchIndexerConfiguration.n3 | 46 --------------- .../searchIndexerConfigurationVivo.n3 | 56 +++++++++++++++++++ .../documentBuilding/CalculateParameters.java | 7 +++ .../VIVOValuesFromVcards.java | 6 ++ .../AdditionalURIsForContextNodes.java | 27 +++++---- .../indexing/AdditionalUriFinders.java | 29 ---------- .../indexing/AdditionalUrisForVCards.java | 20 +++++-- .../AdditionalURIsForContextNodesTest.java | 11 +++- 8 files changed, 109 insertions(+), 93 deletions(-) delete mode 100644 rdf/display/everytime/VivoSearchIndexerConfiguration.n3 create mode 100644 rdf/display/everytime/searchIndexerConfigurationVivo.n3 delete mode 100644 src/edu/cornell/mannlib/vitro/webapp/searchindex/indexing/AdditionalUriFinders.java diff --git a/rdf/display/everytime/VivoSearchIndexerConfiguration.n3 b/rdf/display/everytime/VivoSearchIndexerConfiguration.n3 deleted file mode 100644 index 52c0ada2..00000000 --- a/rdf/display/everytime/VivoSearchIndexerConfiguration.n3 +++ /dev/null @@ -1,46 +0,0 @@ -@prefix : . - -# -# Specify the SearchIndexExcluders and DocumentModifiers for VIVO. -# These are in addition to the ones specified for VIVO. -# - -:vivoSearchExcluder_namespaceExcluder - a , - ; - :excludes - "http://purl.obolibrary.org/obo/" . - -# ------------------------------------ - -:vivodocumentModifier_calculateParameters - a , - . - -:vivodocumentModifier_valuesFromVcards - a , - . - -:vivodocumentModifier_ISFBasicFields - a , - . - -:vivodocumentModifier_ISFAdvisingFields - a , - . - -:vivodocumentModifier_ISFEducationFields - a , - . - -:vivodocumentModifier_ISFGrantFields - a , - . - -:vivodocumentModifier_ISFMemberFields - a , - . - -:vivodocumentModifier_informationResourceContextNodeFields - a , - . diff --git a/rdf/display/everytime/searchIndexerConfigurationVivo.n3 b/rdf/display/everytime/searchIndexerConfigurationVivo.n3 new file mode 100644 index 00000000..6e8bdb54 --- /dev/null +++ b/rdf/display/everytime/searchIndexerConfigurationVivo.n3 @@ -0,0 +1,56 @@ +@prefix : . + +# +# Specify the SearchIndexExcluders, DocumentModifiers and IndexingUriFinders for VIVO. +# These are in addition to the ones specified for VIVO. +# + +:vivoSearchExcluder_namespaceExcluder + a , + ; + :excludes + "http://purl.obolibrary.org/obo/" . + +# ------------------------------------ + +:vivodocumentModifier_calculateParameters + a , + . + +:vivodocumentModifier_valuesFromVcards + a , + . + +:vivodocumentModifier_ISFBasicFields + a , + . + +:vivodocumentModifier_ISFAdvisingFields + a , + . + +:vivodocumentModifier_ISFEducationFields + a , + . + +:vivodocumentModifier_ISFGrantFields + a , + . + +:vivodocumentModifier_ISFMemberFields + a , + . + +:vivodocumentModifier_informationResourceContextNodeFields + a , + . + +# ------------------------------------ + +:uriFinder_forContextNodes + a , + . + +:uriFinder_forVCards + a , + . diff --git a/src/edu/cornell/mannlib/vitro/webapp/searchindex/documentBuilding/CalculateParameters.java b/src/edu/cornell/mannlib/vitro/webapp/searchindex/documentBuilding/CalculateParameters.java index 2f0301c4..78bfa9c1 100644 --- a/src/edu/cornell/mannlib/vitro/webapp/searchindex/documentBuilding/CalculateParameters.java +++ b/src/edu/cornell/mannlib/vitro/webapp/searchindex/documentBuilding/CalculateParameters.java @@ -254,6 +254,13 @@ public class CalculateParameters implements DocumentModifier, ContextModelsUser public void shutdown(){ shutdown=true; } + + + @Override + public String toString() { + return this.getClass().getSimpleName() + "[]"; + } + } class TotalInd implements Runnable{ diff --git a/src/edu/cornell/mannlib/vitro/webapp/searchindex/documentBuilding/VIVOValuesFromVcards.java b/src/edu/cornell/mannlib/vitro/webapp/searchindex/documentBuilding/VIVOValuesFromVcards.java index 3b9aac52..551da06d 100644 --- a/src/edu/cornell/mannlib/vitro/webapp/searchindex/documentBuilding/VIVOValuesFromVcards.java +++ b/src/edu/cornell/mannlib/vitro/webapp/searchindex/documentBuilding/VIVOValuesFromVcards.java @@ -122,6 +122,12 @@ public class VIVOValuesFromVcards implements DocumentModifier, ContextModelsUser shutdown = true; } + + @Override + public String toString() { + return this.getClass().getSimpleName() + "[]"; + } + private abstract static class ResultParser { public abstract void parse(String uri, QuerySolution solution, SearchInputDocument doc); diff --git a/src/edu/cornell/mannlib/vitro/webapp/searchindex/indexing/AdditionalURIsForContextNodes.java b/src/edu/cornell/mannlib/vitro/webapp/searchindex/indexing/AdditionalURIsForContextNodes.java index 78745437..6b1325fd 100644 --- a/src/edu/cornell/mannlib/vitro/webapp/searchindex/indexing/AdditionalURIsForContextNodes.java +++ b/src/edu/cornell/mannlib/vitro/webapp/searchindex/indexing/AdditionalURIsForContextNodes.java @@ -21,25 +21,27 @@ import com.hp.hpl.jena.rdf.model.ResourceFactory; import com.hp.hpl.jena.rdf.model.Statement; 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.utils.configuration.ContextModelsUser; -public class AdditionalURIsForContextNodes implements StatementToURIsToUpdate { - - private final RDFService rdfService; - private Set alreadyChecked; - private long accumulatedTime = 0; +public class AdditionalURIsForContextNodes implements IndexingUriFinder, ContextModelsUser { + private Log log = LogFactory.getLog(AdditionalURIsForContextNodes.class); private static final List multiValuedQueriesForAgent = new ArrayList(); private static final String multiValuedQueryForInformationContentEntity; private static final List multiValuedQueriesForRole = new ArrayList(); private static final ListqueryList; - private Log log = LogFactory.getLog(AdditionalURIsForContextNodes.class); + private RDFService rdfService; + private Set alreadyChecked; + private long accumulatedTime = 0; - public AdditionalURIsForContextNodes( RDFService rdfService){ - this.rdfService = rdfService; - } + @Override + public void setContextModels(ContextModelAccess models) { + this.rdfService = models.getRDFService(); + } @Override public List findAdditionalURIsToIndex(Statement stmt) { @@ -78,7 +80,7 @@ public class AdditionalURIsForContextNodes implements StatementToURIsToUpdate { } @Override - public void endIndxing() { + public void endIndexing() { log.debug( "Accumulated time for this run of the index: " + accumulatedTime + " msec"); alreadyChecked = null; } @@ -765,4 +767,9 @@ public class AdditionalURIsForContextNodes implements StatementToURIsToUpdate { queryList = Collections.unmodifiableList(tmpList); } + @Override + public String toString() { + return this.getClass().getSimpleName(); + } + } diff --git a/src/edu/cornell/mannlib/vitro/webapp/searchindex/indexing/AdditionalUriFinders.java b/src/edu/cornell/mannlib/vitro/webapp/searchindex/indexing/AdditionalUriFinders.java deleted file mode 100644 index c64e7086..00000000 --- a/src/edu/cornell/mannlib/vitro/webapp/searchindex/indexing/AdditionalUriFinders.java +++ /dev/null @@ -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 getList(RDFService rdfService, - IndividualDao indDao) { - List 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; - } - -} diff --git a/src/edu/cornell/mannlib/vitro/webapp/searchindex/indexing/AdditionalUrisForVCards.java b/src/edu/cornell/mannlib/vitro/webapp/searchindex/indexing/AdditionalUrisForVCards.java index 5bf0bf8e..8c08b781 100644 --- a/src/edu/cornell/mannlib/vitro/webapp/searchindex/indexing/AdditionalUrisForVCards.java +++ b/src/edu/cornell/mannlib/vitro/webapp/searchindex/indexing/AdditionalUrisForVCards.java @@ -18,13 +18,15 @@ import com.hp.hpl.jena.rdf.model.ResourceFactory; import com.hp.hpl.jena.rdf.model.Statement; 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.utils.configuration.ContextModelsUser; /** * If the property of a VCard object is changed, we should re-index the owner of * that VCard. */ -public class AdditionalUrisForVCards implements StatementToURIsToUpdate { +public class AdditionalUrisForVCards implements IndexingUriFinder, ContextModelsUser { private static final Log log = LogFactory .getLog(AdditionalUrisForVCards.class); @@ -37,10 +39,11 @@ public class AdditionalUrisForVCards implements StatementToURIsToUpdate { + " ?uri obo:ARG_2000028 ?contactInfo . \n " // + "}"; - private final RDFService rdfService; - - public AdditionalUrisForVCards(RDFService rdfService) { - this.rdfService = rdfService; + private RDFService rdfService; + + @Override + public void setContextModels(ContextModelAccess models) { + this.rdfService = models.getRDFService(); } @Override @@ -113,8 +116,13 @@ public class AdditionalUrisForVCards implements StatementToURIsToUpdate { } @Override - public void endIndxing() { + public void endIndexing() { // Nothing to tear down. } + @Override + public String toString() { + return this.getClass().getSimpleName(); + } + } diff --git a/test/edu/cornell/mannlib/vitro/webapp/searchindex/indexing/AdditionalURIsForContextNodesTest.java b/test/edu/cornell/mannlib/vitro/webapp/searchindex/indexing/AdditionalURIsForContextNodesTest.java index 8693b9fb..c06c9e14 100644 --- a/test/edu/cornell/mannlib/vitro/webapp/searchindex/indexing/AdditionalURIsForContextNodesTest.java +++ b/test/edu/cornell/mannlib/vitro/webapp/searchindex/indexing/AdditionalURIsForContextNodesTest.java @@ -9,9 +9,12 @@ import java.util.List; 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.rdf.model.ModelFactory; +import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess.WhichService; import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.jena.model.RDFServiceModel; @@ -598,7 +601,11 @@ public class AdditionalURIsForContextNodesTest { private void populateModelAndCreateUriFinder(String n3String) { OntModel model = ModelFactory.createOntologyModel(); 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); } }