Strabon

changeset 730:115bc7ddabb9 temporals

more changes to get to append temporal joinn functions
author Konstantina Bereta <Konstantina.Bereta@di.uoa.gr>
date Thu Nov 22 17:43:47 2012 +0200 (2012-11-22)
parents f0527de6dfb7
children 35884bc15005
files generaldb/src/main/java/org/openrdf/sail/generaldb/algebra/GeneralDBLabelColumn.java generaldb/src/main/java/org/openrdf/sail/generaldb/evaluation/GeneralDBEvaluation.java postgis/src/main/java/org/openrdf/sail/postgis/evaluation/PostGISEvaluation.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/GeneralDBLabelColumn.java	Thu Nov 22 16:51:51 2012 +0200
     1.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/algebra/GeneralDBLabelColumn.java	Thu Nov 22 17:43:47 2012 +0200
     1.3 @@ -13,11 +13,14 @@
     1.4   * Represents a variable's label value in an SQL expression.
     1.5   * 
     1.6   * @author James Leigh
     1.7 + * @author Manos Karpathiotakis <mk@di.uoa.gr>
     1.8 + * @author Konstantina Bereta <Konstantina.Bereta@di.uoa.gr>
     1.9   * 
    1.10   */
    1.11  public class GeneralDBLabelColumn extends GeneralDBValueColumnBase {
    1.12  
    1.13  	private boolean spatial = false;
    1.14 +	private boolean temporal = false;
    1.15  	
    1.16  	public GeneralDBLabelColumn(Var var) {
    1.17  		 
    1.18 @@ -30,7 +33,16 @@
    1.19  			String originalName = var.getName().substring(0, whereToCut);
    1.20  			var.setName(originalName);
    1.21  			super.setVarName(originalName);
    1.22 +		}// constant- just copied behaviour to comply with temporal values as well
    1.23 +		else if(var.getName().endsWith("?temporal"))
    1.24 +		{
    1.25 +			setTemporal(true);
    1.26 +			int whereToCut = var.getName().lastIndexOf("?");
    1.27 +			String originalName = var.getName().substring(0, whereToCut);
    1.28 +			var.setName(originalName);
    1.29 +			super.setVarName(originalName);
    1.30  		}
    1.31 +		
    1.32  	}
    1.33  
    1.34  	public GeneralDBLabelColumn(GeneralDBColumnVar var) {
    1.35 @@ -40,6 +52,7 @@
    1.36  		{
    1.37  			setSpatial(true);
    1.38  		}
    1.39 +		
    1.40  	}
    1.41  	
    1.42  	public GeneralDBLabelColumn(GeneralDBColumnVar var, boolean isSpatial) {
    1.43 @@ -56,6 +69,15 @@
    1.44  		this.spatial = spatial;
    1.45  	}
    1.46  
    1.47 +	public boolean isTemporal() {
    1.48 +		return temporal;
    1.49 +	}
    1.50 +
    1.51 +	public void setTemporal(boolean spatial) {
    1.52 +		this.temporal = spatial;
    1.53 +	}
    1.54 +
    1.55 +	
    1.56  	@Override
    1.57  	public <X extends Exception> void visit(GeneralDBQueryModelVisitorBase<X> visitor)
    1.58  		throws X
     2.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/evaluation/GeneralDBEvaluation.java	Thu Nov 22 16:51:51 2012 +0200
     2.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/evaluation/GeneralDBEvaluation.java	Thu Nov 22 17:43:47 2012 +0200
     2.3 @@ -142,7 +142,6 @@
     2.4  	//	private HashMap<String, Integer> metricIndexesAndNames = new HashMap<String, Integer>();
     2.5  	//	private HashMap<String, Integer> intPropertiesIndexesAndNames = new HashMap<String, Integer>();
     2.6  	//	private HashMap<String, Integer> boolPropertiesIndexesAndNames = new HashMap<String, Integer>();
     2.7 -	//	private HashMap<String, Integer> stringPropertiesIndexesAndNames = new HashMap<String, Integer>();
     2.8  
     2.9  	protected HashMap<Integer,String> temporalVars = new HashMap<Integer,String>();
    2.10  
     3.1 --- a/postgis/src/main/java/org/openrdf/sail/postgis/evaluation/PostGISEvaluation.java	Thu Nov 22 16:51:51 2012 +0200
     3.2 +++ b/postgis/src/main/java/org/openrdf/sail/postgis/evaluation/PostGISEvaluation.java	Thu Nov 22 17:43:47 2012 +0200
     3.3 @@ -74,6 +74,7 @@
     3.4  				result.setGeoNames(this.geoNames);
     3.5  				result.setConstructIndexesAndNames(this.constructIndexesAndNames);
     3.6  				//XXX addition- constant
     3.7 +				result.setTemporalVars(this.temporalVars);
     3.8  				if (logger.isDebugEnabled()) {
     3.9  					logger.debug("In PostGIS Evaluation, query is: \n{}", stmt);
    3.10  				}
     4.1 --- a/postgis/src/main/java/org/openrdf/sail/postgis/evaluation/PostGISQueryBuilder.java	Thu Nov 22 16:51:51 2012 +0200
     4.2 +++ b/postgis/src/main/java/org/openrdf/sail/postgis/evaluation/PostGISQueryBuilder.java	Thu Nov 22 17:43:47 2012 +0200
     4.3 @@ -106,6 +106,7 @@
     4.4   * Constructs an SQL query from {@link GeneralDBSqlExpr}s and {@link GeneralDBFromItem}s.
     4.5   * 
     4.6   * @author Manos Karpathiotakis <mk@di.uoa.gr>
     4.7 + * @Konstantina Bereta <Konstantina.Bereta@di.uoa.gr>
     4.8   * 
     4.9   */
    4.10  public class PostGISQueryBuilder extends GeneralDBQueryBuilder {
    4.11 @@ -114,6 +115,10 @@
    4.12  	public static final String SRID_FIELD = "srid";
    4.13  	public static final String ST_TRANSFORM = "ST_Transform";
    4.14  	public static final String ST_ASBINARY = "ST_AsBinary";
    4.15 +	
    4.16 +	public static final String PERIOD_COLUMN = "period"; //this is the name of the period column in period_values table
    4.17 +	public static final String PERIOD_TO_CSTRING="period_out"; //postgres temporal functions for converting period to cstring
    4.18 +	public static final String CSTRING_TO_TEXT="textin"; //postres function for converting cstring to text
    4.19  	/**
    4.20  	 * If (spatial) label column met is null, I must not try to retrieve its srid. 
    4.21  	 * Opting to ask for 'null' instead
    4.22 @@ -243,6 +248,8 @@
    4.23  			nullLabel = true;
    4.24  		}
    4.25  		else {
    4.26 +			String alias = getLabelAlias(var.getRdbmsVar());
    4.27 +
    4.28  			if(var.isSpatial())
    4.29  			{
    4.30  				filter.appendFunction(ST_ASBINARY);
    4.31 @@ -251,7 +258,6 @@
    4.32  				filter.appendFunction(ST_TRANSFORM);
    4.33  				filter.openBracket();
    4.34  				//
    4.35 -				String alias = getLabelAlias(var.getRdbmsVar());
    4.36  
    4.37  				filter.column(alias, STRDFGEO_FIELD);
    4.38  				//XXX SRID
    4.39 @@ -265,10 +271,20 @@
    4.40  				filter.appendComma();
    4.41  				filter.column(alias, SRID_FIELD);
    4.42  			}
    4.43 -			else
    4.44 +			else if(var.isTemporal())
    4.45  			{
    4.46 +				//textin(period_out(period))
    4.47 +				filter.appendFunction(CSTRING_TO_TEXT);
    4.48 +				filter.openBracket();
    4.49 +				filter.appendFunction(PERIOD_TO_CSTRING);
    4.50 +				filter.openBracket();
    4.51 +				filter.column(alias,PERIOD_COLUMN);
    4.52 +				filter.closeBracket();
    4.53 +				filter.closeBracket();
    4.54 +			}
    4.55 +			else{
    4.56  				//XXX original/default case
    4.57 -				String alias = getLabelAlias(var.getRdbmsVar());
    4.58 +				System.out.println("DEFAUUUUULT!: a value column will be printed");
    4.59  				filter.column(alias, "value");
    4.60  			}
    4.61  		}