source: trunk/www/biomaterials/bioplates/wells/edit_biowell.jsp @ 5709

Last change on this file since 5709 was 5709, checked in by Nicklas Nordborg, 10 years ago

References #1597: Subtypes of items

Added link to item subtype from bioplate type which makes it possible to restrict/filter on the biomaterial subtype when selecting biomaterial for a plate. The "restriction" is in the gui only and is not checked by the core since it is possible to change the subtype of a biomaterial after it has been placed on a plate.

As a result of this the "Labeled extract reaction plate" is brought back to life again.

Also discovered that the bioplate event wizards should probably be able to utilize subtype information for some improvements. So there are still some things to fix before this ticket can be closed.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 8.3 KB
Line 
1<%-- $Id: edit_biowell.jsp 5709 2011-08-26 11:26:09Z nicklas $
2  ------------------------------------------------------------------
3  Copyright (C) 2009 Martin Svensson
4
5  This file is part of BASE - BioArray Software Environment.
6  Available at http://base.thep.lu.se/
7
8  BASE is free software; you can redistribute it and/or
9  modify it under the terms of the GNU General Public License
10  as published by the Free Software Foundation; either version 3
11  of the License, or (at your option) any later version.
12
13  BASE is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  GNU General Public License for more details.
17
18  You should have received a copy of the GNU General Public License
19  along with BASE. If not, see <http://www.gnu.org/licenses/>.
20  ------------------------------------------------------------------
21  @author Martin
22  @version 2.10
23--%>
24<%@ page pageEncoding="UTF-8" session="false"
25  import="net.sf.basedb.core.SessionControl"
26  import="net.sf.basedb.core.DbControl"
27  import="net.sf.basedb.core.Item"
28  import="net.sf.basedb.core.ItemContext"
29  import="net.sf.basedb.core.Permission"
30  import="net.sf.basedb.core.BioPlate"
31  import="net.sf.basedb.core.BioPlateType"
32  import="net.sf.basedb.core.BioWell"
33  import="net.sf.basedb.core.ItemSubtype"
34  import="net.sf.basedb.core.MeasuredBioMaterial"
35  import="net.sf.basedb.core.Sample"
36  import="net.sf.basedb.core.Extract"
37  import="net.sf.basedb.core.PermissionDeniedException"
38  import="net.sf.basedb.core.BaseException"
39  import="net.sf.basedb.clients.web.Base"
40  import="net.sf.basedb.clients.web.util.HTML"
41  import="net.sf.basedb.util.Values"
42  import="net.sf.basedb.util.formatter.WellCoordinateFormatter"
43  import="net.sf.basedb.core.plugin.GuiContext"
44  import="net.sf.basedb.clients.web.extensions.ExtensionsControl"
45  import="net.sf.basedb.clients.web.extensions.JspContext"
46  import="net.sf.basedb.clients.web.extensions.edit.EditUtil"
47  import="net.sf.basedb.util.extensions.ExtensionsInvoker"
48  import="java.util.List"
49%>
50<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
51<%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %>
52<%
53final Item itemType = Item.BIOWELL;
54final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
55final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
56final int itemId = cc.getId();
57final String ID = sc.getId();
58final float scale = Base.getScale(sc);
59final DbControl dc = sc.newDbControl();
60try
61{
62  String title = null;
63  BioWell bioWell = BioWell.getById(dc, itemId);
64  BioPlate bioPlate = bioWell.getPlate();
65  BioPlateType bioPlateType = bioPlate.getBioPlateType();
66  Item bioMaterialType = bioPlateType.getBioMaterialType();
67  ItemSubtype bioMaterialSubType = bioPlateType.getItemSubtype();
68 
69  bioWell.checkPermission(Permission.WRITE);
70  WellCoordinateFormatter rowFormatter = new WellCoordinateFormatter(true);
71  WellCoordinateFormatter columnFormatter = new WellCoordinateFormatter(false);
72 
73  title = "Edit biowell -- " + rowFormatter.format(bioWell.getRow()) + columnFormatter.format(bioWell.getColumn()) + " on " + HTML.encodeTags(bioPlate.getName());
74
75  final String clazz = "class=\"text\"";
76  final String requiredClazz = "class=\"text required\"";
77 
78  boolean readCurrentBioMaterial = true;
79  MeasuredBioMaterial currentBioMaterial = null;
80  try
81  {
82    currentBioMaterial = bioWell.getBioMaterial();
83  }
84  catch (PermissionDeniedException ex)
85  {
86    readCurrentBioMaterial = false;
87  }
88  boolean canAddBioMaterial = bioWell.canAddBioMaterial();
89
90  cc.setObject("item", bioWell);
91  JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.item(itemType), bioWell);
92  ExtensionsInvoker invoker = EditUtil.useEditExtensions(jspContext);
93  %>
94  <base:page type="popup" title="<%=title%>">
95  <base:head scripts="tabcontrol.js" styles="tabcontrol.css">
96    <ext:scripts context="<%=jspContext%>" />
97    <ext:stylesheets context="<%=jspContext%>" />
98    <script language="JavaScript">
99    // Validate the "BioWell" tab
100    function validateBioWell()
101    {
102      return true;
103    }
104
105    // Submit the form
106    function saveSettings()
107    {
108      var frm = document.forms['biowell'];
109      if (TabControl.validateActiveTab('settings'))
110      {
111        frm.biomaterial_type.disabled = false;
112        frm.submit();
113      }
114    }
115
116    // Biomaterial selection
117    function selectBioMaterialOnClick()
118    {
119      var frm = document.forms['biowell'];
120      var typelist = frm.biomaterial_type;     
121      if (typelist.selectedIndex == 0)
122      {
123        alert("You must first select what type of biomaterial");
124        return;
125      }     
126      var type = typelist[typelist.selectedIndex].value;
127      var folder = type.toLowerCase();   
128      var controller = Main.getController(type);
129      var url = getRoot() + controller.url + '?ID=<%=ID%>&cmd=UpdateContext&mode=selectone&callback=setBioMaterialCallback';
130      if (frm.biomaterial_id.length > 1)
131      {
132        var id = Math.abs(parseInt(frm.biomaterial_id[1].value));       
133        url += '&item_id='+id;
134      }
135      url += '&resetTemporary=1&tmpfilter:STRING:bioWell='+escape('=');
136      <%
137      if (bioMaterialSubType != null)
138      {
139        %>
140        url += '&tmpfilter:INT:itemSubtype=<%=bioMaterialSubType.getId()%>';
141        <%
142      }
143      %>
144      Main.openPopup(url, 'Select'+type, 1000, 700);
145    }
146    function setBioMaterialCallback(id, name)
147    {
148      var frm = document.forms['biowell'];
149      var list = frm.biomaterial_id;
150      if (list.length < 2 || list[1].value == '0') // >
151      {
152        Forms.addListOption(list, 1, new Option());
153      }
154      list[1].value = id;
155      list[1].text = name;
156      list.selectedIndex = 1;
157    }
158    function bioMaterialTypeOnChange()
159    {
160      var frm = document.forms['biowell'];
161      var list = frm.biomaterial_id;
162      list.selectedIndex = 0;
163      list.remove(1);
164    }
165    </script>
166  </base:head>
167  <base:body>
168    <p>
169    <form action="index.jsp?ID=<%=ID%>" method="post" name="biowell" onsubmit="return false;">
170    <input type="hidden" name="cmd" value="UpdateItem">
171
172    <h3 class="docked"><%=title%> <base:help tabcontrol="settings" /></h3>
173    <t:tabcontrol id="settings" contentstyle="<%="height: "+(int)(scale*160)+"px;"%>" 
174      position="bottom" 
175      extensions="<%=invoker%>">
176    <t:tab id="info" title="Biowell" validate="validateBioWell()" helpid="biowell.edit">
177      <table class="form" cellspacing=0>
178      <tr>
179        <td class="prompt">Bioplate</td>
180        <td><%=HTML.encodeTags(bioPlate.getName())%></td>
181      </tr>
182      <tr>
183        <td class="prompt">Well location</td>
184        <td><%=rowFormatter.format(bioWell.getRow())%><%=columnFormatter.format(bioWell.getColumn())%></td>
185      </tr>
186      <tr>
187        <td class="prompt">Biomaterial type</td>
188        <td>         
189          <select name="biomaterial_type" onchange="bioMaterialTypeOnChange()" <%=bioMaterialType != null ? "disabled": ""%>>
190            <%
191            if (!readCurrentBioMaterial)
192            {
193              %>
194              <option value="-1">- denied -
195              <%
196            }
197            else
198            {
199              Item currentBmType = currentBioMaterial == null ? null : currentBioMaterial.getType();
200              String subtype = bioMaterialSubType != null ? " ("+HTML.encodeTags(bioMaterialSubType.getName()) + ")" : "";
201              %>
202              <option value="0">- none -
203              <option value="<%=Item.SAMPLE.name()%>" 
204                <%=currentBmType == Item.SAMPLE || bioMaterialType == Item.SAMPLE ? "selected" : ""%>>Sample<%=subtype %>
205              <option value="<%=Item.EXTRACT.name()%>" 
206                <%=currentBmType == Item.EXTRACT || bioMaterialType == Item.EXTRACT ? "selected" : ""%>>Extract<%=subtype %>
207              <%
208            }
209            %>
210          </select>
211        </td>
212      </tr>
213      <tr>
214        <td class="prompt">Biomaterial</td>
215        <td>
216          <base:select 
217            id="biomaterial_id"
218            clazz="selectionlist"
219            required="false"
220            current="<%=currentBioMaterial%>"
221            denied="<%=!readCurrentBioMaterial%>"
222            recent="<%=null%>"
223            newitem="<%=false%>"
224            onselect="<%=canAddBioMaterial ? "selectBioMaterialOnClick()" : null%>"
225          />
226        </td>
227      </tr>
228      <%
229      if (!canAddBioMaterial && currentBioMaterial != null)
230      {
231        %>
232        <tr>
233          <td></td>
234          <td>
235            <base:note type="warning" style="background: #ffffd8;">
236              New biomaterial can't be added to this well if
237              '<%=HTML.encodeTags(currentBioMaterial.getName())%>' is removed.
238            </base:note>
239          </td>
240        </tr>
241        <%
242      }
243      %>
244      </table>
245    </t:tab>
246    </t:tabcontrol>
247    <table align="center">
248    <tr>
249      <td width="50%"><base:button onclick="saveSettings()" title="Save" /></td>
250      <td width="50%"><base:button onclick="window.close()" title="Cancel" /></td>
251    </tr>
252    </table>
253    </form>
254  </base:body>
255  </base:page>
256  <%
257}
258finally
259{
260  if (dc != null) dc.close();
261}
262%>
Note: See TracBrowser for help on using the repository browser.