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