source: trunk/www/biomaterials/bioplates/view_bioplate.jsp @ 6261

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

References #1729 and #1730. Fixed for all biomaterial view pages.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 16.2 KB
Line 
1<%-- $Id: view_bioplate.jsp 6261 2013-03-27 12:25:00Z nicklas $
2  ------------------------------------------------------------------
3  Copyright (C) 2006 Jari Häkkinen, Nicklas Nordborg, Martin Svensson
4  Copyright (C) 2007 Martin Svensson
5
6  This file is part of BASE - BioArray Software Environment.
7  Available at http://base.thep.lu.se/
8
9  BASE is free software; you can redistribute it and/or
10  modify it under the terms of the GNU General Public License
11  as published by the Free Software Foundation; either version 3
12  of the License, or (at your option) any later version.
13
14  BASE is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  GNU General Public License for more details.
18
19  You should have received a copy of the GNU General Public License
20  along with BASE. If not, see <http://www.gnu.org/licenses/>.
21  ------------------------------------------------------------------
22
23  @author Martin
24  @version 2.10
25--%>
26<%@ page pageEncoding="UTF-8" session="false"
27  import="net.sf.basedb.core.SessionControl"
28  import="net.sf.basedb.core.DbControl"
29  import="net.sf.basedb.core.SystemItems"
30  import="net.sf.basedb.core.Group"
31  import="net.sf.basedb.core.Item"
32  import="net.sf.basedb.core.ItemContext"
33  import="net.sf.basedb.core.Permission"
34  import="net.sf.basedb.core.AnnotationType"
35  import="net.sf.basedb.core.AnnotationSet"
36  import="net.sf.basedb.core.BioPlate"
37  import="net.sf.basedb.core.BioWell"
38  import="net.sf.basedb.core.MeasuredBioMaterial"
39  import="net.sf.basedb.core.PlateGeometry"
40  import="net.sf.basedb.core.User"
41  import="net.sf.basedb.core.ItemQuery"
42  import="net.sf.basedb.core.Include"
43  import="net.sf.basedb.core.ItemResultList"
44  import="net.sf.basedb.core.MultiPermissions"
45  import="net.sf.basedb.core.PermissionDeniedException"
46  import="net.sf.basedb.core.PluginDefinition"
47  import="net.sf.basedb.core.plugin.GuiContext"
48  import="net.sf.basedb.core.plugin.Plugin"
49  import="net.sf.basedb.core.Project"
50  import="net.sf.basedb.core.query.Orders"
51  import="net.sf.basedb.core.query.Hql"
52  import="net.sf.basedb.clients.web.Base"
53  import="net.sf.basedb.clients.web.ChangeHistoryUtil"
54  import="net.sf.basedb.clients.web.PermissionUtil"
55  import="net.sf.basedb.clients.web.util.HTML"
56  import="net.sf.basedb.util.Values"
57  import="net.sf.basedb.util.formatter.Formatter"
58  import="net.sf.basedb.util.formatter.WellCoordinateFormatter"
59  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
60  import="net.sf.basedb.clients.web.extensions.ExtensionsControl"
61  import="net.sf.basedb.clients.web.extensions.JspContext"
62  import="net.sf.basedb.clients.web.extensions.renderer.PrefixSuffixRenderer"
63  import="net.sf.basedb.clients.web.extensions.toolbar.ToolbarUtil"
64  import="net.sf.basedb.util.extensions.ExtensionsInvoker"
65  import="java.util.Collections"
66  import="java.util.Date"
67  import="java.util.Map"
68  import="java.util.Set"
69  import="java.util.List"
70%>
71<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
72<%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %>
73<%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %>
74<%@ taglib prefix="p" uri="/WEB-INF/path.tld" %>
75<%@ taglib prefix="ext" uri="/WEB-INF/extensions.tld" %>
76<%!
77  private static final Item itemType = Item.BIOPLATE;
78  private static final GuiContext guiContext = new GuiContext(itemType, GuiContext.Type.ITEM);
79%>
80<%
81final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
82final String ID = sc.getId();
83final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
84final int itemId = cc.getId();
85final String tab = Values.getStringOrNull(request.getParameter("tab"));
86final float scale = Base.getScale(sc);
87final DbControl dc = sc.newDbControl();
88try
89{
90  Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext);
91
92  String title = null;
93  BioPlate bioplate = BioPlate.getById(dc, itemId);
94  Item bioMaterialType = bioplate.getBioPlateType().getBioMaterialType();
95  PlateGeometry geometry = bioplate.getPlateGeometry();
96 
97  final boolean writePermission = bioplate.hasPermission(Permission.WRITE);
98  final boolean deletePermission = bioplate.hasPermission(Permission.DELETE);
99  final boolean sharePermission = bioplate.hasPermission(Permission.SET_PERMISSION);
100  final boolean setOwnerPermission = bioplate.hasPermission(Permission.SET_OWNER);
101  final boolean isRemoved = bioplate.isRemoved();
102  final boolean isUsed = isRemoved && bioplate.isUsed();
103  final boolean deletePermanentlyPermission = deletePermission && !isUsed;
104  final boolean isOwner = bioplate.isOwner();
105  JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, guiContext, bioplate);
106  ExtensionsInvoker invoker = ToolbarUtil.useExtensions(jspContext);
107  Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc);
108  %>
109  <base:page title="<%=title%>" id="view-page">
110  <base:head scripts="tabcontrol-2.js,table.js,~bioplates.js" 
111    styles="toolbar.css,table.css,headertabcontrol.css,path.css,plate.css">
112    <ext:scripts context="<%=jspContext%>" />
113    <ext:stylesheets context="<%=jspContext%>" />
114  </base:head>
115  <base:body>
116    <p:path><p:pathelement 
117      title="Bioplates" href="<%="index.jsp?ID="+ID%>" /><p:pathelement 
118      title="<%=HTML.encodeTags(bioplate.getName())%>" /></p:path>
119    <div id="page-data" data-item-id="<%=itemId%>"></div>
120   
121    <t:tabcontrol id="main" 
122      subclass="content mastertabcontrol"
123      active="<%=tab%>">
124    <t:tab id="properties" title="Properties">
125      <div>
126      <table class="fullform">
127      <tr>
128        <th class="itemstatus">
129          <base:icon 
130            image="shared.png" 
131            visible="<%=bioplate.isShared()%>"
132            tooltip="This item is shared to other users, groups and/or projects"
133          />
134          <base:icon 
135            id="btnDeletePermanently"
136            image="deleted.png"
137            tooltip="This item has been flagged for deletion. Click to delete it now."
138            enabled="<%=deletePermanentlyPermission %>"
139            visible="<%=isRemoved%>" 
140          />
141          <base:icon
142            id="btnUsingItems"
143            image="used.png" 
144            tooltip="This item is used by other items and can't be permanently deleted. Show the items that are using this one"
145            visible="<%=isRemoved && isUsed%>" />
146        </th>
147        <td style="padding: 0px;">
148          <tbl:toolbar subclass="bottomborder">
149            <tbl:button 
150              id="btnEdit"
151              disabled="<%=!writePermission%>" 
152              image="edit.png" 
153              title="Edit&hellip;" 
154              tooltip="<%=writePermission ? "Edit this bioplate" : "You do not have permission to edit this bioplate"%>" 
155            />
156            <tbl:button 
157              id="btnDelete"
158              disabled="<%=!deletePermission%>" 
159              image="delete.png" 
160              title="Delete"
161              visible="<%=!bioplate.isRemoved()%>"
162              tooltip="<%=deletePermission ? "Delete this bioplate" : "You do not have permission to delete this bioplate"%>" 
163            />
164            <tbl:button 
165              id="btnRestore"
166              disabled="<%=!writePermission%>" 
167              image="restore.png" 
168              title="Restore"
169              visible="<%=bioplate.isRemoved()%>"
170              tooltip="<%=writePermission ? "Restore this bioplate" : "You do not have permission to restore this bioplate"%>" 
171            />
172            <tbl:button 
173              id="btnShare"
174              disabled="<%=!sharePermission%>"
175              image="share.png"
176              title="Share&hellip;" 
177              tooltip="<%=sharePermission ? "Share this bioplate to other user, groups and projects" : "You do not have permission to share this bioplate"%>"
178            />
179            <tbl:button 
180              id="btnSetOwner"
181              disabled="<%=!setOwnerPermission%>"
182              image="take_ownership.png"
183              title="Set owner&hellip;"
184              tooltip="<%=setOwnerPermission ? "Change owner of this item" : "You do not have permission to change ownership of this item"%>"
185            />
186            <tbl:button 
187              id="btnMoveBioMaterial"
188              image="move_to_plate.png" 
189              title="Move biomaterial&hellip;" 
190              tooltip="Move biomaterial on this plate to another plate" 
191            />
192            <tbl:button 
193              id="btnCreateChildBioPlate"
194              image="add.png" 
195              title="<%="Create child bioplate" + (bioMaterialType == Item.EXTRACT ? "/bioassay" : "") +"&hellip;"%>" 
196              tooltip="Create one or more child biomaterial plates" 
197              visible="<%=bioMaterialType != null%>"
198            />
199            <tbl:button 
200              id="btnImport"
201              image="import.png" 
202              data-plugin-type="IMPORT" 
203              title="Import&hellip;" 
204              tooltip="Import data" 
205              visible="<%=pluginCount.containsKey(Plugin.MainType.IMPORT)%>"
206            />
207            <tbl:button 
208              id="btnExport"
209              image="export.png"
210              data-plugin-type="EXPORT" 
211              title="Export&hellip;" 
212              tooltip="Export data" 
213              visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>"
214            />
215            <tbl:button 
216              id="btnRunPlugin"
217              image="runplugin.png" 
218              data-plugin-type="OTHER" 
219              title="Run plugin&hellip;" 
220              tooltip="Run a plugin" 
221              visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>"
222            />
223            <ext:render extensions="<%=invoker%>" context="<%=jspContext%>" 
224              wrapper="<%=new PrefixSuffixRenderer(jspContext, "<td>", "</td>") %>"/>
225            <tbl:button
226              image="help.png"
227              subclass="auto-init"
228              data-auto-init="help"
229              data-help-id="plate.view.properties"
230              title="Help&hellip;"
231              tooltip="Get help about this page"
232            />
233          </tbl:toolbar>
234        </td>
235      </tr>
236    </table>
237    <table style="width: 100%; height: <%=geometry.getRows()*35+20 %>px;" class="bottomborder">
238    <tr style="vertical-align: top;">
239      <td style="width: 50%; height: 100%;">
240      <table class="fullform" >
241      <tr>
242        <th>Name</th>
243        <td><%=HTML.encodeTags(bioplate.getName())%></td>
244      </tr>
245      <tr>
246        <th>Barcode</th>
247        <td><%=HTML.encodeTags(bioplate.getBarcode())%></td>
248      </tr>
249      <tr>
250        <th>Created</th>
251        <td><%=dateFormatter.format(bioplate.getEventDate())%></td>
252      </tr>
253      <tr>
254        <th>Registered</th>
255        <td><%=dateFormatter.format(bioplate.getEntryDate())%></td>
256      </tr>
257      <tr>
258        <th>Destroyed</th>
259        <td><%=bioplate.isDestroyed() ? "yes" : "no"%></td>
260      </tr>
261      <tr>
262        <th>Bioplate type</th>
263        <td><base:propertyvalue item="<%=bioplate%>" property="bioPlateType" /></td>
264      </tr>
265      <tr>
266        <th>Geometry</th>
267        <td><base:propertyvalue item="<%=bioplate%>" property="plateGeometry" /></td>
268      </tr>
269      <tr>
270        <th>Free (total) wells</th>
271        <td><%=bioplate.getFreeWells()%> (<%=bioplate.getTotalWells()%>)</td>
272      </tr>
273      <tr>
274        <th>Storage location</th>
275        <td><base:propertyvalue item="<%=bioplate%>" property="freezer" /></td>
276      </tr>
277      <tr>
278        <th class="subprompt"></th>
279        <td>
280          <b>Section</b>: <%=HTML.encodeTags(Values.getString(bioplate.getSection(), "-")) %>;
281          <b>Tray</b>: <%=HTML.encodeTags(Values.getString(bioplate.getTray(), "-")) %>;
282          <b>Position</b>: <%=HTML.encodeTags(Values.getString(bioplate.getPosition(), "-")) %>
283        </td>
284      </tr>
285      <tr>
286        <th>Owner</th>
287        <td><base:propertyvalue item="<%=bioplate%>" property="owner" /></td>
288      </tr>
289      <tr>
290        <th>Permissions</th>
291        <td><%=PermissionUtil.getFullPermissionNames(bioplate)%></td>
292      </tr>
293      <tr class="dynamic">
294        <th>Description</th>
295        <td><%=HTML.niceFormat(bioplate.getDescription())%></td>
296      </tr>
297      </table>
298      </td>
299      <td style="width: 50%; padding: 1em;" id="bioplate">
300        <div class="postit" id="wellInfo" style="display:none; width: 20em; min-height: 3em;"></div>
301        <table class="plate">
302        <%
303        int columns = geometry.getColumns();
304        int rows = geometry.getRows();
305        WellCoordinateFormatter rowF = new WellCoordinateFormatter(true);
306        WellCoordinateFormatter colF = new WellCoordinateFormatter(false);
307        %>
308        <tr><td></td>
309        <%
310        for (int c = 0; c < columns; ++c)
311        {
312          %>
313          <td class="columnheader"><%=colF.format(c)%></td>
314          <%
315        }
316        %>
317        </tr>
318        <%
319        for (int r = 0; r < rows; ++r)
320        {
321          String row = rowF.format(r);
322          %>
323          <tr><td class="rowheader"><%=row%></td>
324          <%
325          for (int c = 0; c < columns; ++c)
326          {
327            BioWell well = bioplate.getBioWell(r, c);
328            if (well == null) continue;
329            boolean isEmpty = well.isEmpty();
330            boolean hasBeenUsed = well.hasBeenUsed();
331            boolean canAddBioMaterial = well.canAddBioMaterial();
332            boolean canClearBioMaterial = well.canClearBioMaterial();
333            boolean usePermission = well.hasPermission(Permission.USE);
334           
335            boolean deniedBioMaterial = false;
336            boolean allowEdit = false;
337            boolean showInfo = false;
338           
339            String cls = "well auto-init";
340            String tooltip = "";
341            if (isEmpty)
342            {
343              cls += " empty";
344              if (usePermission && canAddBioMaterial)
345              {
346                // The used is allowed to add biomaterial to the empty well
347                cls += " editable";
348                allowEdit = true;
349                tooltip = "Add biomaterial to this well";
350              }
351              else if (hasBeenUsed) 
352              {
353                // The well has been used and it is not allowed to add biomaterial
354                cls += " wasused";
355                showInfo = true;
356                tooltip = "This well has already been used";
357              }
358              else
359              {
360                // The user doesn't have permission to add biomaterial
361                cls += " locked";
362                tooltip = "You are not allowed to add biomaterial to this well";
363              }
364            }
365            else
366            {
367              cls += " used";
368              try
369              {
370                MeasuredBioMaterial bioMaterial = well.getBioMaterial();
371                showInfo = true;
372                if (usePermission && canClearBioMaterial && bioMaterial.hasPermission(Permission.WRITE))
373                {
374                  // The user is allowed to replace/remove the biomaterial in the well
375                  cls += " editable";
376                  allowEdit = true;
377                  if (canAddBioMaterial)
378                  {
379                    // Replace and/or remove
380                    tooltip = "Change biomaterial in this well";
381                  }
382                  else
383                  {
384                    // Remove only
385                    tooltip = "Remove the biomaterial from this well";
386                  }
387                }
388                else
389                {
390                  cls += " locked";
391                  tooltip = "This well is locked for modifications";
392                }
393              }
394              catch (PermissionDeniedException ex)
395              {
396                cls += " denied";
397                tooltip = "Access denied";
398              }
399            }
400            %>
401            <td class="<%=cls%>" 
402              id="well.<%=well.getId()%>"
403              data-auto-init="well"
404              data-allow-edit="<%=allowEdit ? 1 : 0 %>"
405              data-show-info="<%=showInfo ? 1 : 0 %>"
406              data-item-id="<%=well.getId()%>"
407              data-coordinate="<%=well.getCoordinate()%>"
408              title="<%=tooltip%>"></td>
409            <%
410          }
411          %>
412          </tr>
413          <%
414        }
415        %>
416        </table>
417      </td>
418    </tr>
419    </table>
420    </div>
421     
422      <jsp:include page="../../common/anytoany/list_anytoany.jsp">
423        <jsp:param name="ID" value="<%=ID%>" />
424        <jsp:param name="item_type" value="<%=itemType.name()%>" />
425        <jsp:param name="item_id" value="<%=itemId%>" />
426        <jsp:param name="title" value="Other items related to this bioplate" />
427      </jsp:include>
428      <jsp:include page="../../common/share/list_share.jsp">
429        <jsp:param name="ID" value="<%=ID%>" />
430        <jsp:param name="item_type" value="<%=itemType.name()%>" />
431        <jsp:param name="item_id" value="<%=itemId%>" />
432        <jsp:param name="title" value="Shared to" />
433      </jsp:include>
434      </t:tab>
435     
436      <t:tab id="annotations" title="Annotations" 
437        tooltip="View annotation values" clazz="white">
438        <jsp:include page="../../common/annotations/list_frameset.jsp">
439          <jsp:param name="item_type" value="<%=itemType.name()%>" />
440          <jsp:param name="item_id" value="<%=itemId%>" />
441          <jsp:param name="ID" value="<%=ID%>" />
442        </jsp:include>
443      </t:tab>
444
445      <t:tab id="wells" title="Wells" />
446      <t:tab id="events" title="Plate events" />
447      <t:tab id="overview" title="Overview" 
448        tooltip="Display a tree overview of related items">
449        <jsp:include page="../../common/overview/overview.jsp">
450          <jsp:param name="item_type" value="<%=itemType.name()%>" />
451          <jsp:param name="item_id" value="<%=itemId%>" />
452          <jsp:param name="ID" value="<%=ID%>" />
453        </jsp:include>
454      </t:tab>     
455      <t:tab id="history" title="Change history" 
456        tooltip="Displays a log of all modifications made to this item"
457        visible="<%=ChangeHistoryUtil.showChangeHistoryTab(sc)%>">
458        <jsp:include page="../../common/history/frameset.jsp">
459          <jsp:param name="item_type" value="<%=itemType.name()%>" />
460          <jsp:param name="item_id" value="<%=itemId%>" />
461          <jsp:param name="ID" value="<%=ID%>" />
462        </jsp:include>
463      </t:tab>
464    </t:tabcontrol>
465   
466  </base:body>
467  </base:page>
468  <%
469}
470finally
471{
472  if (dc != null) dc.close();
473}
474%>
Note: See TracBrowser for help on using the repository browser.