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