source: trunk/www/biomaterials/extracts/view_extract.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 Date Id
File size: 19.3 KB
Line 
1<%-- $Id: view_extract.jsp 6261 2013-03-27 12:25:00Z nicklas $
2  ------------------------------------------------------------------
3  Copyright (C) 2006 Johan Enell, 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 Nicklas
24  @version 2.0
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.CommonItem"
33  import="net.sf.basedb.core.ItemContext"
34  import="net.sf.basedb.core.ItemProxy"
35  import="net.sf.basedb.core.Permission"
36  import="net.sf.basedb.core.Extract"
37  import="net.sf.basedb.core.PhysicalBioAssay"
38  import="net.sf.basedb.core.Sample"
39  import="net.sf.basedb.core.BioMaterial"
40  import="net.sf.basedb.core.BioMaterialEvent"
41  import="net.sf.basedb.core.BioMaterialEventSource"
42  import="net.sf.basedb.core.BioWell"
43  import="net.sf.basedb.core.MultiPermissions"
44  import="net.sf.basedb.core.ItemSubtype"
45  import="net.sf.basedb.core.Protocol"
46  import="net.sf.basedb.core.Project"
47  import="net.sf.basedb.core.User"
48  import="net.sf.basedb.core.ItemQuery"
49  import="net.sf.basedb.core.ItemResultList"
50  import="net.sf.basedb.core.SpecialQuery"
51  import="net.sf.basedb.core.Include"
52  import="net.sf.basedb.core.query.ResultList"
53  import="net.sf.basedb.core.query.Orders"
54  import="net.sf.basedb.core.query.Hql"
55  import="net.sf.basedb.core.query.Restrictions"
56  import="net.sf.basedb.core.query.Expressions"
57  import="net.sf.basedb.core.PermissionDeniedException"
58  import="net.sf.basedb.core.PluginDefinition"
59  import="net.sf.basedb.core.plugin.GuiContext"
60  import="net.sf.basedb.core.plugin.Plugin"
61  import="net.sf.basedb.core.Type"
62  import="net.sf.basedb.clients.web.Base"
63  import="net.sf.basedb.clients.web.ChangeHistoryUtil"
64  import="net.sf.basedb.clients.web.PermissionUtil"
65  import="net.sf.basedb.clients.web.util.HTML"
66  import="net.sf.basedb.util.Values"
67  import="net.sf.basedb.util.formatter.Formatter"
68  import="net.sf.basedb.util.formatter.WellCoordinateFormatter"
69  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
70  import="net.sf.basedb.clients.web.extensions.ExtensionsControl"
71  import="net.sf.basedb.clients.web.extensions.JspContext"
72  import="net.sf.basedb.clients.web.extensions.renderer.PrefixSuffixRenderer"
73  import="net.sf.basedb.clients.web.extensions.toolbar.ToolbarUtil"
74  import="net.sf.basedb.util.extensions.ExtensionsInvoker"
75  import="java.util.ArrayList"
76  import="java.util.Collections"
77  import="java.util.Date"
78  import="java.util.Map"
79  import="java.util.Set"
80  import="java.util.List"
81%>
82<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
83<%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %>
84<%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %>
85<%@ taglib prefix="p" uri="/WEB-INF/path.tld" %>
86<%@ taglib prefix="ext" uri="/WEB-INF/extensions.tld" %>
87<%!
88  private static final Item itemType = Item.EXTRACT;
89  private static final GuiContext guiContext = new GuiContext(itemType, GuiContext.Type.ITEM);
90%>
91<%
92final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
93final String ID = sc.getId();
94final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
95final int itemId = cc.getId();
96final String tab = Values.getStringOrNull(request.getParameter("tab"));
97final float scale = Base.getScale(sc);
98final DbControl dc = sc.newDbControl();
99try
100{
101  Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc);
102  Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext);
103 
104  WellCoordinateFormatter rowFormatter = new WellCoordinateFormatter(true);
105  WellCoordinateFormatter columnFormatter = new WellCoordinateFormatter(false);
106
107  String title = null;
108  Extract extract = Extract.getById(dc, itemId);
109  BioMaterialEvent creationEvent = extract.getCreationEvent();
110 
111  final boolean writePermission = extract.hasPermission(Permission.WRITE);
112  final boolean deletePermission = extract.hasPermission(Permission.DELETE);
113  final boolean sharePermission = extract.hasPermission(Permission.SET_PERMISSION);
114  final boolean usePermission = extract.hasPermission(Permission.USE);
115  final boolean setOwnerPermission = extract.hasPermission(Permission.SET_OWNER);
116  final boolean isRemoved = extract.isRemoved();
117  final boolean isUsed = isRemoved && extract.isUsed();
118  final boolean deletePermanentlyPermission = deletePermission && !isUsed;
119  final boolean isOwner = extract.isOwner(); 
120  JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, guiContext, extract);
121  ExtensionsInvoker invoker = ToolbarUtil.useExtensions(jspContext);
122  %>
123  <base:page title="<%=title%>" id="view-page">
124  <base:head scripts="table.js,tabcontrol-2.js,~extracts.js" styles="table.css,toolbar.css,headertabcontrol.css,path.css">
125    <ext:scripts context="<%=jspContext%>" />
126    <ext:stylesheets context="<%=jspContext%>" />
127  </base:head>
128  <base:body>
129    <p:path><p:pathelement 
130      title="Extracts" href="<%="index.jsp?ID="+ID%>" /><p:pathelement
131      title="<%=HTML.encodeTags(extract.getName())%>" /></p:path>
132    <div id="page-data" data-item-id="<%=itemId%>"></div>
133   
134    <t:tabcontrol id="main" subclass="content mastertabcontrol" active="<%=tab%>">
135    <t:tab id="properties" title="Properties">
136      <div>
137      <table class="fullform bottomborder">
138      <tr>
139        <th class="itemstatus">
140          <base:icon 
141            image="shared.png" 
142            visible="<%=extract.isShared()%>"
143            tooltip="This item is shared to other users, groups and/or projects"
144          />
145          <base:icon 
146            id="btnDeletePermanently"
147            image="deleted.png"
148            tooltip="This item has been flagged for deletion. Click to delete it now."
149            enabled="<%=deletePermanentlyPermission %>"
150            visible="<%=isRemoved%>" 
151          />
152          <base:icon 
153            id="btnUsingItems"
154            image="used.png" 
155            tooltip="This item is used by other items and can't be permanently deleted. Show the items that are using this one"
156            visible="<%=isRemoved && isUsed%>" />
157        </th>
158        <td style="padding: 0px;">
159          <tbl:toolbar subclass="bottomborder">
160            <tbl:button 
161              id="btnEdit"
162              disabled="<%=!writePermission%>" 
163              image="edit.png" 
164              title="Edit&hellip;" 
165              tooltip="<%=writePermission ? "Edit this extract" : "You do not have permission to edit this extract"%>" 
166            />
167            <tbl:button 
168              id="btnDelete"
169              disabled="<%=!deletePermission%>" 
170              image="delete.png" 
171              title="Delete"
172              visible="<%=!extract.isRemoved()%>"
173              tooltip="<%=deletePermission ? "Delete this extract" : "You do not have permission to delete this extract"%>" 
174            />
175            <tbl:button 
176              id="btnRestore"
177              disabled="<%=!writePermission%>" 
178              image="restore.png" 
179              title="Restore"
180              visible="<%=extract.isRemoved()%>"
181              tooltip="<%=writePermission ? "Restore this extract" : "You do not have permission to restore this extract"%>" 
182            />
183            <tbl:button 
184              id="btnShare"
185              disabled="<%=!sharePermission%>"
186              image="share.png"
187              title="Share&hellip;" 
188              tooltip="<%=sharePermission ? "Share this extract to other user, groups and projects" : "You do not have permission to share this extract"%>"
189            />
190            <tbl:button 
191              id="btnSetOwner"
192              disabled="<%=!setOwnerPermission%>"
193              image="take_ownership.png"
194              title="Set owner&hellip;"
195              tooltip="<%=setOwnerPermission ? "Change owner of this item" : "You do not have permission to change ownership of this item"%>"
196            />
197            <tbl:button
198              id="btnNewExtract"
199              image="add.png"
200              title="New child extract&hellip;"
201              tooltip="Create a new child extract from this extract"
202              visible="<%=sc.hasPermission(Permission.CREATE, Item.EXTRACT) && usePermission%>"
203            />
204            <tbl:button
205              id="btnNewPhysicalBioAssay"
206              image="add.png"
207              title="New physical bioassay&hellip;"
208              tooltip="Create a new physical bioassay from this extract"
209              visible="<%=sc.hasPermission(Permission.CREATE, Item.PHYSICALBIOASSAY) && usePermission%>"
210            />
211            <tbl:button
212              id="btnNewRawBioAssay"
213              image="add.png"
214              title="New raw bioassay&hellip;"
215              tooltip="Create a new raw bioassay from this extract"
216              visible="<%=sc.hasPermission(Permission.CREATE, Item.RAWBIOASSAY) && usePermission%>"
217            />
218            <tbl:button 
219              id="btnImport"
220              image="import.png" 
221              data-plugin-type="IMPORT" 
222              title="Import&hellip;" 
223              tooltip="Import data" 
224              visible="<%=pluginCount.containsKey(Plugin.MainType.IMPORT)%>"
225            />
226            <tbl:button 
227              id="btnExport"
228              image="export.png"
229              data-plugin-type="EXPORT" 
230              title="Export&hellip;" 
231              tooltip="Export data" 
232              visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>"
233            />
234            <tbl:button 
235              id="btnRunPlugin"
236              image="runplugin.png" 
237              data-plugin-type="OTHER" 
238              title="Run plugin&hellip;" 
239              tooltip="Run a plugin" 
240              visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>"
241            />
242            <ext:render extensions="<%=invoker%>" context="<%=jspContext%>" 
243              wrapper="<%=new PrefixSuffixRenderer(jspContext, "<td>", "</td>") %>"/>
244            <tbl:button
245              image="help.png"
246              subclass="auto-init"
247              data-auto-init="help"
248              data-help-id="extract.view.properties"
249              title="Help&hellip;"
250              tooltip="Get help about this page"
251            />
252            </tbl:toolbar>
253          </td>
254        </tr>
255        <tr>
256          <th>Name</th>
257          <td><%=HTML.encodeTags(extract.getName())%></td>
258        </tr>
259        <tr>
260          <th>Type</th>
261          <td><base:propertyvalue item="<%=extract%>" property="itemSubtype" /></td>
262        </tr>
263        <tr>
264          <th>External ID</th>
265          <td><%=HTML.encodeTags(extract.getExternalId())%></td>
266        </tr>
267        <tr>
268          <th>Created</th>
269          <td><%=dateFormatter.format(creationEvent.getEventDate())%></td>
270        </tr>
271        <tr>
272          <th>Registered</th>
273          <td><%=dateFormatter.format(creationEvent.getEntryDate())%></td>
274        </tr>
275        <tr>
276          <th>Tag</th>
277          <td><base:propertyvalue item="<%=extract%>" property="tag"/></td>
278        </tr>
279        <tr>
280          <th>Protocol</th>
281          <td><base:propertyvalue item="<%=creationEvent%>" property="protocol"/></td>
282        </tr>
283        <tr>
284          <th>Original quantity</th>
285          <td><%=Values.formatNumber(extract.getOriginalQuantity(), 2, " µg")%></td>
286        </tr>
287        <tr>
288          <th class="subprompt">- remaining</th>
289          <td><%=Values.formatNumber(extract.getRemainingQuantity(), 2, " µg")%></td>
290        </tr>
291        <tr>
292          <th>Bioplate</th>
293          <td>
294            <base:propertyvalue item="<%=extract%>" property="bioWell.bioPlate" />
295            <%
296            try
297            {
298              BioWell well = extract.getBioWell();
299              if (well != null)
300              {
301                %>
302                [<%=rowFormatter.format(well.getRow())%><%=columnFormatter.format(well.getColumn())%>]
303                <base:icon image="locked.png"  visible="<%=extract.isLockedInWell()%>"/>
304              <%
305              }
306            }
307            catch (PermissionDeniedException ex)
308            {}
309            %>
310          </td>
311        </tr>
312        <tr>
313          <th>Owner</th>
314          <td><base:propertyvalue item="<%=extract%>" property="owner"/></td>
315        </tr>
316        <tr>
317          <th>Permissions</th>
318          <td><%=PermissionUtil.getFullPermissionNames(extract)%></td>
319        </tr>
320        <tr>
321          <th>Description</th>
322          <td><%=HTML.niceFormat(extract.getDescription())%></td>
323        </tr>
324      </table>
325      </div>
326 
327      <%
328      SpecialQuery<BioMaterialEventSource> sourceQuery = creationEvent.getEventSources();
329      sourceQuery.order(Orders.asc(Hql.property("bioMaterial.name")));
330      ResultList<BioMaterialEventSource> sources = sourceQuery.list(dc);
331      %>
332      <base:section 
333        id="parentsSection" 
334        title="<%="Parent items (" + sources.size() + ")"%>"
335        context="<%=cc%>"
336        >
337        <%
338        if (sources.size() == 0)
339        {
340          %>
341          <div class="messagecontainer note">
342          This extract doesn't have any parent items
343          (or, you don't have permission to view them).
344          </div>
345          <%
346        }
347        else
348        {
349          %>
350          <tbl:table
351            id="parents"
352            columns="all"
353            >
354          <tbl:columndef 
355            id="name"
356            title="Name"
357          />
358          <tbl:columndef 
359            id="type"
360            title="Type"
361          />
362          <tbl:columndef 
363            id="quantity"
364            title="Used quantity (µg)"
365          />
366          <tbl:columndef 
367            id="description"
368            title="Description"
369          />
370          <tbl:data>
371            <tbl:headers>
372              <tbl:headerrow>
373                <tbl:columnheaders />
374              </tbl:headerrow>
375            </tbl:headers>
376            <tbl:rows>
377            <%
378            for (BioMaterialEventSource item : sources)
379            {
380              BioMaterial bm = null;
381              ItemSubtype subtype = null;
382              try
383              {
384                bm = item.getBioMaterial();
385                subtype = bm.getItemSubtype();
386              }
387              catch (PermissionDeniedException ex)
388              {}
389              %>
390              <tbl:row>
391                <tbl:cell column="name"><base:icon 
392                  image="deleted.png" 
393                  tooltip="This item has been scheduled for deletion" 
394                  visible="<%=bm != null && bm.isRemoved()%>"
395                  /><%=Base.getLinkedName(ID, bm, bm == null, true)%></tbl:cell>
396                <tbl:cell column="type">
397                  <%
398                  if (subtype != null)
399                  {
400                    %>
401                    <%=Base.getLinkedName(ID, subtype, false, true)%> <span class="itemsubtype">(<%=bm.getType() %>)</span>
402                    <%
403                  }
404                  else
405                  {
406                    %>
407                    <%=bm != null ? bm.getType() : "" %>
408                    <%
409                  }
410                  %>
411                </tbl:cell>
412                <tbl:cell column="quantity"><%=Values.formatNumber(item.getUsedQuantity(), 2)%></tbl:cell>
413                <tbl:cell column="description"><%=HTML.encodeTags(bm == null ? "" : bm.getDescription())%></tbl:cell>
414              </tbl:row>
415              <%
416            }
417            %>
418          </tbl:rows>
419          </tbl:data>
420          </tbl:table>
421          <%
422        }
423      %>
424      </base:section>
425      <%
426      SpecialQuery<BioMaterialEventSource> childQuery = extract.getChildCreationEvents();
427      childQuery.join(Hql.innerJoin("es", "event", "evt", true));
428      childQuery.join(Hql.leftJoin("evt", "bioMaterial", "bm", null, true));
429      childQuery.join(Hql.leftJoin("evt", "physicalBioAssay", "pba", null, true));
430      childQuery.order(Orders.asc(Hql.property("pba", "name")));
431      childQuery.order(Orders.asc(Hql.property("bm", "name")));
432      ResultList<BioMaterialEventSource> children = childQuery.list(dc);
433      %>
434      <base:section 
435        id="childSection" 
436        title="<%="Child items (" + children.size() + ")"%>"
437        context="<%=cc%>"
438        >
439        <%
440        if (children.size() == 0)
441        {
442          %>
443          <div class="messagecontainer note">
444          No child items have been created from this extract
445          (or, you don't have permission to view them).
446          </div>
447          <%
448        }
449        else
450        {
451          %>
452          <tbl:table 
453            id="children"
454            columns="all"
455            >
456            <tbl:columndef 
457              id="name"
458              title="Name"
459            />
460            <tbl:columndef 
461              id="type"
462              title="Type"
463            />
464            <tbl:columndef 
465              id="quantity"
466              title="Used quantity (µg)"
467            />
468            <tbl:columndef 
469              id="description"
470              title="Description"
471            />
472            <tbl:data>
473            <tbl:headers>
474              <tbl:headerrow>
475                <tbl:columnheaders />
476              </tbl:headerrow>
477              </tbl:headers>
478              <tbl:rows>
479              <%
480              for (BioMaterialEventSource item : children)
481              {
482                CommonItem child = null;
483                ItemSubtype subtype = null;
484                try
485                {
486                  BioMaterialEvent evt = item.getEvent();
487                  if (evt.getEventType() == BioMaterialEvent.Type.BIOASSAY)
488                  {
489                    PhysicalBioAssay bioAssay = evt.getPhysicalBioAssay();
490                    subtype = bioAssay.getItemSubtype();
491                    child = bioAssay;
492                  }
493                  else
494                  {
495                    BioMaterial bm = evt.getBioMaterial();
496                    subtype = bm.getItemSubtype();
497                    child = bm;
498                  }
499                }
500                catch (PermissionDeniedException ex)
501                {}
502                %>
503                <tbl:row>
504                  <tbl:cell column="name"><base:icon 
505                      image="deleted.png" 
506                      tooltip="This item has been scheduled for deletion" 
507                      visible="<%=child != null && child.isRemoved()%>"
508                    /><%=Base.getLinkedName(ID, child, child == null, true)%></tbl:cell>
509                  <tbl:cell column="type">
510                    <%
511                    if (subtype != null)
512                    {
513                      %>
514                      <%=Base.getLinkedName(ID, subtype, false, true)%> <span class="itemsubtype">(<%=child.getType() %>)</span>
515                      <%
516                    }
517                    else
518                    {
519                      %>
520                      <%=child != null ? child.getType() : "" %>
521                      <%
522                    }
523                    %>
524                  </tbl:cell>
525                  <tbl:cell column="quantity"><%=Values.formatNumber(item.getUsedQuantity(), 2)%></tbl:cell>
526                  <tbl:cell column="description"><%=HTML.encodeTags(child == null ? "" : child.getDescription())%></tbl:cell>
527                </tbl:row>
528                <%
529              }
530              %>           
531              </tbl:rows>
532            </tbl:data>
533          </tbl:table>
534          <%
535        }
536        %>
537      </base:section>
538      <jsp:include page="../../common/anytoany/list_anytoany.jsp">
539        <jsp:param name="ID" value="<%=ID%>" />
540        <jsp:param name="item_type" value="<%=itemType.name()%>" />
541        <jsp:param name="item_id" value="<%=itemId%>" />
542        <jsp:param name="title" value="Other items related to this extract" />
543      </jsp:include>
544      <jsp:include page="../../common/share/list_share.jsp">
545        <jsp:param name="ID" value="<%=ID%>" />
546        <jsp:param name="item_type" value="<%=itemType.name()%>" />
547        <jsp:param name="item_id" value="<%=itemId%>" />
548        <jsp:param name="title" value="Shared to" />
549      </jsp:include>
550      </t:tab>
551     
552      <t:tab id="annotations" title="Annotations &amp; parameters" 
553        tooltip="View annotation values and protocol parameters" clazz="white">
554        <jsp:include page="../../common/annotations/list_frameset.jsp">
555          <jsp:param name="item_type" value="<%=itemType.name()%>" />
556          <jsp:param name="item_id" value="<%=itemId%>" />
557          <jsp:param name="ID" value="<%=ID%>" />
558        </jsp:include>
559      </t:tab>
560     
561      <t:tab id="events" title="Events" />
562
563      <t:tab id="overview" title="Overview" 
564        tooltip="Display a tree overview of related items">
565        <jsp:include page="../../common/overview/overview.jsp">
566          <jsp:param name="item_type" value="<%=itemType.name()%>" />
567          <jsp:param name="item_id" value="<%=itemId%>" />
568          <jsp:param name="ID" value="<%=ID%>" />
569        </jsp:include>
570      </t:tab>
571      <t:tab id="history" title="Change history" 
572        tooltip="Displays a log of all modifications made to this item"
573        visible="<%=ChangeHistoryUtil.showChangeHistoryTab(sc)%>">
574        <jsp:include page="../../common/history/frameset.jsp">
575          <jsp:param name="item_type" value="<%=itemType.name()%>" />
576          <jsp:param name="item_id" value="<%=itemId%>" />
577          <jsp:param name="ID" value="<%=ID%>" />
578        </jsp:include>
579      </t:tab>     
580      </t:tabcontrol>
581
582
583  </base:body>
584  </base:page>
585  <%
586}
587finally
588{
589  if (dc != null) dc.close();
590}
591
592%>
Note: See TracBrowser for help on using the repository browser.