572 |
12 May 05 |
nicklas |
1 |
<%-- $Id$ |
572 |
12 May 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 |
572 |
12 May 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/ |
572 |
12 May 05 |
nicklas |
8 |
|
572 |
12 May 05 |
nicklas |
9 |
BASE is free software; you can redistribute it and/or |
572 |
12 May 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 |
572 |
12 May 05 |
nicklas |
12 |
of the License, or (at your option) any later version. |
572 |
12 May 05 |
nicklas |
13 |
|
572 |
12 May 05 |
nicklas |
14 |
BASE is distributed in the hope that it will be useful, |
572 |
12 May 05 |
nicklas |
15 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
572 |
12 May 05 |
nicklas |
16 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
572 |
12 May 05 |
nicklas |
17 |
GNU General Public License for more details. |
572 |
12 May 05 |
nicklas |
18 |
|
572 |
12 May 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/>. |
572 |
12 May 05 |
nicklas |
21 |
------------------------------------------------------------------ |
572 |
12 May 05 |
nicklas |
22 |
|
572 |
12 May 05 |
nicklas |
23 |
@author Nicklas |
572 |
12 May 05 |
nicklas |
24 |
@version 2.0 |
572 |
12 May 05 |
nicklas |
25 |
--%> |
5426 |
24 Sep 10 |
nicklas |
26 |
<%@ page pageEncoding="UTF-8" session="false" |
2939 |
20 Nov 06 |
martin |
27 |
import="net.sf.basedb.core.BasicItem" |
572 |
12 May 05 |
nicklas |
28 |
import="net.sf.basedb.core.SessionControl" |
572 |
12 May 05 |
nicklas |
29 |
import="net.sf.basedb.core.DbControl" |
572 |
12 May 05 |
nicklas |
30 |
import="net.sf.basedb.core.Item" |
572 |
12 May 05 |
nicklas |
31 |
import="net.sf.basedb.core.Include" |
572 |
12 May 05 |
nicklas |
32 |
import="net.sf.basedb.core.Project" |
1895 |
02 Feb 06 |
nicklas |
33 |
import="net.sf.basedb.core.User" |
1895 |
02 Feb 06 |
nicklas |
34 |
import="net.sf.basedb.core.Group" |
3847 |
17 Oct 07 |
nicklas |
35 |
import="net.sf.basedb.core.Platform" |
3847 |
17 Oct 07 |
nicklas |
36 |
import="net.sf.basedb.core.PlatformVariant" |
1418 |
07 Oct 05 |
nicklas |
37 |
import="net.sf.basedb.core.ItemQuery" |
1418 |
07 Oct 05 |
nicklas |
38 |
import="net.sf.basedb.core.ItemResultIterator" |
572 |
12 May 05 |
nicklas |
39 |
import="net.sf.basedb.core.Permission" |
5370 |
23 Jun 10 |
nicklas |
40 |
import="net.sf.basedb.core.PermissionTemplate" |
1895 |
02 Feb 06 |
nicklas |
41 |
import="net.sf.basedb.core.ItemContext" |
1895 |
02 Feb 06 |
nicklas |
42 |
import="net.sf.basedb.core.MultiPermissions" |
4587 |
15 Oct 08 |
martin |
43 |
import="net.sf.basedb.core.OwnedItem" |
1895 |
02 Feb 06 |
nicklas |
44 |
import="net.sf.basedb.core.PermissionDeniedException" |
1895 |
02 Feb 06 |
nicklas |
45 |
import="net.sf.basedb.core.ItemAlreadyExistsException" |
2941 |
22 Nov 06 |
martin |
46 |
import="net.sf.basedb.core.RawDataType" |
2941 |
22 Nov 06 |
martin |
47 |
import="net.sf.basedb.core.RawDataTypes" |
1895 |
02 Feb 06 |
nicklas |
48 |
import="net.sf.basedb.util.RemovableUtil" |
2918 |
15 Nov 06 |
nicklas |
49 |
import="net.sf.basedb.util.OwnableUtil" |
572 |
12 May 05 |
nicklas |
50 |
import="net.sf.basedb.clients.web.Base" |
1965 |
10 Feb 06 |
nicklas |
51 |
import="net.sf.basedb.clients.web.PermissionUtil" |
1895 |
02 Feb 06 |
nicklas |
52 |
import="net.sf.basedb.clients.web.WebException" |
2753 |
20 Oct 06 |
nicklas |
53 |
import="net.sf.basedb.util.Values" |
572 |
12 May 05 |
nicklas |
54 |
import="net.sf.basedb.clients.web.util.HTML" |
5501 |
18 Nov 10 |
nicklas |
55 |
import="net.sf.basedb.core.plugin.GuiContext" |
5501 |
18 Nov 10 |
nicklas |
56 |
import="net.sf.basedb.util.extensions.ExtensionsInvoker" |
5501 |
18 Nov 10 |
nicklas |
57 |
import="net.sf.basedb.clients.web.extensions.ExtensionsControl" |
5501 |
18 Nov 10 |
nicklas |
58 |
import="net.sf.basedb.clients.web.extensions.JspContext" |
5501 |
18 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" |
5501 |
18 Nov 10 |
nicklas |
61 |
import="net.sf.basedb.clients.web.extensions.edit.OnSaveRenderer" |
6040 |
30 Mar 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" |
6040 |
30 Mar 12 |
nicklas |
64 |
import="net.sf.basedb.clients.web.extensions.list.ListColumnUtil" |
1895 |
02 Feb 06 |
nicklas |
65 |
import="java.util.Enumeration" |
1895 |
02 Feb 06 |
nicklas |
66 |
import="java.util.Set" |
1895 |
02 Feb 06 |
nicklas |
67 |
import="java.util.HashSet" |
1895 |
02 Feb 06 |
nicklas |
68 |
import="java.util.List" |
1895 |
02 Feb 06 |
nicklas |
69 |
import="java.util.ArrayList" |
1895 |
02 Feb 06 |
nicklas |
70 |
import="java.util.Collections" |
572 |
12 May 05 |
nicklas |
71 |
%> |
572 |
12 May 05 |
nicklas |
72 |
<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> |
572 |
12 May 05 |
nicklas |
73 |
<%! |
1895 |
02 Feb 06 |
nicklas |
74 |
private static final ItemContext defaultContext = Base.createDefaultContext("name", "name,description,actions"); |
1895 |
02 Feb 06 |
nicklas |
75 |
private static final Item itemType = Item.PROJECT; |
572 |
12 May 05 |
nicklas |
76 |
%> |
572 |
12 May 05 |
nicklas |
77 |
<% |
1895 |
02 Feb 06 |
nicklas |
78 |
final SessionControl sc = Base.getExistingSessionControl(pageContext, true); |
572 |
12 May 05 |
nicklas |
79 |
final String ID = sc.getId(); |
1895 |
02 Feb 06 |
nicklas |
80 |
final String cmd = request.getParameter("cmd"); |
1895 |
02 Feb 06 |
nicklas |
81 |
final String root = request.getContextPath()+"/"; |
1895 |
02 Feb 06 |
nicklas |
82 |
final String mode = request.getParameter("mode"); |
1895 |
02 Feb 06 |
nicklas |
83 |
final String callback = request.getParameter("callback"); |
1895 |
02 Feb 06 |
nicklas |
84 |
final String itemId = request.getParameter("item_id"); |
1895 |
02 Feb 06 |
nicklas |
85 |
final String listPage = "list_projects.jsp?ID="+ID |
1895 |
02 Feb 06 |
nicklas |
86 |
+(mode == null ? "" : "&mode="+mode) |
1895 |
02 Feb 06 |
nicklas |
87 |
+(callback == null ? "" : "&callback="+callback) |
1895 |
02 Feb 06 |
nicklas |
88 |
+(itemId == null ? "" : "&item_id="+itemId); |
1895 |
02 Feb 06 |
nicklas |
89 |
final String viewPage = "view_project.jsp?ID="+ID; |
1895 |
02 Feb 06 |
nicklas |
90 |
final String editPage = "edit_project.jsp?ID="+ID; |
572 |
12 May 05 |
nicklas |
91 |
|
1895 |
02 Feb 06 |
nicklas |
92 |
String forward = null; |
1895 |
02 Feb 06 |
nicklas |
93 |
String redirect = null; |
1895 |
02 Feb 06 |
nicklas |
94 |
String message = null; |
1895 |
02 Feb 06 |
nicklas |
95 |
DbControl dc = null; |
1895 |
02 Feb 06 |
nicklas |
96 |
|
572 |
12 May 05 |
nicklas |
97 |
try |
572 |
12 May 05 |
nicklas |
98 |
{ |
1895 |
02 Feb 06 |
nicklas |
99 |
if (cmd == null || "List".equals(cmd)) |
1895 |
02 Feb 06 |
nicklas |
100 |
{ |
1895 |
02 Feb 06 |
nicklas |
101 |
// Display the list page without updatinging the current context |
2811 |
26 Oct 06 |
nicklas |
102 |
Base.getAndSetCurrentContext(sc, itemType, null, defaultContext, true); |
1895 |
02 Feb 06 |
nicklas |
103 |
redirect = listPage; |
1895 |
02 Feb 06 |
nicklas |
104 |
} |
1895 |
02 Feb 06 |
nicklas |
105 |
else if ("UpdateContext".equals(cmd)) |
1895 |
02 Feb 06 |
nicklas |
106 |
{ |
1895 |
02 Feb 06 |
nicklas |
107 |
// Display the list page after updating the current context from the request parameters |
1895 |
02 Feb 06 |
nicklas |
108 |
Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1895 |
02 Feb 06 |
nicklas |
109 |
redirect = listPage; |
1895 |
02 Feb 06 |
nicklas |
110 |
} |
1895 |
02 Feb 06 |
nicklas |
111 |
else if ("LoadContext".equals(cmd)) |
1895 |
02 Feb 06 |
nicklas |
112 |
{ |
1895 |
02 Feb 06 |
nicklas |
113 |
// Display the list page after loading a saved context |
1895 |
02 Feb 06 |
nicklas |
114 |
int contextId = Values.getInt(request.getParameter("context")); |
1895 |
02 Feb 06 |
nicklas |
115 |
Base.loadContext(sc, contextId, defaultContext); |
1895 |
02 Feb 06 |
nicklas |
116 |
redirect = listPage; |
1895 |
02 Feb 06 |
nicklas |
117 |
} |
1895 |
02 Feb 06 |
nicklas |
118 |
|
1895 |
02 Feb 06 |
nicklas |
119 |
else if ("ViewItem".equals(cmd)) |
1895 |
02 Feb 06 |
nicklas |
120 |
{ |
1895 |
02 Feb 06 |
nicklas |
121 |
// Display the view page for a single item |
1895 |
02 Feb 06 |
nicklas |
122 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1895 |
02 Feb 06 |
nicklas |
123 |
forward = viewPage; |
1895 |
02 Feb 06 |
nicklas |
124 |
} |
1895 |
02 Feb 06 |
nicklas |
125 |
else if ("EditItem".equals(cmd)) |
1895 |
02 Feb 06 |
nicklas |
126 |
{ |
1895 |
02 Feb 06 |
nicklas |
127 |
// Display the edit page for a single item (should be opened in a popup) |
1895 |
02 Feb 06 |
nicklas |
128 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1895 |
02 Feb 06 |
nicklas |
129 |
redirect = editPage; |
1895 |
02 Feb 06 |
nicklas |
130 |
} |
1895 |
02 Feb 06 |
nicklas |
131 |
else if ("NewItem".equals(cmd)) |
1895 |
02 Feb 06 |
nicklas |
132 |
{ |
1895 |
02 Feb 06 |
nicklas |
133 |
// Display the edit page for a new item (should be opened in a popup) |
1895 |
02 Feb 06 |
nicklas |
134 |
if (!sc.hasPermission(Permission.CREATE, itemType)) |
572 |
12 May 05 |
nicklas |
135 |
{ |
1895 |
02 Feb 06 |
nicklas |
136 |
throw new PermissionDeniedException(Permission.CREATE, itemType.toString()); |
572 |
12 May 05 |
nicklas |
137 |
} |
1895 |
02 Feb 06 |
nicklas |
138 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1895 |
02 Feb 06 |
nicklas |
139 |
cc.setId(0); |
1895 |
02 Feb 06 |
nicklas |
140 |
redirect = editPage; |
1895 |
02 Feb 06 |
nicklas |
141 |
} |
1895 |
02 Feb 06 |
nicklas |
142 |
else if ("UpdateItem".equals(cmd)) |
1895 |
02 Feb 06 |
nicklas |
143 |
{ |
1895 |
02 Feb 06 |
nicklas |
144 |
// Update the properties on an item (will close the popup) |
1895 |
02 Feb 06 |
nicklas |
145 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, defaultContext); |
5370 |
23 Jun 10 |
nicklas |
146 |
final int maxRecent = Base.getMaxRecent(sc); |
7954 |
12 May 21 |
nicklas |
147 |
dc = sc.newDbControl(":Edit "+itemType); |
7605 |
26 Feb 19 |
nicklas |
148 |
Project project = cc.getObject("item"); |
1895 |
02 Feb 06 |
nicklas |
149 |
if (project == null) |
572 |
12 May 05 |
nicklas |
150 |
{ |
1895 |
02 Feb 06 |
nicklas |
151 |
project = Project.getNew(dc); |
1895 |
02 Feb 06 |
nicklas |
152 |
message = "Project created"; |
1895 |
02 Feb 06 |
nicklas |
153 |
dc.saveItem(project); |
572 |
12 May 05 |
nicklas |
154 |
} |
1895 |
02 Feb 06 |
nicklas |
155 |
else |
572 |
12 May 05 |
nicklas |
156 |
{ |
5060 |
19 Aug 09 |
nicklas |
157 |
dc.reattachItem(project, false); |
1895 |
02 Feb 06 |
nicklas |
158 |
message = "Project updated"; |
1895 |
02 Feb 06 |
nicklas |
159 |
} |
5501 |
18 Nov 10 |
nicklas |
160 |
JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.item(Item.PROJECT), project); |
7604 |
25 Feb 19 |
nicklas |
161 |
ExtensionsInvoker<OnSaveAction> invoker = EditUtil.useOnSaveExtensions(jspContext); |
5501 |
18 Nov 10 |
nicklas |
162 |
try |
5370 |
23 Jun 10 |
nicklas |
163 |
{ |
5501 |
18 Nov 10 |
nicklas |
164 |
project.setName(Values.getStringOrNull(request.getParameter("name"))); |
5501 |
18 Nov 10 |
nicklas |
165 |
project.setAutoPermission(PermissionUtil.getPermissions(Values.getInt(request.getParameter("autoPermissions"), 31))); |
5501 |
18 Nov 10 |
nicklas |
166 |
project.setDescription(Values.getStringOrNull(request.getParameter("description"))); |
5501 |
18 Nov 10 |
nicklas |
167 |
|
5501 |
18 Nov 10 |
nicklas |
168 |
int permissionTemplateId = Values.getInt(request.getParameter("permissiontemplate_id"), -1); |
5501 |
18 Nov 10 |
nicklas |
169 |
if (permissionTemplateId >= 0) // < 0 = denied or unchanged |
572 |
12 May 05 |
nicklas |
170 |
{ |
5501 |
18 Nov 10 |
nicklas |
171 |
PermissionTemplate pt = permissionTemplateId == 0 ? null : PermissionTemplate.getById(dc, permissionTemplateId); |
5501 |
18 Nov 10 |
nicklas |
172 |
project.setPermissionTemplate(pt); |
7703 |
11 Apr 19 |
nicklas |
173 |
cc.setRecent(Item.PERMISSIONTEMPLATE, pt, maxRecent); |
572 |
12 May 05 |
nicklas |
174 |
} |
5501 |
18 Nov 10 |
nicklas |
175 |
|
5501 |
18 Nov 10 |
nicklas |
176 |
// Members tab |
6320 |
11 Sep 13 |
nicklas |
177 |
String[] modifiedUsers = Values.getString(request.getParameter("!USER")).split(","); |
5501 |
18 Nov 10 |
nicklas |
178 |
for (int i = 0; i < modifiedUsers.length; ++i) |
572 |
12 May 05 |
nicklas |
179 |
{ |
5501 |
18 Nov 10 |
nicklas |
180 |
int userId = Values.getInt(modifiedUsers[i], -1); |
5501 |
18 Nov 10 |
nicklas |
181 |
if (userId != -1) |
5501 |
18 Nov 10 |
nicklas |
182 |
{ |
6320 |
11 Sep 13 |
nicklas |
183 |
Set<Permission> permissions = PermissionUtil.getPermissions(Values.getInt(request.getParameter("USER."+userId), 0)); |
5501 |
18 Nov 10 |
nicklas |
184 |
project.setPermissions(User.getById(dc, userId), permissions); |
5501 |
18 Nov 10 |
nicklas |
185 |
} |
572 |
12 May 05 |
nicklas |
186 |
} |
5501 |
18 Nov 10 |
nicklas |
187 |
|
6320 |
11 Sep 13 |
nicklas |
188 |
String[] modifiedGroups = Values.getString(request.getParameter("!GROUP")).split(","); |
5501 |
18 Nov 10 |
nicklas |
189 |
for (int i = 0; i < modifiedGroups.length; ++i) |
2939 |
20 Nov 06 |
martin |
190 |
{ |
5501 |
18 Nov 10 |
nicklas |
191 |
int groupId = Values.getInt(modifiedGroups[i], -1); |
5501 |
18 Nov 10 |
nicklas |
192 |
if (groupId != -1) |
2941 |
22 Nov 06 |
martin |
193 |
{ |
6320 |
11 Sep 13 |
nicklas |
194 |
Set<Permission> permissions = PermissionUtil.getPermissions(Values.getInt(request.getParameter("GROUP."+groupId), 0)); |
5501 |
18 Nov 10 |
nicklas |
195 |
project.setPermissions(Group.getById(dc, groupId), permissions); |
2941 |
22 Nov 06 |
martin |
196 |
} |
2939 |
20 Nov 06 |
martin |
197 |
} |
5501 |
18 Nov 10 |
nicklas |
198 |
|
5501 |
18 Nov 10 |
nicklas |
199 |
// Default tab |
5813 |
18 Oct 11 |
nicklas |
200 |
Item[] types = { Item.PLATFORM, Item.PLATFORMVARIANT, Item.PROTOCOL, Item.HARDWARE, Item.SOFTWARE, Item.ARRAYDESIGN }; |
5650 |
01 Jun 11 |
nicklas |
201 |
for (Item defaultType : types) |
5501 |
18 Nov 10 |
nicklas |
202 |
{ |
6320 |
11 Sep 13 |
nicklas |
203 |
String[] remove = Values.getString(request.getParameter("-"+defaultType.name())).split(","); |
5650 |
01 Jun 11 |
nicklas |
204 |
for (int i = 0; i < remove.length; ++i) |
5501 |
18 Nov 10 |
nicklas |
205 |
{ |
5650 |
01 Jun 11 |
nicklas |
206 |
int defaultId = Values.getInt(remove[i], -1); |
5650 |
01 Jun 11 |
nicklas |
207 |
if (defaultId != -1) project.removeDefaultItem(defaultType.getById(dc, defaultId)); |
5501 |
18 Nov 10 |
nicklas |
208 |
} |
5650 |
01 Jun 11 |
nicklas |
209 |
|
6320 |
11 Sep 13 |
nicklas |
210 |
String[] add = Values.getString(request.getParameter("+"+defaultType.name())).split(","); |
5650 |
01 Jun 11 |
nicklas |
211 |
for (int i = 0; i < add.length; ++i) |
5650 |
01 Jun 11 |
nicklas |
212 |
{ |
5650 |
01 Jun 11 |
nicklas |
213 |
int defaultId = Values.getInt(add[i], -1); |
5650 |
01 Jun 11 |
nicklas |
214 |
if (defaultId != -1) project.addDefaultItem(defaultType.getById(dc, defaultId)); |
5650 |
01 Jun 11 |
nicklas |
215 |
} |
5501 |
18 Nov 10 |
nicklas |
216 |
} |
5501 |
18 Nov 10 |
nicklas |
217 |
|
5650 |
01 Jun 11 |
nicklas |
218 |
RawDataType rdt = RawDataTypes.getRawDataType( request.getParameter("rawdatatype")); |
5650 |
01 Jun 11 |
nicklas |
219 |
project.setDefaultRawDataType(rdt); |
5650 |
01 Jun 11 |
nicklas |
220 |
|
7199 |
17 Oct 16 |
nicklas |
221 |
// Annotations tab |
7199 |
17 Oct 16 |
nicklas |
222 |
Base.updateAnnotations(dc, project, project, request); |
7199 |
17 Oct 16 |
nicklas |
223 |
|
5501 |
18 Nov 10 |
nicklas |
224 |
// OnSave extensions |
5501 |
18 Nov 10 |
nicklas |
225 |
invoker.render(OnSaveRenderer.ON_SAVE); |
5501 |
18 Nov 10 |
nicklas |
226 |
dc.commit(); |
5501 |
18 Nov 10 |
nicklas |
227 |
invoker.render(OnSaveRenderer.ON_COMMIT); |
2939 |
20 Nov 06 |
martin |
228 |
} |
5501 |
18 Nov 10 |
nicklas |
229 |
catch (Exception ex) |
5501 |
18 Nov 10 |
nicklas |
230 |
{ |
5501 |
18 Nov 10 |
nicklas |
231 |
invoker.render(OnSaveRenderer.onRollback(ex)); |
5501 |
18 Nov 10 |
nicklas |
232 |
throw ex; |
5501 |
18 Nov 10 |
nicklas |
233 |
} |
5501 |
18 Nov 10 |
nicklas |
234 |
finally |
5501 |
18 Nov 10 |
nicklas |
235 |
{ |
5501 |
18 Nov 10 |
nicklas |
236 |
cc.removeObject("item"); |
5501 |
18 Nov 10 |
nicklas |
237 |
} |
1895 |
02 Feb 06 |
nicklas |
238 |
} |
1895 |
02 Feb 06 |
nicklas |
239 |
else if ("DeleteItem".equals(cmd)) |
1895 |
02 Feb 06 |
nicklas |
240 |
{ |
1895 |
02 Feb 06 |
nicklas |
241 |
// Delete a single item and then return to the view page |
7954 |
12 May 21 |
nicklas |
242 |
dc = sc.newDbControl(":Delete "+itemType); |
1895 |
02 Feb 06 |
nicklas |
243 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1895 |
02 Feb 06 |
nicklas |
244 |
RemovableUtil.setRemoved(dc, itemType, Collections.singleton(cc.getId()), true); |
1895 |
02 Feb 06 |
nicklas |
245 |
dc.commit(); |
1895 |
02 Feb 06 |
nicklas |
246 |
redirect = viewPage; |
1895 |
02 Feb 06 |
nicklas |
247 |
} |
1895 |
02 Feb 06 |
nicklas |
248 |
else if ("DeleteItems".equals(cmd)) |
1895 |
02 Feb 06 |
nicklas |
249 |
{ |
1895 |
02 Feb 06 |
nicklas |
250 |
// Delete all selected items on the list page |
7954 |
12 May 21 |
nicklas |
251 |
dc = sc.newDbControl(":Delete "+itemType); |
1895 |
02 Feb 06 |
nicklas |
252 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1895 |
02 Feb 06 |
nicklas |
253 |
int numTotal = cc.getSelected().size(); |
1895 |
02 Feb 06 |
nicklas |
254 |
int numRemoved = RemovableUtil.setRemoved(dc, itemType, cc.getSelected(), true); |
1895 |
02 Feb 06 |
nicklas |
255 |
dc.commit(); |
1895 |
02 Feb 06 |
nicklas |
256 |
if (numTotal != numRemoved) |
572 |
12 May 05 |
nicklas |
257 |
{ |
1895 |
02 Feb 06 |
nicklas |
258 |
message = (numRemoved == 0 ? "No" : "Only "+numRemoved+" of "+numTotal) + " items could be deleted, because you have no DELETE permission"; |
572 |
12 May 05 |
nicklas |
259 |
} |
6192 |
31 Oct 12 |
nicklas |
260 |
redirect = listPage; |
1895 |
02 Feb 06 |
nicklas |
261 |
} |
1895 |
02 Feb 06 |
nicklas |
262 |
else if ("RestoreItem".equals(cmd)) |
1895 |
02 Feb 06 |
nicklas |
263 |
{ |
1895 |
02 Feb 06 |
nicklas |
264 |
// Restore a single item and then return to the view page |
7954 |
12 May 21 |
nicklas |
265 |
dc = sc.newDbControl(":Restore "+itemType); |
1895 |
02 Feb 06 |
nicklas |
266 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1895 |
02 Feb 06 |
nicklas |
267 |
RemovableUtil.setRemoved(dc, itemType, Collections.singleton(cc.getId()), false); |
1895 |
02 Feb 06 |
nicklas |
268 |
dc.commit(); |
1895 |
02 Feb 06 |
nicklas |
269 |
redirect = viewPage; |
1895 |
02 Feb 06 |
nicklas |
270 |
} |
1895 |
02 Feb 06 |
nicklas |
271 |
else if ("RestoreItems".equals(cmd)) |
1895 |
02 Feb 06 |
nicklas |
272 |
{ |
1895 |
02 Feb 06 |
nicklas |
273 |
// Restore all selected items on the list page |
7954 |
12 May 21 |
nicklas |
274 |
dc = sc.newDbControl(":Restore "+itemType); |
1895 |
02 Feb 06 |
nicklas |
275 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1895 |
02 Feb 06 |
nicklas |
276 |
int numTotal = cc.getSelected().size(); |
1895 |
02 Feb 06 |
nicklas |
277 |
int numRemoved = RemovableUtil.setRemoved(dc, itemType, cc.getSelected(), false); |
1895 |
02 Feb 06 |
nicklas |
278 |
dc.commit(); |
1895 |
02 Feb 06 |
nicklas |
279 |
if (numTotal != numRemoved) |
572 |
12 May 05 |
nicklas |
280 |
{ |
2528 |
15 Aug 06 |
martin |
281 |
message = (numRemoved == 0 ? "No" : "Only "+numRemoved+" of "+numTotal) + " items could be restored, because you have no WRITE permission"; |
572 |
12 May 05 |
nicklas |
282 |
} |
6192 |
31 Oct 12 |
nicklas |
283 |
redirect = listPage; |
1895 |
02 Feb 06 |
nicklas |
284 |
} |
4578 |
13 Oct 08 |
martin |
285 |
else if ("SetOwnerOfItem".equals(cmd)) |
2918 |
15 Nov 06 |
nicklas |
286 |
{ |
4578 |
13 Oct 08 |
martin |
287 |
// Change owner of items selected on a list page |
7954 |
12 May 21 |
nicklas |
288 |
dc = sc.newDbControl(":Set owner of "+itemType); |
2918 |
15 Nov 06 |
nicklas |
289 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
4587 |
15 Oct 08 |
martin |
290 |
OwnedItem item = (OwnedItem)itemType.getById(dc, cc.getId()); |
4587 |
15 Oct 08 |
martin |
291 |
cc.setObject("OwnedItems", Collections.singleton(item)); |
4578 |
13 Oct 08 |
martin |
292 |
redirect = "../../common/ownership/ownership.jsp?ID="+ID+"&item_type="+itemType.name(); |
2918 |
15 Nov 06 |
nicklas |
293 |
} |
4578 |
13 Oct 08 |
martin |
294 |
else if ("SetOwnerOfItems".equals(cmd)) |
2918 |
15 Nov 06 |
nicklas |
295 |
{ |
4578 |
13 Oct 08 |
martin |
296 |
// Change owner of items selected on a list page |
7954 |
12 May 21 |
nicklas |
297 |
dc = sc.newDbControl(":Set owner of "+itemType); |
2918 |
15 Nov 06 |
nicklas |
298 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
4587 |
15 Oct 08 |
martin |
299 |
Set<OwnedItem> items = new HashSet<OwnedItem>(); |
4587 |
15 Oct 08 |
martin |
300 |
for (Integer id : cc.getSelected()) |
4587 |
15 Oct 08 |
martin |
301 |
{ |
4587 |
15 Oct 08 |
martin |
302 |
if (id != null) items.add((OwnedItem)itemType.getById(dc, id)); |
4587 |
15 Oct 08 |
martin |
303 |
} |
4587 |
15 Oct 08 |
martin |
304 |
dc.close(); |
4587 |
15 Oct 08 |
martin |
305 |
cc.setObject("OwnedItems", items); |
4578 |
13 Oct 08 |
martin |
306 |
redirect = "../../common/ownership/ownership.jsp?ID="+ID+"&item_type="+itemType.name(); |
2918 |
15 Nov 06 |
nicklas |
307 |
} |
1895 |
02 Feb 06 |
nicklas |
308 |
else if ("ExportItems".equals(cmd)) |
1895 |
02 Feb 06 |
nicklas |
309 |
{ |
1895 |
02 Feb 06 |
nicklas |
310 |
// Run an export plugin in a list context |
1895 |
02 Feb 06 |
nicklas |
311 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1895 |
02 Feb 06 |
nicklas |
312 |
final ItemQuery<Project> query = Project.getQuery(); |
7954 |
12 May 21 |
nicklas |
313 |
dc = sc.newDbControl(":Export "+itemType); |
7914 |
23 Feb 21 |
nicklas |
314 |
JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.list(itemType), null); |
7914 |
23 Feb 21 |
nicklas |
315 |
cc.configureQuery(dc, query, jspContext, true); |
6040 |
30 Mar 12 |
nicklas |
316 |
cc.setQuery(query); |
7604 |
25 Feb 19 |
nicklas |
317 |
ExtensionsInvoker<ListColumnAction<Project,?>> listInvoker = ListColumnUtil.useExtensions(jspContext); |
7604 |
25 Feb 19 |
nicklas |
318 |
listInvoker.render(new ListColumnExportRenderer<Project>(cc)); |
5590 |
16 Mar 11 |
nicklas |
319 |
dc.close(); |
1895 |
02 Feb 06 |
nicklas |
320 |
redirect = "../../common/export/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=LIST&title=Export+projects"; |
1895 |
02 Feb 06 |
nicklas |
321 |
} |
1895 |
02 Feb 06 |
nicklas |
322 |
else if ("ExportItem".equals(cmd)) |
1895 |
02 Feb 06 |
nicklas |
323 |
{ |
1895 |
02 Feb 06 |
nicklas |
324 |
// Run an export plugin in single-item context |
1895 |
02 Feb 06 |
nicklas |
325 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1895 |
02 Feb 06 |
nicklas |
326 |
redirect = "../../common/export/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=ITEM&title=Export+project"; |
1895 |
02 Feb 06 |
nicklas |
327 |
} |
1895 |
02 Feb 06 |
nicklas |
328 |
else if ("ImportItems".equals(cmd)) |
1895 |
02 Feb 06 |
nicklas |
329 |
{ |
1895 |
02 Feb 06 |
nicklas |
330 |
// Run an import plugin in a list context |
1895 |
02 Feb 06 |
nicklas |
331 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1895 |
02 Feb 06 |
nicklas |
332 |
final ItemQuery<Project> query = Project.getQuery(); |
7954 |
12 May 21 |
nicklas |
333 |
dc = sc.newDbControl(":Import "+itemType); |
7914 |
23 Feb 21 |
nicklas |
334 |
JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.list(itemType), null); |
7914 |
23 Feb 21 |
nicklas |
335 |
cc.configureQuery(dc, query, jspContext, true); |
5590 |
16 Mar 11 |
nicklas |
336 |
dc.close(); |
1895 |
02 Feb 06 |
nicklas |
337 |
cc.setQuery(query); |
1895 |
02 Feb 06 |
nicklas |
338 |
redirect = "../../common/import/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=LIST&title=Import+projects"; |
1895 |
02 Feb 06 |
nicklas |
339 |
} |
1895 |
02 Feb 06 |
nicklas |
340 |
else if ("ImportItem".equals(cmd)) |
1895 |
02 Feb 06 |
nicklas |
341 |
{ |
1895 |
02 Feb 06 |
nicklas |
342 |
// Run an import plugin in single-item context |
1895 |
02 Feb 06 |
nicklas |
343 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1895 |
02 Feb 06 |
nicklas |
344 |
redirect = "../../common/import/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=ITEM&title=Import+project"; |
1895 |
02 Feb 06 |
nicklas |
345 |
} |
1895 |
02 Feb 06 |
nicklas |
346 |
else if ("RunListPlugin".equals(cmd)) |
1895 |
02 Feb 06 |
nicklas |
347 |
{ |
1895 |
02 Feb 06 |
nicklas |
348 |
// Run another plugin in a list context |
1895 |
02 Feb 06 |
nicklas |
349 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1895 |
02 Feb 06 |
nicklas |
350 |
final ItemQuery<Project> query = Project.getQuery(); |
7954 |
12 May 21 |
nicklas |
351 |
dc = sc.newDbControl(":Run plugin "+itemType); |
7914 |
23 Feb 21 |
nicklas |
352 |
JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.list(itemType), null); |
7914 |
23 Feb 21 |
nicklas |
353 |
cc.configureQuery(dc, query, jspContext, true); |
5590 |
16 Mar 11 |
nicklas |
354 |
dc.close(); |
1895 |
02 Feb 06 |
nicklas |
355 |
cc.setQuery(query); |
1895 |
02 Feb 06 |
nicklas |
356 |
redirect = "../../common/plugin/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=LIST&main_type=OTHER&title=Run+plugin"; |
1895 |
02 Feb 06 |
nicklas |
357 |
} |
1895 |
02 Feb 06 |
nicklas |
358 |
else if ("RunPlugin".equals(cmd)) |
1895 |
02 Feb 06 |
nicklas |
359 |
{ |
1895 |
02 Feb 06 |
nicklas |
360 |
// Run another plugin in single-item context |
1895 |
02 Feb 06 |
nicklas |
361 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1895 |
02 Feb 06 |
nicklas |
362 |
redirect = "../../common/plugin/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=ITEM&main_type=OTHER&title=Run+plugin"; |
1895 |
02 Feb 06 |
nicklas |
363 |
} |
1895 |
02 Feb 06 |
nicklas |
364 |
else |
1895 |
02 Feb 06 |
nicklas |
365 |
{ |
1895 |
02 Feb 06 |
nicklas |
366 |
throw new WebException("popup", "Invalid command", "The command {1} is not recognised as a valid command.", cmd); |
1895 |
02 Feb 06 |
nicklas |
367 |
} |
572 |
12 May 05 |
nicklas |
368 |
} |
572 |
12 May 05 |
nicklas |
369 |
finally |
572 |
12 May 05 |
nicklas |
370 |
{ |
572 |
12 May 05 |
nicklas |
371 |
if (dc != null) dc.close(); |
572 |
12 May 05 |
nicklas |
372 |
} |
1895 |
02 Feb 06 |
nicklas |
373 |
|
1895 |
02 Feb 06 |
nicklas |
374 |
if (forward != null) |
1895 |
02 Feb 06 |
nicklas |
375 |
{ |
6192 |
31 Oct 12 |
nicklas |
376 |
sc.setSessionSetting("alert-message", message); |
1895 |
02 Feb 06 |
nicklas |
377 |
pageContext.forward(forward); |
1895 |
02 Feb 06 |
nicklas |
378 |
} |
1895 |
02 Feb 06 |
nicklas |
379 |
else if (redirect != null) |
1895 |
02 Feb 06 |
nicklas |
380 |
{ |
6192 |
31 Oct 12 |
nicklas |
381 |
sc.setSessionSetting("alert-message", message); |
1895 |
02 Feb 06 |
nicklas |
382 |
response.sendRedirect(redirect); |
1895 |
02 Feb 06 |
nicklas |
383 |
} |
1895 |
02 Feb 06 |
nicklas |
384 |
else if (message == null) |
1895 |
02 Feb 06 |
nicklas |
385 |
{ |
1895 |
02 Feb 06 |
nicklas |
386 |
response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&wait=0"); |
1895 |
02 Feb 06 |
nicklas |
387 |
} |
1895 |
02 Feb 06 |
nicklas |
388 |
else |
1895 |
02 Feb 06 |
nicklas |
389 |
{ |
1895 |
02 Feb 06 |
nicklas |
390 |
response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&message="+HTML.urlEncode(message)); |
1895 |
02 Feb 06 |
nicklas |
391 |
} |
1895 |
02 Feb 06 |
nicklas |
392 |
%> |
1895 |
02 Feb 06 |
nicklas |
393 |
|