494 |
29 Apr 05 |
nicklas |
1 |
<%-- $Id$ |
494 |
29 Apr 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 |
494 |
29 Apr 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/ |
494 |
29 Apr 05 |
nicklas |
8 |
|
494 |
29 Apr 05 |
nicklas |
9 |
BASE is free software; you can redistribute it and/or |
494 |
29 Apr 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 |
494 |
29 Apr 05 |
nicklas |
12 |
of the License, or (at your option) any later version. |
494 |
29 Apr 05 |
nicklas |
13 |
|
494 |
29 Apr 05 |
nicklas |
14 |
BASE is distributed in the hope that it will be useful, |
494 |
29 Apr 05 |
nicklas |
15 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
494 |
29 Apr 05 |
nicklas |
16 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
494 |
29 Apr 05 |
nicklas |
17 |
GNU General Public License for more details. |
494 |
29 Apr 05 |
nicklas |
18 |
|
494 |
29 Apr 05 |
nicklas |
19 |
You should have received a copy of the GNU General Public License |
4510 |
11 Sep 08 |
jari |
20 |
along with BASE. If not, see <http://www.gnu.org/licenses/>. |
494 |
29 Apr 05 |
nicklas |
21 |
------------------------------------------------------------------ |
494 |
29 Apr 05 |
nicklas |
22 |
|
494 |
29 Apr 05 |
nicklas |
23 |
@author Nicklas |
494 |
29 Apr 05 |
nicklas |
24 |
@version 2.0 |
494 |
29 Apr 05 |
nicklas |
25 |
--%> |
5426 |
24 Sep 10 |
nicklas |
26 |
<%@ page pageEncoding="UTF-8" session="false" |
494 |
29 Apr 05 |
nicklas |
27 |
import="net.sf.basedb.core.SessionControl" |
494 |
29 Apr 05 |
nicklas |
28 |
import="net.sf.basedb.core.DbControl" |
494 |
29 Apr 05 |
nicklas |
29 |
import="net.sf.basedb.core.Item" |
2015 |
17 Feb 06 |
nicklas |
30 |
import="net.sf.basedb.core.Include" |
494 |
29 Apr 05 |
nicklas |
31 |
import="net.sf.basedb.core.Quota" |
494 |
29 Apr 05 |
nicklas |
32 |
import="net.sf.basedb.core.QuotaType" |
1418 |
07 Oct 05 |
nicklas |
33 |
import="net.sf.basedb.core.ItemQuery" |
2015 |
17 Feb 06 |
nicklas |
34 |
import="net.sf.basedb.core.ItemResultList" |
2015 |
17 Feb 06 |
nicklas |
35 |
import="net.sf.basedb.core.Location" |
494 |
29 Apr 05 |
nicklas |
36 |
import="net.sf.basedb.core.Permission" |
2015 |
17 Feb 06 |
nicklas |
37 |
import="net.sf.basedb.core.ItemContext" |
2015 |
17 Feb 06 |
nicklas |
38 |
import="net.sf.basedb.core.MultiPermissions" |
2015 |
17 Feb 06 |
nicklas |
39 |
import="net.sf.basedb.core.PermissionDeniedException" |
2015 |
17 Feb 06 |
nicklas |
40 |
import="net.sf.basedb.core.ItemAlreadyExistsException" |
2015 |
17 Feb 06 |
nicklas |
41 |
import="net.sf.basedb.util.RemovableUtil" |
494 |
29 Apr 05 |
nicklas |
42 |
import="net.sf.basedb.clients.web.Base" |
2015 |
17 Feb 06 |
nicklas |
43 |
import="net.sf.basedb.clients.web.WebException" |
2753 |
20 Oct 06 |
nicklas |
44 |
import="net.sf.basedb.util.Values" |
494 |
29 Apr 05 |
nicklas |
45 |
import="net.sf.basedb.clients.web.util.HTML" |
5506 |
19 Nov 10 |
nicklas |
46 |
import="net.sf.basedb.core.plugin.GuiContext" |
5506 |
19 Nov 10 |
nicklas |
47 |
import="net.sf.basedb.util.extensions.ExtensionsInvoker" |
5506 |
19 Nov 10 |
nicklas |
48 |
import="net.sf.basedb.clients.web.extensions.ExtensionsControl" |
5506 |
19 Nov 10 |
nicklas |
49 |
import="net.sf.basedb.clients.web.extensions.JspContext" |
5506 |
19 Nov 10 |
nicklas |
50 |
import="net.sf.basedb.clients.web.extensions.edit.EditUtil" |
7604 |
25 Feb 19 |
nicklas |
51 |
import="net.sf.basedb.clients.web.extensions.edit.OnSaveAction" |
5506 |
19 Nov 10 |
nicklas |
52 |
import="net.sf.basedb.clients.web.extensions.edit.OnSaveRenderer" |
6045 |
03 Apr 12 |
nicklas |
53 |
import="net.sf.basedb.clients.web.extensions.list.ListColumnExportRenderer" |
7604 |
25 Feb 19 |
nicklas |
54 |
import="net.sf.basedb.clients.web.extensions.list.ListColumnAction" |
6045 |
03 Apr 12 |
nicklas |
55 |
import="net.sf.basedb.clients.web.extensions.list.ListColumnUtil" |
2015 |
17 Feb 06 |
nicklas |
56 |
import="java.util.Enumeration" |
2015 |
17 Feb 06 |
nicklas |
57 |
import="java.util.Set" |
2015 |
17 Feb 06 |
nicklas |
58 |
import="java.util.HashSet" |
2015 |
17 Feb 06 |
nicklas |
59 |
import="java.util.List" |
2015 |
17 Feb 06 |
nicklas |
60 |
import="java.util.ArrayList" |
2015 |
17 Feb 06 |
nicklas |
61 |
import="java.util.Collections" |
494 |
29 Apr 05 |
nicklas |
62 |
%> |
494 |
29 Apr 05 |
nicklas |
63 |
<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> |
494 |
29 Apr 05 |
nicklas |
64 |
<%! |
2015 |
17 Feb 06 |
nicklas |
65 |
private static final ItemContext defaultContext = Base.createDefaultContext("name", "name,total,description"); |
2015 |
17 Feb 06 |
nicklas |
66 |
private static final Item itemType = Item.QUOTA; |
494 |
29 Apr 05 |
nicklas |
67 |
%> |
494 |
29 Apr 05 |
nicklas |
68 |
<% |
2015 |
17 Feb 06 |
nicklas |
69 |
final SessionControl sc = Base.getExistingSessionControl(pageContext, true); |
494 |
29 Apr 05 |
nicklas |
70 |
final String ID = sc.getId(); |
2015 |
17 Feb 06 |
nicklas |
71 |
final String cmd = request.getParameter("cmd"); |
2015 |
17 Feb 06 |
nicklas |
72 |
final String root = request.getContextPath()+"/"; |
2015 |
17 Feb 06 |
nicklas |
73 |
final String mode = request.getParameter("mode"); |
2015 |
17 Feb 06 |
nicklas |
74 |
final String callback = request.getParameter("callback"); |
2015 |
17 Feb 06 |
nicklas |
75 |
final String itemId = request.getParameter("item_id"); |
2015 |
17 Feb 06 |
nicklas |
76 |
final String listPage = "list_quota.jsp?ID="+ID |
2015 |
17 Feb 06 |
nicklas |
77 |
+(mode == null ? "" : "&mode="+mode) |
2015 |
17 Feb 06 |
nicklas |
78 |
+(callback == null ? "" : "&callback="+callback) |
2015 |
17 Feb 06 |
nicklas |
79 |
+(itemId == null ? "" : "&item_id="+itemId); |
2015 |
17 Feb 06 |
nicklas |
80 |
final String viewPage = "view_quota.jsp?ID="+ID; |
2015 |
17 Feb 06 |
nicklas |
81 |
final String editPage = "edit_quota.jsp?ID="+ID; |
494 |
29 Apr 05 |
nicklas |
82 |
|
2015 |
17 Feb 06 |
nicklas |
83 |
String forward = null; |
2015 |
17 Feb 06 |
nicklas |
84 |
String redirect = null; |
2015 |
17 Feb 06 |
nicklas |
85 |
String message = null; |
2015 |
17 Feb 06 |
nicklas |
86 |
DbControl dc = null; |
2015 |
17 Feb 06 |
nicklas |
87 |
|
494 |
29 Apr 05 |
nicklas |
88 |
try |
494 |
29 Apr 05 |
nicklas |
89 |
{ |
2015 |
17 Feb 06 |
nicklas |
90 |
if (cmd == null || "List".equals(cmd)) |
2015 |
17 Feb 06 |
nicklas |
91 |
{ |
2015 |
17 Feb 06 |
nicklas |
92 |
// Display the list page without updatinging the current context |
2811 |
26 Oct 06 |
nicklas |
93 |
Base.getAndSetCurrentContext(sc, itemType, null, defaultContext, true); |
2015 |
17 Feb 06 |
nicklas |
94 |
redirect = listPage; |
2015 |
17 Feb 06 |
nicklas |
95 |
} |
2015 |
17 Feb 06 |
nicklas |
96 |
else if ("UpdateContext".equals(cmd)) |
2015 |
17 Feb 06 |
nicklas |
97 |
{ |
2015 |
17 Feb 06 |
nicklas |
98 |
// Display the list page after updating the current context from the request parameters |
2015 |
17 Feb 06 |
nicklas |
99 |
Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
2015 |
17 Feb 06 |
nicklas |
100 |
redirect = listPage; |
2015 |
17 Feb 06 |
nicklas |
101 |
} |
2015 |
17 Feb 06 |
nicklas |
102 |
else if ("LoadContext".equals(cmd)) |
2015 |
17 Feb 06 |
nicklas |
103 |
{ |
2015 |
17 Feb 06 |
nicklas |
104 |
// Display the list page after loading a saved context |
2015 |
17 Feb 06 |
nicklas |
105 |
int contextId = Values.getInt(request.getParameter("context")); |
2015 |
17 Feb 06 |
nicklas |
106 |
Base.loadContext(sc, contextId, defaultContext); |
2015 |
17 Feb 06 |
nicklas |
107 |
redirect = listPage; |
2015 |
17 Feb 06 |
nicklas |
108 |
} |
2015 |
17 Feb 06 |
nicklas |
109 |
|
2015 |
17 Feb 06 |
nicklas |
110 |
else if ("ViewItem".equals(cmd)) |
2015 |
17 Feb 06 |
nicklas |
111 |
{ |
2015 |
17 Feb 06 |
nicklas |
112 |
// Display the view page for a single item |
2015 |
17 Feb 06 |
nicklas |
113 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
2015 |
17 Feb 06 |
nicklas |
114 |
forward = viewPage; |
2015 |
17 Feb 06 |
nicklas |
115 |
} |
2015 |
17 Feb 06 |
nicklas |
116 |
else if ("EditItem".equals(cmd)) |
2015 |
17 Feb 06 |
nicklas |
117 |
{ |
2015 |
17 Feb 06 |
nicklas |
118 |
// Display the edit page for a single item (should be opened in a popup) |
2015 |
17 Feb 06 |
nicklas |
119 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
2015 |
17 Feb 06 |
nicklas |
120 |
redirect = editPage; |
2015 |
17 Feb 06 |
nicklas |
121 |
} |
2015 |
17 Feb 06 |
nicklas |
122 |
else if ("NewItem".equals(cmd)) |
2015 |
17 Feb 06 |
nicklas |
123 |
{ |
2015 |
17 Feb 06 |
nicklas |
124 |
// Display the edit page for a new item (should be opened in a popup) |
2015 |
17 Feb 06 |
nicklas |
125 |
if (!sc.hasPermission(Permission.CREATE, itemType)) |
494 |
29 Apr 05 |
nicklas |
126 |
{ |
2015 |
17 Feb 06 |
nicklas |
127 |
throw new PermissionDeniedException(Permission.CREATE, itemType.toString()); |
494 |
29 Apr 05 |
nicklas |
128 |
} |
2015 |
17 Feb 06 |
nicklas |
129 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
2015 |
17 Feb 06 |
nicklas |
130 |
cc.setId(0); |
2015 |
17 Feb 06 |
nicklas |
131 |
redirect = editPage; |
2015 |
17 Feb 06 |
nicklas |
132 |
} |
2015 |
17 Feb 06 |
nicklas |
133 |
else if ("UpdateItem".equals(cmd)) |
2015 |
17 Feb 06 |
nicklas |
134 |
{ |
2015 |
17 Feb 06 |
nicklas |
135 |
// Update the properties on an item (will close the popup) |
2015 |
17 Feb 06 |
nicklas |
136 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, defaultContext); |
7954 |
12 May 21 |
nicklas |
137 |
dc = sc.newDbControl(":Edit "+itemType); |
7605 |
26 Feb 19 |
nicklas |
138 |
Quota quota = cc.getObject("item"); |
2015 |
17 Feb 06 |
nicklas |
139 |
if (quota == null) |
494 |
29 Apr 05 |
nicklas |
140 |
{ |
2015 |
17 Feb 06 |
nicklas |
141 |
quota = Quota.getNew(dc, 0); |
2015 |
17 Feb 06 |
nicklas |
142 |
message = "Quota created"; |
2015 |
17 Feb 06 |
nicklas |
143 |
dc.saveItem(quota); |
494 |
29 Apr 05 |
nicklas |
144 |
} |
2015 |
17 Feb 06 |
nicklas |
145 |
else |
494 |
29 Apr 05 |
nicklas |
146 |
{ |
5060 |
19 Aug 09 |
nicklas |
147 |
dc.reattachItem(quota, false); |
2015 |
17 Feb 06 |
nicklas |
148 |
message = "Quota updated"; |
494 |
29 Apr 05 |
nicklas |
149 |
} |
5506 |
19 Nov 10 |
nicklas |
150 |
JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.item(Item.QUOTA), quota); |
7604 |
25 Feb 19 |
nicklas |
151 |
ExtensionsInvoker<OnSaveAction> invoker = EditUtil.useOnSaveExtensions(jspContext); |
5506 |
19 Nov 10 |
nicklas |
152 |
try |
494 |
29 Apr 05 |
nicklas |
153 |
{ |
5506 |
19 Nov 10 |
nicklas |
154 |
quota.setName(Values.getStringOrNull(request.getParameter("name"))); |
5506 |
19 Nov 10 |
nicklas |
155 |
quota.setDescription(Values.getStringOrNull(request.getParameter("description"))); |
5506 |
19 Nov 10 |
nicklas |
156 |
|
5506 |
19 Nov 10 |
nicklas |
157 |
ItemQuery<QuotaType> q = QuotaType.getQuery(); |
5506 |
19 Nov 10 |
nicklas |
158 |
q.setCacheResult(true); |
5506 |
19 Nov 10 |
nicklas |
159 |
ItemResultList<QuotaType> quotaTypes = q.list(dc); |
5506 |
19 Nov 10 |
nicklas |
160 |
for (QuotaType type : quotaTypes) |
494 |
29 Apr 05 |
nicklas |
161 |
{ |
5506 |
19 Nov 10 |
nicklas |
162 |
for (Location location : Location.values()) |
2015 |
17 Feb 06 |
nicklas |
163 |
{ |
7595 |
22 Feb 19 |
nicklas |
164 |
if (location.isQuotaLimited()) |
2015 |
17 Feb 06 |
nicklas |
165 |
{ |
5506 |
19 Nov 10 |
nicklas |
166 |
long bytes = Quota.UNDEFINED; |
6305 |
09 Aug 13 |
nicklas |
167 |
String unlimited = request.getParameter("unlimited:"+location.name()+":"+type.getId()); |
6305 |
09 Aug 13 |
nicklas |
168 |
String quotaValue = Values.getStringOrNull(request.getParameter(location.name()+":"+type.getId())); |
5506 |
19 Nov 10 |
nicklas |
169 |
if (unlimited != null) |
2015 |
17 Feb 06 |
nicklas |
170 |
{ |
5506 |
19 Nov 10 |
nicklas |
171 |
bytes = Quota.UNLIMITED; |
2015 |
17 Feb 06 |
nicklas |
172 |
} |
5506 |
19 Nov 10 |
nicklas |
173 |
else if (quotaValue != null) |
5506 |
19 Nov 10 |
nicklas |
174 |
{ |
5506 |
19 Nov 10 |
nicklas |
175 |
bytes = Values.parseBytes(quotaValue, Quota.UNDEFINED); |
5506 |
19 Nov 10 |
nicklas |
176 |
if (bytes == Quota.UNDEFINED) |
5506 |
19 Nov 10 |
nicklas |
177 |
{ |
5506 |
19 Nov 10 |
nicklas |
178 |
throw new WebException("popup", "Invalid byte value", |
5506 |
19 Nov 10 |
nicklas |
179 |
"The value {1} entered for {2} at {3} location is not a valid value.", |
5506 |
19 Nov 10 |
nicklas |
180 |
quotaValue, HTML.encodeTags(type.getName()), location.toString()); |
5506 |
19 Nov 10 |
nicklas |
181 |
} |
5506 |
19 Nov 10 |
nicklas |
182 |
} |
5506 |
19 Nov 10 |
nicklas |
183 |
quota.setQuotaValue(type, location, bytes); |
2015 |
17 Feb 06 |
nicklas |
184 |
} |
2015 |
17 Feb 06 |
nicklas |
185 |
} |
494 |
29 Apr 05 |
nicklas |
186 |
} |
5506 |
19 Nov 10 |
nicklas |
187 |
|
5506 |
19 Nov 10 |
nicklas |
188 |
// OnSave extensions |
5506 |
19 Nov 10 |
nicklas |
189 |
invoker.render(OnSaveRenderer.ON_SAVE); |
5506 |
19 Nov 10 |
nicklas |
190 |
dc.commit(); |
5506 |
19 Nov 10 |
nicklas |
191 |
invoker.render(OnSaveRenderer.ON_COMMIT); |
494 |
29 Apr 05 |
nicklas |
192 |
} |
5506 |
19 Nov 10 |
nicklas |
193 |
catch (Exception ex) |
5506 |
19 Nov 10 |
nicklas |
194 |
{ |
5506 |
19 Nov 10 |
nicklas |
195 |
invoker.render(OnSaveRenderer.onRollback(ex)); |
5506 |
19 Nov 10 |
nicklas |
196 |
throw ex; |
5506 |
19 Nov 10 |
nicklas |
197 |
} |
5506 |
19 Nov 10 |
nicklas |
198 |
finally |
5506 |
19 Nov 10 |
nicklas |
199 |
{ |
5506 |
19 Nov 10 |
nicklas |
200 |
cc.removeObject("item"); |
5506 |
19 Nov 10 |
nicklas |
201 |
} |
2015 |
17 Feb 06 |
nicklas |
202 |
} |
2015 |
17 Feb 06 |
nicklas |
203 |
else if ("DeleteItem".equals(cmd)) |
2015 |
17 Feb 06 |
nicklas |
204 |
{ |
2015 |
17 Feb 06 |
nicklas |
205 |
// Delete a single item and then return to the view page |
7954 |
12 May 21 |
nicklas |
206 |
dc = sc.newDbControl(":Delete "+itemType); |
2015 |
17 Feb 06 |
nicklas |
207 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
2015 |
17 Feb 06 |
nicklas |
208 |
RemovableUtil.setRemoved(dc, itemType, Collections.singleton(cc.getId()), true); |
2015 |
17 Feb 06 |
nicklas |
209 |
dc.commit(); |
2015 |
17 Feb 06 |
nicklas |
210 |
redirect = viewPage; |
2015 |
17 Feb 06 |
nicklas |
211 |
} |
2015 |
17 Feb 06 |
nicklas |
212 |
else if ("DeleteItems".equals(cmd)) |
2015 |
17 Feb 06 |
nicklas |
213 |
{ |
2015 |
17 Feb 06 |
nicklas |
214 |
// Delete all selected items on the list page |
7954 |
12 May 21 |
nicklas |
215 |
dc = sc.newDbControl(":Delete "+itemType); |
2015 |
17 Feb 06 |
nicklas |
216 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
2015 |
17 Feb 06 |
nicklas |
217 |
int numTotal = cc.getSelected().size(); |
2015 |
17 Feb 06 |
nicklas |
218 |
int numRemoved = RemovableUtil.setRemoved(dc, itemType, cc.getSelected(), true); |
2015 |
17 Feb 06 |
nicklas |
219 |
dc.commit(); |
2015 |
17 Feb 06 |
nicklas |
220 |
if (numTotal != numRemoved) |
494 |
29 Apr 05 |
nicklas |
221 |
{ |
2015 |
17 Feb 06 |
nicklas |
222 |
message = (numRemoved == 0 ? "No" : "Only "+numRemoved+" of "+numTotal) + " items could be deleted, because you have no DELETE permission"; |
494 |
29 Apr 05 |
nicklas |
223 |
} |
6192 |
31 Oct 12 |
nicklas |
224 |
redirect = listPage; |
2015 |
17 Feb 06 |
nicklas |
225 |
} |
2015 |
17 Feb 06 |
nicklas |
226 |
else if ("RestoreItem".equals(cmd)) |
2015 |
17 Feb 06 |
nicklas |
227 |
{ |
2015 |
17 Feb 06 |
nicklas |
228 |
// Restore a single item and then return to the view page |
7954 |
12 May 21 |
nicklas |
229 |
dc = sc.newDbControl(":Restore "+itemType); |
2015 |
17 Feb 06 |
nicklas |
230 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
2015 |
17 Feb 06 |
nicklas |
231 |
RemovableUtil.setRemoved(dc, itemType, Collections.singleton(cc.getId()), false); |
2015 |
17 Feb 06 |
nicklas |
232 |
dc.commit(); |
2015 |
17 Feb 06 |
nicklas |
233 |
redirect = viewPage; |
2015 |
17 Feb 06 |
nicklas |
234 |
} |
2015 |
17 Feb 06 |
nicklas |
235 |
else if ("RestoreItems".equals(cmd)) |
2015 |
17 Feb 06 |
nicklas |
236 |
{ |
2015 |
17 Feb 06 |
nicklas |
237 |
// Restore all selected items on the list page |
7954 |
12 May 21 |
nicklas |
238 |
dc = sc.newDbControl(":Restore "+itemType); |
2015 |
17 Feb 06 |
nicklas |
239 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
2015 |
17 Feb 06 |
nicklas |
240 |
int numTotal = cc.getSelected().size(); |
2015 |
17 Feb 06 |
nicklas |
241 |
int numRemoved = RemovableUtil.setRemoved(dc, itemType, cc.getSelected(), false); |
2015 |
17 Feb 06 |
nicklas |
242 |
dc.commit(); |
2015 |
17 Feb 06 |
nicklas |
243 |
if (numTotal != numRemoved) |
494 |
29 Apr 05 |
nicklas |
244 |
{ |
2528 |
15 Aug 06 |
martin |
245 |
message = (numRemoved == 0 ? "No" : "Only "+numRemoved+" of "+numTotal) + " items could be restored, because you have no WRITE permission"; |
494 |
29 Apr 05 |
nicklas |
246 |
} |
6192 |
31 Oct 12 |
nicklas |
247 |
redirect = listPage; |
2015 |
17 Feb 06 |
nicklas |
248 |
} |
2015 |
17 Feb 06 |
nicklas |
249 |
else if ("ExportItems".equals(cmd)) |
2015 |
17 Feb 06 |
nicklas |
250 |
{ |
2015 |
17 Feb 06 |
nicklas |
251 |
// Run an export plugin in a list context |
2015 |
17 Feb 06 |
nicklas |
252 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
2015 |
17 Feb 06 |
nicklas |
253 |
final ItemQuery<Quota> query = Quota.getQuery(); |
7954 |
12 May 21 |
nicklas |
254 |
dc = sc.newDbControl(":Export "+itemType); |
7914 |
23 Feb 21 |
nicklas |
255 |
JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.list(itemType), null); |
7914 |
23 Feb 21 |
nicklas |
256 |
cc.configureQuery(dc, query, jspContext, true); |
6045 |
03 Apr 12 |
nicklas |
257 |
cc.setQuery(query); |
7604 |
25 Feb 19 |
nicklas |
258 |
ExtensionsInvoker<ListColumnAction<Quota,?>> listInvoker = ListColumnUtil.useExtensions(jspContext); |
7604 |
25 Feb 19 |
nicklas |
259 |
listInvoker.render(new ListColumnExportRenderer<Quota>(cc)); |
5590 |
16 Mar 11 |
nicklas |
260 |
dc.close(); |
2015 |
17 Feb 06 |
nicklas |
261 |
redirect = "../../common/export/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=LIST&title=Export+quota"; |
2015 |
17 Feb 06 |
nicklas |
262 |
} |
2015 |
17 Feb 06 |
nicklas |
263 |
else if ("ExportItem".equals(cmd)) |
2015 |
17 Feb 06 |
nicklas |
264 |
{ |
2015 |
17 Feb 06 |
nicklas |
265 |
// Run an export plugin in single-item context |
2015 |
17 Feb 06 |
nicklas |
266 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
2015 |
17 Feb 06 |
nicklas |
267 |
redirect = "../../common/export/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=ITEM&title=Export+quota"; |
2015 |
17 Feb 06 |
nicklas |
268 |
} |
2015 |
17 Feb 06 |
nicklas |
269 |
else if ("ImportItems".equals(cmd)) |
2015 |
17 Feb 06 |
nicklas |
270 |
{ |
2015 |
17 Feb 06 |
nicklas |
271 |
// Run an import plugin in a list context |
2015 |
17 Feb 06 |
nicklas |
272 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
2015 |
17 Feb 06 |
nicklas |
273 |
final ItemQuery<Quota> query = Quota.getQuery(); |
7954 |
12 May 21 |
nicklas |
274 |
dc = sc.newDbControl(":Import "+itemType); |
7914 |
23 Feb 21 |
nicklas |
275 |
JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.list(itemType), null); |
7914 |
23 Feb 21 |
nicklas |
276 |
cc.configureQuery(dc, query, jspContext, true); |
5590 |
16 Mar 11 |
nicklas |
277 |
dc.close(); |
2015 |
17 Feb 06 |
nicklas |
278 |
cc.setQuery(query); |
2015 |
17 Feb 06 |
nicklas |
279 |
redirect = "../../common/import/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=LIST&title=Import+quota"; |
2015 |
17 Feb 06 |
nicklas |
280 |
} |
2015 |
17 Feb 06 |
nicklas |
281 |
else if ("ImportItem".equals(cmd)) |
2015 |
17 Feb 06 |
nicklas |
282 |
{ |
2015 |
17 Feb 06 |
nicklas |
283 |
// Run an import plugin in single-item context |
2015 |
17 Feb 06 |
nicklas |
284 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
2015 |
17 Feb 06 |
nicklas |
285 |
redirect = "../../common/import/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=ITEM&title=Import+quota"; |
2015 |
17 Feb 06 |
nicklas |
286 |
} |
2015 |
17 Feb 06 |
nicklas |
287 |
else if ("RunListPlugin".equals(cmd)) |
2015 |
17 Feb 06 |
nicklas |
288 |
{ |
2015 |
17 Feb 06 |
nicklas |
289 |
// Run another plugin in a list context |
2015 |
17 Feb 06 |
nicklas |
290 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
2015 |
17 Feb 06 |
nicklas |
291 |
final ItemQuery<Quota> query = Quota.getQuery(); |
7954 |
12 May 21 |
nicklas |
292 |
dc = sc.newDbControl(":Run plugin "+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); |
5590 |
16 Mar 11 |
nicklas |
295 |
dc.close(); |
2015 |
17 Feb 06 |
nicklas |
296 |
cc.setQuery(query); |
2015 |
17 Feb 06 |
nicklas |
297 |
redirect = "../../common/plugin/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=LIST&main_type=OTHER&title=Run+plugin"; |
2015 |
17 Feb 06 |
nicklas |
298 |
} |
2015 |
17 Feb 06 |
nicklas |
299 |
else if ("RunPlugin".equals(cmd)) |
2015 |
17 Feb 06 |
nicklas |
300 |
{ |
2015 |
17 Feb 06 |
nicklas |
301 |
// Run another plugin in single-item context |
2015 |
17 Feb 06 |
nicklas |
302 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
2015 |
17 Feb 06 |
nicklas |
303 |
redirect = "../../common/plugin/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=ITEM&main_type=OTHER&title=Run+plugin"; |
2015 |
17 Feb 06 |
nicklas |
304 |
} |
2015 |
17 Feb 06 |
nicklas |
305 |
else |
2015 |
17 Feb 06 |
nicklas |
306 |
{ |
2015 |
17 Feb 06 |
nicklas |
307 |
throw new WebException("popup", "Invalid command", "The command {1} is not recognised as a valid command.", cmd); |
2015 |
17 Feb 06 |
nicklas |
308 |
} |
494 |
29 Apr 05 |
nicklas |
309 |
} |
494 |
29 Apr 05 |
nicklas |
310 |
finally |
494 |
29 Apr 05 |
nicklas |
311 |
{ |
494 |
29 Apr 05 |
nicklas |
312 |
if (dc != null) dc.close(); |
494 |
29 Apr 05 |
nicklas |
313 |
} |
2015 |
17 Feb 06 |
nicklas |
314 |
|
2015 |
17 Feb 06 |
nicklas |
315 |
if (forward != null) |
2015 |
17 Feb 06 |
nicklas |
316 |
{ |
6192 |
31 Oct 12 |
nicklas |
317 |
sc.setSessionSetting("alert-message", message); |
2015 |
17 Feb 06 |
nicklas |
318 |
pageContext.forward(forward); |
2015 |
17 Feb 06 |
nicklas |
319 |
} |
2015 |
17 Feb 06 |
nicklas |
320 |
else if (redirect != null) |
2015 |
17 Feb 06 |
nicklas |
321 |
{ |
6192 |
31 Oct 12 |
nicklas |
322 |
sc.setSessionSetting("alert-message", message); |
2015 |
17 Feb 06 |
nicklas |
323 |
response.sendRedirect(redirect); |
2015 |
17 Feb 06 |
nicklas |
324 |
} |
2015 |
17 Feb 06 |
nicklas |
325 |
else if (message == null) |
2015 |
17 Feb 06 |
nicklas |
326 |
{ |
2015 |
17 Feb 06 |
nicklas |
327 |
response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&wait=0"); |
2015 |
17 Feb 06 |
nicklas |
328 |
} |
2015 |
17 Feb 06 |
nicklas |
329 |
else |
2015 |
17 Feb 06 |
nicklas |
330 |
{ |
2015 |
17 Feb 06 |
nicklas |
331 |
response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&message="+HTML.urlEncode(message)); |
2015 |
17 Feb 06 |
nicklas |
332 |
} |
2015 |
17 Feb 06 |
nicklas |
333 |
%> |
2015 |
17 Feb 06 |
nicklas |
334 |
|