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

Last change on this file since 4866 was 4866, checked in by Martin Svensson, 13 years ago

Fixes #1282 Change display-format of well coordinates.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 6.4 KB
Line 
1<%-- $Id: index.jsp 4866 2009-03-31 07:36:06Z martin $
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="net.sf.basedb.util.formatter.WellCoordinateFormatter"
45  import="java.util.List"
46%>
47<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
48<%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %>
49<%!
50  private static final ItemContext defaultContext = Base.createDefaultContext("position", "position,block,row,column,reporter.name,reporter.externalId");
51  private static final Item itemType = Item.RAWDATA;
52 
53  private static void registerExportFormatters(ItemContext cc)
54  {
55    cc.setObject("export.formatter.feature.well.row", new WellCoordinateFormatter(true));
56    cc.setObject("export.formatter.feature.well.column", new WellCoordinateFormatter(false));
57  }
58%>
59<%
60final int rawBioAssayId = Values.getInt(request.getParameter("rawbioassay_id"));
61
62final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
63final String ID = sc.getId();
64final String cmd = request.getParameter("cmd");
65final String root = request.getContextPath()+"/";
66final String listPage = "list_rawdata.jsp?ID="+ID+"&rawbioassay_id="+rawBioAssayId;
67final String viewPage = "view_rawdata.jsp?ID="+ID+"&rawbioassay_id="+rawBioAssayId;
68sc.getCurrentContext(Item.RAWBIOASSAY).setId(rawBioAssayId);
69
70String forward = null;
71String redirect = null;
72String message = null;
73DbControl dc = null;
74
75try
76{
77  dc = sc.newDbControl();
78  RawBioAssay rba = RawBioAssay.getById(dc, rawBioAssayId);
79  RawDataType rawDataType = rba.getRawDataType();
80  dc.close();
81
82  if (cmd == null || "List".equals(cmd))
83  {
84    // Display the list page without updatinging the current context
85    Base.getAndSetCurrentContext(sc, itemType, rawDataType.getId(), null, defaultContext);
86    redirect = listPage;
87  }
88  else if ("UpdateContext".equals(cmd))
89  {
90    // Display the list page after updating the current context from the request parameters
91    Base.getAndSetCurrentContext(sc, itemType, rawDataType.getId(), pageContext, defaultContext);
92    redirect = listPage;
93  }
94  else if ("LoadContext".equals(cmd))
95  {
96    // Display the list page after loading a saved context
97    int contextId = Values.getInt(request.getParameter("context"));
98    Base.loadContext(sc, contextId, defaultContext);
99    redirect = listPage;
100  }
101  else if ("ViewItem".equals(cmd))
102  {
103    // Display the view page for a single item
104    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, rawDataType.getId(), pageContext, defaultContext);
105    forward = viewPage;
106  }
107  else if ("ExportItems".equals(cmd))
108  {
109    // Run an export plugin in a list context
110    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, rawDataType.getId(), pageContext, defaultContext);
111    final DataQuery<RawData> query = rba.getRawData();
112    cc.configureQuery(query, true);
113    registerExportFormatters(cc);
114    cc.setQuery(query);
115    redirect = "../../../common/export/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&subcontext="+rawDataType.getId()+"&context_type=LIST&title=Export+raw+data";
116  }
117  else if ("ImportItems".equals(cmd))
118  {
119    // Run an import plugin in a list context
120    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, rawDataType.getId(), pageContext, defaultContext);
121    final DataQuery<RawData> query = rba.getRawData();
122    cc.configureQuery(query, true);
123    cc.setQuery(query);
124    redirect = "../../../common/import/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&subcontext="+rawDataType.getId()+"&context_type=LIST&title=Import+raw+data";
125  }
126  else if ("RunListPlugin".equals(cmd))
127  {
128    // Run another plugin in a list context
129    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, rawDataType.getId(), pageContext, defaultContext);
130    final DataQuery<RawData> query = rba.getRawData();
131    cc.configureQuery(query, true);
132    cc.setQuery(query);
133    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";
134  }
135  else if ("CreateReporterList".equals(cmd))
136  {
137    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, rawDataType.getId(), pageContext, defaultContext);
138    final DataQuery<ReporterData> query = rba.getReporters();
139    cc.configureQuery(query, true);
140    cc.setQuery(query);
141    redirect = "../../../views/reporterlists/index.jsp?ID="+ID+
142      "&cmd=NewItem&addReporters=1&formId=rawdata&fromContext=RAWDATA&subContext="+rawDataType.getId()+
143      "&name=" + HTML.urlEncode(rba.getName());
144  }
145  else
146  {
147    throw new WebException("popup", "Invalid command", "The command {1} is not recognised as a valid command.", cmd);
148  }
149
150}
151finally
152{
153  if (dc != null) dc.close();
154}
155if (forward != null)
156{
157  pageContext.forward(forward);
158}
159else if (redirect != null)
160{
161  response.sendRedirect(redirect);
162}
163else if (message == null)
164{
165  response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&wait=0");
166}
167else
168{
169  response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&message="+HTML.urlEncode(message));
170}
171
172%>
Note: See TracBrowser for help on using the repository browser.