Strabon

changeset 141:2392a5bf7b9c

minor fix - transform function used to cause exception when predicate existing in triple pattern was missing from the stored db schema
author Manos Karpathiotakis <mk@di.uoa.gr>
date Wed May 09 16:06:35 2012 +0300 (2012-05-09)
parents 1de6a3e4670f
children 36df5f584371
files postgis/src/main/java/org/openrdf/sail/postgis/evaluation/PostGISQueryBuilder.java
line diff
     1.1 --- a/postgis/src/main/java/org/openrdf/sail/postgis/evaluation/PostGISQueryBuilder.java	Wed May 09 12:35:14 2012 +0300
     1.2 +++ b/postgis/src/main/java/org/openrdf/sail/postgis/evaluation/PostGISQueryBuilder.java	Wed May 09 16:06:35 2012 +0300
     1.3 @@ -1073,9 +1073,17 @@
     1.4  					tmp = child;
     1.5  					if(tmp instanceof GeneralDBLabelColumn)
     1.6  					{
     1.7 -						//Reached the innermost left var -> need to capture its SRID
     1.8 -						String alias = getLabelAlias(((GeneralDBLabelColumn) tmp).getRdbmsVar());
     1.9 -						alias=alias+".srid";
    1.10 +						String alias;
    1.11 +						if (((GeneralDBLabelColumn) tmp).getRdbmsVar().isResource()) {
    1.12 +							//Predicates used in triple patterns non-existent in db
    1.13 +							alias="NULL";
    1.14 +						}
    1.15 +						else
    1.16 +						{
    1.17 +							//Reached the innermost left var -> need to capture its SRID
    1.18 +							alias = getLabelAlias(((GeneralDBLabelColumn) tmp).getRdbmsVar());
    1.19 +							alias=alias+".srid";
    1.20 +						}
    1.21  						sridExpr = alias;
    1.22  						//						((GeneralDBSqlSpatialConstructBinary)expr).setSrid(alias);
    1.23  						break;
    1.24 @@ -1115,7 +1123,7 @@
    1.25  			{
    1.26  				appendMBB((GeneralDBLabelColumn)(expr.getLeftArg()),filter);
    1.27  			}
    1.28 -			
    1.29 +
    1.30  			//SRID Support
    1.31  			if(expr instanceof GeneralDBSqlSpatialConstructBinary && expr.getParentNode() == null)
    1.32  			{
    1.33 @@ -1124,13 +1132,13 @@
    1.34  				filter.append(sridExpr);
    1.35  				filter.closeBracket();
    1.36  			}
    1.37 -			
    1.38 +
    1.39  			filter.appendComma();
    1.40  
    1.41  			if(expr.getRightArg() instanceof GeneralDBSqlCase) //case met in transform!
    1.42  			{
    1.43  				GeneralDBURIColumn plainURI = (GeneralDBURIColumn)((GeneralDBSqlCase)expr.getRightArg()).getEntries().get(0).getResult();
    1.44 -				
    1.45 +
    1.46  				//XXX This case would be met if we recovered the SRID URI from the db!!!
    1.47  				//Need to set sridExpr to the value of this new URI, otherwise the appended uri
    1.48  				//to the spatial object will be the wrong one!!!! (Seee following case)
    1.49 @@ -1143,16 +1151,17 @@
    1.50  			else if(expr.getRightArg() instanceof GeneralDBStringValue)
    1.51  			{
    1.52  				String unparsedSRID = ((GeneralDBStringValue)expr.getRightArg()).getValue();
    1.53 -//				int srid = Integer.parseInt(unparsedSRID.substring(unparsedSRID.lastIndexOf('/')+1));
    1.54 +				//				int srid = Integer.parseInt(unparsedSRID.substring(unparsedSRID.lastIndexOf('/')+1));
    1.55  				sridExpr = unparsedSRID.substring(unparsedSRID.lastIndexOf('/')+1);
    1.56  				filter.append(sridExpr);
    1.57  				filter.closeBracket();
    1.58  			}
    1.59  
    1.60 -			
    1.61 +
    1.62  		}
    1.63  		filter.closeBracket();
    1.64 -		//In this case, SRID is the one that has been provided by the user!!
    1.65 +		//In this case, SRID is the one that has been provided by the user!! 
    1.66 +		//I am including this extra binding to be used in subsequent (Aggregate) steps
    1.67  		if(expr instanceof GeneralDBSqlSpatialConstructBinary && expr.getParentNode() == null)
    1.68  		{
    1.69  			filter.appendComma();