source: trunk/www/common/annotations/index.jsp @ 5060

Last change on this file since 5060 was 5060, checked in by Nicklas Nordborg, 14 years ago

References #108: Logging the change history of an item

  • Documented the change made in [5058]
  • Changed calls to DbControl?.reattachItem() from all core code and jsp scripts
  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 2.9 KB
Line 
1<%-- $Id: index.jsp 5060 2009-08-19 07:02:11Z nicklas $
2  ------------------------------------------------------------------
3  Copyright (C) 2006 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  @author Nicklas
23  @version 2.0
24--%>
25<%@ page session="false"
26  import="net.sf.basedb.core.SessionControl"
27  import="net.sf.basedb.core.DbControl"
28  import="net.sf.basedb.core.Item"
29  import="net.sf.basedb.core.ItemContext"
30  import="net.sf.basedb.core.BasicItem"
31  import="net.sf.basedb.core.Annotatable"
32  import="net.sf.basedb.core.BaseException"
33  import="net.sf.basedb.clients.web.Base"
34  import="net.sf.basedb.clients.web.WebException"
35  import="net.sf.basedb.util.Values"
36  import="net.sf.basedb.clients.web.util.HTML"
37%>
38<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
39<%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %>
40
41<%
42final String root = request.getContextPath()+"/";
43final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
44final String ID = sc.getId();
45final String cmd = request.getParameter("cmd");
46final Item itemType = Item.valueOf(request.getParameter("item_type"));
47final int itemId = Values.getInt(request.getParameter("item_id"));
48
49DbControl newDc = null;
50DbControl oldDc = null;
51String forward = null;
52String message = null;
53String redirect = null;
54try
55{
56  if ("SaveAnnotations".equals(cmd))
57  {
58    newDc = sc.newDbControl();
59    oldDc = sc.newDbControl();
60    ItemContext cc = sc.getCurrentContext(itemType);
61    Annotatable oldItem = (Annotatable)cc.getObject("item");
62    Annotatable newItem = (Annotatable)itemType.getById(newDc, itemId);
63    oldDc.reattachItem((BasicItem)oldItem, false);
64    Base.updateAnnotations(newDc, oldItem, newItem, request);
65    oldDc.close();
66    newDc.commit();
67    cc.removeObject("item");
68    message = "Annotations saved";
69  }
70  else
71  {
72    throw new WebException("popup", "Invalid command", "The command {1} is not recognised as a valid command.", cmd);
73  }
74}
75finally
76{
77  if (oldDc != null) oldDc.close();
78  if (newDc != null) newDc.close();
79}
80
81if (forward != null)
82{
83  pageContext.forward(forward);
84}
85else if (redirect != null)
86{
87  response.sendRedirect(redirect);
88}
89else if (message == null)
90{
91  response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&wait=0");
92}
93else
94{
95  response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&message="+HTML.urlEncode(message));
96}
97%>
98
Note: See TracBrowser for help on using the repository browser.