1 | <%-- $Id $ |
---|
2 | ------------------------------------------------------------------ |
---|
3 | Copyright (C) 2011 Nicklas Nordborg |
---|
4 | |
---|
5 | This file is part of BASE - BioArray Software Environment. |
---|
6 | Available at http://base.thep.lu.se/ |
---|
7 | |
---|
8 | This file is part of BASE. |
---|
9 | |
---|
10 | BASE is free software; you can redistribute it and/or |
---|
11 | modify it under the terms of the GNU General Public License |
---|
12 | as published by the Free Software Foundation; either version 3 |
---|
13 | of the License, or (at your option) any later version. |
---|
14 | |
---|
15 | BASE is distributed in the hope that it will be useful, |
---|
16 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
18 | GNU General Public License for more details. |
---|
19 | |
---|
20 | You should have received a copy of the GNU General Public License |
---|
21 | along with BASE. If not, see <http://www.gnu.org/licenses/>. |
---|
22 | ------------------------------------------------------------------ |
---|
23 | |
---|
24 | --%> |
---|
25 | <%@ page pageEncoding="UTF-8" session="false" |
---|
26 | import="net.sf.basedb.core.SessionControl" |
---|
27 | import="net.sf.basedb.core.DbControl" |
---|
28 | import="net.sf.basedb.core.DerivedBioAssay" |
---|
29 | import="net.sf.basedb.core.PhysicalBioAssay" |
---|
30 | import="net.sf.basedb.core.RawBioAssay" |
---|
31 | import="net.sf.basedb.core.ItemSubtype" |
---|
32 | import="net.sf.basedb.core.Extract" |
---|
33 | import="net.sf.basedb.core.Protocol" |
---|
34 | import="net.sf.basedb.core.Software" |
---|
35 | import="net.sf.basedb.core.Hardware" |
---|
36 | import="net.sf.basedb.core.Item" |
---|
37 | import="net.sf.basedb.core.Include" |
---|
38 | import="net.sf.basedb.core.User" |
---|
39 | import="net.sf.basedb.core.OwnedItem" |
---|
40 | import="net.sf.basedb.core.AnnotatedItem" |
---|
41 | import="net.sf.basedb.core.ItemQuery" |
---|
42 | import="net.sf.basedb.core.ItemResultIterator" |
---|
43 | import="net.sf.basedb.core.Permission" |
---|
44 | import="net.sf.basedb.core.PluginDefinition" |
---|
45 | import="net.sf.basedb.core.ItemContext" |
---|
46 | import="net.sf.basedb.core.MultiPermissions" |
---|
47 | import="net.sf.basedb.core.PermissionDeniedException" |
---|
48 | import="net.sf.basedb.core.ItemAlreadyExistsException" |
---|
49 | import="net.sf.basedb.core.query.Hql" |
---|
50 | import="net.sf.basedb.core.query.Orders" |
---|
51 | import="net.sf.basedb.core.query.Restrictions" |
---|
52 | import="net.sf.basedb.core.query.Expressions" |
---|
53 | import="net.sf.basedb.util.RemovableUtil" |
---|
54 | import="net.sf.basedb.util.ShareableUtil" |
---|
55 | import="net.sf.basedb.util.IncludeExcludeFilter" |
---|
56 | import="net.sf.basedb.clients.web.Base" |
---|
57 | import="net.sf.basedb.clients.web.WebException" |
---|
58 | import="net.sf.basedb.util.Values" |
---|
59 | import="net.sf.basedb.clients.web.util.HTML" |
---|
60 | import="net.sf.basedb.core.plugin.GuiContext" |
---|
61 | import="net.sf.basedb.util.extensions.ExtensionsInvoker" |
---|
62 | import="net.sf.basedb.util.formatter.NameableFormatter" |
---|
63 | import="net.sf.basedb.clients.web.extensions.ExtensionsControl" |
---|
64 | import="net.sf.basedb.clients.web.extensions.JspContext" |
---|
65 | import="net.sf.basedb.clients.web.extensions.edit.EditUtil" |
---|
66 | import="net.sf.basedb.clients.web.extensions.edit.OnSaveRenderer" |
---|
67 | import="net.sf.basedb.clients.web.extensions.list.ListColumnExportRenderer" |
---|
68 | import="net.sf.basedb.clients.web.extensions.list.ListColumnUtil" |
---|
69 | import="net.sf.basedb.clients.web.plugins.ItemQueryLoader" |
---|
70 | import="java.util.Enumeration" |
---|
71 | import="java.util.Set" |
---|
72 | import="java.util.HashSet" |
---|
73 | import="java.util.List" |
---|
74 | import="java.util.LinkedList" |
---|
75 | import="java.util.Collections" |
---|
76 | import="java.util.Arrays" |
---|
77 | %> |
---|
78 | <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> |
---|
79 | <%! |
---|
80 | private static final ItemContext defaultContext = Base.createDefaultContext("name", "name,itemSubtype,physicalBioAssay,extract,parent,description"); |
---|
81 | private static final Item itemType = Item.DERIVEDBIOASSAY; |
---|
82 | |
---|
83 | private static void registerExportUtils(ItemContext cc) |
---|
84 | { |
---|
85 | // Register formatters |
---|
86 | cc.setObject("export.formatter.&physicalBioAssays(name)", new NameableFormatter()); |
---|
87 | cc.setObject("export.formatter.&parents(name)", new NameableFormatter()); |
---|
88 | cc.setObject("export.formatter.&children(name)", new NameableFormatter()); |
---|
89 | cc.setObject("export.formatter.&rawBioAssays(name)", new NameableFormatter()); |
---|
90 | |
---|
91 | // Register dataloaders |
---|
92 | String bioassayParameter = "bioassay"; |
---|
93 | // Physical bioassays |
---|
94 | ItemQuery<PhysicalBioAssay> physicalQuery = PhysicalBioAssay.getQuery(); |
---|
95 | physicalQuery.include(cc.getInclude()); |
---|
96 | physicalQuery.join(Hql.innerJoin("derivedBioAssays", "dba")); |
---|
97 | physicalQuery.restrict(Restrictions.eq(Hql.alias("dba"), Expressions.parameter(bioassayParameter))); |
---|
98 | physicalQuery.order(Orders.asc(Hql.property("name"))); |
---|
99 | cc.setObject("export.dataloader.&physicalBioAssays(name)", new ItemQueryLoader(physicalQuery, bioassayParameter)); |
---|
100 | |
---|
101 | // Parent bioassays |
---|
102 | ItemQuery<DerivedBioAssay> parentQuery = DerivedBioAssay.getQuery(); |
---|
103 | parentQuery.include(cc.getInclude()); |
---|
104 | parentQuery.join(Hql.innerJoin("children", "c")); |
---|
105 | parentQuery.restrict(Restrictions.eq(Hql.alias("c"), Expressions.parameter(bioassayParameter))); |
---|
106 | parentQuery.order(Orders.asc(Hql.property("name"))); |
---|
107 | cc.setObject("export.dataloader.&parents(name)", new ItemQueryLoader(parentQuery, bioassayParameter)); |
---|
108 | |
---|
109 | // Child bioassays |
---|
110 | ItemQuery<DerivedBioAssay> childQuery = DerivedBioAssay.getQuery(); |
---|
111 | childQuery.include(cc.getInclude()); |
---|
112 | childQuery.join(Hql.innerJoin("parents", "p")); |
---|
113 | childQuery.restrict(Restrictions.eq(Hql.alias("p"), Expressions.parameter(bioassayParameter))); |
---|
114 | childQuery.order(Orders.asc(Hql.property("name"))); |
---|
115 | cc.setObject("export.dataloader.&children(name)", new ItemQueryLoader(childQuery, bioassayParameter)); |
---|
116 | |
---|
117 | // Child raw bioassays |
---|
118 | ItemQuery<RawBioAssay> rawQuery = RawBioAssay.getQuery(); |
---|
119 | rawQuery.include(cc.getInclude()); |
---|
120 | rawQuery.restrict(Restrictions.eq(Hql.property("parentBioAssay"), Expressions.parameter(bioassayParameter))); |
---|
121 | rawQuery.order(Orders.asc(Hql.property("name"))); |
---|
122 | cc.setObject("export.dataloader.&rawBioAssays(name)", new ItemQueryLoader(rawQuery, bioassayParameter)); |
---|
123 | |
---|
124 | } |
---|
125 | |
---|
126 | %> |
---|
127 | <% |
---|
128 | final SessionControl sc = Base.getExistingSessionControl(pageContext, true); |
---|
129 | final String ID = sc.getId(); |
---|
130 | final String cmd = request.getParameter("cmd"); |
---|
131 | final String root = request.getContextPath()+"/"; |
---|
132 | final String mode = request.getParameter("mode"); |
---|
133 | final String callback = request.getParameter("callback"); |
---|
134 | final String itemId = request.getParameter("item_id"); |
---|
135 | final String listPage = "list_bioassays.jsp?ID="+ID+"&item_id="+itemId |
---|
136 | +(mode == null ? "" : "&mode="+mode) |
---|
137 | +(callback == null ? "" : "&callback="+callback) |
---|
138 | +(itemId == null ? "" : "&item_id="+itemId); |
---|
139 | final String viewPage = "view_bioassay.jsp?ID="+ID; |
---|
140 | final String editPage = "edit_bioassay.jsp?ID="+ID; |
---|
141 | |
---|
142 | String forward = null; |
---|
143 | String redirect = null; |
---|
144 | String message = null; |
---|
145 | DbControl dc = null; |
---|
146 | |
---|
147 | try |
---|
148 | { |
---|
149 | if (cmd == null || "List".equals(cmd)) |
---|
150 | { |
---|
151 | // Display the list page without updatinging the current context |
---|
152 | ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, defaultContext, true); |
---|
153 | redirect = listPage; |
---|
154 | } |
---|
155 | else if ("UpdateContext".equals(cmd)) |
---|
156 | { |
---|
157 | // Display the list page after updating the current context from the request parameters |
---|
158 | ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
---|
159 | redirect = listPage; |
---|
160 | } |
---|
161 | else if ("LoadContext".equals(cmd)) |
---|
162 | { |
---|
163 | // Display the list page after loading a saved context |
---|
164 | int contextId = Values.getInt(request.getParameter("context")); |
---|
165 | Base.loadContext(sc, contextId, defaultContext); |
---|
166 | redirect = listPage; |
---|
167 | } |
---|
168 | else if ("ViewItem".equals(cmd)) |
---|
169 | { |
---|
170 | // Display the view page for a single item |
---|
171 | ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
---|
172 | forward = viewPage; |
---|
173 | } |
---|
174 | else if ("EditItem".equals(cmd)) |
---|
175 | { |
---|
176 | // Display the edit page for a single item (should be opened in a popup) |
---|
177 | ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
---|
178 | forward = editPage; |
---|
179 | } |
---|
180 | else if ("NewItem".equals(cmd)) |
---|
181 | { |
---|
182 | // Display the edit page for a new item (should be opened in a popup) |
---|
183 | if (!sc.hasPermission(Permission.CREATE, itemType)) |
---|
184 | { |
---|
185 | throw new PermissionDeniedException(Permission.CREATE, itemType.toString()); |
---|
186 | } |
---|
187 | ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
---|
188 | cc.setId(0); |
---|
189 | forward = editPage; |
---|
190 | } |
---|
191 | else if ("UpdateItem".equals(cmd)) |
---|
192 | { |
---|
193 | // Update the properties on an item (will close the popup) |
---|
194 | ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, defaultContext); |
---|
195 | final int maxRecent = Base.getMaxRecent(sc); |
---|
196 | dc = sc.newDbControl(); |
---|
197 | |
---|
198 | DerivedBioAssay bas = (DerivedBioAssay)cc.getObject("item"); |
---|
199 | if (bas == null) |
---|
200 | { |
---|
201 | bas = DerivedBioAssay.getNew(dc, Values.getBoolean(request.getParameter("isRoot")), null); |
---|
202 | dc.saveItem(bas); |
---|
203 | message = "Derived bioassay created"; |
---|
204 | } |
---|
205 | else |
---|
206 | { |
---|
207 | dc.reattachItem(bas, false); |
---|
208 | message = "Derived bioassay updated"; |
---|
209 | } |
---|
210 | |
---|
211 | JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.item(itemType), bas); |
---|
212 | ExtensionsInvoker invoker = EditUtil.useOnSaveExtensions(jspContext); |
---|
213 | try |
---|
214 | { |
---|
215 | bas.setName(Values.getStringOrNull(request.getParameter("name"))); |
---|
216 | bas.setDescription(Values.getStringOrNull(request.getParameter("description"))); |
---|
217 | |
---|
218 | int subtypeId = Values.getInt(request.getParameter("subtype_id"), -1); |
---|
219 | ItemSubtype subtype = null; |
---|
220 | if (subtypeId >= 0) // < 0 = denied or unchanged |
---|
221 | { |
---|
222 | subtype = subtypeId == 0 ? null : ItemSubtype.getById(dc, subtypeId); |
---|
223 | bas.setItemSubtype(subtype); |
---|
224 | if (subtype != null) cc.setRecent(subtype, maxRecent); |
---|
225 | } |
---|
226 | |
---|
227 | int extractId = Values.getInt(request.getParameter("extract_id"), -1); |
---|
228 | if (extractId >= 0) // < 0 = denied or unchanged |
---|
229 | { |
---|
230 | Extract extract = extractId == 0 ? null : Extract.getById(dc, extractId); |
---|
231 | bas.setExtract(extract); |
---|
232 | } |
---|
233 | |
---|
234 | int protocolId = Values.getInt(request.getParameter("protocol_id"), -1); |
---|
235 | if (protocolId >= 0) // < 0 = denied or unchanged |
---|
236 | { |
---|
237 | Protocol pt = protocolId == 0 ? null : Protocol.getById(dc, protocolId); |
---|
238 | bas.setProtocol(pt); |
---|
239 | if (pt != null) cc.setRecent(pt, subtype, maxRecent); |
---|
240 | } |
---|
241 | |
---|
242 | int hardwareId = Values.getInt(request.getParameter("hardware_id"), -1); |
---|
243 | if (hardwareId >= 0) // < 0 denied or unchanged |
---|
244 | { |
---|
245 | Hardware hw = hardwareId == 0 ? null : Hardware.getById(dc, hardwareId); |
---|
246 | bas.setHardware(hw); |
---|
247 | if (hw != null) cc.setRecent(hw, subtype, maxRecent); |
---|
248 | } |
---|
249 | |
---|
250 | int softwareId = Values.getInt(request.getParameter("software_id"), -1); |
---|
251 | if (softwareId >= 0) // < 0 denied or unchanged |
---|
252 | { |
---|
253 | Software sw = softwareId == 0 ? null : Software.getById(dc, softwareId); |
---|
254 | bas.setSoftware(sw); |
---|
255 | if (sw != null) cc.setRecent(sw, subtype, maxRecent); |
---|
256 | } |
---|
257 | |
---|
258 | if (bas.isRoot()) |
---|
259 | { |
---|
260 | // A root derived bioassay set may have physical bioassays as parents |
---|
261 | String[] removePhysicalBioAssays = Values.getString(request.getParameter("-PHYSICALBIOASSAY")).split(","); |
---|
262 | for (int i = 0; i < removePhysicalBioAssays.length; ++i) |
---|
263 | { |
---|
264 | int pbaId = Values.getInt(removePhysicalBioAssays[i], -1); |
---|
265 | if (pbaId != -1) bas.removePhysicalBioAssay(PhysicalBioAssay.getById(dc, pbaId)); |
---|
266 | } |
---|
267 | |
---|
268 | String[] addPhysicalBioAssays = Values.getString(request.getParameter("+PHYSICALBIOASSAY")).split(","); |
---|
269 | for (int i = 0; i < addPhysicalBioAssays.length; ++i) |
---|
270 | { |
---|
271 | int pbaId = Values.getInt(addPhysicalBioAssays[i], -1); |
---|
272 | if (pbaId != -1) bas.addPhysicalBioAssay(PhysicalBioAssay.getById(dc, pbaId)); |
---|
273 | } |
---|
274 | } |
---|
275 | else |
---|
276 | { |
---|
277 | // A non-root derived bioassay set may have other derived bioassays as parents |
---|
278 | String[] removeParents = Values.getString(request.getParameter("-DERIVEDBIOASSAY")).split(","); |
---|
279 | for (int i = 0; i < removeParents.length; ++i) |
---|
280 | { |
---|
281 | int parentId = Values.getInt(removeParents[i], -1); |
---|
282 | if (parentId != -1) bas.removeParent(DerivedBioAssay.getById(dc, parentId)); |
---|
283 | } |
---|
284 | |
---|
285 | String[] addParents = Values.getString(request.getParameter("+DERIVEDBIOASSAY")).split(","); |
---|
286 | for (int i = 0; i < addParents.length; ++i) |
---|
287 | { |
---|
288 | int parentId = Values.getInt(addParents[i], -1); |
---|
289 | if (parentId != -1) bas.addParent(DerivedBioAssay.getById(dc, parentId)); |
---|
290 | } |
---|
291 | } |
---|
292 | |
---|
293 | // Data files tab |
---|
294 | boolean validate = Values.getBoolean(request.getParameter("datafiles.validate")); |
---|
295 | Base.updateFiles(dc, bas, request, validate, cc, maxRecent); |
---|
296 | |
---|
297 | // Annotations tab |
---|
298 | Base.updateAnnotations(dc, bas, bas, request); |
---|
299 | |
---|
300 | // OnSave extensions |
---|
301 | invoker.render(OnSaveRenderer.ON_SAVE); |
---|
302 | dc.commit(); |
---|
303 | invoker.render(OnSaveRenderer.ON_COMMIT); |
---|
304 | } |
---|
305 | catch (Exception ex) |
---|
306 | { |
---|
307 | invoker.render(OnSaveRenderer.onRollback(ex)); |
---|
308 | throw ex; |
---|
309 | } |
---|
310 | finally |
---|
311 | { |
---|
312 | cc.removeObject("item"); |
---|
313 | } |
---|
314 | } |
---|
315 | else if ("DeleteItem".equals(cmd)) |
---|
316 | { |
---|
317 | // Delete a single item and then return to the view page |
---|
318 | dc = sc.newDbControl(); |
---|
319 | ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
---|
320 | RemovableUtil.removeRecursively(dc, itemType, Collections.singleton(cc.getId()), true); |
---|
321 | dc.commit(); |
---|
322 | redirect = viewPage; |
---|
323 | } |
---|
324 | else if ("DeleteItems".equals(cmd)) |
---|
325 | { |
---|
326 | // Delete all selected items on the list page |
---|
327 | dc = sc.newDbControl(); |
---|
328 | ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
---|
329 | int numTotal = cc.getSelected().size(); |
---|
330 | int numRemoved = RemovableUtil.setRemoved(dc, itemType, cc.getSelected(), true); |
---|
331 | dc.commit(); |
---|
332 | if (numTotal != numRemoved) |
---|
333 | { |
---|
334 | message = (numRemoved == 0 ? "No" : "Only "+numRemoved+" of "+numTotal) + " items could be deleted, because you have no DELETE permission"; |
---|
335 | } |
---|
336 | redirect = listPage; |
---|
337 | } |
---|
338 | else if ("RestoreItem".equals(cmd)) |
---|
339 | { |
---|
340 | // Restore a single item and then return to the view page |
---|
341 | dc = sc.newDbControl(); |
---|
342 | ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
---|
343 | RemovableUtil.removeRecursively(dc, itemType, Collections.singleton(cc.getId()), false); |
---|
344 | dc.commit(); |
---|
345 | redirect = viewPage; |
---|
346 | } |
---|
347 | else if ("RestoreItems".equals(cmd)) |
---|
348 | { |
---|
349 | // Restore all selected items on the list page |
---|
350 | dc = sc.newDbControl(); |
---|
351 | ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
---|
352 | int numTotal = cc.getSelected().size(); |
---|
353 | int numRemoved = RemovableUtil.setRemoved(dc, itemType, cc.getSelected(), false); |
---|
354 | dc.commit(); |
---|
355 | if (numTotal != numRemoved) |
---|
356 | { |
---|
357 | message = (numRemoved == 0 ? "No" : "Only "+numRemoved+" of "+numTotal) + " items could be restored, because you have no WRITE permission"; |
---|
358 | } |
---|
359 | redirect = listPage; |
---|
360 | } |
---|
361 | else if ("ShareItem".equals(cmd)) |
---|
362 | { |
---|
363 | // Display a popup window for sharing a single item |
---|
364 | dc = sc.newDbControl(); |
---|
365 | ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
---|
366 | MultiPermissions permissions = ShareableUtil.getMultiPermissions(dc, itemType, Collections.singleton(cc.getId())); |
---|
367 | dc.close(); |
---|
368 | cc.setObject("MultiPermissions", permissions); |
---|
369 | redirect = "../../common/share/share.jsp?ID="+ID+"&item_type="+itemType.name(); |
---|
370 | } |
---|
371 | else if ("ShareItems".equals(cmd)) |
---|
372 | { |
---|
373 | // Display a popup window for sharing all selected items on the list page |
---|
374 | dc = sc.newDbControl(); |
---|
375 | ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
---|
376 | MultiPermissions permissions = ShareableUtil.getMultiPermissions(dc, itemType, cc.getSelected()); |
---|
377 | dc.close(); |
---|
378 | cc.setObject("MultiPermissions", permissions); |
---|
379 | redirect = "../../common/share/share.jsp?ID="+ID+"&item_type="+itemType.name(); |
---|
380 | } |
---|
381 | else if ("SetOwnerOfItem".equals(cmd)) |
---|
382 | { |
---|
383 | // Change owner of items selected on a list page |
---|
384 | dc = sc.newDbControl(); |
---|
385 | ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
---|
386 | OwnedItem item = (OwnedItem)itemType.getById(dc, cc.getId()); |
---|
387 | cc.setObject("OwnedItems", Collections.singleton(item)); |
---|
388 | redirect = "../../common/ownership/ownership.jsp?ID="+ID+"&item_type="+itemType.name(); |
---|
389 | } |
---|
390 | else if ("SetOwnerOfItems".equals(cmd)) |
---|
391 | { |
---|
392 | // Change owner of items selected on a list page |
---|
393 | dc = sc.newDbControl(); |
---|
394 | ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
---|
395 | Set<OwnedItem> items = new HashSet<OwnedItem>(); |
---|
396 | for (Integer id : cc.getSelected()) |
---|
397 | { |
---|
398 | if (id != null) items.add((OwnedItem)itemType.getById(dc, id)); |
---|
399 | } |
---|
400 | dc.close(); |
---|
401 | cc.setObject("OwnedItems", items); |
---|
402 | redirect = "../../common/ownership/ownership.jsp?ID="+ID+"&item_type="+itemType.name(); |
---|
403 | } |
---|
404 | else if ("InheritAnnotations".equals(cmd)) |
---|
405 | { |
---|
406 | // Change owner of items selected on a list page |
---|
407 | dc = sc.newDbControl(); |
---|
408 | ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
---|
409 | Set<AnnotatedItem> items = new HashSet<AnnotatedItem>(); |
---|
410 | for (Integer id : cc.getSelected()) |
---|
411 | { |
---|
412 | if (id != null) items.add((AnnotatedItem)itemType.getById(dc, id)); |
---|
413 | } |
---|
414 | dc.close(); |
---|
415 | cc.setObject("AnnotatedItems", items); |
---|
416 | redirect = "../../common/annotations/batch_inherit.jsp?ID="+ID+"&item_type="+itemType.name(); |
---|
417 | } |
---|
418 | else if ("ExportItems".equals(cmd)) |
---|
419 | { |
---|
420 | // Run an export plugin in a list context |
---|
421 | ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
---|
422 | final ItemQuery<DerivedBioAssay> query = DerivedBioAssay.getQuery(); |
---|
423 | dc = sc.newDbControl(); |
---|
424 | cc.configureQuery(dc, query, true); |
---|
425 | cc.setQuery(query); |
---|
426 | registerExportUtils(cc); |
---|
427 | JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.list(itemType), null); |
---|
428 | ExtensionsInvoker listInvoker = ListColumnUtil.useExtensions(jspContext); |
---|
429 | listInvoker.render(new ListColumnExportRenderer(cc)); |
---|
430 | dc.close(); |
---|
431 | redirect = "../../common/export/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=LIST&title=Export+bioassay+sets"; |
---|
432 | } |
---|
433 | else if ("ExportItem".equals(cmd)) |
---|
434 | { |
---|
435 | // Run an export plugin in single-item context |
---|
436 | ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
---|
437 | registerExportUtils(cc); |
---|
438 | redirect = "../../common/export/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=ITEM&title=Export+bioassay+set"; |
---|
439 | } |
---|
440 | else if ("ImportItems".equals(cmd)) |
---|
441 | { |
---|
442 | // Run an import plugin in a list context |
---|
443 | ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
---|
444 | final ItemQuery<DerivedBioAssay> query = DerivedBioAssay.getQuery(); |
---|
445 | dc = sc.newDbControl(); |
---|
446 | cc.configureQuery(dc, query, true); |
---|
447 | dc.close(); |
---|
448 | cc.setQuery(query); |
---|
449 | redirect = "../../common/import/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=LIST&title=Import+bioassay+sets"; |
---|
450 | } |
---|
451 | else if ("ImportItem".equals(cmd)) |
---|
452 | { |
---|
453 | // Run an import plugin in single-item context |
---|
454 | ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
---|
455 | redirect = "../../common/import/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=ITEM&title=Import+bioassay+set"; |
---|
456 | } |
---|
457 | else if ("RunListPlugin".equals(cmd)) |
---|
458 | { |
---|
459 | // Run another plugin in a list context |
---|
460 | ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
---|
461 | final ItemQuery<DerivedBioAssay> query = DerivedBioAssay.getQuery(); |
---|
462 | dc = sc.newDbControl(); |
---|
463 | cc.configureQuery(dc, query, true); |
---|
464 | dc.close(); |
---|
465 | cc.setQuery(query); |
---|
466 | redirect = "../../../common/plugin/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=LIST&main_type=OTHER&title=Run+plugin"; |
---|
467 | } |
---|
468 | else if ("RunPlugin".equals(cmd)) |
---|
469 | { |
---|
470 | // Run a plugin in single-item context |
---|
471 | ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
---|
472 | redirect = "../../../common/plugin/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=ITEM&main_type=OTHER&title=Run+plugin"; |
---|
473 | } |
---|
474 | else if ("RunAnalysisPlugin".equals(cmd)) |
---|
475 | { |
---|
476 | // Run an analysis plugin in single-item context |
---|
477 | ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
---|
478 | redirect = "../../common/plugin/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=ITEM&main_type=ANALYZE&title=Run+analysis+plugin"; |
---|
479 | } |
---|
480 | else if ("NewMergedDerivedBioAssay".equals(cmd)) |
---|
481 | { |
---|
482 | ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
---|
483 | cc.setId(0); |
---|
484 | forward = editPage + "&useParents=DERIVEDBIOASSAY"; |
---|
485 | } |
---|
486 | else |
---|
487 | { |
---|
488 | throw new WebException("popup", "Invalid command", "The command {1} is not recognised as a valid command.", cmd); |
---|
489 | } |
---|
490 | } |
---|
491 | finally |
---|
492 | { |
---|
493 | if (dc != null) dc.close(); |
---|
494 | } |
---|
495 | |
---|
496 | if (forward != null) |
---|
497 | { |
---|
498 | sc.setSessionSetting("alert-message", message); |
---|
499 | pageContext.forward(forward); |
---|
500 | } |
---|
501 | else if (redirect != null) |
---|
502 | { |
---|
503 | sc.setSessionSetting("alert-message", message); |
---|
504 | response.sendRedirect(redirect); |
---|
505 | } |
---|
506 | else if (message == null) |
---|
507 | { |
---|
508 | response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&wait=0"); |
---|
509 | } |
---|
510 | else |
---|
511 | { |
---|
512 | response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&message="+HTML.urlEncode(message)); |
---|
513 | } |
---|
514 | %> |
---|
515 | |
---|