Strabon

changeset 129:c84657ac1966

Queries are entered in plain text in beans.xml
author Kostis Kyzirakos <kkyzir@di.uoa.gr>
date Tue May 08 11:16:34 2012 +0300 (2012-05-08)
parents 4fc7c28159aa
children 3d4a04d579aa
files endpoint/WebContent/WEB-INF/beans.xml endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/QueryBean.java endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/StrabonBeanWrapper.java
line diff
     1.1 --- a/endpoint/WebContent/WEB-INF/beans.xml	Fri May 04 14:08:23 2012 +0300
     1.2 +++ b/endpoint/WebContent/WEB-INF/beans.xml	Tue May 08 11:16:34 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>corine</value>
     1.8 +			<value>darmstadt-noa</value>
     1.9  		</constructor-arg>
    1.10  		<constructor-arg type="java.lang.String">
    1.11  			<!-- Username -->
    1.12 -			<value>strabon</value>
    1.13 +			<value>kkyzir</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>teleios4.di.uoa.gr</value>
    1.22 +			<value>localhost</value>
    1.23  		</constructor-arg>
    1.24  		<constructor-arg type="boolean">
    1.25  			<!-- Check for locks and remove them (in case of a crash) -->
    1.26 @@ -35,7 +35,7 @@
    1.27  		</constructor-arg>
    1.28  		<constructor-arg type="java.lang.String">
    1.29  			<!-- Query1 -->
    1.30 -			<value><![CDATA[%23+Get+all+hotspots+%0D%0A%23+-+in+Pelloponesus+%0D%0A%23+-+at+2007-08-23%0D%0A%23+-+of+firms%0D%0A%0D%0APREFIX+noa%3A+<http%3A%2F%2Fteleios.di.uoa.gr%2Fontologies%2FnoaOntology.owl%23>%0D%0APREFIX+clc%3A+<http%3A%2F%2Fteleios.di.uoa.gr%2Fontologies%2FclcOntology.owl%23>%0D%0APREFIX+rdf%3A+<http%3A%2F%2Fwww.w3.org%2F1999%2F02%2F22-rdf-syntax-ns%23>%0D%0APREFIX+rdfs%3A+<http%3A%2F%2Fwww.w3.org%2F2000%2F01%2Frdf-schema%23>%0D%0APREFIX+strdf%3A+<http%3A%2F%2Fstrdf.di.uoa.gr%2Fontology%23>%0D%0APREFIX+teleios%3A+<http%3A%2F%2Fteleios.di.uoa.gr%2Fontologies%2FnoaOntology.owl%23>%0D%0APREFIX+gag%3A+<http%3A%2F%2Fwww.semanticweb.org%2Fontologies%2F2011%2FgagKallikratis.rdf%23>%0D%0APREFIX+geo%3A+<http%3A%2F%2Fwww.w3.org%2F2003%2F01%2Fgeo%2Fwgs84_pos%23>%0D%0APREFIX+georss%3A+<http%3A%2F%2Fwww.georss.org%2Fgeorss%2F>%0D%0APREFIX+xsd%3A+<http%3A%2F%2Fwww.w3.org%2F2001%2FXMLSchema%23>%0D%0APREFIX+lgdo%3A+<http%3A%2F%2Flinkedgeodata.org%2Fontology%2F>%0D%0APREFIX+gn%3A+<http%3A%2F%2Fwww.geonames.org%2Fontology%23>%0D%0A%0D%0ASELECT+%3Fh+%3FhGeo+%3FhAcqTime+%3FhConfidence+%3FhConfirmation+%3FhProvider+%3FhSensor+%3FhSatellite%0D%0AWHERE+{%0D%0A++++%3Fh++a+noa%3AHotspot+%3B+%23+all%0D%0A++++++++noa%3AhasGeometry+%3FhGeo+%3B+%23+all%0D%0A++++++++noa%3AhasAcquisitionTime+%3FhAcqTime+%3B+%23+all%0D%0A++++++++noa%3AhasConfidence+%3FhConfidence+%3B+%23+all%0D%0A++++++++noa%3AisProducedBy+%3FhProvider+%3B+%23+all%0D%0A++++++++noa%3AhasConfirmation+%3FhConfirmation+%3B+%23+all+(only+value+unknown)%0D%0A++++++++noa%3AisDerivedFromSensor+%3FhSensor+%3B+%23+all%0D%0A++++++++noa%3AisDerivedFromSatellite+%3FhSatellite+.+%23+only+firms+noa%0D%0A++++++++FILTER(+%222007-08-23T00%3A00%3A00%22^^xsd%3AdateTime+<%3D+%3FhAcqTime+%26%26+%3FhAcqTime+<%3D+%222007-08-23T23%3A59%3A59%22^^xsd%3AdateTime+)+.%0D%0A++++++++FILTER(+%3FhProvider+%3D+noa%3Afirms+)+.%0D%0A++++++++FILTER(++strdf%3Acontains(%22POLYGON((21.027+38.36%2C+23.77+38.36%2C+23.77+36.05%2C+21.027+36.05%2C+21.027+38.36))%22^^strdf%3AWKT%2C+%3FhGeo)+)+.%0D%0A}&format=KML]]></value>
    1.31 +			<value><![CDATA[select * where {?s ?p ?o} limit 10]]></value>
    1.32  		</constructor-arg>
    1.33  		<constructor-arg type="java.lang.String">
    1.34  			<!-- Query2 -->
    1.35 @@ -65,6 +65,10 @@
    1.36  			<!-- Query8 -->
    1.37                          <value><![CDATA[]]></value>
    1.38  		</constructor-arg>
    1.39 +                <constructor-arg type="java.lang.String">
    1.40 +                        <!-- Default format -->
    1.41 +                        <value><![CDATA[format=HTML]]></value>
    1.42 +                </constructor-arg>
    1.43  	</bean>
    1.44  
    1.45  <!-- 	<bean id="queryBean" class="eu.earthobservatory.org.StrabonEndpoint.QueryBean"> -->
     2.1 --- a/endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/QueryBean.java	Fri May 04 14:08:23 2012 +0300
     2.2 +++ b/endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/QueryBean.java	Tue May 08 11:16:34 2012 +0300
     2.3 @@ -5,7 +5,9 @@
     2.4  import java.io.FileWriter;
     2.5  import java.io.IOException;
     2.6  import java.io.PrintWriter;
     2.7 +import java.io.UnsupportedEncodingException;
     2.8  import java.math.BigInteger;
     2.9 +import java.net.URLEncoder;
    2.10  import java.security.SecureRandom;
    2.11  import java.util.Date;
    2.12  import java.util.Iterator;
    2.13 @@ -435,16 +437,16 @@
    2.14  		out.println("</html>");
    2.15  	}
    2.16  	
    2.17 -	protected static void appendHTMLQ(PrintWriter out, StrabonBeanWrapper strabonWrapper) {
    2.18 +	protected static void appendHTMLQ(PrintWriter out, StrabonBeanWrapper strabonWrapper) throws UnsupportedEncodingException {
    2.19  		out.println("<tr><td width=\"90\">");
    2.20 -		out.println("<a href=\"Query?SPARQLQuery="+strabonWrapper.getQuery1()+"\">&nbsp;&middot;&nbsp;Query 1</a></br> ");		
    2.21 -		out.println("<a href=\"Query?SPARQLQuery="+strabonWrapper.getQuery2()+"\">&nbsp;&middot;&nbsp;Query 2</a></br> ");
    2.22 -		out.println("<a href=\"Query?SPARQLQuery="+strabonWrapper.getQuery3()+"\">&nbsp;&middot;&nbsp;Query 3</a></br> ");
    2.23 -		out.println("<a href=\"Query?SPARQLQuery="+strabonWrapper.getQuery4()+"\">&nbsp;&middot;&nbsp;Query 4</a></br> ");
    2.24 -		out.println("<a href=\"Query?SPARQLQuery="+strabonWrapper.getQuery5()+"\">&nbsp;&middot;&nbsp;Query 5</a></br> ");
    2.25 -		out.println("<a href=\"Query?SPARQLQuery="+strabonWrapper.getQuery6()+"\">&nbsp;&middot;&nbsp;Query 6</a></br> ");
    2.26 -		out.println("<a href=\"Query?SPARQLQuery="+strabonWrapper.getQuery7()+"\">&nbsp;&middot;&nbsp;Query 7</a></br>");
    2.27 -		out.println("<a href=\"Query?SPARQLQuery="+strabonWrapper.getQuery8()+"\">&nbsp;&middot;&nbsp;Query 8</a> ");
    2.28 +		out.println("<a href=\"Query?SPARQLQuery="+URLEncoder.encode(strabonWrapper.getQuery1(), "UTF-8")+ "&" + strabonWrapper.getFormat() + "\">&nbsp;&middot;&nbsp;Query 1</a></br> ");		
    2.29 +		out.println("<a href=\"Query?SPARQLQuery="+URLEncoder.encode(strabonWrapper.getQuery2(), "UTF-8")+ "&" + strabonWrapper.getFormat() +"\">&nbsp;&middot;&nbsp;Query 2</a></br> ");
    2.30 +		out.println("<a href=\"Query?SPARQLQuery="+URLEncoder.encode(strabonWrapper.getQuery3(), "UTF-8")+ "&" + strabonWrapper.getFormat() +"\">&nbsp;&middot;&nbsp;Query 3</a></br> ");
    2.31 +		out.println("<a href=\"Query?SPARQLQuery="+URLEncoder.encode(strabonWrapper.getQuery4(), "UTF-8")+ "&" + strabonWrapper.getFormat() +"\">&nbsp;&middot;&nbsp;Query 4</a></br> ");
    2.32 +		out.println("<a href=\"Query?SPARQLQuery="+URLEncoder.encode(strabonWrapper.getQuery5(), "UTF-8")+ "&" + strabonWrapper.getFormat() +"\">&nbsp;&middot;&nbsp;Query 5</a></br> ");
    2.33 +		out.println("<a href=\"Query?SPARQLQuery="+URLEncoder.encode(strabonWrapper.getQuery6(), "UTF-8")+ "&" + strabonWrapper.getFormat() +"\">&nbsp;&middot;&nbsp;Query 6</a></br> ");
    2.34 +		out.println("<a href=\"Query?SPARQLQuery="+URLEncoder.encode(strabonWrapper.getQuery7(), "UTF-8")+ "&" + strabonWrapper.getFormat() +"\">&nbsp;&middot;&nbsp;Query 7</a></br>");
    2.35 +		out.println("<a href=\"Query?SPARQLQuery="+URLEncoder.encode(strabonWrapper.getQuery8(), "UTF-8")+ "&" + strabonWrapper.getFormat() +"\">&nbsp;&middot;&nbsp;Query 8</a> ");
    2.36  		out.println("</td></tr> ");
    2.37  	}
    2.38  }
     3.1 --- a/endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/StrabonBeanWrapper.java	Fri May 04 14:08:23 2012 +0300
     3.2 +++ b/endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/StrabonBeanWrapper.java	Tue May 08 11:16:34 2012 +0300
     3.3 @@ -32,6 +32,7 @@
     3.4  	private String query6;
     3.5  	private String query7;
     3.6  	private String query8;
     3.7 +	private String format;
     3.8  	
     3.9  	public StrabonBeanWrapper() {
    3.10  		this.strabon = null;
    3.11 @@ -57,6 +58,27 @@
    3.12  		this.query6 = query6;
    3.13  		this.query7 = query7;
    3.14  		this.query8 = query8;
    3.15 +		format = "format=HTML";
    3.16 +		init();
    3.17 +	}
    3.18 +	
    3.19 +	public StrabonBeanWrapper(String databaseName, String user, String password, int port, String serverName, boolean checkForLockTable, String query1, String query2, String query3, String query4, String query5, String query6, String query7, String query8, String format) {
    3.20 +		this.serverName = serverName;
    3.21 +		this.port = port;
    3.22 +		this.databaseName = databaseName;
    3.23 +		this.user = user;
    3.24 +		this.password = password;
    3.25 +		this.checkForLockTable = checkForLockTable;
    3.26 +		//this.strabon = new Strabon(databaseName, user, password, port, serverName, checkForLockTable);
    3.27 +		this.query1 = query1;
    3.28 +		this.query2 = query2;
    3.29 +		this.query3 = query3;
    3.30 +		this.query4 = query4;
    3.31 +		this.query5 = query5;
    3.32 +		this.query6 = query6;
    3.33 +		this.query7 = query7;
    3.34 +		this.query8 = query8;
    3.35 +		this.format = format;
    3.36  		
    3.37  		init();
    3.38  	}
    3.39 @@ -242,6 +264,15 @@
    3.40  	public void setQuery8(String query8) {
    3.41  		this.query8 = query8;
    3.42  	}
    3.43 +
    3.44 +	public String getFormat() {
    3.45 +		return format;
    3.46 +	}
    3.47 +
    3.48 +	public void setFormat(String format) {
    3.49 +		this.format = format;
    3.50 +	}
    3.51 +	
    3.52  	
    3.53  	
    3.54  }