Strabon

view endpoint/WebContent/query.jsp @ 614:05841a0f3d6b

On my way........ (temporal commit)
author Kostis Kyzirakos <kkyzir@di.uoa.gr>
date Wed Sep 19 16:14:55 2012 +0300 (2012-09-19)
parents 157780b4d79b
children db8b65bcd1d6
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 <link rel="stylesheet" href="style.css" type="text/css" />
16 <script type="text/javascript">
17 function toggleMe(a) {
18 var e = document.getElementById(a);
19 if (!e) {
20 return true;
21 }
22 if (e.style.display == "none") {
23 e.style.display = "block";
24 } else {
25 e.style.display = "none";
26 }
27 return true;
28 }
29 </script>
30 <%
31 if (request.getAttribute("pathToKML") != null) {
32 if ("map_local".equals(request.getAttribute("handle"))) {
33 %>
34 <script type="text/javascript" src="js/geoxml3-kmz.js"></script>
35 <script type="text/javascript" src="js/ProjectedOverlay.js"></script>
36 <%
37 }
38 %>
39 <link href="http://code.google.com/apis/maps/documentation/javascript/examples/default.css" rel="stylesheet" type="text/css" />
40 <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
41 <script type="text/javascript">
42 function initialize() {
43 // center at Brahames
44 var brahames = new google.maps.LatLng(37.92253, 23.72275);
45 var myOptions = {
46 zoom: 11,
47 center: brahames,
48 mapTypeId: google.maps.MapTypeId.ROADMAP
49 };
51 // get KML filename
52 var kml = '<%=request.getAttribute("pathToKML")%>';
53 // <%=request.getAttribute("handle")%>
54 // create map
55 var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
57 // display using geoxml3
58 <%if ("map_local".equals(request.getAttribute("handle"))) {%>
59 var myParser = new geoXML3.parser({map: map});
60 myParser.parse(kml);
62 <%} else {%>
63 var ctaLayer = new google.maps.KmlLayer(kml);
64 ctaLayer.setMap(map);
65 <%}%>
66 <%if ("map_local".equals(request.getAttribute("handle"))) {%>
67 location.hash = "#results";
68 <%}%>
70 }
71 </script>
72 <%
73 }
74 %>
76 <%if ( "map".equals(request.getAttribute("handle")) ||
77 "map_local".equals(request.getAttribute("handle"))) {%>
78 <script type="text/javascript">
79 window.onload=toBottom;
80 function toBottom() {
81 alert("Scrolling to bottom 2...");
82 window.scrollTo(0, document.body.scrollHeight);
83 }
84 </script>
85 <%}%>
87 <title>TELEIOS: Strabon Endpoint</title>
88 </head>
89 <body topmargin="0" leftmargin="0" link="#FFFFFF" vlink="#FFFFFF" alink="#FFFFFF" onload="initialize()">
91 <!-- include TELEIOS header and description -->
92 <%@ include file="teleios-header.html"%>
93 <!-- include TELEIOS header and description -->
95 <FORM enctype="UTF-8" accept-charset="UTF-8" method="post" action="Query">
96 <INPUT type=hidden name="view" value="HTML"/>
98 <table border="0" width="100%">
99 <tr>
100 <td width="90" valign="top" bgcolor="#dfe8f0">
101 <table border="0" cellspacing="0" cellpadding="0" width="165" id="navigation">
102 <tr><td id="twidth">
104 <%
105 StrabonBeanWrapper strabonWrapper;
106 ServletContext context;
107 context = getServletContext();
108 WebApplicationContext applicationContext = WebApplicationContextUtils.getWebApplicationContext(context);
109 strabonWrapper=(StrabonBeanWrapper) applicationContext.getBean("strabonBean");
111 Iterator <StrabonBeanWrapperConfiguration> entryListIterator = strabonWrapper.getEntries().iterator();
113 while(entryListIterator.hasNext())
114 {
115 StrabonBeanWrapperConfiguration entry = entryListIterator.next();
117 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")+"\"";
118 String title="\""+entry.getTitle()+"\"";
119 String label=entry.getLabel();
120 %>
121 <a href=<%=href%> title=<%=title%>><%=label%></a><br/>
122 <%
123 }
124 %>
125 </td>
126 </tr>
127 <tr><td width="90" class="style4"><a href="describe.jsp" class="navText">Describe</a></td></tr>
128 <tr><td width="90" class="style4"><a href="store.jsp" class="navText" title="Store triples">Store</a></td></tr>
129 </table>
130 </td>
131 <td width="*" valign="top" >
132 <table cellspacing="5">
133 <%if (request.getAttribute("info") != null) { %>
134 <!-- Info Message -->
135 <TR><TD colspan=2>
136 <CENTER><P><%=request.getAttribute("info") %></P></CENTER>
137 </TD></TR>
138 <!-- Info Message -->
139 <%}%>
140 <tr>
141 <td id="output">stSPARQL Query:</td>
142 <%
143 String query = "";
144 if (request.getParameter("query") != null) {
145 query = request.getParameter("query");
147 } else if (request.getAttribute("query") != null) {
148 query = (String) request.getAttribute("query");
150 }
151 %>
152 <td id="output"><textarea name="query" title="pose your query/update here" rows="15" cols="100"><%=query%></textarea></td>
153 </tr>
154 <tr>
155 <td id="output"><center>Output Format:<br/>
156 <select name="format" title="select one of the following output format types">
157 <%
158 String selFormat = request.getParameter("format") != null ? request.getParameter("format"):"";
159 for (String format : Common.registeredQueryResultsFormatNames) {%>
160 <OPTION value="<%=format%>"<%=format.equals(selFormat) ? "selected":""%>><%=format%></OPTION>
161 <%}%>
162 </select></center>
163 </td>
164 <td colspan=2><br/><center>
165 <input type="submit" title="execute query" value="Query" name="submit" /><br/>
166 <input type="submit" title="execute update" value="Update" name="submit" style="width: 400px"/></center><br/></td>
167 </tr>
168 <tr>
169 <td id="output"><center>View Result:<br/>
170 <SELECT name="handle" title="select how you would like to view the result">
171 <OPTION value="plain"<%= ("plain".equals(request.getAttribute("handle"))) ? "selected":""%>>Plain</OPTION>
172 <OPTION value="download"<%= ("download".equals(request.getAttribute("handle"))) ? "selected":""%>>Download</OPTION>
173 <OPTION value="map"<%= ("map".equals(request.getAttribute("handle"))) ? "selected":""%>>On a map</OPTION>
174 <OPTION value="map_local"<%= ("map_local".equals(request.getAttribute("handle"))) ? "selected":""%>>On a map (localhost)</OPTION>
175 </SELECT></center>
176 </td>
177 <td colspan=2>&nbsp;</td>
178 </tr>
179 <% if (request.getAttribute("error") != null) {%>
180 <!-- Error Message -->
181 <TR>
182 <TD id="output">Result: </TD><TD id="output"><%=request.getAttribute("error") %></TD>
183 </TR>
184 <!-- Error Message -->
185 <%}%>
186 </table></td></tr></table><br/><br/>
187 </form>
188 <!-- Response -->
189 <a name="#results">&nbsp;</a>
190 <% if (request.getAttribute("response") != null) {
191 if (Common.getHTMLFormat().equals(request.getParameter("format"))) {%>
192 <%=request.getAttribute("response")%>
193 <%} else { %>
194 <PRE><%=request.getAttribute("response") %></PRE>
195 <%}%>
196 <%}%>
197 <!-- Response -->
198 <% if (request.getAttribute("pathToKML") != null) { %>
199 <div id="map_canvas"></div>
200 <%}%>
201 </body>
202 </html>