Strabon

changeset 28:bf7e497a0b9e

Added QueryDir op, modified poms to include latest jdbc driver (MonetDB-11.7.8-NOA_20120228a_SQL_C_Strabon.tar.bz2 with 43531:856fbc4256ff patch)
author Kostis Kyzirakos <kkyzir@di.uoa.gr>
date Wed Feb 29 13:41:48 2012 +0200 (2012-02-29)
parents 4caa89c66104
children 3d5afd337ccf
files generaldb/pom.xml monetdb/pom.xml pom.xml runtime/pom.xml runtime/src/main/java/eu/earthobservatory/runtime/monetdb/QueryDir.java runtime/src/main/java/eu/earthobservatory/runtime/postgis/QueryDir.java strabon
line diff
     1.1 --- a/generaldb/pom.xml	Tue Feb 28 20:23:15 2012 +0200
     1.2 +++ b/generaldb/pom.xml	Wed Feb 29 13:41:48 2012 +0200
     1.3 @@ -96,12 +96,12 @@
     1.4  	      <version>4.7</version>
     1.5  	      <scope>test</scope>
     1.6  	    </dependency>
     1.7 -	
     1.8 +	    <!--
     1.9  	    <dependency>
    1.10  	    	<groupId>net.sf</groupId>
    1.11  	    	<artifactId>log4jdbc3</artifactId>
    1.12  	    	<version>1.2beta2</version>
    1.13  	    </dependency>
    1.14 -	
    1.15 +	    -->
    1.16  	</dependencies>
    1.17  </project>
     2.1 --- a/monetdb/pom.xml	Tue Feb 28 20:23:15 2012 +0200
     2.2 +++ b/monetdb/pom.xml	Wed Feb 29 13:41:48 2012 +0200
     2.3 @@ -99,14 +99,14 @@
     2.4  	    <dependency>
     2.5  	    	<groupId>monetdb</groupId>
     2.6  	    	<artifactId>jdbcclient</artifactId>
     2.7 -	    	<version>3.2.0</version>
     2.8 +	    	<version>3.4.0</version>
     2.9  	    </dependency>
    2.10 -
    2.11 +	    <!--
    2.12  	    <dependency>
    2.13  	    	<groupId>net.sf</groupId>
    2.14  	    	<artifactId>log4jdbc3</artifactId>
    2.15  	    	<version>1.2beta2</version>
    2.16  	    </dependency>
    2.17 -	
    2.18 +	    -->
    2.19  	</dependencies>
    2.20  </project>
     3.1 --- a/pom.xml	Tue Feb 28 20:23:15 2012 +0200
     3.2 +++ b/pom.xml	Wed Feb 29 13:41:48 2012 +0200
     3.3 @@ -396,6 +396,19 @@
     3.4  	</scm>
     3.5  
     3.6  	<repositories>
     3.7 +		<!--
     3.8 +                <repository>
     3.9 +                        <releases>
    3.10 +                                <enabled>true</enabled>
    3.11 +                        </releases>
    3.12 +                        <snapshots>
    3.13 +                                <enabled>false</enabled>
    3.14 +                        </snapshots>
    3.15 +                        <id>strabon.testing</id>
    3.16 +                        <name>Strabon - maven repository</name>
    3.17 +                        <url>http://maven.strabon.di.uoa.gr/content/repositories/testing</url>
    3.18 +                </repository>
    3.19 +		-->
    3.20  		<repository>
    3.21  			<releases>
    3.22  				<enabled>true</enabled>
     4.1 --- a/runtime/pom.xml	Tue Feb 28 20:23:15 2012 +0200
     4.2 +++ b/runtime/pom.xml	Wed Feb 29 13:41:48 2012 +0200
     4.3 @@ -299,7 +299,7 @@
     4.4  			<dependency>
     4.5  				<groupId>monetdb</groupId>
     4.6  				<artifactId>jdbcclient</artifactId>
     4.7 -				<version>3.2.0</version>
     4.8 +				<version>3.4.0</version>
     4.9  			</dependency>
    4.10  
    4.11  			<!--
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/runtime/src/main/java/eu/earthobservatory/runtime/monetdb/QueryDir.java	Wed Feb 29 13:41:48 2012 +0200
     5.3 @@ -0,0 +1,96 @@
     5.4 +package eu.earthobservatory.runtime.monetdb;
     5.5 +
     5.6 +import java.io.BufferedReader;
     5.7 +import java.io.File;
     5.8 +import java.io.FileReader;
     5.9 +import java.io.IOException;
    5.10 +
    5.11 +
    5.12 +public class QueryDir {
    5.13 +
    5.14 +	/**
    5.15 +	 * @param args
    5.16 +	 * @throws Exception 
    5.17 +	 */
    5.18 +	public static void main(String[] args) throws Exception {
    5.19 +
    5.20 +		if (args.length < 6) {
    5.21 +			System.err.println("Usage: eu.ist.semsorgrid4env.strabon.Strabon <HOST> <PORT> <DATABASE> <USERNAME> <PASSWORD> <PATH> [<FORMAT>]");
    5.22 +			System.err.println("       where <HOST>       is the postgis database host to connect to");
    5.23 +			System.err.println("             <PORT>       is the port to connect to on the database host");		
    5.24 +			System.err.println("             <DATABASE>   is the spatially enabled postgis database that Strabon will use as a backend, ");
    5.25 +			System.err.println("             <USERNAME>   is the username to use when connecting to the database ");
    5.26 +			System.err.println("             <PASSWORD>   is the password to use when connecting to the database");
    5.27 +			System.err.println("             <PATH>      is the path containing all stSPARQL queries to evaluate.");
    5.28 +			System.err.println("             [<FORMAT>]     is the format of your results (XML)");
    5.29 +			System.exit(0);
    5.30 +		}
    5.31 +
    5.32 +		String host = args[0];
    5.33 +		Integer port = new Integer(args[1]);
    5.34 +		String db = args[2];
    5.35 +		String user = args[3];
    5.36 +		String passwd = args[4];		
    5.37 +		String path = args[5];
    5.38 +		String resultsFormat = "";
    5.39 +		if ( args.length == 7 ) {
    5.40 +			resultsFormat = args[6];
    5.41 +		}
    5.42 +
    5.43 +
    5.44 +
    5.45 +
    5.46 +		Strabon strabon = new Strabon(db, user, passwd, port, host, true);
    5.47 +
    5.48 +		File dir = new File(path);
    5.49 +		String[] children = dir.list();
    5.50 +		if (children != null) {
    5.51 +			for (int i=0; i<children.length; i++) {
    5.52 +				String filename = children[i];
    5.53 +				try {
    5.54 +					String queryString = readFile(path + System.getProperty("file.separator") + filename);
    5.55 +					strabon.query(queryString, resultsFormat, strabon.getSailRepoConnection());
    5.56 +				} catch (IOException e) {
    5.57 +					System.err.println("IOException while reading " + filename);
    5.58 +				}
    5.59 +			}
    5.60 +		}
    5.61 +		
    5.62 +		strabon.close();
    5.63 +	}
    5.64 +
    5.65 +	private static String readFile(String file) throws IOException {
    5.66 +		BufferedReader reader = new BufferedReader( new FileReader(file));
    5.67 +		String line  = null;
    5.68 +		StringBuilder stringBuilder = new StringBuilder();
    5.69 +		String ls = System.getProperty("line.separator");
    5.70 +		while( ( line = reader.readLine() ) != null ) {
    5.71 +			stringBuilder.append( line );
    5.72 +			stringBuilder.append( ls );
    5.73 +		}
    5.74 +		return stringBuilder.toString();
    5.75 +	}
    5.76 +
    5.77 +	/*
    5.78 +	private static void query(String queryString, SailRepositoryConnection con) throws MalformedQueryException, RepositoryException, QueryEvaluationException, IOException, ClassNotFoundException, TupleQueryResultHandlerException {
    5.79 +		TupleQuery tupleQuery = con.prepareTupleQuery(QueryLanguage.SPARQL, queryString);
    5.80 +
    5.81 +		System.out.println(queryString);
    5.82 +		TupleQueryResult result = tupleQuery.evaluate();
    5.83 +
    5.84 +		System.out.println("-------------------------------------------");
    5.85 +		System.out.println("-                RESULTS                  -");
    5.86 +		System.out.println("-------------------------------------------");
    5.87 +
    5.88 +		tupleQuery.evaluate(new SPARQLResultsXMLWriter(System.out));
    5.89 +
    5.90 +		List<String> bindingNames = result.getBindingNames();
    5.91 +		while (result.hasNext()) {
    5.92 +			BindingSet bindingSet = result.next();			
    5.93 +			System.out.println(bindingSet.toString());
    5.94 +		}
    5.95 +		System.out.println("-------------------------------------------");
    5.96 +		System.out.flush();
    5.97 +	}
    5.98 +	 */
    5.99 +}
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/runtime/src/main/java/eu/earthobservatory/runtime/postgis/QueryDir.java	Wed Feb 29 13:41:48 2012 +0200
     6.3 @@ -0,0 +1,96 @@
     6.4 +package eu.earthobservatory.runtime.postgis;
     6.5 +
     6.6 +import java.io.BufferedReader;
     6.7 +import java.io.File;
     6.8 +import java.io.FileReader;
     6.9 +import java.io.IOException;
    6.10 +
    6.11 +
    6.12 +public class QueryDir {
    6.13 +
    6.14 +	/**
    6.15 +	 * @param args
    6.16 +	 * @throws Exception 
    6.17 +	 */
    6.18 +	public static void main(String[] args) throws Exception {
    6.19 +
    6.20 +		if (args.length < 6) {
    6.21 +			System.err.println("Usage: eu.ist.semsorgrid4env.strabon.Strabon <HOST> <PORT> <DATABASE> <USERNAME> <PASSWORD> <PATH> [<FORMAT>]");
    6.22 +			System.err.println("       where <HOST>       is the postgis database host to connect to");
    6.23 +			System.err.println("             <PORT>       is the port to connect to on the database host");		
    6.24 +			System.err.println("             <DATABASE>   is the spatially enabled postgis database that Strabon will use as a backend, ");
    6.25 +			System.err.println("             <USERNAME>   is the username to use when connecting to the database ");
    6.26 +			System.err.println("             <PASSWORD>   is the password to use when connecting to the database");
    6.27 +			System.err.println("             <PATH>      is the path containing all stSPARQL queries to evaluate.");
    6.28 +			System.err.println("             [<FORMAT>]     is the format of your results (XML)");
    6.29 +			System.exit(0);
    6.30 +		}
    6.31 +
    6.32 +		String host = args[0];
    6.33 +		Integer port = new Integer(args[1]);
    6.34 +		String db = args[2];
    6.35 +		String user = args[3];
    6.36 +		String passwd = args[4];		
    6.37 +		String path = args[5];
    6.38 +		String resultsFormat = "";
    6.39 +		if ( args.length == 7 ) {
    6.40 +			resultsFormat = args[6];
    6.41 +		}
    6.42 +
    6.43 +
    6.44 +
    6.45 +
    6.46 +		Strabon strabon = new Strabon(db, user, passwd, port, host, true);
    6.47 +
    6.48 +		File dir = new File(path);
    6.49 +		String[] children = dir.list();
    6.50 +		if (children != null) {
    6.51 +			for (int i=0; i<children.length; i++) {
    6.52 +				String filename = children[i];
    6.53 +				try {
    6.54 +					String queryString = readFile(path + System.getProperty("file.separator") + filename);
    6.55 +					strabon.query(queryString, resultsFormat, strabon.getSailRepoConnection());
    6.56 +				} catch (IOException e) {
    6.57 +					System.err.println("IOException while reading " + filename);
    6.58 +				}
    6.59 +			}
    6.60 +		}
    6.61 +		
    6.62 +		strabon.close();
    6.63 +	}
    6.64 +
    6.65 +	private static String readFile(String file) throws IOException {
    6.66 +		BufferedReader reader = new BufferedReader( new FileReader(file));
    6.67 +		String line  = null;
    6.68 +		StringBuilder stringBuilder = new StringBuilder();
    6.69 +		String ls = System.getProperty("line.separator");
    6.70 +		while( ( line = reader.readLine() ) != null ) {
    6.71 +			stringBuilder.append( line );
    6.72 +			stringBuilder.append( ls );
    6.73 +		}
    6.74 +		return stringBuilder.toString();
    6.75 +	}
    6.76 +
    6.77 +	/*
    6.78 +	private static void query(String queryString, SailRepositoryConnection con) throws MalformedQueryException, RepositoryException, QueryEvaluationException, IOException, ClassNotFoundException, TupleQueryResultHandlerException {
    6.79 +		TupleQuery tupleQuery = con.prepareTupleQuery(QueryLanguage.SPARQL, queryString);
    6.80 +
    6.81 +		System.out.println(queryString);
    6.82 +		TupleQueryResult result = tupleQuery.evaluate();
    6.83 +
    6.84 +		System.out.println("-------------------------------------------");
    6.85 +		System.out.println("-                RESULTS                  -");
    6.86 +		System.out.println("-------------------------------------------");
    6.87 +
    6.88 +		tupleQuery.evaluate(new SPARQLResultsXMLWriter(System.out));
    6.89 +
    6.90 +		List<String> bindingNames = result.getBindingNames();
    6.91 +		while (result.hasNext()) {
    6.92 +			BindingSet bindingSet = result.next();			
    6.93 +			System.out.println(bindingSet.toString());
    6.94 +		}
    6.95 +		System.out.println("-------------------------------------------");
    6.96 +		System.out.flush();
    6.97 +	}
    6.98 +	 */
    6.99 +}
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/strabon	Wed Feb 29 13:41:48 2012 +0200
     7.3 @@ -0,0 +1,27 @@
     7.4 +#! /bin/bash
     7.5 +
     7.6 +dbName=$1
     7.7 +dirs=$2
     7.8 +
     7.9 +# Evaluates a query using Strabon that is stored in $dir
    7.10 +#dir='/home/ggarbis/workspaces/Strabon-workspace/Strabon/jars/target'
    7.11 +dir='/home/kkyzir/teleios/nkua/Strabon/jars/target'
    7.12 +
    7.13 +# Arguments for QueryDir
    7.14 +HOST='localhost'
    7.15 +PORT='50000'
    7.16 +DATABASE=$dbName
    7.17 +USERNAME='monetdb'
    7.18 +PASSWORD='monetdb'
    7.19 +FORMAT=''
    7.20 +DIRS=$2
    7.21 +
    7.22 +# Construct classpath with dependencies
    7.23 +cd $dir &&
    7.24 +for file in `ls -1 *.jar`;
    7.25 +do 
    7.26 +	myVar=$myVar./$file":";
    7.27 +done;
    7.28 +
    7.29 +# Evaluate a query
    7.30 +java -Xmx5000M -cp $myVar eu.earthobservatory.runtime.monetdb.QueryDir $HOST $PORT $DATABASE $USERNAME $PASSWORD "$DIRS" $FORMAT