diff --git a/webapp/config/applicationSetup.n3 b/webapp/config/applicationSetup.n3 index cabf41a08..23c26f7fe 100644 --- a/webapp/config/applicationSetup.n3 +++ b/webapp/config/applicationSetup.n3 @@ -42,4 +42,4 @@ :jfactTBoxReasonerModule a , - . \ No newline at end of file + . diff --git a/webapp/rdf/display/everytime/SearchIndexerConfiguration.n3 b/webapp/rdf/display/everytime/SearchIndexerConfiguration.n3 deleted file mode 100644 index fb82c5b74..000000000 --- a/webapp/rdf/display/everytime/SearchIndexerConfiguration.n3 +++ /dev/null @@ -1,57 +0,0 @@ -@prefix : . -@prefix xsd: . - -# -# Specify the SearchIndexExcluders and DocumentModifiers. -# - -# Exclude from the search index Individuals with types from these namespaces. -# Note: if you do OWL.NS here you will exclude all of owl:Thing. -:searchExcluder_namespaceExcluder - a , - ; - :excludes - "http://vitro.mannlib.cornell.edu/ns/vitro/0.7#" , - "http://vitro.mannlib.cornell.edu/ns/vitro/public#" , - "http://vitro.mannlib.cornell.edu/ns/bnode#" , - "http://www.w3.org/2002/07/owl#" . - -# Individuals of these types will be excluded from the search index -:searchExcluder_typeExcluder - a , - ; - :excludes - "http://www.w3.org/2002/07/owl#AnnotationProperty" , - "http://www.w3.org/2002/07/owl#DatatypeProperty" , - "http://www.w3.org/2002/07/owl#ObjectProperty" . - -# Exclude from the search index individuals who's URIs start with these namespaces. -:searchExcluder_typeNamespaceExcluder - a , - ; - :excludes - "http://vitro.mannlib.cornell.edu/ns/vitro/role#public" . - -:searchExcluder_vitroExcluder - a , - . - -:searchExcluder_syncingTypeExcluder - a , - . - -# ------------------------------------ - -:documentModifier_nameFields - a , - . - -:documentModifier_nameBoost - a , - ; - :hasBoost "1.2"^^xsd:float . - -:documentModifier_thumbnailImageUrl - a , - . - diff --git a/webapp/rdf/display/everytime/searchIndexerConfigurationVitro.n3 b/webapp/rdf/display/everytime/searchIndexerConfigurationVitro.n3 new file mode 100644 index 000000000..8bddad7b8 --- /dev/null +++ b/webapp/rdf/display/everytime/searchIndexerConfigurationVitro.n3 @@ -0,0 +1,73 @@ +@prefix : . +@prefix xsd: . + +# +# configure the SearchIndexer +# + +# Individuals with these types will be excluded from the search index +:searchExcluder_typeExcluder + a , + ; + :excludes + "http://www.w3.org/2002/07/owl#AnnotationProperty" , + "http://www.w3.org/2002/07/owl#DatatypeProperty" , + "http://www.w3.org/2002/07/owl#ObjectProperty" . + +# Individuals with types from these namespaces will be excluded from the search index. +:searchExcluder_namespaceExcluder + a , + ; + :excludes + "http://vitro.mannlib.cornell.edu/ns/vitro/0.7#" , + "http://vitro.mannlib.cornell.edu/ns/vitro/public#" , + "http://vitro.mannlib.cornell.edu/ns/bnode#" , + "http://www.w3.org/2002/07/owl#" . + +# Individuals with URIs in these namespaces will be excluded from the search index. +:searchExcluder_typeNamespaceExcluder + a , + ; + :excludes + "http://vitro.mannlib.cornell.edu/ns/vitro/role#public" . + +:searchExcluder_vitroExcluder + a , + . + +:searchExcluder_syncingTypeExcluder + a , + . + +# ------------------------------------ + +:documentModifier_nameFields + a , + . + +:documentModifier_nameBoost + a , + ; + :hasBoost "1.2"^^xsd:float . + +:documentModifier_thumbnailImageUrl + a , + . + +# ------------------------------------ + +:uriFinder_forDataProperties + a , + . + +:uriFinder_forObjectProperties + a , + . + +:uriFinder_forTypeStatements + a , + . + +:uriFinder_forClassGroupChange + a , + . diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/modules/searchIndexer/SearchIndexer.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/modules/searchIndexer/SearchIndexer.java index ef21c88e3..9cfc43cd2 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/modules/searchIndexer/SearchIndexer.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/modules/searchIndexer/SearchIndexer.java @@ -110,6 +110,8 @@ public interface SearchIndexer extends Application.Module { */ public static class Event { public enum Type { + STARTUP, + START_PROCESSING_URIS, PROGRESS_PROCESSING_URIS, diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/search/VitroSearchTermNames.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/search/VitroSearchTermNames.java index b53ad9e4d..479b228d1 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/search/VitroSearchTermNames.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/search/VitroSearchTermNames.java @@ -5,25 +5,25 @@ package edu.cornell.mannlib.vitro.webapp.search; public class VitroSearchTermNames { /** Id of entity, vclass or tab */ - public static String URI = "URI"; + public static final String URI = "URI"; /** search document id */ - public static String DOCID = "DocId"; + public static final String DOCID = "DocId"; /** rdf:type */ - public static String RDFTYPE = "type"; + public static final String RDFTYPE = "type"; /** classgroups from the individual's rdf:types */ - public static String CLASSGROUP_URI = "classgroup"; + public static final String CLASSGROUP_URI = "classgroup"; /** Most specific types for individual*/ - public static String MOST_SPECIFIC_TYPE_URIS = "mostSpecificTypeURIs"; + public static final String MOST_SPECIFIC_TYPE_URIS = "mostSpecificTypeURIs"; /** time of index in msec since epoc */ - public static String INDEXEDTIME= "indexedTime"; + public static final String INDEXEDTIME= "indexedTime"; /** text for 'full text' search, this is stemmed */ - public static String ALLTEXT = "ALLTEXT"; + public static final String ALLTEXT = "ALLTEXT"; /** text for 'full text' search, this is unstemmed for * use with wildcards and prefix queries */ - public static String ALLTEXTUNSTEMMED = "ALLTEXTUNSTEMMED"; + public static final String ALLTEXTUNSTEMMED = "ALLTEXTUNSTEMMED"; /** Does the individual have a thumbnail image? 1=yes 0=no */ public static final String THUMBNAIL = "THUMBNAIL"; @@ -32,20 +32,20 @@ public class VitroSearchTermNames { // Fields derived from rdfs:label /** Raw rdfs:label: no lowercasing, no tokenizing, no stop words, no stemming **/ - public static String NAME_RAW = "nameRaw"; // + public static final String NAME_RAW = "nameRaw"; // /** rdfs:label lowercased, no tokenizing, no stop words, no stemming **/ - public static String NAME_LOWERCASE = "nameLowercase"; // + public static final String NAME_LOWERCASE = "nameLowercase"; // /** Same as NAME_LOWERCASE, but single-valued so it's sortable. **/ // RY Need to control how indexing selects which of multiple values to copy. - public static String NAME_LOWERCASE_SINGLE_VALUED = "nameLowercaseSingleValued"; + public static final String NAME_LOWERCASE_SINGLE_VALUED = "nameLowercaseSingleValued"; /** rdfs:label lowercased, tokenized, stop words, no stemming **/ - public static String NAME_UNSTEMMED = "nameUnstemmed"; + public static final String NAME_UNSTEMMED = "nameUnstemmed"; /** rdfs:label lowercased, tokenized, stop words, stemmed **/ - public static String NAME_STEMMED = "nameStemmed"; + public static final String NAME_STEMMED = "nameStemmed"; /** preferred title */ public static final String PREFERRED_TITLE = "PREFERRED_TITLE"; @@ -53,14 +53,14 @@ public class VitroSearchTermNames { public static final String NAME_PHONETIC = "NAME_PHONETIC"; /** rdfs:label lowercased, untokenized, edge-n-gram-filtered for autocomplete on people names **/ - public static String AC_NAME_UNTOKENIZED = "acNameUntokenized"; + public static final String AC_NAME_UNTOKENIZED = "acNameUntokenized"; /** rdfs:label lowercased, tokenized, stop words, stemmed, edge-n-gram-filtered for autocomplete * on non-person labels such as book titles and grant names **/ - public static String AC_NAME_STEMMED = "acNameStemmed"; + public static final String AC_NAME_STEMMED = "acNameStemmed"; /* There is currently no use case for an autocomplete search field that is tokenized but not stemmed. - public static String AC_NAME_UNSTEMMED = "acNameUnstemmed"; */ + public static final String AC_NAME_UNSTEMMED = "acNameUnstemmed"; */ /** Beta values used in weighting **/ public static final String BETA = "BETA"; diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/search/indexing/IndexBuilder.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/search/indexing/IndexBuilder.java index 8e1835911..4aa5a3ca7 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/search/indexing/IndexBuilder.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/search/indexing/IndexBuilder.java @@ -25,7 +25,7 @@ import edu.cornell.mannlib.vitro.webapp.beans.Individual; import edu.cornell.mannlib.vitro.webapp.dao.IndividualDao; import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory; import edu.cornell.mannlib.vitro.webapp.search.beans.IndexerIface; -import edu.cornell.mannlib.vitro.webapp.searchindex.indexing.StatementToURIsToUpdate; +import edu.cornell.mannlib.vitro.webapp.searchindex.indexing.IndexingUriFinder; import edu.cornell.mannlib.vitro.webapp.utils.threads.VitroBackgroundThread; @@ -52,7 +52,7 @@ public class IndexBuilder extends VitroBackgroundThread { /** This is a list of objects that will compute what URIs need to be * updated in the search index when a statement changes. */ - private final List stmtToURIsToIndexFunctions; + private final List stmtToURIsToIndexFunctions; /** Indicates that a full index re-build has been requested. */ private volatile boolean reindexRequested = false; @@ -102,7 +102,7 @@ public class IndexBuilder extends VitroBackgroundThread { public IndexBuilder(IndexerIface indexer, WebappDaoFactory wdf, - List stmtToURIsToIndexFunctions ){ + List stmtToURIsToIndexFunctions ){ super("IndexBuilder"); this.indexer = indexer; @@ -275,7 +275,7 @@ public class IndexBuilder extends VitroBackgroundThread { */ private Collection changedStatementsToUris(){ //inform StatementToURIsToUpdate that index is starting - for( StatementToURIsToUpdate stu : stmtToURIsToIndexFunctions ) { + for( IndexingUriFinder stu : stmtToURIsToIndexFunctions ) { stu.startIndexing(); } @@ -291,7 +291,7 @@ public class IndexBuilder extends VitroBackgroundThread { for (int i = 0; i < howManyChanges; i++) { Statement stmt = changedStatements[i]; - for (StatementToURIsToUpdate stu : stmtToURIsToIndexFunctions) { + for (IndexingUriFinder stu : stmtToURIsToIndexFunctions) { urisToUpdate.addAll(stu.findAdditionalURIsToIndex(stmt)); } if ((i > 0) && (i % 1000 == 0)) { @@ -301,8 +301,8 @@ public class IndexBuilder extends VitroBackgroundThread { } //inform StatementToURIsToUpdate that they are done - for( StatementToURIsToUpdate stu : stmtToURIsToIndexFunctions ) { - stu.endIndxing(); + for( IndexingUriFinder stu : stmtToURIsToIndexFunctions ) { + stu.endIndexing(); } return urisToUpdate; diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/searchindex/SearchIndexerImpl.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/searchindex/SearchIndexerImpl.java index f28893ebb..343df3a57 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/searchindex/SearchIndexerImpl.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/searchindex/SearchIndexerImpl.java @@ -2,8 +2,9 @@ package edu.cornell.mannlib.vitro.webapp.searchindex; +import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames.DISPLAY; import static edu.cornell.mannlib.vitro.webapp.modules.searchIndexer.SearchIndexer.Event.Type.REBUILD_REQUESTED; -import static edu.cornell.mannlib.vitro.webapp.modules.searchIndexer.SearchIndexer.Event.Type.START_PROCESSING_STATEMENTS; +import static edu.cornell.mannlib.vitro.webapp.modules.searchIndexer.SearchIndexer.Event.Type.*; import static edu.cornell.mannlib.vitro.webapp.modules.searchIndexer.SearchIndexer.Event.Type.STOP_PROCESSING_STATEMENTS; import java.util.ArrayList; @@ -11,12 +12,14 @@ import java.util.Collection; import java.util.Collections; import java.util.Date; import java.util.List; +import java.util.Set; import javax.servlet.ServletContext; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess; import edu.cornell.mannlib.vitro.webapp.modules.Application; import edu.cornell.mannlib.vitro.webapp.modules.ComponentStartupStatus; import edu.cornell.mannlib.vitro.webapp.modules.searchIndexer.SearchIndexer; @@ -24,12 +27,16 @@ import edu.cornell.mannlib.vitro.webapp.modules.searchIndexer.SearchIndexerStatu import edu.cornell.mannlib.vitro.webapp.modules.searchIndexer.SearchIndexerStatus.State; import edu.cornell.mannlib.vitro.webapp.search.indexing.IndexBuilder; import edu.cornell.mannlib.vitro.webapp.search.indexing.IndexingEventListener; +import edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.DocumentModifier; +import edu.cornell.mannlib.vitro.webapp.searchindex.exclusions.SearchIndexExcluder; +import edu.cornell.mannlib.vitro.webapp.searchindex.indexing.IndexingUriFinder; +import edu.cornell.mannlib.vitro.webapp.utils.configuration.ConfigurationBeanLoader; +import edu.cornell.mannlib.vitro.webapp.utils.configuration.ConfigurationBeanLoaderException; import edu.cornell.mannlib.vitro.webapp.utils.threads.VitroBackgroundThread.WorkLevel; import edu.cornell.mannlib.vitro.webapp.utils.threads.VitroBackgroundThread.WorkLevelStamp; /** - * TODO - * A silly implementation that just wraps the old IndexBuilder. + * TODO A silly implementation that just wraps the old IndexBuilder. */ public class SearchIndexerImpl implements SearchIndexer { private static final Log log = LogFactory.getLog(SearchIndexerImpl.class); @@ -37,9 +44,9 @@ public class SearchIndexerImpl implements SearchIndexer { private final ListenerList listeners = new ListenerList(); private ServletContext ctx; - // private Set excluders; - // private Set modifiers; - // private Set uriFinders; + private Set excluders; + private Set modifiers; + private Set uriFinders; // TODO private IndexBuilder indexBuilder; @@ -48,15 +55,18 @@ public class SearchIndexerImpl implements SearchIndexer { public void startup(Application application, ComponentStartupStatus ss) { try { this.ctx = application.getServletContext(); - // loadConfiguration(); - // ss.info("Configured SearchIndexer: excluders=" + excluders - // + ", modifiers=" + modifiers + ", uriFinders=" + uriFinders); + loadConfiguration(); + ss.info("Configured SearchIndexer: excluders=" + excluders + + ", modifiers=" + modifiers + ", uriFinders=" + uriFinders); - // TODO - this.indexBuilder = (IndexBuilder) ctx - .getAttribute(IndexBuilder.class.getName()); + { // >>>>>>> TODO + this.indexBuilder = (IndexBuilder) ctx + .getAttribute(IndexBuilder.class.getName()); - this.indexBuilder.addIndexBuilderListener(new BridgeListener()); + this.indexBuilder.addIndexBuilderListener(new BridgeListener()); + } + + createAndFire(STARTUP); } catch (Exception e) { ss.fatal("Failed to configure the SearchIndexer", e); } @@ -66,25 +76,12 @@ public class SearchIndexerImpl implements SearchIndexer { listeners.fireEvent(new Event(type, getStatus())); } - // private void loadConfiguration() throws ConfigurationBeanLoaderException - // { - // ConfigurationBeanLoader beanLoader = new ConfigurationBeanLoader( - // ModelAccess.on(ctx).getOntModel(DISPLAY), ctx); - // excluders = beanLoader.loadAll(SearchIndexExcluder.class); - // modifiers = beanLoader.loadAll(DocumentModifier.class); - // uriFinders = beanLoader.loadAll(IndexingUriFinder.class); - // } - - /* - * (non-Javadoc) - * - * @see - * edu.cornell.mannlib.vitro.webapp.modules.Application.Component#shutdown - * (edu.cornell.mannlib.vitro.webapp.modules.Application) - */ - @Override - public void shutdown(Application application) { - // TODO + private void loadConfiguration() throws ConfigurationBeanLoaderException { + ConfigurationBeanLoader beanLoader = new ConfigurationBeanLoader( + ModelAccess.on(ctx).getOntModel(DISPLAY), ctx); + excluders = beanLoader.loadAll(SearchIndexExcluder.class); + modifiers = beanLoader.loadAll(DocumentModifier.class); + uriFinders = beanLoader.loadAll(IndexingUriFinder.class); } /* @@ -173,6 +170,21 @@ public class SearchIndexerImpl implements SearchIndexer { listeners.remove(listener); } + /* + * (non-Javadoc) + * + * @see + * edu.cornell.mannlib.vitro.webapp.modules.Application.Component#shutdown + * (edu.cornell.mannlib.vitro.webapp.modules.Application) + */ + @Override + public void shutdown(Application application) { + // TODO + } + + /** + * A simple thread-safe list of event listeners. + */ private static class ListenerList { private final List list; diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/searchindex/SearchIndexerSetup.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/searchindex/SearchIndexerSetup.java index cec9b9aa6..8784ccb2e 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/searchindex/SearchIndexerSetup.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/searchindex/SearchIndexerSetup.java @@ -25,16 +25,13 @@ import edu.cornell.mannlib.vitro.webapp.dao.filtering.filters.VitroFilters; import edu.cornell.mannlib.vitro.webapp.dao.jena.ModelContext; import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess; import edu.cornell.mannlib.vitro.webapp.modules.searchEngine.SearchEngine; -import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService; -import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.RDFServiceUtils; import edu.cornell.mannlib.vitro.webapp.search.SearchIndexer; import edu.cornell.mannlib.vitro.webapp.search.documentBuilding.IndividualToSearchDocument; import edu.cornell.mannlib.vitro.webapp.search.indexing.IndexBuilder; import edu.cornell.mannlib.vitro.webapp.search.indexing.SearchReindexingListener; import edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.DocumentModifier; import edu.cornell.mannlib.vitro.webapp.searchindex.exclusions.SearchIndexExcluder; -import edu.cornell.mannlib.vitro.webapp.searchindex.indexing.AdditionalUriFinders; -import edu.cornell.mannlib.vitro.webapp.searchindex.indexing.StatementToURIsToUpdate; +import edu.cornell.mannlib.vitro.webapp.searchindex.indexing.IndexingUriFinder; import edu.cornell.mannlib.vitro.webapp.startup.ComponentStartupStatusImpl; import edu.cornell.mannlib.vitro.webapp.startup.StartupStatus; import edu.cornell.mannlib.vitro.webapp.utils.configuration.ConfigurationBeanLoader; @@ -78,10 +75,7 @@ public class SearchIndexerSetup implements ServletContextListener { wadf = new WebappDaoFactoryFiltering(wadf, vf); // make objects that will find additional URIs for context nodes etc - RDFService rdfService = RDFServiceUtils.getRDFServiceFactory( - context).getRDFService(); - List uriFinders = AdditionalUriFinders - .getList(rdfService, wadf.getIndividualDao()); + List uriFinders = loadUriFinders(); // Make the IndexBuilder IndexBuilder builder = new IndexBuilder(searchIndexer, wadf, @@ -128,4 +122,12 @@ public class SearchIndexerSetup implements ServletContextListener { throw new RuntimeException("Failed to configure the SearchIndexer", e); } } + + private List loadUriFinders() { + try { + return new ArrayList<>(beanLoader.loadAll(IndexingUriFinder.class)); + } catch (ConfigurationBeanLoaderException e) { + throw new RuntimeException("Failed to configure the SearchIndexer", e); + } + } } diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/searchindex/documentBuilding/NameFields.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/searchindex/documentBuilding/NameFields.java index ea5716966..9511b5e6d 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/searchindex/documentBuilding/NameFields.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/searchindex/documentBuilding/NameFields.java @@ -69,6 +69,11 @@ public class NameFields implements DocumentModifier, ContextModelsUser { } + @Override + public String toString() { + return this.getClass().getSimpleName(); + } + @Override public void shutdown() { /*nothing to do */ } } diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/searchindex/documentBuilding/ThumbnailImageURL.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/searchindex/documentBuilding/ThumbnailImageURL.java index 548b2f039..a28020a6b 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/searchindex/documentBuilding/ThumbnailImageURL.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/searchindex/documentBuilding/ThumbnailImageURL.java @@ -93,6 +93,11 @@ public class ThumbnailImageURL implements DocumentModifier, ContextModelsUser { return result.toString(); } + @Override + public String toString() { + return this.getClass().getSimpleName(); + } + @Override public void shutdown() { // nothing to release. diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/searchindex/exclusions/ExcludeBasedOnType.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/searchindex/exclusions/ExcludeBasedOnType.java index 08d01002c..ee668eccc 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/searchindex/exclusions/ExcludeBasedOnType.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/searchindex/exclusions/ExcludeBasedOnType.java @@ -2,10 +2,7 @@ package edu.cornell.mannlib.vitro.webapp.searchindex.exclusions; -import static edu.cornell.mannlib.vitro.webapp.search.documentBuilding.IndividualToSearchDocument.DONT_EXCLUDE; - import java.util.ArrayList; -import java.util.Arrays; import java.util.HashSet; import java.util.List; import java.util.Set; @@ -92,6 +89,6 @@ public class ExcludeBasedOnType implements SearchIndexExcluder { @Override public String toString() { - return this.getClass().getSimpleName() + " [typeURIs=" + typeURIs + "]"; + return this.getClass().getSimpleName() + "[typeURIs=" + typeURIs + "]"; } } diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/searchindex/exclusions/ExcludeBasedOnTypeNamespace.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/searchindex/exclusions/ExcludeBasedOnTypeNamespace.java index e85f98682..5fb74bcb1 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/searchindex/exclusions/ExcludeBasedOnTypeNamespace.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/searchindex/exclusions/ExcludeBasedOnTypeNamespace.java @@ -61,6 +61,6 @@ public class ExcludeBasedOnTypeNamespace implements SearchIndexExcluder { @Override public String toString() { - return "ExcludeBasedOnTypeNamespace [namespaces=" + namespaces + "]"; + return "ExcludeBasedOnTypeNamespace[namespaces=" + namespaces + "]"; } } diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/searchindex/exclusions/ExcludeNonFlagVitro.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/searchindex/exclusions/ExcludeNonFlagVitro.java index 3b63ed6ba..3ce4d3872 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/searchindex/exclusions/ExcludeNonFlagVitro.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/searchindex/exclusions/ExcludeNonFlagVitro.java @@ -1,8 +1,6 @@ /* $This file is distributed under the terms of the license in /doc/license.txt$ */ package edu.cornell.mannlib.vitro.webapp.searchindex.exclusions; -import static edu.cornell.mannlib.vitro.webapp.search.documentBuilding.IndividualToSearchDocument.DONT_EXCLUDE; - import java.util.List; import org.apache.commons.lang.StringUtils; @@ -56,7 +54,7 @@ public class ExcludeNonFlagVitro implements SearchIndexExcluder { @Override public String toString() { - return "ExcludeNonFlagVitro []"; + return "ExcludeNonFlagVitro"; } } diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/searchindex/exclusions/SearchIndexExcluder.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/searchindex/exclusions/SearchIndexExcluder.java index 949cec2e3..aca71f34a 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/searchindex/exclusions/SearchIndexExcluder.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/searchindex/exclusions/SearchIndexExcluder.java @@ -9,6 +9,7 @@ import edu.cornell.mannlib.vitro.webapp.beans.Individual; * should be excluded from the search index. */ public interface SearchIndexExcluder { + public static final String DONT_EXCLUDE = null; /** * REturn a string message if the individual should diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/searchindex/indexing/AdditionalURIsForClassGroupChanges.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/searchindex/indexing/AdditionalURIsForClassGroupChanges.java index aecd582ee..83c94c06c 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/searchindex/indexing/AdditionalURIsForClassGroupChanges.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/searchindex/indexing/AdditionalURIsForClassGroupChanges.java @@ -1,9 +1,9 @@ /* $This file is distributed under the terms of the license in /doc/license.txt$ */ -/** - * - */ + package edu.cornell.mannlib.vitro.webapp.searchindex.indexing; +import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames.TBOX_ASSERTIONS; + import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -15,6 +15,8 @@ import com.hp.hpl.jena.shared.Lock; import com.hp.hpl.jena.vocabulary.RDF; import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary; +import edu.cornell.mannlib.vitro.webapp.modelaccess.ContextModelAccess; +import edu.cornell.mannlib.vitro.webapp.utils.configuration.ContextModelsUser; /** * If a class changes classgroups, then all members of that class @@ -27,14 +29,14 @@ import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary; * obj='http://vivoweb.org/ontology#vitroClassGrouppeople' * changes, all members of the class core:Summer need to be update so they get the new classgroup values. */ -public class AdditionalURIsForClassGroupChanges implements - StatementToURIsToUpdate { +public class AdditionalURIsForClassGroupChanges implements IndexingUriFinder, ContextModelsUser { private OntModel model; - public AdditionalURIsForClassGroupChanges(OntModel model) { - this.model = model; - } + @Override + public void setContextModels(ContextModelAccess models) { + model = models.getOntModel(TBOX_ASSERTIONS); + } @Override public List findAdditionalURIsToIndex(Statement stmt) { @@ -66,5 +68,11 @@ public class AdditionalURIsForClassGroupChanges implements public void startIndexing() { /* nothing to prepare */ } @Override - public void endIndxing() { /* nothing to do */ } + public void endIndexing() { /* nothing to do */ } + + @Override + public String toString() { + return this.getClass().getSimpleName(); + } + } diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/searchindex/indexing/AdditionalURIsForDataProperties.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/searchindex/indexing/AdditionalURIsForDataProperties.java index d44ff002a..0e3c14820 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/searchindex/indexing/AdditionalURIsForDataProperties.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/searchindex/indexing/AdditionalURIsForDataProperties.java @@ -7,9 +7,9 @@ import java.util.List; import com.hp.hpl.jena.rdf.model.Statement; -import edu.cornell.mannlib.vitro.webapp.searchindex.indexing.StatementToURIsToUpdate; +import edu.cornell.mannlib.vitro.webapp.searchindex.indexing.IndexingUriFinder; -public class AdditionalURIsForDataProperties implements StatementToURIsToUpdate{ +public class AdditionalURIsForDataProperties implements IndexingUriFinder{ @Override public List findAdditionalURIsToIndex(Statement stmt) { @@ -23,5 +23,11 @@ public class AdditionalURIsForDataProperties implements StatementToURIsToUpdate public void startIndexing() { /* nothing to prepare */ } @Override - public void endIndxing() { /* nothing to do */ } + public void endIndexing() { /* nothing to do */ } + + @Override + public String toString() { + return this.getClass().getSimpleName(); + } + } diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/searchindex/indexing/AdditionalURIsForObjectProperties.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/searchindex/indexing/AdditionalURIsForObjectProperties.java index 7ee7f67cd..1ed7d7a37 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/searchindex/indexing/AdditionalURIsForObjectProperties.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/searchindex/indexing/AdditionalURIsForObjectProperties.java @@ -20,7 +20,9 @@ import com.hp.hpl.jena.rdf.model.Statement; import com.hp.hpl.jena.vocabulary.RDFS; 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; /** * For a given statement, return the URIs that may need to be updated in @@ -29,13 +31,14 @@ import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService; * * Context nodes are not handled here. They are taken care of in AdditionalURIsForContextNodex. */ -public class AdditionalURIsForObjectProperties implements StatementToURIsToUpdate { +public class AdditionalURIsForObjectProperties implements IndexingUriFinder, ContextModelsUser { protected static final Log log = LogFactory.getLog(AdditionalURIsForObjectProperties.class); - protected final RDFService rdfService; + protected RDFService rdfService; - public AdditionalURIsForObjectProperties(RDFService rdfService) { - this.rdfService = rdfService; + @Override + public void setContextModels(ContextModelAccess models) { + this.rdfService = models.getRDFService(); } @Override @@ -53,7 +56,7 @@ public class AdditionalURIsForObjectProperties implements StatementToURIsToUpdat public void startIndexing() { /* nothing to prepare */ } @Override - public void endIndxing() { /* nothing to do */ } + public void endIndexing() { /* nothing to do */ } protected List doObjectPropertyStmt(Statement stmt) { // Only need to consider the object since the subject @@ -132,5 +135,9 @@ public class AdditionalURIsForObjectProperties implements StatementToURIsToUpdat " filter( isURI( ?related ) && ?p != rdf:type ) \n" + "}" ; - + @Override + public String toString() { + return this.getClass().getSimpleName(); + } + } diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/searchindex/indexing/AdditionalURIsForTypeStatements.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/searchindex/indexing/AdditionalURIsForTypeStatements.java index 1ca7a6004..b1261a1f9 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/searchindex/indexing/AdditionalURIsForTypeStatements.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/searchindex/indexing/AdditionalURIsForTypeStatements.java @@ -8,12 +8,12 @@ import java.util.List; import com.hp.hpl.jena.rdf.model.Statement; import com.hp.hpl.jena.vocabulary.RDF; -import edu.cornell.mannlib.vitro.webapp.searchindex.indexing.StatementToURIsToUpdate; +import edu.cornell.mannlib.vitro.webapp.searchindex.indexing.IndexingUriFinder; /** * Adds URIs to index for type statement changes on individuals. */ -public class AdditionalURIsForTypeStatements implements StatementToURIsToUpdate { +public class AdditionalURIsForTypeStatements implements IndexingUriFinder { @Override public List findAdditionalURIsToIndex(Statement stmt) { @@ -28,7 +28,11 @@ public class AdditionalURIsForTypeStatements implements StatementToURIsToUpdate public void startIndexing() { /* nothing to prepare */ } @Override - public void endIndxing() { /* nothing to do */ } + public void endIndexing() { /* nothing to do */ } + @Override + public String toString() { + return this.getClass().getSimpleName(); + } } diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/searchindex/indexing/AdditionalUriFinders.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/searchindex/indexing/AdditionalUriFinders.java deleted file mode 100644 index f474f1f8b..000000000 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/searchindex/indexing/AdditionalUriFinders.java +++ /dev/null @@ -1,28 +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) { - // TODO How many of these are only relevant to VIVO? - List uriFinders = new ArrayList<>(); - uriFinders.add(new AdditionalURIsForDataProperties()); - uriFinders.add(new AdditionalURIsForObjectProperties(rdfService)); - uriFinders.add(new AdditionalURIsForTypeStatements()); - uriFinders.add(new URIsForClassGroupChange(indDao)); - return uriFinders; - } - -} diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/searchindex/indexing/StatementToURIsToUpdate.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/searchindex/indexing/IndexingUriFinder.java similarity index 93% rename from webapp/src/edu/cornell/mannlib/vitro/webapp/searchindex/indexing/StatementToURIsToUpdate.java rename to webapp/src/edu/cornell/mannlib/vitro/webapp/searchindex/indexing/IndexingUriFinder.java index f73aa848b..e86c07d0f 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/searchindex/indexing/StatementToURIsToUpdate.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/searchindex/indexing/IndexingUriFinder.java @@ -10,7 +10,7 @@ import com.hp.hpl.jena.rdf.model.Statement; * Interface to use with IndexBuilder to find more URIs to index given a changed statement. * The statement may have been added or removed from the model. */ -public interface StatementToURIsToUpdate { +public interface IndexingUriFinder { /** * For the domain that is the responsibility of the given implementation, @@ -25,5 +25,5 @@ public interface StatementToURIsToUpdate { void startIndexing(); - void endIndxing(); + void endIndexing(); } diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/searchindex/indexing/URIsForClassGroupChange.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/searchindex/indexing/URIsForClassGroupChange.java index d5bfa1c5a..e79395dcd 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/searchindex/indexing/URIsForClassGroupChange.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/searchindex/indexing/URIsForClassGroupChange.java @@ -11,19 +11,22 @@ 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.modelaccess.ContextModelAccess; +import edu.cornell.mannlib.vitro.webapp.utils.configuration.ContextModelsUser; /** * if a class's classgroup changes, reindex all individuals in that class. */ -public class URIsForClassGroupChange implements StatementToURIsToUpdate { +public class URIsForClassGroupChange implements IndexingUriFinder, ContextModelsUser { IndividualDao indDao; - - public URIsForClassGroupChange(IndividualDao individualDao){ - this.indDao = individualDao; - } - + @Override + public void setContextModels(ContextModelAccess models) { + this.indDao = models.getWebappDaoFactory().getIndividualDao(); + } + + @Override public List findAdditionalURIsToIndex(Statement stmt) { if( stmt == null || stmt.getPredicate() == null) return Collections.emptyList(); @@ -57,9 +60,14 @@ public class URIsForClassGroupChange implements StatementToURIsToUpdate { } @Override - public void endIndxing() { + public void endIndexing() { // Do nothing } + @Override + public String toString() { + return this.getClass().getSimpleName(); + } + } diff --git a/webapp/test/edu/cornell/mannlib/vitro/webapp/searchindex/indexing/AdditionalURIsForClassGroupChangesTest.java b/webapp/test/edu/cornell/mannlib/vitro/webapp/searchindex/indexing/AdditionalURIsForClassGroupChangesTest.java index 81b64a8a6..602f2dd4c 100644 --- a/webapp/test/edu/cornell/mannlib/vitro/webapp/searchindex/indexing/AdditionalURIsForClassGroupChangesTest.java +++ b/webapp/test/edu/cornell/mannlib/vitro/webapp/searchindex/indexing/AdditionalURIsForClassGroupChangesTest.java @@ -9,11 +9,14 @@ import org.junit.Assert; import org.junit.Before; 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 com.hp.hpl.jena.rdf.model.ResourceFactory; import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary; +import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames; /** * @author bdc34 @@ -36,7 +39,12 @@ public class AdditionalURIsForClassGroupChangesTest { OntModel model = ModelFactory.createOntologyModel(); model.read( new StringReader(n3ForPresentationClass), null, "N3"); - StatementToURIsToUpdate uriFinder = new AdditionalURIsForClassGroupChanges( model ); + ContextModelAccessStub models = new ContextModelAccessStub(); + models.setOntModel(ModelNames.TBOX_ASSERTIONS, model); + + AdditionalURIsForClassGroupChanges uriFinder = new AdditionalURIsForClassGroupChanges( ); + uriFinder.setContextModels(models); + List uris = uriFinder.findAdditionalURIsToIndex( ResourceFactory.createStatement( ResourceFactory.createResource("http://vivoweb.org/ontology/core#Presentation"), diff --git a/webapp/test/edu/cornell/mannlib/vitro/webapp/searchindex/indexing/AdditionalURIsForObjectPropertiesTest.java b/webapp/test/edu/cornell/mannlib/vitro/webapp/searchindex/indexing/AdditionalURIsForObjectPropertiesTest.java index 3d77c9dec..e74942dbb 100644 --- a/webapp/test/edu/cornell/mannlib/vitro/webapp/searchindex/indexing/AdditionalURIsForObjectPropertiesTest.java +++ b/webapp/test/edu/cornell/mannlib/vitro/webapp/searchindex/indexing/AdditionalURIsForObjectPropertiesTest.java @@ -2,6 +2,8 @@ package edu.cornell.mannlib.vitro.webapp.searchindex.indexing; +import static edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess.WhichService.CONTENT; + import java.io.StringReader; import java.util.List; @@ -9,6 +11,8 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; +import stubs.edu.cornell.mannlib.vitro.webapp.modelaccess.ContextModelAccessStub; + import com.hp.hpl.jena.rdf.model.Model; import com.hp.hpl.jena.rdf.model.ModelFactory; import com.hp.hpl.jena.rdf.model.ResourceFactory; @@ -22,6 +26,7 @@ public class AdditionalURIsForObjectPropertiesTest { Model model; RDFService rdfService; + AdditionalURIsForObjectProperties aufop; String testNS = "http://example.com/test#"; String n3 = "" + @@ -44,11 +49,16 @@ public class AdditionalURIsForObjectPropertiesTest { model = ModelFactory.createDefaultModel(); model.read(new StringReader(n3 ), null , "N3"); rdfService = new RDFServiceModel(model); + + ContextModelAccessStub models = new ContextModelAccessStub(); + models.setRDFService(CONTENT, rdfService); + + aufop = new AdditionalURIsForObjectProperties(); + aufop.setContextModels(models); } @Test public void testChangeOfRdfsLabel() { - AdditionalURIsForObjectProperties aufop = new AdditionalURIsForObjectProperties(rdfService); List uris = aufop.findAdditionalURIsToIndex( ResourceFactory.createStatement( ResourceFactory.createResource(testNS + "bob"), @@ -70,8 +80,6 @@ public class AdditionalURIsForObjectPropertiesTest { @Test public void testChangeOfObjPropStmt() { - - AdditionalURIsForObjectProperties aufop = new AdditionalURIsForObjectProperties(rdfService); List uris = aufop.findAdditionalURIsToIndex( ResourceFactory.createStatement( ResourceFactory.createResource(testNS + "bob"), @@ -93,7 +101,6 @@ public class AdditionalURIsForObjectPropertiesTest { @Test public void testOfDataPropChange() { - AdditionalURIsForObjectProperties aufop = new AdditionalURIsForObjectProperties(rdfService); List uris = aufop.findAdditionalURIsToIndex( ResourceFactory.createStatement( ResourceFactory.createResource(testNS + "bob"), @@ -112,9 +119,12 @@ public class AdditionalURIsForObjectPropertiesTest { Model model = ModelFactory.createDefaultModel(); model.read(new StringReader( n3ForNIHVIVO_2902 ), null , "N3"); - RDFService rdfService = new RDFServiceModel(model); + + ContextModelAccessStub models = new ContextModelAccessStub(); + models.setRDFService(CONTENT, new RDFServiceModel(model)); - AdditionalURIsForObjectProperties aufop = new AdditionalURIsForObjectProperties(rdfService); + aufop.setContextModels(models); + List uris = aufop.findAdditionalURIsToIndex( ResourceFactory.createStatement( ResourceFactory.createResource("http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n2241"),