Strabon

changeset 121:036ab5c5d2c0

"merge"
author Konstantina Mpereta <grad1110@di.uoa.gr>
date Thu Apr 19 14:18:00 2012 +0300 (2012-04-19)
parents b2667f7bc051 22fd30137096
children 83b37b2ba009
files evaluation/pom.xml evaluation/src/main/java/org/openrdf/query/algebra/evaluation/function/spatial/StrabonPolyhedron.java generaldb/src/main/java/org/openrdf/sail/generaldb/schema/LiteralTable.java pom.xml runtime/src/main/java/eu/earthobservatory/runtime/generaldb/Strabon.java
line diff
     1.1 --- a/.hgignore	Thu Apr 19 14:04:35 2012 +0300
     1.2 +++ b/.hgignore	Thu Apr 19 14:18:00 2012 +0300
     1.3 @@ -3,3 +3,5 @@
     1.4  .settings$
     1.5  .classpath
     1.6  pom.xml~
     1.7 +~$
     1.8 +.extract$
     2.1 --- a/.hgtags	Thu Apr 19 14:04:35 2012 +0300
     2.2 +++ b/.hgtags	Thu Apr 19 14:18:00 2012 +0300
     2.3 @@ -5,3 +5,4 @@
     2.4  e986f499c057472c01a500b3a845b6b8905b3f55 v3.1.5
     2.5  5a6948d2bfc5027b833d97276ec4e0e7ee1b292c v3.1.6
     2.6  3eaccd928b81b85e19b0d929e364643d794a2aa5 v3.1.7
     2.7 +2338da4560729e5e48ef6822c516c7f1a4fc87db v3.1.8
     3.1 --- a/endpoint/WebContent/WEB-INF/web.xml	Thu Apr 19 14:04:35 2012 +0300
     3.2 +++ b/endpoint/WebContent/WEB-INF/web.xml	Thu Apr 19 14:18:00 2012 +0300
     3.3 @@ -33,6 +33,17 @@
     3.4  		<url-pattern>/Store</url-pattern>
     3.5  	</servlet-mapping>
     3.6  	
     3.7 +	<servlet>
     3.8 +		<display-name>Update</display-name>
     3.9 +		<servlet-name>Update</servlet-name>
    3.10 +		<servlet-class>eu.earthobservatory.org.StrabonEndpoint.UpdateBean</servlet-class>
    3.11 +		<load-on-startup>1</load-on-startup>
    3.12 +	</servlet>
    3.13 +	<servlet-mapping>
    3.14 +		<servlet-name>Update</servlet-name>
    3.15 +		<url-pattern>/Update</url-pattern>
    3.16 +	</servlet-mapping>
    3.17 +		
    3.18  <!-- 	<servlet> -->
    3.19  <!-- 		<display-name>QueryServlet</display-name> -->
    3.20  <!-- 		<servlet-name>QueryServlet</servlet-name> -->
     4.1 --- a/endpoint/pom.xml	Thu Apr 19 14:04:35 2012 +0300
     4.2 +++ b/endpoint/pom.xml	Thu Apr 19 14:18:00 2012 +0300
     4.3 @@ -1,11 +1,10 @@
     4.4 -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     4.5 -	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
     4.6 +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
     4.7  	<modelVersion>4.0.0</modelVersion>
     4.8  
     4.9  	<parent>
    4.10  		<groupId>eu.earthobservatory</groupId>
    4.11  		<artifactId>strabon</artifactId>
    4.12 -		<version>3.1.8-SNAPSHOT</version>
    4.13 +		<version>3.1.9-SNAPSHOT</version>
    4.14  	</parent>
    4.15  
    4.16  	<artifactId>strabon-endpoint</artifactId>
    4.17 @@ -175,32 +174,13 @@
    4.18  						</archive> -->
    4.19  				</configuration>
    4.20  			</plugin>
    4.21 -			<!--
    4.22 -			<plugin>
    4.23 -				<groupId>org.eclipse.m2e</groupId>
    4.24 -				<artifactId>lifecycle-mapping</artifactId>
    4.25 -				<version>1.0.0</version>
    4.26 -				<configuration>
    4.27 -					<lifecycleMappingMetadata>
    4.28 -						<pluginExecutions>
    4.29 -							<pluginExecution>
    4.30 -								<pluginExecutionFilter>
    4.31 -									<groupId>org.apache.maven.plugins</groupId>
    4.32 -									<artifactId>maven-dependency-plugin</artifactId>
    4.33 -									<versionRange>[2.1,)</versionRange>
    4.34 -									<goals>
    4.35 -										<goal>copy-dependencies</goal>
    4.36 -									</goals>
    4.37 -								</pluginExecutionFilter>
    4.38 -								<action>
    4.39 -									<ignore />
    4.40 -								</action>
    4.41 -							</pluginExecution>
    4.42 -						</pluginExecutions>
    4.43 -					</lifecycleMappingMetadata>
    4.44 -				</configuration>
    4.45 -			</plugin>
    4.46 -			-->
    4.47 +			<!-- <plugin> <groupId>org.eclipse.m2e</groupId> <artifactId>lifecycle-mapping</artifactId> 
    4.48 +				<version>1.0.0</version> <configuration> <lifecycleMappingMetadata> <pluginExecutions> 
    4.49 +				<pluginExecution> <pluginExecutionFilter> <groupId>org.apache.maven.plugins</groupId> 
    4.50 +				<artifactId>maven-dependency-plugin</artifactId> <versionRange>[2.1,)</versionRange> 
    4.51 +				<goals> <goal>copy-dependencies</goal> </goals> </pluginExecutionFilter> 
    4.52 +				<action> <ignore /> </action> </pluginExecution> </pluginExecutions> </lifecycleMappingMetadata> 
    4.53 +				</configuration> </plugin> -->
    4.54  			<plugin>
    4.55  				<groupId>org.apache.maven.plugins</groupId>
    4.56  				<artifactId>maven-dependency-plugin</artifactId>
    4.57 @@ -235,11 +215,35 @@
    4.58  					<autoVersionSubmodules>true</autoVersionSubmodules>
    4.59  				</configuration>
    4.60  			</plugin>
    4.61 +			<!--
    4.62 +			<plugin>
    4.63 +				<groupId>org.apache.tomcat.maven</groupId>
    4.64 +				<artifactId>tomcat7-maven-plugin</artifactId>
    4.65 +				<executions>
    4.66 +					<execution>
    4.67 +						<id>tomcat-run</id>
    4.68 +						<goals>
    4.69 +							<goal>exec-war-only</goal>
    4.70 +						</goals>
    4.71 +						<phase>package</phase>
    4.72 +						<configuration>
    4.73 +							<enableNaming>true</enableNaming>
    4.74 +						</configuration>
    4.75 +					</execution>
    4.76 +				</executions>
    4.77 +			</plugin>
    4.78 +			-->
    4.79  		</plugins>
    4.80  
    4.81  		<pluginManagement>
    4.82  			<plugins>
    4.83 -			<!--
    4.84 +				<!-- <plugin> <groupId>org.eclipse.m2e</groupId> <artifactId>lifecycle-mapping</artifactId> 
    4.85 +					<version>1.0.0</version> <configuration> <lifecycleMappingMetadata> <pluginExecutions> 
    4.86 +					<pluginExecution> <pluginExecutionFilter> <groupId>org.apache.maven.plugins</groupId> 
    4.87 +					<artifactId>maven-dependency-plugin</artifactId> <versionRange>[2.3,)</versionRange> 
    4.88 +					<goals> <goal>copy-dependencies</goal> </goals> </pluginExecutionFilter> 
    4.89 +					<action> <ignore /> </action> </pluginExecution> </pluginExecutions> </lifecycleMappingMetadata> 
    4.90 +					</configuration> </plugin> -->
    4.91  				<plugin>
    4.92  					<groupId>org.eclipse.m2e</groupId>
    4.93  					<artifactId>lifecycle-mapping</artifactId>
    4.94 @@ -251,7 +255,7 @@
    4.95  									<pluginExecutionFilter>
    4.96  										<groupId>org.apache.maven.plugins</groupId>
    4.97  										<artifactId>maven-dependency-plugin</artifactId>
    4.98 -										<versionRange>[2.3,)</versionRange>
    4.99 +										<versionRange>[2.1,)</versionRange>
   4.100  										<goals>
   4.101  											<goal>copy-dependencies</goal>
   4.102  										</goals>
   4.103 @@ -264,31 +268,6 @@
   4.104  						</lifecycleMappingMetadata>
   4.105  					</configuration>
   4.106  				</plugin>
   4.107 -			-->
   4.108 -                       	<plugin>
   4.109 -                               	<groupId>org.eclipse.m2e</groupId>
   4.110 -                                <artifactId>lifecycle-mapping</artifactId>
   4.111 -                                <version>1.0.0</version>
   4.112 -                                <configuration>
   4.113 -                                       	<lifecycleMappingMetadata>
   4.114 -                                                <pluginExecutions>
   4.115 -                                                        <pluginExecution>
   4.116 -                                                               	<pluginExecutionFilter>
   4.117 -                                                                       	<groupId>org.apache.maven.plugins</groupId>
   4.118 -                                                                       	<artifactId>maven-dependency-plugin</artifactId>
   4.119 -                                                                       	<versionRange>[2.1,)</versionRange>
   4.120 -                                                                       	<goals>
   4.121 -                                                                               	<goal>copy-dependencies</goal>
   4.122 -                                                                       	</goals>
   4.123 -                                                                </pluginExecutionFilter>
   4.124 -                                                                <action>
   4.125 -                                                                       	<ignore />
   4.126 -                                                                </action>
   4.127 -                                                        </pluginExecution>
   4.128 -                                               	</pluginExecutions>
   4.129 -                                        </lifecycleMappingMetadata>
   4.130 -                                </configuration>
   4.131 -                        </plugin>
   4.132  			</plugins>
   4.133  		</pluginManagement>
   4.134  
     5.1 --- a/endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/QueryBean.java	Thu Apr 19 14:04:35 2012 +0300
     5.2 +++ b/endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/QueryBean.java	Thu Apr 19 14:18:00 2012 +0300
     5.3 @@ -30,7 +30,8 @@
     5.4  	
     5.5  	private static final long serialVersionUID = -378175118289907707L;
     5.6  	
     5.7 -	public QueryBean() {}
     5.8 +	private ServletContext context; 
     5.9 +	private StrabonBeanWrapper strabonWrapper;
    5.10  	
    5.11  	public void doGet(HttpServletRequest request, HttpServletResponse response)
    5.12  	throws ServletException, IOException
    5.13 @@ -86,7 +87,12 @@
    5.14  		String reqFuncionality = (request.getParameter("submit") == null) ? "" : request.getParameter("submit");
    5.15  		
    5.16  		// check whether Update submit button was fired
    5.17 -		boolean isUpdate = (reqFuncionality.equals("Update") ? true:false);
    5.18 +		if (reqFuncionality.equals("Update")) { // only for executions from web browsers
    5.19 +			response.setStatus(HttpServletResponse.SC_TEMPORARY_REDIRECT);
    5.20 +			response.sendRedirect("Update?SPARQLQuery=" + hive.getSPARQLQuery());
    5.21 +			
    5.22 +			return;
    5.23 +		}
    5.24  		
    5.25  		if ((reqFormat == "") && (reqAccept == "")) {
    5.26  			hive.setFormat("HTML");
    5.27 @@ -113,33 +119,7 @@
    5.28  			response.setContentType("text/html; charset=UTF-8");
    5.29  			hive.setFormat("HTML");
    5.30  		}
    5.31 -		//System.out.println("\n\n\n\n\format='"+this.format+"'\n\n\n\n\n");
    5.32  		
    5.33 -		ServletContext context = getServletContext();
    5.34 -		WebApplicationContext applicationContext = WebApplicationContextUtils.getWebApplicationContext(context);
    5.35 -		StrabonBeanWrapper strabonWrapper = (StrabonBeanWrapper)applicationContext.getBean("strabonBean");
    5.36 -		
    5.37 -		/* Execution of UPDATE query */  
    5.38 -		if (isUpdate) {
    5.39 -			String answer = "";
    5.40 -			try {
    5.41 -				strabonWrapper.getStrabon().update(hive.getSPARQLQuery(), strabonWrapper.getStrabon().getSailRepoConnection());
    5.42 -				response.setStatus(HttpServletResponse.SC_OK);
    5.43 -				answer = "true";
    5.44 -				
    5.45 -			} catch(MalformedQueryException e) {
    5.46 -				response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
    5.47 -				answer = "<exception>\n"+e.getMessage()+"\n\t</exception>";
    5.48 -			}
    5.49 -			
    5.50 -			// write response to client
    5.51 -			response.getWriter().append(getUPDATEHeaderResponse());
    5.52 -			response.getWriter().append(answer);
    5.53 -			response.getWriter().append(getUPDATEFooterResponse());
    5.54 -			return;
    5.55 -		}
    5.56 -		/* Execution of UPDATE query */
    5.57 -
    5.58  		PrintWriter out = response.getWriter();
    5.59  		
    5.60  		if ((hive.getFormat().equalsIgnoreCase("KML"))) {
    5.61 @@ -177,9 +157,9 @@
    5.62   
    5.63  	            //System.out.println("Done");
    5.64   
    5.65 -    	     }catch(IOException e){
    5.66 +    	     } catch(IOException e) {
    5.67      		        e.printStackTrace();
    5.68 -    	           }
    5.69 +    	     }
    5.70      	     
    5.71   			 response.setContentType("application/vnd.google-earth.kml+xml; charset=UTF-8");
    5.72   			 response.setDateHeader("Expires", 0);
    5.73 @@ -209,16 +189,49 @@
    5.74  			   //out.append("<div id=\"map_canvas\"></div>");
    5.75  				out.append("");
    5.76  			appendHTML5(out);
    5.77 -		} 
    5.78 -		else if ((hive.getFormat().equalsIgnoreCase("XML"))) {
    5.79 +			
    5.80 +		} else if ((hive.getFormat().equalsIgnoreCase("XML"))) {
    5.81 +			int status_code = HttpServletResponse.SC_OK;
    5.82 +			String answer = "";
    5.83 +			
    5.84 +			try {
    5.85 +				// execute query
    5.86 +				answer = (String) strabonWrapper.query(hive.getSPARQLQuery(), hive.getFormat());
    5.87 +				
    5.88 +			} catch (MalformedQueryException e) {
    5.89 +				status_code = HttpServletResponse.SC_BAD_REQUEST;
    5.90 +				answer = e.getMessage();
    5.91 +				
    5.92 +			} catch (RepositoryException e) {
    5.93 +				status_code = HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
    5.94 +				answer = e.getMessage();
    5.95 +				
    5.96 +			} catch (QueryEvaluationException e) {
    5.97 +				status_code = HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
    5.98 +				answer = e.getMessage();
    5.99 +				
   5.100 +			} catch (TupleQueryResultHandlerException e) {
   5.101 +				status_code = HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
   5.102 +				answer = e.getMessage();
   5.103 +				
   5.104 +			} catch (ClassNotFoundException e) {
   5.105 +				status_code = HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
   5.106 +				answer = e.getMessage();
   5.107 +			}
   5.108 +			
   5.109 +			// write response to client
   5.110  			response.setContentType("text/xml; charset=UTF-8");
   5.111 -			StringBuilder errorMessage = new StringBuilder ();
   5.112 -			String answer = evaluateQuery(strabonWrapper, hive.getFormat(), reqFuncionality, hive.getSPARQLQuery(), errorMessage);
   5.113 -			hive.setErrorMessage(errorMessage.toString());
   5.114 -			out.println(answer);
   5.115 -
   5.116 -		}
   5.117 -		else {
   5.118 +			response.setStatus(status_code);
   5.119 +			if (status_code == HttpServletResponse.SC_OK) {
   5.120 +				response.getWriter().append(answer);
   5.121 +				
   5.122 +			} else {
   5.123 +				response.getWriter().append(ResponseMessages.getXMLHeader());
   5.124 +				response.getWriter().append(ResponseMessages.getXMLException(answer));
   5.125 +				response.getWriter().append(ResponseMessages.getXMLFooter());
   5.126 +			}
   5.127 +			
   5.128 +		} else { // HTML
   5.129  			
   5.130  			appendHTML1a(out,"");
   5.131  			
   5.132 @@ -258,47 +271,24 @@
   5.133  		out.flush();
   5.134  	}
   5.135  
   5.136 -	/**
   5.137 -	 * Used as the template answer for UPDATE queries.
   5.138 -	 * @return
   5.139 -	 */
   5.140 -	private String getUPDATEHeaderResponse() {
   5.141 -		return "<?xml version='1.0' encoding='UTF-8'?>\n" +
   5.142 -			   "<response>\n" +
   5.143 -			   "\t";
   5.144 -	}
   5.145 -	
   5.146 -	/**
   5.147 -	 * Used as the template answer for UPDATE queries.
   5.148 -	 * @return
   5.149 -	 */
   5.150 -	private String getUPDATEFooterResponse() {
   5.151 -		return "\n</response>\n";
   5.152 -	}
   5.153 -
   5.154  	public void init(ServletConfig servletConfig) throws ServletException {
   5.155  		super.init(servletConfig);
   5.156 +		
   5.157 +		// get StrabonWrapper
   5.158 +		context = getServletContext();
   5.159 +		WebApplicationContext applicationContext = WebApplicationContextUtils.getWebApplicationContext(context);
   5.160 +		
   5.161 +		strabonWrapper = (StrabonBeanWrapper) applicationContext.getBean("strabonBean");
   5.162  	}
   5.163  
   5.164  	public String evaluateQuery(StrabonBeanWrapper strabonWrapper, String resultFormat, String reqFunctionality, String SPARQLQuery, StringBuilder errorMessage) {		
   5.165  		String answer = "";
   5.166 -
   5.167 -//		System.out.println("evaluateQuery: will call wrapper. Query  = " + this.SPARQLQuery);
   5.168 -//		System.out.println("evaluateQuery: will call wrapper. result = " + resultFormat);
   5.169 -
   5.170 +		
   5.171  		try {
   5.172  			if (SPARQLQuery == null) {
   5.173  				answer = "";
   5.174  			} else {
   5.175 -				//System.out.println("evaluateQuery: Calling...");
   5.176 -				if (reqFunctionality.equals("Update")) {
   5.177 -				//if (((String)this.SPARQLQuery).toLowerCase().contains("insert") || ((String)this.SPARQLQuery).toLowerCase().contains("delete"))  { 
   5.178 -				   answer = (String)strabonWrapper.update(SPARQLQuery, resultFormat);
   5.179 -				   }
   5.180 -				else{
   5.181 -				   answer = (String)strabonWrapper.query(SPARQLQuery, resultFormat);
   5.182 -				}
   5.183 -				//System.out.println("evaluateQuery: Called...");
   5.184 +				   answer = (String) strabonWrapper.query(SPARQLQuery, resultFormat);
   5.185  			}
   5.186  		} catch (MalformedQueryException e) {
   5.187  			e.printStackTrace();
   5.188 @@ -323,10 +313,6 @@
   5.189  			errorMessage.append(e.getMessage());
   5.190  		}
   5.191  
   5.192 -		//System.out.println("evaluateQuery: called wrapper. answer  = " + answer);
   5.193 -		//System.out.println("evaluateQuery: called wrapper. error   = " + ((this.errorMessage == null) ? "" : this.errorMessage));
   5.194 -
   5.195 -		
   5.196  		return answer;		
   5.197  	}
   5.198  	
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/ResponseMessages.java	Thu Apr 19 14:18:00 2012 +0300
     6.3 @@ -0,0 +1,47 @@
     6.4 +/**
     6.5 + * 
     6.6 + */
     6.7 +package eu.earthobservatory.org.StrabonEndpoint;
     6.8 +
     6.9 +/**
    6.10 + * This class holds the methods constructing the various
    6.11 + * responses to a client issuing a query, update, or store
    6.12 + * request.
    6.13 + * 
    6.14 + * @author charnik
    6.15 + *
    6.16 + */
    6.17 +public class ResponseMessages {
    6.18 +
    6.19 +	/**
    6.20 +	 * Used as the template answer for UPDATE queries.
    6.21 +	 * @return
    6.22 +	 */
    6.23 +	public static String getXMLHeader() {
    6.24 +		return "<?xml version='1.0' encoding='UTF-8'?>\n" +
    6.25 +			   "<response>\n" +
    6.26 +			   "\t";
    6.27 +	}
    6.28 +	
    6.29 +	/**
    6.30 +	 * Used as the template answer for UPDATE queries.
    6.31 +	 * Actually, it encloses msg around an <exception>
    6.32 +	 * XML element tag.
    6.33 +	 * @param msg
    6.34 +	 * @return
    6.35 +	 */
    6.36 +	public static String getXMLException(String msg) {
    6.37 +		return "<exception>\n"+msg+"\n\t</exception>";
    6.38 +	}
    6.39 +	
    6.40 +	/**
    6.41 +	 * Used as the template answer for UPDATE queries.
    6.42 +	 * @return
    6.43 +	 */
    6.44 +	public static String getXMLFooter() {
    6.45 +		return "\n</response>\n";
    6.46 +	}
    6.47 +	
    6.48 +	
    6.49 +	
    6.50 +}
     7.1 --- a/endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/StrabonBeanWrapper.java	Thu Apr 19 14:04:35 2012 +0300
     7.2 +++ b/endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/StrabonBeanWrapper.java	Thu Apr 19 14:18:00 2012 +0300
     7.3 @@ -101,19 +101,6 @@
     7.4  			throw new RepositoryException("Could not connect to Strabon.");
     7.5  		} 
     7.6  		
     7.7 -    	//String newQueryString = TemporalWrapper.rebuildQuery(queryString);
     7.8 -    	
     7.9 -    	System.out.println("================================================================");
    7.10 -    	System.out.println("Query:");
    7.11 -    	System.out.println(queryString);
    7.12 -    	System.out.println("================================================================");
    7.13 -    	System.out.println("Answer format: " + answerFormatStrabon);
    7.14 -    	System.out.println("================================================================");
    7.15 -    	//System.out.println("Rewritten query:");
    7.16 -    	//System.out.println(newQueryString);
    7.17 -    	//System.out.println("================================================================");
    7.18 -		
    7.19 -   		//return strabon.query(newQueryString, answerFormatStrabon, strabon.getSailRepoConnection());
    7.20  		return strabon.query(queryString, answerFormatStrabon, strabon.getSailRepoConnection());
    7.21  	}
    7.22  	
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/UpdateBean.java	Thu Apr 19 14:18:00 2012 +0300
     8.3 @@ -0,0 +1,67 @@
     8.4 +/**
     8.5 + * 
     8.6 + */
     8.7 +package eu.earthobservatory.org.StrabonEndpoint;
     8.8 +
     8.9 +import java.io.IOException;
    8.10 +
    8.11 +import javax.servlet.ServletConfig;
    8.12 +import javax.servlet.ServletContext;
    8.13 +import javax.servlet.ServletException;
    8.14 +import javax.servlet.http.HttpServlet;
    8.15 +import javax.servlet.http.HttpServletRequest;
    8.16 +import javax.servlet.http.HttpServletResponse;
    8.17 +
    8.18 +import org.openrdf.query.MalformedQueryException;
    8.19 +import org.springframework.web.context.WebApplicationContext;
    8.20 +import org.springframework.web.context.support.WebApplicationContextUtils;
    8.21 +
    8.22 +/**
    8.23 + * @author charnik
    8.24 + *
    8.25 + */
    8.26 +public class UpdateBean extends HttpServlet {
    8.27 +
    8.28 +	private static final long serialVersionUID = -633279376188071670L;
    8.29 +
    8.30 +	private StrabonBeanWrapper strabonWrapper;
    8.31 +	
    8.32 +	public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    8.33 +		doPost(request, response);
    8.34 +	}
    8.35 +			
    8.36 +	@Override
    8.37 +	public void init(ServletConfig servletConfig) throws ServletException {
    8.38 +		super.init(servletConfig);
    8.39 +		
    8.40 +		// get strabon wrapper
    8.41 +		ServletContext context = getServletContext();
    8.42 +		WebApplicationContext applicationContext = WebApplicationContextUtils.getWebApplicationContext(context);
    8.43 +		
    8.44 +		strabonWrapper = (StrabonBeanWrapper) applicationContext.getBean("strabonBean");
    8.45 +	}
    8.46 +	
    8.47 +	public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    8.48 +		String query = request.getParameter("SPARQLQuery");
    8.49 +		
    8.50 +		String answer = "";
    8.51 +		try {
    8.52 +			if (query == null) {
    8.53 +				throw new MalformedQueryException("No SPARQL Update query specified.");
    8.54 +			}
    8.55 +			
    8.56 +			strabonWrapper.getStrabon().update(query, strabonWrapper.getStrabon().getSailRepoConnection());
    8.57 +			response.setStatus(HttpServletResponse.SC_OK);
    8.58 +			answer = "true";
    8.59 +			
    8.60 +		} catch(MalformedQueryException e) {
    8.61 +			response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
    8.62 +			answer = ResponseMessages.getXMLException(e.getMessage());
    8.63 +		}
    8.64 +		
    8.65 +		// write response to client
    8.66 +		response.getWriter().append(ResponseMessages.getXMLHeader());
    8.67 +		response.getWriter().append(answer);
    8.68 +		response.getWriter().append(ResponseMessages.getXMLFooter());
    8.69 +	}
    8.70 +}
     9.1 --- a/evaluation/pom.xml	Thu Apr 19 14:04:35 2012 +0300
     9.2 +++ b/evaluation/pom.xml	Thu Apr 19 14:18:00 2012 +0300
     9.3 @@ -5,7 +5,7 @@
     9.4  	<parent>
     9.5  		<groupId>eu.earthobservatory</groupId>
     9.6  		<artifactId>strabon</artifactId>
     9.7 -		<version>3.1.8-SNAPSHOT</version>
     9.8 +		<version>3.1.9-SNAPSHOT</version>
     9.9  	</parent>
    9.10  
    9.11  	<groupId>org.openrdf.sesame</groupId>
    10.1 --- a/evaluation/src/main/java/org/openrdf/query/algebra/evaluation/impl/SpatialJoinOptimizer.java	Thu Apr 19 14:04:35 2012 +0300
    10.2 +++ b/evaluation/src/main/java/org/openrdf/query/algebra/evaluation/impl/SpatialJoinOptimizer.java	Thu Apr 19 14:18:00 2012 +0300
    10.3 @@ -195,6 +195,7 @@
    10.4  			}
    10.5  
    10.6  			//Checking graph to be sure
    10.7 +			/*
    10.8  			for(int a = 0; a < allNodes; a++)
    10.9  			{
   10.10  				for(int b = 0; b < allNodes; b++)
   10.11 @@ -204,6 +205,7 @@
   10.12  				}
   10.13  				System.out.println("");
   10.14  			}
   10.15 +			*/
   10.16  
   10.17  			//Time to construct ordered sequence of joins + filters
   10.18  			List<TupleExpr> orderedJoinArgs = new ArrayList<TupleExpr>(allNodes);
   10.19 @@ -223,9 +225,11 @@
   10.20  				}
   10.21  
   10.22  			}
   10.23 +
   10.24 +			/*
   10.25  			System.out.println("*--REWRITTEN TREE--**");
   10.26  			System.out.println(finalList.toString());
   10.27 -
   10.28 +			*/
   10.29  
   10.30  			int varsMapSize = varsMap.size();
   10.31  			for(Integer position : finalList)
   10.32 @@ -724,4 +728,4 @@
   10.33  	}
   10.34  
   10.35  
   10.36 -}
   10.37 \ No newline at end of file
   10.38 +}
    11.1 --- a/generaldb/pom.xml	Thu Apr 19 14:04:35 2012 +0300
    11.2 +++ b/generaldb/pom.xml	Thu Apr 19 14:18:00 2012 +0300
    11.3 @@ -6,7 +6,7 @@
    11.4  	<parent>
    11.5  		<groupId>eu.earthobservatory</groupId>
    11.6  		<artifactId>strabon</artifactId>
    11.7 -		<version>3.1.8-SNAPSHOT</version>
    11.8 +		<version>3.1.9-SNAPSHOT</version>
    11.9  	</parent>
   11.10    
   11.11  	<groupId>org.openrdf.sesame</groupId>
    12.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/GeneralDBSqlTable.java	Thu Apr 19 14:04:35 2012 +0300
    12.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/GeneralDBSqlTable.java	Thu Apr 19 14:18:00 2012 +0300
    12.3 @@ -48,4 +48,6 @@
    12.4  	public abstract String buildDummyFromAndWhere(String fromDummy);
    12.5  	
    12.6  	public abstract String buildDynamicParameterInteger();
    12.7 +	
    12.8 +	public abstract String buildWhere();
    12.9  }
    13.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/GeneralDBTripleRepository.java	Thu Apr 19 14:04:35 2012 +0300
    13.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/GeneralDBTripleRepository.java	Thu Apr 19 14:18:00 2012 +0300
    13.3 @@ -156,17 +156,8 @@
    13.4  		conn.setAutoCommit(false);
    13.5  	}
    13.6  
    13.7 -	public synchronized void close()
    13.8 -		throws SQLException
    13.9 -	{
   13.10 -		manager.close();
   13.11 -		if (!conn.getAutoCommit()) {
   13.12 -			conn.rollback();
   13.13 -		}
   13.14 -		conn.setAutoCommit(true);
   13.15 -		conn.close();
   13.16 -		releaseLock();
   13.17 -	}
   13.18 +	abstract public void close()
   13.19 +		throws SQLException;
   13.20  
   13.21  	public synchronized void commit()
   13.22  		throws SQLException, RdbmsException, InterruptedException 
    14.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/optimizers/GeneralDBSelectQueryOptimizer.java	Thu Apr 19 14:04:35 2012 +0300
    14.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/optimizers/GeneralDBSelectQueryOptimizer.java	Thu Apr 19 14:18:00 2012 +0300
    14.3 @@ -187,7 +187,7 @@
    14.4  		this.dataset = dataset;
    14.5  		this.bindings = bindings;
    14.6  		tupleExpr.visit(this);
    14.7 -		System.out.println("placeholder");
    14.8 +		//System.out.println("placeholder");
    14.9  	}
   14.10  
   14.11  	@Override
    15.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/schema/GeoValueTable.java	Thu Apr 19 14:04:35 2012 +0300
    15.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/schema/GeoValueTable.java	Thu Apr 19 14:18:00 2012 +0300
    15.3 @@ -139,7 +139,7 @@
    15.4  		INSERT = sb.toString();
    15.5  		sb.delete(0, sb.length());
    15.6  		sb.append("DELETE FROM ").append(table.getName()).append("\n");
    15.7 -		sb.append("WHERE 1=1 ");
    15.8 +		sb.append(((GeneralDBSqlTable)table).buildWhere());
    15.9  		EXPUNGE = sb.toString();
   15.10  		if (temporary != null) {
   15.11  			sb.delete(0, sb.length());
    16.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/schema/LiteralTable.java	Thu Apr 19 14:04:35 2012 +0300
    16.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/schema/LiteralTable.java	Thu Apr 19 14:18:00 2012 +0300
    16.3 @@ -262,7 +262,7 @@
    16.4  		String[] crs=label.split(";");
    16.5  		if((crs.length == 1))
    16.6  		{
    16.7 -			System.out.println("srid not specified. 4326 will be used as default.");
    16.8 +			//System.out.println("The coordinate reference system for the spatial literal is not specified. WGS84 (srid 4326) is used (default).");
    16.9  			return 4326; //use this as default
   16.10  		}
   16.11  		String prefix="http://www.opengis.net/def/crs/EPSG/0/";
   16.12 @@ -270,9 +270,9 @@
   16.13  			int index=crs[1].lastIndexOf('/');
   16.14  			index++;
   16.15  			Integer srid = Integer.parseInt(crs[1].substring(index));
   16.16 -			 System.out.println("The EPSG code: " + srid);
   16.17 +			//System.out.println("The EPSG code: " + srid);
   16.18  					 
   16.19 -			System.out.println("SRS FOUND:"+srid);
   16.20 +			//System.out.println("SRS FOUND:"+srid);
   16.21  			 return srid;
   16.22  		}else{
   16.23  			throw new IllegalArgumentException("MALFORMED URI FOR SRID!!!");
    17.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/schema/ValueTable.java	Thu Apr 19 14:04:35 2012 +0300
    17.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/schema/ValueTable.java	Thu Apr 19 14:18:00 2012 +0300
    17.3 @@ -136,7 +136,7 @@
    17.4  		INSERT = sb.toString();
    17.5  		sb.delete(0, sb.length());
    17.6  		sb.append("DELETE FROM ").append(table.getName()).append("\n");
    17.7 -		sb.append("WHERE 1=1 ");
    17.8 +		sb.append(table.buildWhere());
    17.9  		EXPUNGE = sb.toString();
   17.10  		if (temporary != null) {
   17.11  			sb.delete(0, sb.length());
    18.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/schema/ValueTableFactory.java	Thu Apr 19 14:04:35 2012 +0300
    18.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/schema/ValueTableFactory.java	Thu Apr 19 14:18:00 2012 +0300
    18.3 @@ -171,7 +171,7 @@
    18.4  			int sqlType, int length)
    18.5  		throws SQLException
    18.6  	{
    18.7 -		System.out.println("Create GeoValueTable!!");
    18.8 +		//System.out.println("Create GeoValueTable!!");
    18.9  		GeoValueTable table = newGeoValueTable();
   18.10  		
   18.11  		table.setRdbmsTable(createTable(conn, name));
    19.1 --- a/monetdb/pom.xml	Thu Apr 19 14:04:35 2012 +0300
    19.2 +++ b/monetdb/pom.xml	Thu Apr 19 14:18:00 2012 +0300
    19.3 @@ -6,7 +6,7 @@
    19.4  	<parent>
    19.5  		<groupId>eu.earthobservatory</groupId>
    19.6  		<artifactId>strabon</artifactId>
    19.7 -		<version>3.1.8-SNAPSHOT</version>
    19.8 +		<version>3.1.9-SNAPSHOT</version>
    19.9  	</parent>
   19.10    
   19.11  	<groupId>org.openrdf.sesame</groupId>
    20.1 --- a/monetdb/src/main/java/org/openrdf/sail/monetdb/MonetDBSqlTable.java	Thu Apr 19 14:04:35 2012 +0300
    20.2 +++ b/monetdb/src/main/java/org/openrdf/sail/monetdb/MonetDBSqlTable.java	Thu Apr 19 14:18:00 2012 +0300
    20.3 @@ -74,4 +74,9 @@
    20.4  	public String buildDynamicParameterInteger() {
    20.5  			return "CAST( ? AS INTEGER)";
    20.6  	}
    20.7 +	
    20.8 +	@Override
    20.9 +	public String buildWhere() {
   20.10 +		return " WHERE (1=1 OR 1=1) ";
   20.11 +	}
   20.12  }
   20.13 \ No newline at end of file
    21.1 --- a/monetdb/src/main/java/org/openrdf/sail/monetdb/MonetDBTripleRepository.java	Thu Apr 19 14:04:35 2012 +0300
    21.2 +++ b/monetdb/src/main/java/org/openrdf/sail/monetdb/MonetDBTripleRepository.java	Thu Apr 19 14:18:00 2012 +0300
    21.3 @@ -147,4 +147,24 @@
    21.4  //		}
    21.5  //		return sb.toString();
    21.6  //	}
    21.7 +	
    21.8 +	@Override
    21.9 +	public synchronized void close()
   21.10 +		throws SQLException
   21.11 +	{
   21.12 +		manager.close();
   21.13 +		if (!conn.getAutoCommit()) {
   21.14 +			conn.rollback();
   21.15 +		}
   21.16 +	
   21.17 +		/**
   21.18 +		 * In MonetDBConnectionFactory.createConnection()
   21.19 +		 * instead of creating a new connection (<db>) the connection <nsAndTableIndexes> is shared.
   21.20 +		 * Here the <db> connection would be closed. This should not be done because it 
   21.21 +		 * would cause <nsAndTableIndexes> to close too. 
   21.22 +		 * */
   21.23 +//		conn.setAutoCommit(true);
   21.24 +//		conn.close();
   21.25 +		releaseLock();
   21.26 +	}
   21.27  }
    22.1 --- a/monetdb/src/main/java/org/openrdf/sail/monetdb/evaluation/MonetDBSqlExprBuilder.java	Thu Apr 19 14:04:35 2012 +0300
    22.2 +++ b/monetdb/src/main/java/org/openrdf/sail/monetdb/evaluation/MonetDBSqlExprBuilder.java	Thu Apr 19 14:18:00 2012 +0300
    22.3 @@ -25,10 +25,10 @@
    22.4  	@Override
    22.5  	public void appendBoolean(boolean booleanValue) {
    22.6  		if (booleanValue) {
    22.7 -			where.append(" (1=1) ");
    22.8 +			where.append(" (1=1 or 1=1) ");
    22.9  		}
   22.10  		else {
   22.11 -			where.append(" (0=1) ");
   22.12 +			where.append(" (0=1 or 0=1) ");
   22.13  		}
   22.14  	}
   22.15  	
    23.1 --- a/pom.xml	Thu Apr 19 14:04:35 2012 +0300
    23.2 +++ b/pom.xml	Thu Apr 19 14:18:00 2012 +0300
    23.3 @@ -1,11 +1,10 @@
    23.4 -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    23.5 -	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    23.6 +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    23.7  
    23.8  	<modelVersion>4.0.0</modelVersion>
    23.9  
   23.10  	<groupId>eu.earthobservatory</groupId>
   23.11  	<artifactId>strabon</artifactId>
   23.12 -	<version>3.1.8-SNAPSHOT</version>
   23.13 +	<version>3.1.9-SNAPSHOT</version>
   23.14  	<packaging>pom</packaging>
   23.15  
   23.16  	<parent>
   23.17 @@ -30,7 +29,7 @@
   23.18  	</modules>
   23.19  
   23.20  	<properties>
   23.21 -                <eu.earthobservatory.version>${project.version}</eu.earthobservatory.version>
   23.22 +                <eu.earthobservatory.version>3.1.9-SNAPSHOT</eu.earthobservatory.version>
   23.23  		<sesame.version>2.6.3</sesame.version>
   23.24  		<aduna.appbase.version>3.5.0</aduna.appbase.version>
   23.25  		<slf4j.version>1.6.1</slf4j.version>
   23.26 @@ -473,6 +472,15 @@
   23.27  					<artifactId>maven-assembly-plugin</artifactId>
   23.28  					<version>2.3</version>
   23.29  				</plugin>
   23.30 +				
   23.31 +				<!-- The following plugin is for being able to run tomcat6/7:run -->
   23.32 +				<!--
   23.33 +				<plugin>
   23.34 +					<groupId>org.apache.tomcat.maven</groupId>
   23.35 +					<artifactId>tomcat7-maven-plugin</artifactId>
   23.36 +					<version>2.0-SNAPSHOT</version>
   23.37 +				</plugin>
   23.38 +				-->
   23.39  			</plugins>
   23.40  		</pluginManagement>
   23.41  
   23.42 @@ -519,6 +527,23 @@
   23.43  
   23.44  	<!-- <pluginRepositories> <pluginRepository> <id>elca-services</id> <url>http://el4.elca-services.ch/el4j/maven2repository</url> 
   23.45  		<releases> <enabled>true</enabled> </releases> </pluginRepository> </pluginRepositories> -->
   23.46 +	
   23.47 +	<pluginRepositories>
   23.48 +		<!-- The following repository is for being able to run tomcat7:run -->
   23.49 +		<!-- 
   23.50 +		<pluginRepository>
   23.51 +			<id>apache.snapshots</id>
   23.52 +			<name>Apache Snapshots</name>
   23.53 +			<url>http://people.apache.org/repo/m2-snapshot-repository</url>
   23.54 +			<releases>
   23.55 +				<enabled>false</enabled>
   23.56 +			</releases>
   23.57 +			<snapshots>
   23.58 +				<enabled>true</enabled>
   23.59 +			</snapshots>
   23.60 +		</pluginRepository>
   23.61 +		-->
   23.62 +	</pluginRepositories>
   23.63  
   23.64  	<scm>
   23.65  		<connection>scm:hg:ssh://hg.strabon.di.uoa.gr//opt/hg/Strabon/</connection>
    24.1 --- a/postgis/pom.xml	Thu Apr 19 14:04:35 2012 +0300
    24.2 +++ b/postgis/pom.xml	Thu Apr 19 14:18:00 2012 +0300
    24.3 @@ -6,7 +6,7 @@
    24.4  	<parent>
    24.5  		<groupId>eu.earthobservatory</groupId>
    24.6  		<artifactId>strabon</artifactId>
    24.7 -		<version>3.1.8-SNAPSHOT</version>
    24.8 +		<version>3.1.9-SNAPSHOT</version>
    24.9  	</parent>
   24.10    
   24.11  	<groupId>org.openrdf.sesame</groupId>
    25.1 --- a/postgis/src/main/java/org/openrdf/sail/postgis/PostGISConnectionFactory.java	Thu Apr 19 14:04:35 2012 +0300
    25.2 +++ b/postgis/src/main/java/org/openrdf/sail/postgis/PostGISConnectionFactory.java	Thu Apr 19 14:18:00 2012 +0300
    25.3 @@ -67,68 +67,67 @@
    25.4  	@Override
    25.5  	public SailConnection createConnection()
    25.6  	throws SailException
    25.7 -{
    25.8 -	try {
    25.9 -		Connection db = getConnection();
   25.10 -		db.setAutoCommit(true);
   25.11 -		if (db.getTransactionIsolation() != TRANSACTION_READ_COMMITTED) {
   25.12 -			db.setTransactionIsolation(TRANSACTION_READ_COMMITTED);
   25.13 +	{
   25.14 +		try {
   25.15 +			Connection db = getConnection();
   25.16 +			db.setAutoCommit(true);
   25.17 +			if (db.getTransactionIsolation() != TRANSACTION_READ_COMMITTED) {
   25.18 +				db.setTransactionIsolation(TRANSACTION_READ_COMMITTED);
   25.19 +			}
   25.20 +			TripleManager tripleManager = new TripleManager();
   25.21 +			GeneralDBTripleRepository s = new PostGISTripleRepository();
   25.22 +			s.setTripleManager(tripleManager);
   25.23 +			s.setValueFactory(vf);
   25.24 +			s.setConnection(db);
   25.25 +			s.setBNodeTable(bnodeTable);
   25.26 +			s.setURITable(uriTable);
   25.27 +			s.setLiteralTable(literalTable);
   25.28 +			s.setIdSequence(ids);
   25.29 +			DefaultSailChangedEvent sailChangedEvent = new DefaultSailChangedEvent(sail);
   25.30 +			s.setSailChangedEvent(sailChangedEvent);
   25.31 +			TableFactory tables = createTableFactory();
   25.32 +			TransTableManager trans = createTransTableManager();
   25.33 +			trans.setIdSequence(ids);
   25.34 +			tripleManager.setTransTableManager(trans);
   25.35 +			trans.setBatchQueue(tripleManager.getQueue());
   25.36 +			trans.setSailChangedEvent(sailChangedEvent);
   25.37 +			trans.setConnection(db);
   25.38 +			trans.setTemporaryTableFactory(tables);
   25.39 +			trans.setStatementsTable(tripleTableManager);
   25.40 +			trans.setFromDummyTable(getFromDummyTable());
   25.41 +			trans.initialize();
   25.42 +			s.setTransaction(trans);
   25.43 +			GeneralDBQueryBuilderFactory bfactory = createQueryBuilderFactory();
   25.44 +			bfactory.setValueFactory(vf);
   25.45 +			bfactory.setUsingHashTable(hashManager != null);
   25.46 +			s.setQueryBuilderFactory(bfactory);
   25.47 +			GeneralDBConnection conn = new GeneralDBConnection(sail, s);
   25.48 +			conn.setNamespaces(namespaces);
   25.49 +			GeneralDBEvaluationFactory efactory = new PostGISEvaluationFactory();
   25.50 +			efactory.setQueryBuilderFactory(bfactory);
   25.51 +			efactory.setRdbmsTripleRepository(s);
   25.52 +			efactory.setIdSequence(ids);
   25.53 +			conn.setRdbmsEvaluationFactory(efactory);
   25.54 +			GeneralDBQueryOptimizer optimizer = createOptimizer();
   25.55 +			GeneralDBSelectQueryOptimizerFactory selectOptimizerFactory = createSelectQueryOptimizerFactory();
   25.56 +			selectOptimizerFactory.setTransTableManager(trans);
   25.57 +			selectOptimizerFactory.setValueFactory(vf);
   25.58 +			selectOptimizerFactory.setIdSequence(ids);
   25.59 +			optimizer.setSelectQueryOptimizerFactory(selectOptimizerFactory);
   25.60 +			optimizer.setValueFactory(vf);
   25.61 +			optimizer.setBnodeTable(bnodeTable);
   25.62 +			optimizer.setUriTable(uriTable);
   25.63 +			optimizer.setLiteralTable(literalTable);
   25.64 +			optimizer.setHashTable(hashTable);
   25.65 +			conn.setRdbmsQueryOptimizer(optimizer);
   25.66 +			conn.setLockManager(lock);
   25.67 +			return conn;
   25.68  		}
   25.69 -		TripleManager tripleManager = new TripleManager();
   25.70 -		GeneralDBTripleRepository s = new PostGISTripleRepository();
   25.71 -		s.setTripleManager(tripleManager);
   25.72 -		s.setValueFactory(vf);
   25.73 -		s.setConnection(db);
   25.74 -		s.setBNodeTable(bnodeTable);
   25.75 -		s.setURITable(uriTable);
   25.76 -		s.setLiteralTable(literalTable);
   25.77 -		s.setIdSequence(ids);
   25.78 -		DefaultSailChangedEvent sailChangedEvent = new DefaultSailChangedEvent(sail);
   25.79 -		s.setSailChangedEvent(sailChangedEvent);
   25.80 -		TableFactory tables = createTableFactory();
   25.81 -		TransTableManager trans = createTransTableManager();
   25.82 -		trans.setIdSequence(ids);
   25.83 -		tripleManager.setTransTableManager(trans);
   25.84 -		trans.setBatchQueue(tripleManager.getQueue());
   25.85 -		trans.setSailChangedEvent(sailChangedEvent);
   25.86 -		trans.setConnection(db);
   25.87 -		trans.setTemporaryTableFactory(tables);
   25.88 -		trans.setStatementsTable(tripleTableManager);
   25.89 -		trans.setFromDummyTable(getFromDummyTable());
   25.90 -		trans.initialize();
   25.91 -		s.setTransaction(trans);
   25.92 -		GeneralDBQueryBuilderFactory bfactory = createQueryBuilderFactory();
   25.93 -		bfactory.setValueFactory(vf);
   25.94 -		bfactory.setUsingHashTable(hashManager != null);
   25.95 -		s.setQueryBuilderFactory(bfactory);
   25.96 -		GeneralDBConnection conn = new GeneralDBConnection(sail, s);
   25.97 -		conn.setNamespaces(namespaces);
   25.98 -		GeneralDBEvaluationFactory efactory = new PostGISEvaluationFactory();
   25.99 -		efactory.setQueryBuilderFactory(bfactory);
  25.100 -		efactory.setRdbmsTripleRepository(s);
  25.101 -		efactory.setIdSequence(ids);
  25.102 -		conn.setRdbmsEvaluationFactory(efactory);
  25.103 -		GeneralDBQueryOptimizer optimizer = createOptimizer();
  25.104 -		GeneralDBSelectQueryOptimizerFactory selectOptimizerFactory = createSelectQueryOptimizerFactory();
  25.105 -		selectOptimizerFactory.setTransTableManager(trans);
  25.106 -		selectOptimizerFactory.setValueFactory(vf);
  25.107 -		selectOptimizerFactory.setIdSequence(ids);
  25.108 -		optimizer.setSelectQueryOptimizerFactory(selectOptimizerFactory);
  25.109 -		optimizer.setValueFactory(vf);
  25.110 -		optimizer.setBnodeTable(bnodeTable);
  25.111 -		optimizer.setUriTable(uriTable);
  25.112 -		optimizer.setLiteralTable(literalTable);
  25.113 -		optimizer.setHashTable(hashTable);
  25.114 -		conn.setRdbmsQueryOptimizer(optimizer);
  25.115 -		conn.setLockManager(lock);
  25.116 -		return conn;
  25.117 +		catch (SQLException e) {
  25.118 +			throw new RdbmsException(e);
  25.119 +		}
  25.120  	}
  25.121 -	catch (SQLException e) {
  25.122 -		throw new RdbmsException(e);
  25.123 -	}
  25.124 -}
  25.125  
  25.126 -	
  25.127  	/**
  25.128  	 * FROM DUAL
  25.129  	 * 
    26.1 --- a/postgis/src/main/java/org/openrdf/sail/postgis/PostGISSqlTable.java	Thu Apr 19 14:04:35 2012 +0300
    26.2 +++ b/postgis/src/main/java/org/openrdf/sail/postgis/PostGISSqlTable.java	Thu Apr 19 14:18:00 2012 +0300
    26.3 @@ -75,4 +75,9 @@
    26.4  	public String buildDynamicParameterInteger() {
    26.5  			return "?";
    26.6  	}
    26.7 +	
    26.8 +	@Override
    26.9 +	public String buildWhere() {
   26.10 +		return " WHERE (1=1) ";
   26.11 +	}
   26.12  }
   26.13 \ No newline at end of file
    27.1 --- a/postgis/src/main/java/org/openrdf/sail/postgis/PostGISTripleRepository.java	Thu Apr 19 14:04:35 2012 +0300
    27.2 +++ b/postgis/src/main/java/org/openrdf/sail/postgis/PostGISTripleRepository.java	Thu Apr 19 14:18:00 2012 +0300
    27.3 @@ -110,4 +110,17 @@
    27.4  		}
    27.5  		return sb.toString();
    27.6  	}
    27.7 +	
    27.8 +	@Override
    27.9 +	public synchronized void close()
   27.10 +		throws SQLException
   27.11 +	{
   27.12 +		manager.close();
   27.13 +		if (!conn.getAutoCommit()) {
   27.14 +			conn.rollback();
   27.15 +		}
   27.16 +		conn.setAutoCommit(true);
   27.17 +		conn.close();
   27.18 +		releaseLock();
   27.19 +	}
   27.20  }
    28.1 --- a/postgis/src/main/java/org/openrdf/sail/postgis/evaluation/PostGISEvaluation.java	Thu Apr 19 14:04:35 2012 +0300
    28.2 +++ b/postgis/src/main/java/org/openrdf/sail/postgis/evaluation/PostGISEvaluation.java	Thu Apr 19 14:18:00 2012 +0300
    28.3 @@ -64,8 +64,8 @@
    28.4  					stmt.setObject(++p, o);
    28.5  				}
    28.6  				Collection<GeneralDBColumnVar> proj = qb.getProjections();
    28.7 -				System.out.println("In PostGIS Evaluation, query is: ");
    28.8 -				System.out.println(stmt.toString());
    28.9 +				//System.out.println("The SQL query is: ");
   28.10 +				//System.out.println(stmt.toString().replaceAll("\n"," ");
   28.11  				GeneralDBBindingIteration result = new PostGISBindingIteration(stmt);
   28.12  				result.setProjections(proj);
   28.13  				result.setBindings(bindings);
   28.14 @@ -87,4 +87,4 @@
   28.15  			throw new RdbmsQueryEvaluationException(e);
   28.16  		}
   28.17  	}
   28.18 -}
   28.19 \ No newline at end of file
   28.20 +}
    29.1 --- a/resultio/pom.xml	Thu Apr 19 14:04:35 2012 +0300
    29.2 +++ b/resultio/pom.xml	Thu Apr 19 14:18:00 2012 +0300
    29.3 @@ -5,7 +5,7 @@
    29.4  	<parent>
    29.5  		<groupId>eu.earthobservatory</groupId>
    29.6  		<artifactId>strabon</artifactId>
    29.7 -		<version>3.1.8-SNAPSHOT</version>
    29.8 +		<version>3.1.9-SNAPSHOT</version>
    29.9  	</parent>
   29.10  
   29.11  	<groupId>org.openrdf.sesame</groupId>
    30.1 --- a/runtime/pom.xml	Thu Apr 19 14:04:35 2012 +0300
    30.2 +++ b/runtime/pom.xml	Thu Apr 19 14:18:00 2012 +0300
    30.3 @@ -5,7 +5,7 @@
    30.4  	<parent>
    30.5  		<groupId>eu.earthobservatory</groupId>
    30.6  		<artifactId>strabon</artifactId>
    30.7 -		<version>3.1.8-SNAPSHOT</version>
    30.8 +		<version>3.1.9-SNAPSHOT</version>
    30.9  	</parent>
   30.10  
   30.11  	<artifactId>strabon-runtime</artifactId>
    31.1 --- a/runtime/src/main/java/eu/earthobservatory/runtime/generaldb/Strabon.java	Thu Apr 19 14:04:35 2012 +0300
    31.2 +++ b/runtime/src/main/java/eu/earthobservatory/runtime/generaldb/Strabon.java	Thu Apr 19 14:18:00 2012 +0300
    31.3 @@ -150,6 +150,18 @@
    31.4  			}
    31.5  	}
    31.6  
    31.7 +	public Object query(String queryString)
    31.8 +	throws  MalformedQueryException, QueryEvaluationException, IOException, TupleQueryResultHandlerException
    31.9 +	{
   31.10 +		return query(queryString, "", this.getSailRepoConnection());	
   31.11 +	}
   31.12 +
   31.13 +	public Object query(String queryString, String resultsFormat)
   31.14 +			throws  MalformedQueryException , QueryEvaluationException, IOException, TupleQueryResultHandlerException
   31.15 +	{
   31.16 +		return query (queryString, resultsFormat, this.getSailRepoConnection());
   31.17 +	}
   31.18 +	
   31.19  	public Object query(String queryString, SailRepositoryConnection con)
   31.20  	throws  MalformedQueryException, QueryEvaluationException, IOException, TupleQueryResultHandlerException
   31.21  	{
   31.22 @@ -715,7 +727,7 @@
   31.23  		}
   31.24  		
   31.25  		// Print results.
   31.26 -		System.out.println(retStream.toString());
   31.27 +		//System.out.println(retStream.toString());
   31.28  
   31.29  		//return ret;
   31.30  		return retStream.toString();
    32.1 --- a/runtime/src/main/java/eu/earthobservatory/runtime/postgis/DescribeOp.java	Thu Apr 19 14:04:35 2012 +0300
    32.2 +++ b/runtime/src/main/java/eu/earthobservatory/runtime/postgis/DescribeOp.java	Thu Apr 19 14:18:00 2012 +0300
    32.3 @@ -17,7 +17,7 @@
    32.4  			System.err.println("             <USERNAME>   is the username to use when connecting to the database ");
    32.5  			System.err.println("             <PASSWORD>   is the password to use when connecting to the database");
    32.6  			System.err.println("             <QUERY>      is the stSPARQL query to evaluate.");
    32.7 -			System.err.println("             <OUTPUT>      is the stSPARQL query to evaluate.");
    32.8 +			System.err.println("             <OUTPUT>     is the output file.");
    32.9  			System.exit(0);
   32.10  		}
   32.11  
    33.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    33.2 +++ b/scripts/endpoint	Thu Apr 19 14:18:00 2012 +0300
    33.3 @@ -0,0 +1,144 @@
    33.4 +#!/bin/bash
    33.5 +#
    33.6 +# Script for executing SPARQL queries and SPARQL Update queries 
    33.7 +# as well as storing RDF triples on a Strabon Endpoint.
    33.8 +#
    33.9 +# Author: Charalampos (Babis) Nikolaou <charnik@di.uoa.gr>
   33.10 +#
   33.11 +
   33.12 +function help() {
   33.13 +	echo "Usage: `basename ${0}` [OPTIONS] COMMAND ENDPOINT ARGS"
   33.14 +	echo
   33.15 +	echo "Execute SPARQL and SPARQL Update queries as well as store RDF triples on a Strabon endpoint."
   33.16 +	echo
   33.17 +	echo "	COMMAND	 : one of query, update, store, or help"
   33.18 +	echo "	ENDPOINT : the URL of the Strabon Endpoint (e.g., http://localhost:8080/StrabonEndpoint)"
   33.19 +	echo "	ARGS	 : arguments according to selected command"
   33.20 +	echo 
   33.21 +	echo "OPTIONS can be any of the following"
   33.22 +	echo "	-d	 : don't run, just print what shall be executed"
   33.23 +}
   33.24 +
   33.25 +function help_query() {
   33.26 +	echo "Usage: `basename ${0}` query ENDPOINT SPARQL_QUERY"
   33.27 +	echo
   33.28 +	echo "	ENDPOINT     : the URL of Strabon Endpoint (e.g., http://localhost:8080/StrabonEndpoint/)"
   33.29 +	echo "	SPARQL_QUERY : the SPARQL query to execute"
   33.30 +}
   33.31 +
   33.32 +function help_update() {
   33.33 +	echo "Usage: `basename ${0}` update ENDPOINT SPARQL_QUERY"
   33.34 +	echo
   33.35 +	echo "	ENDPOINT     : the URL of Strabon Endpoint (e.g., http://localhost:8080/StrabonEndpoint/)"
   33.36 +	echo "	SPARQL_QUERY : the SPARQL update query to execute"
   33.37 +}
   33.38 +
   33.39 +function help_store() {
   33.40 +	echo "Usage: `basename ${0}` store ENDPOINT FORMAT -t TRIPLES|-u TRIPLES_URL"
   33.41 +	echo
   33.42 +	echo "	ENDPOINT    : the URL of Strabon Endpoint (e.g., http://localhost:8080/StrabonEndpoint/)"
   33.43 +	echo "	FORMAT	    : the RDF format of the input (one of RDF/XML, N-Triples, Turtle, N3, TriX, TriG, or BinaryRDF)"
   33.44 +	echo "	TRIPLES	    : the RDF triples to store"
   33.45 +	echo "	TRIPLES_URL : the URL containing the RDF triples to store"
   33.46 +}
   33.47 +
   33.48 +CURL_OPTS="-w HTTP_CODE='%{http_code}\n' -H \"Content-Type:application/x-www-form-urlencoded\" -H \"Accept:text/xml\""
   33.49 +
   33.50 +# if set to 1, then only the command to be executed is printed
   33.51 +DEBUG=0
   33.52 +
   33.53 +case "${1}" in
   33.54 +	-d)
   33.55 +		shift
   33.56 +		DEBUG=1
   33.57 +		;;
   33.58 +esac
   33.59 +
   33.60 +case "${1}" in
   33.61 +	help)
   33.62 +		shift
   33.63 +		if test $# -eq 1; then
   33.64 +			case "${1}" in
   33.65 +				query)
   33.66 +					help_query
   33.67 +					;;
   33.68 +				update)
   33.69 +					help_update
   33.70 +					;;
   33.71 +				store)
   33.72 +					help_store
   33.73 +					;;
   33.74 +				*)
   33.75 +					help
   33.76 +					;;
   33.77 +			esac
   33.78 +			exit 1
   33.79 +		fi
   33.80 +		help
   33.81 +		exit 0
   33.82 +		;;
   33.83 +	query)
   33.84 +		shift
   33.85 +		if ! test $# -eq 2; then
   33.86 +			help_query
   33.87 +			exit 1
   33.88 +		fi
   33.89 +		URL="${1}/Query"
   33.90 +		QUERY="${2}"
   33.91 +
   33.92 +		# TODO: make it an argument
   33.93 +		FORMAT="XML"
   33.94 +
   33.95 +		CMD="curl ${CURL_OPTS} -d \"format=${FORMAT}\" --data-urlencode \"SPARQLQuery=${QUERY}\" ${URL}"
   33.96 +		;;
   33.97 +	update)
   33.98 +		shift
   33.99 +		if ! test $# -eq 2; then
  33.100 +			help_update
  33.101 +			exit 1
  33.102 +		fi
  33.103 +		URL="${1}/Update"
  33.104 +		QUERY="${2}"
  33.105 +		
  33.106 +		CMD="curl ${CURL_OPTS} --data-urlencode \"SPARQLQuery=${QUERY}\" ${URL}"
  33.107 +		;;
  33.108 +	store)
  33.109 +		shift
  33.110 +		if ! test $# -eq 4; then
  33.111 +			help_store
  33.112 +			exit 1
  33.113 +		fi
  33.114 +		URL="${1}/Store"
  33.115 +		FORMAT="${2}"
  33.116 +		case "${3}" in
  33.117 +			-t)
  33.118 +				TRIPLES="${4}"
  33.119 +				CMD="curl ${CURL_OPTS} -d \"format=${FORMAT}\" --data-urlencode \"data=${TRIPLES}\" ${URL}"
  33.120 +				;;
  33.121 +			-u)
  33.122 +				URL_TRIPLES="${4}"
  33.123 +				CMD="curl ${CURL_OPTS} -d \"format=${FORMAT}\" --data-urlencode \"url=${URL_TRIPLES}\" -d \"fromurl=\" ${URL}"
  33.124 +				;;
  33.125 +			 *)
  33.126 +				help_store
  33.127 +				exit 1
  33.128 +				;;
  33.129 +		esac
  33.130 +		;;
  33.131 +	*) 
  33.132 +		help
  33.133 +		echo
  33.134 +		echo "ERROR: Unknown command \"${1}\"."
  33.135 +		exit 1
  33.136 +		;;
  33.137 +esac
  33.138 +
  33.139 +# execute or debug
  33.140 +if test $DEBUG -eq 1; then
  33.141 +	echo "`basename ${0}`: Debug is ON"
  33.142 +	echo "`basename ${0}`: Printing command for execution"	
  33.143 +	echo "	$CMD"
  33.144 +else
  33.145 +	eval ${CMD}
  33.146 +fi
  33.147 +