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

This commit is contained in:
briancaruso 2012-07-03 00:13:08 +00:00
parent c39790aed9
commit 6d6d2fb784

View file

@ -47,7 +47,7 @@ public class ContextNodeFields implements DocumentModifier{
} }
protected StringBuffer getValues( Individual individual ){ public StringBuffer getValues( Individual individual ){
return executeQueryForValues( individual, queries ); 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. * @return StringBuffer with text values to add to ALLTEXT field of solr Document.
*/ */
protected StringBuffer executeQueryForValues( Individual individual, Collection<String> queries){ protected StringBuffer executeQueryForValues( Individual individual, Collection<String> 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(); RDFService rdfService = rdfServiceFactory.getRDFService();
StringBuffer allValues = new StringBuffer(""); StringBuffer allValues = new StringBuffer("");
QuerySolutionMap initialBinding = new QuerySolutionMap();
initialBinding.add("uri", ResourceFactory.createResource(individual.getURI()));
for(String query : queries ){ for(String query : queries ){
StringBuffer valuesForQuery = new StringBuffer(); StringBuffer valuesForQuery = new StringBuffer();
String subInUriQuery =
query.replaceAll("\\?uri", "<" + individual.getURI() + "> ");
try{ try{
ResultSet results = RDFServiceUtils.sparqlSelectQuery(query, rdfService);
ResultSet results = RDFServiceUtils.sparqlSelectQuery(subInUriQuery, rdfService);
while(results.hasNext()){ while(results.hasNext()){
valuesForQuery.append( valuesForQuery.append(
getTextForRow( results.nextSolution() ) ) ; getTextForRow( results.nextSolution() ) ) ;
@ -102,7 +101,7 @@ public class ContextNodeFields implements DocumentModifier{
} }
if(log.isDebugEnabled()){ if(log.isDebugEnabled()){
log.debug("query: '" + query + "'"); log.debug("query: '" + subInUriQuery+ "'");
log.debug("text for query: '" + valuesForQuery.toString() + "'"); log.debug("text for query: '" + valuesForQuery.toString() + "'");
} }
allValues.append(valuesForQuery); allValues.append(valuesForQuery);