Strabon

changeset 746:e72e4b2412ce temporals

Added support for "NOW" when used in temporal functions
author Konstantina Bereta <Konstantina.Bereta@di.uoa.gr>
date Wed Nov 28 19:33:02 2012 +0200 (2012-11-28)
parents 565907aa0e93
children 5855c4eeb243
files postgis/src/main/java/org/openrdf/sail/postgis/evaluation/PostGISQueryBuilder.java runtime/src/main/java/eu/earthobservatory/runtime/generaldb/NQuadsParser.java
line diff
     1.1 --- a/postgis/src/main/java/org/openrdf/sail/postgis/evaluation/PostGISQueryBuilder.java	Wed Nov 28 19:16:03 2012 +0200
     1.2 +++ b/postgis/src/main/java/org/openrdf/sail/postgis/evaluation/PostGISQueryBuilder.java	Wed Nov 28 19:33:02 2012 +0200
     1.3 @@ -6,8 +6,13 @@
     1.4  package org.openrdf.sail.postgis.evaluation;
     1.5  
     1.6  import java.util.ArrayList;
     1.7 +import java.util.Calendar;
     1.8 +import java.util.Date;
     1.9 +import java.util.GregorianCalendar;
    1.10  import java.util.List;
    1.11 +import java.util.TimeZone;
    1.12  
    1.13 +import org.openrdf.query.algebra.evaluation.function.datetime.Timezone;
    1.14  import org.openrdf.query.algebra.evaluation.function.spatial.StrabonPolyhedron;
    1.15  import org.openrdf.sail.generaldb.algebra.GeneralDBColumnVar;
    1.16  import org.openrdf.sail.generaldb.algebra.GeneralDBDoubleValue;
    1.17 @@ -964,8 +969,25 @@
    1.18  		String period = arg.getValue();
    1.19  		
    1.20  		//FIXME period constant should be validated before appended
    1.21 -		
    1.22 -		filter.append("period_in(textout('"+period+"'))");
    1.23 +		if(period.equalsIgnoreCase("now"))
    1.24 +		{
    1.25 +			filter.append("period(now())");
    1.26 +		}
    1.27 +		else if(period.equalsIgnoreCase("uc"))
    1.28 +		{
    1.29 +			   TimeZone UTC = TimeZone.getTimeZone("UTC");
    1.30 +			    final Calendar c = new GregorianCalendar(UTC);
    1.31 +			    c.set(1, 0, 1, 0, 0, 0);
    1.32 +			    c.set(Calendar.MILLISECOND, 0);
    1.33 +			    Date begin = c.getTime();
    1.34 +			    c.setTime(new Date(Long.MAX_VALUE));
    1.35 +			    Date end = c.getTime();
    1.36 +			filter.append("period_in(textout("+ end +"))");
    1.37 +		}
    1.38 +		else
    1.39 +		{
    1.40 +			filter.append("period_in(textout('"+period+"'))");
    1.41 +		}
    1.42  		return period;
    1.43  	}
    1.44  	
     2.1 --- a/runtime/src/main/java/eu/earthobservatory/runtime/generaldb/NQuadsParser.java	Wed Nov 28 19:16:03 2012 +0200
     2.2 +++ b/runtime/src/main/java/eu/earthobservatory/runtime/generaldb/NQuadsParser.java	Wed Nov 28 19:33:02 2012 +0200
     2.3 @@ -205,6 +205,7 @@
     2.4      	validTimeLiteral=sb;
     2.5      	if(sb.toString().contains("^^<http://strdf.di.uoa.gr/ontology#validTime>"))
     2.6       	{	
     2.7 +    	
     2.8       	String[] splits = sb.toString().split(",");
     2.9       	int i1 = splits[0].indexOf('[');
    2.10       	int i2 = splits[1].indexOf(']');