Strabon

changeset 126:8ebd01848161

added python script for querying the endpoint
(author: Dimitris Michail)
author Kostis Kyzirakos <kkyzir@di.uoa.gr>
date Fri May 04 14:08:10 2012 +0300 (2012-05-04)
parents 1f462a2db241
children 4fc7c28159aa
files endpoint/WebContent/WEB-INF/beans.xml scripts/example-query.py
line diff
     1.1 --- a/endpoint/WebContent/WEB-INF/beans.xml	Fri Apr 20 15:05:09 2012 +0300
     1.2 +++ b/endpoint/WebContent/WEB-INF/beans.xml	Fri May 04 14:08:10 2012 +0300
     1.3 @@ -11,11 +11,11 @@
     1.4  	<bean id="strabonBean" class="eu.earthobservatory.org.StrabonEndpoint.StrabonBeanWrapper" destroy-method="destroy">
     1.5  		<constructor-arg type="java.lang.String">
     1.6  			<!-- Database name -->
     1.7 -			<value>endpoint</value>
     1.8 +			<value>corine</value>
     1.9  		</constructor-arg>
    1.10  		<constructor-arg type="java.lang.String">
    1.11  			<!-- Username -->
    1.12 -			<value>postgres</value>
    1.13 +			<value>strabon</value>
    1.14  		</constructor-arg>
    1.15  		<constructor-arg type="java.lang.String">
    1.16  			<!-- Password -->
    1.17 @@ -27,7 +27,7 @@
    1.18  		</constructor-arg>
    1.19  		<constructor-arg type="java.lang.String">
    1.20  			<!-- Database server -->
    1.21 -			<value>localhost</value>
    1.22 +			<value>teleios4.di.uoa.gr</value>
    1.23  		</constructor-arg>
    1.24  		<constructor-arg type="boolean">
    1.25  			<!-- Check for locks and remove them (in case of a crash) -->
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/scripts/example-query.py	Fri May 04 14:08:10 2012 +0300
     2.3 @@ -0,0 +1,29 @@
     2.4 +#!/usr/bin/env python
     2.5 +
     2.6 +import sys, re, os
     2.7 +import os
     2.8 +import glob
     2.9 +import time
    2.10 +import shutil
    2.11 +import httplib, urllib
    2.12 +
    2.13 +def main(argv):
    2.14 +
    2.15 +    query = 'PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX strdf: <http://strdf.di.uoa.gr/ontology#> PREFIX noa: <http://teleios.di.uoa.gr/ontologies/noaOntology.owl#> SELECT ?H (strdf:transform(?HGEO, <http://www.opengis.net/def/crs/EPSG/0/4326>) AS ?GEO) WHERE { ?H rdf:type noa:Hotspot . ?H noa:hasAcquisitionTime ?HAT . FILTER(str(?HAT) = "2010-08-21T21:20:00") . ?H noa:isDerivedFromSensor ?HS . FILTER(str(?HS) = "MSG1_RSS" ) . ?H noa:hasGeometry ?HGEO . }'
    2.16 +    params = urllib.urlencode({'SPARQLQuery': query, 'format': "XML"})
    2.17 +    headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/xml"}
    2.18 +
    2.19 +    #conn = httplib.HTTPConnection("papos.space.noa.gr:8080")
    2.20 +    #conn.request("POST", "/endpoint/Query", params, headers)
    2.21 +
    2.22 +    conn = httplib.HTTPConnection("test.strabon.di.uoa.gr")
    2.23 +    conn.request("POST", "/NOA/Query", params, headers)
    2.24 +
    2.25 +    response = conn.getresponse()
    2.26 +    print response.status, response.reason
    2.27 +    print response.msg
    2.28 +    print response.read()
    2.29 +    return 0
    2.30 +
    2.31 +if __name__ == "__main__":
    2.32 +    sys.exit(main(sys.argv))