1411 |
06 Oct 05 |
gregory |
1 |
<%-- $Id$ |
1411 |
06 Oct 05 |
gregory |
2 |
------------------------------------------------------------------ |
3675 |
16 Aug 07 |
jari |
Copyright (C) 2005 Nicklas Nordborg, Gregory Vincic |
5425 |
23 Sep 10 |
nicklas |
Copyright (C) 2006 Jari Häkkinen, Nicklas Nordborg, Martin Svensson |
3675 |
16 Aug 07 |
jari |
Copyright (C) 2007 Nicklas Nordborg |
1411 |
06 Oct 05 |
gregory |
6 |
|
2304 |
22 May 06 |
jari |
7 |
This file is part of BASE - BioArray Software Environment. |
2304 |
22 May 06 |
jari |
8 |
Available at http://base.thep.lu.se/ |
1411 |
06 Oct 05 |
gregory |
9 |
|
1666 |
25 Nov 05 |
nicklas |
10 |
BASE is free software; you can redistribute it and/or |
1411 |
06 Oct 05 |
gregory |
11 |
modify it under the terms of the GNU General Public License |
4476 |
05 Sep 08 |
jari |
12 |
as published by the Free Software Foundation; either version 3 |
1411 |
06 Oct 05 |
gregory |
13 |
of the License, or (at your option) any later version. |
1411 |
06 Oct 05 |
gregory |
14 |
|
1411 |
06 Oct 05 |
gregory |
15 |
BASE is distributed in the hope that it will be useful, |
1411 |
06 Oct 05 |
gregory |
16 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
1411 |
06 Oct 05 |
gregory |
17 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1411 |
06 Oct 05 |
gregory |
18 |
GNU General Public License for more details. |
1411 |
06 Oct 05 |
gregory |
19 |
|
1411 |
06 Oct 05 |
gregory |
20 |
You should have received a copy of the GNU General Public License |
4511 |
11 Sep 08 |
jari |
21 |
along with BASE. If not, see <http://www.gnu.org/licenses/>. |
1411 |
06 Oct 05 |
gregory |
22 |
------------------------------------------------------------------ |
1411 |
06 Oct 05 |
gregory |
23 |
|
1666 |
25 Nov 05 |
nicklas |
24 |
@author Nicklas |
1411 |
06 Oct 05 |
gregory |
25 |
@version 2.0 |
1411 |
06 Oct 05 |
gregory |
26 |
--%> |
5426 |
24 Sep 10 |
nicklas |
27 |
<%@ page pageEncoding="UTF-8" session="false" |
1411 |
06 Oct 05 |
gregory |
28 |
import="net.sf.basedb.core.SessionControl" |
1411 |
06 Oct 05 |
gregory |
29 |
import="net.sf.basedb.core.DbControl" |
1411 |
06 Oct 05 |
gregory |
30 |
import="net.sf.basedb.core.Item" |
1820 |
24 Jan 06 |
nicklas |
31 |
import="net.sf.basedb.core.Include" |
4901 |
23 Apr 09 |
martin |
32 |
import="net.sf.basedb.core.ArrayBatch" |
1666 |
25 Nov 05 |
nicklas |
33 |
import="net.sf.basedb.core.ArrayDesign" |
5964 |
15 Feb 12 |
nicklas |
34 |
import="net.sf.basedb.core.Project" |
3820 |
12 Oct 07 |
nicklas |
35 |
import="net.sf.basedb.core.Platform" |
3820 |
12 Oct 07 |
nicklas |
36 |
import="net.sf.basedb.core.PlatformVariant" |
1976 |
13 Feb 06 |
nicklas |
37 |
import="net.sf.basedb.core.Plate" |
2384 |
15 Jun 06 |
nicklas |
38 |
import="net.sf.basedb.core.File" |
3820 |
12 Oct 07 |
nicklas |
39 |
import="net.sf.basedb.core.FileSet" |
3820 |
12 Oct 07 |
nicklas |
40 |
import="net.sf.basedb.core.Path" |
3820 |
12 Oct 07 |
nicklas |
41 |
import="net.sf.basedb.core.DataFileType" |
1666 |
25 Nov 05 |
nicklas |
42 |
import="net.sf.basedb.core.ItemQuery" |
1666 |
25 Nov 05 |
nicklas |
43 |
import="net.sf.basedb.core.ItemResultIterator" |
1411 |
06 Oct 05 |
gregory |
44 |
import="net.sf.basedb.core.Permission" |
1820 |
24 Jan 06 |
nicklas |
45 |
import="net.sf.basedb.core.ItemContext" |
1820 |
24 Jan 06 |
nicklas |
46 |
import="net.sf.basedb.core.MultiPermissions" |
4587 |
15 Oct 08 |
martin |
47 |
import="net.sf.basedb.core.OwnedItem" |
6695 |
28 Jan 15 |
nicklas |
48 |
import="net.sf.basedb.core.AnnotatedItem" |
1820 |
24 Jan 06 |
nicklas |
49 |
import="net.sf.basedb.core.PermissionDeniedException" |
1820 |
24 Jan 06 |
nicklas |
50 |
import="net.sf.basedb.core.ItemAlreadyExistsException" |
4901 |
23 Apr 09 |
martin |
51 |
import="net.sf.basedb.core.query.Expressions" |
4901 |
23 Apr 09 |
martin |
52 |
import="net.sf.basedb.core.query.Hql" |
4901 |
23 Apr 09 |
martin |
53 |
import="net.sf.basedb.core.query.Orders" |
4901 |
23 Apr 09 |
martin |
54 |
import="net.sf.basedb.core.query.Restrictions" |
1820 |
24 Jan 06 |
nicklas |
55 |
import="net.sf.basedb.util.RemovableUtil" |
1820 |
24 Jan 06 |
nicklas |
56 |
import="net.sf.basedb.util.ShareableUtil" |
2919 |
15 Nov 06 |
nicklas |
57 |
import="net.sf.basedb.util.OwnableUtil" |
4901 |
23 Apr 09 |
martin |
58 |
import="net.sf.basedb.util.formatter.NameableFormatter" |
1411 |
06 Oct 05 |
gregory |
59 |
import="net.sf.basedb.clients.web.Base" |
1820 |
24 Jan 06 |
nicklas |
60 |
import="net.sf.basedb.clients.web.WebException" |
2753 |
20 Oct 06 |
nicklas |
61 |
import="net.sf.basedb.util.Values" |
4901 |
23 Apr 09 |
martin |
62 |
import="net.sf.basedb.clients.web.plugins.ItemQueryLoader" |
1411 |
06 Oct 05 |
gregory |
63 |
import="net.sf.basedb.clients.web.util.HTML" |
5498 |
17 Nov 10 |
nicklas |
64 |
import="net.sf.basedb.core.plugin.GuiContext" |
5498 |
17 Nov 10 |
nicklas |
65 |
import="net.sf.basedb.util.extensions.ExtensionsInvoker" |
5498 |
17 Nov 10 |
nicklas |
66 |
import="net.sf.basedb.clients.web.extensions.ExtensionsControl" |
5498 |
17 Nov 10 |
nicklas |
67 |
import="net.sf.basedb.clients.web.extensions.JspContext" |
5498 |
17 Nov 10 |
nicklas |
68 |
import="net.sf.basedb.clients.web.extensions.edit.EditUtil" |
7604 |
25 Feb 19 |
nicklas |
69 |
import="net.sf.basedb.clients.web.extensions.edit.OnSaveAction" |
5498 |
17 Nov 10 |
nicklas |
70 |
import="net.sf.basedb.clients.web.extensions.edit.OnSaveRenderer" |
6039 |
29 Mar 12 |
nicklas |
71 |
import="net.sf.basedb.clients.web.extensions.list.ListColumnExportRenderer" |
7604 |
25 Feb 19 |
nicklas |
72 |
import="net.sf.basedb.clients.web.extensions.list.ListColumnAction" |
6039 |
29 Mar 12 |
nicklas |
73 |
import="net.sf.basedb.clients.web.extensions.list.ListColumnUtil" |
1820 |
24 Jan 06 |
nicklas |
74 |
import="java.util.Enumeration" |
1820 |
24 Jan 06 |
nicklas |
75 |
import="java.util.Set" |
1820 |
24 Jan 06 |
nicklas |
76 |
import="java.util.HashSet" |
1666 |
25 Nov 05 |
nicklas |
77 |
import="java.util.List" |
1820 |
24 Jan 06 |
nicklas |
78 |
import="java.util.ArrayList" |
1820 |
24 Jan 06 |
nicklas |
79 |
import="java.util.Collections" |
1411 |
06 Oct 05 |
gregory |
80 |
%> |
1411 |
06 Oct 05 |
gregory |
81 |
<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> |
1411 |
06 Oct 05 |
gregory |
82 |
<%! |
3820 |
12 Oct 07 |
nicklas |
83 |
private static final ItemContext defaultContext = Base.createDefaultContext("name", "name,platform,numDbFeatures,numFileFeatures,description"); |
1820 |
24 Jan 06 |
nicklas |
84 |
private static final Item itemType = Item.ARRAYDESIGN; |
4901 |
23 Apr 09 |
martin |
85 |
|
4901 |
23 Apr 09 |
martin |
86 |
private static void registerExportUtils(ItemContext cc) |
4901 |
23 Apr 09 |
martin |
87 |
{ |
4901 |
23 Apr 09 |
martin |
88 |
// Register formatters |
4901 |
23 Apr 09 |
martin |
89 |
cc.setObject("export.formatter.&arrayBatches(name)", new NameableFormatter()); |
4901 |
23 Apr 09 |
martin |
90 |
|
4901 |
23 Apr 09 |
martin |
91 |
// Register dataloaders |
4901 |
23 Apr 09 |
martin |
92 |
String designParameter = "arrayDesign"; |
4901 |
23 Apr 09 |
martin |
93 |
ItemQuery<ArrayBatch> batchQuery = ArrayBatch.getQuery(); |
4901 |
23 Apr 09 |
martin |
94 |
batchQuery.include(cc.getInclude()); |
4901 |
23 Apr 09 |
martin |
95 |
batchQuery.restrict(Restrictions.eq(Hql.property("arrayDesign"), Expressions.parameter(designParameter))); |
4901 |
23 Apr 09 |
martin |
96 |
batchQuery.order(Orders.asc(Hql.property("name"))); |
7604 |
25 Feb 19 |
nicklas |
97 |
cc.setObject("export.dataloader.&arrayBatches(name)", new ItemQueryLoader<ArrayDesign>(batchQuery, designParameter)); |
4901 |
23 Apr 09 |
martin |
98 |
} |
1411 |
06 Oct 05 |
gregory |
99 |
%> |
1411 |
06 Oct 05 |
gregory |
100 |
<% |
1820 |
24 Jan 06 |
nicklas |
101 |
final SessionControl sc = Base.getExistingSessionControl(pageContext, true); |
1666 |
25 Nov 05 |
nicklas |
102 |
final String ID = sc.getId(); |
1820 |
24 Jan 06 |
nicklas |
103 |
final String cmd = request.getParameter("cmd"); |
1820 |
24 Jan 06 |
nicklas |
104 |
final String root = request.getContextPath()+"/"; |
1820 |
24 Jan 06 |
nicklas |
105 |
final String mode = request.getParameter("mode"); |
1820 |
24 Jan 06 |
nicklas |
106 |
final String callback = request.getParameter("callback"); |
1820 |
24 Jan 06 |
nicklas |
107 |
final String itemId = request.getParameter("item_id"); |
1820 |
24 Jan 06 |
nicklas |
108 |
final String listPage = "list_designs.jsp?ID="+ID |
1820 |
24 Jan 06 |
nicklas |
109 |
+(mode == null ? "" : "&mode="+mode) |
1820 |
24 Jan 06 |
nicklas |
110 |
+(callback == null ? "" : "&callback="+callback) |
1820 |
24 Jan 06 |
nicklas |
111 |
+(itemId == null ? "" : "&item_id="+itemId); |
1820 |
24 Jan 06 |
nicklas |
112 |
final String viewPage = "view_design.jsp?ID="+ID; |
1820 |
24 Jan 06 |
nicklas |
113 |
final String editPage = "edit_design.jsp?ID="+ID; |
1411 |
06 Oct 05 |
gregory |
114 |
|
1820 |
24 Jan 06 |
nicklas |
115 |
String forward = null; |
1820 |
24 Jan 06 |
nicklas |
116 |
String redirect = null; |
1820 |
24 Jan 06 |
nicklas |
117 |
String message = null; |
1820 |
24 Jan 06 |
nicklas |
118 |
DbControl dc = null; |
1820 |
24 Jan 06 |
nicklas |
119 |
|
1411 |
06 Oct 05 |
gregory |
120 |
try |
1411 |
06 Oct 05 |
gregory |
121 |
{ |
1820 |
24 Jan 06 |
nicklas |
122 |
if (cmd == null || "List".equals(cmd)) |
1820 |
24 Jan 06 |
nicklas |
123 |
{ |
1820 |
24 Jan 06 |
nicklas |
124 |
// Display the list page without updatinging the current context |
2811 |
26 Oct 06 |
nicklas |
125 |
Base.getAndSetCurrentContext(sc, itemType, null, defaultContext, true); |
1820 |
24 Jan 06 |
nicklas |
126 |
redirect = listPage; |
1820 |
24 Jan 06 |
nicklas |
127 |
} |
1820 |
24 Jan 06 |
nicklas |
128 |
else if ("UpdateContext".equals(cmd)) |
1820 |
24 Jan 06 |
nicklas |
129 |
{ |
1820 |
24 Jan 06 |
nicklas |
130 |
// Display the list page after updating the current context from the request parameters |
1820 |
24 Jan 06 |
nicklas |
131 |
Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1820 |
24 Jan 06 |
nicklas |
132 |
redirect = listPage; |
1820 |
24 Jan 06 |
nicklas |
133 |
} |
1820 |
24 Jan 06 |
nicklas |
134 |
else if ("LoadContext".equals(cmd)) |
1820 |
24 Jan 06 |
nicklas |
135 |
{ |
1820 |
24 Jan 06 |
nicklas |
136 |
// Display the list page after loading a saved context |
1820 |
24 Jan 06 |
nicklas |
137 |
int contextId = Values.getInt(request.getParameter("context")); |
1820 |
24 Jan 06 |
nicklas |
138 |
Base.loadContext(sc, contextId, defaultContext); |
1820 |
24 Jan 06 |
nicklas |
139 |
redirect = listPage; |
1820 |
24 Jan 06 |
nicklas |
140 |
} |
1666 |
25 Nov 05 |
nicklas |
141 |
|
1820 |
24 Jan 06 |
nicklas |
142 |
else if ("ViewItem".equals(cmd)) |
1820 |
24 Jan 06 |
nicklas |
143 |
{ |
1820 |
24 Jan 06 |
nicklas |
144 |
// Display the view page for a single item |
1820 |
24 Jan 06 |
nicklas |
145 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1820 |
24 Jan 06 |
nicklas |
146 |
forward = viewPage; |
1820 |
24 Jan 06 |
nicklas |
147 |
} |
1820 |
24 Jan 06 |
nicklas |
148 |
else if ("EditItem".equals(cmd)) |
1820 |
24 Jan 06 |
nicklas |
149 |
{ |
1820 |
24 Jan 06 |
nicklas |
150 |
// Display the edit page for a single item (should be opened in a popup) |
1820 |
24 Jan 06 |
nicklas |
151 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
3859 |
18 Oct 07 |
nicklas |
152 |
forward = editPage; |
1820 |
24 Jan 06 |
nicklas |
153 |
} |
1820 |
24 Jan 06 |
nicklas |
154 |
else if ("NewItem".equals(cmd)) |
1820 |
24 Jan 06 |
nicklas |
155 |
{ |
1820 |
24 Jan 06 |
nicklas |
156 |
// Display the edit page for a new item (should be opened in a popup) |
1820 |
24 Jan 06 |
nicklas |
157 |
if (!sc.hasPermission(Permission.CREATE, itemType)) |
1666 |
25 Nov 05 |
nicklas |
158 |
{ |
1820 |
24 Jan 06 |
nicklas |
159 |
throw new PermissionDeniedException(Permission.CREATE, itemType.toString()); |
1666 |
25 Nov 05 |
nicklas |
160 |
} |
1820 |
24 Jan 06 |
nicklas |
161 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1820 |
24 Jan 06 |
nicklas |
162 |
cc.setId(0); |
1820 |
24 Jan 06 |
nicklas |
163 |
redirect = editPage; |
1820 |
24 Jan 06 |
nicklas |
164 |
} |
1820 |
24 Jan 06 |
nicklas |
165 |
else if ("UpdateItem".equals(cmd)) |
1820 |
24 Jan 06 |
nicklas |
166 |
{ |
1820 |
24 Jan 06 |
nicklas |
167 |
// Update the properties on an item (will close the popup) |
1820 |
24 Jan 06 |
nicklas |
168 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, defaultContext); |
2598 |
28 Aug 06 |
nicklas |
169 |
final int maxRecent = Base.getMaxRecent(sc); |
7954 |
12 May 21 |
nicklas |
170 |
dc = sc.newDbControl(":Edit "+itemType); |
7605 |
26 Feb 19 |
nicklas |
171 |
ArrayDesign design = cc.getObject("item"); |
3820 |
12 Oct 07 |
nicklas |
172 |
|
3820 |
12 Oct 07 |
nicklas |
173 |
String[] pv = request.getParameter("platform").split(":"); |
6312 |
28 Aug 13 |
nicklas |
174 |
Platform platform = null; |
6312 |
28 Aug 13 |
nicklas |
175 |
PlatformVariant variant = null; |
6312 |
28 Aug 13 |
nicklas |
176 |
if ("PLATFORM".equals(pv[0])) |
6312 |
28 Aug 13 |
nicklas |
177 |
{ |
6312 |
28 Aug 13 |
nicklas |
178 |
int platformId = Values.getInt(pv[1]); |
6312 |
28 Aug 13 |
nicklas |
179 |
platform = Platform.getById(dc, platformId); |
6312 |
28 Aug 13 |
nicklas |
180 |
} |
6312 |
28 Aug 13 |
nicklas |
181 |
else |
6312 |
28 Aug 13 |
nicklas |
182 |
{ |
6312 |
28 Aug 13 |
nicklas |
183 |
int variantId = Values.getInt(pv[1]); |
6312 |
28 Aug 13 |
nicklas |
184 |
variant = PlatformVariant.getById(dc, variantId); |
6312 |
28 Aug 13 |
nicklas |
185 |
platform = variant.getPlatform(); |
6312 |
28 Aug 13 |
nicklas |
186 |
} |
7703 |
11 Apr 19 |
nicklas |
187 |
cc.setRecent(Item.PLATFORM, platform, maxRecent); |
7703 |
11 Apr 19 |
nicklas |
188 |
cc.setRecent(Item.PLATFORMVARIANT, variant, maxRecent); |
1820 |
24 Jan 06 |
nicklas |
189 |
if (design == null) |
1666 |
25 Nov 05 |
nicklas |
190 |
{ |
3820 |
12 Oct 07 |
nicklas |
191 |
if (variant != null) |
3820 |
12 Oct 07 |
nicklas |
192 |
{ |
3820 |
12 Oct 07 |
nicklas |
193 |
design = ArrayDesign.getNew(dc, variant); |
3820 |
12 Oct 07 |
nicklas |
194 |
} |
3820 |
12 Oct 07 |
nicklas |
195 |
else |
3820 |
12 Oct 07 |
nicklas |
196 |
{ |
3820 |
12 Oct 07 |
nicklas |
197 |
design = ArrayDesign.getNew(dc, platform); |
3820 |
12 Oct 07 |
nicklas |
198 |
} |
1820 |
24 Jan 06 |
nicklas |
199 |
message = "Array design created"; |
1820 |
24 Jan 06 |
nicklas |
200 |
dc.saveItem(design); |
6037 |
29 Mar 12 |
nicklas |
201 |
if (Values.getBoolean(request.getParameter("setAsProjectDefault"))) |
5964 |
15 Feb 12 |
nicklas |
202 |
{ |
5964 |
15 Feb 12 |
nicklas |
203 |
Project.getById(dc, sc.getActiveProjectId()).addDefaultItem(design); |
5964 |
15 Feb 12 |
nicklas |
204 |
} |
1666 |
25 Nov 05 |
nicklas |
205 |
} |
1820 |
24 Jan 06 |
nicklas |
206 |
else |
1666 |
25 Nov 05 |
nicklas |
207 |
{ |
5060 |
19 Aug 09 |
nicklas |
208 |
dc.reattachItem(design, false); |
3820 |
12 Oct 07 |
nicklas |
209 |
if (variant != null) |
3820 |
12 Oct 07 |
nicklas |
210 |
{ |
3820 |
12 Oct 07 |
nicklas |
211 |
design.setVariant(variant); |
3820 |
12 Oct 07 |
nicklas |
212 |
} |
3820 |
12 Oct 07 |
nicklas |
213 |
else |
3820 |
12 Oct 07 |
nicklas |
214 |
{ |
3820 |
12 Oct 07 |
nicklas |
215 |
design.setPlatform(platform); |
3820 |
12 Oct 07 |
nicklas |
216 |
} |
1820 |
24 Jan 06 |
nicklas |
217 |
message = "Array design updated"; |
1666 |
25 Nov 05 |
nicklas |
218 |
} |
5498 |
17 Nov 10 |
nicklas |
219 |
JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.item(Item.ARRAYDESIGN), design); |
7604 |
25 Feb 19 |
nicklas |
220 |
ExtensionsInvoker<OnSaveAction> invoker = EditUtil.useOnSaveExtensions(jspContext); |
5498 |
17 Nov 10 |
nicklas |
221 |
try |
5498 |
17 Nov 10 |
nicklas |
222 |
{ |
5498 |
17 Nov 10 |
nicklas |
223 |
design.setName(Values.getStringOrNull(request.getParameter("name"))); |
5498 |
17 Nov 10 |
nicklas |
224 |
design.setDescription(Values.getStringOrNull(request.getParameter("description"))); |
5498 |
17 Nov 10 |
nicklas |
225 |
design.setNumArrays(Values.getInt(request.getParameter("numArrays"), 1)); |
5498 |
17 Nov 10 |
nicklas |
226 |
|
5498 |
17 Nov 10 |
nicklas |
227 |
// Data files tab |
5498 |
17 Nov 10 |
nicklas |
228 |
boolean validate = Values.getBoolean(request.getParameter("datafiles.validate")); |
5623 |
06 May 11 |
nicklas |
229 |
Base.updateFiles(dc, design, request, validate, cc, maxRecent); |
5498 |
17 Nov 10 |
nicklas |
230 |
|
5498 |
17 Nov 10 |
nicklas |
231 |
// Annotations tab |
5498 |
17 Nov 10 |
nicklas |
232 |
Base.updateAnnotations(dc, design, design, request); |
5498 |
17 Nov 10 |
nicklas |
233 |
|
5498 |
17 Nov 10 |
nicklas |
234 |
// OnSave extensions |
5498 |
17 Nov 10 |
nicklas |
235 |
invoker.render(OnSaveRenderer.ON_SAVE); |
5498 |
17 Nov 10 |
nicklas |
236 |
dc.commit(); |
5498 |
17 Nov 10 |
nicklas |
237 |
invoker.render(OnSaveRenderer.ON_COMMIT); |
5498 |
17 Nov 10 |
nicklas |
238 |
} |
5498 |
17 Nov 10 |
nicklas |
239 |
catch (Exception ex) |
5498 |
17 Nov 10 |
nicklas |
240 |
{ |
5498 |
17 Nov 10 |
nicklas |
241 |
invoker.render(OnSaveRenderer.onRollback(ex)); |
5498 |
17 Nov 10 |
nicklas |
242 |
throw ex; |
5498 |
17 Nov 10 |
nicklas |
243 |
} |
5498 |
17 Nov 10 |
nicklas |
244 |
finally |
5498 |
17 Nov 10 |
nicklas |
245 |
{ |
5498 |
17 Nov 10 |
nicklas |
246 |
cc.removeObject("item"); |
5498 |
17 Nov 10 |
nicklas |
247 |
} |
1820 |
24 Jan 06 |
nicklas |
248 |
} |
1820 |
24 Jan 06 |
nicklas |
249 |
else if ("DeleteItem".equals(cmd)) |
1820 |
24 Jan 06 |
nicklas |
250 |
{ |
1820 |
24 Jan 06 |
nicklas |
251 |
// Delete a single item and then return to the view page |
7954 |
12 May 21 |
nicklas |
252 |
dc = sc.newDbControl(":Delete "+itemType); |
1820 |
24 Jan 06 |
nicklas |
253 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1820 |
24 Jan 06 |
nicklas |
254 |
RemovableUtil.setRemoved(dc, itemType, Collections.singleton(cc.getId()), true); |
1820 |
24 Jan 06 |
nicklas |
255 |
dc.commit(); |
1820 |
24 Jan 06 |
nicklas |
256 |
redirect = viewPage; |
1820 |
24 Jan 06 |
nicklas |
257 |
} |
1820 |
24 Jan 06 |
nicklas |
258 |
else if ("DeleteItems".equals(cmd)) |
1820 |
24 Jan 06 |
nicklas |
259 |
{ |
1820 |
24 Jan 06 |
nicklas |
260 |
// Delete all selected items on the list page |
7954 |
12 May 21 |
nicklas |
261 |
dc = sc.newDbControl(":Delete "+itemType); |
1820 |
24 Jan 06 |
nicklas |
262 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1820 |
24 Jan 06 |
nicklas |
263 |
int numTotal = cc.getSelected().size(); |
1820 |
24 Jan 06 |
nicklas |
264 |
int numRemoved = RemovableUtil.setRemoved(dc, itemType, cc.getSelected(), true); |
1820 |
24 Jan 06 |
nicklas |
265 |
dc.commit(); |
1820 |
24 Jan 06 |
nicklas |
266 |
if (numTotal != numRemoved) |
1666 |
25 Nov 05 |
nicklas |
267 |
{ |
1820 |
24 Jan 06 |
nicklas |
268 |
message = (numRemoved == 0 ? "No" : "Only "+numRemoved+" of "+numTotal) + " items could be deleted, because you have no DELETE permission"; |
1666 |
25 Nov 05 |
nicklas |
269 |
} |
6192 |
31 Oct 12 |
nicklas |
270 |
redirect = listPage; |
1820 |
24 Jan 06 |
nicklas |
271 |
} |
1820 |
24 Jan 06 |
nicklas |
272 |
else if ("RestoreItem".equals(cmd)) |
1820 |
24 Jan 06 |
nicklas |
273 |
{ |
1820 |
24 Jan 06 |
nicklas |
274 |
// Restore a single item and then return to the view page |
7954 |
12 May 21 |
nicklas |
275 |
dc = sc.newDbControl(":Restore "+itemType); |
1820 |
24 Jan 06 |
nicklas |
276 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1820 |
24 Jan 06 |
nicklas |
277 |
RemovableUtil.setRemoved(dc, itemType, Collections.singleton(cc.getId()), false); |
1820 |
24 Jan 06 |
nicklas |
278 |
dc.commit(); |
1820 |
24 Jan 06 |
nicklas |
279 |
redirect = viewPage; |
1820 |
24 Jan 06 |
nicklas |
280 |
} |
1820 |
24 Jan 06 |
nicklas |
281 |
else if ("RestoreItems".equals(cmd)) |
1820 |
24 Jan 06 |
nicklas |
282 |
{ |
1820 |
24 Jan 06 |
nicklas |
283 |
// Restore all selected items on the list page |
7954 |
12 May 21 |
nicklas |
284 |
dc = sc.newDbControl(":Restore "+itemType); |
1820 |
24 Jan 06 |
nicklas |
285 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1820 |
24 Jan 06 |
nicklas |
286 |
int numTotal = cc.getSelected().size(); |
1820 |
24 Jan 06 |
nicklas |
287 |
int numRemoved = RemovableUtil.setRemoved(dc, itemType, cc.getSelected(), false); |
1820 |
24 Jan 06 |
nicklas |
288 |
dc.commit(); |
1820 |
24 Jan 06 |
nicklas |
289 |
if (numTotal != numRemoved) |
1666 |
25 Nov 05 |
nicklas |
290 |
{ |
2528 |
15 Aug 06 |
martin |
291 |
message = (numRemoved == 0 ? "No" : "Only "+numRemoved+" of "+numTotal) + " items could be restored, because you have no WRITE permission"; |
1666 |
25 Nov 05 |
nicklas |
292 |
} |
6192 |
31 Oct 12 |
nicklas |
293 |
redirect = listPage; |
1820 |
24 Jan 06 |
nicklas |
294 |
} |
1820 |
24 Jan 06 |
nicklas |
295 |
else if ("ShareItem".equals(cmd)) |
1820 |
24 Jan 06 |
nicklas |
296 |
{ |
1820 |
24 Jan 06 |
nicklas |
297 |
// Display a popup window for sharing a single item |
7954 |
12 May 21 |
nicklas |
298 |
dc = sc.newDbControl(":Share "+itemType); |
1820 |
24 Jan 06 |
nicklas |
299 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1820 |
24 Jan 06 |
nicklas |
300 |
MultiPermissions permissions = ShareableUtil.getMultiPermissions(dc, itemType, Collections.singleton(cc.getId())); |
1820 |
24 Jan 06 |
nicklas |
301 |
dc.close(); |
1820 |
24 Jan 06 |
nicklas |
302 |
cc.setObject("MultiPermissions", permissions); |
1820 |
24 Jan 06 |
nicklas |
303 |
redirect = "../../common/share/share.jsp?ID="+ID+"&item_type="+itemType.name(); |
1820 |
24 Jan 06 |
nicklas |
304 |
} |
1820 |
24 Jan 06 |
nicklas |
305 |
else if ("ShareItems".equals(cmd)) |
1820 |
24 Jan 06 |
nicklas |
306 |
{ |
1820 |
24 Jan 06 |
nicklas |
307 |
// Display a popup window for sharing all selected items on the list page |
7954 |
12 May 21 |
nicklas |
308 |
dc = sc.newDbControl(":Share "+itemType); |
1820 |
24 Jan 06 |
nicklas |
309 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1820 |
24 Jan 06 |
nicklas |
310 |
MultiPermissions permissions = ShareableUtil.getMultiPermissions(dc, itemType, cc.getSelected()); |
1820 |
24 Jan 06 |
nicklas |
311 |
dc.close(); |
1820 |
24 Jan 06 |
nicklas |
312 |
cc.setObject("MultiPermissions", permissions); |
1820 |
24 Jan 06 |
nicklas |
313 |
redirect = "../../common/share/share.jsp?ID="+ID+"&item_type="+itemType.name(); |
1820 |
24 Jan 06 |
nicklas |
314 |
} |
4578 |
13 Oct 08 |
martin |
315 |
else if ("SetOwnerOfItem".equals(cmd)) |
2919 |
15 Nov 06 |
nicklas |
316 |
{ |
4578 |
13 Oct 08 |
martin |
317 |
// Change owner of items selected on a list page |
7954 |
12 May 21 |
nicklas |
318 |
dc = sc.newDbControl(":Set owner of "+itemType); |
2919 |
15 Nov 06 |
nicklas |
319 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
4587 |
15 Oct 08 |
martin |
320 |
OwnedItem item = (OwnedItem)itemType.getById(dc, cc.getId()); |
4587 |
15 Oct 08 |
martin |
321 |
cc.setObject("OwnedItems", Collections.singleton(item)); |
4578 |
13 Oct 08 |
martin |
322 |
redirect = "../../common/ownership/ownership.jsp?ID="+ID+"&item_type="+itemType.name(); |
2919 |
15 Nov 06 |
nicklas |
323 |
} |
4578 |
13 Oct 08 |
martin |
324 |
else if ("SetOwnerOfItems".equals(cmd)) |
2919 |
15 Nov 06 |
nicklas |
325 |
{ |
4578 |
13 Oct 08 |
martin |
326 |
// Change owner of items selected on a list page |
7954 |
12 May 21 |
nicklas |
327 |
dc = sc.newDbControl(":Set owner of "+itemType); |
2919 |
15 Nov 06 |
nicklas |
328 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
4587 |
15 Oct 08 |
martin |
329 |
Set<OwnedItem> items = new HashSet<OwnedItem>(); |
4587 |
15 Oct 08 |
martin |
330 |
for (Integer id : cc.getSelected()) |
4587 |
15 Oct 08 |
martin |
331 |
{ |
4587 |
15 Oct 08 |
martin |
332 |
if (id != null) items.add((OwnedItem)itemType.getById(dc, id)); |
4587 |
15 Oct 08 |
martin |
333 |
} |
4587 |
15 Oct 08 |
martin |
334 |
dc.close(); |
4587 |
15 Oct 08 |
martin |
335 |
cc.setObject("OwnedItems", items); |
4578 |
13 Oct 08 |
martin |
336 |
redirect = "../../common/ownership/ownership.jsp?ID="+ID+"&item_type="+itemType.name(); |
2919 |
15 Nov 06 |
nicklas |
337 |
} |
6695 |
28 Jan 15 |
nicklas |
338 |
else if ("InheritAnnotations".equals(cmd)) |
6695 |
28 Jan 15 |
nicklas |
339 |
{ |
6695 |
28 Jan 15 |
nicklas |
340 |
// Change owner of items selected on a list page |
7954 |
12 May 21 |
nicklas |
341 |
dc = sc.newDbControl(":Inherit annotations "+itemType); |
6695 |
28 Jan 15 |
nicklas |
342 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
6695 |
28 Jan 15 |
nicklas |
343 |
Set<AnnotatedItem> items = new HashSet<AnnotatedItem>(); |
6695 |
28 Jan 15 |
nicklas |
344 |
for (Integer id : cc.getSelected()) |
6695 |
28 Jan 15 |
nicklas |
345 |
{ |
6695 |
28 Jan 15 |
nicklas |
346 |
if (id != null) items.add((AnnotatedItem)itemType.getById(dc, id)); |
6695 |
28 Jan 15 |
nicklas |
347 |
} |
6695 |
28 Jan 15 |
nicklas |
348 |
dc.close(); |
6695 |
28 Jan 15 |
nicklas |
349 |
cc.setObject("AnnotatedItems", items); |
6695 |
28 Jan 15 |
nicklas |
350 |
redirect = "../../common/annotations/batch_inherit.jsp?ID="+ID+"&item_type="+itemType.name(); |
6695 |
28 Jan 15 |
nicklas |
351 |
} |
1820 |
24 Jan 06 |
nicklas |
352 |
else if ("ExportItems".equals(cmd)) |
1820 |
24 Jan 06 |
nicklas |
353 |
{ |
1820 |
24 Jan 06 |
nicklas |
354 |
// Run an export plugin in a list context |
1820 |
24 Jan 06 |
nicklas |
355 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1820 |
24 Jan 06 |
nicklas |
356 |
final ItemQuery<ArrayDesign> query = ArrayDesign.getQuery(); |
7954 |
12 May 21 |
nicklas |
357 |
dc = sc.newDbControl(":Export "+itemType); |
7914 |
23 Feb 21 |
nicklas |
358 |
JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.list(itemType), null); |
7914 |
23 Feb 21 |
nicklas |
359 |
cc.configureQuery(dc, query, jspContext, true); |
1820 |
24 Jan 06 |
nicklas |
360 |
cc.setQuery(query); |
4901 |
23 Apr 09 |
martin |
361 |
registerExportUtils(cc); |
7604 |
25 Feb 19 |
nicklas |
362 |
ExtensionsInvoker<ListColumnAction<ArrayDesign,?>> listInvoker = ListColumnUtil.useExtensions(jspContext); |
7604 |
25 Feb 19 |
nicklas |
363 |
listInvoker.render(new ListColumnExportRenderer<ArrayDesign>(cc)); |
6039 |
29 Mar 12 |
nicklas |
364 |
dc.close(); |
1820 |
24 Jan 06 |
nicklas |
365 |
redirect = "../../common/export/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=LIST&title=Export+array+designs"; |
1820 |
24 Jan 06 |
nicklas |
366 |
} |
1820 |
24 Jan 06 |
nicklas |
367 |
else if ("ExportItem".equals(cmd)) |
1820 |
24 Jan 06 |
nicklas |
368 |
{ |
1820 |
24 Jan 06 |
nicklas |
369 |
// Run an export plugin in single-item context |
1820 |
24 Jan 06 |
nicklas |
370 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
4901 |
23 Apr 09 |
martin |
371 |
registerExportUtils(cc); |
1820 |
24 Jan 06 |
nicklas |
372 |
redirect = "../../common/export/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=ITEM&title=Export+array+design"; |
1820 |
24 Jan 06 |
nicklas |
373 |
} |
1820 |
24 Jan 06 |
nicklas |
374 |
else if ("ImportItems".equals(cmd)) |
1820 |
24 Jan 06 |
nicklas |
375 |
{ |
1820 |
24 Jan 06 |
nicklas |
376 |
// Run an import plugin in a list context |
1820 |
24 Jan 06 |
nicklas |
377 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1820 |
24 Jan 06 |
nicklas |
378 |
final ItemQuery<ArrayDesign> query = ArrayDesign.getQuery(); |
7954 |
12 May 21 |
nicklas |
379 |
dc = sc.newDbControl(":Import "+itemType); |
7914 |
23 Feb 21 |
nicklas |
380 |
JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.list(itemType), null); |
7914 |
23 Feb 21 |
nicklas |
381 |
cc.configureQuery(dc, query, jspContext, true); |
5590 |
16 Mar 11 |
nicklas |
382 |
dc.close(); |
1820 |
24 Jan 06 |
nicklas |
383 |
cc.setQuery(query); |
1820 |
24 Jan 06 |
nicklas |
384 |
redirect = "../../common/import/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=LIST&title=Import+array+designs"; |
1820 |
24 Jan 06 |
nicklas |
385 |
} |
1820 |
24 Jan 06 |
nicklas |
386 |
else if ("ImportItem".equals(cmd)) |
1820 |
24 Jan 06 |
nicklas |
387 |
{ |
1820 |
24 Jan 06 |
nicklas |
388 |
// Run an import plugin in single-item context |
1820 |
24 Jan 06 |
nicklas |
389 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1820 |
24 Jan 06 |
nicklas |
390 |
redirect = "../../common/import/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=ITEM&title=Import+features"; |
1820 |
24 Jan 06 |
nicklas |
391 |
} |
1820 |
24 Jan 06 |
nicklas |
392 |
else if ("RunListPlugin".equals(cmd)) |
1820 |
24 Jan 06 |
nicklas |
393 |
{ |
1820 |
24 Jan 06 |
nicklas |
394 |
// Run another plugin in a list context |
1820 |
24 Jan 06 |
nicklas |
395 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1820 |
24 Jan 06 |
nicklas |
396 |
final ItemQuery<ArrayDesign> query = ArrayDesign.getQuery(); |
7954 |
12 May 21 |
nicklas |
397 |
dc = sc.newDbControl(":Run plugin "+itemType); |
7914 |
23 Feb 21 |
nicklas |
398 |
JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.list(itemType), null); |
7914 |
23 Feb 21 |
nicklas |
399 |
cc.configureQuery(dc, query, jspContext, true); |
5590 |
16 Mar 11 |
nicklas |
400 |
dc.close(); |
1820 |
24 Jan 06 |
nicklas |
401 |
cc.setQuery(query); |
1820 |
24 Jan 06 |
nicklas |
402 |
redirect = "../../common/plugin/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=LIST&main_type=OTHER&title=Run+plugin"; |
1820 |
24 Jan 06 |
nicklas |
403 |
} |
1820 |
24 Jan 06 |
nicklas |
404 |
else if ("RunPlugin".equals(cmd)) |
1820 |
24 Jan 06 |
nicklas |
405 |
{ |
1820 |
24 Jan 06 |
nicklas |
406 |
// Run another plugin in single-item context |
1820 |
24 Jan 06 |
nicklas |
407 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1820 |
24 Jan 06 |
nicklas |
408 |
redirect = "../../common/plugin/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=ITEM&main_type=OTHER&title=Run+plugin"; |
1820 |
24 Jan 06 |
nicklas |
409 |
} |
1976 |
13 Feb 06 |
nicklas |
410 |
else if ("ManagePlates".equals(cmd)) |
1976 |
13 Feb 06 |
nicklas |
411 |
{ |
1976 |
13 Feb 06 |
nicklas |
412 |
// Open the attach plates page (in a popup) |
1976 |
13 Feb 06 |
nicklas |
413 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1976 |
13 Feb 06 |
nicklas |
414 |
forward = "manage_plates.jsp"; |
1976 |
13 Feb 06 |
nicklas |
415 |
} |
1976 |
13 Feb 06 |
nicklas |
416 |
else if ("UpdatePlates".equals(cmd)) |
1976 |
13 Feb 06 |
nicklas |
417 |
{ |
1976 |
13 Feb 06 |
nicklas |
418 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, defaultContext); |
7954 |
12 May 21 |
nicklas |
419 |
dc = sc.newDbControl(":Update plates"); |
7605 |
26 Feb 19 |
nicklas |
420 |
ArrayDesign design = cc.getObject("item"); |
5060 |
19 Aug 09 |
nicklas |
421 |
dc.reattachItem(design, false); |
1976 |
13 Feb 06 |
nicklas |
422 |
|
1976 |
13 Feb 06 |
nicklas |
423 |
List<Plate> plates = new java.util.LinkedList<Plate>(); |
6312 |
28 Aug 13 |
nicklas |
424 |
for (String pId : request.getParameter("+PLATE").split(",")) |
1976 |
13 Feb 06 |
nicklas |
425 |
{ |
6312 |
28 Aug 13 |
nicklas |
426 |
plates.add(Plate.getById(dc, Values.getInt(pId))); |
1976 |
13 Feb 06 |
nicklas |
427 |
} |
1976 |
13 Feb 06 |
nicklas |
428 |
design.setPlateList(plates); |
1976 |
13 Feb 06 |
nicklas |
429 |
|
1976 |
13 Feb 06 |
nicklas |
430 |
dc.commit(); |
1976 |
13 Feb 06 |
nicklas |
431 |
cc.removeObject("item"); |
1976 |
13 Feb 06 |
nicklas |
432 |
} |
3482 |
13 Jun 07 |
nicklas |
433 |
else if ("VerifyReporters".equals(cmd)) |
3482 |
13 Jun 07 |
nicklas |
434 |
{ |
3482 |
13 Jun 07 |
nicklas |
435 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
3482 |
13 Jun 07 |
nicklas |
436 |
redirect = "../../common/plugin/index.jsp?ID="+ID+"&cmd=NewJob&plugin_class=net.sf.basedb.plugins.CdfFileReporterImporter"; |
3482 |
13 Jun 07 |
nicklas |
437 |
redirect += "&item_type=ARRAYDESIGN&context_type=LIST&title=Verify+reporters¶meter:mode=verify"; |
3482 |
13 Jun 07 |
nicklas |
438 |
} |
1820 |
24 Jan 06 |
nicklas |
439 |
else |
1820 |
24 Jan 06 |
nicklas |
440 |
{ |
1820 |
24 Jan 06 |
nicklas |
441 |
throw new WebException("popup", "Invalid command", "The command {1} is not recognised as a valid command.", cmd); |
1820 |
24 Jan 06 |
nicklas |
442 |
} |
1411 |
06 Oct 05 |
gregory |
443 |
} |
1411 |
06 Oct 05 |
gregory |
444 |
finally |
1411 |
06 Oct 05 |
gregory |
445 |
{ |
1411 |
06 Oct 05 |
gregory |
446 |
if (dc != null) dc.close(); |
1411 |
06 Oct 05 |
gregory |
447 |
} |
1820 |
24 Jan 06 |
nicklas |
448 |
|
1820 |
24 Jan 06 |
nicklas |
449 |
if (forward != null) |
1820 |
24 Jan 06 |
nicklas |
450 |
{ |
6192 |
31 Oct 12 |
nicklas |
451 |
sc.setSessionSetting("alert-message", message); |
1820 |
24 Jan 06 |
nicklas |
452 |
pageContext.forward(forward); |
1820 |
24 Jan 06 |
nicklas |
453 |
} |
1820 |
24 Jan 06 |
nicklas |
454 |
else if (redirect != null) |
1820 |
24 Jan 06 |
nicklas |
455 |
{ |
6192 |
31 Oct 12 |
nicklas |
456 |
sc.setSessionSetting("alert-message", message); |
1820 |
24 Jan 06 |
nicklas |
457 |
response.sendRedirect(redirect); |
1820 |
24 Jan 06 |
nicklas |
458 |
} |
1820 |
24 Jan 06 |
nicklas |
459 |
else if (message == null) |
1820 |
24 Jan 06 |
nicklas |
460 |
{ |
1820 |
24 Jan 06 |
nicklas |
461 |
response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&wait=0"); |
1820 |
24 Jan 06 |
nicklas |
462 |
} |
1820 |
24 Jan 06 |
nicklas |
463 |
else |
1820 |
24 Jan 06 |
nicklas |
464 |
{ |
1820 |
24 Jan 06 |
nicklas |
465 |
response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&message="+HTML.urlEncode(message)); |
1820 |
24 Jan 06 |
nicklas |
466 |
} |
1820 |
24 Jan 06 |
nicklas |
467 |
%> |
1820 |
24 Jan 06 |
nicklas |
468 |
|