www/lims/arraybatches/edit_batch.jsp

Code
Comments
Other
Rev Date Author Line
1813 24 Jan 06 nicklas 1 <%-- $Id$
1813 24 Jan 06 nicklas 2   ------------------------------------------------------------------
5425 23 Sep 10 nicklas 3   Copyright (C) 2006 Jari Häkkinen, Nicklas Nordborg, Martin Svensson
1813 24 Jan 06 nicklas 4
2304 22 May 06 jari 5   This file is part of BASE - BioArray Software Environment.
2304 22 May 06 jari 6   Available at http://base.thep.lu.se/
1813 24 Jan 06 nicklas 7
1813 24 Jan 06 nicklas 8   BASE is free software; you can redistribute it and/or
1813 24 Jan 06 nicklas 9   modify it under the terms of the GNU General Public License
4476 05 Sep 08 jari 10   as published by the Free Software Foundation; either version 3
1813 24 Jan 06 nicklas 11   of the License, or (at your option) any later version.
1813 24 Jan 06 nicklas 12
1813 24 Jan 06 nicklas 13   BASE is distributed in the hope that it will be useful,
1813 24 Jan 06 nicklas 14   but WITHOUT ANY WARRANTY; without even the implied warranty of
1813 24 Jan 06 nicklas 15   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1813 24 Jan 06 nicklas 16   GNU General Public License for more details.
1813 24 Jan 06 nicklas 17
1813 24 Jan 06 nicklas 18   You should have received a copy of the GNU General Public License
4511 11 Sep 08 jari 19   along with BASE. If not, see <http://www.gnu.org/licenses/>.
1813 24 Jan 06 nicklas 20   ------------------------------------------------------------------
1813 24 Jan 06 nicklas 21
1813 24 Jan 06 nicklas 22
1813 24 Jan 06 nicklas 23   @author Nicklas
1813 24 Jan 06 nicklas 24   @version 2.0
1813 24 Jan 06 nicklas 25 --%>
5426 24 Sep 10 nicklas 26 <%@ page pageEncoding="UTF-8" session="false"
1813 24 Jan 06 nicklas 27   import="net.sf.basedb.core.SessionControl"
1813 24 Jan 06 nicklas 28   import="net.sf.basedb.core.DbControl"
1813 24 Jan 06 nicklas 29   import="net.sf.basedb.core.Item"
1813 24 Jan 06 nicklas 30   import="net.sf.basedb.core.ItemContext"
1813 24 Jan 06 nicklas 31   import="net.sf.basedb.core.SystemItems"
1813 24 Jan 06 nicklas 32   import="net.sf.basedb.core.Permission"
1813 24 Jan 06 nicklas 33   import="net.sf.basedb.core.Include"
1813 24 Jan 06 nicklas 34   import="net.sf.basedb.core.ArrayBatch"
1813 24 Jan 06 nicklas 35   import="net.sf.basedb.core.ArrayDesign"
1813 24 Jan 06 nicklas 36   import="net.sf.basedb.core.Protocol"
5650 01 Jun 11 nicklas 37   import="net.sf.basedb.core.ItemSubtype"
2949 24 Nov 06 martin 38   import="net.sf.basedb.core.Project"
1813 24 Jan 06 nicklas 39   import="net.sf.basedb.core.Hardware"
1813 24 Jan 06 nicklas 40   import="net.sf.basedb.core.ItemQuery"
1813 24 Jan 06 nicklas 41   import="net.sf.basedb.core.ItemResultList"
1813 24 Jan 06 nicklas 42   import="net.sf.basedb.core.PermissionDeniedException"
1813 24 Jan 06 nicklas 43   import="net.sf.basedb.core.BaseException"
1813 24 Jan 06 nicklas 44   import="net.sf.basedb.core.query.Orders"
1813 24 Jan 06 nicklas 45   import="net.sf.basedb.core.query.Hql"
1813 24 Jan 06 nicklas 46   import="net.sf.basedb.clients.web.Base"
1813 24 Jan 06 nicklas 47   import="net.sf.basedb.clients.web.util.HTML"
2753 20 Oct 06 nicklas 48   import="net.sf.basedb.util.Values"
5498 17 Nov 10 nicklas 49   import="net.sf.basedb.core.plugin.GuiContext"
5498 17 Nov 10 nicklas 50   import="net.sf.basedb.clients.web.extensions.ExtensionsControl"
5498 17 Nov 10 nicklas 51   import="net.sf.basedb.clients.web.extensions.JspContext"
5498 17 Nov 10 nicklas 52   import="net.sf.basedb.clients.web.extensions.edit.EditUtil"
7604 25 Feb 19 nicklas 53   import="net.sf.basedb.clients.web.extensions.tabcontrol.TabAction"
5498 17 Nov 10 nicklas 54   import="net.sf.basedb.util.extensions.ExtensionsInvoker"
1813 24 Jan 06 nicklas 55   import="java.util.List"
1813 24 Jan 06 nicklas 56   import="java.util.Set"
1813 24 Jan 06 nicklas 57   import="java.util.HashSet"
1813 24 Jan 06 nicklas 58   import="java.util.Date"
1813 24 Jan 06 nicklas 59 %>
1813 24 Jan 06 nicklas 60 <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
1813 24 Jan 06 nicklas 61 <%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %>
6146 21 Sep 12 nicklas 62 <%@ taglib prefix="ext" uri="/WEB-INF/extensions.tld" %>
1813 24 Jan 06 nicklas 63 <%
1813 24 Jan 06 nicklas 64 final Item itemType = Item.ARRAYBATCH;
1813 24 Jan 06 nicklas 65 final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
1813 24 Jan 06 nicklas 66 final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
1813 24 Jan 06 nicklas 67 final int itemId = cc.getId();
1813 24 Jan 06 nicklas 68 final String ID = sc.getId();
1813 24 Jan 06 nicklas 69 final float scale = Base.getScale(sc);
7954 12 May 21 nicklas 70 final DbControl dc = sc.newDbControl(":Edit "+itemType);
1813 24 Jan 06 nicklas 71 try
1813 24 Jan 06 nicklas 72 {
1813 24 Jan 06 nicklas 73   String title = null;
1813 24 Jan 06 nicklas 74   ArrayBatch batch = null;
1813 24 Jan 06 nicklas 75   
1813 24 Jan 06 nicklas 76   boolean readCurrentArrayDesign = true;
1813 24 Jan 06 nicklas 77   ArrayDesign currentArrayDesign = null;
5687 09 Aug 11 nicklas 78   List<ArrayDesign> defaultArrayDesigns = null;
1813 24 Jan 06 nicklas 79   boolean readCurrentProtocol = true;
1813 24 Jan 06 nicklas 80   Protocol currentProtocol = null;
5687 09 Aug 11 nicklas 81   List<Protocol> defaultProtocols = null;
1813 24 Jan 06 nicklas 82   boolean readCurrentPrintRobot = true;
1813 24 Jan 06 nicklas 83   Hardware currentPrintRobot = null;
5687 09 Aug 11 nicklas 84   List<Hardware> defaultPrintRobots = null;
1813 24 Jan 06 nicklas 85
2598 28 Aug 06 nicklas 86   // Load recently used items
7605 26 Feb 19 nicklas 87   List<ArrayDesign> recentArrayDesigns = cc.getRecent(dc, Item.ARRAYDESIGN);
7605 26 Feb 19 nicklas 88   List<Protocol> recentProtocols = cc.getRecent(dc, Item.PROTOCOL);
7605 26 Feb 19 nicklas 89   List<Hardware> recentPrintRobots = cc.getRecent(dc, Item.HARDWARE);
2598 28 Aug 06 nicklas 90   
2949 24 Nov 06 martin 91   int activeProjectId = sc.getActiveProjectId();
2949 24 Nov 06 martin 92   if (activeProjectId > 0)
2949 24 Nov 06 martin 93   {
2949 24 Nov 06 martin 94     Project activeProject = Project.getById(dc, activeProjectId);
2949 24 Nov 06 martin 95     try
2949 24 Nov 06 martin 96     {
7605 26 Feb 19 nicklas 97       defaultArrayDesigns = activeProject.findDefaultItems(dc, Item.ARRAYDESIGN, true);
2949 24 Nov 06 martin 98     }
2949 24 Nov 06 martin 99     catch (PermissionDeniedException pdex)
5687 09 Aug 11 nicklas 100     {}
2949 24 Nov 06 martin 101     try
2949 24 Nov 06 martin 102     {
7605 26 Feb 19 nicklas 103       defaultProtocols = activeProject.findDefaultItems(dc, 
5650 01 Jun 11 nicklas 104           ItemSubtype.getById(dc, SystemItems.getId(Protocol.PRINTING)), false);
2949 24 Nov 06 martin 105     }
2949 24 Nov 06 martin 106     catch (PermissionDeniedException pdex)
5687 09 Aug 11 nicklas 107     {}
2949 24 Nov 06 martin 108     try
2949 24 Nov 06 martin 109     {
7605 26 Feb 19 nicklas 110       defaultPrintRobots = activeProject.findDefaultItems(dc, 
5650 01 Jun 11 nicklas 111           ItemSubtype.getById(dc, SystemItems.getId(Hardware.PRINT_ROBOT)), false);
2949 24 Nov 06 martin 112     }
2949 24 Nov 06 martin 113     catch (PermissionDeniedException pdex)
5687 09 Aug 11 nicklas 114     {}
2949 24 Nov 06 martin 115   }
1813 24 Jan 06 nicklas 116   if (itemId == 0)
1813 24 Jan 06 nicklas 117   {
1813 24 Jan 06 nicklas 118     title = "Create array batch";
1813 24 Jan 06 nicklas 119     cc.removeObject("item");
2449 29 Jun 06 nicklas 120     int arrayDesignId = Values.getInt(request.getParameter("arraydesign_id"));
2449 29 Jun 06 nicklas 121     if (arrayDesignId != 0)
1813 24 Jan 06 nicklas 122     {
2449 29 Jun 06 nicklas 123       currentArrayDesign = ArrayDesign.getById(dc, arrayDesignId);
2449 29 Jun 06 nicklas 124     }
2449 29 Jun 06 nicklas 125     else if (cc.getPropertyFilter("arrayDesign.name") != null)
2449 29 Jun 06 nicklas 126     {
1813 24 Jan 06 nicklas 127       currentArrayDesign = Base.getFirstMatching(dc, ArrayDesign.getQuery(), "name", cc.getPropertyFilter("arrayDesign.name"));
1813 24 Jan 06 nicklas 128     }
1813 24 Jan 06 nicklas 129     if (cc.getPropertyFilter("printRobot.name") != null)
1813 24 Jan 06 nicklas 130     {
1813 24 Jan 06 nicklas 131       currentPrintRobot = Base.getFirstMatching(dc, Hardware.getQuery(), "name", cc.getPropertyFilter("printRobot.name"));
1813 24 Jan 06 nicklas 132     }
1813 24 Jan 06 nicklas 133     if (cc.getPropertyFilter("protocol.name") != null)
1813 24 Jan 06 nicklas 134     {
1813 24 Jan 06 nicklas 135       currentProtocol = Base.getFirstMatching(dc, Protocol.getQuery(), "name", cc.getPropertyFilter("protocol.name"));
1813 24 Jan 06 nicklas 136     }
1813 24 Jan 06 nicklas 137   }
1813 24 Jan 06 nicklas 138   else
1813 24 Jan 06 nicklas 139   {
1813 24 Jan 06 nicklas 140     batch = ArrayBatch.getById(dc, itemId);
6312 28 Aug 13 nicklas 141     batch.checkPermission(Permission.WRITE);
1813 24 Jan 06 nicklas 142     cc.setObject("item", batch);
1813 24 Jan 06 nicklas 143     title = "Edit array batch -- " + HTML.encodeTags(batch.getName());
1813 24 Jan 06 nicklas 144     try
1813 24 Jan 06 nicklas 145     {
1813 24 Jan 06 nicklas 146       currentArrayDesign = batch.getArrayDesign();
1813 24 Jan 06 nicklas 147     }
1813 24 Jan 06 nicklas 148     catch (PermissionDeniedException ex)
1813 24 Jan 06 nicklas 149     {
1813 24 Jan 06 nicklas 150       readCurrentArrayDesign = false;
1813 24 Jan 06 nicklas 151     }
1813 24 Jan 06 nicklas 152     try
1813 24 Jan 06 nicklas 153     {
2949 24 Nov 06 martin 154       currentPrintRobot = batch.getPrintRobot();      
1813 24 Jan 06 nicklas 155     }
1813 24 Jan 06 nicklas 156     catch (PermissionDeniedException ex)
1813 24 Jan 06 nicklas 157     {
1813 24 Jan 06 nicklas 158       readCurrentPrintRobot = false;
1813 24 Jan 06 nicklas 159     }
1813 24 Jan 06 nicklas 160     try
1813 24 Jan 06 nicklas 161     {
2949 24 Nov 06 martin 162       currentProtocol = batch.getProtocol();      
1813 24 Jan 06 nicklas 163     }
1813 24 Jan 06 nicklas 164     catch (PermissionDeniedException ex)
1813 24 Jan 06 nicklas 165     {
1813 24 Jan 06 nicklas 166       readCurrentProtocol = false;
1813 24 Jan 06 nicklas 167     }
6312 28 Aug 13 nicklas 168   }  
6217 14 Dec 12 nicklas 169   
5498 17 Nov 10 nicklas 170   JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.item(itemType), batch);
7604 25 Feb 19 nicklas 171   ExtensionsInvoker<TabAction> invoker = EditUtil.useEditExtensions(jspContext);
1813 24 Jan 06 nicklas 172   %>
6312 28 Aug 13 nicklas 173   <base:page type="popup" title="<%=title%>" id="edit-page">
6312 28 Aug 13 nicklas 174   <base:head scripts="tabcontrol-2.js,~batches.js" styles="tabcontrol.css">
5498 17 Nov 10 nicklas 175     <ext:scripts context="<%=jspContext%>" />
5498 17 Nov 10 nicklas 176     <ext:stylesheets context="<%=jspContext%>" />
1813 24 Jan 06 nicklas 177   </base:head>
6312 28 Aug 13 nicklas 178   <base:body>
5917 19 Dec 11 nicklas 179     <h1><%=title%> <base:help tabcontrol="settings" /></h1>
6312 28 Aug 13 nicklas 180     <div id="page-data" class="datacontainer"
6312 28 Aug 13 nicklas 181       data-printing-protocol="<%=SystemItems.getId(Protocol.PRINTING)%>"
6312 28 Aug 13 nicklas 182       data-print-robot="<%=SystemItems.getId(Hardware.PRINT_ROBOT)%>"
6312 28 Aug 13 nicklas 183     ></div>
6312 28 Aug 13 nicklas 184     
6162 10 Oct 12 nicklas 185     <form action="index.jsp?ID=<%=ID%>" method="post" name="batch">
1813 24 Jan 06 nicklas 186     <input type="hidden" name="cmd" value="UpdateItem">
1813 24 Jan 06 nicklas 187
5917 19 Dec 11 nicklas 188     <t:tabcontrol id="settings" 
5917 19 Dec 11 nicklas 189       subclass="content dialogtabcontrol"
6312 28 Aug 13 nicklas 190       position="bottom" remember="<%=batch != null%>" 
5498 17 Nov 10 nicklas 191       extensions="<%=invoker%>">
6312 28 Aug 13 nicklas 192     <t:tab id="info" title="Array batch" helpid="arraybatch.edit">
5917 19 Dec 11 nicklas 193       <table class="fullform input100">
1813 24 Jan 06 nicklas 194       <tr>
5917 19 Dec 11 nicklas 195         <th>Name</th>
6312 28 Aug 13 nicklas 196         <td><input class="text required auto-init" data-auto-init="<%=batch == null ? "focus-select" : "focus" %>"
6312 28 Aug 13 nicklas 197           type="text" name="name" 
1813 24 Jan 06 nicklas 198           value="<%=HTML.encodeTags(batch == null ? Values.getString(cc.getPropertyValue("name"), "New array batch") : batch.getName())%>" 
5917 19 Dec 11 nicklas 199           maxlength="<%=ArrayBatch.MAX_NAME_LENGTH%>"></td>
5917 19 Dec 11 nicklas 200         <td></td>
1813 24 Jan 06 nicklas 201       </tr>
1813 24 Jan 06 nicklas 202       <tr>
5917 19 Dec 11 nicklas 203         <th>Array design</th>
1813 24 Jan 06 nicklas 204         <td>
1813 24 Jan 06 nicklas 205           <%
1813 24 Jan 06 nicklas 206           if (batch != null)
1813 24 Jan 06 nicklas 207           {
1813 24 Jan 06 nicklas 208             %>
1813 24 Jan 06 nicklas 209             <%=Base.getEncodedName(currentArrayDesign, !readCurrentArrayDesign)%>
1813 24 Jan 06 nicklas 210             <%
1813 24 Jan 06 nicklas 211           }
1813 24 Jan 06 nicklas 212           else
1813 24 Jan 06 nicklas 213           {
1813 24 Jan 06 nicklas 214             %>
2598 28 Aug 06 nicklas 215             <base:select 
2598 28 Aug 06 nicklas 216               id="arraydesign_id"
2598 28 Aug 06 nicklas 217               clazz="selectionlist required"
2598 28 Aug 06 nicklas 218               required="true"
2598 28 Aug 06 nicklas 219               current="<%=currentArrayDesign%>"
2598 28 Aug 06 nicklas 220               denied="<%=!readCurrentArrayDesign%>"
2598 28 Aug 06 nicklas 221               recent="<%=recentArrayDesigns%>"
5687 09 Aug 11 nicklas 222               defaultitems="<%=defaultArrayDesigns%>"
2598 28 Aug 06 nicklas 223               newitem="true"
2598 28 Aug 06 nicklas 224             />
1813 24 Jan 06 nicklas 225             <%
1813 24 Jan 06 nicklas 226           }
1813 24 Jan 06 nicklas 227           %>
1813 24 Jan 06 nicklas 228         </td>
5917 19 Dec 11 nicklas 229         <td></td>
1813 24 Jan 06 nicklas 230       </tr>
1813 24 Jan 06 nicklas 231       <tr>
5917 19 Dec 11 nicklas 232         <th>Print robot</th>
1813 24 Jan 06 nicklas 233         <td>
2598 28 Aug 06 nicklas 234           <base:select 
2598 28 Aug 06 nicklas 235             id="printrobot_id"
2598 28 Aug 06 nicklas 236             clazz="selectionlist"
2598 28 Aug 06 nicklas 237             required="false"
2598 28 Aug 06 nicklas 238             current="<%=currentPrintRobot%>"
2598 28 Aug 06 nicklas 239             denied="<%=!readCurrentPrintRobot%>"
2598 28 Aug 06 nicklas 240             recent="<%=recentPrintRobots%>"
5687 09 Aug 11 nicklas 241             defaultitems="<%=defaultPrintRobots%>"
2598 28 Aug 06 nicklas 242             newitem="<%=batch == null%>"
2598 28 Aug 06 nicklas 243           />
1813 24 Jan 06 nicklas 244         </td>
5917 19 Dec 11 nicklas 245         <td></td>
1813 24 Jan 06 nicklas 246       </tr>
1813 24 Jan 06 nicklas 247       <tr>
5917 19 Dec 11 nicklas 248         <th>Protocol</th>
1813 24 Jan 06 nicklas 249         <td>
2598 28 Aug 06 nicklas 250           <base:select 
2598 28 Aug 06 nicklas 251             id="protocol_id"
2598 28 Aug 06 nicklas 252             clazz="selectionlist"
2598 28 Aug 06 nicklas 253             required="false"
2598 28 Aug 06 nicklas 254             current="<%=currentProtocol%>"
2598 28 Aug 06 nicklas 255             denied="<%=!readCurrentProtocol%>"
2598 28 Aug 06 nicklas 256             recent="<%=recentProtocols%>"
5687 09 Aug 11 nicklas 257             defaultitems="<%=defaultProtocols%>"
2598 28 Aug 06 nicklas 258             newitem="<%=batch == null%>"
2598 28 Aug 06 nicklas 259           />
1813 24 Jan 06 nicklas 260         </td>
5917 19 Dec 11 nicklas 261         <td></td>
1813 24 Jan 06 nicklas 262       </tr>
5917 19 Dec 11 nicklas 263       <tr class="dynamic">
5917 19 Dec 11 nicklas 264         <th>Description</th>
5917 19 Dec 11 nicklas 265         <td>
6217 14 Dec 12 nicklas 266           <textarea class="text" rows="6" name="description" id="description"
1813 24 Jan 06 nicklas 267             ><%=HTML.encodeTags(batch == null ? cc.getPropertyValue("description") : batch.getDescription())%></textarea>
1813 24 Jan 06 nicklas 268         </td>
5917 19 Dec 11 nicklas 269         <td style="width: 20px;">
6215 13 Dec 12 nicklas 270           <base:zoom textarea="description" title="Description" />
5917 19 Dec 11 nicklas 271         </td>
1813 24 Jan 06 nicklas 272       </tr>
1813 24 Jan 06 nicklas 273       </table>
1813 24 Jan 06 nicklas 274     </t:tab>
1813 24 Jan 06 nicklas 275     
6312 28 Aug 13 nicklas 276     <t:tab id="annotations" title="Annotations &amp; parameters" helpid="annotations.edit">
6254 22 Mar 13 nicklas 277       <jsp:include page="../../common/annotations/annotate_frameset.jsp">
6254 22 Mar 13 nicklas 278         <jsp:param name="item_type" value="<%=itemType.name()%>" />
6254 22 Mar 13 nicklas 279         <jsp:param name="item_id" value="<%=itemId%>" />
6254 22 Mar 13 nicklas 280         <jsp:param name="ID" value="<%=ID%>" />
6254 22 Mar 13 nicklas 281       </jsp:include>
6254 22 Mar 13 nicklas 282     </t:tab>
1813 24 Jan 06 nicklas 283     </t:tabcontrol>
5917 19 Dec 11 nicklas 284     </form>
1813 24 Jan 06 nicklas 285
5917 19 Dec 11 nicklas 286     <div class="legend">
5946 03 Feb 12 nicklas 287       <base:icon image="required.png" />= required information
5917 19 Dec 11 nicklas 288     </div>
5917 19 Dec 11 nicklas 289
5917 19 Dec 11 nicklas 290     <base:buttongroup subclass="dialogbuttons">
6312 28 Aug 13 nicklas 291       <base:button id="btnSave" title="Save" />
6312 28 Aug 13 nicklas 292       <base:button id="close" title="Cancel" />
5917 19 Dec 11 nicklas 293     </base:buttongroup>
1813 24 Jan 06 nicklas 294   </base:body>
1813 24 Jan 06 nicklas 295   </base:page>
1813 24 Jan 06 nicklas 296   <%
1813 24 Jan 06 nicklas 297 }
1813 24 Jan 06 nicklas 298 finally
1813 24 Jan 06 nicklas 299 {
1813 24 Jan 06 nicklas 300   if (dc != null) dc.close();
1813 24 Jan 06 nicklas 301 }
1813 24 Jan 06 nicklas 302 %>