Strabon

changeset 44:7bbf921b454d

Fixed case where stRDF datatype was not present in spatial constructs related to aggregate clause.
author Manos Karpathiotakis <mk@di.uoa.gr>
date Mon Mar 12 14:27:44 2012 +0200 (2012-03-12)
parents 07eaeca98f59
children 9199c0cbaa91 b74d143a7ef7
files evaluation/src/main/java/org/openrdf/query/algebra/evaluation/iterator/StSPARQLGroupIterator.java 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/iterator/StSPARQLGroupIterator.java	Sat Mar 10 03:55:10 2012 +0200
     1.2 +++ b/evaluation/src/main/java/org/openrdf/query/algebra/evaluation/iterator/StSPARQLGroupIterator.java	Mon Mar 12 14:27:44 2012 +0200
     1.3 @@ -18,11 +18,13 @@
     1.4  import info.aduna.iteration.CloseableIteratorIteration;
     1.5  import info.aduna.lang.ObjectUtil;
     1.6  
     1.7 +import org.openrdf.model.URI;
     1.8  import org.openrdf.model.Literal;
     1.9  import org.openrdf.model.Value;
    1.10  import org.openrdf.model.datatypes.XMLDatatypeUtil;
    1.11  import org.openrdf.model.impl.LiteralImpl;
    1.12  import org.openrdf.model.impl.NumericLiteralImpl;
    1.13 +import org.openrdf.model.impl.URIImpl;
    1.14  import org.openrdf.model.impl.ValueFactoryImpl;
    1.15  import org.openrdf.model.vocabulary.XMLSchema;
    1.16  import org.openrdf.query.BindingSet;
    1.17 @@ -349,11 +351,12 @@
    1.18  				//LiteralImpl lit 
    1.19  				try {
    1.20  					val = evaluateConstruct(expr, this.prototype);
    1.21 -				} catch (Exception e) {
    1.22 +					} catch (Exception e) {
    1.23  					e.printStackTrace();
    1.24  				}
    1.25  				if (val != null) {
    1.26 -					sol.setBinding(name,val);
    1.27 +					Literal wkt = new LiteralImpl(val.toString(),new URIImpl(StrabonPolyhedron.ogcGeometry));
    1.28 +					sol.setBinding(name,wkt);
    1.29  				}
    1.30  
    1.31  			}
     2.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/evaluation/GeneralDBEvaluation.java	Sat Mar 10 03:55:10 2012 +0200
     2.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/evaluation/GeneralDBEvaluation.java	Mon Mar 12 14:27:44 2012 +0200
     2.3 @@ -32,6 +32,7 @@
     2.4  import info.aduna.iteration.EmptyIteration;
     2.5  
     2.6  import org.opengis.filter.spatial.Disjoint;
     2.7 +import org.openrdf.model.Literal;
     2.8  import org.openrdf.model.Value;
     2.9  import org.openrdf.model.impl.BooleanLiteralImpl;
    2.10  import org.openrdf.model.impl.LiteralImpl;
    2.11 @@ -244,7 +245,7 @@
    2.12  	@Override
    2.13  	public Value evaluate(FunctionCall fc, BindingSet bindings)
    2.14  	{
    2.15 -		System.out.println("FunctionCall placeholder");
    2.16 +//		System.out.println("FunctionCall placeholder");
    2.17  
    2.18  		if(fc.getParentNode() instanceof Avg)
    2.19  		{
    2.20 @@ -333,6 +334,15 @@
    2.21  				{
    2.22  					leftGeom = ((GeneralDBPolyhedron) leftResult).getPolyhedron().getGeometry();
    2.23  				}
    2.24 +				else if(leftResult instanceof Literal)
    2.25 +				{	
    2.26 +					/**
    2.27 +					 * Duplicate work done here in order to retain the literal's datatype...
    2.28 +					 * Instead of only utilizing StrabonPolyhedron items, I converted them to Literals
    2.29 +					 * in order to have them appear in Select Clause along with the appropriate datatype.
    2.30 +					 */
    2.31 +					leftGeom = new StrabonPolyhedron(((Literal) leftResult).getLabel()).getGeometry();
    2.32 +				}
    2.33  				else
    2.34  				{	//SHOULD NEVER REACH THIS CASE!
    2.35  					return null;
    2.36 @@ -346,6 +356,15 @@
    2.37  				{
    2.38  					rightGeom = ((GeneralDBPolyhedron) rightResult).getPolyhedron().getGeometry();
    2.39  				}
    2.40 +				else if(rightResult instanceof Literal)
    2.41 +				{	
    2.42 +					/**
    2.43 +					 * Duplicate work done here in order to retain the literal's datatype...
    2.44 +					 * Instead of only utilizing StrabonPolyhedron items, I converted them to Literals
    2.45 +					 * in order to have them appear in Select Clause along with the appropriate datatype.
    2.46 +					 */
    2.47 +					rightGeom = new StrabonPolyhedron(((Literal) rightResult).getLabel()).getGeometry();
    2.48 +				}
    2.49  				else
    2.50  				{	//SHOULD NEVER REACH THIS CASE!
    2.51  					return null;
    2.52 @@ -409,6 +428,7 @@
    2.53  				return funcResult ? BooleanLiteralImpl.TRUE : BooleanLiteralImpl.FALSE;
    2.54  			}
    2.55  			else {
    2.56 +			//Default Sesame Behavior
    2.57  				List<ValueExpr> args = fc.getArgs();
    2.58  
    2.59  				Value[] argValues = new Value[args.size()];