From 6d6d2fb784dbbdb68ea08208b022c50f3f5ee062 Mon Sep 17 00:00:00 2001 From: briancaruso Date: Tue, 3 Jul 2012 00:13:08 +0000 Subject: [PATCH] Fixing a bug in the ContextNodeFields where initialBindings were no longer getting used so a critical variable in the SPARQL query was free. NIHVIVO-3853 --- .../documentBuilding/ContextNodeFields.java | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/search/solr/documentBuilding/ContextNodeFields.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/search/solr/documentBuilding/ContextNodeFields.java index 579c7bd1e..e0c442f9e 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/search/solr/documentBuilding/ContextNodeFields.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/search/solr/documentBuilding/ContextNodeFields.java @@ -47,7 +47,7 @@ public class ContextNodeFields implements DocumentModifier{ } - protected StringBuffer getValues( Individual individual ){ + public StringBuffer getValues( Individual individual ){ return executeQueryForValues( individual, queries ); } @@ -77,20 +77,19 @@ public class ContextNodeFields implements DocumentModifier{ * @return StringBuffer with text values to add to ALLTEXT field of solr Document. */ protected StringBuffer executeQueryForValues( Individual individual, Collection queries){ - /* execute all the queries on the list and concat the values to add to all text */ - + /* execute all the queries on the list and concat the values to add to all text */ RDFService rdfService = rdfServiceFactory.getRDFService(); - StringBuffer allValues = new StringBuffer(""); - - QuerySolutionMap initialBinding = new QuerySolutionMap(); - initialBinding.add("uri", ResourceFactory.createResource(individual.getURI())); + StringBuffer allValues = new StringBuffer(""); for(String query : queries ){ StringBuffer valuesForQuery = new StringBuffer(); - + + String subInUriQuery = + query.replaceAll("\\?uri", "<" + individual.getURI() + "> "); + try{ - ResultSet results = RDFServiceUtils.sparqlSelectQuery(query, rdfService); - + + ResultSet results = RDFServiceUtils.sparqlSelectQuery(subInUriQuery, rdfService); while(results.hasNext()){ valuesForQuery.append( getTextForRow( results.nextSolution() ) ) ; @@ -102,7 +101,7 @@ public class ContextNodeFields implements DocumentModifier{ } if(log.isDebugEnabled()){ - log.debug("query: '" + query + "'"); + log.debug("query: '" + subInUriQuery+ "'"); log.debug("text for query: '" + valuesForQuery.toString() + "'"); } allValues.append(valuesForQuery);