source: trunk/www/views/rawbioassays/rawdata/index.jsp @ 4511

Last change on this file since 4511 was 4511, checked in by Jari Häkkinen, 14 years ago

Addresses #1106. Missed to change reference wherefrom retrive GPLv3 license text. And some other changes.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 6.1 KB
Line 
1<%-- $Id: index.jsp 4511 2008-09-11 20:04:27Z jari $
2  ------------------------------------------------------------------
3  Copyright (C) 2005 Nicklas Nordborg
4  Copyright (C) 2006 Jari Hakkinen, Nicklas Nordborg
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.ItemContext"
31  import="net.sf.basedb.core.data.RawData"
32  import="net.sf.basedb.core.data.ReporterData"
33  import="net.sf.basedb.core.RawBioAssay"
34  import="net.sf.basedb.core.RawDataType"
35  import="net.sf.basedb.core.ItemQuery"
36  import="net.sf.basedb.core.DataQuery"
37  import="net.sf.basedb.core.DataResultIterator"
38  import="net.sf.basedb.core.Permission"
39  import="net.sf.basedb.core.PermissionDeniedException"
40  import="net.sf.basedb.clients.web.Base"
41  import="net.sf.basedb.clients.web.WebException"
42  import="net.sf.basedb.clients.web.util.HTML"
43  import="net.sf.basedb.util.Values"
44  import="java.util.List"
45%>
46<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
47<%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %>
48<%!
49  private static final ItemContext defaultContext = Base.createDefaultContext("position", "position,block,row,column,reporter.name,reporter.externalId");
50  private static final Item itemType = Item.RAWDATA;
51%>
52<%
53final int rawBioAssayId = Values.getInt(request.getParameter("rawbioassay_id"));
54
55final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
56final String ID = sc.getId();
57final String cmd = request.getParameter("cmd");
58final String root = request.getContextPath()+"/";
59final String listPage = "list_rawdata.jsp?ID="+ID+"&rawbioassay_id="+rawBioAssayId;
60final String viewPage = "view_rawdata.jsp?ID="+ID+"&rawbioassay_id="+rawBioAssayId;
61sc.getCurrentContext(Item.RAWBIOASSAY).setId(rawBioAssayId);
62
63String forward = null;
64String redirect = null;
65String message = null;
66DbControl dc = null;
67
68try
69{
70  dc = sc.newDbControl();
71  RawBioAssay rba = RawBioAssay.getById(dc, rawBioAssayId);
72  RawDataType rawDataType = rba.getRawDataType();
73  dc.close();
74
75  if (cmd == null || "List".equals(cmd))
76  {
77    // Display the list page without updatinging the current context
78    Base.getAndSetCurrentContext(sc, itemType, rawDataType.getId(), null, defaultContext);
79    redirect = listPage;
80  }
81  else if ("UpdateContext".equals(cmd))
82  {
83    // Display the list page after updating the current context from the request parameters
84    Base.getAndSetCurrentContext(sc, itemType, rawDataType.getId(), pageContext, defaultContext);
85    redirect = listPage;
86  }
87  else if ("LoadContext".equals(cmd))
88  {
89    // Display the list page after loading a saved context
90    int contextId = Values.getInt(request.getParameter("context"));
91    Base.loadContext(sc, contextId, defaultContext);
92    redirect = listPage;
93  }
94  else if ("ViewItem".equals(cmd))
95  {
96    // Display the view page for a single item
97    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, rawDataType.getId(), pageContext, defaultContext);
98    forward = viewPage;
99  }
100  else if ("ExportItems".equals(cmd))
101  {
102    // Run an export plugin in a list context
103    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, rawDataType.getId(), pageContext, defaultContext);
104    final DataQuery<RawData> query = rba.getRawData();
105    cc.configureQuery(query, true);
106    cc.setQuery(query);
107    redirect = "../../../common/export/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&subcontext="+rawDataType.getId()+"&context_type=LIST&title=Export+raw+data";
108  }
109  else if ("ImportItems".equals(cmd))
110  {
111    // Run an import plugin in a list context
112    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, rawDataType.getId(), pageContext, defaultContext);
113    final DataQuery<RawData> query = rba.getRawData();
114    cc.configureQuery(query, true);
115    cc.setQuery(query);
116    redirect = "../../../common/import/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&subcontext="+rawDataType.getId()+"&context_type=LIST&title=Import+raw+data";
117  }
118  else if ("RunListPlugin".equals(cmd))
119  {
120    // Run another plugin in a list context
121    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, rawDataType.getId(), pageContext, defaultContext);
122    final DataQuery<RawData> query = rba.getRawData();
123    cc.configureQuery(query, true);
124    cc.setQuery(query);
125    redirect = "../../../common/plugin/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&subcontext="+rawDataType.getId()+"&context_type=LIST&main_type=OTHER&title=Run+plugin";
126  }
127  else if ("CreateReporterList".equals(cmd))
128  {
129    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, rawDataType.getId(), pageContext, defaultContext);
130    final DataQuery<ReporterData> query = rba.getReporters();
131    cc.configureQuery(query, true);
132    cc.setQuery(query);
133    redirect = "../../../views/reporterlists/index.jsp?ID="+ID+
134      "&cmd=NewItem&addReporters=1&formId=rawdata&fromContext=RAWDATA&subContext="+rawDataType.getId()+
135      "&name=" + HTML.urlEncode(rba.getName());
136  }
137  else
138  {
139    throw new WebException("popup", "Invalid command", "The command {1} is not recognised as a valid command.", cmd);
140  }
141
142}
143finally
144{
145  if (dc != null) dc.close();
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.