Strabon

changeset 838:fb573773e72d temporals

Fixed functions: peridUnion, periodIntersection and minusPeriod when used in the select clause of the query
author Konstantina Bereta <Konstantina.Bereta@di.uoa.gr>
date Fri Jan 04 16:18:42 2013 +0200 (2013-01-04)
parents 8ffcde5a3127
children 9a76dc603a5a
files evaluation/src/main/java/org/openrdf/query/algebra/evaluation/function/spatial/StrabonPeriod.java generaldb/src/main/java/org/openrdf/sail/generaldb/evaluation/GeneralDBEvaluation.java resultio/src/main/java/org/openrdf/query/resultio/text/stSPARQLResultsTSVWriter.java
line diff
     1.1 --- a/evaluation/src/main/java/org/openrdf/query/algebra/evaluation/function/spatial/StrabonPeriod.java	Fri Jan 04 15:16:08 2013 +0200
     1.2 +++ b/evaluation/src/main/java/org/openrdf/query/algebra/evaluation/function/spatial/StrabonPeriod.java	Fri Jan 04 16:18:42 2013 +0200
     1.3 @@ -100,6 +100,8 @@
     1.4  	@Override
     1.5  	public String stringValue() 
     1.6  	{
     1.7 +		if(this.period == null)
     1.8 +			return null;
     1.9  		return period.toString().replace("Period:(","[");
    1.10  	}
    1.11  
     2.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/evaluation/GeneralDBEvaluation.java	Fri Jan 04 15:16:08 2013 +0200
     2.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/evaluation/GeneralDBEvaluation.java	Fri Jan 04 16:18:42 2013 +0200
     2.3 @@ -549,8 +549,7 @@
     2.4  		}
     2.5  		else if(function.getURI().equals(TemporalConstants.periodIntersection))
     2.6  		{			
     2.7 -			System.out.println("left= "+left.toString());
     2.8 -			System.out.println("right= "+right.toString());
     2.9 +
    2.10  			StrabonTemporalElement rightArg= null;
    2.11  			StrabonTemporalElement leftArg= null;
    2.12  			
    2.13 @@ -574,7 +573,9 @@
    2.14  			return StrabonPeriod.intersection(rightArg, leftArg);
    2.15  		}
    2.16  		else if(function.getURI().equals(TemporalConstants.minusPeriod))
    2.17 -		{
    2.18 +		{ //this functions takes only periods as arguments
    2.19 +			if(!right.toString().contains(",") || !left.toString().contains(","))
    2.20 +				return null;
    2.21  			return StrabonPeriod.except(new StrabonPeriod(left.toString()), new StrabonPeriod(right.toString()));
    2.22  		}
    2.23  		else if(function.getURI().equals(TemporalConstants.precedingPeriod))
     3.1 --- a/resultio/src/main/java/org/openrdf/query/resultio/text/stSPARQLResultsTSVWriter.java	Fri Jan 04 15:16:08 2013 +0200
     3.2 +++ b/resultio/src/main/java/org/openrdf/query/resultio/text/stSPARQLResultsTSVWriter.java	Fri Jan 04 16:18:42 2013 +0200
     3.3 @@ -35,6 +35,8 @@
     3.4  
     3.5  	@Override
     3.6  	protected void writeValue(Value val) throws IOException {
     3.7 +		if (val.stringValue()== null)
     3.8 +			return;
     3.9  		if (val instanceof GeneralDBPolyhedron) {
    3.10  			// catch the spatial case and create a new literal
    3.11  			// constructing a new literal is the only way if we want to reuse the {@link #writeValue(Value)} method
    3.12 @@ -42,10 +44,12 @@
    3.13  			val = new LiteralImpl(dbpolyhedron.getPolyhedronStringRep(), dbpolyhedron.getDatatype());
    3.14  		}
    3.15  		else if(val instanceof StrabonTemporalElement){
    3.16 +			//creating a temporal literal, which is either a period or an instant
    3.17 +			
    3.18  			val = new LiteralImpl(((StrabonTemporalElement)val).stringValue(), ((StrabonTemporalElement) val).getDatatype());
    3.19  		}
    3.20  		
    3.21 -		// write value
    3.22 +		// write value		
    3.23  		super.writeValue(val);
    3.24  		
    3.25  	}