www/lims/platetypes/eventtypes/edit_eventtype.jsp

Code
Comments
Other
Rev Date Author Line
2305 22 May 06 jari 1 <%-- $Id$
2305 22 May 06 jari 2   ------------------------------------------------------------------
5425 23 Sep 10 nicklas 3   Copyright (C) 2006 Jari Häkkinen, Nicklas Nordborg, Martin Svensson
2305 22 May 06 jari 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/
2305 22 May 06 jari 7
2305 22 May 06 jari 8   BASE is free software; you can redistribute it and/or
2305 22 May 06 jari 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
2305 22 May 06 jari 11   of the License, or (at your option) any later version.
2305 22 May 06 jari 12
2305 22 May 06 jari 13   BASE is distributed in the hope that it will be useful,
2305 22 May 06 jari 14   but WITHOUT ANY WARRANTY; without even the implied warranty of
2305 22 May 06 jari 15   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
2305 22 May 06 jari 16   GNU General Public License for more details.
2305 22 May 06 jari 17
2305 22 May 06 jari 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/>.
2305 22 May 06 jari 20   ------------------------------------------------------------------
2305 22 May 06 jari 21
2305 22 May 06 jari 22
2305 22 May 06 jari 23   @author Nicklas
2305 22 May 06 jari 24   @version 2.0
2305 22 May 06 jari 25 --%>
5426 24 Sep 10 nicklas 26 <%@ page pageEncoding="UTF-8" session="false"
2305 22 May 06 jari 27   import="net.sf.basedb.core.SessionControl"
2305 22 May 06 jari 28   import="net.sf.basedb.core.DbControl"
2305 22 May 06 jari 29   import="net.sf.basedb.core.Item"
2305 22 May 06 jari 30   import="net.sf.basedb.core.ItemContext"
2305 22 May 06 jari 31   import="net.sf.basedb.core.SystemItems"
2305 22 May 06 jari 32   import="net.sf.basedb.core.Permission"
2305 22 May 06 jari 33   import="net.sf.basedb.core.Include"
2305 22 May 06 jari 34   import="net.sf.basedb.core.PlateType"
2305 22 May 06 jari 35   import="net.sf.basedb.core.PlateEventType"
5630 13 May 11 nicklas 36   import="net.sf.basedb.core.ItemSubtype"
2305 22 May 06 jari 37   import="net.sf.basedb.core.ItemQuery"
2305 22 May 06 jari 38   import="net.sf.basedb.core.ItemResultList"
2305 22 May 06 jari 39   import="net.sf.basedb.core.PermissionDeniedException"
2305 22 May 06 jari 40   import="net.sf.basedb.core.BaseException"
2305 22 May 06 jari 41   import="net.sf.basedb.core.query.Orders"
2305 22 May 06 jari 42   import="net.sf.basedb.core.query.Hql"
2305 22 May 06 jari 43   import="net.sf.basedb.clients.web.Base"
2305 22 May 06 jari 44   import="net.sf.basedb.clients.web.util.HTML"
2753 20 Oct 06 nicklas 45   import="net.sf.basedb.util.Values"
5498 17 Nov 10 nicklas 46   import="net.sf.basedb.core.plugin.GuiContext"
5498 17 Nov 10 nicklas 47   import="net.sf.basedb.clients.web.extensions.ExtensionsControl"
5498 17 Nov 10 nicklas 48   import="net.sf.basedb.clients.web.extensions.JspContext"
5498 17 Nov 10 nicklas 49   import="net.sf.basedb.clients.web.extensions.edit.EditUtil"
7604 25 Feb 19 nicklas 50   import="net.sf.basedb.clients.web.extensions.tabcontrol.TabAction"
5498 17 Nov 10 nicklas 51   import="net.sf.basedb.util.extensions.ExtensionsInvoker"
2305 22 May 06 jari 52   import="java.util.List"
2305 22 May 06 jari 53   import="java.util.Set"
2305 22 May 06 jari 54   import="java.util.HashSet"
2305 22 May 06 jari 55   import="java.util.Date"
2305 22 May 06 jari 56 %>
2305 22 May 06 jari 57 <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
2305 22 May 06 jari 58 <%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %>
6146 21 Sep 12 nicklas 59 <%@ taglib prefix="ext" uri="/WEB-INF/extensions.tld" %>
2305 22 May 06 jari 60 <%
2305 22 May 06 jari 61 final Item itemType = Item.PLATEEVENTTYPE;
2305 22 May 06 jari 62 final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
2305 22 May 06 jari 63 final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
2305 22 May 06 jari 64 final int itemId = cc.getId();
2305 22 May 06 jari 65 final int plateTypeId = Values.getInt(request.getParameter("platetype_id"));
2305 22 May 06 jari 66 final String ID = sc.getId();
2305 22 May 06 jari 67 final float scale = Base.getScale(sc);
7954 12 May 21 nicklas 68 final DbControl dc = sc.newDbControl(":Edit "+itemType);
2305 22 May 06 jari 69 try
2305 22 May 06 jari 70 {
2305 22 May 06 jari 71   String title = null;
2305 22 May 06 jari 72   PlateEventType eventType = null;
2305 22 May 06 jari 73   PlateType plateType = null;
2305 22 May 06 jari 74   
5630 13 May 11 nicklas 75   ItemSubtype currentProtocolType = null;
2305 22 May 06 jari 76   boolean readCurrentProtocolType = true;
2446 29 Jun 06 nicklas 77   int maxOrdinal = 0;
2598 28 Aug 06 nicklas 78   
2598 28 Aug 06 nicklas 79   // Load recently used items
7605 26 Feb 19 nicklas 80   List<ItemSubtype> recentProtocolTypes = cc.getRecent(dc, Item.ITEMSUBTYPE);
2305 22 May 06 jari 81
2305 22 May 06 jari 82   if (itemId == 0)
2305 22 May 06 jari 83   {
2305 22 May 06 jari 84     title = "Create event type";
2305 22 May 06 jari 85     cc.removeObject("item");
2305 22 May 06 jari 86     plateType = PlateType.getById(dc, plateTypeId);
2305 22 May 06 jari 87     if (cc.getPropertyFilter("protocolType.name") != null)
2305 22 May 06 jari 88     {
5630 13 May 11 nicklas 89       currentProtocolType = Base.getFirstMatching(dc, ItemSubtype.getQuery(Item.PROTOCOL), "name", cc.getPropertyFilter("protocolType.name"));
2305 22 May 06 jari 90     }
2474 31 Jul 06 nicklas 91     maxOrdinal = (int)plateType.getEventTypes().count(dc);
2305 22 May 06 jari 92   }
2305 22 May 06 jari 93   else
2305 22 May 06 jari 94   {
2305 22 May 06 jari 95     eventType = PlateEventType.getById(dc, itemId);
6306 13 Aug 13 nicklas 96     eventType.checkPermission(Permission.WRITE);
2305 22 May 06 jari 97     plateType = eventType.getPlateType();
2305 22 May 06 jari 98     cc.setObject("item", eventType);
2305 22 May 06 jari 99     title = "Edit event type -- " + HTML.encodeTags(plateType.getName());
2305 22 May 06 jari 100     try
2305 22 May 06 jari 101     {
2305 22 May 06 jari 102       currentProtocolType = eventType.getProtocolType();
2305 22 May 06 jari 103     }
2305 22 May 06 jari 104     catch (PermissionDeniedException ex)
2305 22 May 06 jari 105     {
2305 22 May 06 jari 106       readCurrentProtocolType = false;
2305 22 May 06 jari 107     }
2305 22 May 06 jari 108   }
6217 14 Dec 12 nicklas 109   
5498 17 Nov 10 nicklas 110   JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.item(itemType), eventType);
7604 25 Feb 19 nicklas 111   ExtensionsInvoker<TabAction> invoker = EditUtil.useEditExtensions(jspContext);
2305 22 May 06 jari 112   %>
6306 13 Aug 13 nicklas 113   <base:page type="popup" title="<%=title%>" id="edit-page">
6306 13 Aug 13 nicklas 114   <base:head scripts="tabcontrol-2.js,~eventtypes.js" styles="tabcontrol.css">
5498 17 Nov 10 nicklas 115     <ext:scripts context="<%=jspContext%>" />
5498 17 Nov 10 nicklas 116     <ext:stylesheets context="<%=jspContext%>" />
2305 22 May 06 jari 117   </base:head>
6306 13 Aug 13 nicklas 118   <base:body>
5920 10 Jan 12 nicklas 119     <h1><%=title%> <base:help tabcontrol="settings" /></h1>
5920 10 Jan 12 nicklas 120     
6162 10 Oct 12 nicklas 121     <form action="index.jsp?ID=<%=ID%>" method="post" name="eventtype">
2305 22 May 06 jari 122     <input type="hidden" name="cmd" value="UpdateItem">
2305 22 May 06 jari 123     <input type="hidden" name="platetype_id" value="<%=plateTypeId%>">
2305 22 May 06 jari 124
5920 10 Jan 12 nicklas 125     <t:tabcontrol id="settings"
5920 10 Jan 12 nicklas 126       subclass="content dialogtabcontrol"
5498 17 Nov 10 nicklas 127       position="bottom" remember="<%=eventType != null%>"
5498 17 Nov 10 nicklas 128       extensions="<%=invoker%>">
6306 13 Aug 13 nicklas 129     <t:tab id="info" title="Event type" helpid="plateeventtype.edit">
5920 10 Jan 12 nicklas 130       <table class="fullform input100 smaller">
2305 22 May 06 jari 131       <tr>
5920 10 Jan 12 nicklas 132         <th>Name</th>
6306 13 Aug 13 nicklas 133         <td><input class="text required auto-init" data-auto-init="<%=eventType == null ? "focus-select" : "focus" %>"
6306 13 Aug 13 nicklas 134           type="text" name="name" 
2305 22 May 06 jari 135           value="<%=HTML.encodeTags(eventType == null ? Values.getString(cc.getPropertyValue("name"), "New event type") : eventType.getName())%>" 
5920 10 Jan 12 nicklas 136           maxlength="<%=PlateEventType.MAX_NAME_LENGTH%>"></td>
5920 10 Jan 12 nicklas 137         <td></td>
2305 22 May 06 jari 138       </tr>
2305 22 May 06 jari 139       <tr>
5920 10 Jan 12 nicklas 140         <th>Ordinal</th>
6306 13 Aug 13 nicklas 141         <td><input class="text required" type="text" name="ordinal" id="ordinal"
6306 13 Aug 13 nicklas 142           style="width: 15em;"
2446 29 Jun 06 nicklas 143           value="<%=eventType == null ? Values.getInt(cc.getPropertyValue("ordinal"), maxOrdinal+1) : eventType.getOrdinal()%>" 
6306 13 Aug 13 nicklas 144           maxlength="10"></td>
5920 10 Jan 12 nicklas 145         <td></td>
2305 22 May 06 jari 146       </tr>
2305 22 May 06 jari 147       <tr>
5920 10 Jan 12 nicklas 148         <th>Protocol type</th>
2305 22 May 06 jari 149         <td>
2598 28 Aug 06 nicklas 150           <base:select 
2598 28 Aug 06 nicklas 151             id="protocoltype_id"
2598 28 Aug 06 nicklas 152             clazz="selectionlist"
6306 13 Aug 13 nicklas 153             data-protocol-type-filter="<%=Item.PROTOCOL.getValue()%>"
2598 28 Aug 06 nicklas 154             required="false"
2598 28 Aug 06 nicklas 155             current="<%=currentProtocolType%>"
2598 28 Aug 06 nicklas 156             denied="<%=!readCurrentProtocolType%>"
2598 28 Aug 06 nicklas 157             recent="<%=recentProtocolTypes%>"
2598 28 Aug 06 nicklas 158             newitem="<%=eventType == null%>"
2598 28 Aug 06 nicklas 159           />
2305 22 May 06 jari 160         </td>
5920 10 Jan 12 nicklas 161         <td></td>
2305 22 May 06 jari 162       </tr>
5920 10 Jan 12 nicklas 163       <tr class="dynamic">
5920 10 Jan 12 nicklas 164         <th>Description</th>
5920 10 Jan 12 nicklas 165         <td>
6217 14 Dec 12 nicklas 166           <textarea class="text" rows="4" name="description" id="description"
2305 22 May 06 jari 167             ><%=HTML.encodeTags(eventType == null ? cc.getPropertyValue("description") : eventType.getDescription())%></textarea>
2305 22 May 06 jari 168         </td>
5920 10 Jan 12 nicklas 169         <td style="width: 20px;">
6215 13 Dec 12 nicklas 170           <base:zoom textarea="description" title="Description" />
5920 10 Jan 12 nicklas 171         </td>
2305 22 May 06 jari 172       </tr>
2305 22 May 06 jari 173       </table>
2305 22 May 06 jari 174     </t:tab>
2305 22 May 06 jari 175     </t:tabcontrol>
5920 10 Jan 12 nicklas 176     </form>
5920 10 Jan 12 nicklas 177     
5920 10 Jan 12 nicklas 178     <div class="legend">
5946 03 Feb 12 nicklas 179       <base:icon image="required.png" />= required information
5920 10 Jan 12 nicklas 180     </div>
2305 22 May 06 jari 181
5920 10 Jan 12 nicklas 182     <base:buttongroup subclass="dialogbuttons">
6306 13 Aug 13 nicklas 183       <base:button id="btnSave" title="Save" />
6306 13 Aug 13 nicklas 184       <base:button id="close" title="Cancel" />
5920 10 Jan 12 nicklas 185     </base:buttongroup>
2305 22 May 06 jari 186   </base:body>
2305 22 May 06 jari 187   </base:page>
2305 22 May 06 jari 188   <%
2305 22 May 06 jari 189 }
2305 22 May 06 jari 190 finally
2305 22 May 06 jari 191 {
2305 22 May 06 jari 192   if (dc != null) dc.close();
2305 22 May 06 jari 193 }
2305 22 May 06 jari 194 %>