Strabon

changeset 1062:c2e43cb108d9

Added a parameter that enables/disables inference.
author Panayiotis Smeros <psmeros@di.uoa.gr>
date Mon Apr 22 14:24:39 2013 +0300 (2013-04-22)
parents b903c47cc189
children 94cac9923a49
files runtime/src/main/java/eu/earthobservatory/runtime/generaldb/GeosparqlRDFHandlerBase.java runtime/src/main/java/eu/earthobservatory/runtime/generaldb/Strabon.java runtime/src/main/java/eu/earthobservatory/runtime/monetdb/StoreOp.java runtime/src/main/java/eu/earthobservatory/runtime/postgis/StoreOp.java runtime/src/test/java/eu/earthobservatory/runtime/monetdb/TemplateTests.java runtime/src/test/java/eu/earthobservatory/runtime/postgis/TemplateTests.java testsuite/src/test/java/eu/earthobservatory/testsuite/utils/Utils.java
line diff
     1.1 --- a/runtime/src/main/java/eu/earthobservatory/runtime/generaldb/GeosparqlRDFHandlerBase.java	Mon Apr 22 13:26:52 2013 +0300
     1.2 +++ b/runtime/src/main/java/eu/earthobservatory/runtime/generaldb/GeosparqlRDFHandlerBase.java	Mon Apr 22 14:24:39 2013 +0300
     1.3 @@ -39,12 +39,13 @@
     1.4   * 
     1.5   * @author Charalampos Nikolaou <charnik@di.uoa.gr>
     1.6   * @author Konstantina Bereta <konstantina.bereta@di.uoa.gr>
     1.7 + * @author Panayiotis Smeros <psmeros@di.uoa.gr>
     1.8   */
     1.9  public class GeosparqlRDFHandlerBase extends RDFInserter {
    1.10  	
    1.11  	private static final Logger logger = LoggerFactory.getLogger(eu.earthobservatory.runtime.generaldb.GeosparqlRDFHandlerBase.class);
    1.12  	
    1.13 -	private static final boolean ENABLE_INFERENCE = false;
    1.14 +	public static boolean ENABLE_INFERENCE;
    1.15  	
    1.16  	/**
    1.17  	 * Keeps a String to URI mapping for the URIs of Simple Features and GML
     2.1 --- a/runtime/src/main/java/eu/earthobservatory/runtime/generaldb/Strabon.java	Mon Apr 22 13:26:52 2013 +0300
     2.2 +++ b/runtime/src/main/java/eu/earthobservatory/runtime/generaldb/Strabon.java	Mon Apr 22 14:24:39 2013 +0300
     2.3 @@ -307,15 +307,17 @@
     2.4  		}
     2.5  	}
     2.6  
     2.7 -	public void storeInRepo(String src, String format) throws RDFParseException, RepositoryException, IOException, RDFHandlerException, InvalidDatasetFormatFault
     2.8 +	public void storeInRepo(String src, String format, Boolean inference) throws RDFParseException, RepositoryException, IOException, RDFHandlerException, InvalidDatasetFormatFault
     2.9  	{
    2.10 -		storeInRepo(src, null, null, format);
    2.11 +		storeInRepo(src, null, null, format, inference);
    2.12  	}
    2.13  
    2.14 -	public void storeInRepo(String src, String baseURI, String context, String format) throws RDFParseException, RepositoryException, IOException, RDFHandlerException, InvalidDatasetFormatFault
    2.15 +	public void storeInRepo(String src, String baseURI, String context, String format, Boolean inference) throws RDFParseException, RepositoryException, IOException, RDFHandlerException, InvalidDatasetFormatFault
    2.16  	{
    2.17  		RDFFormat realFormat = null;
    2.18  
    2.19 +		GeosparqlRDFHandlerBase.ENABLE_INFERENCE=inference;
    2.20 +		
    2.21  		if ((baseURI != null) && (baseURI.equals(""))) {
    2.22  			baseURI = null;
    2.23  		}
     3.1 --- a/runtime/src/main/java/eu/earthobservatory/runtime/monetdb/StoreOp.java	Mon Apr 22 13:26:52 2013 +0300
     3.2 +++ b/runtime/src/main/java/eu/earthobservatory/runtime/monetdb/StoreOp.java	Mon Apr 22 14:24:39 2013 +0300
     3.3 @@ -35,6 +35,7 @@
     3.4  		String src = args[5];
     3.5  		String format = "NTRIPLES";
     3.6  		String graph = null;
     3.7 +		Boolean inference = false;
     3.8  		
     3.9  		for (int i = 6; i < args.length; i += 2) {
    3.10  			if (args[i].equals("-f")) {
    3.11 @@ -54,12 +55,21 @@
    3.12  					
    3.13  				} else {
    3.14  					graph = args[i+1];
    3.15 +				}			
    3.16 +			} else if (args[i].equals("-i")) {
    3.17 +				if (i + 1 >= args.length) {
    3.18 +					System.err.println("Option \"-i\" requires an argument.");
    3.19 +					help();
    3.20 +					System.exit(1);
    3.21 +					
    3.22 +				} else {
    3.23 +					inference = Boolean.valueOf(args[i+1]);
    3.24  				}
    3.25  				
    3.26  			} else {
    3.27 -				System.err.println("Unknown argument \"" + args[i] + "\".");
    3.28 -				help();
    3.29 -				System.exit(1);
    3.30 +					System.err.println("Unknown argument \"" + args[i] + "\".");
    3.31 +					help();
    3.32 +					System.exit(1);
    3.33  			}
    3.34  		}
    3.35  
    3.36 @@ -67,10 +77,10 @@
    3.37  		try {
    3.38  			strabon = new Strabon(db, user, passwd, port, host, false);
    3.39  			if (graph == null) {
    3.40 -				strabon.storeInRepo(src, format);
    3.41 +				strabon.storeInRepo(src, format, inference);
    3.42  				
    3.43  			} else {
    3.44 -				strabon.storeInRepo(src, null, graph, format);
    3.45 +				strabon.storeInRepo(src, null, graph, format, inference);
    3.46  			}
    3.47  		
    3.48  		} catch (Exception e) {
    3.49 @@ -84,15 +94,16 @@
    3.50  	}
    3.51  	
    3.52  	private static void help() {
    3.53 -		System.err.println("Usage: eu.earthobservatory.runtime.monetdb.StoreOp <HOST> <PORT> <DATABASE> <USERNAME> <PASSWORD> <FILE> [-f <FORMAT>] [-g <NAMED_GRAPH>]");
    3.54 +		System.err.println("Usage: eu.earthobservatory.runtime.monetdb.StoreOp <HOST> <PORT> <DATABASE> <USERNAME> <PASSWORD> <FILE> [-f <FORMAT>] [-g <NAMED_GRAPH>] [-i <INFERENCE>]");
    3.55  		System.err.println("       where <HOST>       		 is the postgis database host to connect to");
    3.56  		System.err.println("             <PORT>       		 is the port to connect to on the database host");		
    3.57 -		System.err.println("             <DATABASE>   		 is the spatially enabled postgis database that Strabon will use as a backend, ");
    3.58 -		System.err.println("             <USERNAME>   		 is the username to use when connecting to the database ");
    3.59 +		System.err.println("             <DATABASE>   		 is the spatially enabled postgis database that Strabon will use as a backend");
    3.60 +		System.err.println("             <USERNAME>   		 is the username to use when connecting to the database");
    3.61  		System.err.println("             <PASSWORD>   		 is the password to use when connecting to the database");
    3.62  		System.err.println("             <FILE>       		 is the file to be stored");
    3.63  		System.err.println("             [-f <FORMAT>] 		 is the format of the file (default: NTRIPLES)");
    3.64  		System.err.println("             [-g <NAMED_GRAPH>]  is the URI of the named graph to store the input file (default: default graph)");
    3.65 +		System.err.println("             [-i <INFERENCE>] 	 is true when inference is enabled (default: false)");
    3.66  	}
    3.67  
    3.68  }
     4.1 --- a/runtime/src/main/java/eu/earthobservatory/runtime/postgis/StoreOp.java	Mon Apr 22 13:26:52 2013 +0300
     4.2 +++ b/runtime/src/main/java/eu/earthobservatory/runtime/postgis/StoreOp.java	Mon Apr 22 14:24:39 2013 +0300
     4.3 @@ -35,6 +35,7 @@
     4.4  		String src = args[5];
     4.5  		String format = "NTRIPLES";
     4.6  		String graph = null;
     4.7 +		Boolean inference = false;
     4.8  		
     4.9  		for (int i = 6; i < args.length; i += 2) {
    4.10  			if (args[i].equals("-f")) {
    4.11 @@ -54,8 +55,17 @@
    4.12  					
    4.13  				} else {
    4.14  					graph = args[i+1];
    4.15 -				}
    4.16 -				
    4.17 +				}	
    4.18 +			} else if (args[i].equals("-i")) {
    4.19 +					if (i + 1 >= args.length) {
    4.20 +						System.err.println("Option \"-i\" requires an argument.");
    4.21 +						help();
    4.22 +						System.exit(1);
    4.23 +						
    4.24 +					} else {
    4.25 +						inference = Boolean.valueOf(args[i+1]);
    4.26 +					}
    4.27 +					
    4.28  			} else {
    4.29  				System.err.println("Unknown argument \"" + args[i] + "\".");
    4.30  				help();
    4.31 @@ -67,10 +77,10 @@
    4.32  		try {
    4.33  			strabon = new Strabon(db, user, passwd, port, host, false);
    4.34  			if (graph == null) {
    4.35 -				strabon.storeInRepo(src, format);
    4.36 +				strabon.storeInRepo(src, format, inference);
    4.37  				
    4.38  			} else {
    4.39 -				strabon.storeInRepo(src, null, graph, format);
    4.40 +				strabon.storeInRepo(src, null, graph, format, inference);
    4.41  			}
    4.42  			
    4.43  		} catch (Exception e) {
    4.44 @@ -84,14 +94,16 @@
    4.45  	}
    4.46  
    4.47  	private static void help() {
    4.48 -		System.err.println("Usage: eu.earthobservatory.runtime.postgis.StoreOp <HOST> <PORT> <DATABASE> <USERNAME> <PASSWORD> <FILE> [-f <FORMAT>] [-g <NAMED_GRAPH>]");
    4.49 +		System.err.println("Usage: eu.earthobservatory.runtime.postgis.StoreOp <HOST> <PORT> <DATABASE> <USERNAME> <PASSWORD> <FILE> [-f <FORMAT>] [-g <NAMED_GRAPH>] [-i <INFERENCE>]");
    4.50  		System.err.println("       where <HOST>       		 is the postgis database host to connect to");
    4.51  		System.err.println("             <PORT>       		 is the port to connect to on the database host");		
    4.52 -		System.err.println("             <DATABASE>   		 is the spatially enabled postgis database that Strabon will use as a backend, ");
    4.53 -		System.err.println("             <USERNAME>   		 is the username to use when connecting to the database ");
    4.54 +		System.err.println("             <DATABASE>   		 is the spatially enabled postgis database that Strabon will use as a backend");
    4.55 +		System.err.println("             <USERNAME>   		 is the username to use when connecting to the database");
    4.56  		System.err.println("             <PASSWORD>   		 is the password to use when connecting to the database");
    4.57  		System.err.println("             <FILE>       		 is the file to be stored");
    4.58  		System.err.println("             [-f <FORMAT>] 		 is the format of the file (default: NTRIPLES)");
    4.59  		System.err.println("             [-g <NAMED_GRAPH>]  is the URI of the named graph to store the input file (default: default graph)");
    4.60 +		System.err.println("             [-i <INFERENCE>] 	 is true when inference is enabled (default: false)");
    4.61 +
    4.62  	}
    4.63  }
     5.1 --- a/runtime/src/test/java/eu/earthobservatory/runtime/monetdb/TemplateTests.java	Mon Apr 22 13:26:52 2013 +0300
     5.2 +++ b/runtime/src/test/java/eu/earthobservatory/runtime/monetdb/TemplateTests.java	Mon Apr 22 14:24:39 2013 +0300
     5.3 @@ -84,7 +84,7 @@
     5.4  	protected static void loadTestData(String inputfile, Strabon strabon)
     5.5  			throws RDFParseException, RepositoryException, IOException, RDFHandlerException, InvalidDatasetFormatFault
     5.6  		{
     5.7 -			strabon.storeInRepo(inputfile, "NTRIPLES");
     5.8 +			strabon.storeInRepo(inputfile, "NTRIPLES", false);
     5.9  		}
    5.10  	
    5.11  //	/**
     6.1 --- a/runtime/src/test/java/eu/earthobservatory/runtime/postgis/TemplateTests.java	Mon Apr 22 13:26:52 2013 +0300
     6.2 +++ b/runtime/src/test/java/eu/earthobservatory/runtime/postgis/TemplateTests.java	Mon Apr 22 14:24:39 2013 +0300
     6.3 @@ -127,7 +127,7 @@
     6.4  	protected static void loadTestData(String inputfile, Strabon strabon)
     6.5  		throws RDFParseException, RepositoryException, IOException, RDFHandlerException, InvalidDatasetFormatFault
     6.6  	{
     6.7 -		strabon.storeInRepo(inputfile, "NTRIPLES");
     6.8 +		strabon.storeInRepo(inputfile, "NTRIPLES", false);
     6.9  	}
    6.10  
    6.11  	
     7.1 --- a/testsuite/src/test/java/eu/earthobservatory/testsuite/utils/Utils.java	Mon Apr 22 13:26:52 2013 +0300
     7.2 +++ b/testsuite/src/test/java/eu/earthobservatory/testsuite/utils/Utils.java	Mon Apr 22 14:24:39 2013 +0300
     7.3 @@ -141,9 +141,9 @@
     7.4  	public static void storeDataset(String datasetFile) throws RDFParseException, RepositoryException, RDFHandlerException, IOException, InvalidDatasetFormatFault
     7.5  	{
     7.6  	    if(datasetFile.endsWith(".nt"))
     7.7 -	    	strabon.storeInRepo(datasetFile, "NTRIPLES");
     7.8 +	    	strabon.storeInRepo(datasetFile, "NTRIPLES", false);
     7.9  	    else if(datasetFile.endsWith(".nq"))
    7.10 -	    	strabon.storeInRepo(datasetFile, "NQUADS");
    7.11 +	    	strabon.storeInRepo(datasetFile, "NQUADS", false);
    7.12  	}
    7.13  	
    7.14  	public static void testQuery(String queryFile, String resultsFile) throws IOException, MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, URISyntaxException, QueryResultParseException, UnsupportedQueryResultFormatException