source: trunk/www/biomaterials/samples/index.jsp @ 7703

Last change on this file since 7703 was 7703, checked in by Nicklas Nordborg, 4 years ago

Merged pre-3.15 changes to the trunk.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 21.2 KB
Line 
1<%-- $Id: index.jsp 7703 2019-04-11 07:31:26Z nicklas $
2  ------------------------------------------------------------------
3  Copyright (C) 2005 Nicklas Nordborg
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.Sample"
32  import="net.sf.basedb.core.BioSource"
33  import="net.sf.basedb.core.BioMaterialEvent"
34  import="net.sf.basedb.core.BioPlateEventType"
35  import="net.sf.basedb.core.BioWell"
36  import="net.sf.basedb.core.ItemSubtype"
37  import="net.sf.basedb.core.Extract"
38  import="net.sf.basedb.core.Kit"
39  import="net.sf.basedb.core.Protocol"
40  import="net.sf.basedb.core.ItemQuery"
41  import="net.sf.basedb.core.ItemResultIterator"
42  import="net.sf.basedb.core.Permission"
43  import="net.sf.basedb.core.ItemContext"
44  import="net.sf.basedb.core.MultiPermissions"
45  import="net.sf.basedb.core.OwnedItem"
46  import="net.sf.basedb.core.AnnotatedItem"
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.OwnableUtil"
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.plugins.ParentBioMaterialLoader"
60  import="net.sf.basedb.clients.web.plugins.BioMaterialEventSourceFormatter"
61  import="net.sf.basedb.clients.web.plugins.ParentBioMaterialEventSourceLoader"
62  import="net.sf.basedb.clients.web.plugins.ItemQueryLoader"
63  import="net.sf.basedb.clients.web.util.HTML"
64  import="net.sf.basedb.util.formatter.Formatter"
65  import="net.sf.basedb.util.formatter.WellCoordinateFormatter"
66  import="net.sf.basedb.util.formatter.NameableFormatter"
67  import="net.sf.basedb.util.formatter.ItemTypeFormatter"
68  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
69
70  import="net.sf.basedb.core.plugin.GuiContext"
71  import="net.sf.basedb.util.extensions.ExtensionsInvoker"
72  import="net.sf.basedb.clients.web.extensions.ExtensionsControl"
73  import="net.sf.basedb.clients.web.extensions.JspContext"
74  import="net.sf.basedb.clients.web.extensions.edit.EditUtil"
75  import="net.sf.basedb.clients.web.extensions.edit.OnSaveAction"
76  import="net.sf.basedb.clients.web.extensions.edit.OnSaveRenderer"
77  import="net.sf.basedb.clients.web.extensions.list.ListColumnExportRenderer"
78  import="net.sf.basedb.clients.web.extensions.list.ListColumnAction"
79  import="net.sf.basedb.clients.web.extensions.list.ListColumnUtil"
80  import="java.util.Enumeration"
81  import="java.util.Set"
82  import="java.util.HashSet"
83  import="java.util.List"
84  import="java.util.ArrayList"
85  import="java.util.Collections"
86  import="java.util.Date"
87%>
88<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
89<%!
90  private static final ItemContext defaultContext = Base.createDefaultContext("name", "name,itemSubtype,originalQuantity,remainingQuantity,extracts,description");
91  private static final Item itemType = Item.SAMPLE;
92 
93  private static void registerExportUtils(ItemContext cc)
94  {
95    // Register formatters
96    cc.setObject("export.formatter.bioWell.row", new WellCoordinateFormatter(true));
97    cc.setObject("export.formatter.bioWell.column", new WellCoordinateFormatter(false));
98    cc.setObject("export.formatter.&creationEvent.sources(bioMaterial.name)", new BioMaterialEventSourceFormatter());
99    cc.setObject("export.formatter.&childCreationEvents(event.bioMaterial.name)", new NameableFormatter());
100    cc.setObject("export.formatter.&children(name)", new NameableFormatter());
101    cc.setObject("export.formatter.parentType", new ItemTypeFormatter());
102   
103    // Register dataloaders
104    String sampleParameter = "sample";
105
106    // Child extracts
107    ItemQuery<Extract> extractQuery = Extract.getQuery();
108    extractQuery.include(cc.getInclude());
109    extractQuery.restrict(Restrictions.eq(Hql.property("parent"), Expressions.parameter(sampleParameter)));
110    extractQuery.order(Orders.asc(Hql.property("name")));
111    cc.setObject("export.dataloader.&children(name)", new ItemQueryLoader<Sample>(extractQuery, sampleParameter));
112
113    // Child samples
114    ItemQuery<Sample> childSamplesQuery = Sample.getQuery();
115    childSamplesQuery.join(Hql.innerJoin("creationEvent", "ce"));
116    childSamplesQuery.join(Hql.innerJoin("ce", "sources", "src"));
117    childSamplesQuery.restrict(Restrictions.eq(Hql.property("src", "bioMaterial"), Expressions.parameter(sampleParameter)));
118    childSamplesQuery.order(Orders.asc(Hql.property("name")));
119    childSamplesQuery.include(cc.getInclude());
120    cc.setObject("export.dataloader.&childCreationEvents(event.bioMaterial.name)", new ItemQueryLoader<Sample>(childSamplesQuery, sampleParameter));
121   
122    // Parent samples
123    cc.setObject("export.dataloader.&creationEvent.sources(bioMaterial.name)", new ParentBioMaterialEventSourceLoader());
124  } 
125%>
126<%
127final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
128final String ID = sc.getId();
129final String cmd = request.getParameter("cmd");
130final String root = request.getContextPath()+"/";
131final String mode = request.getParameter("mode");
132final String callback = request.getParameter("callback");
133final String itemId = request.getParameter("item_id");
134final String listPage = "list_samples.jsp?ID="+ID
135  +(mode == null ? "" : "&mode="+mode)
136  +(callback == null ? "" : "&callback="+callback)
137  +(itemId == null ? "" : "&item_id="+itemId);
138final String viewPage = "view_sample.jsp?ID="+ID;
139final String editPage = "edit_sample.jsp?ID="+ID;
140
141String forward = null;
142String redirect = null;
143String message = null;
144DbControl dc = null;
145
146try
147{
148  if (cmd == null || "List".equals(cmd))
149  {
150    // Display the list page without updatinging the current context
151    Base.getAndSetCurrentContext(sc, itemType, null, defaultContext, true);
152    redirect = listPage;
153  }
154  else if ("UpdateContext".equals(cmd))
155  {
156    // Display the list page after updating the current context from the request parameters
157    Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
158    redirect = listPage;
159  }
160  else if ("LoadContext".equals(cmd))
161  {
162    // Display the list page after loading a saved context
163    int contextId = Values.getInt(request.getParameter("context"));
164    Base.loadContext(sc, contextId, defaultContext);
165    redirect = listPage;
166  }
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    redirect = 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 ("NewPooledItem".equals(cmd))
192  {
193    // Display the edit page for a new pooled item (should be opened in a popup)
194    if (!sc.hasPermission(Permission.CREATE, itemType))
195    {
196      throw new PermissionDeniedException(Permission.CREATE, itemType.toString());
197    }
198    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
199    cc.setId(0);
200    forward = editPage+"&pooled="+true;
201  }
202  else if ("UpdateItem".equals(cmd))
203  {
204    // Update the properties on an item (will close the popup)
205    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, defaultContext);
206    final int maxRecent = Base.getMaxRecent(sc);
207    dc = sc.newDbControl();
208    Sample sample = cc.getObject("item");
209    if (sample == null)
210    {
211      sample = Sample.getNew(dc);
212      message = "Sample created";
213      dc.saveItem(sample);
214    }
215    else
216    {
217      dc.reattachItem(sample, false);
218      dc.reattachItem(sample.getCreationEvent(), false);
219      message = "Sample updated";
220    }
221
222    // Create extension context
223    JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.item(Item.SAMPLE), sample);
224    ExtensionsInvoker<OnSaveAction> invoker = EditUtil.useOnSaveExtensions(jspContext);
225    try
226    {
227      sample.setName(Values.getStringOrNull(request.getParameter("name")));
228      sample.setDescription(Values.getStringOrNull(request.getParameter("description")));
229      sample.setExternalId(Values.getStringOrNull(request.getParameter("external_id")));
230      sample.setOriginalQuantity(Values.getFloat(request.getParameter("original_quantity"), null));
231
232      int subtypeId = Values.getInt(request.getParameter("subtype_id"), -1);
233      ItemSubtype subtype = null;
234      if (subtypeId >= 0) // < 0 = denied or unchanged
235      {
236        if (subtypeId > 0) subtype = ItemSubtype.getById(dc, subtypeId);
237        sample.setItemSubtype(subtype);
238        cc.setRecent(Item.ITEMSUBTYPE, subtype, maxRecent);
239      }
240     
241      BioMaterialEvent creationEvent = sample.getCreationEvent();
242      if (creationEvent.hasPermission(Permission.WRITE))
243      {
244        Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc);
245        creationEvent.setEventDate(dateFormatter.parseString(Values.getStringOrNull(request.getParameter("event_date"))));
246        int protocolId = Values.getInt(request.getParameter("protocol_id"), -1);
247        if (protocolId >= 0) // < 0 = denied or unchanged
248        {
249          Protocol pt = protocolId == 0 ? null : Protocol.getById(dc, protocolId);
250          creationEvent.setProtocol(pt);
251          cc.setRecent(Item.PROTOCOL, pt, subtype, maxRecent);
252        }
253        int kitId = Values.getInt(request.getParameter("kit_id"), -1);
254        if (kitId >= 0) // < 0 = denied or unchanged
255        {
256          Kit kit = kitId == 0 ? null : Kit.getById(dc, kitId);
257          creationEvent.setKit(kit);
258          cc.setRecent(Item.KIT, kit, subtype, maxRecent);
259        }
260      }
261 
262      int biowellId = Values.getInt(request.getParameter("biowell_id"), -1);
263      if (biowellId >= 0) // < 0 = denied or unchanged
264      {
265        BioWell bw = biowellId == 0 ? null : BioWell.getById(dc, biowellId);
266        if (bw != null && bw.getBioMaterial() != null)
267        {
268          throw new WebException("popup", "Biowell can not be used",
269              "The biowell [{1}] on bioplate {2} is already connected to another biomaterial", 
270              HTML.encodeTags(bw.getRow()+"," + bw.getColumn()), HTML.encodeTags(bw.getPlate().getName()));
271        }
272        sample.setBioWell(bw);
273        cc.setRecent(Item.BIOPLATE, bw == null ? null : bw.getPlate(), subtype, maxRecent);
274      }
275 
276      // Parents tab
277      Item parentType = Item.valueOf(request.getParameter("parentType"));
278      if (parentType == Item.BIOSOURCE)
279      {
280        int bioSourceId = Values.getInt(request.getParameter("biosource_id"), -1);
281        if (bioSourceId >= 0) // < 0 = denied or unchanged
282        {
283          BioSource bs = bioSourceId == 0 ? null : BioSource.getById(dc, bioSourceId);
284          creationEvent.setSource(bs);
285          cc.setRecent(Item.BIOSOURCE, bs, maxRecent);
286        }
287      }
288      else
289      {
290        if (sample.getParentType() != Item.SAMPLE)
291        {
292          creationEvent.clearSources();
293        }
294        String[] modifiedSamples = Values.getString(request.getParameter("+SAMPLE")).split(",");
295        for (int i = 0; i < modifiedSamples.length; ++i)
296        {
297          int sId = Values.getInt(modifiedSamples[i], -1);
298          if (sId != -1) 
299          {
300            Sample s = Sample.getById(dc, sId);
301            creationEvent.addSource(s).setUsedQuantity(Values.getFloat(request.getParameter("SAMPLE."+sId), null));
302          }
303        }
304        String[] removedSamples = Values.getString(request.getParameter("-SAMPLE")).split(",");
305        for (int i = 0; i < removedSamples.length; ++i)
306        {
307          int sId = Values.getInt(removedSamples[i], -1);
308          if (sId != -1) creationEvent.removeSource(Sample.getById(dc, sId));
309        }
310      }
311 
312      // Annotations tab
313      Base.updateAnnotations(dc, sample, sample, request);
314     
315      // OnSave extensions
316      invoker.render(OnSaveRenderer.ON_SAVE);
317      dc.commit();
318      invoker.render(OnSaveRenderer.ON_COMMIT);
319    }
320    catch (Exception ex)
321    {
322      invoker.render(OnSaveRenderer.onRollback(ex));
323      throw ex;
324    }
325    finally
326    {
327      cc.removeObject("item");
328    }
329  }
330  else if ("DeleteItem".equals(cmd))
331  {
332    // Delete a single item and then return to the view page
333    dc = sc.newDbControl();
334    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
335    RemovableUtil.setRemoved(dc, itemType, Collections.singleton(cc.getId()), true);
336    dc.commit();
337    redirect = viewPage;
338  }
339  else if ("DeleteItems".equals(cmd))
340  {
341    // Delete all selected items on the list page
342    dc = sc.newDbControl();
343    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
344    int numTotal = cc.getSelected().size();
345    int numRemoved = RemovableUtil.setRemoved(dc, itemType, cc.getSelected(), true);
346    dc.commit();
347    if (numTotal != numRemoved)
348    {
349      message = (numRemoved == 0 ? "No" : "Only "+numRemoved+" of "+numTotal) + " items could be deleted, because you have no DELETE permission";
350    }
351    redirect = listPage;
352  }
353  else if ("RestoreItem".equals(cmd))
354  {
355    // Restore a single item and then return to the view page
356    dc = sc.newDbControl();
357    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
358    RemovableUtil.setRemoved(dc, itemType, Collections.singleton(cc.getId()), false);
359    dc.commit();
360    redirect = viewPage;
361  }
362  else if ("RestoreItems".equals(cmd))
363  {
364    // Restore all selected items on the list page
365    dc = sc.newDbControl();
366    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
367    int numTotal = cc.getSelected().size();
368    int numRemoved = RemovableUtil.setRemoved(dc, itemType, cc.getSelected(), false);
369    dc.commit();
370    if (numTotal != numRemoved)
371    {
372      message = (numRemoved == 0 ? "No" : "Only "+numRemoved+" of "+numTotal) + " items could be restored, because you have no WRITE permission";
373    }
374    redirect = listPage;
375  }
376  else if ("ShareItem".equals(cmd))
377  {
378    // Display a popup window for sharing a single item
379    dc = sc.newDbControl();
380    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
381    MultiPermissions permissions = ShareableUtil.getMultiPermissions(dc, itemType, Collections.singleton(cc.getId()));
382    dc.close();
383    cc.setObject("MultiPermissions", permissions);
384    redirect = "../../common/share/share.jsp?ID="+ID+"&item_type="+itemType.name();
385  }
386  else if ("ShareItems".equals(cmd))
387  {
388    // Display a popup window for sharing all selected items on the list page
389    dc = sc.newDbControl();
390    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
391    MultiPermissions permissions = ShareableUtil.getMultiPermissions(dc, itemType, cc.getSelected());
392    dc.close();
393    cc.setObject("MultiPermissions", permissions);
394    redirect = "../../common/share/share.jsp?ID="+ID+"&item_type="+itemType.name();
395  }
396  else if ("SetOwnerOfItem".equals(cmd))
397  {
398    // Change owner of items selected on a list page
399    dc = sc.newDbControl();
400    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
401    OwnedItem item = (OwnedItem)itemType.getById(dc, cc.getId());
402    cc.setObject("OwnedItems", Collections.singleton(item));
403    redirect = "../../common/ownership/ownership.jsp?ID="+ID+"&item_type="+itemType.name();
404  }
405  else if ("SetOwnerOfItems".equals(cmd))
406  {
407    // Change owner of items selected on a list page
408    dc = sc.newDbControl();
409    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
410    Set<OwnedItem> items = new HashSet<OwnedItem>();
411    for (Integer id : cc.getSelected())
412    {
413      if (id != null) items.add((OwnedItem)itemType.getById(dc, id));
414    }
415    dc.close();
416    cc.setObject("OwnedItems", items);
417    redirect = "../../common/ownership/ownership.jsp?ID="+ID+"&item_type="+itemType.name();
418  }
419  else if ("InheritAnnotations".equals(cmd))
420  {
421    // Change owner of items selected on a list page
422    dc = sc.newDbControl();
423    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
424    Set<AnnotatedItem> items = new HashSet<AnnotatedItem>();
425    for (Integer id : cc.getSelected())
426    {
427      if (id != null) items.add((AnnotatedItem)itemType.getById(dc, id));
428    }
429    dc.close();
430    cc.setObject("AnnotatedItems", items);
431    redirect = "../../common/annotations/batch_inherit.jsp?ID="+ID+"&item_type="+itemType.name();
432  }
433  else if ("ExportItems".equals(cmd))
434  {
435    // Run an export plugin in a list context
436    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
437    final ItemQuery<Sample> query = Sample.getQuery();
438    dc = sc.newDbControl();
439    cc.configureQuery(dc, query, true);
440    registerExportUtils(cc);
441    cc.setQuery(query);
442    JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.list(itemType), null);
443    ExtensionsInvoker<ListColumnAction<Sample,?>> listInvoker = ListColumnUtil.useExtensions(jspContext);
444    listInvoker.render(new ListColumnExportRenderer<Sample>(cc));
445    dc.close();
446    redirect = "../../common/export/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=LIST&title=Export+samples";
447  }
448  else if ("ExportItem".equals(cmd))
449  {
450    // Run an export plugin in single-item context
451    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
452    registerExportUtils(cc);
453    redirect = "../../common/export/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=ITEM&title=Export+sample";
454  }
455  else if ("ImportItems".equals(cmd))
456  {
457    // Run an import plugin in a list context
458    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
459    final ItemQuery<Sample> query = Sample.getQuery();
460    dc = sc.newDbControl();
461    cc.configureQuery(dc, query, true);
462    dc.close();
463    cc.setQuery(query);
464    redirect = "../../common/import/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=LIST&title=Import+sample";
465  }
466  else if ("ImportItem".equals(cmd))
467  {
468    // Run an import plugin in single-item context
469    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
470    redirect = "../../common/import/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=ITEM&title=Import+sample";
471  }
472  else if ("RunListPlugin".equals(cmd))
473  {
474    // Run another plugin in a list context
475    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
476    final ItemQuery<Sample> query = Sample.getQuery();
477    dc = sc.newDbControl();
478    cc.configureQuery(dc, query, true);
479    dc.close();
480    cc.setQuery(query);
481    redirect = "../../common/plugin/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=LIST&main_type=OTHER&title=Run+plugin";
482  }
483  else if ("RunPlugin".equals(cmd))
484  {
485    // Run another plugin in single-item context
486    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
487    redirect = "../../common/plugin/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=ITEM&main_type=OTHER&title=Run+plugin";
488  }
489  else if ("CreateItemList".equals(cmd))
490  {
491    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
492    final ItemQuery<Sample> query = Sample.getQuery();
493    dc = sc.newDbControl();
494    cc.configureQuery(dc, query, true);
495    dc.close();
496    cc.setQuery(query);
497    redirect = "../../views/itemlists/index.jsp?ID="+ID+"&cmd=NewItem&addItems=1&memberType=SAMPLE&formId=samples";
498  }
499  else if ("PlaceOnPlate".equals(cmd))
500  {
501    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
502    final ItemQuery<Sample> query = Sample.getQuery();
503    dc = sc.newDbControl();
504    cc.configureQuery(dc, query, true);
505    dc.close();
506    cc.filterOnSelectedItems(query);
507    sc.getCurrentContext(Item.BIOPLATEEVENT, BioPlateEventType.PLACE_ON_PLATE).setQuery(query);
508    redirect = "../wizards/place_on_plate.jsp?ID="+ID+"&itemType=SAMPLE";
509  }
510  else
511  {
512    throw new WebException("popup", "Invalid command", "The command {1} is not recognised as a valid command.", cmd);
513  }
514}
515finally
516{
517  if (dc != null) dc.close();
518}
519
520if (forward != null)
521{
522  sc.setSessionSetting("alert-message", message);
523  pageContext.forward(forward);
524}
525else if (redirect != null)
526{
527  sc.setSessionSetting("alert-message", message);
528  response.sendRedirect(redirect);
529}
530else if (message == null)
531{
532  response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&wait=0");
533}
534else
535{
536  response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&message="+HTML.urlEncode(message));
537}
538%>
539
Note: See TracBrowser for help on using the repository browser.