diff --git a/solr/exampleSolr/conf/schema.xml b/solr/exampleSolr/conf/schema.xml
index cce5fc182..4c82fc668 100644
--- a/solr/exampleSolr/conf/schema.xml
+++ b/solr/exampleSolr/conf/schema.xml
@@ -578,6 +578,9 @@
+
+
+
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 f35586b77..361bde923 100644
--- a/webapp/src/edu/cornell/mannlib/vitro/webapp/search/VitroSearchTermNames.java
+++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/search/VitroSearchTermNames.java
@@ -67,4 +67,7 @@ public class VitroSearchTermNames {
/** adding phonetic field **/
public static final String ALLTEXT_PHONETIC = "ALLTEXT_PHONETIC";
public static final String NAME_PHONETIC = "NAME_PHONETIC";
+
+ /** download url location for thumbnail */
+ public static final String THUMBNAIL_URL = "THUMBNAIL_URL";
}
diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/search/solr/SolrSetup.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/search/solr/SolrSetup.java
index 8ef90058b..23cf7c7ac 100644
--- a/webapp/src/edu/cornell/mannlib/vitro/webapp/search/solr/SolrSetup.java
+++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/search/solr/SolrSetup.java
@@ -85,6 +85,7 @@ public class SolrSetup implements javax.servlet.ServletContextListener{
modifiers.add(new CalculateParameters(dataset));
modifiers.add(new ContextNodeFields(jenaOntModel));
modifiers.add(new NameBoost());
+ modifiers.add(new ThumbnailImageURL(jenaOntModel));
// setup probhibited froms earch based on N3 files in the
// directory WEB-INF/ontologies/search
diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/search/solr/ThumbnailImageURL.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/search/solr/ThumbnailImageURL.java
new file mode 100644
index 000000000..a2d5076e8
--- /dev/null
+++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/search/solr/ThumbnailImageURL.java
@@ -0,0 +1,112 @@
+/* $This file is distributed under the terms of the license in /doc/license.txt$ */
+
+package edu.cornell.mannlib.vitro.webapp.search.solr;
+
+import java.util.Iterator;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.solr.common.SolrInputDocument;
+import org.apache.solr.common.SolrInputField;
+
+import com.hp.hpl.jena.query.Query;
+import com.hp.hpl.jena.query.QueryExecution;
+import com.hp.hpl.jena.query.QueryExecutionFactory;
+import com.hp.hpl.jena.query.QueryFactory;
+import com.hp.hpl.jena.query.QuerySolution;
+import com.hp.hpl.jena.query.QuerySolutionMap;
+import com.hp.hpl.jena.query.ResultSet;
+import com.hp.hpl.jena.query.Syntax;
+import com.hp.hpl.jena.rdf.model.Model;
+import com.hp.hpl.jena.rdf.model.RDFNode;
+import com.hp.hpl.jena.rdf.model.Resource;
+import com.hp.hpl.jena.rdf.model.ResourceFactory;
+import com.hp.hpl.jena.shared.Lock;
+
+import edu.cornell.mannlib.vitro.webapp.beans.Individual;
+import edu.cornell.mannlib.vitro.webapp.search.VitroSearchTermNames;
+
+public class ThumbnailImageURL implements DocumentModifier {
+
+ private static final String prefix = "prefix owl: "
+ + " prefix vitroDisplay: "
+ + " prefix rdf: "
+ + " prefix core: "
+ + " prefix foaf: "
+ + " prefix rdfs: "
+ + " prefix localNav: "
+ + " prefix bibo: ";
+
+ private static final String query = prefix +
+
+ " SELECT (str(?thumbnailLocationURL) as ?ThumbnailLocationURL) WHERE { " +
+ " ?uri ?a . " +
+ " ?a ?b . " +
+ " ?b ?thumbnailLocationURL . } ";
+
+ private Model model;
+ private Log log = LogFactory.getLog(ThumbnailImageURL.class);
+ private boolean shutdown = false;
+
+ static VitroSearchTermNames term = new VitroSearchTermNames();
+ String fieldForThumbnailURL = term.THUMBNAIL_URL;
+
+
+ public ThumbnailImageURL(Model model){
+ this.model = model;
+ }
+
+ @Override
+ public void modifyDocument(Individual individual, SolrInputDocument doc,
+ StringBuffer addUri) throws SkipIndividualException {
+
+ //add a field for storing the location of thumbnail for the individual.
+ doc.addField(fieldForThumbnailURL, runQueryForThumbnailLocation(individual));
+
+ }
+
+ private String runQueryForThumbnailLocation(Individual individual) {
+
+ StringBuffer result = new StringBuffer();
+ QuerySolutionMap initialBinding = new QuerySolutionMap();
+ Resource uriResource = ResourceFactory.createResource(individual.getURI());
+ initialBinding.add("uri", uriResource);
+
+ Query sparqlQuery = QueryFactory.create(query, Syntax.syntaxARQ);
+ model.getLock().enterCriticalSection(Lock.READ);
+ try{
+ QueryExecution qExec = QueryExecutionFactory.create(sparqlQuery, model, initialBinding);
+ try{
+ ResultSet results = qExec.execSelect();
+ while(results.hasNext()){
+ QuerySolution soln = results.nextSolution();
+ Iterator iter = soln.varNames() ;
+ while( iter.hasNext()){
+ String name = iter.next();
+ RDFNode node = soln.get( name );
+ if( node != null ){
+ result.append(" " + node.toString());
+ }else{
+ log.info(name + " is null");
+ }
+ }
+ }
+ }catch(Throwable t){
+ if( ! shutdown )
+ log.error(t,t);
+ } finally{
+ qExec.close();
+ }
+ }finally{
+ model.getLock().leaveCriticalSection();
+ }
+
+ return result.toString();
+ }
+
+ @Override
+ public void shutdown() {
+ shutdown = true;
+ }
+
+}