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