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