4704 |
11 Dec 08 |
martin |
1 |
<%-- $Id$ |
4704 |
11 Dec 08 |
martin |
2 |
------------------------------------------------------------------ |
4704 |
11 Dec 08 |
martin |
Copyright (C) 2005 Nicklas Nordborg |
5425 |
23 Sep 10 |
nicklas |
Copyright (C) 2006 Jari Häkkinen, Nicklas Nordborg, Martin Svensson |
4704 |
11 Dec 08 |
martin |
5 |
|
4704 |
11 Dec 08 |
martin |
6 |
This file is part of BASE - BioArray Software Environment. |
4704 |
11 Dec 08 |
martin |
7 |
Available at http://base.thep.lu.se/ |
4704 |
11 Dec 08 |
martin |
8 |
|
4704 |
11 Dec 08 |
martin |
9 |
BASE is free software; you can redistribute it and/or |
4704 |
11 Dec 08 |
martin |
10 |
modify it under the terms of the GNU General Public License |
4704 |
11 Dec 08 |
martin |
11 |
as published by the Free Software Foundation; either version 3 |
4704 |
11 Dec 08 |
martin |
12 |
of the License, or (at your option) any later version. |
4704 |
11 Dec 08 |
martin |
13 |
|
4704 |
11 Dec 08 |
martin |
14 |
BASE is distributed in the hope that it will be useful, |
4704 |
11 Dec 08 |
martin |
15 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
4704 |
11 Dec 08 |
martin |
16 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4704 |
11 Dec 08 |
martin |
17 |
GNU General Public License for more details. |
4704 |
11 Dec 08 |
martin |
18 |
|
4704 |
11 Dec 08 |
martin |
19 |
You should have received a copy of the GNU General Public License |
4704 |
11 Dec 08 |
martin |
20 |
along with BASE. If not, see <http://www.gnu.org/licenses/>. |
4704 |
11 Dec 08 |
martin |
21 |
------------------------------------------------------------------ |
4704 |
11 Dec 08 |
martin |
22 |
|
4704 |
11 Dec 08 |
martin |
23 |
@author Martin |
4704 |
11 Dec 08 |
martin |
24 |
@version 2.10 |
4704 |
11 Dec 08 |
martin |
25 |
--%> |
5426 |
24 Sep 10 |
nicklas |
26 |
<%@ page pageEncoding="UTF-8" session="false" |
4704 |
11 Dec 08 |
martin |
27 |
import="net.sf.basedb.core.SessionControl" |
4704 |
11 Dec 08 |
martin |
28 |
import="net.sf.basedb.core.BioPlate" |
5262 |
08 Mar 10 |
nicklas |
29 |
import="net.sf.basedb.core.BioPlateType" |
4704 |
11 Dec 08 |
martin |
30 |
import="net.sf.basedb.core.DbControl" |
4732 |
21 Jan 09 |
martin |
31 |
import="net.sf.basedb.core.Hardware" |
4704 |
11 Dec 08 |
martin |
32 |
import="net.sf.basedb.core.Item" |
4704 |
11 Dec 08 |
martin |
33 |
import="net.sf.basedb.core.ItemQuery" |
4704 |
11 Dec 08 |
martin |
34 |
import="net.sf.basedb.core.Permission" |
4704 |
11 Dec 08 |
martin |
35 |
import="net.sf.basedb.core.PlateGeometry" |
4704 |
11 Dec 08 |
martin |
36 |
import="net.sf.basedb.core.ItemContext" |
4704 |
11 Dec 08 |
martin |
37 |
import="net.sf.basedb.core.MultiPermissions" |
4704 |
11 Dec 08 |
martin |
38 |
import="net.sf.basedb.core.OwnedItem" |
4704 |
11 Dec 08 |
martin |
39 |
import="net.sf.basedb.core.PermissionDeniedException" |
4704 |
11 Dec 08 |
martin |
40 |
import="net.sf.basedb.core.ItemAlreadyExistsException" |
4704 |
11 Dec 08 |
martin |
41 |
import="net.sf.basedb.util.RemovableUtil" |
4704 |
11 Dec 08 |
martin |
42 |
import="net.sf.basedb.util.ShareableUtil" |
4704 |
11 Dec 08 |
martin |
43 |
import="net.sf.basedb.util.OwnableUtil" |
4704 |
11 Dec 08 |
martin |
44 |
import="net.sf.basedb.clients.web.Base" |
4704 |
11 Dec 08 |
martin |
45 |
import="net.sf.basedb.clients.web.WebException" |
4704 |
11 Dec 08 |
martin |
46 |
import="net.sf.basedb.util.Values" |
4704 |
11 Dec 08 |
martin |
47 |
import="net.sf.basedb.clients.web.util.HTML" |
5492 |
16 Nov 10 |
nicklas |
48 |
import="net.sf.basedb.core.plugin.GuiContext" |
5996 |
05 Mar 12 |
nicklas |
49 |
import="net.sf.basedb.util.formatter.Formatter" |
5492 |
16 Nov 10 |
nicklas |
50 |
import="net.sf.basedb.util.extensions.ExtensionsInvoker" |
5996 |
05 Mar 12 |
nicklas |
51 |
import="net.sf.basedb.clients.web.formatter.FormatterFactory" |
5492 |
16 Nov 10 |
nicklas |
52 |
import="net.sf.basedb.clients.web.extensions.ExtensionsControl" |
5492 |
16 Nov 10 |
nicklas |
53 |
import="net.sf.basedb.clients.web.extensions.JspContext" |
5492 |
16 Nov 10 |
nicklas |
54 |
import="net.sf.basedb.clients.web.extensions.edit.EditUtil" |
7604 |
25 Feb 19 |
nicklas |
55 |
import="net.sf.basedb.clients.web.extensions.edit.OnSaveAction" |
5492 |
16 Nov 10 |
nicklas |
56 |
import="net.sf.basedb.clients.web.extensions.edit.OnSaveRenderer" |
6038 |
29 Mar 12 |
nicklas |
57 |
import="net.sf.basedb.clients.web.extensions.list.ListColumnExportRenderer" |
7604 |
25 Feb 19 |
nicklas |
58 |
import="net.sf.basedb.clients.web.extensions.list.ListColumnAction" |
6038 |
29 Mar 12 |
nicklas |
59 |
import="net.sf.basedb.clients.web.extensions.list.ListColumnUtil" |
4704 |
11 Dec 08 |
martin |
60 |
import="java.util.Collections" |
4704 |
11 Dec 08 |
martin |
61 |
import="java.util.HashSet" |
4704 |
11 Dec 08 |
martin |
62 |
import="java.util.Set" |
5996 |
05 Mar 12 |
nicklas |
63 |
import="java.util.Date" |
4704 |
11 Dec 08 |
martin |
64 |
%> |
4704 |
11 Dec 08 |
martin |
65 |
<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> |
4704 |
11 Dec 08 |
martin |
66 |
<%! |
5355 |
04 Jun 10 |
nicklas |
67 |
private static final ItemContext defaultContext = Base.createDefaultContext("name", "name,barcode,bioPlateType,description"); |
4704 |
11 Dec 08 |
martin |
68 |
private static final Item itemType = Item.BIOPLATE; |
4704 |
11 Dec 08 |
martin |
69 |
%> |
4704 |
11 Dec 08 |
martin |
70 |
<% |
4704 |
11 Dec 08 |
martin |
71 |
final SessionControl sc = Base.getExistingSessionControl(pageContext, true); |
4704 |
11 Dec 08 |
martin |
72 |
final String ID = sc.getId(); |
4704 |
11 Dec 08 |
martin |
73 |
final String cmd = request.getParameter("cmd"); |
4704 |
11 Dec 08 |
martin |
74 |
final String root = request.getContextPath()+"/"; |
4704 |
11 Dec 08 |
martin |
75 |
final String mode = request.getParameter("mode"); |
4704 |
11 Dec 08 |
martin |
76 |
final String callback = request.getParameter("callback"); |
4704 |
11 Dec 08 |
martin |
77 |
final String itemId = request.getParameter("item_id"); |
4704 |
11 Dec 08 |
martin |
78 |
final String listPage = "list_bioplates.jsp?ID="+ID |
4704 |
11 Dec 08 |
martin |
79 |
+(mode == null ? "" : "&mode="+mode) |
4704 |
11 Dec 08 |
martin |
80 |
+(callback == null ? "" : "&callback="+callback) |
4704 |
11 Dec 08 |
martin |
81 |
+(itemId == null ? "" : "&item_id="+itemId); |
4704 |
11 Dec 08 |
martin |
82 |
final String viewPage = "view_bioplate.jsp?ID="+ID; |
4704 |
11 Dec 08 |
martin |
83 |
final String editPage = "edit_bioplate.jsp?ID="+ID; |
4704 |
11 Dec 08 |
martin |
84 |
|
4704 |
11 Dec 08 |
martin |
85 |
String forward = null; |
4704 |
11 Dec 08 |
martin |
86 |
String redirect = null; |
4704 |
11 Dec 08 |
martin |
87 |
String message = null; |
4704 |
11 Dec 08 |
martin |
88 |
DbControl dc = null; |
4704 |
11 Dec 08 |
martin |
89 |
|
4704 |
11 Dec 08 |
martin |
90 |
try |
4704 |
11 Dec 08 |
martin |
91 |
{ |
4704 |
11 Dec 08 |
martin |
92 |
if (cmd == null || "List".equals(cmd)) |
4704 |
11 Dec 08 |
martin |
93 |
{ |
4704 |
11 Dec 08 |
martin |
94 |
// Display the list page without updatinging the current context |
4704 |
11 Dec 08 |
martin |
95 |
Base.getAndSetCurrentContext(sc, itemType, null, defaultContext, true); |
4704 |
11 Dec 08 |
martin |
96 |
redirect = listPage; |
4704 |
11 Dec 08 |
martin |
97 |
} |
4704 |
11 Dec 08 |
martin |
98 |
else if ("UpdateContext".equals(cmd)) |
4704 |
11 Dec 08 |
martin |
99 |
{ |
4704 |
11 Dec 08 |
martin |
100 |
// Display the list page after updating the current context from the request parameters |
4704 |
11 Dec 08 |
martin |
101 |
Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
4704 |
11 Dec 08 |
martin |
102 |
redirect = listPage; |
4704 |
11 Dec 08 |
martin |
103 |
} |
4704 |
11 Dec 08 |
martin |
104 |
else if ("LoadContext".equals(cmd)) |
4704 |
11 Dec 08 |
martin |
105 |
{ |
4704 |
11 Dec 08 |
martin |
106 |
// Display the list page after loading a saved context |
4704 |
11 Dec 08 |
martin |
107 |
int contextId = Values.getInt(request.getParameter("context")); |
4704 |
11 Dec 08 |
martin |
108 |
Base.loadContext(sc, contextId, defaultContext); |
4704 |
11 Dec 08 |
martin |
109 |
redirect = listPage; |
4704 |
11 Dec 08 |
martin |
110 |
} |
4704 |
11 Dec 08 |
martin |
111 |
|
4704 |
11 Dec 08 |
martin |
112 |
else if ("ViewItem".equals(cmd)) |
4704 |
11 Dec 08 |
martin |
113 |
{ |
4704 |
11 Dec 08 |
martin |
114 |
// Display the view page for a single item |
4704 |
11 Dec 08 |
martin |
115 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
4704 |
11 Dec 08 |
martin |
116 |
forward = viewPage; |
4704 |
11 Dec 08 |
martin |
117 |
} |
4704 |
11 Dec 08 |
martin |
118 |
else if ("EditItem".equals(cmd)) |
4704 |
11 Dec 08 |
martin |
119 |
{ |
4704 |
11 Dec 08 |
martin |
120 |
// Display the edit page for a single item (should be opened in a popup) |
4704 |
11 Dec 08 |
martin |
121 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
4704 |
11 Dec 08 |
martin |
122 |
redirect = editPage; |
4704 |
11 Dec 08 |
martin |
123 |
} |
4704 |
11 Dec 08 |
martin |
124 |
else if ("NewItem".equals(cmd)) |
4704 |
11 Dec 08 |
martin |
125 |
{ |
4704 |
11 Dec 08 |
martin |
126 |
// Display the edit page for a new item (should be opened in a popup) |
4704 |
11 Dec 08 |
martin |
127 |
if (!sc.hasPermission(Permission.CREATE, itemType)) |
4704 |
11 Dec 08 |
martin |
128 |
{ |
4704 |
11 Dec 08 |
martin |
129 |
throw new PermissionDeniedException(Permission.CREATE, itemType.toString()); |
4704 |
11 Dec 08 |
martin |
130 |
} |
4704 |
11 Dec 08 |
martin |
131 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
4704 |
11 Dec 08 |
martin |
132 |
cc.setId(0); |
4704 |
11 Dec 08 |
martin |
133 |
forward = editPage; |
4704 |
11 Dec 08 |
martin |
134 |
} |
4704 |
11 Dec 08 |
martin |
135 |
else if ("UpdateItem".equals(cmd)) |
4704 |
11 Dec 08 |
martin |
136 |
{ |
4704 |
11 Dec 08 |
martin |
137 |
// Update the properties on an item (will close the popup) |
4704 |
11 Dec 08 |
martin |
138 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, defaultContext); |
7954 |
12 May 21 |
nicklas |
139 |
dc = sc.newDbControl(":Edit "+itemType); |
4732 |
21 Jan 09 |
martin |
140 |
final int maxRecent = Base.getMaxRecent(sc); |
7605 |
26 Feb 19 |
nicklas |
141 |
BioPlate bioPlate = cc.getObject("item"); |
4704 |
11 Dec 08 |
martin |
142 |
if (bioPlate == null) |
4704 |
11 Dec 08 |
martin |
143 |
{ |
5262 |
08 Mar 10 |
nicklas |
144 |
PlateGeometry pg = PlateGeometry.getById(dc, Values.getInt(request.getParameter("plategeometry_id"))); |
5262 |
08 Mar 10 |
nicklas |
145 |
BioPlateType pt = BioPlateType.getById(dc, Values.getInt(request.getParameter("bioplatetype_id"))); |
5262 |
08 Mar 10 |
nicklas |
146 |
bioPlate = BioPlate.getNew(dc, pg, pt); |
7703 |
11 Apr 19 |
nicklas |
147 |
cc.setRecent(Item.PLATEGEOMETRY, pg, maxRecent); |
7703 |
11 Apr 19 |
nicklas |
148 |
cc.setRecent(Item.BIOPLATETYPE, pt, maxRecent); |
4704 |
11 Dec 08 |
martin |
149 |
message = "Bioplate created"; |
4704 |
11 Dec 08 |
martin |
150 |
dc.saveItem(bioPlate); |
4704 |
11 Dec 08 |
martin |
151 |
} |
4704 |
11 Dec 08 |
martin |
152 |
else |
4704 |
11 Dec 08 |
martin |
153 |
{ |
5060 |
19 Aug 09 |
nicklas |
154 |
dc.reattachItem(bioPlate, false); |
4704 |
11 Dec 08 |
martin |
155 |
message = "Bioplate updated"; |
4704 |
11 Dec 08 |
martin |
156 |
} |
5492 |
16 Nov 10 |
nicklas |
157 |
JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.item(Item.BIOPLATE), bioPlate); |
7604 |
25 Feb 19 |
nicklas |
158 |
ExtensionsInvoker<OnSaveAction> invoker = EditUtil.useOnSaveExtensions(jspContext); |
5492 |
16 Nov 10 |
nicklas |
159 |
try |
4732 |
21 Jan 09 |
martin |
160 |
{ |
5492 |
16 Nov 10 |
nicklas |
161 |
bioPlate.setName(Values.getStringOrNull(request.getParameter("name"))); |
5492 |
16 Nov 10 |
nicklas |
162 |
bioPlate.setDescription(Values.getStringOrNull(request.getParameter("description"))); |
5492 |
16 Nov 10 |
nicklas |
163 |
bioPlate.setBarcode(Values.getStringOrNull(request.getParameter("barcode"))); |
5492 |
16 Nov 10 |
nicklas |
164 |
bioPlate.setDestroyed(Values.getBoolean(request.getParameter("destroyed"))); |
6306 |
13 Aug 13 |
nicklas |
165 |
int storageId = Values.getInt(request.getParameter("storage_id")); |
6306 |
13 Aug 13 |
nicklas |
166 |
if (storageId >= 0) |
5492 |
16 Nov 10 |
nicklas |
167 |
{ |
6306 |
13 Aug 13 |
nicklas |
168 |
Hardware fz = storageId == 0 ? null : Hardware.getById(dc, storageId); |
5492 |
16 Nov 10 |
nicklas |
169 |
bioPlate.setFreezer(fz); |
7703 |
11 Apr 19 |
nicklas |
170 |
cc.setRecent(Item.HARDWARE, fz, fz==null ? null : fz.getItemSubtype(), maxRecent); |
5492 |
16 Nov 10 |
nicklas |
171 |
} |
6061 |
13 Jun 12 |
nicklas |
172 |
bioPlate.setSection(Values.getStringOrNull(request.getParameter("section"))); |
6061 |
13 Jun 12 |
nicklas |
173 |
bioPlate.setTray(Values.getStringOrNull(request.getParameter("tray"))); |
6061 |
13 Jun 12 |
nicklas |
174 |
bioPlate.setPosition(Values.getStringOrNull(request.getParameter("position"))); |
6061 |
13 Jun 12 |
nicklas |
175 |
|
5996 |
05 Mar 12 |
nicklas |
176 |
Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc); |
5996 |
05 Mar 12 |
nicklas |
177 |
bioPlate.setEventDate(dateFormatter.parseString(Values.getStringOrNull(request.getParameter("event_date")))); |
5996 |
05 Mar 12 |
nicklas |
178 |
|
5492 |
16 Nov 10 |
nicklas |
179 |
// Annotations tab |
5492 |
16 Nov 10 |
nicklas |
180 |
Base.updateAnnotations(dc, bioPlate, bioPlate, request); |
5492 |
16 Nov 10 |
nicklas |
181 |
|
5492 |
16 Nov 10 |
nicklas |
182 |
// OnSave extensions |
5492 |
16 Nov 10 |
nicklas |
183 |
invoker.render(OnSaveRenderer.ON_SAVE); |
5492 |
16 Nov 10 |
nicklas |
184 |
dc.commit(); |
5492 |
16 Nov 10 |
nicklas |
185 |
invoker.render(OnSaveRenderer.ON_COMMIT); |
4732 |
21 Jan 09 |
martin |
186 |
} |
5492 |
16 Nov 10 |
nicklas |
187 |
catch (Exception ex) |
5492 |
16 Nov 10 |
nicklas |
188 |
{ |
5492 |
16 Nov 10 |
nicklas |
189 |
invoker.render(OnSaveRenderer.onRollback(ex)); |
5492 |
16 Nov 10 |
nicklas |
190 |
throw ex; |
5492 |
16 Nov 10 |
nicklas |
191 |
} |
5492 |
16 Nov 10 |
nicklas |
192 |
finally |
5492 |
16 Nov 10 |
nicklas |
193 |
{ |
5492 |
16 Nov 10 |
nicklas |
194 |
cc.removeObject("item"); |
5492 |
16 Nov 10 |
nicklas |
195 |
} |
4704 |
11 Dec 08 |
martin |
196 |
} |
4704 |
11 Dec 08 |
martin |
197 |
else if ("DeleteItem".equals(cmd)) |
4704 |
11 Dec 08 |
martin |
198 |
{ |
4704 |
11 Dec 08 |
martin |
199 |
// Delete a single item and then return to the view page |
7954 |
12 May 21 |
nicklas |
200 |
dc = sc.newDbControl(":Delete "+itemType); |
4704 |
11 Dec 08 |
martin |
201 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
4704 |
11 Dec 08 |
martin |
202 |
RemovableUtil.setRemoved(dc, itemType, Collections.singleton(cc.getId()), true); |
4704 |
11 Dec 08 |
martin |
203 |
dc.commit(); |
4704 |
11 Dec 08 |
martin |
204 |
redirect = viewPage; |
4704 |
11 Dec 08 |
martin |
205 |
} |
4704 |
11 Dec 08 |
martin |
206 |
else if ("DeleteItems".equals(cmd)) |
4704 |
11 Dec 08 |
martin |
207 |
{ |
4704 |
11 Dec 08 |
martin |
208 |
// Delete all selected items on the list page |
7954 |
12 May 21 |
nicklas |
209 |
dc = sc.newDbControl(":Delete "+itemType); |
4704 |
11 Dec 08 |
martin |
210 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
4704 |
11 Dec 08 |
martin |
211 |
int numTotal = cc.getSelected().size(); |
4704 |
11 Dec 08 |
martin |
212 |
int numRemoved = RemovableUtil.setRemoved(dc, itemType, cc.getSelected(), true); |
4704 |
11 Dec 08 |
martin |
213 |
dc.commit(); |
4704 |
11 Dec 08 |
martin |
214 |
if (numTotal != numRemoved) |
4704 |
11 Dec 08 |
martin |
215 |
{ |
4704 |
11 Dec 08 |
martin |
216 |
message = (numRemoved == 0 ? "No" : "Only "+numRemoved+" of "+numTotal) + " items could be deleted, because you have no DELETE permission"; |
4704 |
11 Dec 08 |
martin |
217 |
} |
6192 |
31 Oct 12 |
nicklas |
218 |
redirect = listPage; |
4704 |
11 Dec 08 |
martin |
219 |
} |
4704 |
11 Dec 08 |
martin |
220 |
else if ("RestoreItem".equals(cmd)) |
4704 |
11 Dec 08 |
martin |
221 |
{ |
4704 |
11 Dec 08 |
martin |
222 |
// Restore a single item and then return to the view page |
7954 |
12 May 21 |
nicklas |
223 |
dc = sc.newDbControl(":Restore "+itemType); |
4704 |
11 Dec 08 |
martin |
224 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
4704 |
11 Dec 08 |
martin |
225 |
RemovableUtil.setRemoved(dc, itemType, Collections.singleton(cc.getId()), false); |
4704 |
11 Dec 08 |
martin |
226 |
dc.commit(); |
4704 |
11 Dec 08 |
martin |
227 |
redirect = viewPage; |
4704 |
11 Dec 08 |
martin |
228 |
} |
4704 |
11 Dec 08 |
martin |
229 |
else if ("RestoreItems".equals(cmd)) |
4704 |
11 Dec 08 |
martin |
230 |
{ |
4704 |
11 Dec 08 |
martin |
231 |
// Restore all selected items on the list page |
7954 |
12 May 21 |
nicklas |
232 |
dc = sc.newDbControl(":Restore "+itemType); |
4704 |
11 Dec 08 |
martin |
233 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
4704 |
11 Dec 08 |
martin |
234 |
int numTotal = cc.getSelected().size(); |
4704 |
11 Dec 08 |
martin |
235 |
int numRemoved = RemovableUtil.setRemoved(dc, itemType, cc.getSelected(), false); |
4704 |
11 Dec 08 |
martin |
236 |
dc.commit(); |
4704 |
11 Dec 08 |
martin |
237 |
if (numTotal != numRemoved) |
4704 |
11 Dec 08 |
martin |
238 |
{ |
4704 |
11 Dec 08 |
martin |
239 |
message = (numRemoved == 0 ? "No" : "Only "+numRemoved+" of "+numTotal) + " items could be restored, because you have no WRITE permission"; |
4704 |
11 Dec 08 |
martin |
240 |
} |
6192 |
31 Oct 12 |
nicklas |
241 |
redirect = listPage; |
4704 |
11 Dec 08 |
martin |
242 |
} |
4704 |
11 Dec 08 |
martin |
243 |
else if ("ShareItem".equals(cmd)) |
4704 |
11 Dec 08 |
martin |
244 |
{ |
4704 |
11 Dec 08 |
martin |
245 |
// Display a popup window for sharing a single item |
7954 |
12 May 21 |
nicklas |
246 |
dc = sc.newDbControl(":Share "+itemType); |
4704 |
11 Dec 08 |
martin |
247 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
4704 |
11 Dec 08 |
martin |
248 |
MultiPermissions permissions = ShareableUtil.getMultiPermissions(dc, itemType, Collections.singleton(cc.getId())); |
4704 |
11 Dec 08 |
martin |
249 |
dc.close(); |
4704 |
11 Dec 08 |
martin |
250 |
cc.setObject("MultiPermissions", permissions); |
4704 |
11 Dec 08 |
martin |
251 |
redirect = "../../common/share/share.jsp?ID="+ID+"&item_type="+itemType.name(); |
4704 |
11 Dec 08 |
martin |
252 |
} |
4704 |
11 Dec 08 |
martin |
253 |
else if ("ShareItems".equals(cmd)) |
4704 |
11 Dec 08 |
martin |
254 |
{ |
4704 |
11 Dec 08 |
martin |
255 |
// Display a popup window for sharing all selected items on the list page |
7954 |
12 May 21 |
nicklas |
256 |
dc = sc.newDbControl(":Share "+itemType); |
4704 |
11 Dec 08 |
martin |
257 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
4704 |
11 Dec 08 |
martin |
258 |
MultiPermissions permissions = ShareableUtil.getMultiPermissions(dc, itemType, cc.getSelected()); |
4704 |
11 Dec 08 |
martin |
259 |
dc.close(); |
4704 |
11 Dec 08 |
martin |
260 |
cc.setObject("MultiPermissions", permissions); |
4704 |
11 Dec 08 |
martin |
261 |
redirect = "../../common/share/share.jsp?ID="+ID+"&item_type="+itemType.name(); |
4704 |
11 Dec 08 |
martin |
262 |
} |
4704 |
11 Dec 08 |
martin |
263 |
else if ("SetOwnerOfItem".equals(cmd)) |
4704 |
11 Dec 08 |
martin |
264 |
{ |
4704 |
11 Dec 08 |
martin |
265 |
// Change owner of items selected on a list page |
7954 |
12 May 21 |
nicklas |
266 |
dc = sc.newDbControl(":Set owner of "+itemType); |
4704 |
11 Dec 08 |
martin |
267 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
4704 |
11 Dec 08 |
martin |
268 |
OwnedItem item = (OwnedItem)itemType.getById(dc, cc.getId()); |
4704 |
11 Dec 08 |
martin |
269 |
cc.setObject("OwnedItems", Collections.singleton(item)); |
4704 |
11 Dec 08 |
martin |
270 |
redirect = "../../common/ownership/ownership.jsp?ID="+ID+"&item_type="+itemType.name(); |
4704 |
11 Dec 08 |
martin |
271 |
} |
4704 |
11 Dec 08 |
martin |
272 |
else if ("SetOwnerOfItems".equals(cmd)) |
4704 |
11 Dec 08 |
martin |
273 |
{ |
4704 |
11 Dec 08 |
martin |
274 |
// Change owner of items selected on a list page |
7954 |
12 May 21 |
nicklas |
275 |
dc = sc.newDbControl(":Set owner of "+itemType); |
4704 |
11 Dec 08 |
martin |
276 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
4704 |
11 Dec 08 |
martin |
277 |
Set<OwnedItem> items = new HashSet<OwnedItem>(); |
4704 |
11 Dec 08 |
martin |
278 |
for (Integer id : cc.getSelected()) |
4704 |
11 Dec 08 |
martin |
279 |
{ |
4704 |
11 Dec 08 |
martin |
280 |
if (id != null) items.add((OwnedItem)itemType.getById(dc, id)); |
4704 |
11 Dec 08 |
martin |
281 |
} |
4704 |
11 Dec 08 |
martin |
282 |
dc.close(); |
4704 |
11 Dec 08 |
martin |
283 |
cc.setObject("OwnedItems", items); |
4704 |
11 Dec 08 |
martin |
284 |
redirect = "../../common/ownership/ownership.jsp?ID="+ID+"&item_type="+itemType.name(); |
4704 |
11 Dec 08 |
martin |
285 |
} |
4704 |
11 Dec 08 |
martin |
286 |
else if ("ExportItems".equals(cmd)) |
4704 |
11 Dec 08 |
martin |
287 |
{ |
4704 |
11 Dec 08 |
martin |
288 |
// Run an export plugin in a list context |
4704 |
11 Dec 08 |
martin |
289 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
4704 |
11 Dec 08 |
martin |
290 |
final ItemQuery<BioPlate> query = BioPlate.getQuery(); |
7954 |
12 May 21 |
nicklas |
291 |
dc = sc.newDbControl(":Export "+itemType); |
7914 |
23 Feb 21 |
nicklas |
292 |
JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.list(itemType), null); |
7914 |
23 Feb 21 |
nicklas |
293 |
cc.configureQuery(dc, query, jspContext, true); |
6038 |
29 Mar 12 |
nicklas |
294 |
cc.setQuery(query); |
7604 |
25 Feb 19 |
nicklas |
295 |
ExtensionsInvoker<ListColumnAction<BioPlate,?>> listInvoker = ListColumnUtil.useExtensions(jspContext); |
7604 |
25 Feb 19 |
nicklas |
296 |
listInvoker.render(new ListColumnExportRenderer<BioPlate>(cc)); |
5590 |
16 Mar 11 |
nicklas |
297 |
dc.close(); |
4704 |
11 Dec 08 |
martin |
298 |
redirect = "../../common/export/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=LIST&title=Export+bioplates"; |
4704 |
11 Dec 08 |
martin |
299 |
} |
4704 |
11 Dec 08 |
martin |
300 |
else if ("ExportItem".equals(cmd)) |
4704 |
11 Dec 08 |
martin |
301 |
{ |
4704 |
11 Dec 08 |
martin |
302 |
// Run an export plugin in single-item context |
4704 |
11 Dec 08 |
martin |
303 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
4704 |
11 Dec 08 |
martin |
304 |
redirect = "../../common/export/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=ITEM&title=Export+bioplate"; |
4704 |
11 Dec 08 |
martin |
305 |
} |
4704 |
11 Dec 08 |
martin |
306 |
else if ("ImportItems".equals(cmd)) |
4704 |
11 Dec 08 |
martin |
307 |
{ |
4704 |
11 Dec 08 |
martin |
308 |
// Run an import plugin in a list context |
4704 |
11 Dec 08 |
martin |
309 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
4704 |
11 Dec 08 |
martin |
310 |
final ItemQuery<BioPlate> query = BioPlate.getQuery(); |
7954 |
12 May 21 |
nicklas |
311 |
dc = sc.newDbControl(":Import "+itemType); |
7914 |
23 Feb 21 |
nicklas |
312 |
JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.list(itemType), null); |
7914 |
23 Feb 21 |
nicklas |
313 |
cc.configureQuery(dc, query, jspContext, true); |
5590 |
16 Mar 11 |
nicklas |
314 |
dc.close(); |
4704 |
11 Dec 08 |
martin |
315 |
cc.setQuery(query); |
4704 |
11 Dec 08 |
martin |
316 |
redirect = "../../common/import/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=LIST&title=Import+plates"; |
4704 |
11 Dec 08 |
martin |
317 |
} |
4704 |
11 Dec 08 |
martin |
318 |
else if ("ImportItem".equals(cmd)) |
4704 |
11 Dec 08 |
martin |
319 |
{ |
4704 |
11 Dec 08 |
martin |
320 |
// Run an import plugin in single-item context |
4704 |
11 Dec 08 |
martin |
321 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
4704 |
11 Dec 08 |
martin |
322 |
redirect = "../../common/import/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=ITEM&title=Import+plates"; |
4704 |
11 Dec 08 |
martin |
323 |
} |
4704 |
11 Dec 08 |
martin |
324 |
else if ("RunListPlugin".equals(cmd)) |
4704 |
11 Dec 08 |
martin |
325 |
{ |
4704 |
11 Dec 08 |
martin |
326 |
// Run another plugin in a list context |
4704 |
11 Dec 08 |
martin |
327 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
4704 |
11 Dec 08 |
martin |
328 |
final ItemQuery<BioPlate> query = BioPlate.getQuery(); |
7954 |
12 May 21 |
nicklas |
329 |
dc = sc.newDbControl(":Run plugin "+itemType); |
7914 |
23 Feb 21 |
nicklas |
330 |
JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.list(itemType), null); |
7914 |
23 Feb 21 |
nicklas |
331 |
cc.configureQuery(dc, query, jspContext, true); |
5590 |
16 Mar 11 |
nicklas |
332 |
dc.close(); |
4704 |
11 Dec 08 |
martin |
333 |
cc.setQuery(query); |
4704 |
11 Dec 08 |
martin |
334 |
redirect = "../../common/plugin/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=LIST&main_type=OTHER&title=Run+plugin"; |
4704 |
11 Dec 08 |
martin |
335 |
} |
4704 |
11 Dec 08 |
martin |
336 |
else if ("RunPlugin".equals(cmd)) |
4704 |
11 Dec 08 |
martin |
337 |
{ |
4704 |
11 Dec 08 |
martin |
338 |
// Run another plugin in single-item context |
4704 |
11 Dec 08 |
martin |
339 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
4704 |
11 Dec 08 |
martin |
340 |
redirect = "../../common/plugin/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=ITEM&main_type=OTHER&title=Run+plugin"; |
4704 |
11 Dec 08 |
martin |
341 |
} |
5532 |
16 Dec 10 |
nicklas |
342 |
else if ("MoveBioMaterial".equals(cmd)) |
5532 |
16 Dec 10 |
nicklas |
343 |
{ |
5535 |
21 Dec 10 |
nicklas |
344 |
redirect = "../wizards/move_biomaterial.jsp?ID="+ID+"&sourceplate_id=" + itemId; |
5532 |
16 Dec 10 |
nicklas |
345 |
} |
5548 |
24 Jan 11 |
nicklas |
346 |
else if ("CreateChildBioPlate".equals(cmd)) |
5548 |
24 Jan 11 |
nicklas |
347 |
{ |
5548 |
24 Jan 11 |
nicklas |
348 |
redirect = "../wizards/create_child_bioplate_step1.jsp?ID="+ID+"&sourceplate_id=" + itemId; |
5548 |
24 Jan 11 |
nicklas |
349 |
} |
4704 |
11 Dec 08 |
martin |
350 |
else |
4704 |
11 Dec 08 |
martin |
351 |
{ |
4704 |
11 Dec 08 |
martin |
352 |
throw new WebException("popup", "Invalid command", "The command {1} is not recognised as a valid command.", cmd); |
4704 |
11 Dec 08 |
martin |
353 |
} |
4704 |
11 Dec 08 |
martin |
354 |
} |
4704 |
11 Dec 08 |
martin |
355 |
finally |
4704 |
11 Dec 08 |
martin |
356 |
{ |
4704 |
11 Dec 08 |
martin |
357 |
if (dc != null) dc.close(); |
4704 |
11 Dec 08 |
martin |
358 |
} |
4704 |
11 Dec 08 |
martin |
359 |
|
4704 |
11 Dec 08 |
martin |
360 |
if (forward != null) |
4704 |
11 Dec 08 |
martin |
361 |
{ |
6192 |
31 Oct 12 |
nicklas |
362 |
sc.setSessionSetting("alert-message", message); |
4704 |
11 Dec 08 |
martin |
363 |
pageContext.forward(forward); |
4704 |
11 Dec 08 |
martin |
364 |
} |
4704 |
11 Dec 08 |
martin |
365 |
else if (redirect != null) |
4704 |
11 Dec 08 |
martin |
366 |
{ |
6192 |
31 Oct 12 |
nicklas |
367 |
sc.setSessionSetting("alert-message", message); |
4704 |
11 Dec 08 |
martin |
368 |
response.sendRedirect(redirect); |
4704 |
11 Dec 08 |
martin |
369 |
} |
4704 |
11 Dec 08 |
martin |
370 |
else if (message == null) |
4704 |
11 Dec 08 |
martin |
371 |
{ |
4704 |
11 Dec 08 |
martin |
372 |
response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&wait=0"); |
4704 |
11 Dec 08 |
martin |
373 |
} |
4704 |
11 Dec 08 |
martin |
374 |
else |
4704 |
11 Dec 08 |
martin |
375 |
{ |
4704 |
11 Dec 08 |
martin |
376 |
response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&message="+HTML.urlEncode(message)); |
4704 |
11 Dec 08 |
martin |
377 |
} |
4704 |
11 Dec 08 |
martin |
378 |
%> |