source: trunk/www/common/history/index.jsp @ 5053

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

References #108: Logging the change history of an item

  • Changed default sort order to sort by descending time, eg. most recent change first.
  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 5.7 KB
Line 
1<%-- $Id: index.jsp 5053 2009-08-18 09:52:16Z nicklas $
2  ------------------------------------------------------------------
3  Copyright (C) 2005 Nicklas Nordborg
4  Copyright (C) 2006 Jari Häkkinen, Nicklas Nordborg, Martin Svensson
5
6  This file is part of BASE - BioArray Software Environment.
7  Available at http://base.thep.lu.se/
8
9  BASE is free software; you can redistribute it and/or
10  modify it under the terms of the GNU General Public License
11  as published by the Free Software Foundation; either version 3
12  of the License, or (at your option) any later version.
13
14  BASE is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  GNU General Public License for more details.
18
19  You should have received a copy of the GNU General Public License
20  along with BASE. If not, see <http://www.gnu.org/licenses/>.
21  ------------------------------------------------------------------
22
23  @author Nicklas
24  @version 2.0
25--%>
26<%@ page session="false"
27  import="net.sf.basedb.core.SessionControl"
28  import="net.sf.basedb.core.DbControl"
29  import="net.sf.basedb.core.Item"
30  import="net.sf.basedb.core.Include"
31  import="net.sf.basedb.core.BasicItem"
32  import="net.sf.basedb.core.ChangeHistory"
33  import="net.sf.basedb.core.ItemQuery"
34  import="net.sf.basedb.core.ItemResultIterator"
35  import="net.sf.basedb.core.Permission"
36  import="net.sf.basedb.core.ItemContext"
37  import="net.sf.basedb.core.MultiPermissions"
38  import="net.sf.basedb.core.OwnedItem"
39  import="net.sf.basedb.core.PermissionDeniedException"
40  import="net.sf.basedb.core.ItemAlreadyExistsException"
41  import="net.sf.basedb.core.Sample"
42  import="net.sf.basedb.core.query.Hql"
43  import="net.sf.basedb.core.query.Orders"
44  import="net.sf.basedb.core.query.Restrictions"
45  import="net.sf.basedb.core.query.Expressions"
46  import="net.sf.basedb.util.RemovableUtil"
47  import="net.sf.basedb.util.ShareableUtil"
48  import="net.sf.basedb.util.OwnableUtil"
49  import="net.sf.basedb.util.formatter.NameableFormatter"
50  import="net.sf.basedb.clients.web.Base"
51  import="net.sf.basedb.clients.web.WebException"
52  import="net.sf.basedb.util.Values"
53  import="net.sf.basedb.clients.web.plugins.ItemQueryLoader"
54  import="net.sf.basedb.clients.web.util.HTML" 
55  import="java.util.Enumeration"
56  import="java.util.Set"
57  import="java.util.HashSet"
58  import="java.util.List"
59  import="java.util.ArrayList"
60  import="java.util.Collections"
61%>
62<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
63<%!
64  private static final ItemContext defaultContext = 
65    Base.createDefaultContext("-$hst.time", "time,changeType,user,changeInfo");
66  private static final Item itemType = Item.CHANGEHISTORY;
67%>
68<%
69final int sourceId = Values.getInt(request.getParameter("source_id"));
70final Item sourceType = Item.valueOf(request.getParameter("source_type"));
71
72final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
73final String ID = sc.getId();
74final String cmd = request.getParameter("cmd");
75final String root = request.getContextPath()+"/";
76final String mode = request.getParameter("mode");
77final String callback = request.getParameter("callback");
78final String itemId = request.getParameter("item_id");
79final String listPage = "list_history.jsp?ID="+ID
80  +"&source_id="+sourceId
81  +"&source_type="+sourceType.name()
82  +(mode == null ? "" : "&mode="+mode)
83  +(callback == null ? "" : "&callback="+callback)
84  +(itemId == null ? "" : "&item_id="+itemId);
85final String viewPage = "view_history.jsp?ID="+ID;
86
87String forward = null;
88String redirect = null;
89String message = null;
90DbControl dc = null;
91
92try
93{
94  if (cmd == null || "List".equals(cmd))
95  {
96    // Display the list page without updatinging the current context
97    Base.getAndSetCurrentContext(sc, itemType, null, defaultContext, true);
98    redirect = listPage;
99  }
100  else if ("UpdateContext".equals(cmd))
101  {
102    // Display the list page after updating the current context from the request parameters
103    Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
104    redirect = listPage;
105  }
106  else if ("LoadContext".equals(cmd))
107  {
108    // Display the list page after loading a saved context
109    int contextId = Values.getInt(request.getParameter("context"));
110    Base.loadContext(sc, contextId, defaultContext);
111    redirect = listPage;
112  }
113
114  else if ("ViewItem".equals(cmd))
115  {
116    // Display the view page for a single item
117    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
118    forward = viewPage;
119  }
120  else if ("ExportItems".equals(cmd))
121  {
122    // Run an export plugin in a list context
123    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
124    dc = sc.newDbControl();
125    BasicItem source = sourceType.getById(dc, sourceId);
126    final ItemQuery<ChangeHistory> query = ChangeHistory.getHistoryOf(source);
127    cc.configureQuery(query, true);
128    cc.setQuery(query);
129    redirect = "../../common/export/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=LIST&title=Export+biosources";
130  }
131  else if ("ExportItem".equals(cmd))
132  {
133    // Run an export plugin in single-item context
134    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
135    redirect = "../../common/export/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=ITEM&title=Export+biosource";
136  }
137  else
138  {
139    throw new WebException("popup", "Invalid command", "The command {1} is not recognised as a valid command.", cmd);
140  }
141}
142finally
143{
144  if (dc != null) dc.close();
145}
146
147if (forward != null)
148{
149  pageContext.forward(forward);
150}
151else if (redirect != null)
152{
153  response.sendRedirect(redirect);
154}
155else if (message == null)
156{
157  response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&wait=0");
158}
159else
160{
161  response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&message="+HTML.urlEncode(message));
162}
163%>
164
Note: See TracBrowser for help on using the repository browser.