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