Strabon

changeset 821:4a67573708da temporals

modified again the query engine as follows: Temporal instants are returned as xsd:dateTime values (instead of periods with the same starting and ending points as implemented in Postgres Temporal)
author Konstantina Bereta <Konstantina.Bereta@di.uoa.gr>
date Wed Dec 19 20:18:19 2012 +0200 (2012-12-19)
parents 9cd84c21ffbd
children 1562eb0afdcb
files evaluation/src/main/java/org/openrdf/query/algebra/evaluation/function/temporal/stsparql/relation/TemporalConstants.java postgis/src/main/java/org/openrdf/sail/postgis/iteration/PostGISBindingIteration.java runtime/src/main/java/eu/earthobservatory/runtime/generaldb/QuadRDFHandler.java
line diff
     1.1 --- a/evaluation/src/main/java/org/openrdf/query/algebra/evaluation/function/temporal/stsparql/relation/TemporalConstants.java	Wed Dec 19 19:43:34 2012 +0200
     1.2 +++ b/evaluation/src/main/java/org/openrdf/query/algebra/evaluation/function/temporal/stsparql/relation/TemporalConstants.java	Wed Dec 19 20:18:19 2012 +0200
     1.3 @@ -19,6 +19,8 @@
     1.4  	
     1.5  	public static final String PERIOD                = stRDF + "period";
     1.6  	
     1.7 +	public static final String INSTANT = "http://www.w3.org/2001/XMLSchema#dateTime";
     1.8 +	
     1.9  	//Temporal Relationships
    1.10  	public static final String periodContains= stRDF+ "PeriodContains";
    1.11  
     2.1 --- a/postgis/src/main/java/org/openrdf/sail/postgis/iteration/PostGISBindingIteration.java	Wed Dec 19 19:43:34 2012 +0200
     2.2 +++ b/postgis/src/main/java/org/openrdf/sail/postgis/iteration/PostGISBindingIteration.java	Wed Dec 19 20:18:19 2012 +0200
     2.3 @@ -73,6 +73,7 @@
     2.4  		int i = temp.indexOf("[");
     2.5  		int j = temp.indexOf(")"); //postgres always returns periods in the following format: [start, end)
     2.6  		String label = null;
     2.7 +		URI datatype = null;
     2.8  		String[] periods = temp.substring(++i, j).split(",");
     2.9  
    2.10  		SimpleDateFormat postgres = new SimpleDateFormat("yyyy-MM-DD HH:mm:ss");
    2.11 @@ -81,7 +82,16 @@
    2.12  			
    2.13  			String newStart = xsd.format(postgres.parse(periods[0])).toString();
    2.14  			String newEnd = xsd.format(postgres.parse(periods[1])).toString();
    2.15 -			label = temp.replace(periods[0], newStart).replace(periods[1], newEnd);
    2.16 +			if(newStart.equalsIgnoreCase(newEnd))
    2.17 +			{
    2.18 +				label = newStart;
    2.19 +			    datatype = vf.createURI(TemporalConstants.INSTANT);
    2.20 +			}
    2.21 +			else
    2.22 +			{
    2.23 +				label = temp.replace(periods[0], newStart).replace(periods[1], newEnd);
    2.24 +			    datatype = vf.createURI(TemporalConstants.PERIOD);		
    2.25 +			}			
    2.26  			
    2.27  		} catch (ParseException e) {
    2.28  			// TODO Auto-generated catch block
    2.29 @@ -89,7 +99,6 @@
    2.30  		}
    2.31  		// label=temp.replace(" ", "T");
    2.32  			//String label = rs.getObject(index+1).toString();
    2.33 -		    URI datatype = vf.createURI(TemporalConstants.PERIOD);
    2.34  		    return vf.createLiteral(label, datatype);
    2.35  		    
    2.36  		}
     3.1 --- a/runtime/src/main/java/eu/earthobservatory/runtime/generaldb/QuadRDFHandler.java	Wed Dec 19 19:43:34 2012 +0200
     3.2 +++ b/runtime/src/main/java/eu/earthobservatory/runtime/generaldb/QuadRDFHandler.java	Wed Dec 19 20:18:19 2012 +0200
     3.3 @@ -49,14 +49,13 @@
     3.4  	        
     3.5  	        @Override
     3.6  	        public void handleStatement(Statement st) {
     3.7 -	            if(st.getContext().toString().contains("^^<"+TemporalConstants.PERIOD)||
     3.8 -	        			st.toString().contains("^^<http://strdf.di.uoa.gr/ontology#period>"))
     3.9 +	            if(st.getContext().toString().contains("^^<"+TemporalConstants.PERIOD)||st.getContext().toString().contains("^^<"+TemporalConstants.INSTANT))
    3.10  	         	{	
    3.11  	         	    NQuadsParser parser = new NQuadsParser();
    3.12  	         		try {
    3.13  	         			String context = st.getContext().toString();
    3.14  						 String validPeriod= context;
    3.15 -						 if(!context.contains(","))
    3.16 +						 if(context.contains("^^<"+TemporalConstants.INSTANT))
    3.17  						 {
    3.18  							 int i = context.indexOf('"')+1;
    3.19  							 int j = context.lastIndexOf('"');