Strabon

view endpoint/WebContent/query.jsp @ 1466:194886c8647e

local commit
author Liza Sakellari <esakellari@di.uoa.gr>
date Thu Jan 15 18:54:03 2015 +0200 (2015-01-15)
parents 355ab4e7cf59
children c99b065768d9
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 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 if(bean.equals("browse.jsp") || bean.equals("ChangeConnection"))
246 continue;
247 String style = "", href = "";
248 hash = new Integer(Math.abs(label.hashCode()*bean.hashCode())).toString();
249 href = "\"" +bean + "#"+ hash+"\"";
250 style = "class=\"navText\"";
251 %>
252 <b>&middot;</b>&nbsp;<a class="linkText" href=<%=href%>><%=label%></a><br/>
253 <%
254 } else {
255 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)+"\"";
256 String title="\""+entry.getTitle()+"\"";
257 String label=entry.getLabel();
258 %>
259 <b>&middot;</b>&nbsp;<a class="linkText" href=<%=href%> title=<%=title%>><%=label%></a><br/>
260 <%
262 }
263 }
264 %>
265 </div>
266 </div>
267 </td>
268 </tr>
269 <!--
270 <tr><td width="90" class="style4"><a href="describe.jsp" class="navText">Describe</a></td></tr>
271 <tr><td width="90" class="style4"><a href="store.jsp" class="navText" title="Store triples">Store</a></td></tr>
272 -->
273 </table>
274 </td>
275 <td width="*" valign="top" >
276 <table cellspacing="5">
277 <%if (request.getAttribute("info") != null) { %>
278 <!-- Info Message -->
279 <TR><TD colspan=2>
280 <CENTER><P><%=request.getAttribute("info") %></P></CENTER>
281 </TD></TR>
282 <!-- Info Message -->
283 <%}%>
284 <tr>
285 <td id="output" colspan=2>
286 <div style="font-size:13px">
287 You must be logged in to perform update queries.
288 </div>
289 </td>
290 </tr>
291 <tr>
292 <td id="output" style="width: 150px">stSPARQL Query:</td>
293 <td id="output"><textarea name="query" title="pose your query/update here" rows="20" cols="100"><%=query%></textarea></td>
294 </tr>
295 <tr>
296 <td id="output">Output Format:</td>
297 <td id="output">
298 <select name="format" title="select one of the following output format types">
299 <%
300 for (String format : Common.registeredQueryResultsFormatNames) {%>
301 <OPTION value="<%=format%>"<%=format.equals(selFormat) ? "selected":""%>><%=format%></OPTION>
302 <%}%>
303 </select>
304 </td>
305 </tr>
306 <tr>
307 <td id="output">View Result:</td>
308 <td id="output">
309 <SELECT name="handle" title="select how you would like to view the result">
310 <OPTION value="plain"<%= ("plain".equals(handle)) ? "selected":""%>>Plain</OPTION>
311 <OPTION value="download"<%= ("download".equals(handle)) ? "selected":""%>>Download</OPTION>
312 <OPTION value="map"<%= ("map".equals(handle)) ? "selected":""%>>On a map</OPTION>
313 <OPTION value="map_local"<%= ("map_local".equals(handle)) ? "selected":""%>>On a map (localhost)</OPTION>
314 </SELECT>
315 </td>
316 </tr>
318 <tr>
319 <td colspan=2 id="output"><br/><center>
320 <input type="submit" title="execute query" value="Query" name="submit" style="width: 350px" />
321 <input type="submit" title="execute update" value="Update" name="submit" style="width: 350px"/></center><br/></td>
322 </tr>
324 <% if (request.getAttribute("error") != null) {%>
325 <!-- Error Message -->
326 <TR>
327 <TD id="output">Result: </TD><TD id="output"><%=request.getAttribute("error") %></TD>
328 </TR>
329 <!-- Error Message -->
330 <%}%>
331 </table></td></tr></table><br/><br/>
332 </form>
333 <a name="#results">&nbsp;</a>
334 <div id="divResultsStart"></div>
335 <!-- Response -->
336 <% if (request.getAttribute("response") != null) {
337 if (Common.getHTMLFormat().equals(request.getParameter("format"))) {%>
338 <%=request.getAttribute("response")%>
339 <%} else { %>
340 <PRE><%=request.getAttribute("response") %></PRE>
341 <%}%>
342 <%}%>
343 <!-- Response -->
344 <% if (request.getAttribute("pathToKML") != null) { %>
345 <div id="map_canvas"></div>
346 <%}%>
347 <div id="divResultsEnd" style="height: 1px; width 1px"></div>
348 </body>
349 </html>