source: trunk/www/common/annotations/ajax.jsp @ 6947

Last change on this file since 6947 was 6947, checked in by Nicklas Nordborg, 6 years ago

References #1941: Store experimental factor values as part experiments

Implemented support for inheriting new annotations via the "Inherit" button. The 'Inherited annotations' tab has been removed from all dialogs.

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