Strabon

changeset 636:8dc4cd1c8e8a

Changed endpoint script and added -l option to OPTIONS.
author Stella Giannakopoulou <sgian@di.uoa.gr>
date Thu Oct 11 16:24:32 2012 +0300 (2012-10-11)
parents 3a946fc8f0f8
children 0a2d39b80321
files scripts/endpoint
line diff
     1.1 --- a/scripts/endpoint	Thu Oct 11 14:45:22 2012 +0300
     1.2 +++ b/scripts/endpoint	Thu Oct 11 16:24:32 2012 +0300
     1.3 @@ -42,14 +42,13 @@
     1.4  }
     1.5  
     1.6  function help_query() {
     1.7 -	echo "Usage: ${CMD} query ENDPOINT SPARQL_QUERY [RESULT_FORMAT] [-l MAXLIMIT]"
     1.8 +	echo "Usage: ${CMD} query ENDPOINT SPARQL_QUERY [RESULT_FORMAT]"
     1.9  	echo
    1.10  	echo "	ENDPOINT	: the URL of Strabon Endpoint (e.g., http://localhost:8080/StrabonEndpoint/)"
    1.11  	echo "	SPARQL_QUERY	: the SPARQL query to execute or the alias name corresponding to a"
    1.12  	echo "			  predefined query such as:"
    1.13  	echo "				\`size': SELECT (count(*) as ?c) WHERE {?s ?p ?o}"
    1.14  	echo "	RESULT_FORMAT	: the format of the result. Possible values are \`XML' (default), \`KML', \`KMZ', \`GeoJSON', \`HTML', or \`TSV'"
    1.15 -	echo "	MAXLIMIT	: the maximum limit for the query results"
    1.16  }
    1.17  
    1.18  function help_queryfile() {
    1.19 @@ -92,7 +91,8 @@
    1.20  
    1.21  # if set to 1, then only the command to be executed is printed
    1.22  DEBUG=0
    1.23 -
    1.24 +# set default limit
    1.25 +MAXLIMIT=0
    1.26  case "${1}" in
    1.27  	-d)
    1.28  		shift
    1.29 @@ -103,6 +103,11 @@
    1.30  		PREFIXES="$(cat ${PREFIXES_FILE})
    1.31  "
    1.32  		;;
    1.33 +	-l)
    1.34 +		MAXLIMIT="${2}"	
    1.35 +		shift
    1.36 +		shift
    1.37 +		;;
    1.38  esac
    1.39  
    1.40  case "${1}" in
    1.41 @@ -154,43 +159,9 @@
    1.42  
    1.43  		# set default format
    1.44  		FORMAT="XML"
    1.45 -		# set default limit
    1.46 -		MAXLIMIT=0
    1.47  		if test $# -eq 1; then
    1.48  			FORMAT="${1}"
    1.49 -		elif test $# -eq 2; then
    1.50 -			case "${1}" in
    1.51 -				-l)
    1.52 -					MAXLIMIT="${2}"
    1.53 -					;;				
    1.54 -				*)
    1.55 -					help_query
    1.56 -					exit 1
    1.57 -					;;
    1.58 -			esac
    1.59 -		elif test $# -eq 3; then
    1.60 -			case "${1}" in
    1.61 -				-l)
    1.62 -					MAXLIMIT="${2}"
    1.63 -					FORMAT="${3}"
    1.64 -					;;				
    1.65 -				*)
    1.66 -					FORMAT="${1}"
    1.67 -					case "${2}" in
    1.68 -						-l)
    1.69 -							MAXLIMIT="${3}"	
    1.70 -							;;
    1.71 -						*)
    1.72 -							help_query
    1.73 -							exit 1
    1.74 -							;;	
    1.75 -					esac	
    1.76 -					;;
    1.77 -			esac				
    1.78 -		elif  test $# -ge 4; then
    1.79 -			help_query
    1.80 -			exit 1
    1.81 -		fi	
    1.82 +		fi
    1.83  
    1.84  		case "${FORMAT}" in
    1.85  			[Xx][Mm][Ll])
    1.86 @@ -217,11 +188,6 @@
    1.87  				exit 2
    1.88  				;;
    1.89  		esac
    1.90 -		
    1.91 -		if [[ $MAXLIMIT != *[[:digit:]]* ]]; then
    1.92 -			help_query
    1.93 -			exit 1
    1.94 -		fi	
    1.95  
    1.96  		EXEC="curl -H 'Content-Type:application/x-www-form-urlencoded' -H 'Accept:${MIME_TYPE}' --data-urlencode query='${QUERY}' --data maxLimit='${MAXLIMIT}' ${URL}"
    1.97  		;;