VIVO-873 Simplify and document the DocumentModifier interface.
allUris parameter on modifyDocument() was not documented and not used. There is no logical reason for modifyDocument to throw a SkipIndividualException.
This commit is contained in:
parent
3877ba1c3e
commit
3ccb10dc83
8 changed files with 32 additions and 33 deletions
|
@ -51,7 +51,7 @@ public class ContextNodeFields implements DocumentModifier{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void modifyDocument(Individual individual, SearchInputDocument doc, StringBuffer addUri) {
|
public void modifyDocument(Individual individual, SearchInputDocument doc) {
|
||||||
if( individual == null )
|
if( individual == null )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -4,11 +4,21 @@ package edu.cornell.mannlib.vitro.webapp.search.documentBuilding;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
||||||
import edu.cornell.mannlib.vitro.webapp.modules.searchEngine.SearchInputDocument;
|
import edu.cornell.mannlib.vitro.webapp.modules.searchEngine.SearchInputDocument;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This interface represents an object that can add to a SearchInputDocument.
|
* This interface represents an object that can add to a SearchInputDocument.
|
||||||
*/
|
*/
|
||||||
public interface DocumentModifier {
|
public interface DocumentModifier {
|
||||||
public void modifyDocument(Individual individual, SearchInputDocument doc, StringBuffer addUri) throws SkipIndividualException;
|
/**
|
||||||
|
* Use the rules contained within this class to modify this search document,
|
||||||
|
* according to the characteristics of this individual.
|
||||||
|
*
|
||||||
|
* @param individual
|
||||||
|
* The individual that is being indexed. Will not be null.
|
||||||
|
* @param doc
|
||||||
|
* The document as it stands so far. Will not be null.
|
||||||
|
*/
|
||||||
|
public void modifyDocument(Individual individual, SearchInputDocument doc);
|
||||||
|
|
||||||
// called to inform the DocumentModifier that the system is shutting down
|
// called to inform the DocumentModifier that the system is shutting down
|
||||||
public void shutdown();
|
public void shutdown();
|
||||||
|
|
|
@ -97,7 +97,7 @@ public class IndividualToSearchDocument {
|
||||||
|
|
||||||
log.debug(ind.getURI() + " pre mod boost: " + doc.getDocumentBoost());
|
log.debug(ind.getURI() + " pre mod boost: " + doc.getDocumentBoost());
|
||||||
|
|
||||||
runAdditionalDocModifers(ind,doc,addUri);
|
runAdditionalDocModifers(ind,doc);
|
||||||
|
|
||||||
log.debug(ind.getURI() + " post mod boost: " + doc.getDocumentBoost());
|
log.debug(ind.getURI() + " post mod boost: " + doc.getDocumentBoost());
|
||||||
|
|
||||||
|
@ -132,7 +132,7 @@ public class IndividualToSearchDocument {
|
||||||
protected Map<String,Long> docModClassToTime = new HashMap<String,Long>();
|
protected Map<String,Long> docModClassToTime = new HashMap<String,Long>();
|
||||||
protected long docModCount =0;
|
protected long docModCount =0;
|
||||||
|
|
||||||
protected void runAdditionalDocModifers( Individual ind, SearchInputDocument doc, StringBuffer addUri )
|
protected void runAdditionalDocModifers( Individual ind, SearchInputDocument doc )
|
||||||
throws SkipIndividualException{
|
throws SkipIndividualException{
|
||||||
//run the document modifiers
|
//run the document modifiers
|
||||||
if( documentModifiers != null && !documentModifiers.isEmpty()){
|
if( documentModifiers != null && !documentModifiers.isEmpty()){
|
||||||
|
@ -141,7 +141,7 @@ public class IndividualToSearchDocument {
|
||||||
|
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
|
|
||||||
modifier.modifyDocument(ind, doc, addUri);
|
modifier.modifyDocument(ind, doc);
|
||||||
|
|
||||||
if( log.isDebugEnabled()){
|
if( log.isDebugEnabled()){
|
||||||
long delta = System.currentTimeMillis() - start;
|
long delta = System.currentTimeMillis() - start;
|
||||||
|
|
|
@ -28,8 +28,7 @@ public class NameBoost implements DocumentModifier {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void modifyDocument(Individual individual, SearchInputDocument doc,
|
public void modifyDocument(Individual individual, SearchInputDocument doc) {
|
||||||
StringBuffer addUri) {
|
|
||||||
|
|
||||||
for( String fieldName : fieldsToBoost){
|
for( String fieldName : fieldsToBoost){
|
||||||
SearchInputField field = doc.getField(fieldName);
|
SearchInputField field = doc.getField(fieldName);
|
||||||
|
|
|
@ -31,8 +31,7 @@ public class NameFields implements DocumentModifier {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void modifyDocument(Individual ind, SearchInputDocument doc,
|
public void modifyDocument(Individual ind, SearchInputDocument doc) {
|
||||||
StringBuffer addUri) throws SkipIndividualException {
|
|
||||||
if( ind == null || ind.getURI() == null ){
|
if( ind == null || ind.getURI() == null ){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,8 +21,7 @@ public class SourceInstitution implements DocumentModifier {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void modifyDocument(Individual individual, SearchInputDocument doc,
|
public void modifyDocument(Individual individual, SearchInputDocument doc) {
|
||||||
StringBuffer addUri) throws SkipIndividualException {
|
|
||||||
|
|
||||||
doc.addField(VitroSearchTermNames.SITE_URL, siteURL);
|
doc.addField(VitroSearchTermNames.SITE_URL, siteURL);
|
||||||
doc.addField(VitroSearchTermNames.SITE_NAME, siteURL);
|
doc.addField(VitroSearchTermNames.SITE_NAME, siteURL);
|
||||||
|
|
|
@ -45,9 +45,7 @@ public class ThumbnailImageURL implements DocumentModifier {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void modifyDocument(Individual individual, SearchInputDocument doc,
|
public void modifyDocument(Individual individual, SearchInputDocument doc) {
|
||||||
StringBuffer addUri) throws SkipIndividualException {
|
|
||||||
|
|
||||||
// add a field for storing the location of thumbnail for the individual.
|
// add a field for storing the location of thumbnail for the individual.
|
||||||
doc.addField(THUMBNAIL_URL, runQueryForThumbnailLocation(individual));
|
doc.addField(THUMBNAIL_URL, runQueryForThumbnailLocation(individual));
|
||||||
addThumbnailExistence(individual, doc);
|
addThumbnailExistence(individual, doc);
|
||||||
|
|
|
@ -29,8 +29,6 @@ import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceFactory;
|
||||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.RDFServiceFactorySingle;
|
import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.RDFServiceFactorySingle;
|
||||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.jena.model.RDFServiceModel;
|
import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.jena.model.RDFServiceModel;
|
||||||
import edu.cornell.mannlib.vitro.webapp.search.VitroSearchTermNames;
|
import edu.cornell.mannlib.vitro.webapp.search.VitroSearchTermNames;
|
||||||
import edu.cornell.mannlib.vitro.webapp.search.documentBuilding.SkipIndividualException;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.search.documentBuilding.ThumbnailImageURL;
|
|
||||||
|
|
||||||
public class ThumbnailImageURLTest extends AbstractTestClass{
|
public class ThumbnailImageURLTest extends AbstractTestClass{
|
||||||
RDFServiceFactory testRDF;
|
RDFServiceFactory testRDF;
|
||||||
|
@ -62,11 +60,7 @@ public class ThumbnailImageURLTest extends AbstractTestClass{
|
||||||
ind.setURI(personsURI);
|
ind.setURI(personsURI);
|
||||||
|
|
||||||
//make sure that the person is in the RDF
|
//make sure that the person is in the RDF
|
||||||
try {
|
testMe.modifyDocument(ind, doc);
|
||||||
testMe.modifyDocument(ind, doc, null);
|
|
||||||
} catch (SkipIndividualException e) {
|
|
||||||
Assert.fail("Test individual was skipped by classes that build the search document: " + e.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
//make sure that a search document field got created for the thumbnail image
|
//make sure that a search document field got created for the thumbnail image
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue