Strabon

changeset 15:b617bb3ba9d6

Add operations for monetdb
author Giorgos Garbis <ggarbis@di.uoa.gr>
date Tue Feb 14 13:37:33 2012 +0200 (2012-02-14)
parents f1bf401243e3
children 0e4ea11c0861
files runtime/src/main/java/eu/earthobservatory/runtime/monetdb/DescribeOp.java runtime/src/main/java/eu/earthobservatory/runtime/monetdb/QueryOp.java runtime/src/main/java/eu/earthobservatory/runtime/monetdb/StoreOp.java runtime/src/main/java/eu/earthobservatory/runtime/monetdb/UpdateOp.java
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/runtime/src/main/java/eu/earthobservatory/runtime/monetdb/DescribeOp.java	Tue Feb 14 13:37:33 2012 +0200
     1.3 @@ -0,0 +1,37 @@
     1.4 +package eu.earthobservatory.runtime.monetdb;
     1.5 +
     1.6 +
     1.7 +public class DescribeOp {
     1.8 +
     1.9 +	/**
    1.10 +	 * @param args
    1.11 +	 * @throws Exception 
    1.12 +	 */
    1.13 +	public static void main(String[] args) throws Exception {
    1.14 +
    1.15 +		if (args.length < 7) {
    1.16 +			System.err.println("Usage: eu.ist.semsorgrid4env.strabon.Strabon <HOST> <PORT> <DATABASE> <USERNAME> <PASSWORD> <QUERY> <OUTPUT>");
    1.17 +			System.err.println("       where <HOST>       is the postgis database host to connect to");
    1.18 +			System.err.println("             <PORT>       is the port to connect to on the database host");		
    1.19 +			System.err.println("             <DATABASE>   is the spatially enabled postgis database that Strabon will use as a backend, ");
    1.20 +			System.err.println("             <USERNAME>   is the username to use when connecting to the database ");
    1.21 +			System.err.println("             <PASSWORD>   is the password to use when connecting to the database");
    1.22 +			System.err.println("             <QUERY>      is the stSPARQL query to evaluate.");
    1.23 +			System.err.println("             <OUTPUT>      is the stSPARQL query to evaluate.");
    1.24 +			System.exit(0);
    1.25 +		}
    1.26 +
    1.27 +		String host = args[0];
    1.28 +		Integer port = new Integer(args[1]);
    1.29 +		String db = args[2];
    1.30 +		String user = args[3];
    1.31 +		String passwd = args[4];		
    1.32 +		String queryString = args[5];
    1.33 +		String outFile = args[6];
    1.34 +		
    1.35 +		Strabon strabon = new Strabon(db, user, passwd, port, host, true);
    1.36 +		strabon.describe(queryString, strabon.getSailRepoConnection(), outFile);
    1.37 +
    1.38 +		strabon.close();
    1.39 +	}
    1.40 +}
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/runtime/src/main/java/eu/earthobservatory/runtime/monetdb/QueryOp.java	Tue Feb 14 13:37:33 2012 +0200
     2.3 @@ -0,0 +1,66 @@
     2.4 +package eu.earthobservatory.runtime.monetdb;
     2.5 +
     2.6 +
     2.7 +public class QueryOp {
     2.8 +
     2.9 +	/**
    2.10 +	 * @param args
    2.11 +	 * @throws Exception 
    2.12 +	 */
    2.13 +	public static void main(String[] args) throws Exception {
    2.14 +
    2.15 +		if (args.length < 6) {
    2.16 +			System.err.println("Usage: eu.ist.semsorgrid4env.strabon.Strabon <HOST> <PORT> <DATABASE> <USERNAME> <PASSWORD> <QUERY> ");
    2.17 +			System.err.println("       where <HOST>       is the postgis database host to connect to");
    2.18 +			System.err.println("             <PORT>       is the port to connect to on the database host");		
    2.19 +			System.err.println("             <DATABASE>   is the spatially enabled postgis database that Strabon will use as a backend, ");
    2.20 +			System.err.println("             <USERNAME>   is the username to use when connecting to the database ");
    2.21 +			System.err.println("             <PASSWORD>   is the password to use when connecting to the database");
    2.22 +			System.err.println("             <QUERY>      is the stSPARQL query to evaluate.");
    2.23 +			System.err.println("             [<FORMAT>]     is the format of your results (XML)");
    2.24 +			System.exit(0);
    2.25 +		}
    2.26 +
    2.27 +		String host = args[0];
    2.28 +		Integer port = new Integer(args[1]);
    2.29 +		String db = args[2];
    2.30 +		String user = args[3];
    2.31 +		String passwd = args[4];		
    2.32 +		String queryString = args[5];
    2.33 +		String resultsFormat = "";
    2.34 +		if ( args.length == 7 ) {
    2.35 +			resultsFormat = args[6];
    2.36 +		}
    2.37 +
    2.38 +
    2.39 +
    2.40 +
    2.41 +		Strabon strabon = new Strabon(db, user, passwd, port, host, true);
    2.42 +
    2.43 +		strabon.query(queryString, resultsFormat, strabon.getSailRepoConnection());
    2.44 +
    2.45 +		strabon.close();
    2.46 +	}
    2.47 +	/*
    2.48 +	private static void query(String queryString, SailRepositoryConnection con) throws MalformedQueryException, RepositoryException, QueryEvaluationException, IOException, ClassNotFoundException, TupleQueryResultHandlerException {
    2.49 +		TupleQuery tupleQuery = con.prepareTupleQuery(QueryLanguage.SPARQL, queryString);
    2.50 +
    2.51 +		System.out.println(queryString);
    2.52 +		TupleQueryResult result = tupleQuery.evaluate();
    2.53 +
    2.54 +		System.out.println("-------------------------------------------");
    2.55 +		System.out.println("-                RESULTS                  -");
    2.56 +		System.out.println("-------------------------------------------");
    2.57 +
    2.58 +		tupleQuery.evaluate(new SPARQLResultsXMLWriter(System.out));
    2.59 +
    2.60 +		List<String> bindingNames = result.getBindingNames();
    2.61 +		while (result.hasNext()) {
    2.62 +			BindingSet bindingSet = result.next();			
    2.63 +			System.out.println(bindingSet.toString());
    2.64 +		}
    2.65 +		System.out.println("-------------------------------------------");
    2.66 +		System.out.flush();
    2.67 +	}
    2.68 +	 */
    2.69 +}
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/runtime/src/main/java/eu/earthobservatory/runtime/monetdb/StoreOp.java	Tue Feb 14 13:37:33 2012 +0200
     3.3 @@ -0,0 +1,46 @@
     3.4 +package eu.earthobservatory.runtime.monetdb;
     3.5 +
     3.6 +import java.io.File;
     3.7 +
     3.8 +
     3.9 +public class StoreOp {
    3.10 +
    3.11 +	/**
    3.12 +	 * @param args
    3.13 +	 * @throws Exception 
    3.14 +	 */
    3.15 +	public static void main(String[] args) throws Exception {
    3.16 +
    3.17 +		if (args.length < 6) {
    3.18 +			System.err.println("Usage: eu.ist.semsorgrid4env.strabon.Strabon <HOST> <PORT> <DATABASE> <USERNAME> <PASSWORD> <QUERY> ");
    3.19 +			System.err.println("       where <HOST>       is the postgis database host to connect to");
    3.20 +			System.err.println("             <PORT>       is the port to connect to on the database host");		
    3.21 +			System.err.println("             <DATABASE>   is the spatially enabled postgis database that Strabon will use as a backend, ");
    3.22 +			System.err.println("             <USERNAME>   is the username to use when connecting to the database ");
    3.23 +			System.err.println("             <PASSWORD>   is the password to use when connecting to the database");
    3.24 +			System.err.println("             <FILE>       is the file to be stored");
    3.25 +			System.err.println("             [<FORMAT>]   is the format of the file (NTRIPLES)");
    3.26 +			System.exit(0);
    3.27 +		}
    3.28 +
    3.29 +		String host = args[0];
    3.30 +		Integer port = new Integer(args[1]);
    3.31 +		String db = args[2];
    3.32 +		String user = args[3];
    3.33 +		String passwd = args[4];		
    3.34 +		String src = args[5];
    3.35 +		String format = "NTRIPLES";
    3.36 +		if ( args.length == 7 ) {
    3.37 +			format = args[6];
    3.38 +		}
    3.39 +
    3.40 +		Strabon strabon = new Strabon(db, user, passwd, port, host, true);
    3.41 +		
    3.42 +		File file = new File (src);
    3.43 +		strabon.storeInRepo(file, format);
    3.44 +//		strabon.storeInRepo(file, null, null, fileRDFFormat);
    3.45 +
    3.46 +		strabon.close();
    3.47 +	}
    3.48 +
    3.49 +}
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/runtime/src/main/java/eu/earthobservatory/runtime/monetdb/UpdateOp.java	Tue Feb 14 13:37:33 2012 +0200
     4.3 @@ -0,0 +1,36 @@
     4.4 +package eu.earthobservatory.runtime.monetdb;
     4.5 +
     4.6 +
     4.7 +public class UpdateOp {
     4.8 +
     4.9 +	/**
    4.10 +	 * @param args
    4.11 +	 * @throws Exception 
    4.12 +	 */
    4.13 +	public static void main(String[] args) throws Exception {
    4.14 +
    4.15 +		if (args.length < 6) {
    4.16 +			System.err.println("Usage: eu.ist.semsorgrid4env.strabon.Strabon <HOST> <PORT> <DATABASE> <USERNAME> <PASSWORD> <UPDATE> ");
    4.17 +			System.err.println("       where <HOST>       is the postgis database host to connect to");
    4.18 +			System.err.println("             <PORT>       is the port to connect to on the database host");		
    4.19 +			System.err.println("             <DATABASE>   is the spatially enabled postgis database that Strabon will use as a backend, ");
    4.20 +			System.err.println("             <USERNAME>   is the username to use when connecting to the database ");
    4.21 +			System.err.println("             <PASSWORD>   is the password to use when connecting to the database");
    4.22 +			System.err.println("             <UPDATE>     is the stSPARQL update query to evaluate.");
    4.23 +			System.exit(0);
    4.24 +		}
    4.25 +
    4.26 +		String host = args[0];
    4.27 +		Integer port = new Integer(args[1]);
    4.28 +		String db = args[2];
    4.29 +		String user = args[3];
    4.30 +		String passwd = args[4];		
    4.31 +		String queryString = args[5];
    4.32 +		
    4.33 +		Strabon strabon = new Strabon(db, user, passwd, port, host, true);
    4.34 +
    4.35 +		strabon.update(queryString, strabon.getSailRepoConnection());
    4.36 +
    4.37 +		strabon.close();
    4.38 +	}
    4.39 +}