Strabon

changeset 1071:93f5d7b2d3cb

Endpoint script also supports named graphs and inference.
author Panayiotis Smeros <psmeros@di.uoa.gr>
date Tue Apr 23 21:57:12 2013 +0300 (2013-04-23)
parents eec1a8547bc2
children a801af8a6edd
files endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/StoreBean.java scripts/endpoint
line diff
     1.1 --- a/endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/StoreBean.java	Tue Apr 23 20:12:03 2013 +0300
     1.2 +++ b/endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/StoreBean.java	Tue Apr 23 21:57:12 2013 +0300
     1.3 @@ -177,7 +177,13 @@
     1.4      private void processRequest(HttpServletRequest request, HttpServletResponse response) throws IOException {
     1.5  		// check whether we read from INPUT or URL
     1.6  		boolean input = (request.getParameter(Common.SUBMIT_URL) != null) ? false:true;
     1.7 -		
     1.8 +
     1.9 +      	// graph
    1.10 +    	String graph = (request.getParameter(Common.PARAM_GRAPH) != null) ? request.getParameter(Common.PARAM_GRAPH):null;
    1.11 +    	    	
    1.12 +      	// inference
    1.13 +    	Boolean inference = (request.getParameter(Common.PARAM_INFERENCE) != null) ? Boolean.valueOf(request.getParameter(Common.PARAM_INFERENCE)):false;
    1.14 +
    1.15      	// RDF data to store
    1.16      	String data = getData(request);
    1.17      	
    1.18 @@ -197,9 +203,8 @@
    1.19  		// store data
    1.20  		try {
    1.21  			
    1.22 -			//TODO!!!!!!!!!! remove comment
    1.23 -			//strabon.store(data, format, !input);
    1.24 -			
    1.25 +			strabon.store(data, graph, format.getName(), inference, !input);
    1.26 +
    1.27  			// store was successful, return the respective message
    1.28  			response.sendError(HttpServletResponse.SC_OK);
    1.29  		} catch (Exception e) {
     2.1 --- a/scripts/endpoint	Tue Apr 23 20:12:03 2013 +0300
     2.2 +++ b/scripts/endpoint	Tue Apr 23 21:57:12 2013 +0300
     2.3 @@ -15,6 +15,7 @@
     2.4  # as well as storing RDF triples on a Strabon Endpoint.
     2.5  #
     2.6  # Author: Charalampos (Babis) Nikolaou <charnik@di.uoa.gr>
     2.7 +# Author: Panayiotis Smeros <psmeros@di.uoa.gr>
     2.8  #
     2.9  
    2.10  # absolute directory name of this command
    2.11 @@ -70,12 +71,15 @@
    2.12  }
    2.13  
    2.14  function help_store() {
    2.15 -	echo "Usage: ${CMD} store ENDPOINT FORMAT -t TRIPLES|-u TRIPLES_URL"
    2.16 +	echo "Usage: ${CMD} store ENDPOINT FORMAT [-g NAMED_GRAPH] [--inference] -t TRIPLES|-u TRIPLES_URL"
    2.17  	echo
    2.18  	echo "	ENDPOINT    : the URL of Strabon Endpoint (e.g., http://localhost:8080/StrabonEndpoint/)"
    2.19  	echo "	FORMAT	    : the RDF format of the input (one of RDF/XML, N-Triples, Turtle, N3, TriX, TriG, or BinaryRDF)"
    2.20  	echo "	TRIPLES	    : the RDF triples to store"
    2.21  	echo "	TRIPLES_URL : the URL containing the RDF triples to store"
    2.22 +	echo "  NAMED_GRAPH : the URI of the named graph into which the RDF files shall be stored"
    2.23 +	echo "	              (defaults to the default graph)."
    2.24 +	echo "	--inference : enables inference."
    2.25  }
    2.26  
    2.27  function help_describe() {
    2.28 @@ -264,12 +268,14 @@
    2.29  		;;
    2.30  	store)
    2.31  		shift
    2.32 -		if ! test $# -eq 4; then
    2.33 +		if ! test $# -ge 4; then
    2.34  			help_store
    2.35  			exit 1
    2.36  		fi
    2.37  		URL="${1}/Store"
    2.38 -		FORMAT="${2}"
    2.39 +		shift
    2.40 +		FORMAT="${1}"
    2.41 +		shift
    2.42  		MIME_TYPE=
    2.43  		case "${FORMAT}" in
    2.44  			N-Triples)
    2.45 @@ -299,16 +305,52 @@
    2.46  				exit 2
    2.47  				;;
    2.48  		esac
    2.49 +				
    2.50 +		GRAPH=
    2.51 +		case "${1}" in
    2.52 +			 -g)
    2.53 +				shift
    2.54 +				if [ "${1}" == "--inference" ]; then
    2.55 +					help_store
    2.56 +					exit 1
    2.57 +				fi
    2.58 +				if ! test $# -ge 3; then
    2.59 +					help_store
    2.60 +					exit 1
    2.61 +				fi
    2.62 +				GRAPH="-d graph=${1}"
    2.63 +				shift
    2.64 +		esac
    2.65  
    2.66 -		case "${3}" in
    2.67 +		INFERENCE=
    2.68 +		case "${1}" in
    2.69 +			 --inference)
    2.70 +				shift
    2.71 +				if ! test $# -ge 2; then
    2.72 +					help_store
    2.73 +					exit 1
    2.74 +				fi
    2.75 +				INFERENCE="-d inference=true"
    2.76 +		esac
    2.77 +		
    2.78 +		case "${1}" in
    2.79  			-t)
    2.80 -				TRIPLES="${4}"
    2.81 -				EXEC="curl -u endpoint:3ndpo1nt -w '\nHTTP_CODE=%{http_code}\n' -H 'Content-Type:application/x-www-form-urlencoded' -H 'Accept:${MIME_TYPE}' --data-urlencode data='${TRIPLES}' ${URL}"
    2.82 +				shift
    2.83 +				if ! test $# -eq 1; then
    2.84 +					help_store
    2.85 +					exit 1
    2.86 +				fi
    2.87 +				TRIPLES="${1}"
    2.88 +				EXEC="curl -u endpoint:3ndpo1nt -w '\nHTTP_CODE=%{http_code}\n' -H 'Content-Type:application/x-www-form-urlencoded' -H 'Accept:${MIME_TYPE}' --data-urlencode data='${TRIPLES}' ${GRAPH} ${INFERENCE} ${URL}"
    2.89  				;;
    2.90  			-u)
    2.91 -
    2.92 -				URL_TRIPLES="${4}"
    2.93 -				EXEC="curl -u endpoint:3ndpo1nt -w '\nHTTP_CODE=%{http_code}\n' -H 'Content-Type:application/x-www-form-urlencoded' -H 'Accept:${MIME_TYPE}' --data-urlencode url='${URL_TRIPLES}' -d fromurl='' ${URL}"
    2.94 +				shift
    2.95 +				if ! test $# -eq 1; then
    2.96 +					help_store
    2.97 +					exit 1
    2.98 +				fi
    2.99 +				URL_TRIPLES="${1}"
   2.100 +				EXEC="curl -u endpoint:3ndpo1nt -w '\nHTTP_CODE=%{http_code}\n' -H 'Content-Type:application/x-www-form-urlencoded' -H 'Accept:${MIME_TYPE}' --data-urlencode url='${URL_TRIPLES}' -d fromurl='' ${GRAPH} ${INFERENCE} ${URL}"
   2.101  				;;
   2.102  			 *)
   2.103  				help_store