Strabon

changeset 750:07d584b2fb5b temporals

Four more temporal relation functions are now supported: strdf:overrightPeriod, strdf:overleftPeriod, strdf:equalsPeriod, strdf:nequalsPeriod
author Konstantina Bereta <Konstantina.Bereta@di.uoa.gr>
date Thu Nov 29 19:18:37 2012 +0200 (2012-11-29)
parents 3e4cdb6151fc
children 33f3fa561579
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/algebra/temporal/GeneralDBSqlOverleftPeriod.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	Thu Nov 29 01:00:38 2012 +0200
     1.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/algebra/base/GeneralDBExprSupport.java	Thu Nov 29 19:18:37 2012 +0200
     1.3 @@ -92,6 +92,10 @@
     1.4  import org.openrdf.sail.generaldb.algebra.sf.GeneralDBSqlSF_Within;
     1.5  import org.openrdf.sail.generaldb.algebra.temporal.GeneralDBSqlAfterPeriod;
     1.6  import org.openrdf.sail.generaldb.algebra.temporal.GeneralDBSqlBeforePeriod;
     1.7 +import org.openrdf.sail.generaldb.algebra.temporal.GeneralDBSqlEqualsPeriod;
     1.8 +import org.openrdf.sail.generaldb.algebra.temporal.GeneralDBSqlNequalsPeriod;
     1.9 +import org.openrdf.sail.generaldb.algebra.temporal.GeneralDBSqlOverleftPeriod;
    1.10 +import org.openrdf.sail.generaldb.algebra.temporal.GeneralDBSqlOverrightPeriod;
    1.11  import org.openrdf.sail.generaldb.algebra.temporal.GeneralDBSqlPeriodContainedBy;
    1.12  import org.openrdf.sail.generaldb.algebra.temporal.GeneralDBSqlPeriodContains;
    1.13  import org.openrdf.sail.generaldb.algebra.temporal.GeneralDBSqlPeriodOverlaps;
    1.14 @@ -100,6 +104,8 @@
    1.15   * Support method to create SQL expressions.
    1.16   * 
    1.17   * @author James Leigh
    1.18 + * @author Manos Karpathiotakis <mk@di.uoa.gr>
    1.19 + * @author Konstantina Bereta <Konstantina.Bereta@di.uoa.gr>
    1.20   * 
    1.21   */
    1.22  public class GeneralDBExprSupport {
    1.23 @@ -363,6 +369,18 @@
    1.24  	public static GeneralDBSqlExpr beforePeriod(GeneralDBSqlExpr left, GeneralDBSqlExpr right) {
    1.25  		return new GeneralDBSqlBeforePeriod(left, right);
    1.26  	}
    1.27 +	public static GeneralDBSqlExpr overleftPeriod(GeneralDBSqlExpr left, GeneralDBSqlExpr right) {
    1.28 +		return new GeneralDBSqlOverleftPeriod(left, right);
    1.29 +	}
    1.30 +	public static GeneralDBSqlExpr overrightPeriod(GeneralDBSqlExpr left, GeneralDBSqlExpr right) {
    1.31 +		return new GeneralDBSqlOverrightPeriod(left, right);
    1.32 +	}
    1.33 +	public static GeneralDBSqlExpr equalsPeriod(GeneralDBSqlExpr left, GeneralDBSqlExpr right) {
    1.34 +		return new GeneralDBSqlEqualsPeriod(left, right);
    1.35 +	}
    1.36 +	public static GeneralDBSqlExpr nequalsPeriod(GeneralDBSqlExpr left, GeneralDBSqlExpr right) {
    1.37 +		return new GeneralDBSqlNequalsPeriod(left, right);
    1.38 +	}
    1.39  	public static GeneralDBSqlExpr periodContains(GeneralDBSqlExpr left, GeneralDBSqlExpr right) {
    1.40  		return new GeneralDBSqlPeriodContains(left, right);
    1.41  	}
     2.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/algebra/factories/GeneralDBBooleanExprFactory.java	Thu Nov 29 01:00:38 2012 +0200
     2.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/algebra/factories/GeneralDBBooleanExprFactory.java	Thu Nov 29 19:18:37 2012 +0200
     2.3 @@ -48,6 +48,10 @@
     2.4  import org.openrdf.query.algebra.evaluation.function.spatial.stsparql.relation.RelateFunc;
     2.5  import org.openrdf.query.algebra.evaluation.function.temporal.stsparql.relation.AfterPeriodFunc;
     2.6  import org.openrdf.query.algebra.evaluation.function.temporal.stsparql.relation.BeforePeriodFunc;
     2.7 +import org.openrdf.query.algebra.evaluation.function.temporal.stsparql.relation.EqualsPeriodFunc;
     2.8 +import org.openrdf.query.algebra.evaluation.function.temporal.stsparql.relation.NequalsPeriodFunc;
     2.9 +import org.openrdf.query.algebra.evaluation.function.temporal.stsparql.relation.OverleftPeriodFunc;
    2.10 +import org.openrdf.query.algebra.evaluation.function.temporal.stsparql.relation.OverrightPeriodFunc;
    2.11  import org.openrdf.query.algebra.evaluation.function.temporal.stsparql.relation.PeriodContainedByFunc;
    2.12  import org.openrdf.query.algebra.evaluation.function.temporal.stsparql.relation.PeriodContainsFunc;
    2.13  import org.openrdf.query.algebra.evaluation.function.temporal.stsparql.relation.TemporalConstants;
    2.14 @@ -943,6 +947,22 @@
    2.15  		{
    2.16  			return beforePeriod(leftArg, rightArg);
    2.17  		}
    2.18 +		else if(function instanceof OverleftPeriodFunc)
    2.19 +		{
    2.20 +			return overleftPeriod(leftArg, rightArg);
    2.21 +		}
    2.22 +		else if(function instanceof OverrightPeriodFunc)
    2.23 +		{
    2.24 +			return overrightPeriod(leftArg, rightArg);
    2.25 +		}
    2.26 +		else if(function instanceof EqualsPeriodFunc)
    2.27 +		{
    2.28 +			return equalsPeriod(leftArg, rightArg);
    2.29 +		}
    2.30 +		else if(function instanceof NequalsPeriodFunc)
    2.31 +		{
    2.32 +			return nequalsPeriod(leftArg, rightArg);
    2.33 +		}
    2.34  		else if(function instanceof PeriodContainsFunc)
    2.35  		{
    2.36  			return periodContains(leftArg, rightArg);
     3.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/algebra/temporal/GeneralDBSqlOverleftPeriod.java	Thu Nov 29 01:00:38 2012 +0200
     3.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/algebra/temporal/GeneralDBSqlOverleftPeriod.java	Thu Nov 29 19:18:37 2012 +0200
     3.3 @@ -27,7 +27,7 @@
     3.4  	@Override
     3.5  	public String getOperator() {
     3.6  		
     3.7 -		return "&&";
     3.8 +		return "&<";
     3.9  	}
    3.10  
    3.11  	/* (non-Javadoc)
     4.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/evaluation/GeneralDBQueryBuilder.java	Thu Nov 29 01:00:38 2012 +0200
     4.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/evaluation/GeneralDBQueryBuilder.java	Thu Nov 29 19:18:37 2012 +0200
     4.3 @@ -115,6 +115,10 @@
     4.4  import org.openrdf.sail.generaldb.algebra.sf.GeneralDBSqlSF_Within;
     4.5  import org.openrdf.sail.generaldb.algebra.temporal.GeneralDBSqlAfterPeriod;
     4.6  import org.openrdf.sail.generaldb.algebra.temporal.GeneralDBSqlBeforePeriod;
     4.7 +import org.openrdf.sail.generaldb.algebra.temporal.GeneralDBSqlEqualsPeriod;
     4.8 +import org.openrdf.sail.generaldb.algebra.temporal.GeneralDBSqlNequalsPeriod;
     4.9 +import org.openrdf.sail.generaldb.algebra.temporal.GeneralDBSqlOverleftPeriod;
    4.10 +import org.openrdf.sail.generaldb.algebra.temporal.GeneralDBSqlOverrightPeriod;
    4.11  import org.openrdf.sail.generaldb.algebra.temporal.GeneralDBSqlPeriodContainedBy;
    4.12  import org.openrdf.sail.generaldb.algebra.temporal.GeneralDBSqlPeriodContains;
    4.13  import org.openrdf.sail.generaldb.algebra.temporal.GeneralDBSqlPeriodIntersection;
    4.14 @@ -603,6 +607,18 @@
    4.15  		else if(expr instanceof GeneralDBSqlBeforePeriod){
    4.16  			append((GeneralDBSqlBeforePeriod)expr, filter);
    4.17  		}
    4.18 +		else if(expr instanceof GeneralDBSqlOverleftPeriod){
    4.19 +			append((GeneralDBSqlOverleftPeriod)expr, filter);
    4.20 +		}
    4.21 +		else if(expr instanceof GeneralDBSqlOverrightPeriod){
    4.22 +			append((GeneralDBSqlOverrightPeriod)expr, filter);
    4.23 +		}
    4.24 +		else if(expr instanceof GeneralDBSqlEqualsPeriod){
    4.25 +			append((GeneralDBSqlEqualsPeriod)expr, filter);
    4.26 +		}
    4.27 +		else if(expr instanceof GeneralDBSqlNequalsPeriod){
    4.28 +			append((GeneralDBSqlNequalsPeriod)expr, filter);
    4.29 +		}
    4.30  		else if(expr instanceof GeneralDBSqlPeriodContainedBy){
    4.31  			append((GeneralDBSqlPeriodContainedBy)expr, filter);
    4.32  		}
    4.33 @@ -1304,6 +1320,21 @@
    4.34  		GeneralDBSqlExprBuilder filter)
    4.35  		throws UnsupportedRdbmsOperatorException;
    4.36  
    4.37 +protected abstract void append(GeneralDBSqlOverleftPeriod expr,
    4.38 +		GeneralDBSqlExprBuilder filter)
    4.39 +		throws UnsupportedRdbmsOperatorException;
    4.40 +
    4.41 +protected abstract void append(GeneralDBSqlOverrightPeriod expr,
    4.42 +		GeneralDBSqlExprBuilder filter)
    4.43 +		throws UnsupportedRdbmsOperatorException;
    4.44 +
    4.45 +protected abstract void append(GeneralDBSqlEqualsPeriod expr,
    4.46 +		GeneralDBSqlExprBuilder filter)
    4.47 +		throws UnsupportedRdbmsOperatorException;
    4.48 +
    4.49 +protected abstract void append(GeneralDBSqlNequalsPeriod expr,
    4.50 +		GeneralDBSqlExprBuilder filter)
    4.51 +		throws UnsupportedRdbmsOperatorException;
    4.52  protected abstract void append(GeneralDBSqlBeforePeriod expr,
    4.53  		GeneralDBSqlExprBuilder filter)
    4.54  		throws UnsupportedRdbmsOperatorException;
     5.1 --- a/monetdb/src/main/java/org/openrdf/sail/monetdb/evaluation/MonetDBQueryBuilder.java	Thu Nov 29 01:00:38 2012 +0200
     5.2 +++ b/monetdb/src/main/java/org/openrdf/sail/monetdb/evaluation/MonetDBQueryBuilder.java	Thu Nov 29 19:18:37 2012 +0200
     5.3 @@ -97,6 +97,10 @@
     5.4  import org.openrdf.sail.generaldb.algebra.sf.GeneralDBSqlSF_Within;
     5.5  import org.openrdf.sail.generaldb.algebra.temporal.GeneralDBSqlAfterPeriod;
     5.6  import org.openrdf.sail.generaldb.algebra.temporal.GeneralDBSqlBeforePeriod;
     5.7 +import org.openrdf.sail.generaldb.algebra.temporal.GeneralDBSqlEqualsPeriod;
     5.8 +import org.openrdf.sail.generaldb.algebra.temporal.GeneralDBSqlNequalsPeriod;
     5.9 +import org.openrdf.sail.generaldb.algebra.temporal.GeneralDBSqlOverleftPeriod;
    5.10 +import org.openrdf.sail.generaldb.algebra.temporal.GeneralDBSqlOverrightPeriod;
    5.11  import org.openrdf.sail.generaldb.algebra.temporal.GeneralDBSqlPeriodContainedBy;
    5.12  import org.openrdf.sail.generaldb.algebra.temporal.GeneralDBSqlPeriodContains;
    5.13  import org.openrdf.sail.generaldb.algebra.temporal.GeneralDBSqlPeriodIntersection;
    5.14 @@ -2164,4 +2168,36 @@
    5.15  		
    5.16  	}
    5.17  
    5.18 +	@Override
    5.19 +	protected void append(GeneralDBSqlOverleftPeriod expr,
    5.20 +			GeneralDBSqlExprBuilder filter)
    5.21 +			throws UnsupportedRdbmsOperatorException {
    5.22 +		// TODO Auto-generated method stub
    5.23 +		
    5.24 +	}
    5.25 +
    5.26 +	@Override
    5.27 +	protected void append(GeneralDBSqlOverrightPeriod expr,
    5.28 +			GeneralDBSqlExprBuilder filter)
    5.29 +			throws UnsupportedRdbmsOperatorException {
    5.30 +		// TODO Auto-generated method stub
    5.31 +		
    5.32 +	}
    5.33 +
    5.34 +	@Override
    5.35 +	protected void append(GeneralDBSqlEqualsPeriod expr,
    5.36 +			GeneralDBSqlExprBuilder filter)
    5.37 +			throws UnsupportedRdbmsOperatorException {
    5.38 +		// TODO Auto-generated method stub
    5.39 +		
    5.40 +	}
    5.41 +
    5.42 +	@Override
    5.43 +	protected void append(GeneralDBSqlNequalsPeriod expr,
    5.44 +			GeneralDBSqlExprBuilder filter)
    5.45 +			throws UnsupportedRdbmsOperatorException {
    5.46 +		// TODO Auto-generated method stub
    5.47 +		
    5.48 +	}
    5.49 +
    5.50  }
    5.51 \ No newline at end of file
     6.1 --- a/postgis/src/main/java/org/openrdf/sail/postgis/evaluation/PostGISQueryBuilder.java	Thu Nov 29 01:00:38 2012 +0200
     6.2 +++ b/postgis/src/main/java/org/openrdf/sail/postgis/evaluation/PostGISQueryBuilder.java	Thu Nov 29 19:18:37 2012 +0200
     6.3 @@ -5,6 +5,8 @@
     6.4   */
     6.5  package org.openrdf.sail.postgis.evaluation;
     6.6  
     6.7 +import java.text.ParseException;
     6.8 +import java.text.SimpleDateFormat;
     6.9  import java.util.ArrayList;
    6.10  import java.util.Calendar;
    6.11  import java.util.Date;
    6.12 @@ -977,12 +979,20 @@
    6.13  		{
    6.14  			   TimeZone UTC = TimeZone.getTimeZone("UTC");
    6.15  			    final Calendar c = new GregorianCalendar(UTC);
    6.16 +			    SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    6.17 +			   
    6.18  			    c.set(1, 0, 1, 0, 0, 0);
    6.19  			    c.set(Calendar.MILLISECOND, 0);
    6.20  			    Date begin = c.getTime();
    6.21  			    c.setTime(new Date(Long.MAX_VALUE));
    6.22  			    Date end = c.getTime();
    6.23 -			filter.append("period_in(textout("+ end +"))");
    6.24 +			    try {
    6.25 +					format.parse(end.toString());
    6.26 +				} catch (ParseException e) {
    6.27 +					// TODO Auto-generated catch block
    6.28 +					e.printStackTrace();
    6.29 +				}
    6.30 +			filter.append("period("+ end +")");
    6.31  		}
    6.32  		else
    6.33  		{
    6.34 @@ -1036,6 +1046,34 @@
    6.35  		appendGeneralDBTemporalFunctionBinary(expr, filter, expr.getOperator());
    6.36  		
    6.37  	}
    6.38 +	@Override
    6.39 +	protected void append(GeneralDBSqlOverrightPeriod expr,
    6.40 +			GeneralDBSqlExprBuilder filter)
    6.41 +			throws UnsupportedRdbmsOperatorException {
    6.42 +		appendGeneralDBTemporalFunctionBinary(expr, filter, expr.getOperator());
    6.43 +		
    6.44 +	}
    6.45 +	@Override
    6.46 +	protected void append(GeneralDBSqlOverleftPeriod expr,
    6.47 +			GeneralDBSqlExprBuilder filter)
    6.48 +			throws UnsupportedRdbmsOperatorException {
    6.49 +		appendGeneralDBTemporalFunctionBinary(expr, filter, expr.getOperator());
    6.50 +		
    6.51 +	}
    6.52 +	@Override
    6.53 +	protected void append(GeneralDBSqlEqualsPeriod expr,
    6.54 +			GeneralDBSqlExprBuilder filter)
    6.55 +			throws UnsupportedRdbmsOperatorException {
    6.56 +		appendGeneralDBTemporalFunctionBinary(expr, filter, expr.getOperator());
    6.57 +		
    6.58 +	}
    6.59 +	@Override
    6.60 +	protected void append(GeneralDBSqlNequalsPeriod expr,
    6.61 +			GeneralDBSqlExprBuilder filter)
    6.62 +			throws UnsupportedRdbmsOperatorException {
    6.63 +		appendGeneralDBTemporalFunctionBinary(expr, filter, expr.getOperator());
    6.64 +		
    6.65 +	}
    6.66  	
    6.67  	@Override
    6.68  	protected void append(GeneralDBSqlPeriodIntersection expr, GeneralDBSqlExprBuilder filter)
    6.69 @@ -1482,7 +1520,7 @@
    6.70  			}
    6.71  			
    6.72  			if(func.equals("=")|| func.equals("!=")|| func.equals("-")|| func.equals("+")|| func.equals("~")|| 
    6.73 -					func.equals("@")|| func.equals("<<")|| func.equals(">>")|| func.equals("&>")|| func.equals("&>")|| func.equals("&&"))
    6.74 +					func.equals("@")|| func.equals("<<")|| func.equals(">>")|| func.equals("&<")|| func.equals("&>")|| func.equals("&&"))
    6.75  			{
    6.76  				filter.append(" ");
    6.77  				filter.appendFunction(func);