3793 |
27 Sep 07 |
nicklas |
1 |
<%-- $Id$ |
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.DataFileType" |
5630 |
13 May 11 |
nicklas |
31 |
import="net.sf.basedb.core.ItemSubtype" |
3793 |
27 Sep 07 |
nicklas |
32 |
import="net.sf.basedb.core.ItemQuery" |
3793 |
27 Sep 07 |
nicklas |
33 |
import="net.sf.basedb.core.Permission" |
3793 |
27 Sep 07 |
nicklas |
34 |
import="net.sf.basedb.core.ItemContext" |
3793 |
27 Sep 07 |
nicklas |
35 |
import="net.sf.basedb.core.MultiPermissions" |
3793 |
27 Sep 07 |
nicklas |
36 |
import="net.sf.basedb.core.PermissionDeniedException" |
3793 |
27 Sep 07 |
nicklas |
37 |
import="net.sf.basedb.core.ItemAlreadyExistsException" |
3793 |
27 Sep 07 |
nicklas |
38 |
import="net.sf.basedb.util.RemovableUtil" |
3793 |
27 Sep 07 |
nicklas |
39 |
import="net.sf.basedb.clients.web.Base" |
3793 |
27 Sep 07 |
nicklas |
40 |
import="net.sf.basedb.clients.web.WebException" |
3793 |
27 Sep 07 |
nicklas |
41 |
import="net.sf.basedb.util.Values" |
3793 |
27 Sep 07 |
nicklas |
42 |
import="net.sf.basedb.clients.web.util.HTML" |
3793 |
27 Sep 07 |
nicklas |
43 |
import="net.sf.basedb.util.formatter.Formatter" |
3793 |
27 Sep 07 |
nicklas |
44 |
import="net.sf.basedb.clients.web.formatter.FormatterFactory" |
5508 |
19 Nov 10 |
nicklas |
45 |
import="net.sf.basedb.core.plugin.GuiContext" |
5508 |
19 Nov 10 |
nicklas |
46 |
import="net.sf.basedb.util.extensions.ExtensionsInvoker" |
5508 |
19 Nov 10 |
nicklas |
47 |
import="net.sf.basedb.clients.web.extensions.ExtensionsControl" |
5508 |
19 Nov 10 |
nicklas |
48 |
import="net.sf.basedb.clients.web.extensions.JspContext" |
5508 |
19 Nov 10 |
nicklas |
49 |
import="net.sf.basedb.clients.web.extensions.edit.EditUtil" |
7604 |
25 Feb 19 |
nicklas |
50 |
import="net.sf.basedb.clients.web.extensions.edit.OnSaveAction" |
5508 |
19 Nov 10 |
nicklas |
51 |
import="net.sf.basedb.clients.web.extensions.edit.OnSaveRenderer" |
6045 |
03 Apr 12 |
nicklas |
52 |
import="net.sf.basedb.clients.web.extensions.list.ListColumnExportRenderer" |
7604 |
25 Feb 19 |
nicklas |
53 |
import="net.sf.basedb.clients.web.extensions.list.ListColumnAction" |
6045 |
03 Apr 12 |
nicklas |
54 |
import="net.sf.basedb.clients.web.extensions.list.ListColumnUtil" |
3793 |
27 Sep 07 |
nicklas |
55 |
import="java.util.Date" |
3793 |
27 Sep 07 |
nicklas |
56 |
import="java.util.Set" |
3793 |
27 Sep 07 |
nicklas |
57 |
import="java.util.HashSet" |
3793 |
27 Sep 07 |
nicklas |
58 |
import="java.util.List" |
3793 |
27 Sep 07 |
nicklas |
59 |
import="java.util.ArrayList" |
3793 |
27 Sep 07 |
nicklas |
60 |
import="java.util.Collections" |
3793 |
27 Sep 07 |
nicklas |
61 |
%> |
3793 |
27 Sep 07 |
nicklas |
62 |
<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> |
3793 |
27 Sep 07 |
nicklas |
63 |
<%! |
3793 |
27 Sep 07 |
nicklas |
64 |
private static final ItemContext defaultContext = Base.createDefaultContext("name", "name,extension,itemType,description"); |
3793 |
27 Sep 07 |
nicklas |
65 |
private static final Item itemType = Item.DATAFILETYPE; |
3793 |
27 Sep 07 |
nicklas |
66 |
%> |
3793 |
27 Sep 07 |
nicklas |
67 |
<% |
3793 |
27 Sep 07 |
nicklas |
68 |
final SessionControl sc = Base.getExistingSessionControl(pageContext, true); |
3793 |
27 Sep 07 |
nicklas |
69 |
final String ID = sc.getId(); |
3793 |
27 Sep 07 |
nicklas |
70 |
final String cmd = request.getParameter("cmd"); |
3793 |
27 Sep 07 |
nicklas |
71 |
final String root = request.getContextPath()+"/"; |
3793 |
27 Sep 07 |
nicklas |
72 |
final String mode = request.getParameter("mode"); |
3793 |
27 Sep 07 |
nicklas |
73 |
final String callback = request.getParameter("callback"); |
3793 |
27 Sep 07 |
nicklas |
74 |
final String itemId = request.getParameter("item_id"); |
3793 |
27 Sep 07 |
nicklas |
75 |
final String listPage = "list_filetypes.jsp?ID="+ID |
3793 |
27 Sep 07 |
nicklas |
76 |
+(mode == null ? "" : "&mode="+mode) |
3793 |
27 Sep 07 |
nicklas |
77 |
+(callback == null ? "" : "&callback="+callback) |
3793 |
27 Sep 07 |
nicklas |
78 |
+(itemId == null ? "" : "&item_id="+itemId); |
3793 |
27 Sep 07 |
nicklas |
79 |
final String viewPage = "view_filetype.jsp?ID="+ID; |
3793 |
27 Sep 07 |
nicklas |
80 |
final String editPage = "edit_filetype.jsp?ID="+ID; |
3793 |
27 Sep 07 |
nicklas |
81 |
|
3793 |
27 Sep 07 |
nicklas |
82 |
String forward = null; |
3793 |
27 Sep 07 |
nicklas |
83 |
String redirect = null; |
3793 |
27 Sep 07 |
nicklas |
84 |
String message = null; |
3793 |
27 Sep 07 |
nicklas |
85 |
DbControl dc = null; |
3793 |
27 Sep 07 |
nicklas |
86 |
|
3793 |
27 Sep 07 |
nicklas |
87 |
try |
3793 |
27 Sep 07 |
nicklas |
88 |
{ |
3793 |
27 Sep 07 |
nicklas |
89 |
if (cmd == null || "List".equals(cmd)) |
3793 |
27 Sep 07 |
nicklas |
90 |
{ |
3793 |
27 Sep 07 |
nicklas |
91 |
// Display the list page without updatinging the current context |
3793 |
27 Sep 07 |
nicklas |
92 |
Base.getAndSetCurrentContext(sc, itemType, null, defaultContext, true); |
3793 |
27 Sep 07 |
nicklas |
93 |
redirect = listPage; |
3793 |
27 Sep 07 |
nicklas |
94 |
} |
3793 |
27 Sep 07 |
nicklas |
95 |
else if ("UpdateContext".equals(cmd)) |
3793 |
27 Sep 07 |
nicklas |
96 |
{ |
3793 |
27 Sep 07 |
nicklas |
97 |
// Display the list page after updating the current context from the request parameters |
3793 |
27 Sep 07 |
nicklas |
98 |
Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
3793 |
27 Sep 07 |
nicklas |
99 |
redirect = listPage; |
3793 |
27 Sep 07 |
nicklas |
100 |
} |
3793 |
27 Sep 07 |
nicklas |
101 |
else if ("LoadContext".equals(cmd)) |
3793 |
27 Sep 07 |
nicklas |
102 |
{ |
3793 |
27 Sep 07 |
nicklas |
103 |
// Display the list page after loading a saved context |
3793 |
27 Sep 07 |
nicklas |
104 |
int contextId = Values.getInt(request.getParameter("context")); |
3793 |
27 Sep 07 |
nicklas |
105 |
Base.loadContext(sc, contextId, defaultContext); |
3793 |
27 Sep 07 |
nicklas |
106 |
redirect = listPage; |
3793 |
27 Sep 07 |
nicklas |
107 |
} |
3793 |
27 Sep 07 |
nicklas |
108 |
|
3793 |
27 Sep 07 |
nicklas |
109 |
else if ("ViewItem".equals(cmd)) |
3793 |
27 Sep 07 |
nicklas |
110 |
{ |
3793 |
27 Sep 07 |
nicklas |
111 |
// Display the view page for a single item |
3793 |
27 Sep 07 |
nicklas |
112 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
3793 |
27 Sep 07 |
nicklas |
113 |
forward = viewPage; |
3793 |
27 Sep 07 |
nicklas |
114 |
} |
3793 |
27 Sep 07 |
nicklas |
115 |
else if ("EditItem".equals(cmd)) |
3793 |
27 Sep 07 |
nicklas |
116 |
{ |
3793 |
27 Sep 07 |
nicklas |
117 |
// Display the edit page for a single item (should be opened in a popup) |
3793 |
27 Sep 07 |
nicklas |
118 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
3793 |
27 Sep 07 |
nicklas |
119 |
redirect = editPage; |
3793 |
27 Sep 07 |
nicklas |
120 |
} |
3793 |
27 Sep 07 |
nicklas |
121 |
else if ("NewItem".equals(cmd)) |
3793 |
27 Sep 07 |
nicklas |
122 |
{ |
3793 |
27 Sep 07 |
nicklas |
123 |
// Display the edit page for a new item (should be opened in a popup) |
3793 |
27 Sep 07 |
nicklas |
124 |
if (!sc.hasPermission(Permission.CREATE, itemType)) |
3793 |
27 Sep 07 |
nicklas |
125 |
{ |
3793 |
27 Sep 07 |
nicklas |
126 |
throw new PermissionDeniedException(Permission.CREATE, itemType.toString()); |
3793 |
27 Sep 07 |
nicklas |
127 |
} |
3793 |
27 Sep 07 |
nicklas |
128 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
3793 |
27 Sep 07 |
nicklas |
129 |
cc.setId(0); |
3793 |
27 Sep 07 |
nicklas |
130 |
redirect = editPage; |
3793 |
27 Sep 07 |
nicklas |
131 |
} |
3793 |
27 Sep 07 |
nicklas |
132 |
else if ("UpdateItem".equals(cmd)) |
3793 |
27 Sep 07 |
nicklas |
133 |
{ |
3793 |
27 Sep 07 |
nicklas |
134 |
// Update the properties on an item (will close the popup) |
3793 |
27 Sep 07 |
nicklas |
135 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, defaultContext); |
3793 |
27 Sep 07 |
nicklas |
136 |
final int maxRecent = Base.getMaxRecent(sc); |
7954 |
12 May 21 |
nicklas |
137 |
dc = sc.newDbControl(":Edit "+itemType); |
7605 |
26 Feb 19 |
nicklas |
138 |
DataFileType fileType = cc.getObject("item"); |
3793 |
27 Sep 07 |
nicklas |
139 |
if (fileType == null) |
3793 |
27 Sep 07 |
nicklas |
140 |
{ |
3798 |
28 Sep 07 |
nicklas |
141 |
String externalId = Values.getStringOrNull(request.getParameter("externalId")); |
3793 |
27 Sep 07 |
nicklas |
142 |
Item itemType = Item.valueOf(request.getParameter("itemType")); |
3798 |
28 Sep 07 |
nicklas |
143 |
fileType = DataFileType.getNew(dc, externalId, itemType); |
3793 |
27 Sep 07 |
nicklas |
144 |
message = "Data file type created"; |
3793 |
27 Sep 07 |
nicklas |
145 |
dc.saveItem(fileType); |
3793 |
27 Sep 07 |
nicklas |
146 |
} |
3793 |
27 Sep 07 |
nicklas |
147 |
else |
3793 |
27 Sep 07 |
nicklas |
148 |
{ |
5060 |
19 Aug 09 |
nicklas |
149 |
dc.reattachItem(fileType, false); |
3793 |
27 Sep 07 |
nicklas |
150 |
message = "Data file type updated"; |
3793 |
27 Sep 07 |
nicklas |
151 |
} |
5508 |
19 Nov 10 |
nicklas |
152 |
JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.item(Item.DATAFILETYPE), fileType); |
7604 |
25 Feb 19 |
nicklas |
153 |
ExtensionsInvoker<OnSaveAction> invoker = EditUtil.useOnSaveExtensions(jspContext); |
5508 |
19 Nov 10 |
nicklas |
154 |
try |
3793 |
27 Sep 07 |
nicklas |
155 |
{ |
5508 |
19 Nov 10 |
nicklas |
156 |
fileType.setName(Values.getStringOrNull(request.getParameter("name"))); |
5508 |
19 Nov 10 |
nicklas |
157 |
fileType.setDescription(Values.getStringOrNull(request.getParameter("description"))); |
5508 |
19 Nov 10 |
nicklas |
158 |
fileType.setExtension(Values.getStringOrNull(request.getParameter("extension"))); |
5508 |
19 Nov 10 |
nicklas |
159 |
int genericTypeId = Values.getInt(request.getParameter("generictype_id"), -1); |
5508 |
19 Nov 10 |
nicklas |
160 |
if (genericTypeId >= 0) // < 0 = denied or unchanged |
5508 |
19 Nov 10 |
nicklas |
161 |
{ |
5630 |
13 May 11 |
nicklas |
162 |
ItemSubtype ft = genericTypeId == 0 ? null : ItemSubtype.getById(dc, genericTypeId); |
5508 |
19 Nov 10 |
nicklas |
163 |
fileType.setGenericType(ft); |
7703 |
11 Apr 19 |
nicklas |
164 |
cc.setRecent(Item.ITEMSUBTYPE, ft, maxRecent); |
5508 |
19 Nov 10 |
nicklas |
165 |
} |
5508 |
19 Nov 10 |
nicklas |
166 |
|
5508 |
19 Nov 10 |
nicklas |
167 |
// OnSave extensions |
5508 |
19 Nov 10 |
nicklas |
168 |
invoker.render(OnSaveRenderer.ON_SAVE); |
5508 |
19 Nov 10 |
nicklas |
169 |
dc.commit(); |
5508 |
19 Nov 10 |
nicklas |
170 |
invoker.render(OnSaveRenderer.ON_COMMIT); |
3793 |
27 Sep 07 |
nicklas |
171 |
} |
5508 |
19 Nov 10 |
nicklas |
172 |
catch (Exception ex) |
5508 |
19 Nov 10 |
nicklas |
173 |
{ |
5508 |
19 Nov 10 |
nicklas |
174 |
invoker.render(OnSaveRenderer.onRollback(ex)); |
5508 |
19 Nov 10 |
nicklas |
175 |
throw ex; |
5508 |
19 Nov 10 |
nicklas |
176 |
} |
5508 |
19 Nov 10 |
nicklas |
177 |
finally |
5508 |
19 Nov 10 |
nicklas |
178 |
{ |
5508 |
19 Nov 10 |
nicklas |
179 |
cc.removeObject("item"); |
5508 |
19 Nov 10 |
nicklas |
180 |
} |
3793 |
27 Sep 07 |
nicklas |
181 |
} |
3793 |
27 Sep 07 |
nicklas |
182 |
else if ("DeleteItem".equals(cmd)) |
3793 |
27 Sep 07 |
nicklas |
183 |
{ |
3793 |
27 Sep 07 |
nicklas |
184 |
// Delete a single item and then return to the view page |
7954 |
12 May 21 |
nicklas |
185 |
dc = sc.newDbControl(":Delete "+itemType); |
3793 |
27 Sep 07 |
nicklas |
186 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
3793 |
27 Sep 07 |
nicklas |
187 |
RemovableUtil.setRemoved(dc, itemType, Collections.singleton(cc.getId()), true); |
3793 |
27 Sep 07 |
nicklas |
188 |
dc.commit(); |
3793 |
27 Sep 07 |
nicklas |
189 |
redirect = viewPage; |
3793 |
27 Sep 07 |
nicklas |
190 |
} |
3793 |
27 Sep 07 |
nicklas |
191 |
else if ("DeleteItems".equals(cmd)) |
3793 |
27 Sep 07 |
nicklas |
192 |
{ |
3793 |
27 Sep 07 |
nicklas |
193 |
// Delete all selected items on the list page |
7954 |
12 May 21 |
nicklas |
194 |
dc = sc.newDbControl(":Delete "+itemType); |
3793 |
27 Sep 07 |
nicklas |
195 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
3793 |
27 Sep 07 |
nicklas |
196 |
int numTotal = cc.getSelected().size(); |
3793 |
27 Sep 07 |
nicklas |
197 |
int numRemoved = RemovableUtil.setRemoved(dc, itemType, cc.getSelected(), true); |
3793 |
27 Sep 07 |
nicklas |
198 |
dc.commit(); |
3793 |
27 Sep 07 |
nicklas |
199 |
if (numTotal != numRemoved) |
3793 |
27 Sep 07 |
nicklas |
200 |
{ |
3793 |
27 Sep 07 |
nicklas |
201 |
message = (numRemoved == 0 ? "No" : "Only "+numRemoved+" of "+numTotal) + " items could be deleted, because you have no DELETE permission"; |
3793 |
27 Sep 07 |
nicklas |
202 |
} |
6192 |
31 Oct 12 |
nicklas |
203 |
redirect = listPage; |
3793 |
27 Sep 07 |
nicklas |
204 |
} |
3793 |
27 Sep 07 |
nicklas |
205 |
else if ("RestoreItem".equals(cmd)) |
3793 |
27 Sep 07 |
nicklas |
206 |
{ |
3793 |
27 Sep 07 |
nicklas |
207 |
// Restore a single item and then return to the view page |
7954 |
12 May 21 |
nicklas |
208 |
dc = sc.newDbControl(":Restore "+itemType); |
3793 |
27 Sep 07 |
nicklas |
209 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
3793 |
27 Sep 07 |
nicklas |
210 |
RemovableUtil.setRemoved(dc, itemType, Collections.singleton(cc.getId()), false); |
3793 |
27 Sep 07 |
nicklas |
211 |
dc.commit(); |
3793 |
27 Sep 07 |
nicklas |
212 |
redirect = viewPage; |
3793 |
27 Sep 07 |
nicklas |
213 |
} |
3793 |
27 Sep 07 |
nicklas |
214 |
else if ("RestoreItems".equals(cmd)) |
3793 |
27 Sep 07 |
nicklas |
215 |
{ |
3793 |
27 Sep 07 |
nicklas |
216 |
// Restore all selected items on the list page |
7954 |
12 May 21 |
nicklas |
217 |
dc = sc.newDbControl(":Restore "+itemType); |
3793 |
27 Sep 07 |
nicklas |
218 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
3793 |
27 Sep 07 |
nicklas |
219 |
int numTotal = cc.getSelected().size(); |
3793 |
27 Sep 07 |
nicklas |
220 |
int numRemoved = RemovableUtil.setRemoved(dc, itemType, cc.getSelected(), false); |
3793 |
27 Sep 07 |
nicklas |
221 |
dc.commit(); |
3793 |
27 Sep 07 |
nicklas |
222 |
if (numTotal != numRemoved) |
3793 |
27 Sep 07 |
nicklas |
223 |
{ |
3793 |
27 Sep 07 |
nicklas |
224 |
message = (numRemoved == 0 ? "No" : "Only "+numRemoved+" of "+numTotal) + " items could be restored, because you have no WRITE permission"; |
3793 |
27 Sep 07 |
nicklas |
225 |
} |
6192 |
31 Oct 12 |
nicklas |
226 |
redirect = listPage; |
3793 |
27 Sep 07 |
nicklas |
227 |
} |
3793 |
27 Sep 07 |
nicklas |
228 |
else if ("ExportItems".equals(cmd)) |
3793 |
27 Sep 07 |
nicklas |
229 |
{ |
3793 |
27 Sep 07 |
nicklas |
230 |
// Run an export plugin in a list context |
3793 |
27 Sep 07 |
nicklas |
231 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
3793 |
27 Sep 07 |
nicklas |
232 |
final ItemQuery<DataFileType> query = DataFileType.getQuery(); |
7954 |
12 May 21 |
nicklas |
233 |
dc = sc.newDbControl(":Export "+itemType); |
7914 |
23 Feb 21 |
nicklas |
234 |
JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.list(itemType), null); |
7914 |
23 Feb 21 |
nicklas |
235 |
cc.configureQuery(dc, query, jspContext, true); |
6045 |
03 Apr 12 |
nicklas |
236 |
cc.setQuery(query); |
7604 |
25 Feb 19 |
nicklas |
237 |
ExtensionsInvoker<ListColumnAction<DataFileType,?>> listInvoker = ListColumnUtil.useExtensions(jspContext); |
7604 |
25 Feb 19 |
nicklas |
238 |
listInvoker.render(new ListColumnExportRenderer<DataFileType>(cc)); |
5590 |
16 Mar 11 |
nicklas |
239 |
dc.close(); |
3793 |
27 Sep 07 |
nicklas |
240 |
redirect = "../../common/export/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=LIST&title=Export+data+file+types"; |
3793 |
27 Sep 07 |
nicklas |
241 |
} |
3793 |
27 Sep 07 |
nicklas |
242 |
else if ("ExportItem".equals(cmd)) |
3793 |
27 Sep 07 |
nicklas |
243 |
{ |
3793 |
27 Sep 07 |
nicklas |
244 |
// Run an export plugin in single-item context |
3793 |
27 Sep 07 |
nicklas |
245 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
3793 |
27 Sep 07 |
nicklas |
246 |
redirect = "../../common/export/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=ITEM&title=Export+data+file+type"; |
3793 |
27 Sep 07 |
nicklas |
247 |
} |
3793 |
27 Sep 07 |
nicklas |
248 |
else if ("ImportItems".equals(cmd)) |
3793 |
27 Sep 07 |
nicklas |
249 |
{ |
3793 |
27 Sep 07 |
nicklas |
250 |
// Run an import plugin in a list context |
3793 |
27 Sep 07 |
nicklas |
251 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
3793 |
27 Sep 07 |
nicklas |
252 |
final ItemQuery<DataFileType> query = DataFileType.getQuery(); |
7954 |
12 May 21 |
nicklas |
253 |
dc = sc.newDbControl(":Import "+itemType); |
7914 |
23 Feb 21 |
nicklas |
254 |
JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.list(itemType), null); |
7914 |
23 Feb 21 |
nicklas |
255 |
cc.configureQuery(dc, query, jspContext, true); |
5590 |
16 Mar 11 |
nicklas |
256 |
dc.close(); |
3793 |
27 Sep 07 |
nicklas |
257 |
cc.setQuery(query); |
3793 |
27 Sep 07 |
nicklas |
258 |
redirect = "../../common/import/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=LIST&title=Import+data+file+types"; |
3793 |
27 Sep 07 |
nicklas |
259 |
} |
3793 |
27 Sep 07 |
nicklas |
260 |
else if ("ImportItem".equals(cmd)) |
3793 |
27 Sep 07 |
nicklas |
261 |
{ |
3793 |
27 Sep 07 |
nicklas |
262 |
// Run an import plugin in single-item context |
3793 |
27 Sep 07 |
nicklas |
263 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
3793 |
27 Sep 07 |
nicklas |
264 |
redirect = "../../common/import/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=ITEM&title=Import+data+file+type"; |
3793 |
27 Sep 07 |
nicklas |
265 |
} |
3793 |
27 Sep 07 |
nicklas |
266 |
else if ("RunListPlugin".equals(cmd)) |
3793 |
27 Sep 07 |
nicklas |
267 |
{ |
3793 |
27 Sep 07 |
nicklas |
268 |
// Run another plugin in a list context |
3793 |
27 Sep 07 |
nicklas |
269 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
3793 |
27 Sep 07 |
nicklas |
270 |
final ItemQuery<DataFileType> query = DataFileType.getQuery(); |
7954 |
12 May 21 |
nicklas |
271 |
dc = sc.newDbControl(":Run plugin "+itemType); |
7914 |
23 Feb 21 |
nicklas |
272 |
JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.list(itemType), null); |
7914 |
23 Feb 21 |
nicklas |
273 |
cc.configureQuery(dc, query, jspContext, true); |
5590 |
16 Mar 11 |
nicklas |
274 |
dc.close(); |
3793 |
27 Sep 07 |
nicklas |
275 |
cc.setQuery(query); |
3793 |
27 Sep 07 |
nicklas |
276 |
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 |
277 |
} |
3793 |
27 Sep 07 |
nicklas |
278 |
else if ("RunPlugin".equals(cmd)) |
3793 |
27 Sep 07 |
nicklas |
279 |
{ |
3793 |
27 Sep 07 |
nicklas |
280 |
// Run another plugin in single-item context |
3793 |
27 Sep 07 |
nicklas |
281 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
3793 |
27 Sep 07 |
nicklas |
282 |
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 |
283 |
} |
3793 |
27 Sep 07 |
nicklas |
284 |
else |
3793 |
27 Sep 07 |
nicklas |
285 |
{ |
3793 |
27 Sep 07 |
nicklas |
286 |
throw new WebException("popup", "Invalid command", "The command {1} is not recognised as a valid command.", cmd); |
3793 |
27 Sep 07 |
nicklas |
287 |
} |
3793 |
27 Sep 07 |
nicklas |
288 |
} |
3793 |
27 Sep 07 |
nicklas |
289 |
finally |
3793 |
27 Sep 07 |
nicklas |
290 |
{ |
3793 |
27 Sep 07 |
nicklas |
291 |
if (dc != null) dc.close(); |
3793 |
27 Sep 07 |
nicklas |
292 |
} |
3793 |
27 Sep 07 |
nicklas |
293 |
|
3793 |
27 Sep 07 |
nicklas |
294 |
if (forward != null) |
3793 |
27 Sep 07 |
nicklas |
295 |
{ |
6192 |
31 Oct 12 |
nicklas |
296 |
sc.setSessionSetting("alert-message", message); |
3793 |
27 Sep 07 |
nicklas |
297 |
pageContext.forward(forward); |
3793 |
27 Sep 07 |
nicklas |
298 |
} |
3793 |
27 Sep 07 |
nicklas |
299 |
else if (redirect != null) |
3793 |
27 Sep 07 |
nicklas |
300 |
{ |
6192 |
31 Oct 12 |
nicklas |
301 |
sc.setSessionSetting("alert-message", message); |
3793 |
27 Sep 07 |
nicklas |
302 |
response.sendRedirect(redirect); |
3793 |
27 Sep 07 |
nicklas |
303 |
} |
3793 |
27 Sep 07 |
nicklas |
304 |
else if (message == null) |
3793 |
27 Sep 07 |
nicklas |
305 |
{ |
3793 |
27 Sep 07 |
nicklas |
306 |
response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&wait=0"); |
3793 |
27 Sep 07 |
nicklas |
307 |
} |
3793 |
27 Sep 07 |
nicklas |
308 |
else |
3793 |
27 Sep 07 |
nicklas |
309 |
{ |
3793 |
27 Sep 07 |
nicklas |
310 |
response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&message="+HTML.urlEncode(message)); |
3793 |
27 Sep 07 |
nicklas |
311 |
} |
3793 |
27 Sep 07 |
nicklas |
312 |
%> |
3793 |
27 Sep 07 |
nicklas |
313 |
|