Strabon

view endpoint/WebContent/query.jsp @ 688:9a4bb8e81273

split queryresultio-spatial into submodules (one for API that provides the stSPARQLQueryResultFormat and one for each writer implementation, e.g., XML, HTML, etc.)
Renamed resultio to resultio-spatial.
Renamed endpoint-client artifact to strabon-endpoint-client.
Moved org.openrdf.resultio.Format to eu.earthobservatory.utils.
Renamed and moved org.openrdf.resultio.stSPARQLQueryResultWriter to eu.earthobservatory.utils.stSPARQLQueryResultToFormatAdapter. This is a factory class for stSPARQLQueryResults.

NOTICE: You should import the whole Strabon project into Eclipse to work with this commit
author Babis Nikolaou <charnik@di.uoa.gr>
date Tue Nov 06 19:24:43 2012 +0200 (2012-11-06)
parents 95f6f0d699a4
children 00a9bf5d8b50
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 // center at Brahames
121 var brahames = new google.maps.LatLng(37.92253, 23.72275);
122 var myOptions = {
123 zoom: 11,
124 center: brahames,
125 mapTypeId: google.maps.MapTypeId.ROADMAP
126 };
128 // get KML filename
129 var kml = '<%=request.getAttribute("pathToKML")%>';
130 // create map
131 var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
133 // display using geoxml3
134 <%if ("map_local".equals(request.getAttribute("handle"))) {%>
135 var myParser = new geoXML3.parser({map: map});
136 myParser.parse(kml);
138 <%} else {%>
139 var ctaLayer = new google.maps.KmlLayer(kml);
140 ctaLayer.setMap(map);
141 <%}%>
143 <%if ("map".equals(request.getAttribute("handle")) || "map_local".equals(request.getAttribute("handle"))) {%>
144 $('html, body').animate({
145 scrollTop: $("#divResultsStart").offset().top
146 }, 1500);
147 <%}%>
148 }
149 </script>
150 <% } else { %>
151 <script type="text/javascript">
152 function initialize() {
153 <%
154 if (query != "" || selFormat != "" || handle != "") {
155 %>
156 $('html, body').animate({
157 scrollTop: $("#divResultsStart").offset().top
158 }, 1000);
159 <%}%>
160 }
161 </script>
162 <%}%>
164 <!-- jQuery start -->
165 <link type="text/css" href="style-menu.css" rel="stylesheet" />
166 <script type="text/javascript" src="js/jquery-1.8.0.min.js"></script>
167 <script type="text/javascript" src="js/jquery-ui-1.8.23.custom.min.js"></script>
168 <script type="text/javascript">
169 $(function(){
170 // Accordion
171 $("#accordion").accordion({
172 header: "h3",
173 fillSpace: true,
174 navigation: true,
175 collapsible: true
176 });
177 //hover states on the static widgets
178 $('#dialog_link, ul#icons li').hover(
179 function() { $(this).addClass('ui-state-hover'); },
180 function() { $(this).removeClass('ui-state-hover'); }
181 );
182 });
183 </script>
184 <style type="text/css">
185 /*demo page css*/
186 body{ font: 90% "Trebuchet MS", sans-serif; margin: 50px;}
187 .container { height:410px; width:165px;}
188 .demoHeaders { margin-top: 1em;}
189 #dialog_link {padding: .4em 1em .4em 20px;text-decoration: none;position: relative;}
190 #dialog_link span.ui-icon {margin: 0 5px 0 0;position: absolute;left: .2em;top: 50%;margin-top: -8px;}
191 ul#icons {margin: 0; padding: 0;}
192 ul#icons li {margin: 1px; position: relative; padding: 1px 0; cursor: pointer; float: left; list-style: none;}
193 ul#icons span.ui-icon {float: left; margin: 0 1px;}
194 </style>
195 <!-- jQuery end -->
197 <title>TELEIOS: Strabon Endpoint</title>
198 </head>
199 <body topmargin="0" leftmargin="0" link="#FFFFFF" vlink="#FFFFFF" alink="#FFFFFF" onload="initialize()">
201 <!-- include TELEIOS header and description -->
202 <%@ include file="teleios-header.html"%>
203 <!-- include TELEIOS header and description -->
205 <FORM enctype="UTF-8" accept-charset="UTF-8" method="post" action="Query">
206 <INPUT type=hidden name="view" value="HTML"/>
208 <table border="0" width="100%">
209 <tr>
210 <td width="90" valign="top">
211 <table border="0" cellspacing="0" cellpadding="0" width="165">
212 <tr><td id="twidth">
213 <div class="container">
214 <div id="accordion">
215 <%
217 Iterator <StrabonBeanWrapperConfiguration> entryListIterator = strabonWrapper.getEntries().iterator();
218 boolean first = true;
219 String hash = "";
220 while(entryListIterator.hasNext())
221 {
222 StrabonBeanWrapperConfiguration entry = entryListIterator.next();
224 if (entry.isHeader()) {
225 if (!first) {
226 %>
227 </div></div>
228 <%
229 } else {
230 first = false;
231 }
233 String label=entry.getLabel();
234 String style = "", href = "";
235 hash = new Integer(Math.abs(label.hashCode())).toString();
236 href="href=\"#"+hash+"\"";
237 %>
238 <div><h3><a <%=style%> <%=href%>><%=label%></a></h3><div>
239 <%
240 } else if (entry.isBean()) {
241 String label=entry.getLabel();
242 String bean=entry.getBean();
243 String style = "", href = "";
244 hash = new Integer(Math.abs(label.hashCode()*bean.hashCode())).toString();
245 href = "\"" +bean + "#"+ hash+"\"";
246 style = "class=\"navText\"";
247 %>
248 <b>&middot;</b>&nbsp;<a class="linkText" href=<%=href%>><%=label%></a><br/>
249 <%
250 } else {
251 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)+"\"";
252 String title="\""+entry.getTitle()+"\"";
253 String label=entry.getLabel();
254 %>
255 <b>&middot;</b>&nbsp;<a class="linkText" href=<%=href%> title=<%=title%>><%=label%></a><br/>
256 <%
258 }
259 }
260 %>
261 </div>
262 </div>
263 </td>
264 </tr>
265 <!--
266 <tr><td width="90" class="style4"><a href="describe.jsp" class="navText">Describe</a></td></tr>
267 <tr><td width="90" class="style4"><a href="store.jsp" class="navText" title="Store triples">Store</a></td></tr>
268 -->
269 </table>
270 </td>
271 <td width="*" valign="top" >
272 <table cellspacing="5">
273 <%if (request.getAttribute("info") != null) { %>
274 <!-- Info Message -->
275 <TR><TD colspan=2>
276 <CENTER><P><%=request.getAttribute("info") %></P></CENTER>
277 </TD></TR>
278 <!-- Info Message -->
279 <%}%>
280 <tr>
281 <td id="output">stSPARQL Query:</td>
282 <td id="output">
283 <div style="font-size:13px">
284 You must be logged in to perform update queries.
285 </div>
286 <textarea name="query" title="pose your query/update here" rows="15" cols="100"><%=query%></textarea></td>
287 </tr>
288 <tr>
289 <td id="output"><center>Output Format:<br/>
290 <select name="format" title="select one of the following output format types">
291 <%
292 for (String format : Common.registeredQueryResultsFormatNames) {%>
293 <OPTION value="<%=format%>"<%=format.equals(selFormat) ? "selected":""%>><%=format%></OPTION>
294 <%}%>
295 </select></center>
296 </td>
297 <td colspan=2><br/><center>
298 <input type="submit" title="execute query" value="Query" name="submit" /><br/>
299 <input type="submit" title="execute update" value="Update" name="submit" style="width: 400px"/></center><br/></td>
300 </tr>
301 <tr>
302 <td id="output"><center>View Result:<br/>
303 <SELECT name="handle" title="select how you would like to view the result">
304 <OPTION value="plain"<%= ("plain".equals(handle)) ? "selected":""%>>Plain</OPTION>
305 <OPTION value="download"<%= ("download".equals(handle)) ? "selected":""%>>Download</OPTION>
306 <OPTION value="map"<%= ("map".equals(handle)) ? "selected":""%>>On a map</OPTION>
307 <OPTION value="map_local"<%= ("map_local".equals(handle)) ? "selected":""%>>On a map (localhost)</OPTION>
308 </SELECT></center>
309 </td>
310 <td colspan=2>&nbsp;</td>
311 </tr>
312 <% if (request.getAttribute("error") != null) {%>
313 <!-- Error Message -->
314 <TR>
315 <TD id="output">Result: </TD><TD id="output"><%=request.getAttribute("error") %></TD>
316 </TR>
317 <!-- Error Message -->
318 <%}%>
319 </table></td></tr></table><br/><br/>
320 </form>
321 <a name="#results">&nbsp;</a>
322 <div id="divResultsStart"></div>
323 <!-- Response -->
324 <% if (request.getAttribute("response") != null) {
325 if (Common.getHTMLFormat().equals(request.getParameter("format"))) {%>
326 <%=request.getAttribute("response")%>
327 <%} else { %>
328 <PRE><%=request.getAttribute("response") %></PRE>
329 <%}%>
330 <%}%>
331 <!-- Response -->
332 <% if (request.getAttribute("pathToKML") != null) { %>
333 <div id="map_canvas"></div>
334 <%}%>
335 <div id="divResultsEnd" style="height: 1px; width 1px"></div>
336 </body>
337 </html>