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