Strabon

changeset 1453:2fac60132bc8 temporals

completed imlpementation of the period(timestamp,timestamp) function
author Konstantina Bereta <Konstantina.Bereta@di.uoa.gr>
date Wed Jan 14 13:12:30 2015 +0200 (2015-01-14)
parents 501005e44247
children 2af04c5108de
files generaldb/src/main/java/org/openrdf/sail/generaldb/algebra/base/GeneralDBExprSupport.java generaldb/src/main/java/org/openrdf/sail/generaldb/algebra/factories/GeneralDBBooleanExprFactory.java generaldb/src/main/java/org/openrdf/sail/generaldb/evaluation/GeneralDBQueryBuilder.java monetdb/src/main/java/org/openrdf/sail/monetdb/evaluation/MonetDBQueryBuilder.java postgis/src/main/java/org/openrdf/sail/postgis/evaluation/PostGISQueryBuilder.java
line diff
     1.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/algebra/base/GeneralDBExprSupport.java	Tue Jan 13 19:22:10 2015 +0200
     1.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/algebra/base/GeneralDBExprSupport.java	Wed Jan 14 13:12:30 2015 +0200
     1.3 @@ -102,6 +102,7 @@
     1.4  import org.openrdf.sail.generaldb.algebra.temporal.GeneralDBSqlNequalsPeriod;
     1.5  import org.openrdf.sail.generaldb.algebra.temporal.GeneralDBSqlOverleftPeriod;
     1.6  import org.openrdf.sail.generaldb.algebra.temporal.GeneralDBSqlOverrightPeriod;
     1.7 +import org.openrdf.sail.generaldb.algebra.temporal.GeneralDBSqlPeriod;
     1.8  import org.openrdf.sail.generaldb.algebra.temporal.GeneralDBSqlPeriodContainedBy;
     1.9  import org.openrdf.sail.generaldb.algebra.temporal.GeneralDBSqlPeriodContains;
    1.10  import org.openrdf.sail.generaldb.algebra.temporal.GeneralDBSqlPeriodEnd;
    1.11 @@ -377,6 +378,9 @@
    1.12  	public static GeneralDBSqlExpr periodMinus(GeneralDBSqlExpr left, GeneralDBSqlExpr right) {
    1.13  		return new GeneralDBSqlPeriodMinus(left, right);
    1.14  	}
    1.15 +	public static GeneralDBSqlExpr period(GeneralDBSqlExpr left, GeneralDBSqlExpr right) {
    1.16 +		return new GeneralDBSqlPeriod(left, right);
    1.17 +	}
    1.18  	
    1.19  	
    1.20  	//stSPARQL Temporal Construct Unary Function
     2.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/algebra/factories/GeneralDBBooleanExprFactory.java	Tue Jan 13 19:22:10 2015 +0200
     2.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/algebra/factories/GeneralDBBooleanExprFactory.java	Wed Jan 14 13:12:30 2015 +0200
     2.3 @@ -6,9 +6,6 @@
     2.4  package org.openrdf.sail.generaldb.algebra.factories;
     2.5  
     2.6  import static org.openrdf.sail.generaldb.algebra.base.GeneralDBExprSupport.*;
     2.7 -import static org.openrdf.sail.generaldb.algebra.base.GeneralDBExprSupport.geofSRID;
     2.8 -import static org.openrdf.sail.generaldb.algebra.base.GeneralDBExprSupport.st_Centroid;
     2.9 -import static org.openrdf.sail.generaldb.algebra.base.GeneralDBExprSupport.st_MakeLine;
    2.10  
    2.11  import org.openrdf.model.Literal;
    2.12  import org.openrdf.model.Value;
    2.13 @@ -54,6 +51,7 @@
    2.14  import org.openrdf.query.algebra.evaluation.function.spatial.stsparql.metric.AreaFunc;
    2.15  import org.openrdf.query.algebra.evaluation.function.spatial.stsparql.relation.RelateFunc;
    2.16  import org.openrdf.query.algebra.evaluation.function.temporal.stsparql.construct.PeriodEndsFunc;
    2.17 +import org.openrdf.query.algebra.evaluation.function.temporal.stsparql.construct.PeriodFunc;
    2.18  import org.openrdf.query.algebra.evaluation.function.temporal.stsparql.construct.PeriodIntersectionFunc;
    2.19  import org.openrdf.query.algebra.evaluation.function.temporal.stsparql.construct.PeriodMinusFunc;
    2.20  import org.openrdf.query.algebra.evaluation.function.temporal.stsparql.construct.PeriodStartsFunc;
    2.21 @@ -70,7 +68,9 @@
    2.22  import org.openrdf.query.algebra.evaluation.function.temporal.stsparql.relation.PeriodContainedByFunc;
    2.23  import org.openrdf.query.algebra.evaluation.function.temporal.stsparql.relation.PeriodContainsFunc;
    2.24  import org.openrdf.query.algebra.evaluation.function.temporal.stsparql.relation.PeriodIntersectsFunc;
    2.25 +
    2.26  import eu.earthobservatory.constants.TemporalConstants;
    2.27 +
    2.28  import org.openrdf.query.algebra.evaluation.function.temporal.stsparql.relation.TemporalRelationFunc;
    2.29  import org.openrdf.query.algebra.evaluation.function.temporal.stsparql.relation.finishesFunc;
    2.30  import org.openrdf.query.algebra.evaluation.function.temporal.stsparql.relation.PeriodOverlapsFunc;
    2.31 @@ -1081,6 +1081,10 @@
    2.32  		{
    2.33  			return periodEnd(leftArg);
    2.34  		}
    2.35 +		else if(function instanceof PeriodFunc)
    2.36 +		{
    2.37 +			return period(leftArg, rightArg);
    2.38 +		}
    2.39  		else
    2.40  			return null;
    2.41  	}
     3.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/evaluation/GeneralDBQueryBuilder.java	Tue Jan 13 19:22:10 2015 +0200
     3.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/evaluation/GeneralDBQueryBuilder.java	Wed Jan 14 13:12:30 2015 +0200
     3.3 @@ -124,6 +124,7 @@
     3.4  import org.openrdf.sail.generaldb.algebra.temporal.GeneralDBSqlNequalsPeriod;
     3.5  import org.openrdf.sail.generaldb.algebra.temporal.GeneralDBSqlOverleftPeriod;
     3.6  import org.openrdf.sail.generaldb.algebra.temporal.GeneralDBSqlOverrightPeriod;
     3.7 +import org.openrdf.sail.generaldb.algebra.temporal.GeneralDBSqlPeriod;
     3.8  import org.openrdf.sail.generaldb.algebra.temporal.GeneralDBSqlPeriodContainedBy;
     3.9  import org.openrdf.sail.generaldb.algebra.temporal.GeneralDBSqlPeriodContains;
    3.10  import org.openrdf.sail.generaldb.algebra.temporal.GeneralDBSqlPeriodEnd;
    3.11 @@ -656,6 +657,9 @@
    3.12  		else if(expr instanceof GeneralDBSqlPeriodMinus){
    3.13  			append((GeneralDBSqlPeriodMinus)expr, filter);
    3.14  		}
    3.15 +		else if(expr instanceof GeneralDBSqlPeriod){
    3.16 +			append((GeneralDBSqlPeriod)expr, filter);
    3.17 +		}
    3.18  	
    3.19  		
    3.20  		//GeoSPARQL
    3.21 @@ -1342,6 +1346,10 @@
    3.22  		{
    3.23  			append((GeneralDBSqlPeriodEnd)constr, filter);
    3.24  		}
    3.25 +		else if(constr instanceof GeneralDBSqlPeriod)
    3.26 +		{
    3.27 +			append((GeneralDBSqlPeriod)constr, filter);
    3.28 +		}
    3.29  		/* PostGIS functions */
    3.30  		else if(constr instanceof GeneralDBSqlST_MakeLine)
    3.31  		{
    3.32 @@ -1412,6 +1420,11 @@
    3.33  		GeneralDBSqlExprBuilder filter)
    3.34  		throws UnsupportedRdbmsOperatorException;
    3.35  
    3.36 +protected abstract void append(GeneralDBSqlPeriod expr,
    3.37 +		GeneralDBSqlExprBuilder filter)
    3.38 +		throws UnsupportedRdbmsOperatorException;
    3.39 +
    3.40 +
    3.41  protected abstract void append(GeneralDBSqlPeriodStart expr,
    3.42  		GeneralDBSqlExprBuilder filter)
    3.43  		throws UnsupportedRdbmsOperatorException;
     4.1 --- a/monetdb/src/main/java/org/openrdf/sail/monetdb/evaluation/MonetDBQueryBuilder.java	Tue Jan 13 19:22:10 2015 +0200
     4.2 +++ b/monetdb/src/main/java/org/openrdf/sail/monetdb/evaluation/MonetDBQueryBuilder.java	Wed Jan 14 13:12:30 2015 +0200
     4.3 @@ -109,6 +109,7 @@
     4.4  import org.openrdf.sail.generaldb.algebra.temporal.GeneralDBSqlNequalsPeriod;
     4.5  import org.openrdf.sail.generaldb.algebra.temporal.GeneralDBSqlOverleftPeriod;
     4.6  import org.openrdf.sail.generaldb.algebra.temporal.GeneralDBSqlOverrightPeriod;
     4.7 +import org.openrdf.sail.generaldb.algebra.temporal.GeneralDBSqlPeriod;
     4.8  import org.openrdf.sail.generaldb.algebra.temporal.GeneralDBSqlPeriodContainedBy;
     4.9  import org.openrdf.sail.generaldb.algebra.temporal.GeneralDBSqlPeriodContains;
    4.10  import org.openrdf.sail.generaldb.algebra.temporal.GeneralDBSqlPeriodEnd;
    4.11 @@ -2649,6 +2650,14 @@
    4.12  	}
    4.13  
    4.14  	@Override
    4.15 +	protected void append(GeneralDBSqlPeriod expr,
    4.16 +			GeneralDBSqlExprBuilder filter)
    4.17 +			throws UnsupportedRdbmsOperatorException {
    4.18 +		// TODO Auto-generated method stub
    4.19 +		
    4.20 +	}
    4.21 +
    4.22 +	@Override
    4.23  	protected void append(GeneralDBSqlPeriodOverlaps expr,
    4.24  			GeneralDBSqlExprBuilder filter)
    4.25  			throws UnsupportedRdbmsOperatorException {
     5.1 --- a/postgis/src/main/java/org/openrdf/sail/postgis/evaluation/PostGISQueryBuilder.java	Tue Jan 13 19:22:10 2015 +0200
     5.2 +++ b/postgis/src/main/java/org/openrdf/sail/postgis/evaluation/PostGISQueryBuilder.java	Wed Jan 14 13:12:30 2015 +0200
     5.3 @@ -1113,7 +1113,14 @@
     5.4  			{
     5.5  
     5.6  				String instant =period.substring(period.indexOf('[')+1, period.indexOf(']'));
     5.7 -				filter.append("period(to_timestamp('"+instant+ "','YYYY-MM-DD HH:MI:SS.MS'))");
     5.8 +				if (expr.getParentNode() instanceof GeneralDBSqlPeriod)
     5.9 +				{
    5.10 +					filter.append("to_timestamp('"+instant+ "','YYYY-MM-DD HH:MI:SS.MS')");
    5.11 +				}
    5.12 +				else
    5.13 +				{
    5.14 +					filter.append("period(to_timestamp('"+instant+ "','YYYY-MM-DD HH:MI:SS.MS'))");
    5.15 +				}
    5.16  			}
    5.17  		
    5.18  		}
    5.19 @@ -1235,6 +1242,12 @@
    5.20  			{
    5.21  		appendGeneralDBTemporalFunctionBinary(expr, filter, expr.getPostgresFunction());
    5.22  			}
    5.23 +	@Override
    5.24 +	protected void append(GeneralDBSqlPeriod expr, GeneralDBSqlExprBuilder filter)
    5.25 +			throws UnsupportedRdbmsOperatorException
    5.26 +			{
    5.27 +		appendGeneralDBTemporalFunctionBinary(expr, filter, expr.getPostgresFunction());
    5.28 +			}
    5.29  	
    5.30  	@Override
    5.31  	protected void append(GeneralDBSqlPeriodUnion expr, GeneralDBSqlExprBuilder filter)
    5.32 @@ -1763,6 +1776,14 @@
    5.33  			/////
    5.34  			filter.appendFunction(func); //postgres temporal operators get deprecated. I will use the function names instead- constant
    5.35  			filter.openBracket();
    5.36 +			if(expr instanceof GeneralDBSqlPeriod)
    5.37 +			{
    5.38 +				filter.append("first");
    5.39 +				filter.openBracket();
    5.40 +				appendPeriod((GeneralDBLabelColumn)(tmp),filter);
    5.41 +				filter.closeBracket();
    5.42 +				
    5.43 +			}
    5.44  			if (expr.getLeftArg() instanceof GeneralDBSqlTemporalConstructBinary)
    5.45  			{
    5.46  				appendConstructFunction(expr.getLeftArg(), filter);
    5.47 @@ -1772,9 +1793,13 @@
    5.48  				appendPeriodConstant(expr.getLeftArg(), filter);
    5.49  			}
    5.50  			else
    5.51 -			{			
    5.52 -				appendPeriod((GeneralDBLabelColumn)(expr.getLeftArg()),filter);
    5.53 -
    5.54 +			{	
    5.55 +				if(expr.getParentNode() instanceof GeneralDBSqlPeriod)
    5.56 +				{
    5.57 +					filter.openBracket();
    5.58 +					appendPeriod((GeneralDBLabelColumn)(expr.getLeftArg()),filter);	
    5.59 +					filter.closeBracket();
    5.60 +				}
    5.61  			}
    5.62  		
    5.63  			if(func.equals("=")|| func.equals("!=")|| func.equals("-")|| func.equals("+")|| func.equals("~")|| 
    5.64 @@ -1812,6 +1837,14 @@
    5.65  			{
    5.66  				appendPeriodConstant(expr.getRightArg(), filter);
    5.67  			}
    5.68 +			else if (expr instanceof GeneralDBSqlPeriod)
    5.69 +			{
    5.70 +				filter.append("first");
    5.71 +				filter.openBracket();
    5.72 +				appendPeriod((GeneralDBLabelColumn)(expr.getRightArg()),filter);
    5.73 +				filter.closeBracket();
    5.74 +
    5.75 +			}
    5.76  			else
    5.77  			{
    5.78  				appendPeriod((GeneralDBLabelColumn)(expr.getRightArg()),filter);