www/views/experiments/extravalues/index.jsp

Code
Comments
Other
Rev Date Author Line
2664 26 Sep 06 nicklas 1 <%-- $Id$
2664 26 Sep 06 nicklas 2   ------------------------------------------------------------------
2664 26 Sep 06 nicklas 3   Copyright (C) 2006 Nicklas Nordborg
2664 26 Sep 06 nicklas 4
2664 26 Sep 06 nicklas 5   This file is part of BASE - BioArray Software Environment.
2664 26 Sep 06 nicklas 6   Available at http://base.thep.lu.se/
2664 26 Sep 06 nicklas 7
2664 26 Sep 06 nicklas 8   This file is part of BASE.
2664 26 Sep 06 nicklas 9
2664 26 Sep 06 nicklas 10   BASE is free software; you can redistribute it and/or
2664 26 Sep 06 nicklas 11   modify it under the terms of the GNU General Public License
4476 05 Sep 08 jari 12   as published by the Free Software Foundation; either version 3
2664 26 Sep 06 nicklas 13   of the License, or (at your option) any later version.
2664 26 Sep 06 nicklas 14
2664 26 Sep 06 nicklas 15   BASE is distributed in the hope that it will be useful,
2664 26 Sep 06 nicklas 16   but WITHOUT ANY WARRANTY; without even the implied warranty of
2664 26 Sep 06 nicklas 17   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
2664 26 Sep 06 nicklas 18   GNU General Public License for more details.
2664 26 Sep 06 nicklas 19
2664 26 Sep 06 nicklas 20   You should have received a copy of the GNU General Public License
4511 11 Sep 08 jari 21   along with BASE. If not, see <http://www.gnu.org/licenses/>.
2664 26 Sep 06 nicklas 22   ------------------------------------------------------------------
2664 26 Sep 06 nicklas 23
2664 26 Sep 06 nicklas 24   @author Nicklas
2664 26 Sep 06 nicklas 25   @version 2.0
2664 26 Sep 06 nicklas 26 --%>
5426 24 Sep 10 nicklas 27 <%@ page pageEncoding="UTF-8" session="false"
2664 26 Sep 06 nicklas 28   import="net.sf.basedb.core.SessionControl"
2664 26 Sep 06 nicklas 29   import="net.sf.basedb.core.DbControl"
2664 26 Sep 06 nicklas 30   import="net.sf.basedb.core.Item"
2664 26 Sep 06 nicklas 31   import="net.sf.basedb.core.Include"
2664 26 Sep 06 nicklas 32   import="net.sf.basedb.core.Experiment"
2664 26 Sep 06 nicklas 33   import="net.sf.basedb.core.BioAssaySet"
2664 26 Sep 06 nicklas 34   import="net.sf.basedb.core.ExtraValue"
2664 26 Sep 06 nicklas 35   import="net.sf.basedb.core.User"
2664 26 Sep 06 nicklas 36   import="net.sf.basedb.core.Path"
2664 26 Sep 06 nicklas 37   import="net.sf.basedb.core.ItemQuery"
2664 26 Sep 06 nicklas 38   import="net.sf.basedb.core.ItemResultIterator"
2664 26 Sep 06 nicklas 39   import="net.sf.basedb.core.Permission"
2664 26 Sep 06 nicklas 40   import="net.sf.basedb.core.ItemContext"
2664 26 Sep 06 nicklas 41   import="net.sf.basedb.core.MultiPermissions"
2664 26 Sep 06 nicklas 42   import="net.sf.basedb.core.PermissionDeniedException"
2664 26 Sep 06 nicklas 43   import="net.sf.basedb.core.ItemAlreadyExistsException"
2664 26 Sep 06 nicklas 44   import="net.sf.basedb.core.query.Restriction"
2664 26 Sep 06 nicklas 45   import="net.sf.basedb.util.RemovableUtil"
2664 26 Sep 06 nicklas 46   import="net.sf.basedb.util.ShareableUtil"
2664 26 Sep 06 nicklas 47   import="net.sf.basedb.util.BioAssaySetFilterUtil"
2664 26 Sep 06 nicklas 48   import="net.sf.basedb.util.DynamicFilter"
2664 26 Sep 06 nicklas 49   import="net.sf.basedb.util.IncludeExcludeFilter"
2664 26 Sep 06 nicklas 50   import="net.sf.basedb.clients.web.Base"
2664 26 Sep 06 nicklas 51   import="net.sf.basedb.clients.web.WebException"
2753 20 Oct 06 nicklas 52   import="net.sf.basedb.util.Values"
2664 26 Sep 06 nicklas 53   import="net.sf.basedb.clients.web.util.HTML"
2664 26 Sep 06 nicklas 54   import="java.util.Enumeration"
2664 26 Sep 06 nicklas 55   import="java.util.Set"
2664 26 Sep 06 nicklas 56   import="java.util.HashSet"
2664 26 Sep 06 nicklas 57   import="java.util.List"
2664 26 Sep 06 nicklas 58   import="java.util.LinkedList"
2664 26 Sep 06 nicklas 59   import="java.util.Collections"
2664 26 Sep 06 nicklas 60   import="java.util.Arrays"
2664 26 Sep 06 nicklas 61 %>
2664 26 Sep 06 nicklas 62 <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
2664 26 Sep 06 nicklas 63 <%!
2664 26 Sep 06 nicklas 64   private static final ItemContext defaultContext = Base.createDefaultContext("name", "name,transformation,spots,reporters,date,tools");
2664 26 Sep 06 nicklas 65   private static final Item itemType = Item.EXTRAVALUE;
2664 26 Sep 06 nicklas 66 %>
2664 26 Sep 06 nicklas 67 <%
2664 26 Sep 06 nicklas 68 final int experimentId = Values.getInt(request.getParameter("experiment_id"));
2664 26 Sep 06 nicklas 69 final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
2664 26 Sep 06 nicklas 70 final String ID = sc.getId();
2664 26 Sep 06 nicklas 71 final String cmd = request.getParameter("cmd");
2664 26 Sep 06 nicklas 72 final String root = request.getContextPath()+"/";
2664 26 Sep 06 nicklas 73 final String mode = request.getParameter("mode");
2664 26 Sep 06 nicklas 74 final String callback = request.getParameter("callback");
2664 26 Sep 06 nicklas 75 final String itemId = request.getParameter("item_id");
2664 26 Sep 06 nicklas 76
2664 26 Sep 06 nicklas 77 final String viewPage = "view_extravalue.jsp?ID="+ID+"&experiment_id="+experimentId;
6315 06 Sep 13 nicklas 78 if (experimentId > 0) sc.getCurrentContext(Item.EXPERIMENT).setId(experimentId);
2664 26 Sep 06 nicklas 79
2664 26 Sep 06 nicklas 80 String forward = null;
2664 26 Sep 06 nicklas 81 String redirect = null;
2664 26 Sep 06 nicklas 82 String message = null;
2664 26 Sep 06 nicklas 83 DbControl dc = null;
2664 26 Sep 06 nicklas 84
2664 26 Sep 06 nicklas 85 try
2664 26 Sep 06 nicklas 86 {
2664 26 Sep 06 nicklas 87   if ("ViewItem".equals(cmd))
2664 26 Sep 06 nicklas 88   {
2664 26 Sep 06 nicklas 89     // Display the view page for a single item 
2664 26 Sep 06 nicklas 90     ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
2664 26 Sep 06 nicklas 91     forward = viewPage;
2664 26 Sep 06 nicklas 92   }
2664 26 Sep 06 nicklas 93   else if ("DeleteItem".equals(cmd))
2664 26 Sep 06 nicklas 94   {
2664 26 Sep 06 nicklas 95     // Delete a single item and then return to the view page
7954 12 May 21 nicklas 96     dc = sc.newDbControl(":Delete "+itemType);
2664 26 Sep 06 nicklas 97     ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
2664 26 Sep 06 nicklas 98     BioAssaySet bas = ExtraValue.getById(dc, cc.getId()).getBioAssaySet();
2664 26 Sep 06 nicklas 99     RemovableUtil.delete(dc, itemType, Collections.singleton(cc.getId()));
2664 26 Sep 06 nicklas 100     dc.commit();
2664 26 Sep 06 nicklas 101     redirect = "../bioassaysets/index.jsp?ID="+ID+"&cmd=ViewItem&item_id="+bas.getId();
2664 26 Sep 06 nicklas 102   }
2664 26 Sep 06 nicklas 103   else if ("ExportItem".equals(cmd))
2664 26 Sep 06 nicklas 104   {
2664 26 Sep 06 nicklas 105     // Run an export plugin in single-item context
2664 26 Sep 06 nicklas 106     ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
2664 26 Sep 06 nicklas 107     redirect = "../../../common/export/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=ITEM&title=Export+bioassay+set";
2664 26 Sep 06 nicklas 108   }
2664 26 Sep 06 nicklas 109   else if ("ImportItem".equals(cmd))
2664 26 Sep 06 nicklas 110   {
2664 26 Sep 06 nicklas 111     // Run an import plugin in single-item context
2664 26 Sep 06 nicklas 112     ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
2664 26 Sep 06 nicklas 113     redirect = "../../../common/import/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=ITEM&title=Import+bioassay+set";
2664 26 Sep 06 nicklas 114   }
2664 26 Sep 06 nicklas 115   else if ("RunPlugin".equals(cmd))
2664 26 Sep 06 nicklas 116   {
2664 26 Sep 06 nicklas 117     // Run a plugin in single-item context
2664 26 Sep 06 nicklas 118     ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
2664 26 Sep 06 nicklas 119     redirect = "../../../common/plugin/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=ITEM&main_type=OTHER&title=Run+plugin";
2664 26 Sep 06 nicklas 120   }
2664 26 Sep 06 nicklas 121   else if ("RunAnalysisPlugin".equals(cmd))
2664 26 Sep 06 nicklas 122   {
2664 26 Sep 06 nicklas 123     // Run an analysis plugin in single-item context
2664 26 Sep 06 nicklas 124     ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
2664 26 Sep 06 nicklas 125     redirect = "../../../common/plugin/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=ITEM&main_type=ANALYZE&title=Run+analysis+plugin";
2664 26 Sep 06 nicklas 126   }
2664 26 Sep 06 nicklas 127   else
2664 26 Sep 06 nicklas 128   {
2664 26 Sep 06 nicklas 129     throw new WebException("popup", "Invalid command", "The command {1} is not recognised as a valid command.", cmd);
2664 26 Sep 06 nicklas 130   }
2664 26 Sep 06 nicklas 131 }
2664 26 Sep 06 nicklas 132 finally
2664 26 Sep 06 nicklas 133 {
2664 26 Sep 06 nicklas 134   if (dc != null) dc.close();
2664 26 Sep 06 nicklas 135 }
2664 26 Sep 06 nicklas 136
2664 26 Sep 06 nicklas 137 if (forward != null)
2664 26 Sep 06 nicklas 138 {
6192 31 Oct 12 nicklas 139   sc.setSessionSetting("alert-message", message);
2664 26 Sep 06 nicklas 140   pageContext.forward(forward);
2664 26 Sep 06 nicklas 141 }
2664 26 Sep 06 nicklas 142 else if (redirect != null)
2664 26 Sep 06 nicklas 143 {
6192 31 Oct 12 nicklas 144   sc.setSessionSetting("alert-message", message);
2664 26 Sep 06 nicklas 145   response.sendRedirect(redirect);
2664 26 Sep 06 nicklas 146 }
2664 26 Sep 06 nicklas 147 else if (message == null)
2664 26 Sep 06 nicklas 148 {
2664 26 Sep 06 nicklas 149   response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&wait=0");
2664 26 Sep 06 nicklas 150 }
2664 26 Sep 06 nicklas 151 else
2664 26 Sep 06 nicklas 152 {
2664 26 Sep 06 nicklas 153   response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&message="+HTML.urlEncode(message));
2664 26 Sep 06 nicklas 154 }
2664 26 Sep 06 nicklas 155 %>
2664 26 Sep 06 nicklas 156