Strabon

changeset 960:afd34ba51178

updated endpoint capabilities to print supported extension functions for stSPARQL and GeoSPARQL
author Babis Nikolaou <charnik@di.uoa.gr>
date Tue Apr 02 11:44:35 2013 +0300 (2013-04-02)
parents 3a6b58ffefac
children 93bbe156e6e2
files endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/capabilities/AutoDiscoveryCapabilities.java endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/capabilities/Capabilities.java endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/capabilities/CapabilitiesBean.java endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/capabilities/EndpointCapabilities.java evaluation/src/main/java/org/openrdf/query/algebra/evaluation/function/spatial/GeoConstants.java
line diff
     1.1 --- a/endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/capabilities/AutoDiscoveryCapabilities.java	Tue Apr 02 11:35:44 2013 +0300
     1.2 +++ b/endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/capabilities/AutoDiscoveryCapabilities.java	Tue Apr 02 11:44:35 2013 +0300
     1.3 @@ -10,6 +10,7 @@
     1.4  package eu.earthobservatory.org.StrabonEndpoint.capabilities;
     1.5  
     1.6  import java.io.IOException;
     1.7 +import java.util.List;
     1.8  
     1.9  import org.apache.commons.httpclient.HttpClient;
    1.10  import org.apache.commons.httpclient.methods.PostMethod;
    1.11 @@ -245,4 +246,20 @@
    1.12  	private String getConnectionURL() {
    1.13  		return "http://" + host + ":" + port + "/" + appName;
    1.14  	}
    1.15 +
    1.16 +	/* (non-Javadoc)
    1.17 +	 * @see eu.earthobservatory.org.StrabonEndpoint.capabilities.Capabilities#getstSPARQLSpatialExtensionFunctions()
    1.18 +	 */
    1.19 +	@Override
    1.20 +	public List<String> getstSPARQLSpatialExtensionFunctions() {
    1.21 +		return null;
    1.22 +	}
    1.23 +
    1.24 +	/* (non-Javadoc)
    1.25 +	 * @see eu.earthobservatory.org.StrabonEndpoint.capabilities.Capabilities#getGeoSPARQLSpatialExtensionFunctions()
    1.26 +	 */
    1.27 +	@Override
    1.28 +	public List<String> getGeoSPARQLSpatialExtensionFunctions() {
    1.29 +		return null;
    1.30 +	}
    1.31  }
     2.1 --- a/endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/capabilities/Capabilities.java	Tue Apr 02 11:35:44 2013 +0300
     2.2 +++ b/endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/capabilities/Capabilities.java	Tue Apr 02 11:44:35 2013 +0300
     2.3 @@ -9,6 +9,8 @@
     2.4   */
     2.5  package eu.earthobservatory.org.StrabonEndpoint.capabilities;
     2.6  
     2.7 +import java.util.List;
     2.8 +
     2.9  
    2.10  /**
    2.11   * Interface that exposes the capabilities of a Strabon Endpoint.
    2.12 @@ -87,6 +89,25 @@
    2.13  	public boolean supportsConnectionModification();
    2.14  	
    2.15  	/**
    2.16 +	 * Return a list of URIs corresponding to the spatial extension
    2.17 +	 * functions that stSPARQL supports.
    2.18 +	 * 
    2.19 +	 * @return
    2.20 +	 */
    2.21 +	public List<String> getstSPARQLSpatialExtensionFunctions();
    2.22 +	
    2.23 +	// TODO
    2.24 +	//public List<String> getstSPARQLTemporalExtensionFunctions();
    2.25 +	
    2.26 +	/**
    2.27 +	 * Return a list of URIs corresponding to the spatial extension
    2.28 +	 * functions that GeoSPARQL supports.
    2.29 +	 * 
    2.30 +	 * @return
    2.31 +	 */
    2.32 +	public List<String> getGeoSPARQLSpatialExtensionFunctions();
    2.33 +	
    2.34 +	/**
    2.35  	 * Returns a {@link RequestCapabilities} instance containing
    2.36  	 * the details for how one can query the Query service of the
    2.37  	 * endpoint.
     3.1 --- a/endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/capabilities/CapabilitiesBean.java	Tue Apr 02 11:35:44 2013 +0300
     3.2 +++ b/endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/capabilities/CapabilitiesBean.java	Tue Apr 02 11:44:35 2013 +0300
     3.3 @@ -134,6 +134,24 @@
     3.4  				}
     3.5  			}
     3.6  		}
     3.7 +		
     3.8 +		// print supported spatial extension functions for stSPARQL
     3.9 +		if (caps.getstSPARQLSpatialExtensionFunctions() != null) {
    3.10 +			out.println("stSPARQL Extension Functions");
    3.11 +			out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
    3.12 +			for(String extFunc : caps.getstSPARQLSpatialExtensionFunctions()) {
    3.13 +				out.println(extFunc);
    3.14 +			}
    3.15 +		}
    3.16 +		
    3.17 +		// print supported spatial extension functions for GeoSPARQL
    3.18 +		if (caps.getGeoSPARQLSpatialExtensionFunctions() != null) {
    3.19 +			out.println("GeoSPARQL Extension Functions");
    3.20 +			out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
    3.21 +			for(String extFunc : caps.getGeoSPARQLSpatialExtensionFunctions()) {
    3.22 +				out.println(extFunc);
    3.23 +			}
    3.24 +		}
    3.25  	}
    3.26  	
    3.27  	private String getYesNo(boolean val) {
     4.1 --- a/endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/capabilities/EndpointCapabilities.java	Tue Apr 02 11:35:44 2013 +0300
     4.2 +++ b/endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/capabilities/EndpointCapabilities.java	Tue Apr 02 11:44:35 2013 +0300
     4.3 @@ -9,6 +9,10 @@
     4.4   */
     4.5  package eu.earthobservatory.org.StrabonEndpoint.capabilities;
     4.6  
     4.7 +import java.util.List;
     4.8 +
     4.9 +import org.openrdf.query.algebra.evaluation.function.spatial.GeoConstants;
    4.10 +
    4.11  
    4.12  /**
    4.13   * This class implements the {@link Capabilities} interface and
    4.14 @@ -21,7 +25,7 @@
    4.15  
    4.16  	@Override
    4.17  	public String getVersion() {
    4.18 -		return "3.2.4-SNAPSHOT";
    4.19 +		return "3.2.9-SNAPSHOT";
    4.20  	}
    4.21  	
    4.22  	@Override
    4.23 @@ -88,4 +92,20 @@
    4.24  	public RequestCapabilities getConnectionCapabilities() {
    4.25  		return ConnectionBeanCapabilities.getInstance();
    4.26  	}
    4.27 +
    4.28 +	/* (non-Javadoc)
    4.29 +	 * @see eu.earthobservatory.org.StrabonEndpoint.capabilities.Capabilities#getstSPARQLSpatialExtensionFunctions()
    4.30 +	 */
    4.31 +	@Override
    4.32 +	public List<String> getstSPARQLSpatialExtensionFunctions() {
    4.33 +		return GeoConstants.stSPARQLSpatialExtFunc;
    4.34 +	}
    4.35 +
    4.36 +	/* (non-Javadoc)
    4.37 +	 * @see eu.earthobservatory.org.StrabonEndpoint.capabilities.Capabilities#getGeoSPARQLSpatialExtensionFunctions()
    4.38 +	 */
    4.39 +	@Override
    4.40 +	public List<String> getGeoSPARQLSpatialExtensionFunctions() {
    4.41 +		return GeoConstants.stGeoSPARQLExtFunc;
    4.42 +	}
    4.43  }
     5.1 --- a/evaluation/src/main/java/org/openrdf/query/algebra/evaluation/function/spatial/GeoConstants.java	Tue Apr 02 11:35:44 2013 +0300
     5.2 +++ b/evaluation/src/main/java/org/openrdf/query/algebra/evaluation/function/spatial/GeoConstants.java	Tue Apr 02 11:44:35 2013 +0300
     5.3 @@ -9,6 +9,12 @@
     5.4   */
     5.5  package org.openrdf.query.algebra.evaluation.function.spatial;
     5.6  
     5.7 +import java.lang.reflect.Field;
     5.8 +import java.util.ArrayList;
     5.9 +import java.util.List;
    5.10 +
    5.11 +import com.vividsolutions.jts.io.gml2.GMLReader;
    5.12 +
    5.13  /**
    5.14   * This class is a placeholder for various constants around geometries. These
    5.15   * constants range from URIs of namespaces, functions, representations, etc.,
    5.16 @@ -143,9 +149,6 @@
    5.17  	 */
    5.18  	public static final String GMLLITERAL				=  GEO + "gmlLiteral";
    5.19  	
    5.20 -	
    5.21 -	
    5.22 -	
    5.23  	/**																		*
    5.24  	 *  						Extended functions 							*
    5.25  	 *  							stSPARQL								*
    5.26 @@ -286,16 +289,102 @@
    5.27  	public static final String diffDateTime = "http://strdf.di.uoa.gr/extensions/ontology#diffDateTime";
    5.28  	/** End of addition **/
    5.29  
    5.30 -
    5.31  	/**
    5.32  	 * RCC-8 relations for the RDFi framework
    5.33  	 */
    5.34  	public static final String rdfiDC						= rdfi + "DC";
    5.35  	public static final String rdfiEC						= rdfi + "EC";
    5.36  	public static final String rdfiPO						= rdfi + "PO";
    5.37 -	public static final String rdfiNTPP						= rdfi + "NTPP";
    5.38 +	public static final String rdfiNTPP					= rdfi + "NTPP";
    5.39  	public static final String rdfiNTPPi					= rdfi + "NTPPi";
    5.40 -	public static final String rdfiTPP						= rdfi + "TPP";
    5.41 -	public static final String rdfiTPPi						= rdfi + "TPPi";
    5.42 +	public static final String rdfiTPP					= rdfi + "TPP";
    5.43 +	public static final String rdfiTPPi					= rdfi + "TPPi";
    5.44  	public static final String rdfiEQ						= rdfi + "EQ";
    5.45 +	
    5.46 +	/**
    5.47 +	 * List of stSPARQL spatial extension functions 
    5.48 +	 */
    5.49 +	public static final List<String> stSPARQLSpatialExtFunc = new ArrayList<String>();
    5.50 +	
    5.51 +	/**
    5.52 +	 * List of stSPARQL temporal extension functions
    5.53 +	 */
    5.54 +	//public static final List<String> stSPARQLTemporalExtFunc = new ArrayList<String>();
    5.55 +	
    5.56 +	/**
    5.57 +	 * List of GeoSPARQL extension functions
    5.58 +	 */
    5.59 +	public static final List<String> stGeoSPARQLExtFunc = new ArrayList<String>();
    5.60 +	
    5.61 +	// declare spatial and temporal extension functions
    5.62 +	static {
    5.63 +		Class<GeoConstants> geoConstants = GeoConstants.class;	
    5.64 +		
    5.65 +		stSPARQLSpatialExtFunc.add(equals);	
    5.66 +		stSPARQLSpatialExtFunc.add(disjoint);
    5.67 +		stSPARQLSpatialExtFunc.add(intersects);
    5.68 +		stSPARQLSpatialExtFunc.add(touches);	
    5.69 +		stSPARQLSpatialExtFunc.add(within);	
    5.70 +		stSPARQLSpatialExtFunc.add(contains);	
    5.71 +		stSPARQLSpatialExtFunc.add(overlaps);	
    5.72 +		stSPARQLSpatialExtFunc.add(crosses);
    5.73 +
    5.74 +		stSPARQLSpatialExtFunc.add(relate);
    5.75 +			     
    5.76 +		stSPARQLSpatialExtFunc.add(mbbIntersects);
    5.77 +		stSPARQLSpatialExtFunc.add(mbbContains); 	
    5.78 +		stSPARQLSpatialExtFunc.add(mbbEquals);	
    5.79 +		stSPARQLSpatialExtFunc.add(mbbWithin);
    5.80 +			     
    5.81 +		stSPARQLSpatialExtFunc.add(left);	
    5.82 +		stSPARQLSpatialExtFunc.add(right);	
    5.83 +		stSPARQLSpatialExtFunc.add(above);	
    5.84 +		stSPARQLSpatialExtFunc.add(below);	
    5.85 +			     
    5.86 +		stSPARQLSpatialExtFunc.add(union);	
    5.87 +		stSPARQLSpatialExtFunc.add(buffer);	
    5.88 +		stSPARQLSpatialExtFunc.add(envelope);	
    5.89 +		stSPARQLSpatialExtFunc.add(convexHull);	
    5.90 +		stSPARQLSpatialExtFunc.add(boundary);
    5.91 +		stSPARQLSpatialExtFunc.add(intersection);
    5.92 +		stSPARQLSpatialExtFunc.add(difference);
    5.93 +		stSPARQLSpatialExtFunc.add(symDifference);
    5.94 +		stSPARQLSpatialExtFunc.add(transform);
    5.95 +			     
    5.96 +		stSPARQLSpatialExtFunc.add(distance);
    5.97 +		stSPARQLSpatialExtFunc.add(area);	
    5.98 +			     
    5.99 +		stSPARQLSpatialExtFunc.add(dimension);
   5.100 +		stSPARQLSpatialExtFunc.add(geometryType);
   5.101 +		stSPARQLSpatialExtFunc.add(asText);	
   5.102 +		stSPARQLSpatialExtFunc.add(asGML);	
   5.103 +		stSPARQLSpatialExtFunc.add(srid);
   5.104 +		stSPARQLSpatialExtFunc.add(isEmpty);
   5.105 +		stSPARQLSpatialExtFunc.add(isSimple); 	
   5.106 +			     
   5.107 +		stSPARQLSpatialExtFunc.add(extent);
   5.108 +		
   5.109 +		
   5.110 +		try {
   5.111 +			Field[] field = geoConstants.getDeclaredFields();
   5.112 +		
   5.113 +			for (int i = 0; i < field.length; i++) {
   5.114 +				// stSPARQL
   5.115 +				
   5.116 +				// GeoSPARQL
   5.117 +				if (field[i].getName().startsWith("geoSparql") ||
   5.118 +						field[i].getName().startsWith("sf") ||
   5.119 +						field[i].getName().startsWith("eh") ||
   5.120 +						field[i].getName().startsWith("rcc")) {
   5.121 +					stGeoSPARQLExtFunc.add((String) field[i].get(null));
   5.122 +				}
   5.123 +			}
   5.124 +		} catch (SecurityException e) {
   5.125 +			// suppress exception; it should not reach here
   5.126 +		} catch (IllegalArgumentException e) {
   5.127 +			// suppress exception; it should not reach here 
   5.128 +		} catch (IllegalAccessException e) {
   5.129 +			// suppress exception; it should not reach here
   5.130 +		}
   5.131 +	}
   5.132  }