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:
parent
2ceab6e3df
commit
64624f2b84
23 changed files with 255 additions and 194 deletions
|
@ -1,57 +0,0 @@
|
||||||
@prefix : <http://vitro.mannlib.cornell.edu/ns/vitro/ApplicationSetup#> .
|
|
||||||
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
|
|
||||||
|
|
||||||
#
|
|
||||||
# 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 <java:edu.cornell.mannlib.vitro.webapp.search.documentBuilding.ExcludeBasedOnNamespace> ,
|
|
||||||
<java:edu.cornell.mannlib.vitro.webapp.search.documentBuilding.SearchIndexExcluder> ;
|
|
||||||
: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 <java:edu.cornell.mannlib.vitro.webapp.search.documentBuilding.ExcludeBasedOnType> ,
|
|
||||||
<java:edu.cornell.mannlib.vitro.webapp.search.documentBuilding.SearchIndexExcluder> ;
|
|
||||||
: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 <java:edu.cornell.mannlib.vitro.webapp.search.documentBuilding.ExcludeBasedOnTypeNamespace> ,
|
|
||||||
<java:edu.cornell.mannlib.vitro.webapp.search.documentBuilding.SearchIndexExcluder> ;
|
|
||||||
:excludes
|
|
||||||
"http://vitro.mannlib.cornell.edu/ns/vitro/role#public" .
|
|
||||||
|
|
||||||
:searchExcluder_vitroExcluder
|
|
||||||
a <java:edu.cornell.mannlib.vitro.webapp.search.documentBuilding.ExcludeNonFlagVitro> ,
|
|
||||||
<java:edu.cornell.mannlib.vitro.webapp.search.documentBuilding.SearchIndexExcluder> .
|
|
||||||
|
|
||||||
:searchExcluder_syncingTypeExcluder
|
|
||||||
a <java:edu.cornell.mannlib.vitro.webapp.search.documentBuilding.SyncingExcludeBasedOnType> ,
|
|
||||||
<java:edu.cornell.mannlib.vitro.webapp.search.documentBuilding.SearchIndexExcluder> .
|
|
||||||
|
|
||||||
# ------------------------------------
|
|
||||||
|
|
||||||
:documentModifier_nameFields
|
|
||||||
a <java:edu.cornell.mannlib.vitro.webapp.search.documentBuilding.NameFields> ,
|
|
||||||
<java:edu.cornell.mannlib.vitro.webapp.search.documentBuilding.DocumentModifier> .
|
|
||||||
|
|
||||||
:documentModifier_nameBoost
|
|
||||||
a <java:edu.cornell.mannlib.vitro.webapp.search.documentBuilding.NameBoost> ,
|
|
||||||
<java:edu.cornell.mannlib.vitro.webapp.search.documentBuilding.DocumentModifier> ;
|
|
||||||
:hasBoost "1.2"^^xsd:float .
|
|
||||||
|
|
||||||
:documentModifier_thumbnailImageUrl
|
|
||||||
a <java:edu.cornell.mannlib.vitro.webapp.search.documentBuilding.ThumbnailImageURL> ,
|
|
||||||
<java:edu.cornell.mannlib.vitro.webapp.search.documentBuilding.DocumentModifier> .
|
|
||||||
|
|
|
@ -0,0 +1,73 @@
|
||||||
|
@prefix : <http://vitro.mannlib.cornell.edu/ns/vitro/ApplicationSetup#> .
|
||||||
|
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
|
||||||
|
|
||||||
|
#
|
||||||
|
# configure the SearchIndexer
|
||||||
|
#
|
||||||
|
|
||||||
|
# Individuals with these types will be excluded from the search index
|
||||||
|
:searchExcluder_typeExcluder
|
||||||
|
a <java:edu.cornell.mannlib.vitro.webapp.searchindex.exclusions.ExcludeBasedOnType> ,
|
||||||
|
<java:edu.cornell.mannlib.vitro.webapp.searchindex.exclusions.SearchIndexExcluder> ;
|
||||||
|
: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 <java:edu.cornell.mannlib.vitro.webapp.searchindex.exclusions.ExcludeBasedOnNamespace> ,
|
||||||
|
<java:edu.cornell.mannlib.vitro.webapp.searchindex.exclusions.SearchIndexExcluder> ;
|
||||||
|
: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 <java:edu.cornell.mannlib.vitro.webapp.searchindex.exclusions.ExcludeBasedOnTypeNamespace> ,
|
||||||
|
<java:edu.cornell.mannlib.vitro.webapp.searchindex.exclusions.SearchIndexExcluder> ;
|
||||||
|
:excludes
|
||||||
|
"http://vitro.mannlib.cornell.edu/ns/vitro/role#public" .
|
||||||
|
|
||||||
|
:searchExcluder_vitroExcluder
|
||||||
|
a <java:edu.cornell.mannlib.vitro.webapp.searchindex.exclusions.ExcludeNonFlagVitro> ,
|
||||||
|
<java:edu.cornell.mannlib.vitro.webapp.searchindex.exclusions.SearchIndexExcluder> .
|
||||||
|
|
||||||
|
:searchExcluder_syncingTypeExcluder
|
||||||
|
a <java:edu.cornell.mannlib.vitro.webapp.searchindex.exclusions.SyncingExcludeBasedOnType> ,
|
||||||
|
<java:edu.cornell.mannlib.vitro.webapp.searchindex.exclusions.SearchIndexExcluder> .
|
||||||
|
|
||||||
|
# ------------------------------------
|
||||||
|
|
||||||
|
:documentModifier_nameFields
|
||||||
|
a <java:edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.NameFields> ,
|
||||||
|
<java:edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.DocumentModifier> .
|
||||||
|
|
||||||
|
:documentModifier_nameBoost
|
||||||
|
a <java:edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.NameBoost> ,
|
||||||
|
<java:edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.DocumentModifier> ;
|
||||||
|
:hasBoost "1.2"^^xsd:float .
|
||||||
|
|
||||||
|
:documentModifier_thumbnailImageUrl
|
||||||
|
a <java:edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.ThumbnailImageURL> ,
|
||||||
|
<java:edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.DocumentModifier> .
|
||||||
|
|
||||||
|
# ------------------------------------
|
||||||
|
|
||||||
|
:uriFinder_forDataProperties
|
||||||
|
a <java:edu.cornell.mannlib.vitro.webapp.searchindex.indexing.IndexingUriFinder> ,
|
||||||
|
<java:edu.cornell.mannlib.vitro.webapp.searchindex.indexing.AdditionalURIsForDataProperties> .
|
||||||
|
|
||||||
|
:uriFinder_forObjectProperties
|
||||||
|
a <java:edu.cornell.mannlib.vitro.webapp.searchindex.indexing.IndexingUriFinder> ,
|
||||||
|
<java:edu.cornell.mannlib.vitro.webapp.searchindex.indexing.AdditionalURIsForObjectProperties> .
|
||||||
|
|
||||||
|
:uriFinder_forTypeStatements
|
||||||
|
a <java:edu.cornell.mannlib.vitro.webapp.searchindex.indexing.IndexingUriFinder> ,
|
||||||
|
<java:edu.cornell.mannlib.vitro.webapp.searchindex.indexing.AdditionalURIsForTypeStatements> .
|
||||||
|
|
||||||
|
:uriFinder_forClassGroupChange
|
||||||
|
a <java:edu.cornell.mannlib.vitro.webapp.searchindex.indexing.IndexingUriFinder> ,
|
||||||
|
<java:edu.cornell.mannlib.vitro.webapp.searchindex.indexing.URIsForClassGroupChange> .
|
|
@ -110,6 +110,8 @@ public interface SearchIndexer extends Application.Module {
|
||||||
*/
|
*/
|
||||||
public static class Event {
|
public static class Event {
|
||||||
public enum Type {
|
public enum Type {
|
||||||
|
STARTUP,
|
||||||
|
|
||||||
START_PROCESSING_URIS,
|
START_PROCESSING_URIS,
|
||||||
|
|
||||||
PROGRESS_PROCESSING_URIS,
|
PROGRESS_PROCESSING_URIS,
|
||||||
|
|
|
@ -5,25 +5,25 @@ package edu.cornell.mannlib.vitro.webapp.search;
|
||||||
public class VitroSearchTermNames {
|
public class VitroSearchTermNames {
|
||||||
|
|
||||||
/** Id of entity, vclass or tab */
|
/** Id of entity, vclass or tab */
|
||||||
public static String URI = "URI";
|
public static final String URI = "URI";
|
||||||
/** search document id */
|
/** search document id */
|
||||||
public static String DOCID = "DocId";
|
public static final String DOCID = "DocId";
|
||||||
|
|
||||||
/** rdf:type */
|
/** rdf:type */
|
||||||
public static String RDFTYPE = "type";
|
public static final String RDFTYPE = "type";
|
||||||
/** classgroups from the individual's rdf:types */
|
/** 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*/
|
/** 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 */
|
/** 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 */
|
/** 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
|
/** text for 'full text' search, this is unstemmed for
|
||||||
* use with wildcards and prefix queries */
|
* 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 */
|
/** Does the individual have a thumbnail image? 1=yes 0=no */
|
||||||
public static final String THUMBNAIL = "THUMBNAIL";
|
public static final String THUMBNAIL = "THUMBNAIL";
|
||||||
|
@ -32,20 +32,20 @@ public class VitroSearchTermNames {
|
||||||
|
|
||||||
// Fields derived from rdfs:label
|
// Fields derived from rdfs:label
|
||||||
/** Raw rdfs:label: no lowercasing, no tokenizing, no stop words, no stemming **/
|
/** 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 **/
|
/** 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. **/
|
/** Same as NAME_LOWERCASE, but single-valued so it's sortable. **/
|
||||||
// RY Need to control how indexing selects which of multiple values to copy.
|
// 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 **/
|
/** 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 **/
|
/** rdfs:label lowercased, tokenized, stop words, stemmed **/
|
||||||
public static String NAME_STEMMED = "nameStemmed";
|
public static final String NAME_STEMMED = "nameStemmed";
|
||||||
|
|
||||||
/** preferred title */
|
/** preferred title */
|
||||||
public static final String PREFERRED_TITLE = "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";
|
public static final String NAME_PHONETIC = "NAME_PHONETIC";
|
||||||
|
|
||||||
/** rdfs:label lowercased, untokenized, edge-n-gram-filtered for autocomplete on people names **/
|
/** 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
|
/** rdfs:label lowercased, tokenized, stop words, stemmed, edge-n-gram-filtered for autocomplete
|
||||||
* on non-person labels such as book titles and grant names **/
|
* 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.
|
/* 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 **/
|
/** Beta values used in weighting **/
|
||||||
public static final String BETA = "BETA";
|
public static final String BETA = "BETA";
|
||||||
|
|
|
@ -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.IndividualDao;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
||||||
import edu.cornell.mannlib.vitro.webapp.search.beans.IndexerIface;
|
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;
|
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
|
/** This is a list of objects that will compute what URIs need to be
|
||||||
* updated in the search index when a statement changes. */
|
* updated in the search index when a statement changes. */
|
||||||
private final List<StatementToURIsToUpdate> stmtToURIsToIndexFunctions;
|
private final List<IndexingUriFinder> stmtToURIsToIndexFunctions;
|
||||||
|
|
||||||
/** Indicates that a full index re-build has been requested. */
|
/** Indicates that a full index re-build has been requested. */
|
||||||
private volatile boolean reindexRequested = false;
|
private volatile boolean reindexRequested = false;
|
||||||
|
@ -102,7 +102,7 @@ public class IndexBuilder extends VitroBackgroundThread {
|
||||||
|
|
||||||
public IndexBuilder(IndexerIface indexer,
|
public IndexBuilder(IndexerIface indexer,
|
||||||
WebappDaoFactory wdf,
|
WebappDaoFactory wdf,
|
||||||
List<StatementToURIsToUpdate> stmtToURIsToIndexFunctions ){
|
List<IndexingUriFinder> stmtToURIsToIndexFunctions ){
|
||||||
super("IndexBuilder");
|
super("IndexBuilder");
|
||||||
|
|
||||||
this.indexer = indexer;
|
this.indexer = indexer;
|
||||||
|
@ -275,7 +275,7 @@ public class IndexBuilder extends VitroBackgroundThread {
|
||||||
*/
|
*/
|
||||||
private Collection<String> changedStatementsToUris(){
|
private Collection<String> changedStatementsToUris(){
|
||||||
//inform StatementToURIsToUpdate that index is starting
|
//inform StatementToURIsToUpdate that index is starting
|
||||||
for( StatementToURIsToUpdate stu : stmtToURIsToIndexFunctions ) {
|
for( IndexingUriFinder stu : stmtToURIsToIndexFunctions ) {
|
||||||
stu.startIndexing();
|
stu.startIndexing();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -291,7 +291,7 @@ public class IndexBuilder extends VitroBackgroundThread {
|
||||||
|
|
||||||
for (int i = 0; i < howManyChanges; i++) {
|
for (int i = 0; i < howManyChanges; i++) {
|
||||||
Statement stmt = changedStatements[i];
|
Statement stmt = changedStatements[i];
|
||||||
for (StatementToURIsToUpdate stu : stmtToURIsToIndexFunctions) {
|
for (IndexingUriFinder stu : stmtToURIsToIndexFunctions) {
|
||||||
urisToUpdate.addAll(stu.findAdditionalURIsToIndex(stmt));
|
urisToUpdate.addAll(stu.findAdditionalURIsToIndex(stmt));
|
||||||
}
|
}
|
||||||
if ((i > 0) && (i % 1000 == 0)) {
|
if ((i > 0) && (i % 1000 == 0)) {
|
||||||
|
@ -301,8 +301,8 @@ public class IndexBuilder extends VitroBackgroundThread {
|
||||||
}
|
}
|
||||||
|
|
||||||
//inform StatementToURIsToUpdate that they are done
|
//inform StatementToURIsToUpdate that they are done
|
||||||
for( StatementToURIsToUpdate stu : stmtToURIsToIndexFunctions ) {
|
for( IndexingUriFinder stu : stmtToURIsToIndexFunctions ) {
|
||||||
stu.endIndxing();
|
stu.endIndexing();
|
||||||
}
|
}
|
||||||
|
|
||||||
return urisToUpdate;
|
return urisToUpdate;
|
||||||
|
|
|
@ -2,8 +2,9 @@
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.searchindex;
|
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.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 static edu.cornell.mannlib.vitro.webapp.modules.searchIndexer.SearchIndexer.Event.Type.STOP_PROCESSING_STATEMENTS;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -11,12 +12,14 @@ import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import javax.servlet.ServletContext;
|
import javax.servlet.ServletContext;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
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.Application;
|
||||||
import edu.cornell.mannlib.vitro.webapp.modules.ComponentStartupStatus;
|
import edu.cornell.mannlib.vitro.webapp.modules.ComponentStartupStatus;
|
||||||
import edu.cornell.mannlib.vitro.webapp.modules.searchIndexer.SearchIndexer;
|
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.modules.searchIndexer.SearchIndexerStatus.State;
|
||||||
import edu.cornell.mannlib.vitro.webapp.search.indexing.IndexBuilder;
|
import edu.cornell.mannlib.vitro.webapp.search.indexing.IndexBuilder;
|
||||||
import edu.cornell.mannlib.vitro.webapp.search.indexing.IndexingEventListener;
|
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.WorkLevel;
|
||||||
import edu.cornell.mannlib.vitro.webapp.utils.threads.VitroBackgroundThread.WorkLevelStamp;
|
import edu.cornell.mannlib.vitro.webapp.utils.threads.VitroBackgroundThread.WorkLevelStamp;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO
|
* TODO A silly implementation that just wraps the old IndexBuilder.
|
||||||
* A silly implementation that just wraps the old IndexBuilder.
|
|
||||||
*/
|
*/
|
||||||
public class SearchIndexerImpl implements SearchIndexer {
|
public class SearchIndexerImpl implements SearchIndexer {
|
||||||
private static final Log log = LogFactory.getLog(SearchIndexerImpl.class);
|
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 final ListenerList listeners = new ListenerList();
|
||||||
|
|
||||||
private ServletContext ctx;
|
private ServletContext ctx;
|
||||||
// private Set<SearchIndexExcluder> excluders;
|
private Set<SearchIndexExcluder> excluders;
|
||||||
// private Set<DocumentModifier> modifiers;
|
private Set<DocumentModifier> modifiers;
|
||||||
// private Set<IndexingUriFinder> uriFinders;
|
private Set<IndexingUriFinder> uriFinders;
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
private IndexBuilder indexBuilder;
|
private IndexBuilder indexBuilder;
|
||||||
|
@ -48,15 +55,18 @@ public class SearchIndexerImpl implements SearchIndexer {
|
||||||
public void startup(Application application, ComponentStartupStatus ss) {
|
public void startup(Application application, ComponentStartupStatus ss) {
|
||||||
try {
|
try {
|
||||||
this.ctx = application.getServletContext();
|
this.ctx = application.getServletContext();
|
||||||
// loadConfiguration();
|
loadConfiguration();
|
||||||
// ss.info("Configured SearchIndexer: excluders=" + excluders
|
ss.info("Configured SearchIndexer: excluders=" + excluders
|
||||||
// + ", modifiers=" + modifiers + ", uriFinders=" + uriFinders);
|
+ ", modifiers=" + modifiers + ", uriFinders=" + uriFinders);
|
||||||
|
|
||||||
// TODO
|
{ // >>>>>>> TODO
|
||||||
this.indexBuilder = (IndexBuilder) ctx
|
this.indexBuilder = (IndexBuilder) ctx
|
||||||
.getAttribute(IndexBuilder.class.getName());
|
.getAttribute(IndexBuilder.class.getName());
|
||||||
|
|
||||||
this.indexBuilder.addIndexBuilderListener(new BridgeListener());
|
this.indexBuilder.addIndexBuilderListener(new BridgeListener());
|
||||||
|
}
|
||||||
|
|
||||||
|
createAndFire(STARTUP);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
ss.fatal("Failed to configure the SearchIndexer", e);
|
ss.fatal("Failed to configure the SearchIndexer", e);
|
||||||
}
|
}
|
||||||
|
@ -66,25 +76,12 @@ public class SearchIndexerImpl implements SearchIndexer {
|
||||||
listeners.fireEvent(new Event(type, getStatus()));
|
listeners.fireEvent(new Event(type, getStatus()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// private void loadConfiguration() throws ConfigurationBeanLoaderException
|
private void loadConfiguration() throws ConfigurationBeanLoaderException {
|
||||||
// {
|
ConfigurationBeanLoader beanLoader = new ConfigurationBeanLoader(
|
||||||
// ConfigurationBeanLoader beanLoader = new ConfigurationBeanLoader(
|
ModelAccess.on(ctx).getOntModel(DISPLAY), ctx);
|
||||||
// ModelAccess.on(ctx).getOntModel(DISPLAY), ctx);
|
excluders = beanLoader.loadAll(SearchIndexExcluder.class);
|
||||||
// excluders = beanLoader.loadAll(SearchIndexExcluder.class);
|
modifiers = beanLoader.loadAll(DocumentModifier.class);
|
||||||
// modifiers = beanLoader.loadAll(DocumentModifier.class);
|
uriFinders = beanLoader.loadAll(IndexingUriFinder.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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -173,6 +170,21 @@ public class SearchIndexerImpl implements SearchIndexer {
|
||||||
listeners.remove(listener);
|
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 static class ListenerList {
|
||||||
private final List<Listener> list;
|
private final List<Listener> list;
|
||||||
|
|
||||||
|
|
|
@ -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.dao.jena.ModelContext;
|
||||||
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess;
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess;
|
||||||
import edu.cornell.mannlib.vitro.webapp.modules.searchEngine.SearchEngine;
|
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.SearchIndexer;
|
||||||
import edu.cornell.mannlib.vitro.webapp.search.documentBuilding.IndividualToSearchDocument;
|
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.IndexBuilder;
|
||||||
import edu.cornell.mannlib.vitro.webapp.search.indexing.SearchReindexingListener;
|
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.documentBuilding.DocumentModifier;
|
||||||
import edu.cornell.mannlib.vitro.webapp.searchindex.exclusions.SearchIndexExcluder;
|
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.IndexingUriFinder;
|
||||||
import edu.cornell.mannlib.vitro.webapp.searchindex.indexing.StatementToURIsToUpdate;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.startup.ComponentStartupStatusImpl;
|
import edu.cornell.mannlib.vitro.webapp.startup.ComponentStartupStatusImpl;
|
||||||
import edu.cornell.mannlib.vitro.webapp.startup.StartupStatus;
|
import edu.cornell.mannlib.vitro.webapp.startup.StartupStatus;
|
||||||
import edu.cornell.mannlib.vitro.webapp.utils.configuration.ConfigurationBeanLoader;
|
import edu.cornell.mannlib.vitro.webapp.utils.configuration.ConfigurationBeanLoader;
|
||||||
|
@ -78,10 +75,7 @@ public class SearchIndexerSetup implements ServletContextListener {
|
||||||
wadf = new WebappDaoFactoryFiltering(wadf, vf);
|
wadf = new WebappDaoFactoryFiltering(wadf, vf);
|
||||||
|
|
||||||
// make objects that will find additional URIs for context nodes etc
|
// make objects that will find additional URIs for context nodes etc
|
||||||
RDFService rdfService = RDFServiceUtils.getRDFServiceFactory(
|
List<IndexingUriFinder> uriFinders = loadUriFinders();
|
||||||
context).getRDFService();
|
|
||||||
List<StatementToURIsToUpdate> uriFinders = AdditionalUriFinders
|
|
||||||
.getList(rdfService, wadf.getIndividualDao());
|
|
||||||
|
|
||||||
// Make the IndexBuilder
|
// Make the IndexBuilder
|
||||||
IndexBuilder builder = new IndexBuilder(searchIndexer, wadf,
|
IndexBuilder builder = new IndexBuilder(searchIndexer, wadf,
|
||||||
|
@ -128,4 +122,12 @@ public class SearchIndexerSetup implements ServletContextListener {
|
||||||
throw new RuntimeException("Failed to configure the SearchIndexer", e);
|
throw new RuntimeException("Failed to configure the SearchIndexer", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private List<IndexingUriFinder> loadUriFinders() {
|
||||||
|
try {
|
||||||
|
return new ArrayList<>(beanLoader.loadAll(IndexingUriFinder.class));
|
||||||
|
} catch (ConfigurationBeanLoaderException e) {
|
||||||
|
throw new RuntimeException("Failed to configure the SearchIndexer", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,6 +69,11 @@ public class NameFields implements DocumentModifier, ContextModelsUser {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return this.getClass().getSimpleName();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void shutdown() { /*nothing to do */ }
|
public void shutdown() { /*nothing to do */ }
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,6 +93,11 @@ public class ThumbnailImageURL implements DocumentModifier, ContextModelsUser {
|
||||||
return result.toString();
|
return result.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return this.getClass().getSimpleName();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void shutdown() {
|
public void shutdown() {
|
||||||
// nothing to release.
|
// nothing to release.
|
||||||
|
|
|
@ -2,10 +2,7 @@
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.searchindex.exclusions;
|
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.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -92,6 +89,6 @@ public class ExcludeBasedOnType implements SearchIndexExcluder {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return this.getClass().getSimpleName() + " [typeURIs=" + typeURIs + "]";
|
return this.getClass().getSimpleName() + "[typeURIs=" + typeURIs + "]";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,6 +61,6 @@ public class ExcludeBasedOnTypeNamespace implements SearchIndexExcluder {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "ExcludeBasedOnTypeNamespace [namespaces=" + namespaces + "]";
|
return "ExcludeBasedOnTypeNamespace[namespaces=" + namespaces + "]";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||||
package edu.cornell.mannlib.vitro.webapp.searchindex.exclusions;
|
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 java.util.List;
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
@ -56,7 +54,7 @@ public class ExcludeNonFlagVitro implements SearchIndexExcluder {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "ExcludeNonFlagVitro []";
|
return "ExcludeNonFlagVitro";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
||||||
* should be excluded from the search index.
|
* should be excluded from the search index.
|
||||||
*/
|
*/
|
||||||
public interface SearchIndexExcluder {
|
public interface SearchIndexExcluder {
|
||||||
|
public static final String DONT_EXCLUDE = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* REturn a string message if the individual should
|
* REturn a string message if the individual should
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.searchindex.indexing;
|
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.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -15,6 +15,8 @@ import com.hp.hpl.jena.shared.Lock;
|
||||||
import com.hp.hpl.jena.vocabulary.RDF;
|
import com.hp.hpl.jena.vocabulary.RDF;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
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
|
* If a class changes classgroups, then all members of that class
|
||||||
|
@ -27,13 +29,13 @@ import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
||||||
* obj='http://vivoweb.org/ontology#vitroClassGrouppeople'
|
* 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.
|
* changes, all members of the class core:Summer need to be update so they get the new classgroup values.
|
||||||
*/
|
*/
|
||||||
public class AdditionalURIsForClassGroupChanges implements
|
public class AdditionalURIsForClassGroupChanges implements IndexingUriFinder, ContextModelsUser {
|
||||||
StatementToURIsToUpdate {
|
|
||||||
|
|
||||||
private OntModel model;
|
private OntModel model;
|
||||||
|
|
||||||
public AdditionalURIsForClassGroupChanges(OntModel model) {
|
@Override
|
||||||
this.model = model;
|
public void setContextModels(ContextModelAccess models) {
|
||||||
|
model = models.getOntModel(TBOX_ASSERTIONS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -66,5 +68,11 @@ public class AdditionalURIsForClassGroupChanges implements
|
||||||
public void startIndexing() { /* nothing to prepare */ }
|
public void startIndexing() { /* nothing to prepare */ }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void endIndxing() { /* nothing to do */ }
|
public void endIndexing() { /* nothing to do */ }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return this.getClass().getSimpleName();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,9 +7,9 @@ import java.util.List;
|
||||||
|
|
||||||
import com.hp.hpl.jena.rdf.model.Statement;
|
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
|
@Override
|
||||||
public List<String> findAdditionalURIsToIndex(Statement stmt) {
|
public List<String> findAdditionalURIsToIndex(Statement stmt) {
|
||||||
|
@ -23,5 +23,11 @@ public class AdditionalURIsForDataProperties implements StatementToURIsToUpdate
|
||||||
public void startIndexing() { /* nothing to prepare */ }
|
public void startIndexing() { /* nothing to prepare */ }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void endIndxing() { /* nothing to do */ }
|
public void endIndexing() { /* nothing to do */ }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return this.getClass().getSimpleName();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,9 @@ import com.hp.hpl.jena.rdf.model.Statement;
|
||||||
import com.hp.hpl.jena.vocabulary.RDFS;
|
import com.hp.hpl.jena.vocabulary.RDFS;
|
||||||
|
|
||||||
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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* For a given statement, return the URIs that may need to be updated in
|
* 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.
|
* 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 static final Log log = LogFactory.getLog(AdditionalURIsForObjectProperties.class);
|
||||||
|
|
||||||
protected final RDFService rdfService;
|
protected RDFService rdfService;
|
||||||
|
|
||||||
public AdditionalURIsForObjectProperties(RDFService rdfService) {
|
@Override
|
||||||
this.rdfService = rdfService;
|
public void setContextModels(ContextModelAccess models) {
|
||||||
|
this.rdfService = models.getRDFService();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -53,7 +56,7 @@ public class AdditionalURIsForObjectProperties implements StatementToURIsToUpdat
|
||||||
public void startIndexing() { /* nothing to prepare */ }
|
public void startIndexing() { /* nothing to prepare */ }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void endIndxing() { /* nothing to do */ }
|
public void endIndexing() { /* nothing to do */ }
|
||||||
|
|
||||||
protected List<String> doObjectPropertyStmt(Statement stmt) {
|
protected List<String> doObjectPropertyStmt(Statement stmt) {
|
||||||
// Only need to consider the object since the subject
|
// 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" +
|
" filter( isURI( ?related ) && ?p != rdf:type ) \n" +
|
||||||
"}" ;
|
"}" ;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return this.getClass().getSimpleName();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,12 +8,12 @@ import java.util.List;
|
||||||
import com.hp.hpl.jena.rdf.model.Statement;
|
import com.hp.hpl.jena.rdf.model.Statement;
|
||||||
import com.hp.hpl.jena.vocabulary.RDF;
|
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.
|
* Adds URIs to index for type statement changes on individuals.
|
||||||
*/
|
*/
|
||||||
public class AdditionalURIsForTypeStatements implements StatementToURIsToUpdate {
|
public class AdditionalURIsForTypeStatements implements IndexingUriFinder {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> findAdditionalURIsToIndex(Statement stmt) {
|
public List<String> findAdditionalURIsToIndex(Statement stmt) {
|
||||||
|
@ -28,7 +28,11 @@ public class AdditionalURIsForTypeStatements implements StatementToURIsToUpdate
|
||||||
public void startIndexing() { /* nothing to prepare */ }
|
public void startIndexing() { /* nothing to prepare */ }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void endIndxing() { /* nothing to do */ }
|
public void endIndexing() { /* nothing to do */ }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return this.getClass().getSimpleName();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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<StatementToURIsToUpdate> getList(RDFService rdfService,
|
|
||||||
IndividualDao indDao) {
|
|
||||||
// TODO How many of these are only relevant to VIVO?
|
|
||||||
List<StatementToURIsToUpdate> uriFinders = new ArrayList<>();
|
|
||||||
uriFinders.add(new AdditionalURIsForDataProperties());
|
|
||||||
uriFinders.add(new AdditionalURIsForObjectProperties(rdfService));
|
|
||||||
uriFinders.add(new AdditionalURIsForTypeStatements());
|
|
||||||
uriFinders.add(new URIsForClassGroupChange(indDao));
|
|
||||||
return uriFinders;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -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.
|
* 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.
|
* 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,
|
* For the domain that is the responsibility of the given implementation,
|
||||||
|
@ -25,5 +25,5 @@ public interface StatementToURIsToUpdate {
|
||||||
|
|
||||||
void startIndexing();
|
void startIndexing();
|
||||||
|
|
||||||
void endIndxing();
|
void endIndexing();
|
||||||
}
|
}
|
|
@ -11,16 +11,19 @@ import com.hp.hpl.jena.rdf.model.Statement;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.IndividualDao;
|
import edu.cornell.mannlib.vitro.webapp.dao.IndividualDao;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
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.
|
* 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;
|
IndividualDao indDao;
|
||||||
|
|
||||||
public URIsForClassGroupChange(IndividualDao individualDao){
|
@Override
|
||||||
this.indDao = individualDao;
|
public void setContextModels(ContextModelAccess models) {
|
||||||
|
this.indDao = models.getWebappDaoFactory().getIndividualDao();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -57,9 +60,14 @@ public class URIsForClassGroupChange implements StatementToURIsToUpdate {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void endIndxing() {
|
public void endIndexing() {
|
||||||
// Do nothing
|
// Do nothing
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return this.getClass().getSimpleName();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,11 +9,14 @@ import org.junit.Assert;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
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 com.hp.hpl.jena.rdf.model.ResourceFactory;
|
import com.hp.hpl.jena.rdf.model.ResourceFactory;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author bdc34
|
* @author bdc34
|
||||||
|
@ -36,7 +39,12 @@ public class AdditionalURIsForClassGroupChangesTest {
|
||||||
OntModel model = ModelFactory.createOntologyModel();
|
OntModel model = ModelFactory.createOntologyModel();
|
||||||
model.read( new StringReader(n3ForPresentationClass), null, "N3");
|
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<String> uris = uriFinder.findAdditionalURIsToIndex(
|
List<String> uris = uriFinder.findAdditionalURIsToIndex(
|
||||||
ResourceFactory.createStatement(
|
ResourceFactory.createStatement(
|
||||||
ResourceFactory.createResource("http://vivoweb.org/ontology/core#Presentation"),
|
ResourceFactory.createResource("http://vivoweb.org/ontology/core#Presentation"),
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.searchindex.indexing;
|
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.io.StringReader;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -9,6 +11,8 @@ import org.junit.Assert;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
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.Model;
|
||||||
import com.hp.hpl.jena.rdf.model.ModelFactory;
|
import com.hp.hpl.jena.rdf.model.ModelFactory;
|
||||||
import com.hp.hpl.jena.rdf.model.ResourceFactory;
|
import com.hp.hpl.jena.rdf.model.ResourceFactory;
|
||||||
|
@ -22,6 +26,7 @@ public class AdditionalURIsForObjectPropertiesTest {
|
||||||
|
|
||||||
Model model;
|
Model model;
|
||||||
RDFService rdfService;
|
RDFService rdfService;
|
||||||
|
AdditionalURIsForObjectProperties aufop;
|
||||||
|
|
||||||
String testNS = "http://example.com/test#";
|
String testNS = "http://example.com/test#";
|
||||||
String n3 = "" +
|
String n3 = "" +
|
||||||
|
@ -44,11 +49,16 @@ public class AdditionalURIsForObjectPropertiesTest {
|
||||||
model = ModelFactory.createDefaultModel();
|
model = ModelFactory.createDefaultModel();
|
||||||
model.read(new StringReader(n3 ), null , "N3");
|
model.read(new StringReader(n3 ), null , "N3");
|
||||||
rdfService = new RDFServiceModel(model);
|
rdfService = new RDFServiceModel(model);
|
||||||
|
|
||||||
|
ContextModelAccessStub models = new ContextModelAccessStub();
|
||||||
|
models.setRDFService(CONTENT, rdfService);
|
||||||
|
|
||||||
|
aufop = new AdditionalURIsForObjectProperties();
|
||||||
|
aufop.setContextModels(models);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testChangeOfRdfsLabel() {
|
public void testChangeOfRdfsLabel() {
|
||||||
AdditionalURIsForObjectProperties aufop = new AdditionalURIsForObjectProperties(rdfService);
|
|
||||||
List<String> uris = aufop.findAdditionalURIsToIndex(
|
List<String> uris = aufop.findAdditionalURIsToIndex(
|
||||||
ResourceFactory.createStatement(
|
ResourceFactory.createStatement(
|
||||||
ResourceFactory.createResource(testNS + "bob"),
|
ResourceFactory.createResource(testNS + "bob"),
|
||||||
|
@ -70,8 +80,6 @@ public class AdditionalURIsForObjectPropertiesTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testChangeOfObjPropStmt() {
|
public void testChangeOfObjPropStmt() {
|
||||||
|
|
||||||
AdditionalURIsForObjectProperties aufop = new AdditionalURIsForObjectProperties(rdfService);
|
|
||||||
List<String> uris = aufop.findAdditionalURIsToIndex(
|
List<String> uris = aufop.findAdditionalURIsToIndex(
|
||||||
ResourceFactory.createStatement(
|
ResourceFactory.createStatement(
|
||||||
ResourceFactory.createResource(testNS + "bob"),
|
ResourceFactory.createResource(testNS + "bob"),
|
||||||
|
@ -93,7 +101,6 @@ public class AdditionalURIsForObjectPropertiesTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testOfDataPropChange() {
|
public void testOfDataPropChange() {
|
||||||
AdditionalURIsForObjectProperties aufop = new AdditionalURIsForObjectProperties(rdfService);
|
|
||||||
List<String> uris = aufop.findAdditionalURIsToIndex(
|
List<String> uris = aufop.findAdditionalURIsToIndex(
|
||||||
ResourceFactory.createStatement(
|
ResourceFactory.createStatement(
|
||||||
ResourceFactory.createResource(testNS + "bob"),
|
ResourceFactory.createResource(testNS + "bob"),
|
||||||
|
@ -112,9 +119,12 @@ public class AdditionalURIsForObjectPropertiesTest {
|
||||||
|
|
||||||
Model model = ModelFactory.createDefaultModel();
|
Model model = ModelFactory.createDefaultModel();
|
||||||
model.read(new StringReader( n3ForNIHVIVO_2902 ), null , "N3");
|
model.read(new StringReader( n3ForNIHVIVO_2902 ), null , "N3");
|
||||||
RDFService rdfService = new RDFServiceModel(model);
|
|
||||||
|
|
||||||
AdditionalURIsForObjectProperties aufop = new AdditionalURIsForObjectProperties(rdfService);
|
ContextModelAccessStub models = new ContextModelAccessStub();
|
||||||
|
models.setRDFService(CONTENT, new RDFServiceModel(model));
|
||||||
|
|
||||||
|
aufop.setContextModels(models);
|
||||||
|
|
||||||
List<String> uris = aufop.findAdditionalURIsToIndex(
|
List<String> uris = aufop.findAdditionalURIsToIndex(
|
||||||
ResourceFactory.createStatement(
|
ResourceFactory.createStatement(
|
||||||
ResourceFactory.createResource("http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n2241"),
|
ResourceFactory.createResource("http://caruso-laptop.mannlib.cornell.edu:8090/vivo/individual/n2241"),
|
||||||
|
|
Loading…
Add table
Reference in a new issue