NIHVIVO-707 Set hidden rank field value based on existing webpage ranks
This commit is contained in:
parent
84758e4c3a
commit
bebc08fb8b
7 changed files with 24 additions and 306 deletions
|
@ -27,6 +27,7 @@ import com.hp.hpl.jena.ontology.SomeValuesFromRestriction;
|
|||
import com.hp.hpl.jena.query.Query;
|
||||
import com.hp.hpl.jena.query.QueryFactory;
|
||||
import com.hp.hpl.jena.query.QuerySolution;
|
||||
import com.hp.hpl.jena.query.ResultSet;
|
||||
import com.hp.hpl.jena.rdf.model.Property;
|
||||
import com.hp.hpl.jena.rdf.model.RDFNode;
|
||||
import com.hp.hpl.jena.rdf.model.Resource;
|
||||
|
@ -783,7 +784,7 @@ public class DataPropertyDaoJena extends PropertyDaoJena implements
|
|||
}
|
||||
log.debug("Data property query string:\n" + query);
|
||||
|
||||
Iterator<QuerySolution> results = getPropertyQueryResults(query);
|
||||
ResultSet results = getPropertyQueryResults(query);
|
||||
List<DataProperty> properties = new ArrayList<DataProperty>();
|
||||
while (results.hasNext()) {
|
||||
QuerySolution sol = results.next();
|
||||
|
|
|
@ -338,8 +338,9 @@ public class DataPropertyStatementDaoJena extends JenaBaseDao implements DataPro
|
|||
DatasetWrapper w = dwf.getDatasetWrapper();
|
||||
Dataset dataset = w.getDataset();
|
||||
dataset.getLock().enterCriticalSection(Lock.READ);
|
||||
QueryExecution qexec = null;
|
||||
try {
|
||||
QueryExecution qexec = QueryExecutionFactory.create(
|
||||
qexec = QueryExecutionFactory.create(
|
||||
queryString, dataset);
|
||||
ResultSet results = qexec.execSelect();
|
||||
|
||||
|
@ -351,6 +352,9 @@ public class DataPropertyStatementDaoJena extends JenaBaseDao implements DataPro
|
|||
} finally {
|
||||
dataset.getLock().leaveCriticalSection();
|
||||
w.close();
|
||||
if (qexec != null) {
|
||||
qexec.close();
|
||||
}
|
||||
}
|
||||
return values;
|
||||
}
|
||||
|
|
|
@ -871,7 +871,7 @@ public class ObjectPropertyDaoJena extends PropertyDaoJena implements ObjectProp
|
|||
}
|
||||
log.debug("Object property query:\n" + query);
|
||||
|
||||
Iterator<QuerySolution> results = getPropertyQueryResults(query);
|
||||
ResultSet results = getPropertyQueryResults(query);
|
||||
List<ObjectProperty> properties = new ArrayList<ObjectProperty>();
|
||||
while (results.hasNext()) {
|
||||
QuerySolution soln = results.next();
|
||||
|
@ -916,7 +916,8 @@ public class ObjectPropertyDaoJena extends PropertyDaoJena implements ObjectProp
|
|||
ObjectProperty prop = getObjectPropertyByURI(soln.getResource("property").getURI());
|
||||
String filename = soln.getLiteral("filename").getLexicalForm();
|
||||
customListViewConfigFileMap.put(prop, filename);
|
||||
}
|
||||
}
|
||||
qexec.close();
|
||||
}
|
||||
return customListViewConfigFileMap.get(op);
|
||||
}
|
||||
|
|
|
@ -302,9 +302,10 @@ public class ObjectPropertyStatementDaoJena extends JenaBaseDao implements Objec
|
|||
DatasetWrapper w = dwf.getDatasetWrapper();
|
||||
Dataset dataset = w.getDataset();
|
||||
dataset.getLock().enterCriticalSection(Lock.READ);
|
||||
QueryExecution qexec = null;
|
||||
try {
|
||||
|
||||
QueryExecution qexec = (constructedModel == null)
|
||||
qexec = (constructedModel == null)
|
||||
? QueryExecutionFactory.create(
|
||||
query, dataset, initialBindings)
|
||||
: QueryExecutionFactory.create(
|
||||
|
@ -323,6 +324,9 @@ public class ObjectPropertyStatementDaoJena extends JenaBaseDao implements Objec
|
|||
} finally {
|
||||
dataset.getLock().leaveCriticalSection();
|
||||
w.close();
|
||||
if (qexec != null) {
|
||||
qexec.close();
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
|
|
@ -20,15 +20,13 @@ import com.hp.hpl.jena.query.Dataset;
|
|||
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.QuerySolution;
|
||||
import com.hp.hpl.jena.query.QuerySolutionMap;
|
||||
import com.hp.hpl.jena.query.ResultSet;
|
||||
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.rdf.model.Statement;
|
||||
import com.hp.hpl.jena.rdf.model.StmtIterator;
|
||||
import com.hp.hpl.jena.shared.Lock;
|
||||
import com.hp.hpl.jena.sparql.resultset.ResultSetMem;
|
||||
import com.hp.hpl.jena.vocabulary.OWL;
|
||||
import com.hp.hpl.jena.vocabulary.RDFS;
|
||||
|
||||
|
@ -404,7 +402,7 @@ public class PropertyDaoJena extends JenaBaseDao implements PropertyDao {
|
|||
return classSet;
|
||||
}
|
||||
|
||||
protected Iterator<QuerySolution> getPropertyQueryResults(Query query) {
|
||||
protected ResultSet getPropertyQueryResults(Query query) {
|
||||
log.debug("SPARQL query:\n" + query.toString());
|
||||
|
||||
// RY Removing prebinding due to Jena bug: when isLiteral(?object) or
|
||||
|
@ -417,17 +415,12 @@ public class PropertyDaoJena extends JenaBaseDao implements PropertyDao {
|
|||
DatasetWrapper w = dwf.getDatasetWrapper();
|
||||
Dataset dataset = w.getDataset();
|
||||
dataset.getLock().enterCriticalSection(Lock.READ);
|
||||
ResultSet rs = null;
|
||||
try {
|
||||
QueryExecution qexec = QueryExecutionFactory.create(
|
||||
query, dataset); //, subjectBinding);
|
||||
try {
|
||||
ResultSet rs = qexec.execSelect();
|
||||
// consume iterator before wrapper w is closed in finally block
|
||||
List<QuerySolution> results = new ArrayList<QuerySolution>();
|
||||
while (rs.hasNext()) {
|
||||
results.add(rs.next());
|
||||
}
|
||||
return results.iterator();
|
||||
rs = new ResultSetMem(qexec.execSelect());
|
||||
} finally {
|
||||
qexec.close();
|
||||
}
|
||||
|
@ -435,6 +428,7 @@ public class PropertyDaoJena extends JenaBaseDao implements PropertyDao {
|
|||
dataset.getLock().leaveCriticalSection();
|
||||
w.close();
|
||||
}
|
||||
return rs;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ import com.hp.hpl.jena.rdf.model.Literal;
|
|||
import com.hp.hpl.jena.rdf.model.RDFNode;
|
||||
import com.hp.hpl.jena.rdf.model.Resource;
|
||||
import com.hp.hpl.jena.shared.Lock;
|
||||
import com.hp.hpl.jena.sparql.resultset.ResultSetMem;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||
|
||||
|
@ -30,6 +31,8 @@ public class QueryUtils {
|
|||
|
||||
private static final Log log = LogFactory.getLog(QueryUtils.class);
|
||||
|
||||
private QueryUtils() { }
|
||||
|
||||
protected static Map<String,Object> querySolutionToObjectValueMap( QuerySolution soln){
|
||||
Map<String,Object> map = new HashMap<String,Object>();
|
||||
Iterator<String> varNames = soln.varNames();
|
||||
|
@ -110,12 +113,11 @@ public class QueryUtils {
|
|||
|
||||
Dataset dataset = vreq.getDataset();
|
||||
dataset.getLock().enterCriticalSection(Lock.READ);
|
||||
queryStr = " SELECT ?x WHERE { ?x ?p ?y } LIMIT 10";
|
||||
QueryExecution qexec = null;
|
||||
ResultSet results = null;
|
||||
try {
|
||||
qexec = QueryExecutionFactory.create(queryStr, dataset);
|
||||
results = qexec.execSelect();
|
||||
results = new ResultSetMem(qexec.execSelect());
|
||||
} catch (Exception e) {
|
||||
log.error(e, e);
|
||||
} finally {
|
||||
|
@ -124,32 +126,8 @@ queryStr = " SELECT ?x WHERE { ?x ?p ?y } LIMIT 10";
|
|||
qexec.close();
|
||||
}
|
||||
}
|
||||
try {
|
||||
/* DEBUGGING */
|
||||
int maxRank = 0;
|
||||
if (results.hasNext()) { // there is at most one result
|
||||
log.debug("found a rank");
|
||||
QuerySolution soln = results.next();
|
||||
RDFNode node = soln.get("rank");
|
||||
if (node != null && node.isLiteral()) {
|
||||
log.debug("node value =" + node.asLiteral().getLexicalForm());
|
||||
try {
|
||||
int rank = node.asLiteral().getInt();
|
||||
if (rank > maxRank) {
|
||||
log.debug("setting maxRank to " + rank);
|
||||
maxRank = rank;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("Error getting int value for rank: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(e, e);
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue