source: trunk/www/biomaterials/labeledextracts/view_labeledextract.jsp @ 2875

Last change on this file since 2875 was 2875, checked in by Nicklas Nordborg, 17 years ago

Fixes #339: Protocol parameters

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 12.8 KB
Line 
1<%-- $Id: view_labeledextract.jsp 2875 2006-11-08 14:27:29Z nicklas $
2  ------------------------------------------------------------------
3  Copyright (C) Authors contributing to this file.
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 2
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 this program; if not, write to the Free Software
20  Foundation, Inc., 59 Temple Place - Suite 330,
21  Boston, MA  02111-1307, USA.
22  ------------------------------------------------------------------
23
24  @author Nicklas
25  @version 2.0
26--%>
27<%@ page
28  import="net.sf.basedb.core.SessionControl"
29  import="net.sf.basedb.core.DbControl"
30  import="net.sf.basedb.core.SystemItems"
31  import="net.sf.basedb.core.Hybridization"
32  import="net.sf.basedb.core.Item"
33  import="net.sf.basedb.core.ItemContext"
34  import="net.sf.basedb.core.Permission"
35  import="net.sf.basedb.core.Extract"
36  import="net.sf.basedb.core.LabeledExtract"
37  import="net.sf.basedb.core.Label"
38  import="net.sf.basedb.core.BioMaterialEvent"
39  import="net.sf.basedb.core.Protocol"
40  import="net.sf.basedb.core.User"
41  import="net.sf.basedb.core.ItemQuery"
42  import="net.sf.basedb.core.ItemResultList"
43  import="net.sf.basedb.core.Include"
44  import="net.sf.basedb.core.query.Orders"
45  import="net.sf.basedb.core.query.Hql"
46  import="net.sf.basedb.core.PermissionDeniedException"
47  import="net.sf.basedb.core.PluginDefinition"
48  import="net.sf.basedb.core.plugin.GuiContext"
49  import="net.sf.basedb.core.plugin.Plugin"
50  import="net.sf.basedb.clients.web.Base"
51  import="net.sf.basedb.clients.web.PermissionUtil"
52  import="net.sf.basedb.clients.web.util.HTML"
53  import="net.sf.basedb.util.Values"
54  import="java.util.Date"
55  import="java.util.Map"
56  import="java.util.Set"
57  import="java.util.List"
58%>
59<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
60<%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %>
61<%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %>
62<%@ taglib prefix="p" uri="/WEB-INF/path.tld" %>
63<%!
64  private static final Item itemType = Item.LABELEDEXTRACT;
65  private static final GuiContext guiContext = new GuiContext(itemType, GuiContext.Type.ITEM);
66%>
67<%
68final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
69final String ID = sc.getId();
70final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
71final int itemId = cc.getId();
72final String tab = Values.getString(request.getParameter("tab"), "properties");
73final float scale = Base.getScale(sc);
74final DbControl dc = sc.newDbControl();
75try
76{
77  Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext);
78
79  String title = null;
80  LabeledExtract extract = LabeledExtract.getById(dc, itemId);
81  BioMaterialEvent creationEvent = extract.getCreationEvent();
82 
83  final boolean writePermission = extract.hasPermission(Permission.WRITE);
84  final boolean deletePermission = extract.hasPermission(Permission.DELETE);
85  final boolean sharePermission = extract.hasPermission(Permission.SET_PERMISSION);
86  final boolean usePermission = extract.hasPermission(Permission.USE);
87 
88  %>
89
90  <base:page title="<%=title%>">
91  <base:head scripts="table.js,tabcontrol.js" styles="table.css,toolbar.css,headertabcontrol.css,path.css">
92    <script language="JavaScript">
93    function editItem()
94    {
95      Main.viewOrEditItem('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>, true);
96    }
97    function shareItem()
98    {
99      Main.openPopup('index.jsp?ID=<%=ID%>&cmd=ShareItem&item_id=<%=itemId%>', 'ShareLabeledExtract', 500, 400);
100    }
101    function deleteItem()
102    {
103      location.replace('index.jsp?ID=<%=ID%>&cmd=DeleteItem&item_id=<%=itemId%>');
104    }
105    function restoreItem()
106    {
107      location.replace('index.jsp?ID=<%=ID%>&cmd=RestoreItem&item_id=<%=itemId%>');
108    }
109    function runPlugin(cmd)
110    {
111      Main.openPopup('index.jsp?ID=<%=ID%>&cmd='+cmd+'&item_id=<%=itemId%>', 'RunPlugin'+cmd, 740, 540);
112    }
113    function viewEvents()
114    {
115      location.href = '../events/index.jsp?ID=<%=ID%>&cmd=List&biomaterial_id=<%=itemId%>&biomaterial_type=<%=itemType.name()%>';
116    }
117    function switchTab(tabControlId, tabId)
118    {
119      if (tabId == 'events')
120      {
121        viewEvents();
122      }
123      else
124      {
125        TabControl.setActiveTab(tabControlId, tabId);
126      }
127    }
128    function newHybridization()
129    {
130      Main.viewOrEditItem('<%=ID%>', 'HYBRIDIZATION', 0, true, '&labeledextract_id='+<%=itemId%>);
131    }
132    </script>
133  </base:head>
134  <base:body>
135    <p>
136    <p:path>
137      <p:pathelement title="Labeled extracts" href="<%="index.jsp?ID="+ID%>" />
138      <p:pathelement title="<%=HTML.encodeTags(extract.getName())%>" />
139    </p:path>
140   
141    <t:tabcontrol id="main" active="<%=tab%>" switch="switchTab">
142    <t:tab id="properties" title="Properties">
143
144    <tbl:toolbar
145      >
146      <tbl:button 
147        disabled="<%=writePermission ? false : true%>" 
148        image="<%=writePermission ? "edit.gif" : "edit_disabled.gif"%>" 
149        onclick="editItem()" 
150        title="Edit&hellip;" 
151        tooltip="<%=writePermission ? "Edit this labeled extract" : "You do not have permission to edit this labeled extract"%>" 
152      />
153      <tbl:button 
154        disabled="<%=deletePermission ? false : true%>" 
155        image="<%=deletePermission ? "delete.gif" : "delete_disabled.gif"%>" 
156        onclick="deleteItem()" 
157        title="Delete"
158        visible="<%=!extract.isRemoved()%>"
159        tooltip="<%=deletePermission ? "Delete this labeled extract" : "You do not have permission to delete this labeled extract"%>" 
160      />
161      <tbl:button 
162        disabled="<%=writePermission ? false : true%>" 
163        image="<%=writePermission ? "restore.gif" : "restore_disabled.gif"%>" 
164        onclick="restoreItem()" 
165        title="Restore"
166        visible="<%=extract.isRemoved()%>"
167        tooltip="<%=writePermission ? "Restore this labeled extract" : "You do not have permission to restore this labeled extract"%>" 
168      />
169      <tbl:button 
170        disabled="<%=sharePermission ? false : true%>"
171        image="<%=sharePermission ? "share.gif" : "share_disabled.gif"%>"
172        onclick="shareItem()" 
173        title="Share&hellip;" 
174        tooltip="<%=sharePermission ? "Share this labeled extract to other user, groups and projects" : "You do not have permission to share this labeled extract"%>"
175      />
176      <tbl:button
177        image="add.png"
178        onclick="newHybridization()"
179        title="New hybridization&hellip;"
180        tooltip="Create a new hybridization from this labeled extract"
181        visible="<%=sc.hasPermission(Permission.CREATE, Item.HYBRIDIZATION) && usePermission%>"
182      />
183      <tbl:button 
184        image="import.gif" 
185        onclick="runPlugin('ImportItem')" 
186        title="Import&hellip;" 
187        tooltip="Import data" 
188        visible="<%=pluginCount.containsKey(Plugin.MainType.IMPORT)%>"
189      />
190      <tbl:button 
191        image="export.gif" 
192        onclick="runPlugin('ExportItem')" 
193        title="Export&hellip;" 
194        tooltip="Export data" 
195        visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>"
196      />
197      <tbl:button 
198        image="runplugin.gif" 
199        onclick="runPlugin('RunPlugin')" 
200        title="Run plugin&hellip;" 
201        tooltip="Run a plugin" 
202        visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>"
203      />
204      <tbl:button
205        image="help.gif"
206        onclick="<%="Main.openHelp('" + ID +"', 'labeledextract.view.properties')"%>"
207        title="Help&hellip;"
208        tooltip="Get help about this page"
209      /> 
210      </tbl:toolbar>
211    <div class="boxedbottom">
212      <div class="itemstatus">Permissions on this item: <i><%=PermissionUtil.getFullPermissionNames(extract)%></i></div>
213      <%
214      if (extract.isRemoved() || extract.isShared())
215      {
216        %>
217        <div class="itemstatus">
218          <base:icon image="deleted.gif" 
219            visible="<%=extract.isRemoved()%>"> This item has been flagged for deletion<br></base:icon>
220          <base:icon image="shared.gif" 
221            visible="<%=extract.isShared()%>"> This item is shared to other user, groups and/or projects</base:icon>
222        </div>
223        <%
224      }
225      %>
226      <table class="form" cellspacing=0>
227      <tr>
228        <td class="prompt">Name</td>
229        <td><%=HTML.encodeTags(extract.getName())%></td>
230      </tr>
231      <tr>
232        <td class="prompt">Label</td>
233        <td><base:propertyvalue item="<%=extract%>" property="label"/></td>
234      </tr>
235      <tr>
236        <td class="prompt">External ID</td>
237        <td><%=HTML.encodeTags(extract.getExternalId())%></td>
238      </tr>
239      <tr>
240        <td class="prompt">Created</td>
241        <td><%=Values.formatDate(creationEvent.getEventDate())%></td>
242      </tr>
243      <tr>
244        <td class="prompt">Registered</td>
245        <td><%=Values.formatDate(creationEvent.getEntryDate())%></td>
246      </tr>
247      <%
248      if (!extract.isPooled())
249      {       
250        %>
251        <tr>
252          <td class="prompt">Extract</td>
253          <td>
254            <base:propertyvalue item="<%=extract%>" property="parent"/>
255            <%
256            try
257            {
258            %>
259              <%=extract.getExtract() != null ? "(" + Values.formatNumber(creationEvent.getUsedQuantity(extract.getExtract()), 2, " µg") + ")": ""%>
260            <%
261            }
262            catch (PermissionDeniedException ex)
263            {}
264            %>
265          </td>
266        </tr>
267        <%
268      }
269      %>
270      <tr>
271        <td class="prompt">Protocol</td>
272        <td><base:propertyvalue item="<%=creationEvent%>" property="protocol"/>
273      </tr>
274      <tr>
275        <td class="prompt">Original quantity</td>
276        <td><%=Values.formatNumber(extract.getOriginalQuantity(), 2, " µg")%></td>
277      </tr>
278      <tr>
279        <td class="prompt">Remaining quantity</td>
280        <td><%=Values.formatNumber(extract.getRemainingQuantity(), 2, " µg")%></td>
281      </tr>
282      <tr>
283        <td class="prompt">Owner</td>
284        <td><base:propertyvalue item="<%=extract%>" property="owner"/></td>
285      </tr>
286      <tr valign="baseline">
287        <td class="prompt">Description</td>
288        <td><%=HTML.niceFormat(extract.getDescription())%></td>
289      </tr>
290      </table>
291 
292      <%
293      if (extract.isPooled())
294      {
295        ItemQuery<LabeledExtract> extractsQuery = (ItemQuery<LabeledExtract>)creationEvent.getSources();
296        extractsQuery.include(Include.MINE, Include.SHARED, Include.IN_PROJECT, Include.OTHERS);
297        extractsQuery.order(Orders.asc(Hql.property("name")));
298        ItemResultList<LabeledExtract> extracts = extractsQuery.list(dc);
299        String extractLink = "index.jsp?ID="+ID;
300        %>
301        <h4 class="docked">Pooled from labeled extracts</h4>
302        <tbl:table
303          id="pooled"
304          clazz="itemlist"
305          columns="all"
306          >
307        <tbl:columndef 
308          id="name"
309          title="Name"
310        />
311        <tbl:columndef 
312          id="quantity"
313          title="Used quantity (µg)"
314        />
315        <tbl:columndef 
316          id="description"
317          title="Description"
318        />
319        <tbl:data>
320          <tbl:columns>
321          </tbl:columns>
322          <tbl:rows>
323          <%
324          for (LabeledExtract item : extracts)
325          {
326            %>
327            <tbl:row>
328              <tbl:cell column="name"><%=Base.getEncodedName(item, false, extractLink)%></tbl:cell>
329              <tbl:cell column="quantity"><%=Values.formatNumber(creationEvent.getUsedQuantity(item), 2)%></tbl:cell>
330              <tbl:cell column="description"><%=HTML.encodeTags(item.getDescription())%></tbl:cell>
331            </tbl:row>
332            <%
333          }
334          %>
335          </tbl:rows>
336        </tbl:data>
337        </tbl:table>
338        <%
339      }
340      ItemQuery<Hybridization> hybridizationQuery = extract.getHybridizations();
341      hybridizationQuery.include(Include.MINE, Include.SHARED, Include.OTHERS, Include.IN_PROJECT);
342      hybridizationQuery.order(Orders.asc(Hql.property("name")));
343      ItemResultList<Hybridization>hybridizations = hybridizationQuery.list(dc);
344      if (hybridizations.size() == 0)
345      {
346        %>
347        <h4>Hybridizations</h4>
348        No hybridizations have been created from this labeled extract
349        (or you don't have the permission to view them)
350        <%
351      }
352      else
353      {
354        %>
355        <h4 class="docked">Hybridizations</h4>
356        <tbl:table
357          id="hybridizations"
358          clazz="itemlist"
359          columns="all"
360          >
361          <tbl:columndef
362            id="name"
363            title="Name"
364          />         
365          <tbl:columndef
366            id="description"
367            title="Description"
368          />
369          <tbl:data>
370            <tbl:columns></tbl:columns>
371            <tbl:rows>
372              <%
373              for (Hybridization hyb : hybridizations)
374              {
375                %>
376                <tbl:row>
377                  <tbl:cell column="name"><%=Base.getLinkedName(ID, hyb, false, true)%></tbl:cell>
378                  <tbl:cell column="description"><%=HTML.encodeTags(hyb.getDescription())%></tbl:cell>
379                </tbl:row>
380                <%
381              }
382              %>
383            </tbl:rows>
384          </tbl:data>
385        </tbl:table>
386        <%
387      }
388      %>
389     
390    </div>
391      </t:tab>
392     
393      <t:tab id="annotations" title="Annotations &amp; parameters" 
394        tooltip="View annotation values and protocol parameters">
395        <div class="boxed">
396        <jsp:include page="../../common/annotations/list_annotations.jsp">
397          <jsp:param name="item_type" value="<%=itemType.name()%>" />
398          <jsp:param name="item_id" value="<%=itemId%>" />
399          <jsp:param name="ID" value="<%=ID%>" />
400        </jsp:include>
401        </div>
402      </t:tab>
403     
404      <t:tab id="events" title="Events" />
405     
406      </t:tabcontrol>
407
408
409  </base:body>
410  </base:page>
411  <%
412}
413finally
414{
415  if (dc != null) dc.close();
416}
417
418%>
419
Note: See TracBrowser for help on using the repository browser.