From 6b6bd1194a31a065f655a82eace81a08dd429da1 Mon Sep 17 00:00:00 2001 From: ass92 Date: Fri, 28 Jan 2011 18:08:19 +0000 Subject: [PATCH] NIHVIVO-1926 code change in getSearchBoost method to retrieve float value. --- .../vitro/webapp/dao/jena/IndividualSDB.java | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/IndividualSDB.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/IndividualSDB.java index c3ebc1026..e474a622f 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/IndividualSDB.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/IndividualSDB.java @@ -669,17 +669,29 @@ public class IndividualSDB extends IndividualImpl implements Individual { String getPropertyValue = "SELECT ?value \n" + "WHERE { GRAPH ?g { \n" + - "<" +individualURI+ "> <" +webappDaoFactory.getJenaBaseDao().SEARCH_BOOST_ANNOT+ "> ?value} \n" + + "<" +individualURI+ "> <" +webappDaoFactory.getJenaBaseDao().SEARCH_BOOST_ANNOT+ "> ?value }\n" + WebappDaoFactorySDB.getFilterBlock(graphVars, datasetMode) + "\n" + "}"; + DatasetWrapper w = getDatasetWrapper(); Dataset dataset = w.getDataset(); dataset.getLock().enterCriticalSection(Lock.READ); try{ - searchBoost = ((Literal)QueryExecutionFactory.create( + ResultSet rs = QueryExecutionFactory.create( QueryFactory.create(getPropertyValue), - dataset).execSelect()).getFloat(); - return searchBoost; + dataset).execSelect(); + + if(rs.hasNext()){ + QuerySolution qs = rs.nextSolution(); + if(qs.get("value") !=null){ + Literal value = qs.get("value").asLiteral(); + searchBoost = Float.parseFloat(value.getLexicalForm()); + return searchBoost; + } + } + else{ + return null; + } } catch (Exception e){ log.error(e,e); return null; @@ -688,6 +700,7 @@ public class IndividualSDB extends IndividualImpl implements Individual { w.close(); } } + return null; } @Override