Strabon

changeset 1464:cbef557769b4

Related to bug #58; Debianized strabon runtime component. See more
at ChangeLog.
author Giannis Vlachopoulos <johnvl@di.uoa.gr>
date Fri Jan 23 16:22:50 2015 +0200 (2015-01-23)
parents c56f16b4fb1a
children bc81967ce8ce
files ChangeLog runtime/pom.xml runtime/src/deb/control/control runtime/strabon-cmd scripts/strabon-cmd
line diff
     1.1 --- a/ChangeLog	Thu Jan 15 14:36:12 2015 +0200
     1.2 +++ b/ChangeLog	Fri Jan 23 16:22:50 2015 +0200
     1.3 @@ -1,3 +1,8 @@
     1.4 +	* Related to bug #58, but it generally enhances Strabon; The runtime
     1.5 +	  component has also been debianized. Dependencies are added to
     1.6 +	  /usr/share/jdeb/lib/strabon-runtime. ClassPath and strabon script
     1.7 +	  have also been updated accordingly (strabon-cmd)
     1.8 +
     1.9  	* Bug #58: Maven creates the debian package conditionally. Use
    1.10  	  -Ddebian=true in the mvn package command. 
    1.11  
     2.1 --- a/runtime/pom.xml	Thu Jan 15 14:36:12 2015 +0200
     2.2 +++ b/runtime/pom.xml	Fri Jan 23 16:22:50 2015 +0200
     2.3 @@ -430,6 +430,63 @@
     2.4  			</plugin>
     2.5  		</plugins>
     2.6  	</build>
     2.7 +
     2.8 +<profiles>
     2.9 +		<profile>
    2.10 +			<id>create-debian</id>
    2.11 +			<activation>
    2.12 +				<activeByDefault>false</activeByDefault>
    2.13 +				<property>
    2.14 +					<name>debian</name>
    2.15 +					<value>true</value>
    2.16 +				</property>
    2.17 +			</activation>
    2.18 +				<build>
    2.19 +					<plugins>
    2.20 +						<plugin>
    2.21 +                                <artifactId>jdeb</artifactId>
    2.22 +                                <groupId>org.vafer</groupId>
    2.23 +                                <version>1.3</version>
    2.24 +                                <executions>
    2.25 +                                        <execution>
    2.26 +                                                <phase>package</phase>
    2.27 +                                                <goals>
    2.28 +                                                        <goal>jdeb</goal>
    2.29 +                                                </goals>
    2.30 +                                        <configuration>
    2.31 +						<skipPOMs>false</skipPOMs>
    2.32 +                                                <dataSet>
    2.33 +                                                        <data>
    2.34 +                                                                <src>${project.build.directory}</src>
    2.35 +                                                                <type>directory</type>
    2.36 +								<includes>**/</includes>
    2.37 +                                                                <mapper>
    2.38 +                                                                        <type>perm</type>
    2.39 +                                                                        <prefix>/usr/share/jdeb/lib/strabon-runtime</prefix>
    2.40 +                                                                </mapper>
    2.41 +                                                        </data>
    2.42 +                                                        <data>
    2.43 +                                                                <src>${basedir}/strabon-cmd</src>
    2.44 +                                                                <type>file</type>
    2.45 +                                                                <mapper>
    2.46 +                                                                        <type>perm</type>
    2.47 +                                                                        <prefix>/usr/local/bin</prefix>
    2.48 +                                                                        <user>root</user>
    2.49 +                                                                        <group>root</group>
    2.50 +                                                                        <filemode>755</filemode>
    2.51 +                                                                </mapper>
    2.52 +                                                        </data>
    2.53 +                                                </dataSet>
    2.54 +                                        </configuration>
    2.55 +                                </execution>
    2.56 +                        </executions>
    2.57 +                        </plugin>
    2.58 +
    2.59 +					</plugins>
    2.60 +				</build>
    2.61 +
    2.62 +		</profile>
    2.63 +	</profiles>
    2.64  </project>
    2.65  
    2.66  
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/runtime/src/deb/control/control	Fri Jan 23 16:22:50 2015 +0200
     3.3 @@ -0,0 +1,9 @@
     3.4 +Package: Strabon
     3.5 +Version: 3.2.11
     3.6 +Section: strabon-cmd
     3.7 +Priority: optional
     3.8 +Architecture: all
     3.9 +Maintainer: Manolis Karpathiotakis <manos.karpathiotakis@epfl.ch>, Kostis Kyzirakos <Kostis.Kyzirakos@cwi.nl>, Charalampos Nikolaou <charnik@di.uoa.gr>, Konstantina Bereta <konstantina.bereta@di.uoa.gr>, Georgios Garbis <ggarbis@di.uoa.gr>,  Dimitrios Bilidas <dbilidas@di.uoa.gr>, Stella Giannakopoulou <sgian@di.uoa.gr>, Panayiotis Smeros <psmeros@di.uoa.gr>, Kalliroi Dogani <kallirroi@di.uoa.gr>, Maria Karpathiotaki <mkarpat@di.uoa.gr>, Ioannis Vlachopoulos <johnvl@di.uoa.gr>, Dimitrianos Savva <dimis@di.uoa.gr>, Georgios Stamoulis <gstam@di.uoa.gr>, Kanela Kaligosi <kalkan@di.uoa.gr>
    3.10 +Description: Strabon Command Line Utility
    3.11 +Depends: openjdk-7-jre | oracle-java7-installer, postgresql (>= 9.1) | postgresql-9.1
    3.12 +Distribution: Mozilla v2.0 Public Liscence
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/runtime/strabon-cmd	Fri Jan 23 16:22:50 2015 +0200
     4.3 @@ -0,0 +1,627 @@
     4.4 +#!/bin/bash
     4.5 +
     4.6 +#
     4.7 +# This Source Code Form is subject to the terms of the Mozilla Public
     4.8 +# License, v. 2.0. If a copy of the MPL was not distributed with this
     4.9 +# file, You can obtain one at http://mozilla.org/MPL/2.0/.
    4.10 +#
    4.11 +# Copyright (C) 2010, 2011, 2012, Pyravlos Team
    4.12 +#
    4.13 +# http://www.strabon.di.uoa.gr/
    4.14 +#
    4.15 +
    4.16 +#
    4.17 +# Script for running the main classes of Strabon. The main classes of Strabon comprises
    4.18 +# QueryOp, , UpdateOp, StoreOp, and  DescribeOp.
    4.19 +#
    4.20 +# Author: Charalampos (Babis) Nikolaou <charnik@di.uoa.gr>
    4.21 +#
    4.22 +
    4.23 +# command name
    4.24 +CMD="$(basename ${0})"
    4.25 +
    4.26 +# absolute directory name of this command
    4.27 +LOC="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
    4.28 +
    4.29 +RUNTIME="${LOC}/../runtime"
    4.30 +
    4.31 +# runtime package
    4.32 +PKG="eu.earthobservatory.runtime"
    4.33 +
    4.34 +# the underlying database to use (one of `postgis' or `monetdb')
    4.35 +DATABASE="postgis"
    4.36 +
    4.37 +# the main class to run
    4.38 +CLASS=
    4.39 +
    4.40 +# the hostname at which the database runs
    4.41 +HOST="localhost"
    4.42 +
    4.43 +# the port at which the database listens
    4.44 +PORT=
    4.45 +
    4.46 +# the database name to connect to
    4.47 +DB="strabon"
    4.48 +
    4.49 +# the username for the database connection
    4.50 +DBUSER=
    4.51 +
    4.52 +# the password for the database connection
    4.53 +DBPASS=
    4.54 +
    4.55 +# the query to run
    4.56 +QUERY=
    4.57 +
    4.58 +# the RDF format of the files to store (defaults to ntriples)
    4.59 +FORMAT="ntriples"
    4.60 +
    4.61 +# true to force deletion of locked table, false otherwise
    4.62 +FORCE_DELETE="false"
    4.63 +
    4.64 +# the URI of the named graph into which the RDF files shall be stored
    4.65 +NAMED_GRAPH=
    4.66 +
    4.67 +# true when inference is enabled
    4.68 +INFERENCE=
    4.69 +
    4.70 +# predefined queries
    4.71 +QUERY_SIZE="SELECT (COUNT(*) as ?C) WHERE {?s ?p ?o}"
    4.72 +QUERY_GETALL="SELECT * WHERE {?s ?p ?o}"
    4.73 +QUERY_DELETEALL="DELETE {?s ?p ?o} WHERE {?s ?p ?o}"
    4.74 +QUERY_HOTSPOT_SIZE="SELECT (COUNT(*) as ?C) WHERE {?h <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://teleios.di.uoa.gr/ontologies/noaOntology.owl#Hotspot>}"
    4.75 +QUERY_EXPORT="CONSTRUCT {?s ?p ?o} WHERE {?s ?p ?o}"
    4.76 +
    4.77 +# debug option for log4j configuration:
    4.78 +#-Dlog4j.debug
    4.79 +#-Dlog4j.configuration=\"${RUNTIME}/log4j.properties\"
    4.80 +
    4.81 +# further options for java
    4.82 +JAVA_OPTS=
    4.83 +
    4.84 +# base max memory memory
    4.85 +BASE_MEMORY=1024
    4.86 +
    4.87 +# more memory
    4.88 +MORE_MEMORY="-Xms512M -Xmx1024M"
    4.89 +
    4.90 +# much more memory
    4.91 +MMORE_MEMORY="-Xms512M -Xmx1536M"
    4.92 +
    4.93 +# flag for not setting the memory limit more than once
    4.94 +MEMORY_INCREASED=false
    4.95 +
    4.96 +# just print what shall be executed
    4.97 +DEBUG=false
    4.98 +
    4.99 +# if true, DEBUG has been set in command line,
   4.100 +# so it must not be overidden
   4.101 +DEBUG_SAVE=false
   4.102 +
   4.103 +# Filename containing the prefixes to be included in SPARQL queries
   4.104 +PREFIXES_FILE="${LOC}/prefixes.sparql"
   4.105 +
   4.106 +# configuration file for the Strabon connection
   4.107 +STRABON_CONF="${HOME}/.strabon"
   4.108 +
   4.109 +function help() {
   4.110 +	echo "Usage: ${CMD} [OPTIONS] COMMAND ARGS"
   4.111 +	echo
   4.112 +	echo "Interface to execute the main classes of Strabon, such as QueryOp, StoreOp, UpdateOp, DescribeOp, etc."
   4.113 +	echo
   4.114 +	echo "	COMMAND	 : one of \`query', \`update', \`store', \`describe', or \`help'"
   4.115 +	echo "	ARGS	 : arguments according to selected command"
   4.116 +	echo
   4.117 +	echo "OPTIONS can be any of the following (variable names and values are case sensitive)"
   4.118 +	echo "	-d		: don't run, just print what shall be executed"
   4.119 +	echo "			  Variable for configuration file: \`DEBUG'"
   4.120 +	echo "			  Values: \`true' or \`false'" 
   4.121 +	echo "	-m		: use more memory \`${MORE_MEMORY}' (useful in \"out of memory exceptions\")"
   4.122 +	echo "	-M		: use much more memory \`${MMORE_MEMORY}' (useful in \"out of memory exceptions\")"
   4.123 +	echo "	-MM MULT	: use MULT * ${BASE_MEMORY} MB of memory (useful in \"out of memory exceptions\")"
   4.124 +	echo "	-i		: include URI prefixes in the SPARQL query. Prefixes are taken from file"
   4.125 +	echo "			  \`prefixes.sparql'"
   4.126 +	echo "	-e DATABASE	: the database engine to connect (one of \`postgis' (default) or \`monetdb')"
   4.127 +	echo "			  Variable for configuration file: \`DATABASE'"
   4.128 +	echo "			  Values: \`postgis' or \`monetdb'" 
   4.129 +	echo "	-db DB		: the database to connect to (defaults to \`${DB}')"
   4.130 +	echo "			  Variable for configuration file: \`DB'"
   4.131 +	echo "	-p PORT		: the port to use for the database connection"
   4.132 +	echo "			: (defaults to 5432 for postgis and 50000 for monetdb)"
   4.133 +	echo "			  Variable for configuration file: \`PORT'"
   4.134 +	echo "	-h HOSTNAME	: the hostname to use for the database connection (defaults to \`${HOST}')"
   4.135 +	echo "			  Variable for configuration file: \`HOST'"
   4.136 +	echo "	-u USERNAME	: the username for the database connection"
   4.137 +	echo "			  (defaults to \`postgres' for postgis and \`monetdb' for monetdb)"
   4.138 +	echo "			  Variable for configuration file: \`DBUSER'"
   4.139 +	echo "	-pass PASS	: the password for the database connection"
   4.140 +	echo "			  (defaults to \`postgres' for postgis and \`monetdb' for monetdb)"
   4.141 +	echo "			  Variable for configuration file: \`DBPASS'"
   4.142 +	echo "	-c FILE		: configuration file to use for the connection (defaults to \`${STRABON_CONF}')."
   4.143 +	echo "			  If the default configuration file exists, it is read. Options specified in the"
   4.144 +	echo "			  command line override their values already set by the configuration file."
   4.145 +}
   4.146 +
   4.147 +function help_query() {
   4.148 +	echo "Usage: ${CMD} query [OPTIONS] SPARQL_QUERY [RESULT_FORMAT]"
   4.149 +	echo
   4.150 +	echo "Execute a SPARQL query on Strabon."
   4.151 +	echo
   4.152 +	echo "	SPARQL_QUERY	: the SPARQL query to execute or an alias name such as the following:"
   4.153 +	echo "				size: returns the number of triples"
   4.154 +	echo "				all: returns all triples"
   4.155 +	echo "				hotspots: returns the number of hotspots"
   4.156 +	echo "	RESULT_FORMAT	: the format of the result. Possible values are \`???' (default), \`xml'"
   4.157 +	echo "			  \`html', \`kml', \`kmz', or \`geojson'"
   4.158 +	echo
   4.159 +	echo "OPTIONS can be one of the following"
   4.160 +	echo "	--force-delete  : forces deletion of \"locked\" table (e.g., when Strabon has been"
   4.161 +	echo "			  ungracefully shutdown)"
   4.162 +}
   4.163 +
   4.164 +function help_update() {
   4.165 +	echo "Usage: ${CMD} update SPARQL_UPDATE"
   4.166 +	echo
   4.167 +	echo "Execute a SPARQL Update query on Strabon."
   4.168 +	echo
   4.169 +	echo "	SPARQL_UPDATE	: the SPARQL update query to execute or an alias name such as the"
   4.170 +	echo "			  the following:"
   4.171 +	echo "				clear: deletes all triples"
   4.172 +}
   4.173 +
   4.174 +function help_store() {
   4.175 +	echo "Usage: ${CMD} store [OPTIONS] FILE..."
   4.176 +	echo
   4.177 +	echo "Store RDF documents in Strabon."
   4.178 +	echo
   4.179 +	echo "	FILE	: the file containing the RDF document to store. It can be a filename or a URL,"
   4.180 +	echo "		  (i.e., file:///tmp/file.nt, http://www.example.org/file.nt,"
   4.181 +	echo "		  ftp://www.example.org/file.nt, etc.)."
   4.182 +	echo 
   4.183 +	echo "OPTIONS can be one of the following"
   4.184 +	echo "	-f FORMAT : the RDF format of the files to store. The format can be one of the following:"
   4.185 +	echo "		    \`ntriples' (default), \`n3', \`rdfxml', or \`turtle'."
   4.186 +	echo "	-g NAMED_GRAPH : the URI of the named graph into which the RDF files shall be stored"
   4.187 +	echo "	                 (defaults to the default graph)."
   4.188 +	echo "	--inference : enables inference."
   4.189 +}
   4.190 +
   4.191 +function help_describe() {
   4.192 +	echo "Usage: ${CMD} describe DESCRIBE_QUERY [RESULT_FORMAT]"
   4.193 +	echo
   4.194 +	echo "Execute a SPARQL DESCRIBE query on Strabon."
   4.195 +	echo
   4.196 +	echo "	DESCRIBE_QUERY	: the SPARQL DESCRIBE query to execute or an alias name such as the following:"
   4.197 +	echo "				export: returns all triples stored in the database"
   4.198 +	echo "	RESULT_FORMAT	: the format of the result. Possible values are \`N-Triples', "
   4.199 +	echo "			  \`RDM/XML', \`N3', \`TURTLE', \`TRIG', \`TRIX', and \`BinaryRDF'"
   4.200 +	echo "			  (defaults to N-Triples)"
   4.201 +}
   4.202 +
   4.203 +# read configuration script first
   4.204 +if test -e "${STRABON_CONF}"; then
   4.205 +	. ${STRABON_CONF}
   4.206 +fi
   4.207 +
   4.208 +if ${DEBUG}; then
   4.209 +	echo "${CMD}: debug is ON (from configuration file ${STRABON_CONF})"
   4.210 +fi
   4.211 +
   4.212 +# read script options
   4.213 +while test $# -gt 0 -a "X${1:0:1}" == "X-"; do
   4.214 +	case "${1}" in
   4.215 +		--help)
   4.216 +			help
   4.217 +			exit 0
   4.218 +			;;
   4.219 +		-d)
   4.220 +			shift
   4.221 +			if ! ${DEBUG}; then
   4.222 +				echo "${CMD}: debug is ON"
   4.223 +			fi
   4.224 +			DEBUG=true
   4.225 +			DEBUG_SAVE=true
   4.226 +			;;
   4.227 +		-m)
   4.228 +			if ! ${MEMORY_INCREASED}; then
   4.229 +				JAVA_OPTS="${JAVA_OPTS} ${MORE_MEMORY}"
   4.230 +				MEMORY_INCREASED=true
   4.231 +			else
   4.232 +				echo "${CMD}: memory has already been increased; option \`${1}' will be ignored."
   4.233 +			fi
   4.234 +			shift
   4.235 +			;;
   4.236 +		-M)
   4.237 +			if ! ${MEMORY_INCREASED}; then
   4.238 +				JAVA_OPTS="${JAVA_OPTS} ${MMORE_MEMORY}"
   4.239 +				MEMORY_INCREASED=true
   4.240 +			else
   4.241 +				echo "${CMD}: memory has already been increased; option \`${1}' will be ignored."
   4.242 +			fi
   4.243 +			shift
   4.244 +			;;
   4.245 +		-MM)
   4.246 +			shift
   4.247 +			if ! test $# -gt 1; then
   4.248 +				help
   4.249 +				exit 1
   4.250 +			fi
   4.251 +			MULT=${1}
   4.252 +
   4.253 +			if ! ${MEMORY_INCREASED}; then
   4.254 +				JAVA_OPTS="${JAVA_OPTS} -Xms512M -Xmx$((${MULT}*${BASE_MEMORY}))M"
   4.255 +				MEMORY_INCREASED=true
   4.256 +			else
   4.257 +				echo "${CMD}: memory has already been increased; option \`${1}' will be ignored."
   4.258 +			fi
   4.259 +			shift
   4.260 +			;;
   4.261 +		-i)
   4.262 +			shift
   4.263 +			PREFIXES="$(cat ${PREFIXES_FILE})
   4.264 +"
   4.265 +			;;
   4.266 +		-e)
   4.267 +			shift
   4.268 +			if ! test $# -gt 1; then
   4.269 +				help
   4.270 +				exit 1
   4.271 +			fi
   4.272 +
   4.273 +			DATABASE=${1}
   4.274 +			case "${DATABASE}" in
   4.275 +				monetdb|postgis)
   4.276 +					shift
   4.277 +					;;
   4.278 +				postgis)
   4.279 +					shift
   4.280 +					;;
   4.281 +				*)
   4.282 +					echo "${CMD}: invalid database engine"
   4.283 +					echo "${CMD}: valid database engines are \`postgis' or \`monetdb'"
   4.284 +					exit 2
   4.285 +					;;
   4.286 +			esac
   4.287 +			;;
   4.288 +		-db)
   4.289 +			shift
   4.290 +			if ! test $# -gt 1; then
   4.291 +				help
   4.292 +				exit 1
   4.293 +			fi
   4.294 +			DB="${1}"
   4.295 +			shift
   4.296 +			;;
   4.297 +		-p)
   4.298 +			shift
   4.299 +			if ! test $# -gt 1; then
   4.300 +				help
   4.301 +				exit 1
   4.302 +			fi
   4.303 +			PORT=${1}
   4.304 +			shift
   4.305 +			;;
   4.306 +		-h)
   4.307 +			shift
   4.308 +			if ! test $# -gt 1; then
   4.309 +				help
   4.310 +				exit 1
   4.311 +			fi
   4.312 +			HOST=${1}
   4.313 +			shift
   4.314 +			;;
   4.315 +		-u)
   4.316 +			shift
   4.317 +			if ! test $# -gt 1; then
   4.318 +				help
   4.319 +				exit 1
   4.320 +			fi
   4.321 +			DBUSER=${1}
   4.322 +			shift
   4.323 +			;;
   4.324 +		-pass)
   4.325 +			shift
   4.326 +			if ! test $# -gt 1; then
   4.327 +				help
   4.328 +				exit 1
   4.329 +			fi
   4.330 +			DBPASS=${1}
   4.331 +			shift
   4.332 +			;;
   4.333 +		-c)
   4.334 +			shift
   4.335 +			if ! test $# -gt 1; then
   4.336 +				help
   4.337 +				exit 1
   4.338 +			fi
   4.339 +
   4.340 +			STRABON_CONF="${1}"
   4.341 +			if ! test -e "${STRABON_CONF}"; then
   4.342 +				echo "${CMD}: configuration file \"${1}\" does not exist"
   4.343 +				exit 1
   4.344 +			else
   4.345 +				# if true, then debug has been set ON in command line
   4.346 +				if $DEBUG; then
   4.347 +					echo "${CMD}: Reading configuration file \"${STRABON_CONF}\""
   4.348 +				fi
   4.349 +
   4.350 +				. ${STRABON_CONF}
   4.351 +
   4.352 +				if $DEBUG_SAVE; then
   4.353 +					# restore debug value set on command line
   4.354 +					DEBUG=true
   4.355 +				fi
   4.356 +				shift
   4.357 +			fi
   4.358 +			;;
   4.359 +		-*)
   4.360 +			echo "${CMD}: unknown option \"${1}\""
   4.361 +			help
   4.362 +			exit 1
   4.363 +			;;
   4.364 +	esac
   4.365 +done
   4.366 +
   4.367 +# set defaults
   4.368 +case "${DATABASE}" in
   4.369 +	postgis)
   4.370 +		if test -z "${PORT}";
   4.371 +		then
   4.372 +			PORT=5432
   4.373 +		fi
   4.374 +
   4.375 +		if test -z "${DBUSER}";
   4.376 +		then
   4.377 +			DBUSER="postgres"
   4.378 +		fi
   4.379 +		
   4.380 +		if test -z "${DBPASS}";
   4.381 +		then
   4.382 +			DBPASS="postgres"
   4.383 +		fi
   4.384 +		;;
   4.385 +	monetdb)
   4.386 +		if test -z "${PORT}";
   4.387 +		then
   4.388 +			PORT=50000
   4.389 +		fi
   4.390 +
   4.391 +		if test -z "${DBUSER}";
   4.392 +		then
   4.393 +			DBUSER="monetdb"
   4.394 +		fi
   4.395 +		
   4.396 +		if test -z "${DBPASS}";
   4.397 +		then
   4.398 +			DBPASS="monetdb"
   4.399 +		fi
   4.400 +		;;
   4.401 +esac
   4.402 +
   4.403 +# print configuration/options
   4.404 +if ${DEBUG}; then
   4.405 +	echo "${CMD}: printing database connection details"
   4.406 +	echo "	 Database Engine : ${DATABASE}"
   4.407 +	echo "	 Database Name	 : ${DB}"
   4.408 +	echo "	 Hostname	 : ${HOST}"
   4.409 +	echo "	 Port		 : ${PORT}"
   4.410 +	echo "	 Username	 : ${DBUSER}"
   4.411 +	echo "	 Password	 : ${DBPASS}"
   4.412 +fi
   4.413 +
   4.414 +# determine command to execute
   4.415 +case "${1}" in
   4.416 +	help)
   4.417 +		shift
   4.418 +		if test $# -ge 1; then
   4.419 +			case "${1}" in
   4.420 +				query)
   4.421 +					help_query
   4.422 +					;;
   4.423 +				update)
   4.424 +					help_update
   4.425 +					;;
   4.426 +				store)
   4.427 +					help_store
   4.428 +					;;
   4.429 +				describe)
   4.430 +					help_describe
   4.431 +					;;
   4.432 +				*)
   4.433 +					help
   4.434 +					;;
   4.435 +			esac
   4.436 +			exit 1
   4.437 +		fi
   4.438 +		help
   4.439 +		exit 0
   4.440 +		;;
   4.441 +	query)
   4.442 +		CLASS="QueryOp"
   4.443 +		shift
   4.444 +		if ! test $# -ge 1; then
   4.445 +			help_query
   4.446 +			exit 1
   4.447 +		fi
   4.448 +
   4.449 +		# check whether force deletion of locked table has been specified
   4.450 +		if test "${1}" = "--force-delete"; then
   4.451 +			shift
   4.452 +			FORCE_DELETE="true"
   4.453 +		fi
   4.454 +
   4.455 +		QUERY="${1}"
   4.456 +		shift
   4.457 +
   4.458 +		# check for predefined queries
   4.459 +		case "${QUERY}" in
   4.460 +			size)
   4.461 +				QUERY="${QUERY_SIZE}"
   4.462 +				;;
   4.463 +			hotspots)
   4.464 +				QUERY="${QUERY_HOTSPOT_SIZE}"
   4.465 +				;;
   4.466 +			all)
   4.467 +				QUERY="${QUERY_GETALL}"
   4.468 +				;;
   4.469 +		esac
   4.470 +
   4.471 +		# check for format of result
   4.472 +		if test $# -gt 0; then
   4.473 +			RESULT_FORMAT="${1}"
   4.474 +			shift
   4.475 +			case "${RESULT_FORMAT}" in
   4.476 +				[xX][mM][lL]|[hH][tT][mM][lL]|[kK][mM][lL]|[kK][mM][zZ]|[gG][eE][oO][jJ][sS][oO][nN]|[tT][sS][vV]|[eE][xX][pP])
   4.477 +				;;
   4.478 +			*)
   4.479 +				echo "${CMD}: invalid result format \"${RESULT_FORMAT}\""
   4.480 +				echo "${CMD}: valid formats are \`???' (default), \`xml', \`html', \`kml', \`kmz', or \`geojson'"
   4.481 +				exit 2
   4.482 +				;;
   4.483 +			esac
   4.484 +		fi
   4.485 +		;;
   4.486 +	update)
   4.487 +		CLASS="UpdateOp"
   4.488 +		shift
   4.489 +		if ! test $# -eq 1; then
   4.490 +			help_update
   4.491 +			exit 1
   4.492 +		fi
   4.493 +		QUERY="${1}"
   4.494 +
   4.495 +		# check for predefined queries
   4.496 +		case "${QUERY}" in
   4.497 +			clear)
   4.498 +				QUERY="${QUERY_DELETEALL}"
   4.499 +				;;
   4.500 +		esac
   4.501 +		;;
   4.502 +	store)
   4.503 +		CLASS="StoreOp"
   4.504 +		shift
   4.505 +		if ! test $# -ge 1; then
   4.506 +			help_store
   4.507 +			exit 1
   4.508 +		fi
   4.509 +
   4.510 +		while test $# -gt 0 -a "X${1:0:1}" == "X-"; do
   4.511 +			# check whether format is specified
   4.512 +			if test "${1}" = "-f"; then
   4.513 +				shift
   4.514 +				if ! test $# -ge 1; then
   4.515 +					echo "${CMD}: Option -f requires an RDF format (\`ntriples', \`n3', \`rdfxml', or \`turtle')"
   4.516 +					exit 2
   4.517 +				else
   4.518 +					FORMAT="${1}"
   4.519 +					case "${FORMAT}" in
   4.520 +						[nN][tT][rR][iI][pP][lL][eE][sS]|[nN]3|[rR][dD][fF][xX][mM][lL]|[tT][uU][rR][tT][lL][eE])
   4.521 +							shift
   4.522 +							;;
   4.523 +						*)
   4.524 +							echo "${CMD}: invalid RDF format \"${FORMAT}\"."
   4.525 +							echo "${CMD}: valid RDF formats are \`ntriples', \`n3', \`rdfxml', or \`turtle'"
   4.526 +							exit 2
   4.527 +							;;
   4.528 +					esac
   4.529 +				fi
   4.530 +			fi
   4.531 +
   4.532 +			# check whether a named graph is specified
   4.533 +			if test "${1}" = "-g"; then
   4.534 +				shift
   4.535 +				if ! test $# -ge 1; then
   4.536 +					echo "${CMD}: Option -g requires a URI argument"
   4.537 +					exit 2
   4.538 +				else
   4.539 +					NAMED_GRAPH="-g ${1}"
   4.540 +					shift
   4.541 +				fi
   4.542 +			fi
   4.543 +
   4.544 +			# check whether inference is enabled
   4.545 +			if test "${1}" = "--inference"; then
   4.546 +				shift
   4.547 +				INFERENCE="-i true"
   4.548 +			fi
   4.549 +
   4.550 +		done
   4.551 +
   4.552 +		# if no files are given
   4.553 +		if ! test $# -ge 1; then
   4.554 +			help_store
   4.555 +			exit 1
   4.556 +		fi
   4.557 +
   4.558 +		# do not make an assignment of the files to QUERY
   4.559 +		# handle the case of storing multiple files afterwards
   4.560 +		# QUERY="${@}"
   4.561 +		;;
   4.562 +	describe)
   4.563 +		CLASS="DescribeOp"
   4.564 +		shift
   4.565 +		if ! test $# -ge 1; then
   4.566 +			help_describe
   4.567 +			exit 1
   4.568 +		fi
   4.569 +		QUERY="${1}"
   4.570 +		shift
   4.571 +
   4.572 +		# check for predefined queries
   4.573 +		case "${QUERY}" in
   4.574 +			export)
   4.575 +				QUERY="${QUERY_EXPORT}"
   4.576 +				;;
   4.577 +		esac
   4.578 +
   4.579 +		# check for format of result
   4.580 +		if test $# -gt 0; then
   4.581 +			RESULT_FORMAT="${1}"
   4.582 +			shift
   4.583 +			case "${RESULT_FORMAT}" in
   4.584 +				N-Triples|RDF/XML|N3|TURTLE|TRIG|TRIX|BinaryRDF)
   4.585 +				;;
   4.586 +			*)
   4.587 +				echo "${CMD}: invalid result format \"${RESULT_FORMAT}\""
   4.588 +				echo "${CMD}: valid formats are \`N-Triples', \`RDM/XML', \`N3', \`TURTLE', \`TRIG', \`TRIX', and \`BinaryRDF'"
   4.589 +				exit 2
   4.590 +				;;
   4.591 +			esac
   4.592 +		fi
   4.593 +		;;
   4.594 +	"")
   4.595 +		help
   4.596 +		exit 1
   4.597 +		;;
   4.598 +	*) 
   4.599 +		help
   4.600 +		echo
   4.601 +		echo "${CMD}: unknown command \"${1}\"."
   4.602 +		exit 1
   4.603 +		;;
   4.604 +esac
   4.605 +
   4.606 +# compile command to execute
   4.607 +if test "${CLASS}" = "StoreOp"; then
   4.608 +	STRABON_EXEC=
   4.609 +	for file in "${@}"; do
   4.610 +		# check whether a relative path was given
   4.611 +		if ! test "${file:0:7}" == "file://" -o "${file:0:7}" == "http://" -o "${file:0:1}" == "/"; then
   4.612 +			file="$(pwd)/${file}"
   4.613 +		fi
   4.614 +
   4.615 +		STRABON_EXEC="${STRABON_EXEC}(java ${JAVA_OPTS} -cp :/usr/share/jdeb/lib/strabon-runtime/* ${PKG}.${DATABASE}.${CLASS} ${HOST} ${PORT} ${DB} ${DBUSER} ${DBPASS} \"${file}\" -f ${FORMAT} ${NAMED_GRAPH} ${INFERENCE});
   4.616 +"
   4.617 +	done
   4.618 +elif test "${CLASS}" = "QueryOp"; then
   4.619 +	STRABON_EXEC="(java ${JAVA_OPTS} -cp :/usr/share/jdeb/lib/strabon-runtime/* ${PKG}.${DATABASE}.${CLASS} ${HOST} ${PORT} ${DB} ${DBUSER} ${DBPASS} \"${PREFIXES}${QUERY}\" ${FORCE_DELETE} ${RESULT_FORMAT})"
   4.620 +else
   4.621 +	STRABON_EXEC="(java ${JAVA_OPTS} -cp :/usr/share/jdeb/lib/strabon-runtime/* ${PKG}.${DATABASE}.${CLASS} ${HOST} ${PORT} ${DB} ${DBUSER} ${DBPASS} \"${PREFIXES}${QUERY}\" ${RESULT_FORMAT})"
   4.622 +fi
   4.623 +
   4.624 +# execute command or debug
   4.625 +if ${DEBUG}; then
   4.626 +	echo "${CMD}: printing command for execution"	
   4.627 +	echo "${STRABON_EXEC}"
   4.628 +else
   4.629 +	eval "${STRABON_EXEC}"
   4.630 +fi
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/scripts/strabon-cmd	Fri Jan 23 16:22:50 2015 +0200
     5.3 @@ -0,0 +1,627 @@
     5.4 +#!/bin/bash
     5.5 +
     5.6 +#
     5.7 +# This Source Code Form is subject to the terms of the Mozilla Public
     5.8 +# License, v. 2.0. If a copy of the MPL was not distributed with this
     5.9 +# file, You can obtain one at http://mozilla.org/MPL/2.0/.
    5.10 +#
    5.11 +# Copyright (C) 2010, 2011, 2012, Pyravlos Team
    5.12 +#
    5.13 +# http://www.strabon.di.uoa.gr/
    5.14 +#
    5.15 +
    5.16 +#
    5.17 +# Script for running the main classes of Strabon. The main classes of Strabon comprises
    5.18 +# QueryOp, , UpdateOp, StoreOp, and  DescribeOp.
    5.19 +#
    5.20 +# Author: Charalampos (Babis) Nikolaou <charnik@di.uoa.gr>
    5.21 +#
    5.22 +
    5.23 +# command name
    5.24 +CMD="$(basename ${0})"
    5.25 +
    5.26 +# absolute directory name of this command
    5.27 +LOC="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
    5.28 +
    5.29 +RUNTIME="${LOC}/../runtime"
    5.30 +
    5.31 +# runtime package
    5.32 +PKG="eu.earthobservatory.runtime"
    5.33 +
    5.34 +# the underlying database to use (one of `postgis' or `monetdb')
    5.35 +DATABASE="postgis"
    5.36 +
    5.37 +# the main class to run
    5.38 +CLASS=
    5.39 +
    5.40 +# the hostname at which the database runs
    5.41 +HOST="localhost"
    5.42 +
    5.43 +# the port at which the database listens
    5.44 +PORT=
    5.45 +
    5.46 +# the database name to connect to
    5.47 +DB="strabon"
    5.48 +
    5.49 +# the username for the database connection
    5.50 +DBUSER=
    5.51 +
    5.52 +# the password for the database connection
    5.53 +DBPASS=
    5.54 +
    5.55 +# the query to run
    5.56 +QUERY=
    5.57 +
    5.58 +# the RDF format of the files to store (defaults to ntriples)
    5.59 +FORMAT="ntriples"
    5.60 +
    5.61 +# true to force deletion of locked table, false otherwise
    5.62 +FORCE_DELETE="false"
    5.63 +
    5.64 +# the URI of the named graph into which the RDF files shall be stored
    5.65 +NAMED_GRAPH=
    5.66 +
    5.67 +# true when inference is enabled
    5.68 +INFERENCE=
    5.69 +
    5.70 +# predefined queries
    5.71 +QUERY_SIZE="SELECT (COUNT(*) as ?C) WHERE {?s ?p ?o}"
    5.72 +QUERY_GETALL="SELECT * WHERE {?s ?p ?o}"
    5.73 +QUERY_DELETEALL="DELETE {?s ?p ?o} WHERE {?s ?p ?o}"
    5.74 +QUERY_HOTSPOT_SIZE="SELECT (COUNT(*) as ?C) WHERE {?h <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://teleios.di.uoa.gr/ontologies/noaOntology.owl#Hotspot>}"
    5.75 +QUERY_EXPORT="CONSTRUCT {?s ?p ?o} WHERE {?s ?p ?o}"
    5.76 +
    5.77 +# debug option for log4j configuration:
    5.78 +#-Dlog4j.debug
    5.79 +#-Dlog4j.configuration=\"${RUNTIME}/log4j.properties\"
    5.80 +
    5.81 +# further options for java
    5.82 +JAVA_OPTS=
    5.83 +
    5.84 +# base max memory memory
    5.85 +BASE_MEMORY=1024
    5.86 +
    5.87 +# more memory
    5.88 +MORE_MEMORY="-Xms512M -Xmx1024M"
    5.89 +
    5.90 +# much more memory
    5.91 +MMORE_MEMORY="-Xms512M -Xmx1536M"
    5.92 +
    5.93 +# flag for not setting the memory limit more than once
    5.94 +MEMORY_INCREASED=false
    5.95 +
    5.96 +# just print what shall be executed
    5.97 +DEBUG=false
    5.98 +
    5.99 +# if true, DEBUG has been set in command line,
   5.100 +# so it must not be overidden
   5.101 +DEBUG_SAVE=false
   5.102 +
   5.103 +# Filename containing the prefixes to be included in SPARQL queries
   5.104 +PREFIXES_FILE="${LOC}/prefixes.sparql"
   5.105 +
   5.106 +# configuration file for the Strabon connection
   5.107 +STRABON_CONF="${HOME}/.strabon"
   5.108 +
   5.109 +function help() {
   5.110 +	echo "Usage: ${CMD} [OPTIONS] COMMAND ARGS"
   5.111 +	echo
   5.112 +	echo "Interface to execute the main classes of Strabon, such as QueryOp, StoreOp, UpdateOp, DescribeOp, etc."
   5.113 +	echo
   5.114 +	echo "	COMMAND	 : one of \`query', \`update', \`store', \`describe', or \`help'"
   5.115 +	echo "	ARGS	 : arguments according to selected command"
   5.116 +	echo
   5.117 +	echo "OPTIONS can be any of the following (variable names and values are case sensitive)"
   5.118 +	echo "	-d		: don't run, just print what shall be executed"
   5.119 +	echo "			  Variable for configuration file: \`DEBUG'"
   5.120 +	echo "			  Values: \`true' or \`false'" 
   5.121 +	echo "	-m		: use more memory \`${MORE_MEMORY}' (useful in \"out of memory exceptions\")"
   5.122 +	echo "	-M		: use much more memory \`${MMORE_MEMORY}' (useful in \"out of memory exceptions\")"
   5.123 +	echo "	-MM MULT	: use MULT * ${BASE_MEMORY} MB of memory (useful in \"out of memory exceptions\")"
   5.124 +	echo "	-i		: include URI prefixes in the SPARQL query. Prefixes are taken from file"
   5.125 +	echo "			  \`prefixes.sparql'"
   5.126 +	echo "	-e DATABASE	: the database engine to connect (one of \`postgis' (default) or \`monetdb')"
   5.127 +	echo "			  Variable for configuration file: \`DATABASE'"
   5.128 +	echo "			  Values: \`postgis' or \`monetdb'" 
   5.129 +	echo "	-db DB		: the database to connect to (defaults to \`${DB}')"
   5.130 +	echo "			  Variable for configuration file: \`DB'"
   5.131 +	echo "	-p PORT		: the port to use for the database connection"
   5.132 +	echo "			: (defaults to 5432 for postgis and 50000 for monetdb)"
   5.133 +	echo "			  Variable for configuration file: \`PORT'"
   5.134 +	echo "	-h HOSTNAME	: the hostname to use for the database connection (defaults to \`${HOST}')"
   5.135 +	echo "			  Variable for configuration file: \`HOST'"
   5.136 +	echo "	-u USERNAME	: the username for the database connection"
   5.137 +	echo "			  (defaults to \`postgres' for postgis and \`monetdb' for monetdb)"
   5.138 +	echo "			  Variable for configuration file: \`DBUSER'"
   5.139 +	echo "	-pass PASS	: the password for the database connection"
   5.140 +	echo "			  (defaults to \`postgres' for postgis and \`monetdb' for monetdb)"
   5.141 +	echo "			  Variable for configuration file: \`DBPASS'"
   5.142 +	echo "	-c FILE		: configuration file to use for the connection (defaults to \`${STRABON_CONF}')."
   5.143 +	echo "			  If the default configuration file exists, it is read. Options specified in the"
   5.144 +	echo "			  command line override their values already set by the configuration file."
   5.145 +}
   5.146 +
   5.147 +function help_query() {
   5.148 +	echo "Usage: ${CMD} query [OPTIONS] SPARQL_QUERY [RESULT_FORMAT]"
   5.149 +	echo
   5.150 +	echo "Execute a SPARQL query on Strabon."
   5.151 +	echo
   5.152 +	echo "	SPARQL_QUERY	: the SPARQL query to execute or an alias name such as the following:"
   5.153 +	echo "				size: returns the number of triples"
   5.154 +	echo "				all: returns all triples"
   5.155 +	echo "				hotspots: returns the number of hotspots"
   5.156 +	echo "	RESULT_FORMAT	: the format of the result. Possible values are \`???' (default), \`xml'"
   5.157 +	echo "			  \`html', \`kml', \`kmz', or \`geojson'"
   5.158 +	echo
   5.159 +	echo "OPTIONS can be one of the following"
   5.160 +	echo "	--force-delete  : forces deletion of \"locked\" table (e.g., when Strabon has been"
   5.161 +	echo "			  ungracefully shutdown)"
   5.162 +}
   5.163 +
   5.164 +function help_update() {
   5.165 +	echo "Usage: ${CMD} update SPARQL_UPDATE"
   5.166 +	echo
   5.167 +	echo "Execute a SPARQL Update query on Strabon."
   5.168 +	echo
   5.169 +	echo "	SPARQL_UPDATE	: the SPARQL update query to execute or an alias name such as the"
   5.170 +	echo "			  the following:"
   5.171 +	echo "				clear: deletes all triples"
   5.172 +}
   5.173 +
   5.174 +function help_store() {
   5.175 +	echo "Usage: ${CMD} store [OPTIONS] FILE..."
   5.176 +	echo
   5.177 +	echo "Store RDF documents in Strabon."
   5.178 +	echo
   5.179 +	echo "	FILE	: the file containing the RDF document to store. It can be a filename or a URL,"
   5.180 +	echo "		  (i.e., file:///tmp/file.nt, http://www.example.org/file.nt,"
   5.181 +	echo "		  ftp://www.example.org/file.nt, etc.)."
   5.182 +	echo 
   5.183 +	echo "OPTIONS can be one of the following"
   5.184 +	echo "	-f FORMAT : the RDF format of the files to store. The format can be one of the following:"
   5.185 +	echo "		    \`ntriples' (default), \`n3', \`rdfxml', or \`turtle'."
   5.186 +	echo "	-g NAMED_GRAPH : the URI of the named graph into which the RDF files shall be stored"
   5.187 +	echo "	                 (defaults to the default graph)."
   5.188 +	echo "	--inference : enables inference."
   5.189 +}
   5.190 +
   5.191 +function help_describe() {
   5.192 +	echo "Usage: ${CMD} describe DESCRIBE_QUERY [RESULT_FORMAT]"
   5.193 +	echo
   5.194 +	echo "Execute a SPARQL DESCRIBE query on Strabon."
   5.195 +	echo
   5.196 +	echo "	DESCRIBE_QUERY	: the SPARQL DESCRIBE query to execute or an alias name such as the following:"
   5.197 +	echo "				export: returns all triples stored in the database"
   5.198 +	echo "	RESULT_FORMAT	: the format of the result. Possible values are \`N-Triples', "
   5.199 +	echo "			  \`RDM/XML', \`N3', \`TURTLE', \`TRIG', \`TRIX', and \`BinaryRDF'"
   5.200 +	echo "			  (defaults to N-Triples)"
   5.201 +}
   5.202 +
   5.203 +# read configuration script first
   5.204 +if test -e "${STRABON_CONF}"; then
   5.205 +	. ${STRABON_CONF}
   5.206 +fi
   5.207 +
   5.208 +if ${DEBUG}; then
   5.209 +	echo "${CMD}: debug is ON (from configuration file ${STRABON_CONF})"
   5.210 +fi
   5.211 +
   5.212 +# read script options
   5.213 +while test $# -gt 0 -a "X${1:0:1}" == "X-"; do
   5.214 +	case "${1}" in
   5.215 +		--help)
   5.216 +			help
   5.217 +			exit 0
   5.218 +			;;
   5.219 +		-d)
   5.220 +			shift
   5.221 +			if ! ${DEBUG}; then
   5.222 +				echo "${CMD}: debug is ON"
   5.223 +			fi
   5.224 +			DEBUG=true
   5.225 +			DEBUG_SAVE=true
   5.226 +			;;
   5.227 +		-m)
   5.228 +			if ! ${MEMORY_INCREASED}; then
   5.229 +				JAVA_OPTS="${JAVA_OPTS} ${MORE_MEMORY}"
   5.230 +				MEMORY_INCREASED=true
   5.231 +			else
   5.232 +				echo "${CMD}: memory has already been increased; option \`${1}' will be ignored."
   5.233 +			fi
   5.234 +			shift
   5.235 +			;;
   5.236 +		-M)
   5.237 +			if ! ${MEMORY_INCREASED}; then
   5.238 +				JAVA_OPTS="${JAVA_OPTS} ${MMORE_MEMORY}"
   5.239 +				MEMORY_INCREASED=true
   5.240 +			else
   5.241 +				echo "${CMD}: memory has already been increased; option \`${1}' will be ignored."
   5.242 +			fi
   5.243 +			shift
   5.244 +			;;
   5.245 +		-MM)
   5.246 +			shift
   5.247 +			if ! test $# -gt 1; then
   5.248 +				help
   5.249 +				exit 1
   5.250 +			fi
   5.251 +			MULT=${1}
   5.252 +
   5.253 +			if ! ${MEMORY_INCREASED}; then
   5.254 +				JAVA_OPTS="${JAVA_OPTS} -Xms512M -Xmx$((${MULT}*${BASE_MEMORY}))M"
   5.255 +				MEMORY_INCREASED=true
   5.256 +			else
   5.257 +				echo "${CMD}: memory has already been increased; option \`${1}' will be ignored."
   5.258 +			fi
   5.259 +			shift
   5.260 +			;;
   5.261 +		-i)
   5.262 +			shift
   5.263 +			PREFIXES="$(cat ${PREFIXES_FILE})
   5.264 +"
   5.265 +			;;
   5.266 +		-e)
   5.267 +			shift
   5.268 +			if ! test $# -gt 1; then
   5.269 +				help
   5.270 +				exit 1
   5.271 +			fi
   5.272 +
   5.273 +			DATABASE=${1}
   5.274 +			case "${DATABASE}" in
   5.275 +				monetdb|postgis)
   5.276 +					shift
   5.277 +					;;
   5.278 +				postgis)
   5.279 +					shift
   5.280 +					;;
   5.281 +				*)
   5.282 +					echo "${CMD}: invalid database engine"
   5.283 +					echo "${CMD}: valid database engines are \`postgis' or \`monetdb'"
   5.284 +					exit 2
   5.285 +					;;
   5.286 +			esac
   5.287 +			;;
   5.288 +		-db)
   5.289 +			shift
   5.290 +			if ! test $# -gt 1; then
   5.291 +				help
   5.292 +				exit 1
   5.293 +			fi
   5.294 +			DB="${1}"
   5.295 +			shift
   5.296 +			;;
   5.297 +		-p)
   5.298 +			shift
   5.299 +			if ! test $# -gt 1; then
   5.300 +				help
   5.301 +				exit 1
   5.302 +			fi
   5.303 +			PORT=${1}
   5.304 +			shift
   5.305 +			;;
   5.306 +		-h)
   5.307 +			shift
   5.308 +			if ! test $# -gt 1; then
   5.309 +				help
   5.310 +				exit 1
   5.311 +			fi
   5.312 +			HOST=${1}
   5.313 +			shift
   5.314 +			;;
   5.315 +		-u)
   5.316 +			shift
   5.317 +			if ! test $# -gt 1; then
   5.318 +				help
   5.319 +				exit 1
   5.320 +			fi
   5.321 +			DBUSER=${1}
   5.322 +			shift
   5.323 +			;;
   5.324 +		-pass)
   5.325 +			shift
   5.326 +			if ! test $# -gt 1; then
   5.327 +				help
   5.328 +				exit 1
   5.329 +			fi
   5.330 +			DBPASS=${1}
   5.331 +			shift
   5.332 +			;;
   5.333 +		-c)
   5.334 +			shift
   5.335 +			if ! test $# -gt 1; then
   5.336 +				help
   5.337 +				exit 1
   5.338 +			fi
   5.339 +
   5.340 +			STRABON_CONF="${1}"
   5.341 +			if ! test -e "${STRABON_CONF}"; then
   5.342 +				echo "${CMD}: configuration file \"${1}\" does not exist"
   5.343 +				exit 1
   5.344 +			else
   5.345 +				# if true, then debug has been set ON in command line
   5.346 +				if $DEBUG; then
   5.347 +					echo "${CMD}: Reading configuration file \"${STRABON_CONF}\""
   5.348 +				fi
   5.349 +
   5.350 +				. ${STRABON_CONF}
   5.351 +
   5.352 +				if $DEBUG_SAVE; then
   5.353 +					# restore debug value set on command line
   5.354 +					DEBUG=true
   5.355 +				fi
   5.356 +				shift
   5.357 +			fi
   5.358 +			;;
   5.359 +		-*)
   5.360 +			echo "${CMD}: unknown option \"${1}\""
   5.361 +			help
   5.362 +			exit 1
   5.363 +			;;
   5.364 +	esac
   5.365 +done
   5.366 +
   5.367 +# set defaults
   5.368 +case "${DATABASE}" in
   5.369 +	postgis)
   5.370 +		if test -z "${PORT}";
   5.371 +		then
   5.372 +			PORT=5432
   5.373 +		fi
   5.374 +
   5.375 +		if test -z "${DBUSER}";
   5.376 +		then
   5.377 +			DBUSER="postgres"
   5.378 +		fi
   5.379 +		
   5.380 +		if test -z "${DBPASS}";
   5.381 +		then
   5.382 +			DBPASS="postgres"
   5.383 +		fi
   5.384 +		;;
   5.385 +	monetdb)
   5.386 +		if test -z "${PORT}";
   5.387 +		then
   5.388 +			PORT=50000
   5.389 +		fi
   5.390 +
   5.391 +		if test -z "${DBUSER}";
   5.392 +		then
   5.393 +			DBUSER="monetdb"
   5.394 +		fi
   5.395 +		
   5.396 +		if test -z "${DBPASS}";
   5.397 +		then
   5.398 +			DBPASS="monetdb"
   5.399 +		fi
   5.400 +		;;
   5.401 +esac
   5.402 +
   5.403 +# print configuration/options
   5.404 +if ${DEBUG}; then
   5.405 +	echo "${CMD}: printing database connection details"
   5.406 +	echo "	 Database Engine : ${DATABASE}"
   5.407 +	echo "	 Database Name	 : ${DB}"
   5.408 +	echo "	 Hostname	 : ${HOST}"
   5.409 +	echo "	 Port		 : ${PORT}"
   5.410 +	echo "	 Username	 : ${DBUSER}"
   5.411 +	echo "	 Password	 : ${DBPASS}"
   5.412 +fi
   5.413 +
   5.414 +# determine command to execute
   5.415 +case "${1}" in
   5.416 +	help)
   5.417 +		shift
   5.418 +		if test $# -ge 1; then
   5.419 +			case "${1}" in
   5.420 +				query)
   5.421 +					help_query
   5.422 +					;;
   5.423 +				update)
   5.424 +					help_update
   5.425 +					;;
   5.426 +				store)
   5.427 +					help_store
   5.428 +					;;
   5.429 +				describe)
   5.430 +					help_describe
   5.431 +					;;
   5.432 +				*)
   5.433 +					help
   5.434 +					;;
   5.435 +			esac
   5.436 +			exit 1
   5.437 +		fi
   5.438 +		help
   5.439 +		exit 0
   5.440 +		;;
   5.441 +	query)
   5.442 +		CLASS="QueryOp"
   5.443 +		shift
   5.444 +		if ! test $# -ge 1; then
   5.445 +			help_query
   5.446 +			exit 1
   5.447 +		fi
   5.448 +
   5.449 +		# check whether force deletion of locked table has been specified
   5.450 +		if test "${1}" = "--force-delete"; then
   5.451 +			shift
   5.452 +			FORCE_DELETE="true"
   5.453 +		fi
   5.454 +
   5.455 +		QUERY="${1}"
   5.456 +		shift
   5.457 +
   5.458 +		# check for predefined queries
   5.459 +		case "${QUERY}" in
   5.460 +			size)
   5.461 +				QUERY="${QUERY_SIZE}"
   5.462 +				;;
   5.463 +			hotspots)
   5.464 +				QUERY="${QUERY_HOTSPOT_SIZE}"
   5.465 +				;;
   5.466 +			all)
   5.467 +				QUERY="${QUERY_GETALL}"
   5.468 +				;;
   5.469 +		esac
   5.470 +
   5.471 +		# check for format of result
   5.472 +		if test $# -gt 0; then
   5.473 +			RESULT_FORMAT="${1}"
   5.474 +			shift
   5.475 +			case "${RESULT_FORMAT}" in
   5.476 +				[xX][mM][lL]|[hH][tT][mM][lL]|[kK][mM][lL]|[kK][mM][zZ]|[gG][eE][oO][jJ][sS][oO][nN]|[tT][sS][vV]|[eE][xX][pP])
   5.477 +				;;
   5.478 +			*)
   5.479 +				echo "${CMD}: invalid result format \"${RESULT_FORMAT}\""
   5.480 +				echo "${CMD}: valid formats are \`???' (default), \`xml', \`html', \`kml', \`kmz', or \`geojson'"
   5.481 +				exit 2
   5.482 +				;;
   5.483 +			esac
   5.484 +		fi
   5.485 +		;;
   5.486 +	update)
   5.487 +		CLASS="UpdateOp"
   5.488 +		shift
   5.489 +		if ! test $# -eq 1; then
   5.490 +			help_update
   5.491 +			exit 1
   5.492 +		fi
   5.493 +		QUERY="${1}"
   5.494 +
   5.495 +		# check for predefined queries
   5.496 +		case "${QUERY}" in
   5.497 +			clear)
   5.498 +				QUERY="${QUERY_DELETEALL}"
   5.499 +				;;
   5.500 +		esac
   5.501 +		;;
   5.502 +	store)
   5.503 +		CLASS="StoreOp"
   5.504 +		shift
   5.505 +		if ! test $# -ge 1; then
   5.506 +			help_store
   5.507 +			exit 1
   5.508 +		fi
   5.509 +
   5.510 +		while test $# -gt 0 -a "X${1:0:1}" == "X-"; do
   5.511 +			# check whether format is specified
   5.512 +			if test "${1}" = "-f"; then
   5.513 +				shift
   5.514 +				if ! test $# -ge 1; then
   5.515 +					echo "${CMD}: Option -f requires an RDF format (\`ntriples', \`n3', \`rdfxml', or \`turtle')"
   5.516 +					exit 2
   5.517 +				else
   5.518 +					FORMAT="${1}"
   5.519 +					case "${FORMAT}" in
   5.520 +						[nN][tT][rR][iI][pP][lL][eE][sS]|[nN]3|[rR][dD][fF][xX][mM][lL]|[tT][uU][rR][tT][lL][eE])
   5.521 +							shift
   5.522 +							;;
   5.523 +						*)
   5.524 +							echo "${CMD}: invalid RDF format \"${FORMAT}\"."
   5.525 +							echo "${CMD}: valid RDF formats are \`ntriples', \`n3', \`rdfxml', or \`turtle'"
   5.526 +							exit 2
   5.527 +							;;
   5.528 +					esac
   5.529 +				fi
   5.530 +			fi
   5.531 +
   5.532 +			# check whether a named graph is specified
   5.533 +			if test "${1}" = "-g"; then
   5.534 +				shift
   5.535 +				if ! test $# -ge 1; then
   5.536 +					echo "${CMD}: Option -g requires a URI argument"
   5.537 +					exit 2
   5.538 +				else
   5.539 +					NAMED_GRAPH="-g ${1}"
   5.540 +					shift
   5.541 +				fi
   5.542 +			fi
   5.543 +
   5.544 +			# check whether inference is enabled
   5.545 +			if test "${1}" = "--inference"; then
   5.546 +				shift
   5.547 +				INFERENCE="-i true"
   5.548 +			fi
   5.549 +
   5.550 +		done
   5.551 +
   5.552 +		# if no files are given
   5.553 +		if ! test $# -ge 1; then
   5.554 +			help_store
   5.555 +			exit 1
   5.556 +		fi
   5.557 +
   5.558 +		# do not make an assignment of the files to QUERY
   5.559 +		# handle the case of storing multiple files afterwards
   5.560 +		# QUERY="${@}"
   5.561 +		;;
   5.562 +	describe)
   5.563 +		CLASS="DescribeOp"
   5.564 +		shift
   5.565 +		if ! test $# -ge 1; then
   5.566 +			help_describe
   5.567 +			exit 1
   5.568 +		fi
   5.569 +		QUERY="${1}"
   5.570 +		shift
   5.571 +
   5.572 +		# check for predefined queries
   5.573 +		case "${QUERY}" in
   5.574 +			export)
   5.575 +				QUERY="${QUERY_EXPORT}"
   5.576 +				;;
   5.577 +		esac
   5.578 +
   5.579 +		# check for format of result
   5.580 +		if test $# -gt 0; then
   5.581 +			RESULT_FORMAT="${1}"
   5.582 +			shift
   5.583 +			case "${RESULT_FORMAT}" in
   5.584 +				N-Triples|RDF/XML|N3|TURTLE|TRIG|TRIX|BinaryRDF)
   5.585 +				;;
   5.586 +			*)
   5.587 +				echo "${CMD}: invalid result format \"${RESULT_FORMAT}\""
   5.588 +				echo "${CMD}: valid formats are \`N-Triples', \`RDM/XML', \`N3', \`TURTLE', \`TRIG', \`TRIX', and \`BinaryRDF'"
   5.589 +				exit 2
   5.590 +				;;
   5.591 +			esac
   5.592 +		fi
   5.593 +		;;
   5.594 +	"")
   5.595 +		help
   5.596 +		exit 1
   5.597 +		;;
   5.598 +	*) 
   5.599 +		help
   5.600 +		echo
   5.601 +		echo "${CMD}: unknown command \"${1}\"."
   5.602 +		exit 1
   5.603 +		;;
   5.604 +esac
   5.605 +
   5.606 +# compile command to execute
   5.607 +if test "${CLASS}" = "StoreOp"; then
   5.608 +	STRABON_EXEC=
   5.609 +	for file in "${@}"; do
   5.610 +		# check whether a relative path was given
   5.611 +		if ! test "${file:0:7}" == "file://" -o "${file:0:7}" == "http://" -o "${file:0:1}" == "/"; then
   5.612 +			file="$(pwd)/${file}"
   5.613 +		fi
   5.614 +
   5.615 +		STRABON_EXEC="${STRABON_EXEC}(cd java ${JAVA_OPTS} -cp ./target/\*:. ${PKG}.${DATABASE}.${CLASS} ${HOST} ${PORT} ${DB} ${DBUSER} ${DBPASS} \"${file}\" -f ${FORMAT} ${NAMED_GRAPH} ${INFERENCE});
   5.616 +"
   5.617 +	done
   5.618 +elif test "${CLASS}" = "QueryOp"; then
   5.619 +	STRABON_EXEC="(java ${JAVA_OPTS} -cp ./target/\*:. ${PKG}.${DATABASE}.${CLASS} ${HOST} ${PORT} ${DB} ${DBUSER} ${DBPASS} \"${PREFIXES}${QUERY}\" ${FORCE_DELETE} ${RESULT_FORMAT})"
   5.620 +else
   5.621 +	STRABON_EXEC="(java ${JAVA_OPTS} -cp ./target/\*:. ${PKG}.${DATABASE}.${CLASS} ${HOST} ${PORT} ${DB} ${DBUSER} ${DBPASS} \"${PREFIXES}${QUERY}\" ${RESULT_FORMAT})"
   5.622 +fi
   5.623 +
   5.624 +# execute command or debug
   5.625 +if ${DEBUG}; then
   5.626 +	echo "${CMD}: printing command for execution"
   5.627 +	echo "${STRABON_EXEC}"
   5.628 +else
   5.629 +	eval "${STRABON_EXEC}"
   5.630 +fi