Strabon

view endpoint/WebContent/query.jsp @ 612:0332207eb9ea

When the endpoint receives a query and the results will be viewed on a map, scroll to the map.
TODO: Duplicate this behaviour when the "plain" view is selected"
author Kostis Kyzirakos <kkyzir@di.uoa.gr>
date Fri Sep 28 22:03:11 2012 +0300 (2012-09-28)
parents 0223607ec93f
children 32af1c2fc1da
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.StrabonBeanWrapperConfiguration"%>
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 <%
31 if (request.getAttribute("pathToKML") != null) {
32 if ("map_local".equals(request.getAttribute("handle"))) {
33 %>
34 <script type="text/javascript" src="js/geoxml3-kmz.js"></script>
35 <script type="text/javascript" src="js/ProjectedOverlay.js"></script>
36 <%
37 }
38 %>
39 <link href="http://code.google.com/apis/maps/documentation/javascript/examples/default.css" rel="stylesheet" type="text/css" />
40 <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
41 <script type="text/javascript">
42 function initialize() {
43 // center at Brahames
44 var brahames = new google.maps.LatLng(37.92253, 23.72275);
45 var myOptions = {
46 zoom: 11,
47 center: brahames,
48 mapTypeId: google.maps.MapTypeId.ROADMAP
49 };
51 // get KML filename
52 var kml = '<%=request.getAttribute("pathToKML")%>';
53 // create map
54 var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
56 // display using geoxml3
57 <%if ("map_local".equals(request.getAttribute("handle"))) {%>
58 var myParser = new geoXML3.parser({map: map});
59 myParser.parse(kml);
61 <%} else {%>
62 var ctaLayer = new google.maps.KmlLayer(kml);
63 ctaLayer.setMap(map);
64 <%}%>
66 <%if ("map".equals(request.getAttribute("handle")) || "map_local".equals(request.getAttribute("handle")) || "plain".equals(request.getAttribute("handle"))) {%>
67 $('html, body').animate({
68 scrollTop: $("#divResultsStart").offset().top
69 }, 1000);
70 <%}%>
71 }
72 </script>
73 <%
74 }
75 %>
76 <!-- jQuery start -->
77 <link type="text/css" href="style-menu.css" rel="stylesheet" />
78 <script type="text/javascript" src="js/jquery-1.8.0.min.js"></script>
79 <script type="text/javascript" src="js/jquery-ui-1.8.23.custom.min.js"></script>
80 <script type="text/javascript">
81 $(function(){
82 // Accordion
83 $("#accordion").accordion({
84 header: "h3",
85 fillSpace: true
86 });
87 //hover states on the static widgets
88 $('#dialog_link, ul#icons li').hover(
89 function() { $(this).addClass('ui-state-hover'); },
90 function() { $(this).removeClass('ui-state-hover'); }
91 );
92 });
93 </script>
94 <style type="text/css">
95 /*demo page css*/
96 body{ font: 90% "Trebuchet MS", sans-serif; margin: 50px;}
97 .container { height:700px; width:165px;}
98 .demoHeaders { margin-top: 1em;}
99 #dialog_link {padding: .4em 1em .4em 20px;text-decoration: none;position: relative;}
100 #dialog_link span.ui-icon {margin: 0 5px 0 0;position: absolute;left: .2em;top: 50%;margin-top: -8px;}
101 ul#icons {margin: 0; padding: 0;}
102 ul#icons li {margin: 1px; position: relative; padding: 1px 0; cursor: pointer; float: left; list-style: none;}
103 ul#icons span.ui-icon {float: left; margin: 0 1px;}
104 </style>
105 <!-- jQuery end -->
107 <title>TELEIOS: Strabon Endpoint</title>
108 </head>
109 <body topmargin="0" leftmargin="0" link="#FFFFFF" vlink="#FFFFFF" alink="#FFFFFF" onload="initialize()">
111 <!-- include TELEIOS header and description -->
112 <%@ include file="teleios-header.html"%>
113 <!-- include TELEIOS header and description -->
115 <FORM enctype="UTF-8" accept-charset="UTF-8" method="post" action="Query">
116 <INPUT type=hidden name="view" value="HTML"/>
118 <table border="0" width="100%">
119 <tr>
120 <td width="90" valign="top" bgcolor="#dfe8f0">
121 <table border="0" cellspacing="0" cellpadding="0" width="165">
122 <tr><td id="twidth">
123 <div class="container">
124 <div id="accordion">
125 <%
126 StrabonBeanWrapper strabonWrapper;
127 ServletContext context;
128 context = getServletContext();
129 WebApplicationContext applicationContext = WebApplicationContextUtils.getWebApplicationContext(context);
130 strabonWrapper=(StrabonBeanWrapper) applicationContext.getBean("strabonBean");
132 Iterator <StrabonBeanWrapperConfiguration> entryListIterator = strabonWrapper.getEntries().iterator();
133 boolean first = true;
134 while(entryListIterator.hasNext())
135 {
136 StrabonBeanWrapperConfiguration entry = entryListIterator.next();
138 if (entry.isHeader()) {
139 if (!first) {
140 %>
141 </div></div>
142 <%
143 } else {
144 first = false;
145 }
147 String label=entry.getLabel();
148 String bean=entry.getBean();
149 String style = "";
150 if (bean == null) {
151 bean = "#";
152 } else {
153 style = "class=\"navText\"";
154 }
155 %>
156 <div><h3><a <%=style%> href="<%=bean%>"><%=label%></a></h3><div>
157 <%
158 } else {
159 String href="\""+URLEncoder.encode(entry.getBean(),"utf-8")+"?view=HTML&handle="+entry.getHandle()+"&query="+URLEncoder.encode(entry.getStatement(),"utf-8")+"&format="+URLEncoder.encode(entry.getFormat(),"utf-8")+"\"";
160 String title="\""+entry.getTitle()+"\"";
161 String label=entry.getLabel();
162 %>
163 <b>&middot;</b>&nbsp;<a class="linkText" href=<%=href%> title=<%=title%>><%=label%></a><br/>
164 <%
166 }
167 }
168 %>
169 </div>
170 </div>
171 </td>
172 </tr>
173 <!--
174 <tr><td width="90" class="style4"><a href="describe.jsp" class="navText">Describe</a></td></tr>
175 <tr><td width="90" class="style4"><a href="store.jsp" class="navText" title="Store triples">Store</a></td></tr>
176 -->
177 </table>
178 </td>
179 <td width="*" valign="top" >
180 <table cellspacing="5">
181 <%if (request.getAttribute("info") != null) { %>
182 <!-- Info Message -->
183 <TR><TD colspan=2>
184 <CENTER><P><%=request.getAttribute("info") %></P></CENTER>
185 </TD></TR>
186 <!-- Info Message -->
187 <%}%>
188 <tr>
189 <td id="output">stSPARQL Query:</td>
190 <%
191 // get query parameter or attribute (the attribute comes from ConnectionBean)
192 String query = "";
193 if (request.getParameter("query") != null) {
194 query = request.getParameter("query");
196 } else if (request.getAttribute("query") != null) {
197 query = (String) request.getAttribute("query");
199 }
201 if ("null".equals(query)) {
202 query = "";
203 }
205 // get format parameter or attribute (the attribute comes from ConnectionBean)
206 String selFormat = "";
207 if (request.getParameter("format") != null) {
208 selFormat = request.getParameter("format");
210 } else if (request.getAttribute("format") != null) {
211 selFormat = (String) request.getAttribute("format");
213 }
215 // get handle parameter or attribute (the attribute comes from ConnectionBean)
216 String handle = "";
217 if (request.getParameter("handle") != null) {
218 handle = request.getParameter("handle");
220 } else if (request.getAttribute("handle") != null) {
221 handle = (String) request.getAttribute("handle");
223 }
224 %>
225 <td id="output"><textarea name="query" title="pose your query/update here" rows="15" cols="100"><%=query%></textarea></td>
226 </tr>
227 <tr>
228 <td id="output"><center>Output Format:<br/>
229 <select name="format" title="select one of the following output format types">
230 <%
231 for (String format : Common.registeredQueryResultsFormatNames) {%>
232 <OPTION value="<%=format%>"<%=format.equals(selFormat) ? "selected":""%>><%=format%></OPTION>
233 <%}%>
234 </select></center>
235 </td>
236 <td colspan=2><br/><center>
237 <input type="submit" title="execute query" value="Query" name="submit" /><br/>
238 <input type="submit" title="execute update" value="Update" name="submit" style="width: 400px"/></center><br/></td>
239 </tr>
240 <tr>
241 <td id="output"><center>View Result:<br/>
242 <SELECT name="handle" title="select how you would like to view the result">
243 <OPTION value="plain"<%= ("plain".equals(handle)) ? "selected":""%>>Plain</OPTION>
244 <OPTION value="download"<%= ("download".equals(handle)) ? "selected":""%>>Download</OPTION>
245 <OPTION value="map"<%= ("map".equals(handle)) ? "selected":""%>>On a map</OPTION>
246 <OPTION value="map_local"<%= ("map_local".equals(handle)) ? "selected":""%>>On a map (localhost)</OPTION>
247 </SELECT></center>
248 </td>
249 <td colspan=2>&nbsp;</td>
250 </tr>
251 <% if (request.getAttribute("error") != null) {%>
252 <!-- Error Message -->
253 <TR>
254 <TD id="output">Result: </TD><TD id="output"><%=request.getAttribute("error") %></TD>
255 </TR>
256 <!-- Error Message -->
257 <%}%>
258 </table></td></tr></table><br/><br/>
259 </form>
260 <a name="#results">&nbsp;</a>
261 <div id="divResultsStart"></div>
262 <!-- Response -->
263 <% if (request.getAttribute("response") != null) {
264 if (Common.getHTMLFormat().equals(request.getParameter("format"))) {%>
265 <%=request.getAttribute("response")%>
266 <%} else { %>
267 <PRE><%=request.getAttribute("response") %></PRE>
268 <%}%>
269 <%}%>
270 <!-- Response -->
271 <% if (request.getAttribute("pathToKML") != null) { %>
272 <div id="map_canvas"></div>
273 <%}%>
274 <div id="divResultsEnd" style="height: 1px; width 1px"></div>
275 </body>
276 </html>