Strabon

changeset 731:35884bc15005 temporals

merge
author Konstantina Bereta <Konstantina.Bereta@di.uoa.gr>
date Thu Nov 22 19:34:08 2012 +0200 (2012-11-22)
parents 115bc7ddabb9 b27eb70e7bd6
children 09fc776e43be
files generaldb/src/main/java/org/openrdf/sail/generaldb/evaluation/GeneralDBEvaluation.java generaldb/src/main/java/org/openrdf/sail/generaldb/evaluation/GeneralDBQueryBuilder.java generaldb/src/main/java/org/openrdf/sail/generaldb/iteration/GeneralDBBindingIteration.java generaldb/src/main/java/org/openrdf/sail/generaldb/optimizers/GeneralDBSelectQueryOptimizer.java monetdb/src/main/java/org/openrdf/sail/monetdb/iteration/MonetDBBindingIteration.java postgis/src/main/java/org/openrdf/sail/postgis/evaluation/PostGISQueryBuilder.java postgis/src/main/java/org/openrdf/sail/postgis/iteration/PostGISBindingIteration.java runtime/src/test/java/eu/earthobservatory/runtime/generaldb/GeneralTests.java runtime/src/test/java/eu/earthobservatory/runtime/generaldb/JoinTests.java runtime/src/test/resources/databases.properties
line diff
     1.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/evaluation/GeneralDBEvaluation.java	Thu Nov 22 17:43:47 2012 +0200
     1.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/evaluation/GeneralDBEvaluation.java	Thu Nov 22 19:34:08 2012 +0200
     1.3 @@ -126,7 +126,6 @@
     1.4  
     1.5  	protected HashMap<Integer,String> geoNames = new HashMap<Integer,String>();
     1.6  	
     1.7 -
     1.8  	protected List<GeneralDBSqlExpr> thematicExpressions = new ArrayList<GeneralDBSqlExpr>(5);
     1.9  	
    1.10  	/**
    1.11 @@ -722,7 +721,7 @@
    1.12  							//I am carrying SRID too! Therefore, shifting index one more position
    1.13  							index++;
    1.14  						}
    1.15 -						else if(var.isTemporal()) //i metavliti mpore na einai eite spatial eite temporal
    1.16 +						if(var.isTemporal()) 
    1.17  						{
    1.18  							this.temporalVars.put(var.getIndex()+1,var.getName());
    1.19  							//no SRID here, a single shift is needed
     2.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/evaluation/GeneralDBQueryBuilder.java	Thu Nov 22 17:43:47 2012 +0200
     2.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/evaluation/GeneralDBQueryBuilder.java	Thu Nov 22 19:34:08 2012 +0200
     2.3 @@ -113,6 +113,7 @@
     2.4  import org.openrdf.sail.generaldb.algebra.sf.GeneralDBSqlSF_Overlaps;
     2.5  import org.openrdf.sail.generaldb.algebra.sf.GeneralDBSqlSF_Touches;
     2.6  import org.openrdf.sail.generaldb.algebra.sf.GeneralDBSqlSF_Within;
     2.7 +import org.openrdf.sail.generaldb.algebra.temporal.GeneralDBSqlAfterPeriod;
     2.8  import org.openrdf.sail.generaldb.algebra.temporal.GeneralDBSqlPeriodContainedBy;
     2.9  import org.openrdf.sail.generaldb.algebra.temporal.GeneralDBSqlPeriodContains;
    2.10  import org.openrdf.sail.generaldb.algebra.temporal.GeneralDBSqlPeriodIntersection;
    2.11 @@ -1278,4 +1279,10 @@
    2.12  		throws UnsupportedRdbmsOperatorException {
    2.13  }
    2.14  
    2.15 +protected void append(GeneralDBSqlAfterPeriod expr,
    2.16 +		GeneralDBSqlExprBuilder filter)
    2.17 +		throws UnsupportedRdbmsOperatorException {
    2.18 +	
    2.19  }
    2.20 +
    2.21 +}
     3.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/iteration/GeneralDBBindingIteration.java	Thu Nov 22 17:43:47 2012 +0200
     3.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/iteration/GeneralDBBindingIteration.java	Thu Nov 22 19:34:08 2012 +0200
     3.3 @@ -138,15 +138,20 @@
     3.4  			if (var != null && !result.hasBinding(name)) {
     3.5  				Value value = var.getValue();
     3.6  				if (value == null) {
     3.7 -					if(!var.isSpatial())
     3.8 +					
     3.9 +					if(var.isSpatial())
    3.10 +					{
    3.11 +						value = createGeoValue(rs, var.getIndex() + 1);
    3.12 +					}
    3.13 +					else if(var.isTemporal())
    3.14 +					{
    3.15 +						value = createTemporalValue(rs,var.getIndex()+1);
    3.16 +					}
    3.17 +					else
    3.18  					{
    3.19  						//default action
    3.20  						value = createValue(rs, var.getIndex() + 1);
    3.21  					}
    3.22 -					else//geoVar encountered
    3.23 -					{
    3.24 -						value = createGeoValue(rs, var.getIndex() + 1);
    3.25 -					}
    3.26  				}
    3.27  				if (value != null) {
    3.28  					result.addBinding(var.getName(), value);
    3.29 @@ -221,6 +226,8 @@
    3.30  	protected abstract RdbmsValue createGeoValue(ResultSet rs, int index)
    3.31  	throws SQLException;
    3.32  
    3.33 +	protected abstract RdbmsValue createTemporalValue(ResultSet rs, int index)
    3.34 +	throws SQLException;
    3.35  
    3.36  
    3.37  	protected abstract RdbmsValue createBinaryGeoValueForSelectConstructs(ResultSet rs, int index)
     4.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/optimizers/GeneralDBSelectQueryOptimizer.java	Thu Nov 22 17:43:47 2012 +0200
     4.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/optimizers/GeneralDBSelectQueryOptimizer.java	Thu Nov 22 19:34:08 2012 +0200
     4.3 @@ -1005,7 +1005,7 @@
     4.4  					}
     4.5  				}
     4.6  			}
     4.7 -
     4.8 +			System.out.println("NOT SPATIAL NOR TEMPORAL FUNCTION- SIMPLE VALUE");
     4.9  		
    4.10  		
    4.11  
     5.1 --- a/monetdb/src/main/java/org/openrdf/sail/monetdb/iteration/MonetDBBindingIteration.java	Thu Nov 22 17:43:47 2012 +0200
     5.2 +++ b/monetdb/src/main/java/org/openrdf/sail/monetdb/iteration/MonetDBBindingIteration.java	Thu Nov 22 19:34:08 2012 +0200
     5.3 @@ -66,4 +66,11 @@
     5.4  		int srid = rs.getInt(index + 2);
     5.5  		return vf.getRdbmsPolyhedron(114, GeoConstants.WKT, label, srid);
     5.6  	}
     5.7 +
     5.8 +	@Override
     5.9 +	protected RdbmsValue createTemporalValue(ResultSet rs, int index)
    5.10 +			throws SQLException {
    5.11 +		// TODO Auto-generated method stub
    5.12 +		return null;
    5.13 +	}
    5.14  }
    5.15 \ No newline at end of file
     6.1 --- a/postgis/src/main/java/org/openrdf/sail/postgis/evaluation/PostGISQueryBuilder.java	Thu Nov 22 17:43:47 2012 +0200
     6.2 +++ b/postgis/src/main/java/org/openrdf/sail/postgis/evaluation/PostGISQueryBuilder.java	Thu Nov 22 19:34:08 2012 +0200
     6.3 @@ -969,17 +969,25 @@
     6.4  	protected void append(GeneralDBSqlPeriodContains expr, GeneralDBSqlExprBuilder filter)
     6.5  			throws UnsupportedRdbmsOperatorException
     6.6  			{
     6.7 -		appendGeneralDBSpatialFunctionBinary(expr, filter, SpatialFunctionsPostGIS.ST_IsEmpty);
     6.8 +		appendGeneralDBTemporalFunctionBinary(expr, filter, expr.getOperator());
     6.9  			}
    6.10  
    6.11  	@Override
    6.12  	protected void append(GeneralDBSqlPeriodOverlaps expr, GeneralDBSqlExprBuilder filter)
    6.13  			throws UnsupportedRdbmsOperatorException
    6.14  			{
    6.15 -		//appendGeneralDBSpatialFunctionUnary(expr, filter, SpatialFunctionsPostGIS.ST_IsEmpty);
    6.16 +		appendGeneralDBTemporalFunctionBinary(expr, filter, expr.getOperator());
    6.17  			}
    6.18  
    6.19  	@Override
    6.20 +	protected void append(GeneralDBSqlAfterPeriod expr, GeneralDBSqlExprBuilder filter)
    6.21 +			throws UnsupportedRdbmsOperatorException
    6.22 +			{
    6.23 +		appendGeneralDBTemporalFunctionBinary(expr, filter, expr.getOperator());
    6.24 +			}
    6.25 +
    6.26 +	
    6.27 +	@Override
    6.28  	protected void append(GeneralDBSqlPeriodIntersection expr, GeneralDBSqlExprBuilder filter)
    6.29  			throws UnsupportedRdbmsOperatorException
    6.30  			{
     7.1 --- a/postgis/src/main/java/org/openrdf/sail/postgis/iteration/PostGISBindingIteration.java	Thu Nov 22 17:43:47 2012 +0200
     7.2 +++ b/postgis/src/main/java/org/openrdf/sail/postgis/iteration/PostGISBindingIteration.java	Thu Nov 22 19:34:08 2012 +0200
     7.3 @@ -53,6 +53,18 @@
     7.4  
     7.5  		return createResource(rs, index);
     7.6  	}
     7.7 +	
     7.8 +	
     7.9 +	//constant- do the same for the temporal case
    7.10 +	@Override
    7.11 +	protected RdbmsValue createTemporalValue(ResultSet rs, int index)
    7.12 +	throws SQLException
    7.13 +	{
    7.14 +//TODO implement method 
    7.15 +		System.out.println("CREATE TEMPORAL VALUE!");
    7.16 +
    7.17 +		return null;
    7.18 +	}
    7.19  
    7.20  
    7.21  	@Override
     8.1 --- a/runtime/src/main/java/eu/earthobservatory/runtime/generaldb/Strabon.java	Thu Nov 22 17:43:47 2012 +0200
     8.2 +++ b/runtime/src/main/java/eu/earthobservatory/runtime/generaldb/Strabon.java	Thu Nov 22 19:34:08 2012 +0200
     8.3 @@ -279,9 +279,8 @@
     8.4  		return status;
     8.5  	}
     8.6  
     8.7 -	private String queryRewriting(String queryString) 
     8.8 -	{	
     8.9 -		//TODO
    8.10 +	public String queryRewriting(String queryString) 
    8.11 +	{
    8.12  		String newQueryString="";
    8.13  		int numOfQuadruples=0;
    8.14  		int startIndex=0;
     9.1 --- a/runtime/src/test/java/eu/earthobservatory/runtime/generaldb/GeneralTests.java	Thu Nov 22 17:43:47 2012 +0200
     9.2 +++ b/runtime/src/test/java/eu/earthobservatory/runtime/generaldb/GeneralTests.java	Thu Nov 22 19:34:08 2012 +0200
     9.3 @@ -23,7 +23,7 @@
     9.4  	protected static String jdbcDriver= "org.postgresql.Driver";  
     9.5  	protected static String serverName = "localhost";
     9.6  	protected static String username = "postgres";
     9.7 -	protected static String password = "postgres";
     9.8 +	protected static String password = "p1r3as";
     9.9  	protected static Integer port = 5432;
    9.10  	protected static java.sql.Connection conn = null;
    9.11  	protected static String databaseName = null; 
    10.1 --- a/runtime/src/test/java/eu/earthobservatory/runtime/generaldb/JoinTests.java	Thu Nov 22 17:43:47 2012 +0200
    10.2 +++ b/runtime/src/test/java/eu/earthobservatory/runtime/generaldb/JoinTests.java	Thu Nov 22 19:34:08 2012 +0200
    10.3 @@ -51,7 +51,7 @@
    10.4  		"?sensorsDeployment <http://purl.oclc.org/NET/ssnx/ssn#deployedOnPlatform> ?sensorPlatform . "+
    10.5  		"?sensorPlatform <http://www.loa-cnr.it/ontologies/DUL.owl#hasLocation> ?spaceRegion . "+
    10.6  		"?spaceRegion <http://dbpedia.org/property/hasGeometry> ?sensorsGeo . "+
    10.7 -		"FILTER(strdf:anyInteract(?sensorsGeo,?areaGeo) && strdf:anyInteract(?sensorsGeo,?placeGeo)) . "+ 
    10.8 +		"FILTER(strdf:contains(?sensorsGeo,?areaGeo) && strdf:anyInteract(?sensorsGeo,?placeGeo)) . "+ 
    10.9  		"}";
   10.10  
   10.11  	String query5b = 
    11.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.2 +++ b/runtime/src/test/java/eu/earthobservatory/runtime/postgis/temporals/QueryRewritingTests.java	Thu Nov 22 19:34:08 2012 +0200
    11.3 @@ -0,0 +1,99 @@
    11.4 +/**
    11.5 + * This Source Code Form is subject to the terms of the Mozilla Public
    11.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
    11.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/.
    11.8 + * 
    11.9 + * Copyright (C) 2010, 2011, 2012, Pyravlos Team
   11.10 + * 
   11.11 + * http://www.strabon.di.uoa.gr/
   11.12 + */
   11.13 +package eu.earthobservatory.runtime.postgis.temporals;
   11.14 +
   11.15 +
   11.16 +
   11.17 +import java.io.IOException;
   11.18 +import java.sql.SQLException;
   11.19 +import org.junit.AfterClass;
   11.20 +import org.junit.BeforeClass;
   11.21 +import org.junit.Test;
   11.22 +import org.openrdf.query.MalformedQueryException;
   11.23 +import org.openrdf.query.QueryEvaluationException;
   11.24 +import org.openrdf.query.TupleQueryResultHandlerException;
   11.25 +import org.openrdf.repository.RepositoryException;
   11.26 +import org.openrdf.rio.RDFHandlerException;
   11.27 +import org.openrdf.rio.RDFParseException;
   11.28 +
   11.29 +
   11.30 +import eu.earthobservatory.runtime.generaldb.*;
   11.31 +import eu.earthobservatory.runtime.postgis.temporals.TemplateTests;
   11.32 +
   11.33 +
   11.34 +/**
   11.35 + * A set of simple tests on query rewriting functionality 
   11.36 + * 
   11.37 + * @author Panayiotis Smeros <psmeros@di.uoa.gr>
   11.38 + */
   11.39 +public class QueryRewritingTests {
   11.40 +
   11.41 +	protected static Strabon strabon;
   11.42 +	
   11.43 +	protected static final String prefixes = 
   11.44 +		"PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n" +
   11.45 +		"PREFIX strdf: <http://strdf.di.uoa.gr/ontology#> \n" +
   11.46 +		"PREFIX ex: <http://example.org/> \n" +
   11.47 +		"PREFIX xs: <http://www.w3.org/2001/XMLSchema#> \n" +
   11.48 +		"PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> \n" +
   11.49 +		"PREFIX noa: <http://teleios.di.uoa.gr/ontologies/noaOntology.owl#> \n";
   11.50 +
   11.51 +	
   11.52 +	@BeforeClass
   11.53 +	public static void beforeClass() throws SQLException, ClassNotFoundException, RDFParseException, RepositoryException, RDFHandlerException, IOException, InvalidDatasetFormatFault
   11.54 +	{
   11.55 +		strabon = TemplateTests.beforeClass("/temporal-selection-tests.nq","NQUADS");
   11.56 +	}
   11.57 +	
   11.58 +	@AfterClass
   11.59 +	public static void afterClass() throws SQLException
   11.60 +	{
   11.61 +		TemplateTests.afterClass(strabon);
   11.62 +	}
   11.63 +	
   11.64 +	
   11.65 +	
   11.66 +	@Test
   11.67 +	public void testQueryRewriting1() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException, QueryEvaluationException
   11.68 +	{
   11.69 +	
   11.70 +		String query = 
   11.71 +			prefixes+
   11.72 +			"SELECT ?geo1 "+ 
   11.73 +			"WHERE { "+
   11.74 +				"?x strdf:hasGeometry ?geo1 . "+
   11.75 +				"?y strdf:hasGeometry ?geo2 . "+
   11.76 +				"FILTER(strdf:intersects(?geo1, ?geo2))."+
   11.77 +				"}";
   11.78 +		
   11.79 +		System.out.println(strabon.queryRewriting(query));
   11.80 +	}
   11.81 +	
   11.82 +
   11.83 +	@Test
   11.84 +	public void testQueryRewriting2() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException, QueryEvaluationException
   11.85 +	{
   11.86 +	
   11.87 +		String query = 
   11.88 +			prefixes+
   11.89 +			"select ?geo ?s1 ?s2 " +
   11.90 +			"where {" +
   11.91 +			"?s1  ?p1 ?o1 ?t1 ." +
   11.92 +			" ?s2  ?p2 ?o2 ?t2 ." +
   11.93 +			"?x strdf:hasGeometry ?geo1 ." +
   11.94 +			"?y strdf:hasGeometry ?geo2." +
   11.95 +			"FILTER(strdf:intersects(?geo1,?geo2))." +
   11.96 +			"   FILTER(strdf:afterPeriod(?t1,?t2))}";	
   11.97 +		
   11.98 +		System.out.println(strabon.queryRewriting(query));
   11.99 +	}
  11.100 +
  11.101 +
  11.102 +}
    12.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.2 +++ b/runtime/src/test/java/eu/earthobservatory/runtime/postgis/temporals/TemplateTests.java	Thu Nov 22 19:34:08 2012 +0200
    12.3 @@ -0,0 +1,97 @@
    12.4 +/**
    12.5 + * This Source Code Form is subject to the terms of the Mozilla Public
    12.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
    12.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/.
    12.8 + * 
    12.9 + * Copyright (C) 2010, 2011, 2012, Pyravlos Team
   12.10 + * 
   12.11 + * http://www.strabon.di.uoa.gr/
   12.12 + */
   12.13 +package eu.earthobservatory.runtime.postgis.temporals;
   12.14 +
   12.15 +import java.io.IOException;
   12.16 +import java.io.InputStream;
   12.17 +import java.sql.DriverManager;
   12.18 +import java.sql.ResultSet;
   12.19 +import java.sql.SQLException;
   12.20 +import java.sql.Statement;
   12.21 +import java.util.Properties;
   12.22 +
   12.23 +import org.junit.AfterClass;
   12.24 +import org.junit.BeforeClass;
   12.25 +import org.openrdf.repository.RepositoryException;
   12.26 +import org.openrdf.rio.RDFHandlerException;
   12.27 +import org.openrdf.rio.RDFParseException;
   12.28 +
   12.29 +import eu.earthobservatory.runtime.generaldb.InvalidDatasetFormatFault;
   12.30 +import eu.earthobservatory.runtime.generaldb.SimpleTests;
   12.31 +import eu.earthobservatory.runtime.generaldb.Strabon;
   12.32 +
   12.33 +/**
   12.34 + * A set of simple tests on SPARQL query functionality 
   12.35 + * 
   12.36 + * @author Panayiotis Smeros <psmeros@di.uoa.gr>
   12.37 + */
   12.38 +public class TemplateTests {
   12.39 +	
   12.40 +	public static java.sql.Connection conn = null;
   12.41 +	public static String databaseName = null;
   12.42 +	public static String jdbcDriver = null;
   12.43 +	public static String serverName = null;
   12.44 +	public static String username = null;
   12.45 +	public static String password = null;
   12.46 +	public static Integer port = null;
   12.47 +	
   12.48 +	@BeforeClass
   12.49 +	public static Strabon beforeClass(String inputFile, String format)
   12.50 +		throws SQLException, ClassNotFoundException, RDFParseException, RepositoryException, RDFHandlerException, IOException, InvalidDatasetFormatFault
   12.51 +	{
   12.52 +		// Read properties
   12.53 +		Properties properties = new Properties();
   12.54 +		InputStream propertiesStream =  SimpleTests.class.getResourceAsStream("/databases.properties");
   12.55 +		properties.load(propertiesStream);
   12.56 +
   12.57 +		serverName = properties.getProperty("temporal.postgis.serverName");
   12.58 +		databaseName = properties.getProperty("temporal.postgis.databaseName");
   12.59 +		port = Integer.parseInt(properties.getProperty("temporal.postgis.port"));
   12.60 +		username = properties.getProperty("temporal.postgis.username");
   12.61 +		password = properties.getProperty("temporal.postgis.password");
   12.62 +		
   12.63 +		// Connect to database
   12.64 +		Class.forName("org.postgresql.Driver");
   12.65 +		String url = "jdbc:postgresql://"+serverName+":"+port+"/"+databaseName;
   12.66 +		conn = DriverManager.getConnection(url, username, password);
   12.67 +				
   12.68 +//		// Clean database
   12.69 +		Statement stmt = conn.createStatement();
   12.70 +		ResultSet results = stmt.executeQuery("SELECT table_name FROM information_schema.tables WHERE " +
   12.71 +						"table_schema='public' AND table_name <> 'spatial_ref_sys' " +
   12.72 +						"AND table_name <> 'geometry_columns' AND " +
   12.73 +						"table_name <> 'geography_columns' AND table_name <> 'locked'");
   12.74 +		while (results.next()) {
   12.75 +			String table_name = results.getString("table_name");
   12.76 +			Statement stmt2 = conn.createStatement();
   12.77 +			stmt2.executeUpdate("DROP TABLE \""+table_name+"\"");
   12.78 +			stmt2.close();
   12.79 +		}
   12.80 +		stmt.close();
   12.81 +		
   12.82 +	    Strabon strabon = new eu.earthobservatory.runtime.postgis.Strabon(databaseName, username, password, port, serverName, true);
   12.83 +		
   12.84 +		loadTestData(inputFile, strabon, format);
   12.85 +		
   12.86 +		return strabon;
   12.87 +	}
   12.88 +	
   12.89 +	@AfterClass
   12.90 +	public static void afterClass(Strabon strabon) throws SQLException
   12.91 +	{
   12.92 +		strabon.close();
   12.93 +	}
   12.94 +	
   12.95 +	protected static void loadTestData(String inputfile, Strabon strabon, String format)
   12.96 +		throws RDFParseException, RepositoryException, IOException, RDFHandlerException, InvalidDatasetFormatFault
   12.97 +	{
   12.98 +		strabon.storeInRepo(inputfile, format);
   12.99 +	}
  12.100 +}
    13.1 --- a/runtime/src/test/java/eu/earthobservatory/runtime/postgis/temporals/TemporalSelectionTests.java	Thu Nov 22 17:43:47 2012 +0200
    13.2 +++ b/runtime/src/test/java/eu/earthobservatory/runtime/postgis/temporals/TemporalSelectionTests.java	Thu Nov 22 19:34:08 2012 +0200
    13.3 @@ -6,18 +6,93 @@
    13.4   * Copyright (C) 2010, 2011, 2012, Pyravlos Team
    13.5   * 
    13.6   * http://www.strabon.di.uoa.gr/
    13.7 + */
    13.8 +package eu.earthobservatory.runtime.postgis.temporals;
    13.9 +
   13.10 +
   13.11 +
   13.12 +import static org.junit.Assert.assertEquals;
   13.13 +
   13.14 +import java.io.IOException;
   13.15 +import java.sql.SQLException;
   13.16 +import java.util.ArrayList;
   13.17 +
   13.18 +import org.junit.AfterClass;
   13.19 +import org.junit.BeforeClass;
   13.20 +import org.junit.Test;
   13.21 +import org.openrdf.query.MalformedQueryException;
   13.22 +import org.openrdf.query.QueryEvaluationException;
   13.23 +import org.openrdf.query.TupleQueryResultHandlerException;
   13.24 +import org.openrdf.repository.RepositoryException;
   13.25 +import org.openrdf.rio.RDFHandlerException;
   13.26 +import org.openrdf.rio.RDFParseException;
   13.27 +
   13.28 +
   13.29 +import eu.earthobservatory.runtime.generaldb.*;
   13.30 +import eu.earthobservatory.runtime.postgis.temporals.TemplateTests;
   13.31 +
   13.32 +
   13.33 +/**
   13.34 + * A set of simple tests on temporal selection functionality 
   13.35   * 
   13.36   * @author Panayiotis Smeros <psmeros@di.uoa.gr>
   13.37   */
   13.38 -package eu.earthobservatory.runtime.postgis.temporals;
   13.39 +public class TemporalSelectionTests {
   13.40  
   13.41 +	protected static Strabon strabon;
   13.42 +	
   13.43 +	protected static final String prefixes = 
   13.44 +		"PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n" +
   13.45 +		"PREFIX strdf: <http://strdf.di.uoa.gr/ontology#> \n" +
   13.46 +		"PREFIX ex: <http://example.org/> \n" +
   13.47 +		"PREFIX xs: <http://www.w3.org/2001/XMLSchema#> \n" +
   13.48 +		"PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> \n" +
   13.49 +		"PREFIX noa: <http://teleios.di.uoa.gr/ontologies/noaOntology.owl#> \n";
   13.50  
   13.51 +	
   13.52 +	@BeforeClass
   13.53 +	public static void beforeClass() throws SQLException, ClassNotFoundException, RDFParseException, RepositoryException, RDFHandlerException, IOException, InvalidDatasetFormatFault
   13.54 +	{
   13.55 +		strabon = TemplateTests.beforeClass("/temporal-selection-tests.nq","NQUADS");
   13.56 +	}
   13.57 +	
   13.58 +	@AfterClass
   13.59 +	public static void afterClass() throws SQLException
   13.60 +	{
   13.61 +		TemplateTests.afterClass(strabon);
   13.62 +	}
   13.63 +	
   13.64 +	
   13.65 +	
   13.66 +	@Test
   13.67 +	public void testSPOTQuery() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException, QueryEvaluationException
   13.68 +	{
   13.69 +	
   13.70 +		String query = 
   13.71 +			prefixes+
   13.72 +			"SELECT * "+ 
   13.73 +			"WHERE { "+
   13.74 +				"?s ?p ?o ?t. "+
   13.75 +			"}";
   13.76 +		
   13.77 +		ArrayList<String> bindings = (ArrayList<String>) strabon.query(strabon.queryRewriting(query),strabon.getSailRepoConnection());
   13.78 +		assertEquals(8, bindings.size());
   13.79 +	}
   13.80  
   13.81 -/**
   13.82 - * A set of simple tests on Temporal Selection functionality 
   13.83 - * 
   13.84 - */
   13.85 -public class TemporalSelectionTests {
   13.86 +
   13.87 +	@Test
   13.88 +	public void testSPOQuery() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException, QueryEvaluationException
   13.89 +	{
   13.90  	
   13.91 -
   13.92 +		String query = 
   13.93 +			prefixes+
   13.94 +			"SELECT * "+ 
   13.95 +			"WHERE { "+
   13.96 +				"?s ?p ?o. "+
   13.97 +			"}";
   13.98 +		
   13.99 +		ArrayList<String> bindings = (ArrayList<String>) strabon.query(strabon.queryRewriting(query),strabon.getSailRepoConnection());
  13.100 +		System.out.println(bindings);
  13.101 +		assertEquals(9, bindings.size());
  13.102 +	}
  13.103  }
    14.1 --- a/runtime/src/test/resources/databases.properties	Thu Nov 22 17:43:47 2012 +0200
    14.2 +++ b/runtime/src/test/resources/databases.properties	Thu Nov 22 19:34:08 2012 +0200
    14.3 @@ -1,5 +1,5 @@
    14.4  # PostGIS
    14.5 -postgis.databaseName = strabon-test
    14.6 +postgis.databaseName = strabon-tests
    14.7  postgis.serverName = localhost
    14.8  postgis.username = postgres
    14.9  postgis.password = p1r3as
   14.10 @@ -11,3 +11,10 @@
   14.11  monetdb.username = monetdb
   14.12  monetdb.password = monetdb
   14.13  monetdb.port = 50000
   14.14 +
   14.15 +# PostGIS-Temporal
   14.16 +temporal.postgis.databaseName = endpoint_temporal
   14.17 +temporal.postgis.serverName = localhost
   14.18 +temporal.postgis.username = postgres
   14.19 +temporal.postgis.password = postgres
   14.20 +temporal.postgis.port = 5432
   14.21 \ No newline at end of file