Strabon

view endpoint/WebContent/query.jsp @ 546:b67d9d491156

Remember drop-down menu selections in endpoint.
Fixes Ticket #11: http://bug.strabon.di.uoa.gr/ticket/11
author Babis Nikolaou <charnik@di.uoa.gr>
date Fri Sep 14 20:55:57 2012 +0300 (2012-09-14)
parents 4ae6d7c860a5
children 4bd5b9a0177b
line source
1 <%@page import="java.net.URLEncoder"%>
2 <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
3 <%@page import="org.springframework.web.context.support.WebApplicationContextUtils"%>
4 <%@page import="org.springframework.web.context.WebApplicationContext"%>
5 <%@page import="eu.earthobservatory.org.StrabonEndpoint.StrabonBeanWrapper"%>
6 <%@page import="eu.earthobservatory.org.StrabonEndpoint.StrabonBeanWrapper.Entry"%>
7 <%@page import="java.util.List"%>
8 <%@page import="java.util.Iterator"%>
9 <jsp:directive.page import="eu.earthobservatory.org.StrabonEndpoint.Common"/>
10 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
11 <html>
12 <head>
13 <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
14 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
15 <link rel="stylesheet" href="style.css" type="text/css" />
16 <script type="text/javascript">
17 function toggleMe(a) {
18 var e = document.getElementById(a);
19 if (!e) {
20 return true;
21 }
22 if (e.style.display == "none") {
23 e.style.display = "block";
24 } else {
25 e.style.display = "none";
26 }
27 return true;
28 }
29 </script>
30 <% if (request.getAttribute("pathToKML") != null) {
31 if ("map_local".equals(request.getAttribute("handle"))) { %>
32 <script type="text/javascript" src="js/geoxml3-kmz.js"></script>
33 <script type="text/javascript" src="js/ProjectedOverlay.js"></script>
34 <%} %>
35 <link href="http://code.google.com/apis/maps/documentation/javascript/examples/default.css" rel="stylesheet" type="text/css" />
36 <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
37 <script type="text/javascript">
38 function initialize() {
39 // center at Brahames
40 var brahames = new google.maps.LatLng(37.92253, 23.72275);
41 var myOptions = {
42 zoom: 11,
43 center: brahames,
44 mapTypeId: google.maps.MapTypeId.ROADMAP
45 };
47 // get KML filename
48 var kml = '<%=request.getAttribute("pathToKML")%>';
49 // <%=request.getAttribute("handle")%>
50 // create map
51 var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
53 // display using geoxml3
54 <%if ("map_local".equals(request.getAttribute("handle"))) { %>
55 var myParser = new geoXML3.parser({map: map});
56 myParser.parse(kml);
58 <%} else {%>
59 var ctaLayer = new google.maps.KmlLayer(kml);
60 ctaLayer.setMap(map);
61 <%}%>
62 }
63 </script>
64 <%}%>
65 <title>TELEIOS: Strabon Endpoint</title>
66 </head>
67 <body topmargin="0" leftmargin="0" link="#FFFFFF" vlink="#FFFFFF" alink="#FFFFFF" onload="initialize()">
69 <!-- include TELEIOS header and description -->
70 <%@ include file="teleios-header.html"%>
71 <!-- include TELEIOS header and description -->
73 <FORM enctype="UTF-8" accept-charset="UTF-8" method="post" action="Query">
74 <INPUT type=hidden name="view" value="HTML"/>
76 <table border="0" width="100%">
77 <tr>
78 <td width="90" valign="top" bgcolor="#dfe8f0">
79 <table border="0" cellspacing="0" cellpadding="0" width="165" id="navigation">
80 <tr><td id="twidth">
82 <%
83 StrabonBeanWrapper strabonWrapper;
84 ServletContext context;
85 context = getServletContext();
86 WebApplicationContext applicationContext = WebApplicationContextUtils.getWebApplicationContext(context);
87 strabonWrapper=(StrabonBeanWrapper) applicationContext.getBean("strabonBean");
89 Iterator <Entry> entryListIterator = strabonWrapper.getEntries().iterator();
91 while(entryListIterator.hasNext())
92 {
93 Entry entry = entryListIterator.next();
94 String handle="";
95 if(entry.getBean().equals("Query"))
96 {
97 handle="&handle=map";
98 }
100 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")+"\"";
101 String title="\""+entry.getTitle()+"\"";
102 String label=entry.getLabel();
103 %>
104 <a href=<%=href%> title=<%=title%>><%=label%></a><br/>
105 <%
106 }
107 %>
108 </td>
109 </tr>
110 <tr><td width="90" class="style4"><a href="describe.jsp" class="navText">Describe</a></td></tr>
111 <tr><td width="90" class="style4"><a href="store.jsp" class="navText" title="Store triples">Store</a></td></tr>
112 </table>
113 </td>
114 <td width="*" valign="top" >
115 <table cellspacing="5">
116 <%if (request.getAttribute("info") != null) { %>
117 <!-- Info Message -->
118 <TR><TD colspan=2>
119 <CENTER><P><%=request.getAttribute("info") %></P></CENTER>
120 </TD></TR>
121 <!-- Info Message -->
122 <%}%>
123 <tr>
124 <td id="output">stSPARQL Query:</td>
125 <td id="output"><textarea name="query" title="pose your query/update here" rows="15" cols="100">
126 <%=request.getParameter("query") != null ? request.getParameter("query"):""%></textarea></td>
127 </tr>
128 <tr>
129 <td id="output"><center>Output Format:<br/>
130 <select name="format" title="select one of the following output format types">
131 <%
132 String selFormat = request.getParameter("format") != null ? request.getParameter("format"):"";
133 for (String format : Common.registeredQueryResultsFormatNames) {%>
134 <OPTION value="<%=format%>"<%=format.equals(selFormat) ? "selected":""%>><%=format%></OPTION>
135 <%}%>
136 </select></center>
137 </td>
138 <td colspan=2><br/><center>
139 <input type="submit" title="execute query" value="Query" name="submit" /><br/>
140 <input type="submit" title="execute update" value="Update" name="submit" style="width: 400px"/></center><br/></td>
141 </tr>
142 <tr>
143 <td id="output"><center>View Result:<br/>
144 <SELECT name="handle" title="select how you would like to view the result">
145 <OPTION value="plain"<%= ("plain".equals(request.getAttribute("handle"))) ? "selected":""%>>Plain</OPTION>
146 <OPTION value="download"<%= ("download".equals(request.getAttribute("handle"))) ? "selected":""%>>Download</OPTION>
147 <OPTION value="map"<%= ("map".equals(request.getAttribute("handle"))) ? "selected":""%>>On a map</OPTION>
148 <OPTION value="map_local"<%= ("map_local".equals(request.getAttribute("handle"))) ? "selected":""%>>On a map (localhost)</OPTION>
149 </SELECT></center>
150 </td>
151 <td colspan=2>&nbsp;</td>
152 </tr>
153 <% if (request.getAttribute("error") != null) {%>
154 <!-- Error Message -->
155 <TR>
156 <TD id="output">Result: </TD><TD id="output"><%=request.getAttribute("error") %></TD>
157 </TR>
158 <!-- Error Message -->
159 <%}%>
160 </table></td></tr></table><br/><br/>
161 </form>
162 <!-- Response -->
163 <% if (request.getAttribute("response") != null) {
164 if (Common.getHTMLFormat().equals(request.getParameter("format"))) {%>
165 <%=request.getAttribute("response")%>
166 <%} else { %>
167 <PRE><%=request.getAttribute("response") %></PRE>
168 <%}%>
169 <%}%>
170 <!-- Response -->
171 <% if (request.getAttribute("pathToKML") != null) { %>
172 <div id="map_canvas"></div>
173 <%}%>
174 </body>
175 </html>