VIVO-870 Confirm that DocumentModifiers are thread-safe.
This commit is contained in:
parent
dee53e3aac
commit
3fd72a7110
5 changed files with 11 additions and 46 deletions
|
@ -7,6 +7,8 @@ import edu.cornell.mannlib.vitro.webapp.modules.searchEngine.SearchInputDocument
|
|||
|
||||
/**
|
||||
* An object that can add to a SearchInputDocument.
|
||||
*
|
||||
* Implementations must be thread-safe.
|
||||
*/
|
||||
public interface DocumentModifier {
|
||||
/**
|
||||
|
|
|
@ -23,9 +23,9 @@ public class NameBoost implements DocumentModifier {
|
|||
* please consider if you need to change this list
|
||||
* of name fields to boost.
|
||||
*/
|
||||
private String[] fieldsToBoost = {NAME_RAW,NAME_LOWERCASE,NAME_UNSTEMMED,NAME_STEMMED};
|
||||
private final String[] fieldsToBoost = {NAME_RAW,NAME_LOWERCASE,NAME_UNSTEMMED,NAME_STEMMED};
|
||||
|
||||
private Float boost;
|
||||
private volatile Float boost;
|
||||
|
||||
@Property(uri="http://vitro.mannlib.cornell.edu/ns/vitro/ApplicationSetup#hasBoost")
|
||||
public void setBoost(float boost) {
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
package edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding;
|
||||
|
||||
import static edu.cornell.mannlib.vitro.webapp.search.VitroSearchTermNames.NAME_RAW;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
|
@ -15,18 +17,16 @@ import edu.cornell.mannlib.vitro.webapp.modules.searchEngine.SearchInputDocument
|
|||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
|
||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService.ResultFormat;
|
||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceException;
|
||||
import edu.cornell.mannlib.vitro.webapp.search.VitroSearchTermNames;
|
||||
import edu.cornell.mannlib.vitro.webapp.utils.configuration.ContextModelsUser;
|
||||
|
||||
/**
|
||||
* Adds all labels to name fields, not just the one returned by Individual.getName().
|
||||
*/
|
||||
public class NameFields implements DocumentModifier, ContextModelsUser {
|
||||
private RDFService rdfService;
|
||||
|
||||
public static final VitroSearchTermNames term = new VitroSearchTermNames();
|
||||
public static final Log log = LogFactory.getLog(NameFields.class.getName());
|
||||
|
||||
private volatile RDFService rdfService;
|
||||
|
||||
@Override
|
||||
public void setContextModels(ContextModelAccess models) {
|
||||
this.rdfService = models.getRDFService();
|
||||
|
@ -59,7 +59,7 @@ public class NameFields implements DocumentModifier, ContextModelsUser {
|
|||
}
|
||||
|
||||
log.debug("Adding labels for " + ind.getURI() + " \"" + buffer.toString() + "\"");
|
||||
doc.addField(term.NAME_RAW, buffer.toString());
|
||||
doc.addField(NAME_RAW, buffer.toString());
|
||||
|
||||
} catch (RDFServiceException e) {
|
||||
log.error("could not get the rdfs:label for " + ind.getURI(), e);
|
||||
|
|
|
@ -1,37 +0,0 @@
|
|||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||
|
||||
package edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
||||
import edu.cornell.mannlib.vitro.webapp.modules.searchEngine.SearchInputDocument;
|
||||
import edu.cornell.mannlib.vitro.webapp.search.VitroSearchTermNames;
|
||||
|
||||
public class SourceInstitution implements DocumentModifier {
|
||||
|
||||
private String siteURL;
|
||||
private String siteName;
|
||||
|
||||
static VitroSearchTermNames term = new VitroSearchTermNames();
|
||||
private String fieldForSiteURL = term.SITE_URL;
|
||||
private String fieldForSiteName = term.SITE_NAME;
|
||||
|
||||
public SourceInstitution(String siteURL, String siteName) {
|
||||
this.siteURL = siteURL;
|
||||
this.siteName = siteName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modifyDocument(Individual individual, SearchInputDocument doc) {
|
||||
|
||||
doc.addField(VitroSearchTermNames.SITE_URL, siteURL);
|
||||
doc.addField(VitroSearchTermNames.SITE_NAME, siteURL);
|
||||
|
||||
doc.addField(fieldForSiteName, siteName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shutdown() {
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -22,6 +22,7 @@ import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.RDFServiceUtils;
|
|||
import edu.cornell.mannlib.vitro.webapp.utils.configuration.ContextModelsUser;
|
||||
|
||||
public class ThumbnailImageURL implements DocumentModifier, ContextModelsUser {
|
||||
private static final Log log = LogFactory.getLog(ThumbnailImageURL.class);
|
||||
|
||||
private static final String PREFIX = "prefix owl: <http://www.w3.org/2002/07/owl#> "
|
||||
+ " prefix vitroDisplay: <http://vitro.mannlib.cornell.edu/ontologies/display/1.1#> "
|
||||
|
@ -37,8 +38,7 @@ public class ThumbnailImageURL implements DocumentModifier, ContextModelsUser {
|
|||
+ " ?uri <http://vitro.mannlib.cornell.edu/ns/vitro/public#mainImage> ?a . "
|
||||
+ " ?a <http://vitro.mannlib.cornell.edu/ns/vitro/public#downloadLocation> ?downloadLocation . } ";
|
||||
|
||||
private RDFService rdf;
|
||||
private Log log = LogFactory.getLog(ThumbnailImageURL.class);
|
||||
private volatile RDFService rdf;
|
||||
|
||||
@Override
|
||||
public void setContextModels(ContextModelAccess models) {
|
||||
|
|
Loading…
Add table
Reference in a new issue