5548 |
24 Jan 11 |
nicklas |
1 |
<%-- $Id $ |
5548 |
24 Jan 11 |
nicklas |
2 |
------------------------------------------------------------------ |
5548 |
24 Jan 11 |
nicklas |
Copyright (C) 2011 Nicklas Nordborg |
5548 |
24 Jan 11 |
nicklas |
4 |
|
5548 |
24 Jan 11 |
nicklas |
5 |
This file is part of BASE - BioArray Software Environment. |
5548 |
24 Jan 11 |
nicklas |
6 |
Available at http://base.thep.lu.se/ |
5548 |
24 Jan 11 |
nicklas |
7 |
|
5548 |
24 Jan 11 |
nicklas |
8 |
BASE is free software; you can redistribute it and/or |
5548 |
24 Jan 11 |
nicklas |
9 |
modify it under the terms of the GNU General Public License |
5548 |
24 Jan 11 |
nicklas |
10 |
as published by the Free Software Foundation; either version 3 |
5548 |
24 Jan 11 |
nicklas |
11 |
of the License, or (at your option) any later version. |
5548 |
24 Jan 11 |
nicklas |
12 |
|
5548 |
24 Jan 11 |
nicklas |
13 |
BASE is distributed in the hope that it will be useful, |
5548 |
24 Jan 11 |
nicklas |
14 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
5548 |
24 Jan 11 |
nicklas |
15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
5548 |
24 Jan 11 |
nicklas |
16 |
GNU General Public License for more details. |
5548 |
24 Jan 11 |
nicklas |
17 |
|
5548 |
24 Jan 11 |
nicklas |
18 |
You should have received a copy of the GNU General Public License |
5548 |
24 Jan 11 |
nicklas |
19 |
along with BASE. If not, see <http://www.gnu.org/licenses/>. |
5548 |
24 Jan 11 |
nicklas |
20 |
------------------------------------------------------------------ |
5548 |
24 Jan 11 |
nicklas |
21 |
|
5548 |
24 Jan 11 |
nicklas |
22 |
@author Nicklas |
5548 |
24 Jan 11 |
nicklas |
23 |
--%> |
5557 |
28 Jan 11 |
nicklas |
24 |
<%@ page pageEncoding="UTF-8" session="false" contentType="application/json" |
5548 |
24 Jan 11 |
nicklas |
25 |
import="net.sf.basedb.core.PlateGeometry" |
5548 |
24 Jan 11 |
nicklas |
26 |
import="net.sf.basedb.core.data.MappingCoordinate" |
5548 |
24 Jan 11 |
nicklas |
27 |
import="net.sf.basedb.core.DbControl" |
5548 |
24 Jan 11 |
nicklas |
28 |
import="net.sf.basedb.core.SessionControl" |
5548 |
24 Jan 11 |
nicklas |
29 |
import="net.sf.basedb.util.Values" |
5548 |
24 Jan 11 |
nicklas |
30 |
import="net.sf.basedb.util.error.ThrowableUtil" |
5548 |
24 Jan 11 |
nicklas |
31 |
import="net.sf.basedb.clients.web.Base" |
5548 |
24 Jan 11 |
nicklas |
32 |
import="net.sf.basedb.clients.web.WebException" |
5557 |
28 Jan 11 |
nicklas |
33 |
import="org.json.simple.JSONObject" |
5548 |
24 Jan 11 |
nicklas |
34 |
%> |
5548 |
24 Jan 11 |
nicklas |
35 |
<% |
6124 |
13 Sep 12 |
nicklas |
36 |
response.setHeader("Cache-Control", "no-cache, max-age=0"); |
5548 |
24 Jan 11 |
nicklas |
37 |
final SessionControl sc = Base.getExistingSessionControl(pageContext, true); |
5548 |
24 Jan 11 |
nicklas |
38 |
final String ID = sc.getId(); |
5548 |
24 Jan 11 |
nicklas |
39 |
final String cmd = request.getParameter("cmd"); |
5548 |
24 Jan 11 |
nicklas |
40 |
final String root = request.getContextPath()+"/"; |
5548 |
24 Jan 11 |
nicklas |
41 |
final int itemId = Values.getInt(request.getParameter("item_id")); |
5548 |
24 Jan 11 |
nicklas |
42 |
DbControl dc = null; |
5548 |
24 Jan 11 |
nicklas |
43 |
out.clear(); |
5557 |
28 Jan 11 |
nicklas |
44 |
JSONObject json = new JSONObject(); |
5557 |
28 Jan 11 |
nicklas |
45 |
json.put("status", "ok"); |
5548 |
24 Jan 11 |
nicklas |
46 |
try |
5548 |
24 Jan 11 |
nicklas |
47 |
{ |
5548 |
24 Jan 11 |
nicklas |
48 |
if ("GetGeometryInfo".equals(cmd)) |
5548 |
24 Jan 11 |
nicklas |
49 |
{ |
7954 |
12 May 21 |
nicklas |
50 |
dc = sc.newDbControl(":Get geometry information"); |
5548 |
24 Jan 11 |
nicklas |
51 |
PlateGeometry geometry = PlateGeometry.getById(dc, itemId); |
5557 |
28 Jan 11 |
nicklas |
52 |
json.put("id", geometry.getId()); |
5557 |
28 Jan 11 |
nicklas |
53 |
json.put("name", geometry.getName()); |
5557 |
28 Jan 11 |
nicklas |
54 |
json.put("rows", geometry.getRows()); |
5557 |
28 Jan 11 |
nicklas |
55 |
json.put("columns", geometry.getColumns()); |
5548 |
24 Jan 11 |
nicklas |
56 |
dc.close(); |
5548 |
24 Jan 11 |
nicklas |
57 |
} |
5548 |
24 Jan 11 |
nicklas |
58 |
else |
5548 |
24 Jan 11 |
nicklas |
59 |
{ |
5548 |
24 Jan 11 |
nicklas |
60 |
throw new WebException("popup", "Invalid command", "The command {1} is not recognised as a valid command.", cmd); |
5548 |
24 Jan 11 |
nicklas |
61 |
} |
5548 |
24 Jan 11 |
nicklas |
62 |
} |
5548 |
24 Jan 11 |
nicklas |
63 |
catch (Throwable t) |
5548 |
24 Jan 11 |
nicklas |
64 |
{ |
5548 |
24 Jan 11 |
nicklas |
65 |
t.printStackTrace(); |
5557 |
28 Jan 11 |
nicklas |
66 |
json.clear(); |
5557 |
28 Jan 11 |
nicklas |
67 |
json.put("status", "error"); |
5557 |
28 Jan 11 |
nicklas |
68 |
json.put("message", t.getMessage()); |
5557 |
28 Jan 11 |
nicklas |
69 |
json.put("stacktrace", ThrowableUtil.stackTraceToString(t)); |
5548 |
24 Jan 11 |
nicklas |
70 |
} |
5548 |
24 Jan 11 |
nicklas |
71 |
finally |
5548 |
24 Jan 11 |
nicklas |
72 |
{ |
5557 |
28 Jan 11 |
nicklas |
73 |
json.writeJSONString(out); |
5557 |
28 Jan 11 |
nicklas |
74 |
out.flush(); |
5548 |
24 Jan 11 |
nicklas |
75 |
if (dc != null) dc.close(); |
5548 |
24 Jan 11 |
nicklas |
76 |
} |
5548 |
24 Jan 11 |
nicklas |
77 |
%> |