Strabon
view endpoint/WebContent/query.jsp @ 699:00a9bf5d8b50
Now center at brahames is used only when no geometry is selected.
author | Stella Giannakopoulou <sgian@di.uoa.gr> |
---|---|
date | Thu Nov 08 16:09:49 2012 +0200 (2012-11-08) |
parents | b1caa46da857 |
children | 355ab4e7cf59 |
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 <script type="text/javascript" src="js/more_link.js"></script>
16 <link rel="stylesheet" href="style.css" type="text/css" />
17 <script type="text/javascript">
18 function toggleMe(a) {
19 var e = document.getElementById(a);
20 if (!e) {
21 return true;
22 }
23 if (e.style.display == "none") {
24 e.style.display = "block";
25 } else {
26 e.style.display = "none";
27 }
28 return true;
29 }
30 </script>
31 <script>
32 $(document).ready(function() {
33 var showChar = 100;
34 var ellipsestext = "...";
35 var moretext = "more";
36 var lesstext = "less";
37 $('.more').each(function() {
38 var content = $(this).html();
40 if(content.length > showChar) {
42 var c = content.substr(0, showChar);
43 var h = content.substr(showChar-1, content.length - showChar);
45 var html = c + '<span class="moreelipses">'+ellipsestext+'</span> <span class="morecontent"><span>' + h + '</span> <a href="" class="morelink">'+moretext+'</a></span>';
47 $(this).html(html);
48 }
50 });
52 $(".morelink").click(function(){
53 if($(this).hasClass("less")) {
54 $(this).removeClass("less");
55 $(this).html(moretext);
56 } else {
57 $(this).addClass("less");
58 $(this).html(lesstext);
59 }
60 $(this).parent().prev().toggle();
61 $(this).prev().toggle();
62 return false;
63 });
64 });
65 </script>
66 <%
67 // get the reference to StrabonBeanWrapper
68 StrabonBeanWrapper strabonWrapper;
69 ServletContext context;
70 context = getServletContext();
71 WebApplicationContext applicationContext = WebApplicationContextUtils.getWebApplicationContext(context);
72 strabonWrapper=(StrabonBeanWrapper) applicationContext.getBean("strabonBean");
74 // get query parameter or attribute (the attribute comes from ConnectionBean)
75 String query = strabonWrapper.getPrefixes();
76 if (request.getParameter("query") != null) {
77 query = request.getParameter("query");
79 } else if (request.getAttribute("query") != null) {
80 query = (String) request.getAttribute("query");
82 }
84 if ("null".equals(query)) {
85 query = "";
86 }
88 // get format parameter or attribute (the attribute comes from ConnectionBean)
89 String selFormat = "HTML";
90 if (request.getParameter("format") != null) {
91 selFormat = request.getParameter("format");
93 } else if (request.getAttribute("format") != null) {
94 selFormat = (String) request.getAttribute("format");
96 }
98 // get handle parameter or attribute (the attribute comes from ConnectionBean)
99 String handle = "";
100 if (request.getParameter("handle") != null) {
101 handle = request.getParameter("handle");
103 } else if (request.getAttribute("handle") != null) {
104 handle = (String) request.getAttribute("handle");
106 }
108 if (request.getAttribute("pathToKML") != null) {
109 if ("map_local".equals(request.getAttribute("handle"))) {
110 %>
111 <script type="text/javascript" src="js/geoxml3-kmz.js"></script>
112 <script type="text/javascript" src="js/ProjectedOverlay.js"></script>
113 <%
114 }
115 %>
116 <link href="http://code.google.com/apis/maps/documentation/javascript/examples/default.css" rel="stylesheet" type="text/css" />
117 <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
118 <script type="text/javascript">
119 function initialize() {
120 var myOptions = {
121 zoom: 11,
122 mapTypeId: google.maps.MapTypeId.ROADMAP
123 };
125 // get KML filename
126 var kml = '<%=request.getAttribute("pathToKML")%>';
128 // create map
129 var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
130 <% if (request.getAttribute("pathToKML") == null) {%>
131 // center at Brahames
132 map.setCenter(new google.maps.LatLng(37.92253, 23.72275));
133 <%}%>
135 <%if ("map_local".equals(request.getAttribute("handle"))) {%>
136 // display using geoxml3
137 var myParser = new geoXML3.parser({map: map});
138 myParser.parse(kml);
140 <%} else {%>
141 var ctaLayer = new google.maps.KmlLayer(kml);
142 ctaLayer.setMap(map);
143 <%}%>
145 <%if ("map".equals(request.getAttribute("handle")) || "map_local".equals(request.getAttribute("handle"))) {%>
146 $('html, body').animate({
147 scrollTop: $("#divResultsStart").offset().top
148 }, 1500);
149 <%}%>
150 }
151 </script>
152 <% } else { %>
153 <script type="text/javascript">
154 function initialize() {
155 <%
156 if (query != "" || selFormat != "" || handle != "") {
157 %>
158 $('html, body').animate({
159 scrollTop: $("#divResultsStart").offset().top
160 }, 1000);
161 <%}%>
162 }
163 </script>
164 <%}%>
166 <!-- jQuery start -->
167 <link type="text/css" href="style-menu.css" rel="stylesheet" />
168 <script type="text/javascript" src="js/jquery-1.8.0.min.js"></script>
169 <script type="text/javascript" src="js/jquery-ui-1.8.23.custom.min.js"></script>
170 <script type="text/javascript">
171 $(function(){
172 // Accordion
173 $("#accordion").accordion({
174 header: "h3",
175 fillSpace: true,
176 navigation: true,
177 collapsible: true
178 });
179 //hover states on the static widgets
180 $('#dialog_link, ul#icons li').hover(
181 function() { $(this).addClass('ui-state-hover'); },
182 function() { $(this).removeClass('ui-state-hover'); }
183 );
184 });
185 </script>
186 <style type="text/css">
187 /*demo page css*/
188 body{ font: 90% "Trebuchet MS", sans-serif; margin: 50px;}
189 .container { height:410px; width:165px;}
190 .demoHeaders { margin-top: 1em;}
191 #dialog_link {padding: .4em 1em .4em 20px;text-decoration: none;position: relative;}
192 #dialog_link span.ui-icon {margin: 0 5px 0 0;position: absolute;left: .2em;top: 50%;margin-top: -8px;}
193 ul#icons {margin: 0; padding: 0;}
194 ul#icons li {margin: 1px; position: relative; padding: 1px 0; cursor: pointer; float: left; list-style: none;}
195 ul#icons span.ui-icon {float: left; margin: 0 1px;}
196 </style>
197 <!-- jQuery end -->
199 <title>TELEIOS: Strabon Endpoint</title>
200 </head>
201 <body topmargin="0" leftmargin="0" link="#FFFFFF" vlink="#FFFFFF" alink="#FFFFFF" onload="initialize()">
203 <!-- include TELEIOS header and description -->
204 <%@ include file="teleios-header.html"%>
205 <!-- include TELEIOS header and description -->
207 <FORM enctype="UTF-8" accept-charset="UTF-8" method="post" action="Query">
208 <INPUT type=hidden name="view" value="HTML"/>
210 <table border="0" width="100%">
211 <tr>
212 <td width="90" valign="top">
213 <table border="0" cellspacing="0" cellpadding="0" width="165">
214 <tr><td id="twidth">
215 <div class="container">
216 <div id="accordion">
217 <%
219 Iterator <StrabonBeanWrapperConfiguration> entryListIterator = strabonWrapper.getEntries().iterator();
220 boolean first = true;
221 String hash = "";
222 while(entryListIterator.hasNext())
223 {
224 StrabonBeanWrapperConfiguration entry = entryListIterator.next();
226 if (entry.isHeader()) {
227 if (!first) {
228 %>
229 </div></div>
230 <%
231 } else {
232 first = false;
233 }
235 String label=entry.getLabel();
236 String style = "", href = "";
237 hash = new Integer(Math.abs(label.hashCode())).toString();
238 href="href=\"#"+hash+"\"";
239 %>
240 <div><h3><a <%=style%> <%=href%>><%=label%></a></h3><div>
241 <%
242 } else if (entry.isBean()) {
243 String label=entry.getLabel();
244 String bean=entry.getBean();
245 String style = "", href = "";
246 hash = new Integer(Math.abs(label.hashCode()*bean.hashCode())).toString();
247 href = "\"" +bean + "#"+ hash+"\"";
248 style = "class=\"navText\"";
249 %>
250 <b>·</b> <a class="linkText" href=<%=href%>><%=label%></a><br/>
251 <%
252 } else {
253 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")+(hash == "" ? "" : "#" + hash)+"\"";
254 String title="\""+entry.getTitle()+"\"";
255 String label=entry.getLabel();
256 %>
257 <b>·</b> <a class="linkText" href=<%=href%> title=<%=title%>><%=label%></a><br/>
258 <%
260 }
261 }
262 %>
263 </div>
264 </div>
265 </td>
266 </tr>
267 <!--
268 <tr><td width="90" class="style4"><a href="describe.jsp" class="navText">Describe</a></td></tr>
269 <tr><td width="90" class="style4"><a href="store.jsp" class="navText" title="Store triples">Store</a></td></tr>
270 -->
271 </table>
272 </td>
273 <td width="*" valign="top" >
274 <table cellspacing="5">
275 <%if (request.getAttribute("info") != null) { %>
276 <!-- Info Message -->
277 <TR><TD colspan=2>
278 <CENTER><P><%=request.getAttribute("info") %></P></CENTER>
279 </TD></TR>
280 <!-- Info Message -->
281 <%}%>
282 <tr>
283 <td id="output">stSPARQL Query:</td>
284 <td id="output">
285 <div style="font-size:13px">
286 You must be logged in to perform update queries.
287 </div>
288 <textarea name="query" title="pose your query/update here" rows="15" cols="100"><%=query%></textarea></td>
289 </tr>
290 <tr>
291 <td id="output"><center>Output Format:<br/>
292 <select name="format" title="select one of the following output format types">
293 <%
294 for (String format : Common.registeredQueryResultsFormatNames) {%>
295 <OPTION value="<%=format%>"<%=format.equals(selFormat) ? "selected":""%>><%=format%></OPTION>
296 <%}%>
297 </select></center>
298 </td>
299 <td colspan=2><br/><center>
300 <input type="submit" title="execute query" value="Query" name="submit" /><br/>
301 <input type="submit" title="execute update" value="Update" name="submit" style="width: 400px"/></center><br/></td>
302 </tr>
303 <tr>
304 <td id="output"><center>View Result:<br/>
305 <SELECT name="handle" title="select how you would like to view the result">
306 <OPTION value="plain"<%= ("plain".equals(handle)) ? "selected":""%>>Plain</OPTION>
307 <OPTION value="download"<%= ("download".equals(handle)) ? "selected":""%>>Download</OPTION>
308 <OPTION value="map"<%= ("map".equals(handle)) ? "selected":""%>>On a map</OPTION>
309 <OPTION value="map_local"<%= ("map_local".equals(handle)) ? "selected":""%>>On a map (localhost)</OPTION>
310 </SELECT></center>
311 </td>
312 <td colspan=2> </td>
313 </tr>
314 <% if (request.getAttribute("error") != null) {%>
315 <!-- Error Message -->
316 <TR>
317 <TD id="output">Result: </TD><TD id="output"><%=request.getAttribute("error") %></TD>
318 </TR>
319 <!-- Error Message -->
320 <%}%>
321 </table></td></tr></table><br/><br/>
322 </form>
323 <a name="#results"> </a>
324 <div id="divResultsStart"></div>
325 <!-- Response -->
326 <% if (request.getAttribute("response") != null) {
327 if (Common.getHTMLFormat().equals(request.getParameter("format"))) {%>
328 <%=request.getAttribute("response")%>
329 <%} else { %>
330 <PRE><%=request.getAttribute("response") %></PRE>
331 <%}%>
332 <%}%>
333 <!-- Response -->
334 <% if (request.getAttribute("pathToKML") != null) { %>
335 <div id="map_canvas"></div>
336 <%}%>
337 <div id="divResultsEnd" style="height: 1px; width 1px"></div>
338 </body>
339 </html>