Strabon

changeset 224:fd43d9f83de7

progress on strabon script
author Babis Nikolaou <charnik@di.uoa.gr>
date Fri Jun 01 15:33:42 2012 +0300 (2012-06-01)
parents 1e9ab0c41d50
children bd824b11051a
files scripts/strabon
line diff
     1.1 --- a/scripts/strabon	Fri Jun 01 14:08:48 2012 +0300
     1.2 +++ b/scripts/strabon	Fri Jun 01 15:33:42 2012 +0300
     1.3 @@ -48,18 +48,18 @@
     1.4  DBPASS="charnik"
     1.5  
     1.6  # the query to run
     1.7 -QUERY="select (count(*) as ?c) where {?s ?p ?o}"
     1.8 +QUERY=
     1.9 +
    1.10 +# predefined queries
    1.11 +QUERY_SIZE="SELECT (COUNT(*) as ?C) WHERE {?s ?p ?o}"
    1.12 +QUERY_DELETEALL="DELETE {?s ?p ?o} WHERE {?s ?p ?o}"
    1.13  
    1.14  # debug option for log4j configuration:
    1.15  #-Dlog4j.debug
    1.16  #-Dlog4j.configuration=\"${RUNTIME}/log4j.properties\"
    1.17  
    1.18 -CMD="(cd ${RUNTIME} && java -cp ./target/\*:. ${PKG}.${DATABASE}.${CLASS} ${HOST} ${PORT} ${DB} ${DBUSER} ${DBPASS} \"${QUERY}\")"
    1.19 -
    1.20 -eval $CMD
    1.21 -exit 1
    1.22 -
    1.23 -case "${1}" in
    1.24 +DEBUG=0
    1.25 +#case "${1}" in
    1.26  #	-d)
    1.27  #		shift
    1.28  #		DEBUG=1
    1.29 @@ -90,66 +90,48 @@
    1.30  		exit 0
    1.31  		;;
    1.32  	query)
    1.33 +		CLASS="QueryOp"
    1.34  		shift
    1.35 -		if ! test $# -eq 2; then
    1.36 -			help_query
    1.37 +		if ! test $# -eq 1; then
    1.38 +			#help_query
    1.39 +			help
    1.40  			exit 1
    1.41  		fi
    1.42 -		URL="${1}/Query"
    1.43 -		QUERY="${2}"
    1.44 +		QUERY="${1}"
    1.45  
    1.46 -		# predefined queries
    1.47 +		# check for predefined queries
    1.48  		case "${QUERY}" in
    1.49  			size)
    1.50 -				QUERY="SELECT (count(*) as ?c) WHERE {?s ?p ?o}"
    1.51 +				QUERY="${QUERY_SIZE}"
    1.52  				;;
    1.53  		esac
    1.54 -
    1.55 -		# TODO: make it an argument
    1.56 -		FORMAT="XML"
    1.57 -
    1.58 -		CMD="curl ${CURL_OPTS} -d format='${FORMAT}' --data-urlencode SPARQLQuery='${QUERY}' ${URL}"
    1.59  		;;
    1.60  	update)
    1.61 +		CLASS="UpdateOp"
    1.62  		shift
    1.63 -		if ! test $# -eq 2; then
    1.64 -			help_update
    1.65 +		if ! test $# -eq 1; then
    1.66 +			#help_query
    1.67 +			help
    1.68  			exit 1
    1.69  		fi
    1.70 -		URL="${1}/Update"
    1.71 -		QUERY="${2}"
    1.72 -		
    1.73 -		# predefined queries
    1.74 +		QUERY="${1}"
    1.75 +
    1.76 +		# check for predefined queries
    1.77  		case "${QUERY}" in
    1.78  			clear)
    1.79 -				QUERY="DELETE {?s ?p ?o} WHERE {?s ?p ?o}"
    1.80 +				QUERY="${QUERY_DELETEALL}"
    1.81  				;;
    1.82  		esac
    1.83 -
    1.84 -		CMD="curl ${CURL_OPTS} --data-urlencode SPARQLQuery='${QUERY}' ${URL}"
    1.85  		;;
    1.86  	store)
    1.87 +		CLASS="StoreOp"
    1.88  		shift
    1.89 -		if ! test $# -eq 4; then
    1.90 -			help_store
    1.91 +		if ! test $# -eq 1; then
    1.92 +			#help_query
    1.93 +			help
    1.94  			exit 1
    1.95  		fi
    1.96 -		URL="${1}/Store"
    1.97 -		FORMAT="${2}"
    1.98 -		case "${3}" in
    1.99 -			-t)
   1.100 -				TRIPLES="${4}"
   1.101 -				CMD="curl ${CURL_OPTS} -d format='${FORMAT}' --data-urlencode data='${TRIPLES}' ${URL}"
   1.102 -				;;
   1.103 -			-u)
   1.104 -				URL_TRIPLES="${4}"
   1.105 -				CMD="curl ${CURL_OPTS} -d format='${FORMAT}' --data-urlencode url='${URL_TRIPLES}' -d fromurl='' ${URL}"
   1.106 -				;;
   1.107 -			 *)
   1.108 -				help_store
   1.109 -				exit 1
   1.110 -				;;
   1.111 -		esac
   1.112 +		QUERY="${1}"
   1.113  		;;
   1.114  	*) 
   1.115  		help
   1.116 @@ -159,11 +141,13 @@
   1.117  		;;
   1.118  esac
   1.119  
   1.120 +CMD="(cd ${RUNTIME} && java -cp ./target/\*:. ${PKG}.${DATABASE}.${CLASS} ${HOST} ${PORT} ${DB} ${DBUSER} ${DBPASS} \"${QUERY}\")"
   1.121 +
   1.122  # execute or debug
   1.123 -if test $DEBUG -eq 1; then
   1.124 +if test ${DEBUG} -eq 1; then
   1.125  	echo "`basename ${0}`: Debug is ON"
   1.126  	echo "`basename ${0}`: Printing command for execution"	
   1.127 -	echo "	$CMD"
   1.128 +	echo "	${CMD}"
   1.129  else
   1.130  	eval ${CMD}
   1.131  fi