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