1619 |
16 Nov 05 |
nicklas |
1 |
<%-- $Id$ |
1619 |
16 Nov 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 |
1619 |
16 Nov 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/ |
1619 |
16 Nov 05 |
nicklas |
8 |
|
1619 |
16 Nov 05 |
nicklas |
9 |
BASE is free software; you can redistribute it and/or |
1619 |
16 Nov 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 |
1619 |
16 Nov 05 |
nicklas |
12 |
of the License, or (at your option) any later version. |
1619 |
16 Nov 05 |
nicklas |
13 |
|
1619 |
16 Nov 05 |
nicklas |
14 |
BASE is distributed in the hope that it will be useful, |
1619 |
16 Nov 05 |
nicklas |
15 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
1619 |
16 Nov 05 |
nicklas |
16 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1619 |
16 Nov 05 |
nicklas |
17 |
GNU General Public License for more details. |
1619 |
16 Nov 05 |
nicklas |
18 |
|
1619 |
16 Nov 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/>. |
1619 |
16 Nov 05 |
nicklas |
21 |
------------------------------------------------------------------ |
1619 |
16 Nov 05 |
nicklas |
22 |
|
1619 |
16 Nov 05 |
nicklas |
23 |
@author Nicklas |
1619 |
16 Nov 05 |
nicklas |
24 |
@version 2.0 |
1619 |
16 Nov 05 |
nicklas |
25 |
--%> |
5426 |
24 Sep 10 |
nicklas |
26 |
<%@ page pageEncoding="UTF-8" session="false" |
1619 |
16 Nov 05 |
nicklas |
27 |
import="net.sf.basedb.core.SessionControl" |
1619 |
16 Nov 05 |
nicklas |
28 |
import="net.sf.basedb.core.DbControl" |
1619 |
16 Nov 05 |
nicklas |
29 |
import="net.sf.basedb.core.Item" |
1619 |
16 Nov 05 |
nicklas |
30 |
import="net.sf.basedb.core.Include" |
1619 |
16 Nov 05 |
nicklas |
31 |
import="net.sf.basedb.core.Job" |
7307 |
07 Mar 17 |
nicklas |
32 |
import="net.sf.basedb.core.Project" |
1619 |
16 Nov 05 |
nicklas |
33 |
import="net.sf.basedb.core.ItemQuery" |
1619 |
16 Nov 05 |
nicklas |
34 |
import="net.sf.basedb.core.ItemResultIterator" |
1619 |
16 Nov 05 |
nicklas |
35 |
import="net.sf.basedb.core.Permission" |
1881 |
01 Feb 06 |
nicklas |
36 |
import="net.sf.basedb.core.ItemContext" |
1881 |
01 Feb 06 |
nicklas |
37 |
import="net.sf.basedb.core.MultiPermissions" |
4587 |
15 Oct 08 |
martin |
38 |
import="net.sf.basedb.core.OwnedItem" |
1881 |
01 Feb 06 |
nicklas |
39 |
import="net.sf.basedb.core.PermissionDeniedException" |
1881 |
01 Feb 06 |
nicklas |
40 |
import="net.sf.basedb.core.ItemAlreadyExistsException" |
4093 |
18 Jan 08 |
enell |
41 |
import="net.sf.basedb.core.signal.SignalTransporter" |
4093 |
18 Jan 08 |
enell |
42 |
import="net.sf.basedb.core.signal.Signal" |
1881 |
01 Feb 06 |
nicklas |
43 |
import="net.sf.basedb.util.RemovableUtil" |
1881 |
01 Feb 06 |
nicklas |
44 |
import="net.sf.basedb.util.ShareableUtil" |
2918 |
15 Nov 06 |
nicklas |
45 |
import="net.sf.basedb.util.OwnableUtil" |
1619 |
16 Nov 05 |
nicklas |
46 |
import="net.sf.basedb.clients.web.Base" |
1881 |
01 Feb 06 |
nicklas |
47 |
import="net.sf.basedb.clients.web.WebException" |
2753 |
20 Oct 06 |
nicklas |
48 |
import="net.sf.basedb.util.Values" |
7307 |
07 Mar 17 |
nicklas |
49 |
import="net.sf.basedb.util.formatter.NameableFormatter" |
1619 |
16 Nov 05 |
nicklas |
50 |
import="net.sf.basedb.clients.web.util.HTML" |
6040 |
30 Mar 12 |
nicklas |
51 |
import="net.sf.basedb.core.plugin.GuiContext" |
6040 |
30 Mar 12 |
nicklas |
52 |
import="net.sf.basedb.util.extensions.ExtensionsInvoker" |
7307 |
07 Mar 17 |
nicklas |
53 |
import="net.sf.basedb.clients.web.plugins.ExportedProperty" |
7307 |
07 Mar 17 |
nicklas |
54 |
import="net.sf.basedb.clients.web.plugins.DataLoader" |
6040 |
30 Mar 12 |
nicklas |
55 |
import="net.sf.basedb.clients.web.extensions.ExtensionsControl" |
6040 |
30 Mar 12 |
nicklas |
56 |
import="net.sf.basedb.clients.web.extensions.JspContext" |
6040 |
30 Mar 12 |
nicklas |
57 |
import="net.sf.basedb.clients.web.extensions.list.ListColumnExportRenderer" |
7604 |
25 Feb 19 |
nicklas |
58 |
import="net.sf.basedb.clients.web.extensions.list.ListColumnAction" |
6040 |
30 Mar 12 |
nicklas |
59 |
import="net.sf.basedb.clients.web.extensions.list.ListColumnUtil" |
1881 |
01 Feb 06 |
nicklas |
60 |
import="java.util.Enumeration" |
1881 |
01 Feb 06 |
nicklas |
61 |
import="java.util.Set" |
1881 |
01 Feb 06 |
nicklas |
62 |
import="java.util.HashSet" |
1881 |
01 Feb 06 |
nicklas |
63 |
import="java.util.List" |
1881 |
01 Feb 06 |
nicklas |
64 |
import="java.util.ArrayList" |
6600 |
17 Nov 14 |
nicklas |
65 |
import="java.util.Collection" |
1881 |
01 Feb 06 |
nicklas |
66 |
import="java.util.Collections" |
1619 |
16 Nov 05 |
nicklas |
67 |
%> |
1619 |
16 Nov 05 |
nicklas |
68 |
<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> |
1619 |
16 Nov 05 |
nicklas |
69 |
<%! |
7307 |
07 Mar 17 |
nicklas |
70 |
|
7307 |
07 Mar 17 |
nicklas |
71 |
private static void registerExportUtils(ItemContext cc) |
7307 |
07 Mar 17 |
nicklas |
72 |
{ |
7307 |
07 Mar 17 |
nicklas |
73 |
// Register formatters |
7307 |
07 Mar 17 |
nicklas |
74 |
cc.setObject("export.formatter.activeProjectId", new NameableFormatter()); |
7307 |
07 Mar 17 |
nicklas |
75 |
|
7307 |
07 Mar 17 |
nicklas |
76 |
// Register dataloaders |
7307 |
07 Mar 17 |
nicklas |
77 |
cc.setObject("export.dataloader.activeProjectId", |
7307 |
07 Mar 17 |
nicklas |
78 |
new DataLoader<Job>() |
7307 |
07 Mar 17 |
nicklas |
79 |
{ |
7307 |
07 Mar 17 |
nicklas |
80 |
@Override |
7307 |
07 Mar 17 |
nicklas |
81 |
public Object getData(DbControl dc, ExportedProperty exportedProperty, Job job) |
7307 |
07 Mar 17 |
nicklas |
82 |
{ |
7307 |
07 Mar 17 |
nicklas |
83 |
Project p = null; |
7307 |
07 Mar 17 |
nicklas |
84 |
if (job.getActiveProjectId() != 0) |
7307 |
07 Mar 17 |
nicklas |
85 |
{ |
7307 |
07 Mar 17 |
nicklas |
86 |
try |
7307 |
07 Mar 17 |
nicklas |
87 |
{ |
7307 |
07 Mar 17 |
nicklas |
88 |
p = Project.getById(dc, job.getActiveProjectId()); |
7307 |
07 Mar 17 |
nicklas |
89 |
} |
7307 |
07 Mar 17 |
nicklas |
90 |
catch (Exception ex) |
7307 |
07 Mar 17 |
nicklas |
91 |
{} |
7307 |
07 Mar 17 |
nicklas |
92 |
} |
7307 |
07 Mar 17 |
nicklas |
93 |
return p; |
7307 |
07 Mar 17 |
nicklas |
94 |
} |
7307 |
07 Mar 17 |
nicklas |
95 |
} |
7307 |
07 Mar 17 |
nicklas |
96 |
); |
7307 |
07 Mar 17 |
nicklas |
97 |
} |
7307 |
07 Mar 17 |
nicklas |
98 |
|
5406 |
13 Sep 10 |
nicklas |
99 |
private static final ItemContext defaultContext = Base.createDefaultContext("scheduled", "name,pluginType,scheduled,percentComplete,status,statusMessage,description"); |
5406 |
13 Sep 10 |
nicklas |
100 |
{ |
5406 |
13 Sep 10 |
nicklas |
101 |
defaultContext.setSortDirection(ItemContext.SortDirection.DESC); |
5406 |
13 Sep 10 |
nicklas |
102 |
} |
1881 |
01 Feb 06 |
nicklas |
103 |
private static final Item itemType = Item.JOB; |
1619 |
16 Nov 05 |
nicklas |
104 |
%> |
1619 |
16 Nov 05 |
nicklas |
105 |
<% |
1881 |
01 Feb 06 |
nicklas |
106 |
final SessionControl sc = Base.getExistingSessionControl(pageContext, true); |
1619 |
16 Nov 05 |
nicklas |
107 |
final String ID = sc.getId(); |
1881 |
01 Feb 06 |
nicklas |
108 |
final String cmd = request.getParameter("cmd"); |
1881 |
01 Feb 06 |
nicklas |
109 |
final String root = request.getContextPath()+"/"; |
1881 |
01 Feb 06 |
nicklas |
110 |
final String mode = request.getParameter("mode"); |
1881 |
01 Feb 06 |
nicklas |
111 |
final String callback = request.getParameter("callback"); |
1881 |
01 Feb 06 |
nicklas |
112 |
final String itemId = request.getParameter("item_id"); |
1881 |
01 Feb 06 |
nicklas |
113 |
final String listPage = "list_jobs.jsp?ID="+ID |
1881 |
01 Feb 06 |
nicklas |
114 |
+(mode == null ? "" : "&mode="+mode) |
1881 |
01 Feb 06 |
nicklas |
115 |
+(callback == null ? "" : "&callback="+callback) |
1881 |
01 Feb 06 |
nicklas |
116 |
+(itemId == null ? "" : "&item_id="+itemId); |
1881 |
01 Feb 06 |
nicklas |
117 |
final String viewPage = "view_job.jsp?ID="+ID; |
1881 |
01 Feb 06 |
nicklas |
118 |
//final String editPage = "edit_job.jsp?ID="+ID; |
1619 |
16 Nov 05 |
nicklas |
119 |
|
1881 |
01 Feb 06 |
nicklas |
120 |
String forward = null; |
1881 |
01 Feb 06 |
nicklas |
121 |
String redirect = null; |
1881 |
01 Feb 06 |
nicklas |
122 |
String message = null; |
1881 |
01 Feb 06 |
nicklas |
123 |
DbControl dc = null; |
1881 |
01 Feb 06 |
nicklas |
124 |
|
1619 |
16 Nov 05 |
nicklas |
125 |
try |
1619 |
16 Nov 05 |
nicklas |
126 |
{ |
1881 |
01 Feb 06 |
nicklas |
127 |
if (cmd == null || "List".equals(cmd)) |
1881 |
01 Feb 06 |
nicklas |
128 |
{ |
1881 |
01 Feb 06 |
nicklas |
129 |
// Display the list page without updatinging the current context |
2811 |
26 Oct 06 |
nicklas |
130 |
Base.getAndSetCurrentContext(sc, itemType, null, defaultContext, true); |
1881 |
01 Feb 06 |
nicklas |
131 |
redirect = listPage; |
1881 |
01 Feb 06 |
nicklas |
132 |
} |
1881 |
01 Feb 06 |
nicklas |
133 |
else if ("UpdateContext".equals(cmd)) |
1881 |
01 Feb 06 |
nicklas |
134 |
{ |
1881 |
01 Feb 06 |
nicklas |
135 |
// Display the list page after updating the current context from the request parameters |
1881 |
01 Feb 06 |
nicklas |
136 |
Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1881 |
01 Feb 06 |
nicklas |
137 |
redirect = listPage; |
1881 |
01 Feb 06 |
nicklas |
138 |
} |
1881 |
01 Feb 06 |
nicklas |
139 |
else if ("LoadContext".equals(cmd)) |
1881 |
01 Feb 06 |
nicklas |
140 |
{ |
1881 |
01 Feb 06 |
nicklas |
141 |
// Display the list page after loading a saved context |
1881 |
01 Feb 06 |
nicklas |
142 |
int contextId = Values.getInt(request.getParameter("context")); |
1881 |
01 Feb 06 |
nicklas |
143 |
Base.loadContext(sc, contextId, defaultContext); |
1881 |
01 Feb 06 |
nicklas |
144 |
redirect = listPage; |
1881 |
01 Feb 06 |
nicklas |
145 |
} |
1881 |
01 Feb 06 |
nicklas |
146 |
|
1881 |
01 Feb 06 |
nicklas |
147 |
else if ("ViewItem".equals(cmd)) |
1881 |
01 Feb 06 |
nicklas |
148 |
{ |
1881 |
01 Feb 06 |
nicklas |
149 |
// Display the view page for a single item (opens in a popup) |
1881 |
01 Feb 06 |
nicklas |
150 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1881 |
01 Feb 06 |
nicklas |
151 |
forward = viewPage; |
1881 |
01 Feb 06 |
nicklas |
152 |
} |
1881 |
01 Feb 06 |
nicklas |
153 |
/* |
1881 |
01 Feb 06 |
nicklas |
154 |
else if ("EditItem".equals(cmd)) |
1881 |
01 Feb 06 |
nicklas |
155 |
{ |
1881 |
01 Feb 06 |
nicklas |
156 |
// Display the edit page for a single item (should be opened in a popup) |
1881 |
01 Feb 06 |
nicklas |
157 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1881 |
01 Feb 06 |
nicklas |
158 |
redirect = editPage; |
1881 |
01 Feb 06 |
nicklas |
159 |
} |
1881 |
01 Feb 06 |
nicklas |
160 |
*/ |
1881 |
01 Feb 06 |
nicklas |
161 |
else if ("DeleteItem".equals(cmd)) |
1881 |
01 Feb 06 |
nicklas |
162 |
{ |
1881 |
01 Feb 06 |
nicklas |
163 |
// Delete a single item and then return to the view page |
7954 |
12 May 21 |
nicklas |
164 |
dc = sc.newDbControl(":Delete "+itemType); |
1881 |
01 Feb 06 |
nicklas |
165 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1881 |
01 Feb 06 |
nicklas |
166 |
RemovableUtil.setRemoved(dc, itemType, Collections.singleton(cc.getId()), true); |
1881 |
01 Feb 06 |
nicklas |
167 |
dc.commit(); |
1881 |
01 Feb 06 |
nicklas |
168 |
redirect = viewPage; |
1881 |
01 Feb 06 |
nicklas |
169 |
} |
1881 |
01 Feb 06 |
nicklas |
170 |
else if ("DeleteItems".equals(cmd)) |
1881 |
01 Feb 06 |
nicklas |
171 |
{ |
1881 |
01 Feb 06 |
nicklas |
172 |
// Delete all selected items on the list page |
7954 |
12 May 21 |
nicklas |
173 |
dc = sc.newDbControl(":Delete "+itemType); |
1881 |
01 Feb 06 |
nicklas |
174 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1881 |
01 Feb 06 |
nicklas |
175 |
int numTotal = cc.getSelected().size(); |
1881 |
01 Feb 06 |
nicklas |
176 |
int numRemoved = RemovableUtil.setRemoved(dc, itemType, cc.getSelected(), true); |
1881 |
01 Feb 06 |
nicklas |
177 |
dc.commit(); |
1881 |
01 Feb 06 |
nicklas |
178 |
if (numTotal != numRemoved) |
1619 |
16 Nov 05 |
nicklas |
179 |
{ |
1881 |
01 Feb 06 |
nicklas |
180 |
message = (numRemoved == 0 ? "No" : "Only "+numRemoved+" of "+numTotal) + " items could be deleted, because you have no DELETE permission"; |
1619 |
16 Nov 05 |
nicklas |
181 |
} |
6192 |
31 Oct 12 |
nicklas |
182 |
redirect = listPage; |
1881 |
01 Feb 06 |
nicklas |
183 |
} |
1881 |
01 Feb 06 |
nicklas |
184 |
else if ("RestoreItem".equals(cmd)) |
1881 |
01 Feb 06 |
nicklas |
185 |
{ |
1881 |
01 Feb 06 |
nicklas |
186 |
// Restore a single item and then return to the view page |
7954 |
12 May 21 |
nicklas |
187 |
dc = sc.newDbControl(":Restore "+itemType); |
1881 |
01 Feb 06 |
nicklas |
188 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1881 |
01 Feb 06 |
nicklas |
189 |
RemovableUtil.setRemoved(dc, itemType, Collections.singleton(cc.getId()), false); |
1881 |
01 Feb 06 |
nicklas |
190 |
dc.commit(); |
1881 |
01 Feb 06 |
nicklas |
191 |
redirect = viewPage; |
1881 |
01 Feb 06 |
nicklas |
192 |
} |
1881 |
01 Feb 06 |
nicklas |
193 |
else if ("RestoreItems".equals(cmd)) |
1881 |
01 Feb 06 |
nicklas |
194 |
{ |
1881 |
01 Feb 06 |
nicklas |
195 |
// Restore all selected items on the list page |
7954 |
12 May 21 |
nicklas |
196 |
dc = sc.newDbControl(":Restore "+itemType); |
1881 |
01 Feb 06 |
nicklas |
197 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1881 |
01 Feb 06 |
nicklas |
198 |
int numTotal = cc.getSelected().size(); |
1881 |
01 Feb 06 |
nicklas |
199 |
int numRemoved = RemovableUtil.setRemoved(dc, itemType, cc.getSelected(), false); |
1881 |
01 Feb 06 |
nicklas |
200 |
dc.commit(); |
1881 |
01 Feb 06 |
nicklas |
201 |
if (numTotal != numRemoved) |
1619 |
16 Nov 05 |
nicklas |
202 |
{ |
2528 |
15 Aug 06 |
martin |
203 |
message = (numRemoved == 0 ? "No" : "Only "+numRemoved+" of "+numTotal) + " items could be restored, because you have no WRITE permission"; |
1619 |
16 Nov 05 |
nicklas |
204 |
} |
6192 |
31 Oct 12 |
nicklas |
205 |
redirect = listPage; |
1881 |
01 Feb 06 |
nicklas |
206 |
} |
6447 |
15 Apr 14 |
nicklas |
207 |
else if ("ShareItem".equals(cmd)) |
6447 |
15 Apr 14 |
nicklas |
208 |
{ |
6447 |
15 Apr 14 |
nicklas |
209 |
// Display a popup window for sharing a single item |
7954 |
12 May 21 |
nicklas |
210 |
dc = sc.newDbControl(":Share "+itemType); |
6447 |
15 Apr 14 |
nicklas |
211 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
6447 |
15 Apr 14 |
nicklas |
212 |
MultiPermissions permissions = ShareableUtil.getMultiPermissions(dc, itemType, Collections.singleton(cc.getId())); |
6447 |
15 Apr 14 |
nicklas |
213 |
dc.close(); |
6447 |
15 Apr 14 |
nicklas |
214 |
cc.setObject("MultiPermissions", permissions); |
6447 |
15 Apr 14 |
nicklas |
215 |
redirect = "../../common/share/share.jsp?ID="+ID+"&item_type="+itemType.name(); |
6447 |
15 Apr 14 |
nicklas |
216 |
} |
6447 |
15 Apr 14 |
nicklas |
217 |
else if ("ShareItems".equals(cmd)) |
6447 |
15 Apr 14 |
nicklas |
218 |
{ |
6447 |
15 Apr 14 |
nicklas |
219 |
// Display a popup window for sharing all selected items on the list page |
7954 |
12 May 21 |
nicklas |
220 |
dc = sc.newDbControl(":Share "+itemType); |
6447 |
15 Apr 14 |
nicklas |
221 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
6447 |
15 Apr 14 |
nicklas |
222 |
MultiPermissions permissions = ShareableUtil.getMultiPermissions(dc, itemType, cc.getSelected()); |
6447 |
15 Apr 14 |
nicklas |
223 |
dc.close(); |
6447 |
15 Apr 14 |
nicklas |
224 |
cc.setObject("MultiPermissions", permissions); |
6447 |
15 Apr 14 |
nicklas |
225 |
redirect = "../../common/share/share.jsp?ID="+ID+"&item_type="+itemType.name(); |
6447 |
15 Apr 14 |
nicklas |
226 |
} |
4578 |
13 Oct 08 |
martin |
227 |
else if ("SetOwnerOfItem".equals(cmd)) |
2918 |
15 Nov 06 |
nicklas |
228 |
{ |
4578 |
13 Oct 08 |
martin |
229 |
// Change owner of items selected on a list page |
7954 |
12 May 21 |
nicklas |
230 |
dc = sc.newDbControl(":Set owner of "+itemType); |
2918 |
15 Nov 06 |
nicklas |
231 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
4587 |
15 Oct 08 |
martin |
232 |
OwnedItem item = (OwnedItem)itemType.getById(dc, cc.getId()); |
4587 |
15 Oct 08 |
martin |
233 |
cc.setObject("OwnedItems", Collections.singleton(item)); |
4578 |
13 Oct 08 |
martin |
234 |
redirect = "../../common/ownership/ownership.jsp?ID="+ID+"&item_type="+itemType.name(); |
2918 |
15 Nov 06 |
nicklas |
235 |
} |
4578 |
13 Oct 08 |
martin |
236 |
else if ("SetOwnerOfItems".equals(cmd)) |
2918 |
15 Nov 06 |
nicklas |
237 |
{ |
4578 |
13 Oct 08 |
martin |
238 |
// Change owner of items selected on a list page |
7954 |
12 May 21 |
nicklas |
239 |
dc = sc.newDbControl(":Set owner of "+itemType); |
2918 |
15 Nov 06 |
nicklas |
240 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
4587 |
15 Oct 08 |
martin |
241 |
Set<OwnedItem> items = new HashSet<OwnedItem>(); |
4587 |
15 Oct 08 |
martin |
242 |
for (Integer id : cc.getSelected()) |
4587 |
15 Oct 08 |
martin |
243 |
{ |
4587 |
15 Oct 08 |
martin |
244 |
if (id != null) items.add((OwnedItem)itemType.getById(dc, id)); |
4587 |
15 Oct 08 |
martin |
245 |
} |
4587 |
15 Oct 08 |
martin |
246 |
dc.close(); |
4587 |
15 Oct 08 |
martin |
247 |
cc.setObject("OwnedItems", items); |
4578 |
13 Oct 08 |
martin |
248 |
redirect = "../../common/ownership/ownership.jsp?ID="+ID+"&item_type="+itemType.name(); |
2918 |
15 Nov 06 |
nicklas |
249 |
} |
1881 |
01 Feb 06 |
nicklas |
250 |
else if ("ExportItems".equals(cmd)) |
1881 |
01 Feb 06 |
nicklas |
251 |
{ |
1881 |
01 Feb 06 |
nicklas |
252 |
// Run an export plugin in a list context |
1881 |
01 Feb 06 |
nicklas |
253 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1881 |
01 Feb 06 |
nicklas |
254 |
final ItemQuery<Job> query = Job.getQuery(); |
7954 |
12 May 21 |
nicklas |
255 |
dc = sc.newDbControl(":Export "+itemType); |
7914 |
23 Feb 21 |
nicklas |
256 |
JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.list(itemType), null); |
7914 |
23 Feb 21 |
nicklas |
257 |
cc.configureQuery(dc, query, jspContext, true); |
7307 |
07 Mar 17 |
nicklas |
258 |
registerExportUtils(cc); |
6040 |
30 Mar 12 |
nicklas |
259 |
cc.setQuery(query); |
7604 |
25 Feb 19 |
nicklas |
260 |
ExtensionsInvoker<ListColumnAction<Job,?>> listInvoker = ListColumnUtil.useExtensions(jspContext); |
7604 |
25 Feb 19 |
nicklas |
261 |
listInvoker.render(new ListColumnExportRenderer<Job>(cc)); |
5590 |
16 Mar 11 |
nicklas |
262 |
dc.close(); |
1881 |
01 Feb 06 |
nicklas |
263 |
redirect = "../../common/export/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=LIST&title=Export+jobs"; |
1881 |
01 Feb 06 |
nicklas |
264 |
} |
1881 |
01 Feb 06 |
nicklas |
265 |
else if ("ExportItem".equals(cmd)) |
1881 |
01 Feb 06 |
nicklas |
266 |
{ |
1881 |
01 Feb 06 |
nicklas |
267 |
// Run an export plugin in single-item context |
1881 |
01 Feb 06 |
nicklas |
268 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
7307 |
07 Mar 17 |
nicklas |
269 |
registerExportUtils(cc); |
1881 |
01 Feb 06 |
nicklas |
270 |
redirect = "../../common/export/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=ITEM&title=Export+job"; |
1881 |
01 Feb 06 |
nicklas |
271 |
} |
1881 |
01 Feb 06 |
nicklas |
272 |
else if ("ImportItems".equals(cmd)) |
1881 |
01 Feb 06 |
nicklas |
273 |
{ |
1881 |
01 Feb 06 |
nicklas |
274 |
// Run an import plugin in a list context |
1881 |
01 Feb 06 |
nicklas |
275 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1881 |
01 Feb 06 |
nicklas |
276 |
final ItemQuery<Job> query = Job.getQuery(); |
7954 |
12 May 21 |
nicklas |
277 |
dc = sc.newDbControl(":Import "+itemType); |
7914 |
23 Feb 21 |
nicklas |
278 |
JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.list(itemType), null); |
7914 |
23 Feb 21 |
nicklas |
279 |
cc.configureQuery(dc, query, jspContext, true); |
5590 |
16 Mar 11 |
nicklas |
280 |
dc.close(); |
1881 |
01 Feb 06 |
nicklas |
281 |
cc.setQuery(query); |
1881 |
01 Feb 06 |
nicklas |
282 |
redirect = "../../common/import/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=LIST&title=Import+jobs"; |
1881 |
01 Feb 06 |
nicklas |
283 |
} |
1881 |
01 Feb 06 |
nicklas |
284 |
else if ("ImportItem".equals(cmd)) |
1881 |
01 Feb 06 |
nicklas |
285 |
{ |
1881 |
01 Feb 06 |
nicklas |
286 |
// Run an import plugin in single-item context |
1881 |
01 Feb 06 |
nicklas |
287 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1881 |
01 Feb 06 |
nicklas |
288 |
redirect = "../../common/import/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=ITEM&title=Import+job"; |
1881 |
01 Feb 06 |
nicklas |
289 |
} |
1881 |
01 Feb 06 |
nicklas |
290 |
else if ("RunListPlugin".equals(cmd)) |
1881 |
01 Feb 06 |
nicklas |
291 |
{ |
1881 |
01 Feb 06 |
nicklas |
292 |
// Run another plugin in a list context |
1881 |
01 Feb 06 |
nicklas |
293 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1881 |
01 Feb 06 |
nicklas |
294 |
final ItemQuery<Job> query = Job.getQuery(); |
7954 |
12 May 21 |
nicklas |
295 |
dc = sc.newDbControl(":Run plugin "+itemType); |
7914 |
23 Feb 21 |
nicklas |
296 |
JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.list(itemType), null); |
7914 |
23 Feb 21 |
nicklas |
297 |
cc.configureQuery(dc, query, jspContext, true); |
5590 |
16 Mar 11 |
nicklas |
298 |
dc.close(); |
1881 |
01 Feb 06 |
nicklas |
299 |
cc.setQuery(query); |
1881 |
01 Feb 06 |
nicklas |
300 |
redirect = "../../common/plugin/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=LIST&main_type=OTHER&title=Run+plugin"; |
1881 |
01 Feb 06 |
nicklas |
301 |
} |
1881 |
01 Feb 06 |
nicklas |
302 |
else if ("RunPlugin".equals(cmd)) |
1881 |
01 Feb 06 |
nicklas |
303 |
{ |
1881 |
01 Feb 06 |
nicklas |
304 |
// Run another plugin in single-item context |
1881 |
01 Feb 06 |
nicklas |
305 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1881 |
01 Feb 06 |
nicklas |
306 |
redirect = "../../common/plugin/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=ITEM&main_type=OTHER&title=Run+plugin"; |
1881 |
01 Feb 06 |
nicklas |
307 |
} |
2185 |
25 Apr 06 |
nicklas |
308 |
else if ("RestartJob".equals(cmd)) |
2185 |
25 Apr 06 |
nicklas |
309 |
{ |
2185 |
25 Apr 06 |
nicklas |
310 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
2724 |
11 Oct 06 |
nicklas |
311 |
boolean useLatestConfiguration = Values.getBoolean(request.getParameter("useLatestConfiguration"), false); |
4380 |
06 Aug 08 |
nicklas |
312 |
boolean clearDryRun = Values.getBoolean(request.getParameter("clearDryRun"), false); |
7317 |
03 Apr 17 |
nicklas |
313 |
boolean resumeFromBreakPoint = Values.getBoolean(request.getParameter("resumeFromBreakPoint"), false); |
7954 |
12 May 21 |
nicklas |
314 |
dc = sc.newDbControl(":Restart job"); |
2185 |
25 Apr 06 |
nicklas |
315 |
Job job = Job.getById(dc, cc.getId()); |
7317 |
03 Apr 17 |
nicklas |
316 |
if (!resumeFromBreakPoint) job.clearExecuteCommand(); |
4380 |
06 Aug 08 |
nicklas |
317 |
job.retry(useLatestConfiguration, clearDryRun); |
2185 |
25 Apr 06 |
nicklas |
318 |
dc.commit(); |
2185 |
25 Apr 06 |
nicklas |
319 |
redirect = viewPage; |
2185 |
25 Apr 06 |
nicklas |
320 |
} |
7320 |
05 Apr 17 |
nicklas |
321 |
else if ("AbortJobs".equals(cmd) || "PauseJobs".equals(cmd)) |
6600 |
17 Nov 14 |
nicklas |
322 |
{ |
6600 |
17 Nov 14 |
nicklas |
323 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
7320 |
05 Apr 17 |
nicklas |
324 |
Signal signal = "AbortJobs".equals(cmd) ? Signal.ABORT : Signal.PAUSE; |
7954 |
12 May 21 |
nicklas |
325 |
dc = sc.newDbControl(":"+signal.getName()+" jobs"); |
7320 |
05 Apr 17 |
nicklas |
326 |
int numHandled = 0; |
6600 |
17 Nov 14 |
nicklas |
327 |
int numSelected = 0; |
6600 |
17 Nov 14 |
nicklas |
328 |
for (int jobId : cc.getSelected()) |
6600 |
17 Nov 14 |
nicklas |
329 |
{ |
6600 |
17 Nov 14 |
nicklas |
330 |
numSelected++; |
6600 |
17 Nov 14 |
nicklas |
331 |
Job job = Job.getById(dc, jobId); |
6600 |
17 Nov 14 |
nicklas |
332 |
SignalTransporter signalTransporter = job.getSignalTransporter(); |
6600 |
17 Nov 14 |
nicklas |
333 |
if (signalTransporter == null) |
6600 |
17 Nov 14 |
nicklas |
334 |
{ |
7320 |
05 Apr 17 |
nicklas |
335 |
if (job.getStatus() == Job.Status.WAITING && signal == Signal.ABORT) |
6600 |
17 Nov 14 |
nicklas |
336 |
{ |
6600 |
17 Nov 14 |
nicklas |
337 |
job.doneError("Aborted by user"); |
7320 |
05 Apr 17 |
nicklas |
338 |
numHandled++; |
6600 |
17 Nov 14 |
nicklas |
339 |
} |
6600 |
17 Nov 14 |
nicklas |
340 |
} |
6600 |
17 Nov 14 |
nicklas |
341 |
else |
6600 |
17 Nov 14 |
nicklas |
342 |
{ |
6600 |
17 Nov 14 |
nicklas |
343 |
Collection<Signal> supportedSignals = signalTransporter.getSupportedSignals(); |
7320 |
05 Apr 17 |
nicklas |
344 |
if (supportedSignals == null || supportedSignals.contains(signal)) |
6600 |
17 Nov 14 |
nicklas |
345 |
{ |
7320 |
05 Apr 17 |
nicklas |
346 |
signalTransporter.send(signal); |
7320 |
05 Apr 17 |
nicklas |
347 |
numHandled++; |
6600 |
17 Nov 14 |
nicklas |
348 |
} |
6600 |
17 Nov 14 |
nicklas |
349 |
} |
6600 |
17 Nov 14 |
nicklas |
350 |
} |
6600 |
17 Nov 14 |
nicklas |
351 |
dc.commit(); |
6600 |
17 Nov 14 |
nicklas |
352 |
|
7320 |
05 Apr 17 |
nicklas |
353 |
message = numHandled + " of " + numSelected + " jobs have been " + (signal == Signal.ABORT ? "aborted" : "paused"); |
6600 |
17 Nov 14 |
nicklas |
354 |
Thread.sleep(500); |
6600 |
17 Nov 14 |
nicklas |
355 |
redirect = listPage; |
6600 |
17 Nov 14 |
nicklas |
356 |
} |
7320 |
05 Apr 17 |
nicklas |
357 |
else if ("AbortJob".equals(cmd) || "PauseJob".equals(cmd)) |
4093 |
18 Jan 08 |
enell |
358 |
{ |
4093 |
18 Jan 08 |
enell |
359 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
7954 |
12 May 21 |
nicklas |
360 |
Signal signal = "AbortJob".equals(cmd) ? Signal.ABORT : Signal.PAUSE; |
7954 |
12 May 21 |
nicklas |
361 |
dc = sc.newDbControl(":"+signal.getName()+" jobs"); |
4093 |
18 Jan 08 |
enell |
362 |
Job job = Job.getById(dc, cc.getId()); |
6432 |
14 Mar 14 |
nicklas |
363 |
SignalTransporter signalTransporter = job.getSignalTransporter(); |
6432 |
14 Mar 14 |
nicklas |
364 |
if (signalTransporter == null) |
4093 |
18 Jan 08 |
enell |
365 |
{ |
7320 |
05 Apr 17 |
nicklas |
366 |
if (job.getStatus() == Job.Status.WAITING && signal == Signal.ABORT) |
6432 |
14 Mar 14 |
nicklas |
367 |
{ |
6432 |
14 Mar 14 |
nicklas |
368 |
job.doneError("Aborted by user"); |
6432 |
14 Mar 14 |
nicklas |
369 |
} |
4093 |
18 Jan 08 |
enell |
370 |
} |
4093 |
18 Jan 08 |
enell |
371 |
else |
4093 |
18 Jan 08 |
enell |
372 |
{ |
7320 |
05 Apr 17 |
nicklas |
373 |
signalTransporter.send(signal); |
4093 |
18 Jan 08 |
enell |
374 |
} |
4093 |
18 Jan 08 |
enell |
375 |
dc.commit(); |
4127 |
05 Feb 08 |
nicklas |
376 |
// Wait some time to give the plug-in a chance to response |
4127 |
05 Feb 08 |
nicklas |
377 |
// Otherwise the user has to wait until next refresh to see the status |
4093 |
18 Jan 08 |
enell |
378 |
Thread.sleep(500); |
4093 |
18 Jan 08 |
enell |
379 |
redirect = viewPage; |
4093 |
18 Jan 08 |
enell |
380 |
} |
6880 |
21 Apr 15 |
nicklas |
381 |
else if ("ForceError".equals(cmd)) |
6880 |
21 Apr 15 |
nicklas |
382 |
{ |
6880 |
21 Apr 15 |
nicklas |
383 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
7954 |
12 May 21 |
nicklas |
384 |
dc = sc.newDbControl(":Force error on job"); |
6880 |
21 Apr 15 |
nicklas |
385 |
Job job = Job.getById(dc, cc.getId()); |
6880 |
21 Apr 15 |
nicklas |
386 |
job.doneError(request.getParameter("msg")); |
6880 |
21 Apr 15 |
nicklas |
387 |
dc.commit(); |
6880 |
21 Apr 15 |
nicklas |
388 |
redirect = viewPage; |
6880 |
21 Apr 15 |
nicklas |
389 |
} |
1881 |
01 Feb 06 |
nicklas |
390 |
else |
1881 |
01 Feb 06 |
nicklas |
391 |
{ |
1881 |
01 Feb 06 |
nicklas |
392 |
throw new WebException("popup", "Invalid command", "The command {1} is not recognised as a valid command.", cmd); |
1881 |
01 Feb 06 |
nicklas |
393 |
} |
1619 |
16 Nov 05 |
nicklas |
394 |
} |
1619 |
16 Nov 05 |
nicklas |
395 |
finally |
1619 |
16 Nov 05 |
nicklas |
396 |
{ |
1619 |
16 Nov 05 |
nicklas |
397 |
if (dc != null) dc.close(); |
1619 |
16 Nov 05 |
nicklas |
398 |
} |
1881 |
01 Feb 06 |
nicklas |
399 |
|
1881 |
01 Feb 06 |
nicklas |
400 |
if (forward != null) |
1881 |
01 Feb 06 |
nicklas |
401 |
{ |
6192 |
31 Oct 12 |
nicklas |
402 |
sc.setSessionSetting("alert-message", message); |
1881 |
01 Feb 06 |
nicklas |
403 |
pageContext.forward(forward); |
1881 |
01 Feb 06 |
nicklas |
404 |
} |
1881 |
01 Feb 06 |
nicklas |
405 |
else if (redirect != null) |
1881 |
01 Feb 06 |
nicklas |
406 |
{ |
6192 |
31 Oct 12 |
nicklas |
407 |
sc.setSessionSetting("alert-message", message); |
1881 |
01 Feb 06 |
nicklas |
408 |
response.sendRedirect(redirect); |
1881 |
01 Feb 06 |
nicklas |
409 |
} |
1881 |
01 Feb 06 |
nicklas |
410 |
else if (message == null) |
1881 |
01 Feb 06 |
nicklas |
411 |
{ |
1881 |
01 Feb 06 |
nicklas |
412 |
response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&wait=0"); |
1881 |
01 Feb 06 |
nicklas |
413 |
} |
1881 |
01 Feb 06 |
nicklas |
414 |
else |
1881 |
01 Feb 06 |
nicklas |
415 |
{ |
1881 |
01 Feb 06 |
nicklas |
416 |
response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&message="+HTML.urlEncode(message)); |
1881 |
01 Feb 06 |
nicklas |
417 |
} |
1881 |
01 Feb 06 |
nicklas |
418 |
%> |
1881 |
01 Feb 06 |
nicklas |
419 |
|