NIHVIVO-707 Work on core:webpage custom form; committing test version for debugging
This commit is contained in:
parent
43c03236d2
commit
91409c631c
4 changed files with 53 additions and 7 deletions
|
@ -150,7 +150,6 @@ public class SparqlQueryServlet extends BaseEditController {
|
||||||
}
|
}
|
||||||
|
|
||||||
String queryParam = vreq.getParameter("query");
|
String queryParam = vreq.getParameter("query");
|
||||||
boolean graphPresent = false;
|
|
||||||
String[] tokens = queryParam.split("\\s");
|
String[] tokens = queryParam.split("\\s");
|
||||||
for(int i = 0; i < tokens.length; i++){
|
for(int i = 0; i < tokens.length; i++){
|
||||||
if("graph".equalsIgnoreCase(tokens[i])){
|
if("graph".equalsIgnoreCase(tokens[i])){
|
||||||
|
|
|
@ -36,8 +36,6 @@ public class VitroRequest extends HttpServletRequestWrapper {
|
||||||
private Map<String,String[]> convertedParameterMap;
|
private Map<String,String[]> convertedParameterMap;
|
||||||
|
|
||||||
private HttpServletRequest _req;
|
private HttpServletRequest _req;
|
||||||
|
|
||||||
private boolean isSinglePortal;
|
|
||||||
|
|
||||||
public VitroRequest(HttpServletRequest _req) {
|
public VitroRequest(HttpServletRequest _req) {
|
||||||
super(_req);
|
super(_req);
|
||||||
|
|
|
@ -303,8 +303,7 @@ public class ObjectPropertyStatementDaoJena extends JenaBaseDao implements Objec
|
||||||
Dataset dataset = w.getDataset();
|
Dataset dataset = w.getDataset();
|
||||||
dataset.getLock().enterCriticalSection(Lock.READ);
|
dataset.getLock().enterCriticalSection(Lock.READ);
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
|
||||||
QueryExecution qexec = (constructedModel == null)
|
QueryExecution qexec = (constructedModel == null)
|
||||||
? QueryExecutionFactory.create(
|
? QueryExecutionFactory.create(
|
||||||
query, dataset, initialBindings)
|
query, dataset, initialBindings)
|
||||||
|
|
|
@ -2,21 +2,24 @@
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.dao.jena;
|
package edu.cornell.mannlib.vitro.webapp.dao.jena;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
|
import com.hp.hpl.jena.query.Dataset;
|
||||||
import com.hp.hpl.jena.query.QueryExecution;
|
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.QuerySolution;
|
||||||
import com.hp.hpl.jena.query.ResultSet;
|
import com.hp.hpl.jena.query.ResultSet;
|
||||||
import com.hp.hpl.jena.rdf.model.Literal;
|
import com.hp.hpl.jena.rdf.model.Literal;
|
||||||
import com.hp.hpl.jena.rdf.model.RDFNode;
|
import com.hp.hpl.jena.rdf.model.RDFNode;
|
||||||
import com.hp.hpl.jena.rdf.model.Resource;
|
import com.hp.hpl.jena.rdf.model.Resource;
|
||||||
|
import com.hp.hpl.jena.shared.Lock;
|
||||||
|
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utilities for executing queries and working with query results.
|
* Utilities for executing queries and working with query results.
|
||||||
|
@ -102,4 +105,51 @@ public class QueryUtils {
|
||||||
public static String subUriForQueryVar(String queryString, String varName, String uri) {
|
public static String subUriForQueryVar(String queryString, String varName, String uri) {
|
||||||
return queryString.replaceAll("\\?" + varName + "\\b", "<" + uri + ">");
|
return queryString.replaceAll("\\?" + varName + "\\b", "<" + uri + ">");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static ResultSet getQueryResults(String queryStr, VitroRequest vreq) {
|
||||||
|
|
||||||
|
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();
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e, e);
|
||||||
|
} finally {
|
||||||
|
dataset.getLock().leaveCriticalSection();
|
||||||
|
if (qexec != null) {
|
||||||
|
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