source: trunk/www/lims/plates/wells/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: 7.8 KB
Line 
1<%-- $Id: index.jsp 4511 2008-09-11 20:04:27Z jari $
2  ------------------------------------------------------------------
3  Copyright (C) 2006 Jari Hakkinen, 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.Plate"
31  import="net.sf.basedb.core.Well"
32  import="net.sf.basedb.core.ItemQuery"
33  import="net.sf.basedb.core.DataQuery"
34  import="net.sf.basedb.core.Permission"
35  import="net.sf.basedb.core.PermissionDeniedException"
36  import="net.sf.basedb.core.data.ReporterData"
37  import="net.sf.basedb.util.RemovableUtil"
38  import="net.sf.basedb.clients.web.Base"
39  import="net.sf.basedb.clients.web.WebException"
40  import="net.sf.basedb.clients.web.util.HTML"
41  import="net.sf.basedb.util.Values"
42  import="java.util.List"
43  import="java.util.Collections"
44%>
45<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
46<%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %>
47<%!
48  private static final ItemContext defaultContext = Base.createDefaultContext("row", "row,column,reporter.name,reporter.externalId");
49  private static final Item itemType = Item.WELL;
50%>
51<%
52final int plateId = Values.getInt(request.getParameter("plate_id"));
53
54final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
55final String ID = sc.getId();
56final String cmd = request.getParameter("cmd");
57final String root = request.getContextPath()+"/";
58final String mode = request.getParameter("mode");
59final String callback = request.getParameter("callback");
60final String itemId = request.getParameter("item_id");
61final String listPage = "list_wells.jsp?ID="+ID
62  +"&plate_id="+plateId
63  +(mode == null ? "" : "&mode="+mode)
64  +(callback == null ? "" : "&callback="+callback)
65  +(itemId == null ? "" : "&item_id="+itemId);
66final String viewPage = "view_well.jsp?ID="+ID+"&plate_id="+plateId;
67final String editPage = "edit_well.jsp?ID="+ID+"&plate_id="+plateId;
68
69String forward = null;
70String redirect = null;
71String message = null;
72DbControl dc = null;
73
74try
75{
76  if (cmd == null || "List".equals(cmd))
77  {
78    // Display the list page without updatinging the current context
79    Base.getAndSetCurrentContext(sc, itemType, null, defaultContext, true);
80    redirect = listPage;
81  }
82  else if ("UpdateContext".equals(cmd))
83  {
84    // Display the list page after updating the current context from the request parameters
85    Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
86    redirect = listPage;
87  }
88  else if ("LoadContext".equals(cmd))
89  {
90    // Display the list page after loading a saved context
91    int contextId = Values.getInt(request.getParameter("context"));
92    Base.loadContext(sc, contextId, defaultContext);
93    redirect = listPage;
94  }
95  else if ("ViewItem".equals(cmd))
96  {
97    // Display the view page for a single item
98    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
99    forward = viewPage;
100  }
101  else if ("EditItem".equals(cmd))
102  {
103    // Display the edit page for a single item (should be opened in a popup)
104    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
105    redirect = editPage;
106  }
107  else if ("UpdateItem".equals(cmd))
108  {
109    // Update the properties on an item (will close the popup)
110    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, defaultContext);
111    dc = sc.newDbControl();
112    Well well = (Well)cc.getObject("item");
113    dc.reattachItem(well);
114    message = "Well updated";
115   
116    // Annotations tab
117    Base.updateAnnotations(dc, well, well, request);
118   
119    dc.commit();
120    cc.removeObject("item");
121  }
122  else if ("ExportItems".equals(cmd))
123  {
124    // Run an export plugin in a list context
125    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
126    dc = sc.newDbControl();
127    final Plate plate = Plate.getById(dc, plateId);
128    dc.close();
129    final ItemQuery<Well> query = plate.getWells();
130    cc.configureQuery(query, true);
131    cc.setQuery(query);
132    redirect = "../../common/export/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=LIST&title=Export+wells";
133  }
134  else if ("ExportItem".equals(cmd))
135  {
136    // Run an export plugin in single-item context
137    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
138    redirect = "../../common/export/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=ITEM&title=Export+well";
139  }
140  else if ("ImportItems".equals(cmd))
141  {
142    // Run an import plugin in a list context
143    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
144    dc = sc.newDbControl();
145    final Plate plate = Plate.getById(dc, plateId);
146    dc.close();
147    final ItemQuery<Well> query = plate.getWells();
148    cc.configureQuery(query, true);
149    cc.setQuery(query);
150    redirect = "../../common/import/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=LIST&title=Import+wells";
151  }
152  else if ("ImportItem".equals(cmd))
153  {
154    // Run an import plugin in single-item context
155    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
156    redirect = "../../common/import/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=ITEM&title=Import+well";
157  }
158  else if ("RunListPlugin".equals(cmd))
159  {
160    // Run another plugin in a list context
161    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
162    dc = sc.newDbControl();
163    final Plate plate = Plate.getById(dc, plateId);
164    dc.close();
165    final ItemQuery<Well> query = plate.getWells();
166    cc.configureQuery(query, true);
167    cc.setQuery(query);
168    redirect = "../../common/plugin/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=LIST&main_type=OTHER&title=Run+plugin";
169  }
170  else if ("RunPlugin".equals(cmd))
171  {
172    // Run another plugin in single-item context
173    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
174    redirect = "../../common/plugin/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=ITEM&main_type=OTHER&title=Run+plugin";
175  }
176  else if ("CreateReporterList".equals(cmd))
177  {
178    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
179    dc = sc.newDbControl();   
180    final Plate plate = Plate.getById(dc, plateId);
181    final DataQuery<ReporterData> query = plate.getReporters();
182    cc.configureQuery(query, true);
183    cc.setQuery(query);
184    redirect = "../../../views/reporterlists/index.jsp?ID="+ID+
185      "&cmd=NewItem&addReporters=1&formId=wells&fromContext=WELL"+
186      "&name=" + HTML.urlEncode(plate.getName());
187  }
188  else
189  {
190    throw new WebException("popup", "Invalid command", "The command {1} is not recognised as a valid command.", cmd);
191  }
192
193}
194finally
195{
196  if (dc != null) dc.close();
197}
198if (forward != null)
199{
200  pageContext.forward(forward);
201}
202else if (redirect != null)
203{
204  response.sendRedirect(redirect);
205}
206else if (message == null)
207{
208  response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&wait=0");
209}
210else
211{
212  response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&message="+HTML.urlEncode(message));
213}
214
215%>
Note: See TracBrowser for help on using the repository browser.