NIHVIVO-2762 Fix jsp errors resulting from a jsp variable inserted into a query string in Java code, where it does not get evaluated. Augment the method getActivityTypeQuery() to handle classgroup-based select lists.
This commit is contained in:
parent
1aa136f075
commit
f64db6f406
7 changed files with 23 additions and 20 deletions
|
@ -766,7 +766,7 @@ public class DataPropertyDaoJena extends PropertyDaoJena implements
|
||||||
// filter causes the query to fail. Insert the subjectUri manually instead.
|
// filter causes the query to fail. Insert the subjectUri manually instead.
|
||||||
// QuerySolutionMap initialBindings = new QuerySolutionMap();
|
// QuerySolutionMap initialBindings = new QuerySolutionMap();
|
||||||
// initialBindings.add("subject", ResourceFactory.createResource(subjectUri));
|
// initialBindings.add("subject", ResourceFactory.createResource(subjectUri));
|
||||||
String queryString = subUriForQueryVar(DATA_PROPERTY_QUERY_STRING, "subject", subjectUri);
|
String queryString = QueryUtils.subUriForQueryVar(DATA_PROPERTY_QUERY_STRING, "subject", subjectUri);
|
||||||
|
|
||||||
Query query = null;
|
Query query = null;
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -331,7 +331,7 @@ public class DataPropertyStatementDaoJena extends JenaBaseDao implements DataPro
|
||||||
Map<String, String> bindings = new HashMap<String, String>();
|
Map<String, String> bindings = new HashMap<String, String>();
|
||||||
bindings.put("subject", subjectUri);
|
bindings.put("subject", subjectUri);
|
||||||
bindings.put("property", propertyUri);
|
bindings.put("property", propertyUri);
|
||||||
String queryString = subUrisForQueryVars(DATA_PROPERTY_VALUE_QUERY_STRING, bindings);
|
String queryString = QueryUtils.subUrisForQueryVars(DATA_PROPERTY_VALUE_QUERY_STRING, bindings);
|
||||||
|
|
||||||
// Run the SPARQL query to get the properties
|
// Run the SPARQL query to get the properties
|
||||||
List<Literal> values = new ArrayList<Literal>();
|
List<Literal> values = new ArrayList<Literal>();
|
||||||
|
|
|
@ -1101,21 +1101,5 @@ public class JenaBaseDao extends JenaBaseDaoCon {
|
||||||
return temp;
|
return temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Manually replace query variables with uris when prebinding causes the query to fail, probably
|
|
||||||
* due to a Jena bug.
|
|
||||||
*/
|
|
||||||
protected static String subUrisForQueryVars(String queryString, Map<String, String> varsToUris) {
|
|
||||||
|
|
||||||
for (String var : varsToUris.keySet()) {
|
|
||||||
queryString = subUriForQueryVar(queryString, var, varsToUris.get(var));
|
|
||||||
}
|
|
||||||
return queryString;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Manually replace a query variable with a uri when prebinding causes the query to fail, probably
|
|
||||||
* due to a Jena bug.
|
|
||||||
*/
|
|
||||||
protected static String subUriForQueryVar(String queryString, String varName, String uri) {
|
|
||||||
return queryString.replaceAll("\\?" + varName + "\\b", "<" + uri + ">");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -859,7 +859,7 @@ public class ObjectPropertyDaoJena extends PropertyDaoJena implements ObjectProp
|
||||||
// Due to a Jena bug, prebinding on ?subject combined with the isURI()
|
// Due to a Jena bug, prebinding on ?subject combined with the isURI()
|
||||||
// filter causes the query to fail. Using string concatenation to insert the
|
// filter causes the query to fail. Using string concatenation to insert the
|
||||||
// subject uri instead.
|
// subject uri instead.
|
||||||
String queryString = subUriForQueryVar(OBJECT_PROPERTY_QUERY_STRING, "subject", subjectUri);
|
String queryString = QueryUtils.subUriForQueryVar(OBJECT_PROPERTY_QUERY_STRING, "subject", subjectUri);
|
||||||
|
|
||||||
Query query = null;
|
Query query = null;
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -399,7 +399,7 @@ public class ObjectPropertyStatementDaoJena extends JenaBaseDao implements Objec
|
||||||
* **/
|
* **/
|
||||||
public List<String> getMostSpecificTypesForIndividual(String subjectUri) {
|
public List<String> getMostSpecificTypesForIndividual(String subjectUri) {
|
||||||
|
|
||||||
String queryString = subUriForQueryVar(MOST_SPECIFIC_TYPE_QUERY, "subject", subjectUri);
|
String queryString = QueryUtils.subUriForQueryVar(MOST_SPECIFIC_TYPE_QUERY, "subject", subjectUri);
|
||||||
|
|
||||||
log.debug("Query string for vitro:mostSpecificType : " + queryString);
|
log.debug("Query string for vitro:mostSpecificType : " + queryString);
|
||||||
|
|
||||||
|
|
|
@ -84,4 +84,22 @@ public class QueryUtils {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Manually replace query variables with uris when prebinding causes the query to fail, probably
|
||||||
|
* due to a Jena bug.
|
||||||
|
*/
|
||||||
|
public static String subUrisForQueryVars(String queryString, Map<String, String> varsToUris) {
|
||||||
|
|
||||||
|
for (String var : varsToUris.keySet()) {
|
||||||
|
queryString = subUriForQueryVar(queryString, var, varsToUris.get(var));
|
||||||
|
}
|
||||||
|
return queryString;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Manually replace a query variable with a uri when prebinding causes the query to fail, probably
|
||||||
|
* due to a Jena bug.
|
||||||
|
*/
|
||||||
|
public static String subUriForQueryVar(String queryString, String varName, String uri) {
|
||||||
|
return queryString.replaceAll("\\?" + varName + "\\b", "<" + uri + ">");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -160,6 +160,7 @@ public class SparqlEvaluate {
|
||||||
// }
|
// }
|
||||||
|
|
||||||
public String queryToUri(String querystr){
|
public String queryToUri(String querystr){
|
||||||
|
log.debug("Query string in queryToUri():" + querystr);
|
||||||
String value = null;
|
String value = null;
|
||||||
QueryExecution qe = null;
|
QueryExecution qe = null;
|
||||||
try{
|
try{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue