Strabon

changeset 839:9a76dc603a5a temporals

added functions:precedingPeriod, SucceedingPeriod, period(constructs a period given 2 dateTime arguments) to be used in the select part of an stSPARQL query
author Konstantina Bereta <Konstantina.Bereta@di.uoa.gr>
date Fri Jan 04 16:59:47 2013 +0200 (2013-01-04)
parents fb573773e72d
children 801830bd4d41
files evaluation/src/main/java/org/openrdf/query/algebra/evaluation/function/spatial/StrabonPeriod.java evaluation/src/main/java/org/openrdf/query/algebra/evaluation/function/temporal/stsparql/construct/PeriodFunc.java evaluation/src/main/java/org/openrdf/query/algebra/evaluation/function/temporal/stsparql/construct/PeriodPrecedingFunc.java evaluation/src/main/java/org/openrdf/query/algebra/evaluation/function/temporal/stsparql/construct/PeriodSucceedingFunc.java evaluation/src/main/resources/META-INF/services/org.openrdf.query.algebra.evaluation.function.Function generaldb/src/main/java/org/openrdf/sail/generaldb/evaluation/GeneralDBEvaluation.java
line diff
     1.1 --- a/evaluation/src/main/java/org/openrdf/query/algebra/evaluation/function/spatial/StrabonPeriod.java	Fri Jan 04 16:18:42 2013 +0200
     1.2 +++ b/evaluation/src/main/java/org/openrdf/query/algebra/evaluation/function/spatial/StrabonPeriod.java	Fri Jan 04 16:59:47 2013 +0200
     1.3 @@ -60,19 +60,18 @@
     1.4  	
     1.5  	}
     1.6  	
     1.7 -	public StrabonPeriod(String period1, String period2) throws ParseException
     1.8 +	public StrabonPeriod(String instant1, String instant2) throws ParseException
     1.9  	{
    1.10  		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-DD'T'HH:mm:ss");
    1.11  	
    1.12  			GregorianCalendar startCal = new GregorianCalendar();
    1.13  			GregorianCalendar endCal = new GregorianCalendar();
    1.14 -			startCal.setTime(sdf.parse(period1.substring(period1.indexOf('"')+1,period1.lastIndexOf('"') )));
    1.15 -			endCal.setTime(sdf.parse(period2.substring(period2.indexOf('"')+1,period2.lastIndexOf('"') )));
    1.16 +			startCal.setTime(sdf.parse(instant1.substring(instant1.indexOf('"')+1,instant1.lastIndexOf('"') )));
    1.17 +			endCal.setTime(sdf.parse(instant2.substring(instant2.indexOf('"')+1,instant2.lastIndexOf('"') )));
    1.18  			StrabonInstant start = new StrabonInstant(startCal);
    1.19  			StrabonInstant end = new StrabonInstant(endCal);
    1.20  			this.period = new Period(start, end);
    1.21  			this.datatype = new URIImpl(TemporalConstants.PERIOD);
    1.22 -
    1.23  	}
    1.24  	
    1.25  	public void setDatatype(URI datatype) {
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/evaluation/src/main/java/org/openrdf/query/algebra/evaluation/function/temporal/stsparql/construct/PeriodFunc.java	Fri Jan 04 16:59:47 2013 +0200
     2.3 @@ -0,0 +1,29 @@
     2.4 +/**
     2.5 + * This Source Code Form is subject to the terms of the Mozilla Public
     2.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     2.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/.
     2.8 + *
     2.9 + * Copyright (C) 2013, Pyravlos Team
    2.10 + *
    2.11 + * http://www.strabon.di.uoa.gr/
    2.12 + */
    2.13 +package org.openrdf.query.algebra.evaluation.function.temporal.stsparql.construct;
    2.14 +
    2.15 +import org.openrdf.query.algebra.evaluation.function.temporal.stsparql.relation.TemporalConstants;
    2.16 +import org.openrdf.query.algebra.evaluation.function.temporal.stsparql.relation.TemporalRelationFunc;
    2.17 +
    2.18 +/**
    2.19 + * @author Konstantina Bereta <Konstantina.Bereta@di.uoa.gr>
    2.20 + * This function constructs a period given two timestamps(dateTime values)
    2.21 + */
    2.22 +public class PeriodFunc  extends TemporalConstructFunc {
    2.23 +	
    2.24 +    
    2.25 +	@Override
    2.26 +	public String getURI() {
    2.27 +	
    2.28 +		return TemporalConstants.PERIOD;
    2.29 +	}
    2.30 +
    2.31 +	
    2.32 +}
    2.33 \ No newline at end of file
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/evaluation/src/main/java/org/openrdf/query/algebra/evaluation/function/temporal/stsparql/construct/PeriodPrecedingFunc.java	Fri Jan 04 16:59:47 2013 +0200
     3.3 @@ -0,0 +1,29 @@
     3.4 +/**
     3.5 + * This Source Code Form is subject to the terms of the Mozilla Public
     3.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     3.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/.
     3.8 + *
     3.9 + * Copyright (C) 2013, Pyravlos Team
    3.10 + *
    3.11 + * http://www.strabon.di.uoa.gr/
    3.12 + */
    3.13 +package org.openrdf.query.algebra.evaluation.function.temporal.stsparql.construct;
    3.14 +
    3.15 +import org.openrdf.query.algebra.evaluation.function.temporal.stsparql.relation.TemporalConstants;
    3.16 +import org.openrdf.query.algebra.evaluation.function.temporal.stsparql.relation.TemporalRelationFunc;
    3.17 +
    3.18 +/**
    3.19 + * @author Konstantina Bereta <Konstantina.Bereta@di.uoa.gr>
    3.20 + *
    3.21 + */
    3.22 +public class PeriodPrecedingFunc  extends TemporalConstructFunc {
    3.23 +	
    3.24 +    
    3.25 +	@Override
    3.26 +	public String getURI() {
    3.27 +	
    3.28 +		return TemporalConstants.precedingPeriod;
    3.29 +	}
    3.30 +
    3.31 +	
    3.32 +}
    3.33 \ No newline at end of file
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/evaluation/src/main/java/org/openrdf/query/algebra/evaluation/function/temporal/stsparql/construct/PeriodSucceedingFunc.java	Fri Jan 04 16:59:47 2013 +0200
     4.3 @@ -0,0 +1,29 @@
     4.4 +/**
     4.5 + * This Source Code Form is subject to the terms of the Mozilla Public
     4.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     4.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/.
     4.8 + *
     4.9 + * Copyright (C) 2013, Pyravlos Team
    4.10 + *
    4.11 + * http://www.strabon.di.uoa.gr/
    4.12 + */
    4.13 +package org.openrdf.query.algebra.evaluation.function.temporal.stsparql.construct;
    4.14 +
    4.15 +import org.openrdf.query.algebra.evaluation.function.temporal.stsparql.relation.TemporalConstants;
    4.16 +import org.openrdf.query.algebra.evaluation.function.temporal.stsparql.relation.TemporalRelationFunc;
    4.17 +
    4.18 +/**
    4.19 + * @author Konstantina Bereta <Konstantina.Bereta@di.uoa.gr>
    4.20 + *
    4.21 + */
    4.22 +public class PeriodSucceedingFunc  extends TemporalConstructFunc {
    4.23 +	
    4.24 +    
    4.25 +	@Override
    4.26 +	public String getURI() {
    4.27 +	
    4.28 +		return TemporalConstants.succedingPeriod;
    4.29 +	}
    4.30 +
    4.31 +	
    4.32 +}
    4.33 \ No newline at end of file
     5.1 --- a/evaluation/src/main/resources/META-INF/services/org.openrdf.query.algebra.evaluation.function.Function	Fri Jan 04 16:18:42 2013 +0200
     5.2 +++ b/evaluation/src/main/resources/META-INF/services/org.openrdf.query.algebra.evaluation.function.Function	Fri Jan 04 16:59:47 2013 +0200
     5.3 @@ -79,6 +79,9 @@
     5.4  org.openrdf.query.algebra.evaluation.function.spatial.geosparql.sf.SimpleFeaturesWithinFunc
     5.5  org.openrdf.query.algebra.evaluation.function.spatial.geosparql.sf.SimpleFeatureTouchesFunc
     5.6  org.openrdf.query.algebra.evaluation.function.temporal.stsparql.construct.PeriodIntersectionFunc
     5.7 +org.openrdf.query.algebra.evaluation.function.temporal.stsparql.construct.PeriodPrecedingFunc
     5.8 +org.openrdf.query.algebra.evaluation.function.temporal.stsparql.construct.PeriodSucceedingFunc
     5.9 +org.openrdf.query.algebra.evaluation.function.temporal.stsparql.construct.PeriodFunc
    5.10  org.openrdf.query.algebra.evaluation.function.temporal.stsparql.construct.PeriodMinusFunc
    5.11  org.openrdf.query.algebra.evaluation.function.temporal.stsparql.construct.periodUnionFunc
    5.12  org.openrdf.query.algebra.evaluation.function.temporal.stsparql.relation.AdjacentPeriodFunc
     6.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/evaluation/GeneralDBEvaluation.java	Fri Jan 04 16:18:42 2013 +0200
     6.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/evaluation/GeneralDBEvaluation.java	Fri Jan 04 16:59:47 2013 +0200
     6.3 @@ -586,6 +586,12 @@
     6.4  		{
     6.5  			return StrabonPeriod.succedingPeriod(new StrabonPeriod(left.toString()), new StrabonPeriod(right.toString()));
     6.6  		}
     6.7 +		else if(function.getURI().equals(TemporalConstants.PERIOD))
     6.8 +		{ //constracting a new period given two dateTime values
     6.9 +			if(left.toString().contains(",") || right.toString().contains(","))
    6.10 +				return null;
    6.11 +			return new StrabonPeriod(left.toString(), right.toString());
    6.12 +		}
    6.13  		else
    6.14  		{
    6.15  			return null;