Strabon

changeset 1176:17429203392e

Merge.
author Panayiotis Smeros <psmeros@di.uoa.gr>
date Thu May 16 17:36:07 2013 +0300 (2013-05-16)
parents d14171586485 7bf0f0cfc745
children b21554259954
files ChangeLog
line diff
     1.1 --- a/ChangeLog	Thu May 16 17:33:13 2013 +0300
     1.2 +++ b/ChangeLog	Thu May 16 17:36:07 2013 +0300
     1.3 @@ -46,6 +46,10 @@
     1.4  
     1.5  	* All Simple Features functions of GeoSPARQL do not use the ST_Relate 
     1.6  	PostGIS function
     1.7 +
     1.8 +	* Added diffTime function. This function performs the difference 
     1.9 +	between two literals of xsd:time datatype and returns a literal of
    1.10 +	the xsd:time datatype as well.
    1.11  	
    1.12  	* Added a testsuite package in default branch. Full tester guide can be found
    1.13  	in README. Among other, most of GeoSPARQL compliance tests  
     2.1 --- a/endpoint/WebContent/WEB-INF/connection.properties	Thu May 16 17:33:13 2013 +0300
     2.2 +++ b/endpoint/WebContent/WEB-INF/connection.properties	Thu May 16 17:36:07 2013 +0300
     2.3 @@ -1,6 +1,6 @@
     2.4  hostname=localhost
     2.5  port=5432
     2.6  dbengine=postgis
     2.7 -password=postgres
     2.8 +password=p1r3as
     2.9  dbname=endpoint
    2.10  username=postgres
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/evaluation/src/main/java/org/openrdf/query/algebra/evaluation/function/datetime/stsparql/metric/DiffTime.java	Thu May 16 17:36:07 2013 +0300
     3.3 @@ -0,0 +1,79 @@
     3.4 +/**
     3.5 + * This Source Code Form is subject to the terms of the Mozilla Public
     3.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     3.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/.
     3.8 + *
     3.9 + * Copyright (C) 2013, Pyravlos Team
    3.10 + *
    3.11 + * http://www.strabon.di.uoa.gr/
    3.12 + */
    3.13 +package org.openrdf.query.algebra.evaluation.function.datetime.stsparql.metric;
    3.14 +
    3.15 +import java.text.SimpleDateFormat;
    3.16 +import java.util.Calendar;
    3.17 +import java.util.GregorianCalendar;
    3.18 +
    3.19 +import org.openrdf.model.URI;
    3.20 +import org.openrdf.model.Value;
    3.21 +import org.openrdf.model.ValueFactory;
    3.22 +import org.openrdf.model.impl.URIImpl;
    3.23 +import org.openrdf.query.algebra.evaluation.ValueExprEvaluationException;
    3.24 +import org.openrdf.query.algebra.evaluation.function.spatial.DateTimeMetricFunc;
    3.25 +
    3.26 +import eu.earthobservatory.constants.GeoConstants;
    3.27 +
    3.28 +/** * 
    3.29 + * 
    3.30 + * @author Konstantina Bereta <Konstantina.Bereta@di.uoa.gr>
    3.31 + * 
    3.32 + */
    3.33 +public class DiffTime extends DateTimeMetricFunc {
    3.34 +
    3.35 +	// This functions returns the difference in msecs of two xsd:dateTimes
    3.36 +	
    3.37 +	@Override
    3.38 +	public String getURI() {
    3.39 +		return GeoConstants.diffTime;
    3.40 +	}
    3.41 +	
    3.42 +	@Override
    3.43 +	public Value evaluate(ValueFactory valueFactory, Value... args)
    3.44 +            throws ValueExprEvaluationException {
    3.45 +        if (args.length != 2) {
    3.46 +            throw new ValueExprEvaluationException(this.getURI()
    3.47 +                    + " requires exactly 2 arguments, got " + args.length);
    3.48 +        }
    3.49 +		String datatype = "<http://www.w3.org/2001/XMLSchema#time>";
    3.50 +		String timeFormat = "hh:mm:ss";
    3.51 +        SimpleDateFormat sdf = new SimpleDateFormat(timeFormat); //the format of xsd:Datetime
    3.52 +        String newTime=null;
    3.53 +
    3.54 +		long diff = 0;
    3.55 +    	try {
    3.56 +
    3.57 +    		String date1 = args[0].toString();
    3.58 +    	    date1 = date1.replace("^^"+datatype, "");
    3.59 +    	    date1 = date1.replace("\"", "");
    3.60 +    	    Calendar cal1 = new GregorianCalendar();
    3.61 +    		cal1.setTime(sdf.parse(date1));
    3.62 +    		
    3.63 +    		String date2 = args[1].toString();
    3.64 +    		date2 = date2.replace("^^"+datatype, "");
    3.65 +   	    date2 = date2.replace("\"", "");
    3.66 +    	    Calendar cal2 = new GregorianCalendar();
    3.67 +    		cal2.setTime(sdf.parse(date2));
    3.68 +    		
    3.69 +    		diff = cal2.getTimeInMillis() - cal1.getTimeInMillis();
    3.70 +    		
    3.71 +    		 newTime = sdf.format(diff).toString();
    3.72 +    		
    3.73 +
    3.74 +    	} catch (java.text.ParseException e) {
    3.75 +
    3.76 +			e.printStackTrace();
    3.77 +		}
    3.78 +    	
    3.79 +        return valueFactory.createLiteral(newTime, new URIImpl(datatype));
    3.80 +    }
    3.81 +
    3.82 +}
     4.1 --- a/evaluation/src/main/resources/META-INF/services/org.openrdf.query.algebra.evaluation.function.Function	Thu May 16 17:33:13 2013 +0300
     4.2 +++ b/evaluation/src/main/resources/META-INF/services/org.openrdf.query.algebra.evaluation.function.Function	Thu May 16 17:36:07 2013 +0300
     4.3 @@ -44,6 +44,7 @@
     4.4  org.openrdf.query.algebra.evaluation.function.spatial.stsparql.property.IsSimpleFunc
     4.5  org.openrdf.query.algebra.evaluation.function.spatial.stsparql.aggregate.ExtentFunc
     4.6  org.openrdf.query.algebra.evaluation.function.spatial.stsparql.aggregate.DateTimeDiff
     4.7 +org.openrdf.query.algebra.evaluation.function.spatial.stsparql.aggregate.DateTimeDiff
     4.8  org.openrdf.query.algebra.evaluation.function.spatial.geosparql.nontopological.GeoSparqlBoundaryFunc
     4.9  org.openrdf.query.algebra.evaluation.function.spatial.geosparql.nontopological.GeoSparqlBufferFunc
    4.10  org.openrdf.query.algebra.evaluation.function.spatial.geosparql.nontopological.GeoSparqlConvexHullFunc
    4.11 @@ -81,6 +82,7 @@
    4.12  org.openrdf.query.algebra.evaluation.function.spatial.geosparql.sf.SimpleFeatureTouchesFunc
    4.13  
    4.14  org.openrdf.query.algebra.evaluation.function.datetime.stsparql.metric.DiffDateTime
    4.15 +org.openrdf.query.algebra.evaluation.function.datetime.stsparql.metric.DiffTime
    4.16  
    4.17  org.openrdf.query.algebra.evaluation.function.spatial.postgis.construct.MakeLine
    4.18  org.openrdf.query.algebra.evaluation.function.spatial.postgis.construct.Centroid
    4.19 \ No newline at end of file
     5.1 --- a/runtime/src/main/resources/log4j.properties	Thu May 16 17:33:13 2013 +0300
     5.2 +++ b/runtime/src/main/resources/log4j.properties	Thu May 16 17:36:07 2013 +0300
     5.3 @@ -1,5 +1,5 @@
     5.4  # logger level values: OFF, ERROR, WARN, INFO, DEBUG, ALL
     5.5 -log4j.rootLogger=INFO, CA
     5.6 +log4j.rootLogger=ALL, CA
     5.7  #log4j.rootLogger=DEBUG, CA
     5.8  #log4j.rootLogger=INFO, CA, FA
     5.9  
     6.1 --- a/vocab/src/main/java/eu/earthobservatory/constants/GeoConstants.java	Thu May 16 17:33:13 2013 +0300
     6.2 +++ b/vocab/src/main/java/eu/earthobservatory/constants/GeoConstants.java	Thu May 16 17:36:07 2013 +0300
     6.3 @@ -249,6 +249,10 @@
     6.4  	/**
     6.5  	 * List of stSPARQL spatial extension functions 
     6.6  	 */
     6.7 +	
     6.8 +
     6.9 +	public static final String diffTime = "http://strdf.di.uoa.gr/extensions/ontology#diffTime";
    6.10 +
    6.11  	public static final List<String> STSPARQLSpatialExtFunc = new ArrayList<String>();
    6.12  	
    6.13  	/**