Strabon

view endpoint/WebContent/query.jsp @ 619:db8b65bcd1d6

Merge with tip
author Kostis Kyzirakos <kkyzir@di.uoa.gr>
date Wed Oct 03 17:53:53 2012 +0300 (2012-10-03)
parents 34e68fb2a595 05841a0f3d6b
children 9e0cad04ccd9
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>&nbsp;<span class="morecontent"><span>' + h + '</span>&nbsp;&nbsp;<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 query parameter or attribute (the attribute comes from ConnectionBean)
68 String query = "";
69 if (request.getParameter("query") != null) {
70 query = request.getParameter("query");
72 } else if (request.getAttribute("query") != null) {
73 query = (String) request.getAttribute("query");
75 }
77 if ("null".equals(query)) {
78 query = "";
79 }
81 // get format parameter or attribute (the attribute comes from ConnectionBean)
82 String selFormat = "HTML";
83 if (request.getParameter("format") != null) {
84 selFormat = request.getParameter("format");
86 } else if (request.getAttribute("format") != null) {
87 selFormat = (String) request.getAttribute("format");
89 }
91 // get handle parameter or attribute (the attribute comes from ConnectionBean)
92 String handle = "";
93 if (request.getParameter("handle") != null) {
94 handle = request.getParameter("handle");
96 } else if (request.getAttribute("handle") != null) {
97 handle = (String) request.getAttribute("handle");
99 }
101 if (request.getAttribute("pathToKML") != null) {
102 if ("map_local".equals(request.getAttribute("handle"))) {
103 %>
104 <script type="text/javascript" src="js/geoxml3-kmz.js"></script>
105 <script type="text/javascript" src="js/ProjectedOverlay.js"></script>
106 <%
107 }
108 %>
109 <link href="http://code.google.com/apis/maps/documentation/javascript/examples/default.css" rel="stylesheet" type="text/css" />
110 <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
111 <script type="text/javascript">
112 function initialize() {
113 // center at Brahames
114 var brahames = new google.maps.LatLng(37.92253, 23.72275);
115 var myOptions = {
116 zoom: 11,
117 center: brahames,
118 mapTypeId: google.maps.MapTypeId.ROADMAP
119 };
121 // get KML filename
122 var kml = '<%=request.getAttribute("pathToKML")%>';
123 // create map
124 var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
126 // display using geoxml3
127 <%if ("map_local".equals(request.getAttribute("handle"))) {%>
128 var myParser = new geoXML3.parser({map: map});
129 myParser.parse(kml);
131 <%} else {%>
132 var ctaLayer = new google.maps.KmlLayer(kml);
133 ctaLayer.setMap(map);
134 <%}%>
136 <%if ("map".equals(request.getAttribute("handle")) || "map_local".equals(request.getAttribute("handle"))) {%>
137 $('html, body').animate({
138 scrollTop: $("#divResultsStart").offset().top
139 }, 1500);
140 <%}%>
141 }
142 </script>
143 <% } else { %>
144 <script type="text/javascript">
145 function initialize() {
146 <%
147 if (query != "" || selFormat != "" || handle != "") {
148 %>
149 $('html, body').animate({
150 scrollTop: $("#divResultsStart").offset().top
151 }, 1000);
152 <%}%>
153 }
154 </script>
155 <%}%>
157 <!-- jQuery start -->
158 <link type="text/css" href="style-menu.css" rel="stylesheet" />
159 <script type="text/javascript" src="js/jquery-1.8.0.min.js"></script>
160 <script type="text/javascript" src="js/jquery-ui-1.8.23.custom.min.js"></script>
161 <script type="text/javascript">
162 $(function(){
163 // Accordion
164 $("#accordion").accordion({
165 header: "h3",
166 fillSpace: true,
167 navigation: true,
168 collapsible: true
169 });
170 //hover states on the static widgets
171 $('#dialog_link, ul#icons li').hover(
172 function() { $(this).addClass('ui-state-hover'); },
173 function() { $(this).removeClass('ui-state-hover'); }
174 );
175 });
176 </script>
177 <style type="text/css">
178 /*demo page css*/
179 body{ font: 90% "Trebuchet MS", sans-serif; margin: 50px;}
180 .container { height:410px; width:165px;}
181 .demoHeaders { margin-top: 1em;}
182 #dialog_link {padding: .4em 1em .4em 20px;text-decoration: none;position: relative;}
183 #dialog_link span.ui-icon {margin: 0 5px 0 0;position: absolute;left: .2em;top: 50%;margin-top: -8px;}
184 ul#icons {margin: 0; padding: 0;}
185 ul#icons li {margin: 1px; position: relative; padding: 1px 0; cursor: pointer; float: left; list-style: none;}
186 ul#icons span.ui-icon {float: left; margin: 0 1px;}
187 </style>
188 <!-- jQuery end -->
190 <title>TELEIOS: Strabon Endpoint</title>
191 </head>
192 <body topmargin="0" leftmargin="0" link="#FFFFFF" vlink="#FFFFFF" alink="#FFFFFF" onload="initialize()">
194 <!-- include TELEIOS header and description -->
195 <%@ include file="teleios-header.html"%>
196 <!-- include TELEIOS header and description -->
198 <FORM enctype="UTF-8" accept-charset="UTF-8" method="post" action="Query">
199 <INPUT type=hidden name="view" value="HTML"/>
201 <table border="0" width="100%">
202 <tr>
203 <td width="90" valign="top">
204 <table border="0" cellspacing="0" cellpadding="0" width="165">
205 <tr><td id="twidth">
206 <div class="container">
207 <div id="accordion">
208 <%
209 StrabonBeanWrapper strabonWrapper;
210 ServletContext context;
211 context = getServletContext();
212 WebApplicationContext applicationContext = WebApplicationContextUtils.getWebApplicationContext(context);
213 strabonWrapper=(StrabonBeanWrapper) applicationContext.getBean("strabonBean");
215 Iterator <StrabonBeanWrapperConfiguration> entryListIterator = strabonWrapper.getEntries().iterator();
216 boolean first = true;
217 String hash = "";
218 while(entryListIterator.hasNext())
219 {
220 StrabonBeanWrapperConfiguration entry = entryListIterator.next();
222 if (entry.isHeader()) {
223 if (!first) {
224 %>
225 </div></div>
226 <%
227 } else {
228 first = false;
229 }
231 String label=entry.getLabel();
232 String style = "", href = "";
233 hash = new Integer(Math.abs(label.hashCode())).toString();
234 href="href=\"#"+hash+"\"";
235 %>
236 <div><h3><a <%=style%> <%=href%>><%=label%></a></h3><div>
237 <%
238 } else if (entry.isBean()) {
239 String label=entry.getLabel();
240 String bean=entry.getBean();
241 String style = "", href = "";
242 hash = new Integer(Math.abs(label.hashCode()*bean.hashCode())).toString();
243 href = "\"" +bean + "#"+ hash+"\"";
244 style = "class=\"navText\"";
245 %>
246 <b>&middot;</b>&nbsp;<a class="linkText" href=<%=href%>><%=label%></a><br/>
247 <%
248 } else {
249 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)+"\"";
250 String title="\""+entry.getTitle()+"\"";
251 String label=entry.getLabel();
252 %>
253 <b>&middot;</b>&nbsp;<a class="linkText" href=<%=href%> title=<%=title%>><%=label%></a><br/>
254 <%
256 }
257 }
258 %>
259 </div>
260 </div>
261 </td>
262 </tr>
263 <!--
264 <tr><td width="90" class="style4"><a href="describe.jsp" class="navText">Describe</a></td></tr>
265 <tr><td width="90" class="style4"><a href="store.jsp" class="navText" title="Store triples">Store</a></td></tr>
266 -->
267 </table>
268 </td>
269 <td width="*" valign="top" >
270 <table cellspacing="5">
271 <%if (request.getAttribute("info") != null) { %>
272 <!-- Info Message -->
273 <TR><TD colspan=2>
274 <CENTER><P><%=request.getAttribute("info") %></P></CENTER>
275 </TD></TR>
276 <!-- Info Message -->
277 <%}%>
278 <tr>
279 <td id="output">stSPARQL Query:</td>
280 <td id="output"><textarea name="query" title="pose your query/update here" rows="15" cols="100"><%=query%></textarea></td>
281 </tr>
282 <tr>
283 <td id="output"><center>Output Format:<br/>
284 <select name="format" title="select one of the following output format types">
285 <%
286 for (String format : Common.registeredQueryResultsFormatNames) {%>
287 <OPTION value="<%=format%>"<%=format.equals(selFormat) ? "selected":""%>><%=format%></OPTION>
288 <%}%>
289 </select></center>
290 </td>
291 <td colspan=2><br/><center>
292 <input type="submit" title="execute query" value="Query" name="submit" /><br/>
293 <input type="submit" title="execute update" value="Update" name="submit" style="width: 400px"/></center><br/></td>
294 </tr>
295 <tr>
296 <td id="output"><center>View Result:<br/>
297 <SELECT name="handle" title="select how you would like to view the result">
298 <OPTION value="plain"<%= ("plain".equals(handle)) ? "selected":""%>>Plain</OPTION>
299 <OPTION value="download"<%= ("download".equals(handle)) ? "selected":""%>>Download</OPTION>
300 <OPTION value="map"<%= ("map".equals(handle)) ? "selected":""%>>On a map</OPTION>
301 <OPTION value="map_local"<%= ("map_local".equals(handle)) ? "selected":""%>>On a map (localhost)</OPTION>
302 </SELECT></center>
303 </td>
304 <td colspan=2>&nbsp;</td>
305 </tr>
306 <% if (request.getAttribute("error") != null) {%>
307 <!-- Error Message -->
308 <TR>
309 <TD id="output">Result: </TD><TD id="output"><%=request.getAttribute("error") %></TD>
310 </TR>
311 <!-- Error Message -->
312 <%}%>
313 </table></td></tr></table><br/><br/>
314 </form>
315 <a name="#results">&nbsp;</a>
316 <div id="divResultsStart"></div>
317 <!-- Response -->
318 <% if (request.getAttribute("response") != null) {
319 if (Common.getHTMLFormat().equals(request.getParameter("format"))) {%>
320 <%=request.getAttribute("response")%>
321 <%} else { %>
322 <PRE><%=request.getAttribute("response") %></PRE>
323 <%}%>
324 <%}%>
325 <!-- Response -->
326 <% if (request.getAttribute("pathToKML") != null) { %>
327 <div id="map_canvas"></div>
328 <%}%>
329 <div id="divResultsEnd" style="height: 1px; width 1px"></div>
330 </body>
331 </html>