source: branches/3.16-stable/www/views/derivedbioassays/index.jsp @ 7804

Last change on this file since 7804 was 7804, checked in by Nicklas Nordborg, 2 years ago

References #2209: Add items to existing item list from list page

Fixed on the list pages for extracts, physical, derived and raw bioassays.

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