source: trunk/www/views/experiments/bioassaysets/index.jsp @ 4910

Last change on this file since 4910 was 4910, checked in by Nicklas Nordborg, 13 years ago

References #1120: The dynamic part of BASE should keep track whether intensity data is in log space or not

Added this flag to bioassay set and made it possible to modify it in the web interface.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 14.7 KB
Line 
1
2<%@page import="net.sf.basedb.core.IntensityTransform"%><%-- $Id: index.jsp 4910 2009-04-29 09:05:20Z nicklas $
3  ------------------------------------------------------------------
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  This file is part of BASE.
11
12  BASE is free software; you can redistribute it and/or
13  modify it under the terms of the GNU General Public License
14  as published by the Free Software Foundation; either version 3
15  of the License, or (at your option) any later version.
16
17  BASE is distributed in the hope that it will be useful,
18  but WITHOUT ANY WARRANTY; without even the implied warranty of
19  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20  GNU General Public License for more details.
21
22  You should have received a copy of the GNU General Public License
23  along with BASE. If not, see <http://www.gnu.org/licenses/>.
24  ------------------------------------------------------------------
25
26  @author Nicklas
27  @version 2.0
28--%>
29<%@ page session="false"
30  import="net.sf.basedb.core.SessionControl"
31  import="net.sf.basedb.core.DbControl"
32  import="net.sf.basedb.core.Item"
33  import="net.sf.basedb.core.Include"
34  import="net.sf.basedb.core.Experiment"
35  import="net.sf.basedb.core.BioAssaySet"
36  import="net.sf.basedb.core.Job"
37  import="net.sf.basedb.core.RawBioAssay"
38  import="net.sf.basedb.core.StringParameterType"
39  import="net.sf.basedb.core.IntegerParameterType"
40  import="net.sf.basedb.core.ItemParameterType"
41  import="net.sf.basedb.core.User"
42  import="net.sf.basedb.core.Path"
43  import="net.sf.basedb.core.ItemQuery"
44  import="net.sf.basedb.core.ItemResultIterator"
45  import="net.sf.basedb.core.Permission"
46  import="net.sf.basedb.core.PluginDefinition"
47  import="net.sf.basedb.core.ItemContext"
48  import="net.sf.basedb.core.MultiPermissions"
49  import="net.sf.basedb.core.PermissionDeniedException"
50  import="net.sf.basedb.core.ItemAlreadyExistsException"
51  import="net.sf.basedb.core.query.Restriction"
52  import="net.sf.basedb.util.RemovableUtil"
53  import="net.sf.basedb.util.ShareableUtil"
54  import="net.sf.basedb.util.BioAssaySetUtil"
55  import="net.sf.basedb.util.DynamicFilter"
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="java.util.Enumeration"
62  import="java.util.Set"
63  import="java.util.HashSet"
64  import="java.util.List"
65  import="java.util.LinkedList"
66  import="java.util.Collections"
67  import="java.util.Arrays"
68%>
69<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
70<%!
71  private static final ItemContext defaultContext = Base.createDefaultContext("name", "name,spots,reporters,date,tools");
72  private static final Item itemType = Item.BIOASSAYSET;
73 
74 
75  private void setClosed(HttpServletRequest request, ItemContext cc)
76  {
77    String closed = request.getParameter("closed");
78    if (closed == null && cc.getSetting("closed") != null && cc.getObject("closed") == null)
79    {
80      closed = (String)cc.getSetting("closed");
81    }
82    if (closed != null)
83    {
84      cc.setSetting("closed", closed);
85      cc.setObject("closed", new HashSet<String>(Arrays.asList(closed.split(","))));
86    }
87  }
88%>
89<%
90final int experimentId = Values.getInt(request.getParameter("experiment_id"));
91final String transformationId = request.getParameter("transformation_id");
92final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
93final String ID = sc.getId();
94final String cmd = request.getParameter("cmd");
95final String root = request.getContextPath()+"/";
96final String mode = request.getParameter("mode");
97final String callback = request.getParameter("callback");
98final String itemId = request.getParameter("item_id");
99final String listPage = "list_bioassaysets.jsp?ID="+ID+"&experiment_id="+experimentId
100  +(mode == null ? "" : "&mode="+mode)
101  +(callback == null ? "" : "&callback="+callback)
102  +(itemId == null ? "" : "&item_id="+itemId);
103final String viewPage = "view_bioassayset.jsp?ID="+ID+"&experiment_id="+experimentId;
104final String editPage = "edit_bioassayset.jsp?ID="+ID+"&experiment_id="+experimentId;
105final String viewTransformationPage = "../transformations/view_transformation.jsp?ID="+ID+
106  "&experiment_id="+experimentId;
107final String newPage = "../../../common/plugin/index.jsp?ID="+ID
108  +"&cmd=SelectPlugin&main_type=INTENSITY&item_type=BIOASSAYSET&context_type=LIST&title=Create+root+bioassay+set";
109
110if (experimentId != 0) sc.getCurrentContext(Item.EXPERIMENT).setId(experimentId);
111
112String forward = null;
113String redirect = null;
114String message = null;
115DbControl dc = null;
116
117try
118{
119  if (cmd == null || "List".equals(cmd))
120  {
121    // Display the list page without updatinging the current context
122    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, defaultContext, true);
123    setClosed(request, cc);
124    if (transformationId != null)
125    {
126      forward = viewTransformationPage;
127    }
128    else if (itemId != null)
129    {
130      forward = viewPage;
131    }
132    else
133    {
134      redirect = listPage;
135    }
136  }
137  else if ("UpdateContext".equals(cmd))
138  {
139    // Display the list page after updating the current context from the request parameters
140    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
141    setClosed(request, cc);
142    if (transformationId != null)
143    {
144      forward = viewTransformationPage;
145    }
146    else if (itemId != null)
147    {
148      forward = viewPage;
149    }
150    else
151    {
152      redirect = listPage;
153    }
154  }
155  else if ("LoadContext".equals(cmd))
156  {
157    // Display the list page after loading a saved context
158    int contextId = Values.getInt(request.getParameter("context"));
159    Base.loadContext(sc, contextId, defaultContext);
160    if (transformationId != null)
161    {
162      forward = viewTransformationPage;
163    }
164    else if (itemId != null)
165    {
166      forward = viewPage;
167    }
168    else
169    {
170      redirect = listPage;
171    }
172  }
173
174  else if ("ViewItem".equals(cmd))
175  {
176    // Display the view page for a single item
177    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
178    forward = viewPage;
179  }
180  else if ("EditItem".equals(cmd))
181  {
182    // Display the edit page for a single item (should be opened in a popup)
183    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
184    redirect = editPage;
185  }
186  else if ("NewItem".equals(cmd))
187  {
188    // Display the edit page for a new item (should be opened in a popup)
189    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
190    cc.setId(0);
191    redirect = newPage;
192  }
193  else if ("UpdateItem".equals(cmd))
194  {
195    // Update the properties on an item (will close the popup)
196    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, defaultContext);
197    dc = sc.newDbControl();
198   
199    BioAssaySet bas = (BioAssaySet)cc.getObject("item");
200    if (bas != null)
201    {
202      dc.reattachItem(bas);
203      message = "Bioassay set updated";
204      bas.setName(Values.getStringOrNull(request.getParameter("name")));
205      bas.setDescription(Values.getStringOrNull(request.getParameter("description")));
206      bas.setIntensityTransform(IntensityTransform.valueOf(request.getParameter("intensityTransform")));
207
208      // Annotations tab
209      Base.updateAnnotations(dc, bas, bas, request);
210    }
211    dc.commit();
212    cc.removeObject("item");
213  }
214  else if ("DeleteItem".equals(cmd))
215  {
216    // Delete a single item and then return to the view page
217    dc = sc.newDbControl();
218    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
219    RemovableUtil.removeRecursively(dc, itemType, Collections.singleton(cc.getId()), true);
220    dc.commit();
221    redirect = viewPage;
222  }
223  else if ("DeleteItems".equals(cmd))
224  {
225    // Delete all selected items on the list page
226    dc = sc.newDbControl();
227    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
228    ItemContext tc = sc.getCurrentContext(Item.TRANSFORMATION);
229    ItemContext xc = sc.getCurrentContext(Item.EXTRAVALUE);
230    setClosed(request, cc);
231
232    int numTotal = cc.getSelected().size()+tc.getSelected().size();
233    int numRemoved = 0;
234    int[] numTransformationRemoved = RemovableUtil.removeRecursively(dc, Item.TRANSFORMATION, tc.getSelected(), true);
235    int[] numBioAssaySetRemoved = RemovableUtil.removeRecursively(dc, itemType, cc.getSelected(), true);
236    int numXV = RemovableUtil.delete(dc, Item.EXTRAVALUE, xc.getSelected());
237    numTotal += numTransformationRemoved[1] + numBioAssaySetRemoved[1];
238    numRemoved += numTransformationRemoved[0] + numBioAssaySetRemoved[0];
239
240    dc.commit();
241    if (numTotal != numRemoved)
242    {
243      message = (numRemoved == 0 ? "No" : "Only "+numRemoved+" of "+numTotal) + " items could be deleted, because you have no DELETE permission";
244    }
245    if (transformationId != null)
246    {
247      forward = viewTransformationPage+(message != null ? "&popmessage="+HTML.urlEncode(message) : "");
248    }
249    else if (itemId != null)
250    {
251      forward = viewPage+(message != null ? "&popmessage="+HTML.urlEncode(message) : "");
252    }
253    else
254    {
255      redirect = listPage+(message != null ? "&popmessage="+HTML.urlEncode(message) : "");
256    }
257  }
258  else if ("RestoreItem".equals(cmd))
259  {
260    // Restore a single item and then return to the view page
261    dc = sc.newDbControl();
262    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
263    RemovableUtil.removeRecursively(dc, itemType, Collections.singleton(cc.getId()), false);
264    dc.commit();
265    redirect = viewPage;
266  }
267  else if ("RestoreItems".equals(cmd))
268  {
269    // Restore all selected items on the list page
270    dc = sc.newDbControl();
271    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
272    ItemContext tc = sc.getCurrentContext(Item.TRANSFORMATION);
273    setClosed(request, cc);
274
275    int numTotal = cc.getSelected().size()+tc.getSelected().size();
276    int numRemoved = 0;
277    int[] numTransformationRemoved = RemovableUtil.removeRecursively(dc, Item.TRANSFORMATION, tc.getSelected(), false);
278    int[] numBioAssaySetRemoved = RemovableUtil.removeRecursively(dc, itemType, cc.getSelected(), false);
279    numTotal += numTransformationRemoved[1] + numBioAssaySetRemoved[1];
280    numRemoved += numTransformationRemoved[0] + numBioAssaySetRemoved[0];
281   
282    dc.commit();
283    if (numTotal != numRemoved)
284    {
285      message = (numRemoved == 0 ? "No" : "Only "+numRemoved+" of "+numTotal) + " items could be restored, because you have no WRITE permission";
286    }
287    if (transformationId != null)
288    {
289      forward = viewTransformationPage+(message != null ? "&popmessage="+HTML.urlEncode(message) : "");
290    }
291    else if (itemId != null)
292    {
293      forward = viewPage+(message != null ? "&popmessage="+HTML.urlEncode(message) : "");
294    }
295    else
296    {
297      redirect = listPage+(message != null ? "&popmessage="+HTML.urlEncode(message) : "");
298    }
299  }
300  else if ("ExportItems".equals(cmd))
301  {
302    // Run an export plugin in a list context
303    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
304    setClosed(request, cc);
305    dc = sc.newDbControl();
306    final Experiment experiment = Experiment.getById(dc, experimentId);
307    dc.close();
308    final ItemQuery<BioAssaySet> query = experiment.getBioAssaySets();
309    cc.configureQuery(query, true);
310    cc.setQuery(query);
311    redirect = "../../../common/export/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=LIST&title=Export+bioassay+sets";
312  }
313  else if ("ExportItem".equals(cmd))
314  {
315    // Run an export plugin in single-item context
316    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
317    redirect = "../../../common/export/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=ITEM&title=Export+bioassay+set";
318  }
319  else if ("ImportItems".equals(cmd))
320  {
321    // Run an import plugin in a list context
322    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
323    setClosed(request, cc);
324    dc = sc.newDbControl();
325    final Experiment experiment = Experiment.getById(dc, experimentId);
326    dc.close();
327    final ItemQuery<BioAssaySet> query = experiment.getBioAssaySets();
328    cc.configureQuery(query, true);
329    cc.setQuery(query);
330    redirect = "../../../common/import/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=LIST&title=Import+bioassay+sets";
331  }
332  else if ("ImportItem".equals(cmd))
333  {
334    // Run an import plugin in single-item context
335    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
336    redirect = "../../../common/import/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=ITEM&title=Import+bioassay+set";
337  }
338  else if ("RunListPlugin".equals(cmd))
339  {
340    // Run another plugin in a list context
341    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
342    setClosed(request, cc);
343    dc = sc.newDbControl();
344    final Experiment experiment = Experiment.getById(dc, experimentId);
345    dc.close();
346    final ItemQuery<BioAssaySet> query = experiment.getBioAssaySets();
347    cc.configureQuery(query, true);
348    cc.setQuery(query);
349    redirect = "../../../common/plugin/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=LIST&main_type=OTHER&title=Run+plugin";
350  }
351  else if ("RunPlugin".equals(cmd))
352  {
353    // Run a plugin in single-item context
354    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
355    redirect = "../../../common/plugin/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=ITEM&main_type=OTHER&title=Run+plugin";
356  }
357  else if ("RunAnalysisPlugin".equals(cmd))
358  {
359    // Run an analysis plugin in single-item context
360    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
361    redirect = "../../../common/plugin/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=ITEM&main_type=ANALYZE&title=Run+analysis+plugin";
362  }
363  else if ("NewFilteredBioAssaySet".equals(cmd))
364  {
365    // Display the edit page for for filtering a bioassay set (should be opened in a popup)
366    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
367    redirect = "../../../common/plugin/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=ITEM&main_type=ANALYZE&title=Filter+bioassay+set&plugin_type=net.sf.basedb.core.plugin.AnalysisFilterPlugin";
368  }
369  else if ("SetClosedWithAjax".equals(cmd))
370  {
371    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
372    setClosed(request, cc);
373    return;
374  }
375  else
376  {
377    throw new WebException("popup", "Invalid command", "The command {1} is not recognised as a valid command.", cmd);
378  }
379}
380finally
381{
382  if (dc != null) dc.close();
383}
384
385if (forward != null)
386{
387  pageContext.forward(forward);
388}
389else if (redirect != null)
390{
391  response.sendRedirect(redirect);
392}
393else if (message == null)
394{
395  response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&wait=0");
396}
397else
398{
399  response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&message="+HTML.urlEncode(message));
400}
401%>
402
Note: See TracBrowser for help on using the repository browser.