Strabon

changeset 262:eaef3863cd22

added result format to strabon script
author Babis Nikolaou <charnik@di.uoa.gr>
date Thu Jun 07 00:20:46 2012 +0300 (2012-06-07)
parents a4dadade7e30
children e9ded8878b78
files scripts/strabon
line diff
     1.1 --- a/scripts/strabon	Wed Jun 06 16:49:05 2012 +0300
     1.2 +++ b/scripts/strabon	Thu Jun 07 00:20:46 2012 +0300
     1.3 @@ -96,12 +96,14 @@
     1.4  }
     1.5  
     1.6  function help_query() {
     1.7 -	echo "Usage: ${CMD} query SPARQL_QUERY"
     1.8 +	echo "Usage: ${CMD} query SPARQL_QUERY [RESULT_FORMAT]"
     1.9  	echo
    1.10  	echo "Execute a SPARQL query on Strabon."
    1.11  	echo
    1.12  	echo "	SPARQL_QUERY	: the SPARQL query to execute or an alias name such as the following:"
    1.13  	echo "				size: returns the number of triples"
    1.14 +	echo "  RESULT_FROM	: the format of the result. Possible values are \`???' (default), \`xml'"
    1.15 +	echo "			  \`html', \`kml', \`kmz', or \`geojson'"
    1.16  }
    1.17  
    1.18  function help_update() {
    1.19 @@ -324,11 +326,12 @@
    1.20  	query)
    1.21  		CLASS="QueryOp"
    1.22  		shift
    1.23 -		if ! test $# -eq 1; then
    1.24 +		if ! test $# -ge 1; then
    1.25  			help_query
    1.26  			exit 1
    1.27  		fi
    1.28  		QUERY="${1}"
    1.29 +		shift
    1.30  
    1.31  		# check for predefined queries
    1.32  		case "${QUERY}" in
    1.33 @@ -336,6 +339,21 @@
    1.34  				QUERY="${QUERY_SIZE}"
    1.35  				;;
    1.36  		esac
    1.37 +
    1.38 +		# check for format of result
    1.39 +		if test $# -gt 0; then
    1.40 +			RESULT_FORMAT="${1}"
    1.41 +			shift
    1.42 +			case "${RESULT_FORMAT}" in
    1.43 +				[xX][mM][lL]|[hH][tT][mM][lL]|[kK][mM][lL]|[kK][mM][zZ]|[gG][eE][oO][jJ][sS][oO][nN])
    1.44 +				;;
    1.45 +			*)
    1.46 +				echo "${CMD}: invalid result format \"${RESULT_FORMAT}\""
    1.47 +				echo "${CMD}: valid formats are \`???' (default), \`xml', \`html', \`kml', \`kmz', or \`geojson'"
    1.48 +				exit 2
    1.49 +				;;
    1.50 +			esac
    1.51 +		fi
    1.52  		;;
    1.53  	update)
    1.54  		CLASS="UpdateOp"
    1.55 @@ -409,7 +427,7 @@
    1.56  "
    1.57  	done
    1.58  else
    1.59 -	STRABON_EXEC="(cd ${RUNTIME} && java -cp ./target/\*:. ${PKG}.${DATABASE}.${CLASS} ${HOST} ${PORT} ${DB} ${DBUSER} ${DBPASS} \"${QUERY}\")"
    1.60 +	STRABON_EXEC="(cd ${RUNTIME} && java -cp ./target/\*:. ${PKG}.${DATABASE}.${CLASS} ${HOST} ${PORT} ${DB} ${DBUSER} ${DBPASS} \"${QUERY}\" ${RESULT_FORMAT})"
    1.61  fi
    1.62  
    1.63  # execute command or debug