Strabon

view endpoint/WebContent/query.jsp @ 628:9e0cad04ccd9

#6: Added a maximum limit for the number of results that are returned. If the query has already a limit which
is greater than the maximum limit it sets it to the maximum limit.
The application of the limit is controlled by the limitQuery parameter, which is passed to the QueryBean as a
hidden variable.
author Stella Giannakopoulou <sgian@di.uoa.gr>
date Mon Oct 08 21:15:46 2012 +0300 (2012-10-08)
parents db8b65bcd1d6
children e6d414360f33
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"/>
200 <INPUT type=hidden name="limitQuery" value="true"/>
202 <table border="0" width="100%">
203 <tr>
204 <td width="90" valign="top">
205 <table border="0" cellspacing="0" cellpadding="0" width="165">
206 <tr><td id="twidth">
207 <div class="container">
208 <div id="accordion">
209 <%
210 StrabonBeanWrapper strabonWrapper;
211 ServletContext context;
212 context = getServletContext();
213 WebApplicationContext applicationContext = WebApplicationContextUtils.getWebApplicationContext(context);
214 strabonWrapper=(StrabonBeanWrapper) applicationContext.getBean("strabonBean");
216 Iterator <StrabonBeanWrapperConfiguration> entryListIterator = strabonWrapper.getEntries().iterator();
217 boolean first = true;
218 String hash = "";
219 while(entryListIterator.hasNext())
220 {
221 StrabonBeanWrapperConfiguration entry = entryListIterator.next();
223 if (entry.isHeader()) {
224 if (!first) {
225 %>
226 </div></div>
227 <%
228 } else {
229 first = false;
230 }
232 String label=entry.getLabel();
233 String style = "", href = "";
234 hash = new Integer(Math.abs(label.hashCode())).toString();
235 href="href=\"#"+hash+"\"";
236 %>
237 <div><h3><a <%=style%> <%=href%>><%=label%></a></h3><div>
238 <%
239 } else if (entry.isBean()) {
240 String label=entry.getLabel();
241 String bean=entry.getBean();
242 String style = "", href = "";
243 hash = new Integer(Math.abs(label.hashCode()*bean.hashCode())).toString();
244 href = "\"" +bean + "#"+ hash+"\"";
245 style = "class=\"navText\"";
246 %>
247 <b>&middot;</b>&nbsp;<a class="linkText" href=<%=href%>><%=label%></a><br/>
248 <%
249 } else {
250 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)+"\"";
251 String title="\""+entry.getTitle()+"\"";
252 String label=entry.getLabel();
253 %>
254 <b>&middot;</b>&nbsp;<a class="linkText" href=<%=href%> title=<%=title%>><%=label%></a><br/>
255 <%
257 }
258 }
259 %>
260 </div>
261 </div>
262 </td>
263 </tr>
264 <!--
265 <tr><td width="90" class="style4"><a href="describe.jsp" class="navText">Describe</a></td></tr>
266 <tr><td width="90" class="style4"><a href="store.jsp" class="navText" title="Store triples">Store</a></td></tr>
267 -->
268 </table>
269 </td>
270 <td width="*" valign="top" >
271 <table cellspacing="5">
272 <%if (request.getAttribute("info") != null) { %>
273 <!-- Info Message -->
274 <TR><TD colspan=2>
275 <CENTER><P><%=request.getAttribute("info") %></P></CENTER>
276 </TD></TR>
277 <!-- Info Message -->
278 <%}%>
279 <tr>
280 <td id="output">stSPARQL Query:</td>
281 <td id="output"><textarea name="query" title="pose your query/update here" rows="15" cols="100"><%=query%></textarea></td>
282 </tr>
283 <tr>
284 <td id="output"><center>Output Format:<br/>
285 <select name="format" title="select one of the following output format types">
286 <%
287 for (String format : Common.registeredQueryResultsFormatNames) {%>
288 <OPTION value="<%=format%>"<%=format.equals(selFormat) ? "selected":""%>><%=format%></OPTION>
289 <%}%>
290 </select></center>
291 </td>
292 <td colspan=2><br/><center>
293 <input type="submit" title="execute query" value="Query" name="submit" /><br/>
294 <input type="submit" title="execute update" value="Update" name="submit" style="width: 400px"/></center><br/></td>
295 </tr>
296 <tr>
297 <td id="output"><center>View Result:<br/>
298 <SELECT name="handle" title="select how you would like to view the result">
299 <OPTION value="plain"<%= ("plain".equals(handle)) ? "selected":""%>>Plain</OPTION>
300 <OPTION value="download"<%= ("download".equals(handle)) ? "selected":""%>>Download</OPTION>
301 <OPTION value="map"<%= ("map".equals(handle)) ? "selected":""%>>On a map</OPTION>
302 <OPTION value="map_local"<%= ("map_local".equals(handle)) ? "selected":""%>>On a map (localhost)</OPTION>
303 </SELECT></center>
304 </td>
305 <td colspan=2>&nbsp;</td>
306 </tr>
307 <% if (request.getAttribute("error") != null) {%>
308 <!-- Error Message -->
309 <TR>
310 <TD id="output">Result: </TD><TD id="output"><%=request.getAttribute("error") %></TD>
311 </TR>
312 <!-- Error Message -->
313 <%}%>
314 </table></td></tr></table><br/><br/>
315 </form>
316 <a name="#results">&nbsp;</a>
317 <div id="divResultsStart"></div>
318 <!-- Response -->
319 <% if (request.getAttribute("response") != null) {
320 if (Common.getHTMLFormat().equals(request.getParameter("format"))) {%>
321 <%=request.getAttribute("response")%>
322 <%} else { %>
323 <PRE><%=request.getAttribute("response") %></PRE>
324 <%}%>
325 <%}%>
326 <!-- Response -->
327 <% if (request.getAttribute("pathToKML") != null) { %>
328 <div id="map_canvas"></div>
329 <%}%>
330 <div id="divResultsEnd" style="height: 1px; width 1px"></div>
331 </body>
332 </html>