Strabon
changeset 633:3a946fc8f0f8
#6 Added maxLimit parameter in the endpoint script. Now, the usage of the script is:
${CMD} query ENDPOINT SPARQL_QUERY [RESULT_FORMAT] [-l MAXLIMIT]
When maxLimit = 0, the option is ignored and all the results are returned.
${CMD} query ENDPOINT SPARQL_QUERY [RESULT_FORMAT] [-l MAXLIMIT]
When maxLimit = 0, the option is ignored and all the results are returned.
author | Stella Giannakopoulou <sgian@di.uoa.gr> |
---|---|
date | Thu Oct 11 14:45:22 2012 +0300 (2012-10-11) |
parents | 392c52ed39fe |
children | 95f6f0d699a4 8dc4cd1c8e8a |
files | endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/QueryBean.java scripts/endpoint |
line diff
1.1 --- a/endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/QueryBean.java Thu Oct 11 14:40:47 2012 +0300 1.2 +++ b/endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/QueryBean.java Thu Oct 11 14:45:22 2012 +0300 1.3 @@ -157,6 +157,7 @@ 1.4 1.5 // get the query 1.6 String query = request.getParameter("query"); 1.7 + String maxLimit = request.getParameter("maxLimit"); 1.8 1.9 // check for required parameters 1.10 if (format == null || query == null) { 1.11 @@ -171,6 +172,7 @@ 1.12 1.13 response.setContentType(format.getDefaultMIMEType()); 1.14 try { 1.15 + query = strabonWrapper.addLimit(query, maxLimit); 1.16 strabonWrapper.query(query, format.getName(), out); 1.17 response.setStatus(HttpServletResponse.SC_OK); 1.18
2.1 --- a/scripts/endpoint Thu Oct 11 14:40:47 2012 +0300 2.2 +++ b/scripts/endpoint Thu Oct 11 14:45:22 2012 +0300 2.3 @@ -42,13 +42,14 @@ 2.4 } 2.5 2.6 function help_query() { 2.7 - echo "Usage: ${CMD} query ENDPOINT SPARQL_QUERY [RESULT_FORMAT]" 2.8 + echo "Usage: ${CMD} query ENDPOINT SPARQL_QUERY [RESULT_FORMAT] [-l MAXLIMIT]" 2.9 echo 2.10 echo " ENDPOINT : the URL of Strabon Endpoint (e.g., http://localhost:8080/StrabonEndpoint/)" 2.11 echo " SPARQL_QUERY : the SPARQL query to execute or the alias name corresponding to a" 2.12 echo " predefined query such as:" 2.13 echo " \`size': SELECT (count(*) as ?c) WHERE {?s ?p ?o}" 2.14 echo " RESULT_FORMAT : the format of the result. Possible values are \`XML' (default), \`KML', \`KMZ', \`GeoJSON', \`HTML', or \`TSV'" 2.15 + echo " MAXLIMIT : the maximum limit for the query results" 2.16 } 2.17 2.18 function help_queryfile() { 2.19 @@ -153,9 +154,43 @@ 2.20 2.21 # set default format 2.22 FORMAT="XML" 2.23 + # set default limit 2.24 + MAXLIMIT=0 2.25 if test $# -eq 1; then 2.26 FORMAT="${1}" 2.27 - fi 2.28 + elif test $# -eq 2; then 2.29 + case "${1}" in 2.30 + -l) 2.31 + MAXLIMIT="${2}" 2.32 + ;; 2.33 + *) 2.34 + help_query 2.35 + exit 1 2.36 + ;; 2.37 + esac 2.38 + elif test $# -eq 3; then 2.39 + case "${1}" in 2.40 + -l) 2.41 + MAXLIMIT="${2}" 2.42 + FORMAT="${3}" 2.43 + ;; 2.44 + *) 2.45 + FORMAT="${1}" 2.46 + case "${2}" in 2.47 + -l) 2.48 + MAXLIMIT="${3}" 2.49 + ;; 2.50 + *) 2.51 + help_query 2.52 + exit 1 2.53 + ;; 2.54 + esac 2.55 + ;; 2.56 + esac 2.57 + elif test $# -ge 4; then 2.58 + help_query 2.59 + exit 1 2.60 + fi 2.61 2.62 case "${FORMAT}" in 2.63 [Xx][Mm][Ll]) 2.64 @@ -182,8 +217,13 @@ 2.65 exit 2 2.66 ;; 2.67 esac 2.68 + 2.69 + if [[ $MAXLIMIT != *[[:digit:]]* ]]; then 2.70 + help_query 2.71 + exit 1 2.72 + fi 2.73 2.74 - EXEC="curl -H 'Content-Type:application/x-www-form-urlencoded' -H 'Accept:${MIME_TYPE}' --data-urlencode query='${QUERY}' ${URL}" 2.75 + EXEC="curl -H 'Content-Type:application/x-www-form-urlencoded' -H 'Accept:${MIME_TYPE}' --data-urlencode query='${QUERY}' --data maxLimit='${MAXLIMIT}' ${URL}" 2.76 ;; 2.77 queryfile) 2.78 shift