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