www/biomaterials/events/edit_event.jsp

Code
Comments
Other
Rev Date Author Line
949 18 Jul 05 nicklas 1 <%-- $Id$
949 18 Jul 05 nicklas 2   ------------------------------------------------------------------
3675 16 Aug 07 jari 3   Copyright (C) 2005 Nicklas Nordborg
4889 06 Apr 09 nicklas 4   Copyright (C) 2006 Jari Häkkinen, Nicklas Nordborg
949 18 Jul 05 nicklas 5
2304 22 May 06 jari 6   This file is part of BASE - BioArray Software Environment.
2304 22 May 06 jari 7   Available at http://base.thep.lu.se/
949 18 Jul 05 nicklas 8
949 18 Jul 05 nicklas 9   BASE is free software; you can redistribute it and/or
949 18 Jul 05 nicklas 10   modify it under the terms of the GNU General Public License
4476 05 Sep 08 jari 11   as published by the Free Software Foundation; either version 3
949 18 Jul 05 nicklas 12   of the License, or (at your option) any later version.
949 18 Jul 05 nicklas 13
949 18 Jul 05 nicklas 14   BASE is distributed in the hope that it will be useful,
949 18 Jul 05 nicklas 15   but WITHOUT ANY WARRANTY; without even the implied warranty of
949 18 Jul 05 nicklas 16   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
949 18 Jul 05 nicklas 17   GNU General Public License for more details.
949 18 Jul 05 nicklas 18
949 18 Jul 05 nicklas 19   You should have received a copy of the GNU General Public License
4510 11 Sep 08 jari 20   along with BASE. If not, see <http://www.gnu.org/licenses/>.
949 18 Jul 05 nicklas 21   ------------------------------------------------------------------
949 18 Jul 05 nicklas 22
949 18 Jul 05 nicklas 23   @author Nicklas
949 18 Jul 05 nicklas 24   @version 2.0
949 18 Jul 05 nicklas 25 --%>
5426 24 Sep 10 nicklas 26 <%@ page pageEncoding="UTF-8" session="false"
949 18 Jul 05 nicklas 27   import="net.sf.basedb.core.SessionControl"
949 18 Jul 05 nicklas 28   import="net.sf.basedb.core.DbControl"
949 18 Jul 05 nicklas 29   import="net.sf.basedb.core.Item"
1872 31 Jan 06 nicklas 30   import="net.sf.basedb.core.ItemContext"
949 18 Jul 05 nicklas 31   import="net.sf.basedb.core.Permission"
949 18 Jul 05 nicklas 32   import="net.sf.basedb.core.BioMaterialEvent"
949 18 Jul 05 nicklas 33   import="net.sf.basedb.core.MeasuredBioMaterial"
6993 03 Nov 15 nicklas 34   import="net.sf.basedb.core.Kit"
949 18 Jul 05 nicklas 35   import="net.sf.basedb.core.Protocol"
949 18 Jul 05 nicklas 36   import="net.sf.basedb.core.BaseException"
949 18 Jul 05 nicklas 37   import="net.sf.basedb.core.PermissionDeniedException"
949 18 Jul 05 nicklas 38   import="net.sf.basedb.clients.web.Base"
949 18 Jul 05 nicklas 39   import="net.sf.basedb.clients.web.util.HTML"
2753 20 Oct 06 nicklas 40   import="net.sf.basedb.util.Values"
2942 22 Nov 06 nicklas 41   import="net.sf.basedb.util.formatter.Formatter"
2942 22 Nov 06 nicklas 42   import="net.sf.basedb.clients.web.formatter.FormatterFactory"
2942 22 Nov 06 nicklas 43   import="net.sf.basedb.clients.web.formatter.FormatterSettings"
5492 16 Nov 10 nicklas 44   import="net.sf.basedb.core.plugin.GuiContext"
5492 16 Nov 10 nicklas 45   import="net.sf.basedb.clients.web.extensions.ExtensionsControl"
5492 16 Nov 10 nicklas 46   import="net.sf.basedb.clients.web.extensions.JspContext"
5492 16 Nov 10 nicklas 47   import="net.sf.basedb.clients.web.extensions.edit.EditUtil"
7604 25 Feb 19 nicklas 48   import="net.sf.basedb.clients.web.extensions.tabcontrol.TabAction"
5492 16 Nov 10 nicklas 49   import="net.sf.basedb.util.extensions.ExtensionsInvoker"
949 18 Jul 05 nicklas 50   import="java.util.Date"
2597 25 Aug 06 nicklas 51   import="java.util.List"
949 18 Jul 05 nicklas 52 %>
949 18 Jul 05 nicklas 53 <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
949 18 Jul 05 nicklas 54 <%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %>
6145 21 Sep 12 nicklas 55 <%@ taglib prefix="ext" uri="/WEB-INF/extensions.tld" %>
949 18 Jul 05 nicklas 56 <%
949 18 Jul 05 nicklas 57 final Item itemType = Item.BIOMATERIALEVENT;
1872 31 Jan 06 nicklas 58 final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
1872 31 Jan 06 nicklas 59 final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
1872 31 Jan 06 nicklas 60 final int itemId = cc.getId();
1872 31 Jan 06 nicklas 61 final Item bioMaterialType = Item.valueOf(request.getParameter("biomaterial_type"));
1872 31 Jan 06 nicklas 62 final int bioMaterialId = Values.getInt(request.getParameter("biomaterial_id"));
949 18 Jul 05 nicklas 63 final String ID = sc.getId();
949 18 Jul 05 nicklas 64 final float scale = Base.getScale(sc);
7954 12 May 21 nicklas 65 final DbControl dc = sc.newDbControl(":Edit "+itemType);
949 18 Jul 05 nicklas 66 try
949 18 Jul 05 nicklas 67 {
949 18 Jul 05 nicklas 68   String title = null;
949 18 Jul 05 nicklas 69   BioMaterialEvent event = null;
949 18 Jul 05 nicklas 70   MeasuredBioMaterial bioMaterial = null;
2942 22 Nov 06 nicklas 71   Date eventDate = null;
1872 31 Jan 06 nicklas 72   
1872 31 Jan 06 nicklas 73   boolean readCurrentProtocol = true;
1872 31 Jan 06 nicklas 74   Protocol currentProtocol = null;
6993 03 Nov 15 nicklas 75   boolean readCurrentKit = true;
6993 03 Nov 15 nicklas 76   Kit currentKit = null;
6993 03 Nov 15 nicklas 77   
2597 25 Aug 06 nicklas 78   // Load recently used items
7605 26 Feb 19 nicklas 79   List<Protocol> recentProtocols = cc.getRecent(dc, Item.PROTOCOL);
7605 26 Feb 19 nicklas 80   List<Kit> recentKits = cc.getRecent(dc, Item.KIT);
2597 25 Aug 06 nicklas 81   
1872 31 Jan 06 nicklas 82   if (itemId == 0)
949 18 Jul 05 nicklas 83   {
949 18 Jul 05 nicklas 84     title = "Create event";
1872 31 Jan 06 nicklas 85     cc.removeObject("item");
7605 26 Feb 19 nicklas 86     eventDate = cc.getPropertyObject("eventDate");
6993 03 Nov 15 nicklas 87     if (cc.getPropertyFilter("protocol.name") != null)
6993 03 Nov 15 nicklas 88     {
6993 03 Nov 15 nicklas 89       currentProtocol = Base.getFirstMatching(dc, Protocol.getQuery(), "name", cc.getPropertyFilter("protocol.name"));
6993 03 Nov 15 nicklas 90     }
6993 03 Nov 15 nicklas 91     if (cc.getPropertyFilter("kit.name") != null)
6993 03 Nov 15 nicklas 92     {
6993 03 Nov 15 nicklas 93       currentKit = Base.getFirstMatching(dc, Kit.getQuery(), "name", cc.getPropertyFilter("kit.name"));
6993 03 Nov 15 nicklas 94     }
949 18 Jul 05 nicklas 95   }
949 18 Jul 05 nicklas 96   else
949 18 Jul 05 nicklas 97   {
1872 31 Jan 06 nicklas 98     event = BioMaterialEvent.getById(dc, itemId);
6306 13 Aug 13 nicklas 99     event.checkPermission(Permission.WRITE);
2942 22 Nov 06 nicklas 100     eventDate = event.getEventDate();
949 18 Jul 05 nicklas 101     title = "Edit event";
1872 31 Jan 06 nicklas 102     cc.setObject("item", event);
1872 31 Jan 06 nicklas 103     
1872 31 Jan 06 nicklas 104     try
1872 31 Jan 06 nicklas 105     {
1872 31 Jan 06 nicklas 106       currentProtocol = event.getProtocol();
1872 31 Jan 06 nicklas 107     }
1872 31 Jan 06 nicklas 108     catch (PermissionDeniedException ex)
1872 31 Jan 06 nicklas 109     {
1872 31 Jan 06 nicklas 110       readCurrentProtocol = false;
1872 31 Jan 06 nicklas 111     }
6993 03 Nov 15 nicklas 112     try
6993 03 Nov 15 nicklas 113     {
6993 03 Nov 15 nicklas 114       currentKit = event.getKit();
6993 03 Nov 15 nicklas 115     }
6993 03 Nov 15 nicklas 116     catch (PermissionDeniedException ex)
6993 03 Nov 15 nicklas 117     {
6993 03 Nov 15 nicklas 118       readCurrentKit = false;
6993 03 Nov 15 nicklas 119     }
949 18 Jul 05 nicklas 120   }
6217 14 Dec 12 nicklas 121   
2942 22 Nov 06 nicklas 122   Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc);
2942 22 Nov 06 nicklas 123   String dateFormat = FormatterSettings.getDateFormat(sc);
2942 22 Nov 06 nicklas 124   String jsDateFormat = HTML.javaScriptEncode(dateFormat);
2942 22 Nov 06 nicklas 125   String htmlDateFormat = HTML.encodeTags(dateFormat);
5492 16 Nov 10 nicklas 126   JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.item(itemType), event);
7604 25 Feb 19 nicklas 127   ExtensionsInvoker<TabAction> invoker = EditUtil.useEditExtensions(jspContext);
949 18 Jul 05 nicklas 128   %>
6306 13 Aug 13 nicklas 129   <base:page type="popup" title="<%=title%>" id="edit-page">
6306 13 Aug 13 nicklas 130   <base:head scripts="tabcontrol-2.js,~events.js" styles="tabcontrol.css">
5492 16 Nov 10 nicklas 131     <ext:scripts context="<%=jspContext%>" />
5492 16 Nov 10 nicklas 132     <ext:stylesheets context="<%=jspContext%>" />
949 18 Jul 05 nicklas 133   </base:head>
6306 13 Aug 13 nicklas 134   <base:body>
5913 15 Dec 11 nicklas 135     <h1><%=title%></h1>
6162 10 Oct 12 nicklas 136     <form action="index.jsp?ID=<%=ID%>" method="post" name="event">
1872 31 Jan 06 nicklas 137     <input type="hidden" name="cmd" value="UpdateItem">
949 18 Jul 05 nicklas 138     <input type="hidden" name="biomaterial_type" value="<%=bioMaterialType.name()%>">
949 18 Jul 05 nicklas 139     <input type="hidden" name="biomaterial_id" value="<%=bioMaterialId%>">
949 18 Jul 05 nicklas 140
5913 15 Dec 11 nicklas 141     <t:tabcontrol id="settings" 
5913 15 Dec 11 nicklas 142       subclass="content dialogtabcontrol"
5492 16 Nov 10 nicklas 143       position="bottom" remember="<%=event != null%>"
5492 16 Nov 10 nicklas 144       extensions="<%=invoker%>">
6306 13 Aug 13 nicklas 145     <t:tab id="info" title="Event">
5913 15 Dec 11 nicklas 146       <table class="fullform input100">
949 18 Jul 05 nicklas 147       <tr>
5913 15 Dec 11 nicklas 148         <th>Event date</th>
949 18 Jul 05 nicklas 149         <td>
5913 15 Dec 11 nicklas 150           <table>
949 18 Jul 05 nicklas 151           <tr>
949 18 Jul 05 nicklas 152           <td>
6306 13 Aug 13 nicklas 153             <input class="text auto-init" data-auto-init="<%=event == null ? "focus-select" : "focus" %>"
6306 13 Aug 13 nicklas 154               style="width: 15em;" type="text" name="event_date" id="event_date"
2942 22 Nov 06 nicklas 155               value="<%=HTML.encodeTags(dateFormatter.format(eventDate == null ? new Date() : eventDate))%>" 
5913 15 Dec 11 nicklas 156               maxlength="20" title="Enter date in format: <%=htmlDateFormat%>">
2942 22 Nov 06 nicklas 157             &nbsp;
949 18 Jul 05 nicklas 158           </td>
949 18 Jul 05 nicklas 159           <td>
6216 14 Dec 12 nicklas 160             <base:calendar textarea="event_date" title="Event date" />
949 18 Jul 05 nicklas 161           </td>
949 18 Jul 05 nicklas 162           </tr>
949 18 Jul 05 nicklas 163           </table>
949 18 Jul 05 nicklas 164         </td>
5913 15 Dec 11 nicklas 165         <td></td>
949 18 Jul 05 nicklas 166       </tr>
949 18 Jul 05 nicklas 167       <tr>
5913 15 Dec 11 nicklas 168         <th>Used quantity</th>
6217 14 Dec 12 nicklas 169         <td><input class="text" style="width: 15em;" type="text" name="used_quantity" 
6306 13 Aug 13 nicklas 170           id="usedQuantity"
5913 15 Dec 11 nicklas 171           value="<%=Values.formatNumber(event == null ? null : event.getUsedQuantity(), -1)%>"
6306 13 Aug 13 nicklas 172           maxlength="10"> (µg)</td>
5913 15 Dec 11 nicklas 173         <td></td>
949 18 Jul 05 nicklas 174       </tr>
949 18 Jul 05 nicklas 175       <tr>
5913 15 Dec 11 nicklas 176         <th>Protocol</th>
949 18 Jul 05 nicklas 177         <td>
2597 25 Aug 06 nicklas 178           <base:select 
2597 25 Aug 06 nicklas 179             id="protocol_id"
2597 25 Aug 06 nicklas 180             clazz="selectionlist"
2597 25 Aug 06 nicklas 181             required="false"
2597 25 Aug 06 nicklas 182             current="<%=currentProtocol%>"
2597 25 Aug 06 nicklas 183             denied="<%=!readCurrentProtocol%>"
2597 25 Aug 06 nicklas 184             recent="<%=recentProtocols%>"
2597 25 Aug 06 nicklas 185             newitem="<%=event == null%>"
2597 25 Aug 06 nicklas 186           />
949 18 Jul 05 nicklas 187         </td>
5913 15 Dec 11 nicklas 188         <td></td>
949 18 Jul 05 nicklas 189       </tr>
6993 03 Nov 15 nicklas 190       <tr>
6993 03 Nov 15 nicklas 191         <th>Kit</th>
6993 03 Nov 15 nicklas 192         <td>
6993 03 Nov 15 nicklas 193           <base:select 
6993 03 Nov 15 nicklas 194             id="kit_id"
6993 03 Nov 15 nicklas 195             clazz="selectionlist"
6993 03 Nov 15 nicklas 196             required="false"
6993 03 Nov 15 nicklas 197             current="<%=currentKit%>"
6993 03 Nov 15 nicklas 198             denied="<%=!readCurrentKit%>"
6993 03 Nov 15 nicklas 199             recent="<%=recentKits%>"
6993 03 Nov 15 nicklas 200             newitem="<%=event == null%>"
6993 03 Nov 15 nicklas 201           />
6993 03 Nov 15 nicklas 202         </td>
6993 03 Nov 15 nicklas 203         <td></td>
6993 03 Nov 15 nicklas 204       </tr>
5913 15 Dec 11 nicklas 205       <tr class="dynamic">
5913 15 Dec 11 nicklas 206         <th>Comment</th>
5913 15 Dec 11 nicklas 207         <td>
6217 14 Dec 12 nicklas 208           <textarea class="text" rows="6" name="comment" id="comment"
5913 15 Dec 11 nicklas 209             ><%=HTML.encodeTags(event == null ? cc.getPropertyValue("comment") : event.getComment())%></textarea>
949 18 Jul 05 nicklas 210         </td>
5913 15 Dec 11 nicklas 211         <td style="width: 20px;">
6215 13 Dec 12 nicklas 212           <base:zoom textarea="comment" title="Comment" />
5913 15 Dec 11 nicklas 213         </td>
949 18 Jul 05 nicklas 214       </tr>
949 18 Jul 05 nicklas 215       </table>
949 18 Jul 05 nicklas 216     </t:tab>
949 18 Jul 05 nicklas 217     </t:tabcontrol>
5913 15 Dec 11 nicklas 218     </form>
949 18 Jul 05 nicklas 219
5913 15 Dec 11 nicklas 220     <base:buttongroup subclass="dialogbuttons">
6306 13 Aug 13 nicklas 221       <base:button id="btnSave" title="Save" />
6306 13 Aug 13 nicklas 222       <base:button id="close" title="Cancel" />
5913 15 Dec 11 nicklas 223     </base:buttongroup>
949 18 Jul 05 nicklas 224   </base:body>
949 18 Jul 05 nicklas 225   </base:page>
949 18 Jul 05 nicklas 226   <%
949 18 Jul 05 nicklas 227 }
949 18 Jul 05 nicklas 228 finally
949 18 Jul 05 nicklas 229 {
949 18 Jul 05 nicklas 230   if (dc != null) dc.close();
949 18 Jul 05 nicklas 231 }
949 18 Jul 05 nicklas 232 %>