source: trunk/www/views/rawbioassays/index.jsp @ 7635

Last change on this file since 7635 was 7635, checked in by Nicklas Nordborg, 3 years ago

References #2136: Remove support for spot images

Removed spot-image related functionality from the web client.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 22.2 KB
Line 
1<%-- $Id: index.jsp 7635 2019-03-11 10:01:10Z nicklas $
2  ------------------------------------------------------------------
3  Copyright (C) 2005 Nicklas Nordborg
4  Copyright (C) 2006 Jari Häkkinen, Nicklas Nordborg, Martin Svensson
5  Copyright (C) 2007 Nicklas Nordborg
6
7  This file is part of BASE - BioArray Software Environment.
8  Available at http://base.thep.lu.se/
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  @author Nicklas
25  @version 2.0
26--%>
27<%@ page pageEncoding="UTF-8" session="false"
28  import="net.sf.basedb.core.Application"
29  import="net.sf.basedb.core.SessionControl"
30  import="net.sf.basedb.core.DbControl"
31  import="net.sf.basedb.core.Item"
32  import="net.sf.basedb.core.Include"
33  import="net.sf.basedb.core.RawBioAssay"
34  import="net.sf.basedb.core.FeatureIdentificationMethod"
35  import="net.sf.basedb.core.Protocol"
36  import="net.sf.basedb.core.Software"
37  import="net.sf.basedb.core.ArrayDesign"
38  import="net.sf.basedb.core.Extract"
39  import="net.sf.basedb.core.DerivedBioAssay"
40  import="net.sf.basedb.core.Experiment"
41  import="net.sf.basedb.core.File"
42  import="net.sf.basedb.core.RawDataType"
43  import="net.sf.basedb.core.RawDataTypes"
44  import="net.sf.basedb.core.Platform"
45  import="net.sf.basedb.core.PlatformVariant"
46  import="net.sf.basedb.core.User"
47  import="net.sf.basedb.core.Path"
48  import="net.sf.basedb.core.ItemQuery"
49  import="net.sf.basedb.core.ItemResultIterator"
50  import="net.sf.basedb.core.OwnedItem"
51  import="net.sf.basedb.core.AnnotatedItem"
52  import="net.sf.basedb.core.Permission"
53  import="net.sf.basedb.core.ItemContext"
54  import="net.sf.basedb.core.MultiPermissions"
55  import="net.sf.basedb.core.PermissionDeniedException"
56  import="net.sf.basedb.core.ItemAlreadyExistsException"
57  import="net.sf.basedb.core.PluginDefinition"
58  import="net.sf.basedb.core.Job"
59  import="net.sf.basedb.core.ProgressReporter"
60  import="net.sf.basedb.core.IntegerParameterType"
61  import="net.sf.basedb.core.FloatParameterType"
62  import="net.sf.basedb.core.StringParameterType"
63  import="net.sf.basedb.core.FileParameterType"
64  import="net.sf.basedb.core.ItemParameterType"
65  import="net.sf.basedb.core.BooleanParameterType"
66  import="net.sf.basedb.core.query.Hql"
67  import="net.sf.basedb.core.query.Orders"
68  import="net.sf.basedb.core.query.Restrictions"
69  import="net.sf.basedb.core.query.Expressions"
70  import="net.sf.basedb.util.RemovableUtil"
71  import="net.sf.basedb.util.ShareableUtil"
72  import="net.sf.basedb.util.OwnableUtil"
73  import="net.sf.basedb.clients.web.Base"
74  import="net.sf.basedb.clients.web.WebException"
75  import="net.sf.basedb.util.Values"
76  import="net.sf.basedb.util.formatter.NameableFormatter"
77  import="net.sf.basedb.util.formatter.FilePathFormatter"
78  import="net.sf.basedb.clients.web.plugins.ItemQueryLoader"
79  import="net.sf.basedb.clients.web.plugins.FileSetMemberLoader"
80  import="net.sf.basedb.clients.web.util.HTML" 
81  import="net.sf.basedb.core.plugin.GuiContext"
82  import="net.sf.basedb.util.extensions.ExtensionsInvoker"
83  import="net.sf.basedb.clients.web.extensions.ExtensionsControl"
84  import="net.sf.basedb.clients.web.extensions.JspContext"
85  import="net.sf.basedb.clients.web.extensions.edit.EditUtil"
86  import="net.sf.basedb.clients.web.extensions.edit.OnSaveAction"
87  import="net.sf.basedb.clients.web.extensions.edit.OnSaveRenderer"
88  import="net.sf.basedb.clients.web.extensions.list.ListColumnExportRenderer"
89  import="net.sf.basedb.clients.web.extensions.list.ListColumnAction"
90  import="net.sf.basedb.clients.web.extensions.list.ListColumnUtil"
91  import="java.util.Enumeration"
92  import="java.util.Set"
93  import="java.util.HashSet"
94  import="java.util.List"
95  import="java.util.ArrayList"
96  import="java.util.Arrays"
97  import="java.util.Collections"
98%>
99<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
100<%!
101  private static final ItemContext defaultContext = Base.createDefaultContext("name", "name,platform,variant,hasData,description");
102  private static final Item itemType = Item.RAWBIOASSAY;
103 
104  private static void registerExportUtils(ItemContext cc)
105  {
106    // Register formatters
107    cc.setObject("export.formatter.&experiments(name)", new NameableFormatter());
108    cc.setObject("export.formatter.&fileSet.members(file.name)", new FilePathFormatter());
109   
110    // Register dataloaders
111    String rawParameter = "rawBioAssay";
112    final ItemQuery<Experiment> experimentQuery = Experiment.getQuery();
113    experimentQuery.include(cc.getInclude());
114    experimentQuery.join(Hql.innerJoin("rawBioAssays", "rba"));
115    experimentQuery.restrict(Restrictions.eq(Hql.alias("rba"), Expressions.parameter(rawParameter)));
116    experimentQuery.order(Orders.asc(Hql.property("name"))); 
117    cc.setObject("export.dataloader.&experiments(name)", new ItemQueryLoader<RawBioAssay>(experimentQuery, rawParameter));
118    cc.setObject("export.dataloader.&fileSet.members(file.name)", new FileSetMemberLoader());
119  }
120 
121  private static class UpdateArrayDesign
122    implements Runnable
123  {
124    private final int jobId;
125    private final int rawBioAssayId;
126    private final int arrayDesignId;
127    private final SessionControl sc;
128    private final FeatureIdentificationMethod fiMethod;
129   
130    private UpdateArrayDesign(Job job, RawBioAssay rba, ArrayDesign design, FeatureIdentificationMethod fiMethod)
131    {
132      this.jobId = job.getId();
133      this.rawBioAssayId = rba.getId();
134      this.arrayDesignId = design.getId();
135      this.sc = job.getSessionControl();
136      this.fiMethod = fiMethod;
137    }
138   
139    public void run()
140    {
141      DbControl dc = sc.newDbControl();
142      try
143      {
144        Job j = Job.getById(dc, jobId);
145        j.start("Initialising...", Application.getHostName(), null);
146        ProgressReporter progress = j.getProgressReporter(null);
147        dc.commit();
148        dc = sc.newDbControl();
149        RawBioAssay rba = RawBioAssay.getById(dc, rawBioAssayId);
150        ArrayDesign design = ArrayDesign.getById(dc, arrayDesignId);
151        try
152        {
153          rba.updateArrayDesign(design, fiMethod, progress);
154          progress.display(99, "Committing changes to database...");
155          dc.commit();
156          dc = sc.newDbControl();
157          j = Job.getById(dc, jobId);
158          j.doneOk("Array design updated successfully");
159          j.setRemoved(true);
160          dc.commit();
161        }
162        catch (Throwable t)
163        {
164          if (dc != null) dc.close();
165          dc = sc.newDbControl();
166          j = Job.getById(dc, jobId);
167          j.doneError(t.getMessage(), Arrays.asList(t));
168          j.setRemoved(true);
169          dc.commit();
170        }
171      }
172      finally
173      {
174        if (dc != null) dc.close();
175      }
176    }
177  }
178%>
179<%
180final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
181final String ID = sc.getId();
182final String cmd = request.getParameter("cmd");
183final String root = request.getContextPath()+"/";
184final String mode = request.getParameter("mode");
185final String callback = request.getParameter("callback");
186final String itemId = request.getParameter("item_id");
187final String listPage = "list_rawbioassays.jsp?ID="+ID
188  +(mode == null ? "" : "&mode="+mode)
189  +(callback == null ? "" : "&callback="+callback)
190  +(itemId == null ? "" : "&item_id="+itemId);
191final String viewPage = "view_rawbioassay.jsp?ID="+ID;
192final String editPage = "edit_rawbioassay.jsp?ID="+ID;
193
194String forward = null;
195String redirect = null;
196String message = null;
197DbControl dc = null;
198
199try
200{
201  if (cmd == null || "List".equals(cmd))
202  {
203    // Display the list page without updatinging the current context
204    Base.getAndSetCurrentContext(sc, itemType, null, defaultContext, true);
205    redirect = listPage;
206  }
207  else if ("UpdateContext".equals(cmd))
208  {
209    // Display the list page after updating the current context from the request parameters
210    Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
211    redirect = listPage;
212  }
213  else if ("LoadContext".equals(cmd))
214  {
215    // Display the list page after loading a saved context
216    int contextId = Values.getInt(request.getParameter("context"));
217    Base.loadContext(sc, contextId, defaultContext);
218    redirect = listPage;
219  }
220
221  else if ("ViewItem".equals(cmd))
222  {
223    // Display the view page for a single item
224    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
225    forward = viewPage;
226  }
227  else if ("EditItem".equals(cmd))
228  {
229    // Display the edit page for a single item (should be opened in a popup)
230    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
231    forward = editPage;
232  }
233  else if ("NewItem".equals(cmd))
234  {
235    // Display the edit page for a new item (should be opened in a popup)
236    if (!sc.hasPermission(Permission.CREATE, itemType))
237    {
238      throw new PermissionDeniedException(Permission.CREATE, itemType.toString());
239    }
240    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
241    cc.setId(0);
242    forward = editPage;
243  }
244  else if ("UpdateItem".equals(cmd))
245  {
246    // Update the properties on an item (will close the popup)
247    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, defaultContext);
248    final int maxRecent = Base.getMaxRecent(sc);
249    dc = sc.newDbControl();
250    RawBioAssay rba = cc.getObject("item");
251   
252    Platform platform = null;
253    PlatformVariant variant = null;
254    String pf = request.getParameter("platform");
255
256    if (pf != null)
257    {
258      if (pf.startsWith("PLATFORM:"))
259      {
260        int platformId = Values.getInt(pf.substring(9), -1);
261        if (platformId > 0) platform =  Platform.getById(dc, platformId);
262      }
263      else if (pf.startsWith("VARIANT:"))
264      {
265        int variantId = Values.getInt(pf.substring(8), -1);
266        if (variantId > 0) 
267        {
268          variant = PlatformVariant.getById(dc, variantId);
269          platform = variant.getPlatform();
270        }
271      }
272    }
273    RawDataType rdt = RawDataTypes.getRawDataType(Values.getStringOrNull(request.getParameter("rawdatatype")));
274    if (platform != null) cc.setRecent(platform, maxRecent);
275    if (variant != null) cc.setRecent(variant, maxRecent);
276    if (rdt != null) cc.setRecent("RawDataType", rdt.getId(), maxRecent);
277
278    if (rba == null)
279    {
280      if (variant != null)
281      {
282        rba = RawBioAssay.getNew(dc, variant, rdt);
283      }
284      else
285      {
286        rba = RawBioAssay.getNew(dc, platform, rdt);
287      }
288      message = "Raw bioassay created";
289      dc.saveItem(rba);
290    }
291    else
292    {
293      dc.reattachItem(rba, false);
294      if (variant != null)
295      {
296        rba.setVariant(variant, rdt);
297      }
298      else if (platform != null)
299      {
300        rba.setPlatform(platform, rdt);
301      }
302      message = "Raw bioassay updated";
303    }
304    JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.item(Item.RAWBIOASSAY), rba);
305    ExtensionsInvoker<OnSaveAction> invoker = EditUtil.useOnSaveExtensions(jspContext);
306    try
307    {
308      rba.setName(Values.getStringOrNull(request.getParameter("name")));
309      rba.setDescription(Values.getStringOrNull(request.getParameter("description")));
310      int protocolId = Values.getInt(request.getParameter("protocol_id"), -1);
311      if (protocolId >= 0)  // < 0 = denied or unchanged
312      {
313        Protocol pt = protocolId == 0 ? null : Protocol.getById(dc, protocolId);
314        rba.setProtocol(pt);
315        if (pt != null) cc.setRecent(pt, maxRecent);
316      }
317      int softwareId = Values.getInt(request.getParameter("software_id"), -1);
318      if (softwareId >= 0) // < 0 = denied or unchanged
319      {
320        Software sw = softwareId == 0 ? null : Software.getById(dc, softwareId);
321        rba.setSoftware(sw);
322        if (sw != null) cc.setRecent(sw, maxRecent);
323      }
324      int bioAssayId = Values.getInt(request.getParameter("bioassay_id"), -1);
325      if (bioAssayId >= 0) // < 0 = denied or unchanged
326      {
327        DerivedBioAssay bioAssay = bioAssayId == 0 ? null : DerivedBioAssay.getById(dc, bioAssayId);
328        rba.setParentBioAssay(bioAssay);
329        if (bioAssay != null) cc.setRecent(bioAssay, maxRecent);
330      }
331      int extractId = Values.getInt(request.getParameter("extract_id"), -1);
332      if (extractId >= 0) // < 0 = denied or unchanged
333      {
334        Extract extract = extractId == 0 ? null : Extract.getById(dc, extractId);
335        rba.setParentExtract(extract);
336        if (extract != null) cc.setRecent(extract, maxRecent);
337      }
338
339      Job job = null;
340      ArrayDesign ad = null;
341      FeatureIdentificationMethod fiMethod = null;
342      int arrayDesignId = Values.getInt(request.getParameter("arraydesign_id"), -1);
343      if (arrayDesignId >= 0) // < 0 = denied or unchanged
344      {
345        ad = arrayDesignId == 0 ? null : ArrayDesign.getById(dc, arrayDesignId);
346        if (!rba.isSameArrayDesign(ad) || !rba.isInDatabase())
347        {
348          if (rba.hasData())
349          {
350            try
351            {
352              fiMethod = FeatureIdentificationMethod.valueOf(request.getParameter("fiMethod"));
353            }
354            catch (Exception ex)
355            {}
356            if (rba.getRawDataType().isStoredInDb() && ad != null && ad.hasFeatures())
357            {
358              // Create job and assign it to another thread
359              job = Job.getNew(dc, null, null, null);
360              job.setName("Validating array design on " + rba.getName());
361              job.setPrepared(Application.getHostName(), null);
362              job.setSendMessage(Values.getBoolean(sc.getUserClientSetting("plugins.sendmessage"), false));
363              dc.saveItem(job);
364            }
365            else
366            {
367              rba.updateArrayDesign(ad, fiMethod, null);
368            }
369          }
370          else
371          {
372            rba.setArrayDesign(ad);
373          }
374        }
375        if (ad != null) cc.setRecent(ad, maxRecent);
376      }
377 
378      // Data files tab
379      boolean validate = Values.getBoolean(request.getParameter("datafiles.validate"));
380      Base.updateFiles(dc, rba, request, validate, cc, maxRecent);
381     
382      // Annotations tab
383      Base.updateAnnotations(dc, rba, rba, request);
384     
385      // OnSave extensions
386      invoker.render(OnSaveRenderer.ON_SAVE);
387      dc.commit();
388      invoker.render(OnSaveRenderer.ON_COMMIT);
389      if (job != null) 
390      {
391        redirect = "../jobs/index.jsp?ID="+ID+"&cmd=ViewItem&item_id="+job.getId();
392        Thread updateThread = new Thread(new UpdateArrayDesign(job, rba, ad, fiMethod));
393        updateThread.setPriority(Thread.currentThread().getPriority() - 1);
394        updateThread.start();
395      }
396    }
397    catch (Exception ex)
398    {
399      invoker.render(OnSaveRenderer.onRollback(ex));
400      throw ex;
401    }
402    finally
403    {
404      cc.removeObject("item");
405    }
406  }
407  else if ("DeleteItem".equals(cmd))
408  {
409    // Delete a single item and then return to the view page
410    dc = sc.newDbControl();
411    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
412    RemovableUtil.setRemoved(dc, itemType, Collections.singleton(cc.getId()), true);
413    dc.commit();
414    redirect = viewPage;
415  }
416  else if ("DeleteItems".equals(cmd))
417  {
418    // Delete all selected items on the list page
419    dc = sc.newDbControl();
420    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
421    int numTotal = cc.getSelected().size();
422    int numRemoved = RemovableUtil.setRemoved(dc, itemType, cc.getSelected(), true);
423    dc.commit();
424    if (numTotal != numRemoved)
425    {
426      message = (numRemoved == 0 ? "No" : "Only "+numRemoved+" of "+numTotal) + " items could be deleted, because you have no DELETE permission";
427    }
428    redirect = listPage;
429  }
430  else if ("RestoreItem".equals(cmd))
431  {
432    // Restore a single item and then return to the view page
433    dc = sc.newDbControl();
434    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
435    RemovableUtil.setRemoved(dc, itemType, Collections.singleton(cc.getId()), false);
436    dc.commit();
437    redirect = viewPage;
438  }
439  else if ("RestoreItems".equals(cmd))
440  {
441    // Restore all selected items on the list page
442    dc = sc.newDbControl();
443    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
444    int numTotal = cc.getSelected().size();
445    int numRemoved = RemovableUtil.setRemoved(dc, itemType, cc.getSelected(), false);
446    dc.commit();
447    if (numTotal != numRemoved)
448    {
449      message = (numRemoved == 0 ? "No" : "Only "+numRemoved+" of "+numTotal) + " items could be restored, because you have no WRITE permission";
450    }
451    redirect = listPage;
452  }
453  else if ("ShareItem".equals(cmd))
454  {
455    // Display a popup window for sharing a single item
456    dc = sc.newDbControl();
457    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
458    MultiPermissions permissions = ShareableUtil.getMultiPermissions(dc, itemType, Collections.singleton(cc.getId()));
459    dc.close();
460    cc.setObject("MultiPermissions", permissions);
461    redirect = "../../common/share/share.jsp?ID="+ID+"&item_type="+itemType.name();
462  }
463  else if ("ShareItems".equals(cmd))
464  {
465    // Display a popup window for sharing all selected items on the list page
466    dc = sc.newDbControl();
467    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
468    MultiPermissions permissions = ShareableUtil.getMultiPermissions(dc, itemType, cc.getSelected());
469    dc.close();
470    cc.setObject("MultiPermissions", permissions);
471    redirect = "../../common/share/share.jsp?ID="+ID+"&item_type="+itemType.name();
472  }
473  else if ("SetOwnerOfItem".equals(cmd))
474  {
475    // Change owner of items selected on a list page
476    dc = sc.newDbControl();
477    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
478    OwnedItem item = (OwnedItem)itemType.getById(dc, cc.getId());
479    cc.setObject("OwnedItems", Collections.singleton(item));
480    redirect = "../../common/ownership/ownership.jsp?ID="+ID+"&item_type="+itemType.name();
481  }
482  else if ("SetOwnerOfItems".equals(cmd))
483  {
484    // Change owner of items selected on a list page
485    dc = sc.newDbControl();
486    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
487    Set<OwnedItem> items = new HashSet<OwnedItem>();
488    for (Integer id : cc.getSelected())
489    {
490      if (id != null) items.add((OwnedItem)itemType.getById(dc, id));
491    }
492    dc.close();
493    cc.setObject("OwnedItems", items);
494    redirect = "../../common/ownership/ownership.jsp?ID="+ID+"&item_type="+itemType.name();
495  }
496  else if ("InheritAnnotations".equals(cmd))
497  {
498    // Change owner of items selected on a list page
499    dc = sc.newDbControl();
500    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
501    Set<AnnotatedItem> items = new HashSet<AnnotatedItem>();
502    for (Integer id : cc.getSelected())
503    {
504      if (id != null) items.add((AnnotatedItem)itemType.getById(dc, id));
505    }
506    dc.close();
507    cc.setObject("AnnotatedItems", items);
508    redirect = "../../common/annotations/batch_inherit.jsp?ID="+ID+"&item_type="+itemType.name();
509  }
510  else if ("ExportItems".equals(cmd))
511  {
512    // Run an export plugin in a list context
513    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
514    final ItemQuery<RawBioAssay> query = RawBioAssay.getQuery();
515    dc = sc.newDbControl();
516    cc.setQuery(query);
517    cc.configureQuery(dc, query, true);
518    registerExportUtils(cc);
519    JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.list(itemType), null);
520    ExtensionsInvoker<ListColumnAction<RawBioAssay,?>> listInvoker = ListColumnUtil.useExtensions(jspContext);
521    listInvoker.render(new ListColumnExportRenderer<RawBioAssay>(cc));
522    dc.close();
523    redirect = "../../common/export/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=LIST&title=Export+raw+bioassays";
524  }
525  else if ("ExportItem".equals(cmd))
526  {
527    // Run an export plugin in single-item context
528    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
529    registerExportUtils(cc);
530    redirect = "../../common/export/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=ITEM&title=Export+raw+bioassay";
531  }
532  else if ("ImportItems".equals(cmd))
533  {
534    // Run an import plugin in a list context
535    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
536    final ItemQuery<RawBioAssay> query = RawBioAssay.getQuery();
537    dc = sc.newDbControl();
538    cc.configureQuery(dc, query, true);
539    dc.close();
540    cc.setQuery(query);
541    redirect = "../../common/import/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=LIST&title=Import+raw+bioassays";
542  }
543  else if ("ImportItem".equals(cmd))
544  {
545    // Run an import plugin in single-item context
546    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
547    redirect = "../../common/import/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=ITEM&title=Import+raw+bioassay";
548  }
549  else if ("RunListPlugin".equals(cmd))
550  {
551    // Run another plugin in a list context
552    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
553    final ItemQuery<RawBioAssay> query = RawBioAssay.getQuery();
554    dc = sc.newDbControl();
555    cc.configureQuery(dc, query, true);
556    dc.close();
557    cc.setQuery(query);
558    redirect = "../../common/plugin/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=LIST&main_type=OTHER&title=Run+plugin";
559  }
560  else if ("RunPlugin".equals(cmd))
561  {
562    // Run another plugin in single-item context
563    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
564    redirect = "../../common/plugin/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=ITEM&main_type=OTHER&title=Run+plugin";
565  }
566  else if ("NewExperiment".equals(cmd))
567  {
568    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
569    redirect = "../experiments/index.jsp?ID="+ID+"&cmd=NewItem&rawbioassays=1";
570  }
571  else if ("CreateItemList".equals(cmd))
572  {
573    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
574    final ItemQuery<RawBioAssay> query = RawBioAssay.getQuery();
575    dc = sc.newDbControl();
576    cc.configureQuery(dc, query, true);
577    dc.close();
578    cc.setQuery(query);
579    redirect = "../../views/itemlists/index.jsp?ID="+ID+"&cmd=NewItem&addItems=1&memberType=RAWBIOASSAY&formId=rawbioassays";
580  }
581  else
582  {
583    throw new WebException("popup", "Invalid command", "The command {1} is not recognised as a valid command.", cmd);
584  }
585
586}
587finally
588{
589  if (dc != null) dc.close();
590}
591
592if (forward != null)
593{
594  sc.setSessionSetting("alert-message", message);
595  pageContext.forward(forward);
596}
597else if (redirect != null)
598{
599  sc.setSessionSetting("alert-message", message);
600  response.sendRedirect(redirect);
601}
602else if (message == null)
603{
604  response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&wait=0");
605}
606else
607{
608  response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&message="+HTML.urlEncode(message));
609}
610%>
611
Note: See TracBrowser for help on using the repository browser.