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