Strabon

changeset 548:4bd5b9a0177b

Partially addresses Ticket #16: http://bug.strabon.di.uoa.gr/ticket/16.
It remains to save the new connection details in beans.xml.
Renamed also inner class StrabonEndpoint.Entry to a full class StrabonBeanWrapperConfiguration under package eu.earthobservatory.StrabonEndpoint.
author Babis Nikolaou <charnik@di.uoa.gr>
date Sat Sep 15 20:30:57 2012 +0300 (2012-09-15)
parents 8b1b2a49ebf6
children 9c566efc5991
files endpoint/WebContent/WEB-INF/web.xml endpoint/WebContent/connection.jsp endpoint/WebContent/query.jsp endpoint/pom.xml endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/ConnectionBean.java endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/QueryBean.java endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/StrabonBeanWrapper.java endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/StrabonBeanWrapperConfiguration.java
line diff
     1.1 --- a/endpoint/WebContent/WEB-INF/web.xml	Sat Sep 15 03:07:44 2012 +0300
     1.2 +++ b/endpoint/WebContent/WEB-INF/web.xml	Sat Sep 15 20:30:57 2012 +0300
     1.3 @@ -47,7 +47,7 @@
     1.4  		<url-pattern>/Update</url-pattern>
     1.5  	</servlet-mapping>
     1.6  
     1.7 -        <servlet>
     1.8 +    <servlet>
     1.9  		<display-name>Describe</display-name>
    1.10  		<servlet-name>Describe</servlet-name>
    1.11  		<servlet-class>eu.earthobservatory.org.StrabonEndpoint.DescribeBean</servlet-class>
    1.12 @@ -59,6 +59,17 @@
    1.13  	</servlet-mapping>
    1.14  	
    1.15  	<servlet>
    1.16 +		<display-name>DBConnect</display-name>
    1.17 +		<servlet-name>DBConnect</servlet-name>
    1.18 +		<servlet-class>eu.earthobservatory.org.StrabonEndpoint.ConnectionBean</servlet-class>
    1.19 +		<load-on-startup>1</load-on-startup>
    1.20 +	</servlet>
    1.21 +	<servlet-mapping>
    1.22 +		<servlet-name>DBConnect</servlet-name>
    1.23 +		<url-pattern>/DBConnect</url-pattern>
    1.24 +	</servlet-mapping>
    1.25 +	
    1.26 +	<servlet>
    1.27  		<servlet-name>query.jsp</servlet-name>
    1.28  		<jsp-file>/query.jsp</jsp-file>
    1.29  	</servlet>
    1.30 @@ -73,6 +84,11 @@
    1.31  		<jsp-file>/describe.jsp</jsp-file>
    1.32  	</servlet>
    1.33   
    1.34 + 	<servlet>
    1.35 +		<servlet-name>connection.jsp</servlet-name>
    1.36 +		<jsp-file>/connection.jsp</jsp-file>
    1.37 +	</servlet>
    1.38 +	
    1.39     	<mime-mapping>
    1.40         	<extension>kml</extension>
    1.41         	<mime-type>application/vnd.google-earth.kml+xml</mime-type>
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/endpoint/WebContent/connection.jsp	Sat Sep 15 20:30:57 2012 +0300
     2.3 @@ -0,0 +1,70 @@
     2.4 +<jsp:directive.page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"/>
     2.5 +<jsp:directive.page import="eu.earthobservatory.org.StrabonEndpoint.Common"/>
     2.6 +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
     2.7 +<html>
     2.8 +	<head>
     2.9 +		<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
    2.10 +		<link rel="stylesheet" href="style.css" type="text/css" />
    2.11 +		 
    2.12 +		<script type="text/javascript">
    2.13 +			function toggleMe(a) {
    2.14 +				var e = document.getElementById(a);
    2.15 +				if (!e) {
    2.16 +					return true;
    2.17 +				}
    2.18 +				if (e.style.display == "none") {
    2.19 +					e.style.display = "block";
    2.20 +				} else {
    2.21 +					e.style.display = "none";
    2.22 +				}
    2.23 +				return true;
    2.24 +			}
    2.25 +		</script>
    2.26 +		<title>TELEIOS: Strabon Endpoint</title>
    2.27 +	</head>
    2.28 +<body topmargin="0" leftmargin="0" link="#FFFFFF" vlink="#FFFFFF" alink="#FFFFFF">
    2.29 +
    2.30 +<!-- include TELEIOS header and description -->
    2.31 +<jsp:include page="teleios-header.html"/>
    2.32 +<!-- include TELEIOS header and description -->
    2.33 +
    2.34 +<FORM method=POST enctype="UTF-8" accept-charset="UTF-8" action="DBConnect">
    2.35 +<input type="hidden" name="query" value="<%=request.getAttribute("query")%>"/>
    2.36 +<TABLE class="style4">
    2.37 +	<TR> 
    2.38 +		<TD valign="top" class="style4">Database Name:</TD>
    2.39 +		<TD><input type="text" name="dbname" value="<%=request.getAttribute("dbname")%>"/></TD>
    2.40 +	</TR>
    2.41 +	<TR> 
    2.42 +		<TD valign="top" class="style4">Username:</TD>
    2.43 +		<TD><input type="text" name="username" value="<%=request.getAttribute("username")%>"/></TD>
    2.44 +	</TR>
    2.45 +		<TR> 
    2.46 +		<TD valign="top" class="style4">Password:</TD>
    2.47 +		<TD><input type="password" name="password" value="<%=request.getAttribute("password")%>"/></TD>
    2.48 +	</TR>
    2.49 +	<TR> 
    2.50 +		<TD valign="top" class="style4">Port:</TD>
    2.51 +		<TD><input type="text" name="port" value="<%=request.getAttribute("port")%>"/></TD>
    2.52 +	</TR>
    2.53 +	<TR> 
    2.54 +		<TD valign="top" class="style4">Hostname:</TD>
    2.55 +		<TD><input type="text" name="hostname" value="<%=request.getAttribute("hostname")%>"/></TD>
    2.56 +	</TR>
    2.57 +	<TR> 
    2.58 +		<TD valign="top" class="style4">Database Backend:</TD>
    2.59 +		<TD>
    2.60 +			<SELECT name="dbengine">
    2.61 +				<OPTION value="<%=Common.DBBACKEND_POSTGIS%>" <%=Common.DBBACKEND_POSTGIS.equals(request.getAttribute("dbengine")) ? "selected":""%>><%=Common.DBBACKEND_POSTGIS%></OPTION>
    2.62 +				<OPTION value="<%=Common.DBBACKEND_MONETDB%>" <%=Common.DBBACKEND_MONETDB.equals(request.getAttribute("dbengine")) ? "selected":""%>><%=Common.DBBACKEND_MONETDB%></OPTION>
    2.63 +			</SELECT>
    2.64 +		</TD>
    2.65 +	</TR>
    2.66 +	<TR>
    2.67 +		<TD colspan=2><input type="submit" value="Connect"/></TD>
    2.68 +	</TR>
    2.69 +</TABLE>
    2.70 +</FORM>
    2.71 +<br/><br/><br/><br/><br/>
    2.72 +</BODY>
    2.73 +</HTML>
    2.74 \ No newline at end of file
     3.1 --- a/endpoint/WebContent/query.jsp	Sat Sep 15 03:07:44 2012 +0300
     3.2 +++ b/endpoint/WebContent/query.jsp	Sat Sep 15 20:30:57 2012 +0300
     3.3 @@ -3,7 +3,7 @@
     3.4  <%@page import="org.springframework.web.context.support.WebApplicationContextUtils"%>
     3.5  <%@page import="org.springframework.web.context.WebApplicationContext"%>
     3.6  <%@page import="eu.earthobservatory.org.StrabonEndpoint.StrabonBeanWrapper"%>
     3.7 -<%@page import="eu.earthobservatory.org.StrabonEndpoint.StrabonBeanWrapper.Entry"%>
     3.8 +<%@page import="eu.earthobservatory.org.StrabonEndpoint.StrabonBeanWrapperConfiguration"%>
     3.9  <%@page import="java.util.List"%>
    3.10  <%@page import="java.util.Iterator"%>
    3.11  <jsp:directive.page import="eu.earthobservatory.org.StrabonEndpoint.Common"/>
    3.12 @@ -27,11 +27,15 @@
    3.13  			return true;
    3.14  		}
    3.15  	</script>
    3.16 -<% if (request.getAttribute("pathToKML") != null) {
    3.17 -	if ("map_local".equals(request.getAttribute("handle"))) { %>
    3.18 +<%
    3.19 +	if (request.getAttribute("pathToKML") != null) {
    3.20 +	if ("map_local".equals(request.getAttribute("handle"))) {
    3.21 +%>
    3.22  	<script type="text/javascript" src="js/geoxml3-kmz.js"></script>
    3.23  	<script type="text/javascript" src="js/ProjectedOverlay.js"></script>	
    3.24 -	<%} %>
    3.25 +	<%
    3.26 +			}
    3.27 +		%>
    3.28  	<link href="http://code.google.com/apis/maps/documentation/javascript/examples/default.css" rel="stylesheet" type="text/css" />
    3.29  	<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
    3.30  	<script type="text/javascript">
    3.31 @@ -51,7 +55,7 @@
    3.32  			var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
    3.33  		
    3.34  			// display using geoxml3
    3.35 -		<%if ("map_local".equals(request.getAttribute("handle"))) { %>
    3.36 +		<%if ("map_local".equals(request.getAttribute("handle"))) {%>
    3.37  			var myParser = new geoXML3.parser({map: map});
    3.38  			myParser.parse(kml);
    3.39  			
    3.40 @@ -61,7 +65,9 @@
    3.41  		<%}%>
    3.42  		}
    3.43  	</script> 
    3.44 -<%}%>
    3.45 +<%
    3.46 + 	}
    3.47 + %>
    3.48  	<title>TELEIOS: Strabon Endpoint</title>
    3.49  </head>
    3.50  <body topmargin="0" leftmargin="0" link="#FFFFFF" vlink="#FFFFFF" alink="#FFFFFF" onload="initialize()">
    3.51 @@ -80,27 +86,27 @@
    3.52  		<tr><td id="twidth">
    3.53  		
    3.54  		<%
    3.55 -			StrabonBeanWrapper strabonWrapper;
    3.56 -			ServletContext context;
    3.57 -			context = getServletContext();
    3.58 -			WebApplicationContext applicationContext = WebApplicationContextUtils.getWebApplicationContext(context);
    3.59 -			strabonWrapper=(StrabonBeanWrapper) applicationContext.getBean("strabonBean");
    3.60 -			
    3.61 -			Iterator <Entry> entryListIterator = strabonWrapper.getEntries().iterator();
    3.62 -			
    3.63 -			while(entryListIterator.hasNext())
    3.64 -			{
    3.65 -				Entry entry = entryListIterator.next();
    3.66 -				String handle="";
    3.67 -				if(entry.getBean().equals("Query"))
    3.68 -				{
    3.69 -					handle="&handle=map";
    3.70 -				}
    3.71 -				
    3.72 -				String href="\""+URLEncoder.encode(entry.getBean(),"utf-8")+"?view=HTML"+handle+"&query="+URLEncoder.encode(entry.getStatement(),"utf-8")+"&format="+URLEncoder.encode(entry.getFormat(),"utf-8")+"\"";
    3.73 -				String title="\""+entry.getTitle()+"\"";
    3.74 -				String label=entry.getLabel();
    3.75 -		%>
    3.76 +					StrabonBeanWrapper strabonWrapper;
    3.77 +							ServletContext context;
    3.78 +							context = getServletContext();
    3.79 +							WebApplicationContext applicationContext = WebApplicationContextUtils.getWebApplicationContext(context);
    3.80 +							strabonWrapper=(StrabonBeanWrapper) applicationContext.getBean("strabonBean");
    3.81 +							
    3.82 +							Iterator <StrabonBeanWrapperConfiguration> entryListIterator = strabonWrapper.getEntries().iterator();
    3.83 +							
    3.84 +							while(entryListIterator.hasNext())
    3.85 +							{
    3.86 +								StrabonBeanWrapperConfiguration entry = entryListIterator.next();
    3.87 +								String handle="";
    3.88 +								if(entry.getBean().equals("Query"))
    3.89 +								{
    3.90 +									handle="&handle=map";
    3.91 +								}
    3.92 +								
    3.93 +								String href="\""+URLEncoder.encode(entry.getBean(),"utf-8")+"?view=HTML"+handle+"&query="+URLEncoder.encode(entry.getStatement(),"utf-8")+"&format="+URLEncoder.encode(entry.getFormat(),"utf-8")+"\"";
    3.94 +								String title="\""+entry.getTitle()+"\"";
    3.95 +								String label=entry.getLabel();
    3.96 +				%>
    3.97  					<a href=<%=href%> title=<%=title%>><%=label%></a><br/>
    3.98  		<%
    3.99  			}
   3.100 @@ -122,8 +128,17 @@
   3.101  <%}%>
   3.102  <tr>
   3.103  <td id="output">stSPARQL Query:</td>
   3.104 -<td id="output"><textarea name="query" title="pose your query/update here" rows="15" cols="100">
   3.105 -<%=request.getParameter("query") != null ? request.getParameter("query"):""%></textarea></td>
   3.106 +<%
   3.107 +	String query = "";
   3.108 +	if (request.getParameter("query") != null) {
   3.109 +		query = request.getParameter("query");
   3.110 +		
   3.111 +	} else if (request.getAttribute("query") != null) {
   3.112 +		query = (String) request.getAttribute("query");
   3.113 +		
   3.114 +	}
   3.115 +%>
   3.116 +<td id="output"><textarea name="query" title="pose your query/update here" rows="15" cols="100"><%=query%></textarea></td>
   3.117  </tr>
   3.118  <tr>
   3.119  	<td id="output"><center>Output Format:<br/>
     4.1 --- a/endpoint/pom.xml	Sat Sep 15 03:07:44 2012 +0300
     4.2 +++ b/endpoint/pom.xml	Sat Sep 15 20:30:57 2012 +0300
     4.3 @@ -186,6 +186,7 @@
     4.4  								<include>store.jsp</include>
     4.5  								<include>query.jsp</include>
     4.6  								<include>describe.jsp</include>
     4.7 +								<include>connection.jsp</include>
     4.8  								<include>teleios-header.html</include>
     4.9  							</includes>
    4.10  						</resource>
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/ConnectionBean.java	Sat Sep 15 20:30:57 2012 +0300
     5.3 @@ -0,0 +1,97 @@
     5.4 +/**
     5.5 + * 
     5.6 + */
     5.7 +package eu.earthobservatory.org.StrabonEndpoint;
     5.8 +
     5.9 +
    5.10 +import java.io.IOException;
    5.11 +
    5.12 +import javax.servlet.RequestDispatcher;
    5.13 +import javax.servlet.ServletConfig;
    5.14 +import javax.servlet.ServletContext;
    5.15 +import javax.servlet.ServletException;
    5.16 +import javax.servlet.http.HttpServlet;
    5.17 +import javax.servlet.http.HttpServletRequest;
    5.18 +import javax.servlet.http.HttpServletResponse;
    5.19 +
    5.20 +import org.springframework.web.context.WebApplicationContext;
    5.21 +import org.springframework.web.context.support.WebApplicationContextUtils;
    5.22 +
    5.23 +/**
    5.24 + * @author Charalampos Nikolaou <charnik@di.uoa.gr>
    5.25 + *
    5.26 + */
    5.27 +public class ConnectionBean extends HttpServlet {
    5.28 +
    5.29 +	private static final long serialVersionUID = 2237815345608023368L;
    5.30 +
    5.31 +	/**
    5.32 +	 * Wrapper over Strabon
    5.33 +	 */
    5.34 +	private StrabonBeanWrapper strabonWrapper;
    5.35 +	
    5.36 +	/**
    5.37 +	 * The context of the servlet
    5.38 +	 */
    5.39 +	private ServletContext context;
    5.40 +	
    5.41 +	@Override
    5.42 +	public void init(ServletConfig servletConfig) throws ServletException {
    5.43 +		super.init(servletConfig);
    5.44 +
    5.45 +		// get the context of the servlet
    5.46 +		context = getServletContext();
    5.47 +		
    5.48 +		// get the context of the application
    5.49 +		WebApplicationContext applicationContext = WebApplicationContextUtils.getWebApplicationContext(context);
    5.50 +
    5.51 +		// the the strabon wrapper
    5.52 +		strabonWrapper = (StrabonBeanWrapper) applicationContext.getBean("strabonBean");
    5.53 +
    5.54 +	}
    5.55 +	
    5.56 +	@Override
    5.57 +	public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    5.58 +		doPost(request, response);
    5.59 +	}
    5.60 +	
    5.61 +	@Override
    5.62 +	public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    5.63 +		RequestDispatcher dispatcher;
    5.64 +		
    5.65 +		// set new connection details
    5.66 +		strabonWrapper.setConnectionDetails(
    5.67 +				request.getParameter("username"), 
    5.68 +				request.getParameter("password"), 
    5.69 +				request.getParameter("dbname"), 
    5.70 +				request.getParameter("hostname"), 
    5.71 +				request.getParameter("port"), 
    5.72 +				request.getParameter("dbengine"));
    5.73 +		
    5.74 +		// pass the query that had been issued to the dispatcher
    5.75 +		request.setAttribute("query", request.getAttribute("query"));
    5.76 +			
    5.77 +		// establish connection
    5.78 +		if (strabonWrapper.init()) { // successfully connected, go to QueryBean
    5.79 +			// TODO: save the new connection details in beans.xml
    5.80 +			dispatcher = request.getRequestDispatcher("/query.jsp");
    5.81 +			
    5.82 +		} else { // try again
    5.83 +			// pass the current details of the connection
    5.84 +			request.setAttribute("username", request.getParameter("username"));
    5.85 +			request.setAttribute("password", request.getParameter("password"));
    5.86 +			request.setAttribute("dbname", request.getParameter("dbname"));
    5.87 +			request.setAttribute("hostname", request.getParameter("hostname"));
    5.88 +			request.setAttribute("port", request.getParameter("port"));
    5.89 +			request.setAttribute("dbengine", request.getParameter("dbengine"));
    5.90 +			
    5.91 +			dispatcher = request.getRequestDispatcher("/connection.jsp");
    5.92 +			
    5.93 +		}
    5.94 +		
    5.95 +		dispatcher.forward(request, response);
    5.96 +	}
    5.97 +
    5.98 +	
    5.99 +
   5.100 +}
     6.1 --- a/endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/QueryBean.java	Sat Sep 15 03:07:44 2012 +0300
     6.2 +++ b/endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/QueryBean.java	Sat Sep 15 20:30:57 2012 +0300
     6.3 @@ -100,14 +100,35 @@
     6.4  	public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
     6.5  		request.setCharacterEncoding("UTF-8");
     6.6  		
     6.7 -		if (Common.VIEW_TYPE.equals(request.getParameter(Common.VIEW))) {
     6.8 -			// HTML visual interface
     6.9 -			processVIEWRequest(request, response);
    6.10 +		// check connection details
    6.11 +		if (strabonWrapper.getStrabon() == null) {
    6.12 +			RequestDispatcher dispatcher = request.getRequestDispatcher("/connection.jsp");
    6.13  			
    6.14 -
    6.15 -		} else {// invoked as a service
    6.16 -			processRequest(request, response);
    6.17 -	    }
    6.18 +			// pass the current details of the connection
    6.19 +			request.setAttribute("username", strabonWrapper.getUsername());
    6.20 +			request.setAttribute("password", strabonWrapper.getPassword());
    6.21 +			request.setAttribute("dbname", strabonWrapper.getDatabaseName());
    6.22 +			request.setAttribute("hostname", strabonWrapper.getHostName());
    6.23 +			request.setAttribute("port", strabonWrapper.getPort());
    6.24 +			request.setAttribute("dbengine", strabonWrapper.getDBEngine());
    6.25 +			
    6.26 +			// pass the query as well
    6.27 +			request.setAttribute("query", request.getParameter("query"));
    6.28 +			
    6.29 +			// forward the request
    6.30 +			dispatcher.forward(request, response);
    6.31 +			
    6.32 +		} else {
    6.33 +		
    6.34 +			if (Common.VIEW_TYPE.equals(request.getParameter(Common.VIEW))) {
    6.35 +				// HTML visual interface
    6.36 +				processVIEWRequest(request, response);
    6.37 +				
    6.38 +	
    6.39 +			} else {// invoked as a service
    6.40 +				processRequest(request, response);
    6.41 +		    }
    6.42 +		}
    6.43  	}
    6.44  
    6.45  	/**
     7.1 --- a/endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/StrabonBeanWrapper.java	Sat Sep 15 03:07:44 2012 +0300
     7.2 +++ b/endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/StrabonBeanWrapper.java	Sat Sep 15 20:30:57 2012 +0300
     7.3 @@ -19,74 +19,16 @@
     7.4  import org.slf4j.Logger;
     7.5  import org.slf4j.LoggerFactory;
     7.6  
     7.7 +import eu.earthobservatory.org.StrabonEndpoint.StrabonBeanWrapperConfiguration;
     7.8  import eu.earthobservatory.runtime.generaldb.Strabon;
     7.9  
    7.10 +
    7.11  public class StrabonBeanWrapper implements org.springframework.beans.factory.DisposableBean {
    7.12  	
    7.13  	private static Logger logger = LoggerFactory.getLogger(eu.earthobservatory.org.StrabonEndpoint.StrabonBeanWrapper.class);
    7.14  	
    7.15 -	private static final String DBBACKEND_POSTGIS = "postgis";
    7.16 -	private static final String DBBACKEND_MONETDB = "monetdb";
    7.17 -	
    7.18  	private static final String FILE_PROTOCOL = "file";
    7.19  	
    7.20 -	public class Entry {
    7.21 -		private String label;
    7.22 -		private String bean;
    7.23 -		private String statement;
    7.24 -		private String format;
    7.25 -		private String title;
    7.26 -
    7.27 -		public Entry(String label, String bean, String statement, String format, String title) {
    7.28 -			this.label = label;
    7.29 -			this.bean = bean;
    7.30 -			this.statement = statement;
    7.31 -			this.format = format;
    7.32 -			this.title=title;
    7.33 -		}
    7.34 -		
    7.35 -		public String getLabel() {
    7.36 -			return label;
    7.37 -		}
    7.38 -		
    7.39 -		public void setLabel(String label) {
    7.40 -			this.label = label;
    7.41 -		}
    7.42 -		
    7.43 -		public String getBean() {
    7.44 -			return bean;
    7.45 -		}
    7.46 -		
    7.47 -		public void setBean(String bean) {
    7.48 -			this.bean = bean;
    7.49 -		}
    7.50 -		
    7.51 -		
    7.52 -		public String getTitle() {
    7.53 -			return title;
    7.54 -		}
    7.55 -
    7.56 -		public void setTitle(String title) {
    7.57 -			this.title = title;
    7.58 -		}
    7.59 -
    7.60 -		public String getStatement() {
    7.61 -			return statement;
    7.62 -		}
    7.63 -		
    7.64 -		public void setStatement(String statement) {
    7.65 -			this.statement = statement;
    7.66 -		}
    7.67 -		
    7.68 -		public String getFormat() {
    7.69 -			return format;
    7.70 -		}
    7.71 -		
    7.72 -		public void setFormat(String format) {
    7.73 -			this.format = format;
    7.74 -		}
    7.75 -	}
    7.76 -
    7.77  	private String serverName;
    7.78  	private int port;
    7.79  	private String databaseName;
    7.80 @@ -97,7 +39,7 @@
    7.81  	private Strabon strabon = null;
    7.82  	
    7.83  	private boolean checkForLockTable;
    7.84 -	private List<Entry> entries;
    7.85 +	private List<StrabonBeanWrapperConfiguration> entries;
    7.86  
    7.87  	public StrabonBeanWrapper(String databaseName, String user, String password, 
    7.88  			int port, String serverName, boolean checkForLockTable, String dbBackend, List<List<String>> args) {
    7.89 @@ -108,7 +50,7 @@
    7.90  		this.password = password;
    7.91  		this.checkForLockTable = checkForLockTable;
    7.92  		this.dbBackend = dbBackend;
    7.93 -		this.entries = new ArrayList<StrabonBeanWrapper.Entry>(args.size());
    7.94 +		this.entries = new ArrayList<StrabonBeanWrapperConfiguration>(args.size());
    7.95  		
    7.96  		Iterator<List<String>> entryit = args.iterator();
    7.97  		
    7.98 @@ -142,7 +84,7 @@
    7.99  					items++;
   7.100  				}
   7.101  				if (items == 5) {
   7.102 -					Entry entry = new Entry(label, bean, statement, format, title);
   7.103 +					StrabonBeanWrapperConfiguration entry = new StrabonBeanWrapperConfiguration(label, bean, statement, format, title);
   7.104  					this.entries.add(entry);
   7.105  				}
   7.106  			
   7.107 @@ -153,7 +95,7 @@
   7.108  		init();
   7.109  	}
   7.110  
   7.111 -	private boolean init() {
   7.112 +	public boolean init() {
   7.113  		if (this.strabon == null) {
   7.114  			try {
   7.115  				logger.warn("[StrabonEndpoint] Strabon not initialized yet.");
   7.116 @@ -161,12 +103,12 @@
   7.117  				logger.info("[StrabonEndpoint] Connection details:\n" + this.getDetails());
   7.118  				
   7.119  				// initialize Strabon according to user preference
   7.120 -				if (DBBACKEND_MONETDB.equalsIgnoreCase(dbBackend)) {
   7.121 +				if (Common.DBBACKEND_MONETDB.equalsIgnoreCase(dbBackend)) {
   7.122  					this.strabon = new eu.earthobservatory.runtime.monetdb.Strabon(databaseName, user, password, port, serverName, checkForLockTable);
   7.123  					
   7.124  				} else {
   7.125  					// check whether the user typed wrong database backend and report
   7.126 -					if (!DBBACKEND_POSTGIS.equalsIgnoreCase(dbBackend)) {
   7.127 +					if (!Common.DBBACKEND_POSTGIS.equalsIgnoreCase(dbBackend)) {
   7.128  						logger.warn("[StrabonEndpoint] Unknown database backend \""+dbBackend+"\". Assuming PostGIS.");
   7.129  					}
   7.130  					
   7.131 @@ -300,6 +242,45 @@
   7.132  		return true;
   7.133  	}
   7.134  
   7.135 +	public void setConnectionDetails(String username, String password, String dbname, String hostname, String port, String dbengine) {
   7.136 +		this.user = username;
   7.137 +		this.password = password;
   7.138 +		this.databaseName = dbname;
   7.139 +		this.dbBackend = dbengine;
   7.140 +		this.password = password;
   7.141 +		try { 
   7.142 +			this.port = Integer.valueOf(port);
   7.143 +		} catch (NumberFormatException e) {
   7.144 +			this.port = 5432;
   7.145 +		}
   7.146 +		this.serverName = hostname;
   7.147 +		this.checkForLockTable = true;		
   7.148 +	}
   7.149 +	
   7.150 +	public String getUsername() {
   7.151 +		return user;
   7.152 +	}
   7.153 +	
   7.154 +	public String getPassword() {
   7.155 +		return password;
   7.156 +	}
   7.157 +	
   7.158 +	public String getDatabaseName() {
   7.159 +		return databaseName;
   7.160 +	}
   7.161 +	
   7.162 +	public String getDBEngine() {
   7.163 +		return dbBackend;
   7.164 +	}
   7.165 +	
   7.166 +	public int getPort() {
   7.167 +		return port;
   7.168 +	}
   7.169 +	
   7.170 +	public String getHostName() {
   7.171 +		return serverName;
   7.172 +	}
   7.173 +	
   7.174  	private String getDetails() {
   7.175  		String details = "-----------------------------------------\n";
   7.176  		details += "host     : " + serverName + "\n";
   7.177 @@ -312,15 +293,15 @@
   7.178  		return details;
   7.179  	}
   7.180  
   7.181 -	public List<Entry> getEntries() {
   7.182 +	public List<StrabonBeanWrapperConfiguration> getEntries() {
   7.183  		return this.entries;
   7.184  	}
   7.185  	
   7.186 -	public void setEntries(List<Entry> entries) {
   7.187 +	public void setEntries(List<StrabonBeanWrapperConfiguration> entries) {
   7.188  		this.entries = entries;
   7.189  	}
   7.190  	
   7.191 -	public Entry getEntry(int i) {
   7.192 +	public StrabonBeanWrapperConfiguration getEntry(int i) {
   7.193  		if (i < 0 || i >= this.entries.size())
   7.194  			return null;
   7.195  		
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/endpoint/src/main/java/eu/earthobservatory/org/StrabonEndpoint/StrabonBeanWrapperConfiguration.java	Sat Sep 15 20:30:57 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 +/**
    8.10 + * 
    8.11 + * @author Charalampos Nikolaou <charnik@di.uoa.gr>
    8.12 + *
    8.13 + */
    8.14 +public class StrabonBeanWrapperConfiguration {
    8.15 +	private String label;
    8.16 +	private String bean;
    8.17 +	private String statement;
    8.18 +	private String format;
    8.19 +	private String title;
    8.20 +
    8.21 +	public StrabonBeanWrapperConfiguration(String label, String bean, String statement, String format, String title) {
    8.22 +		this.label = label;
    8.23 +		this.bean = bean;
    8.24 +		this.statement = statement;
    8.25 +		this.format = format;
    8.26 +		this.title=title;
    8.27 +	}
    8.28 +	
    8.29 +	public String getLabel() {
    8.30 +		return label;
    8.31 +	}
    8.32 +	
    8.33 +	public void setLabel(String label) {
    8.34 +		this.label = label;
    8.35 +	}
    8.36 +	
    8.37 +	public String getBean() {
    8.38 +		return bean;
    8.39 +	}
    8.40 +	
    8.41 +	public void setBean(String bean) {
    8.42 +		this.bean = bean;
    8.43 +	}
    8.44 +	
    8.45 +	
    8.46 +	public String getTitle() {
    8.47 +		return title;
    8.48 +	}
    8.49 +
    8.50 +	public void setTitle(String title) {
    8.51 +		this.title = title;
    8.52 +	}
    8.53 +
    8.54 +	public String getStatement() {
    8.55 +		return statement;
    8.56 +	}
    8.57 +	
    8.58 +	public void setStatement(String statement) {
    8.59 +		this.statement = statement;
    8.60 +	}
    8.61 +	
    8.62 +	public String getFormat() {
    8.63 +		return format;
    8.64 +	}
    8.65 +	
    8.66 +	public void setFormat(String format) {
    8.67 +		this.format = format;
    8.68 +	}
    8.69 +}
    8.70 +