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

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

References #348: Take ownership of items

Implemented on all biomaterial pages

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 13.6 KB
Line 
1<%-- $Id: view_labeledextract.jsp 2917 2006-11-15 10:28:36Z 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  final boolean setOwnerPermission = extract.hasPermission(Permission.SET_OWNER);
88  final boolean isOwner = extract.isOwner();
89  %>
90
91  <base:page title="<%=title%>">
92  <base:head scripts="table.js,tabcontrol.js" styles="table.css,toolbar.css,headertabcontrol.css,path.css">
93    <script language="JavaScript">
94    function editItem()
95    {
96      Main.viewOrEditItem('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>, true);
97    }
98    function shareItem()
99    {
100      Main.openPopup('index.jsp?ID=<%=ID%>&cmd=ShareItem&item_id=<%=itemId%>', 'ShareLabeledExtract', 500, 400);
101    }
102    function deleteItem()
103    {
104      location.replace('index.jsp?ID=<%=ID%>&cmd=DeleteItem&item_id=<%=itemId%>');
105    }
106    function restoreItem()
107    {
108      location.replace('index.jsp?ID=<%=ID%>&cmd=RestoreItem&item_id=<%=itemId%>');
109    }
110    function takeOwnership()
111    {
112      if (confirm('Are you sure that you want to take ownership of this item? It can\'t be undone.'))
113      {
114        location.replace('index.jsp?ID=<%=ID%>&cmd=TakeOwnershipOfItem&item_id=<%=itemId%>');
115      }
116    }
117    function runPlugin(cmd)
118    {
119      Main.openPopup('index.jsp?ID=<%=ID%>&cmd='+cmd+'&item_id=<%=itemId%>', 'RunPlugin'+cmd, 740, 540);
120    }
121    function viewEvents()
122    {
123      location.href = '../events/index.jsp?ID=<%=ID%>&cmd=List&biomaterial_id=<%=itemId%>&biomaterial_type=<%=itemType.name()%>';
124    }
125    function switchTab(tabControlId, tabId)
126    {
127      if (tabId == 'events')
128      {
129        viewEvents();
130      }
131      else
132      {
133        TabControl.setActiveTab(tabControlId, tabId);
134      }
135    }
136    function newHybridization()
137    {
138      Main.viewOrEditItem('<%=ID%>', 'HYBRIDIZATION', 0, true, '&labeledextract_id='+<%=itemId%>);
139    }
140    </script>
141  </base:head>
142  <base:body>
143    <p>
144    <p:path>
145      <p:pathelement title="Labeled extracts" href="<%="index.jsp?ID="+ID%>" />
146      <p:pathelement title="<%=HTML.encodeTags(extract.getName())%>" />
147    </p:path>
148   
149    <t:tabcontrol id="main" active="<%=tab%>" switch="switchTab">
150    <t:tab id="properties" title="Properties">
151
152    <tbl:toolbar
153      >
154      <tbl:button 
155        disabled="<%=writePermission ? false : true%>" 
156        image="<%=writePermission ? "edit.gif" : "edit_disabled.gif"%>" 
157        onclick="editItem()" 
158        title="Edit&hellip;" 
159        tooltip="<%=writePermission ? "Edit this labeled extract" : "You do not have permission to edit this labeled extract"%>" 
160      />
161      <tbl:button 
162        disabled="<%=deletePermission ? false : true%>" 
163        image="<%=deletePermission ? "delete.gif" : "delete_disabled.gif"%>" 
164        onclick="deleteItem()" 
165        title="Delete"
166        visible="<%=!extract.isRemoved()%>"
167        tooltip="<%=deletePermission ? "Delete this labeled extract" : "You do not have permission to delete this labeled extract"%>" 
168      />
169      <tbl:button 
170        disabled="<%=writePermission ? false : true%>" 
171        image="<%=writePermission ? "restore.gif" : "restore_disabled.gif"%>" 
172        onclick="restoreItem()" 
173        title="Restore"
174        visible="<%=extract.isRemoved()%>"
175        tooltip="<%=writePermission ? "Restore this labeled extract" : "You do not have permission to restore this labeled extract"%>" 
176      />
177      <tbl:button 
178        disabled="<%=sharePermission ? false : true%>"
179        image="<%=sharePermission ? "share.gif" : "share_disabled.gif"%>"
180        onclick="shareItem()" 
181        title="Share&hellip;" 
182        tooltip="<%=sharePermission ? "Share this labeled extract to other user, groups and projects" : "You do not have permission to share this labeled extract"%>"
183      />
184      <tbl:button 
185        disabled="<%=setOwnerPermission ? false : true%>"
186        image="<%=setOwnerPermission ? "take_ownership.png" : "take_ownership_disabled.png"%>"
187        onclick="takeOwnership()" 
188        title="Take ownership&hellip;"
189        visible="<%=!isOwner%>"
190        tooltip="<%=setOwnerPermission ? "Take ownership of this item" : "You do not have permission to take ownership of this item"%>"
191      />
192      <tbl:button
193        image="add.png"
194        onclick="newHybridization()"
195        title="New hybridization&hellip;"
196        tooltip="Create a new hybridization from this labeled extract"
197        visible="<%=sc.hasPermission(Permission.CREATE, Item.HYBRIDIZATION) && usePermission%>"
198      />
199      <tbl:button 
200        image="import.gif" 
201        onclick="runPlugin('ImportItem')" 
202        title="Import&hellip;" 
203        tooltip="Import data" 
204        visible="<%=pluginCount.containsKey(Plugin.MainType.IMPORT)%>"
205      />
206      <tbl:button 
207        image="export.gif" 
208        onclick="runPlugin('ExportItem')" 
209        title="Export&hellip;" 
210        tooltip="Export data" 
211        visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>"
212      />
213      <tbl:button 
214        image="runplugin.gif" 
215        onclick="runPlugin('RunPlugin')" 
216        title="Run plugin&hellip;" 
217        tooltip="Run a plugin" 
218        visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>"
219      />
220      <tbl:button
221        image="help.gif"
222        onclick="<%="Main.openHelp('" + ID +"', 'labeledextract.view.properties')"%>"
223        title="Help&hellip;"
224        tooltip="Get help about this page"
225      /> 
226      </tbl:toolbar>
227    <div class="boxedbottom">
228      <div class="itemstatus">Permissions on this item: <i><%=PermissionUtil.getFullPermissionNames(extract)%></i></div>
229      <%
230      if (extract.isRemoved() || extract.isShared())
231      {
232        %>
233        <div class="itemstatus">
234          <base:icon image="deleted.gif" 
235            visible="<%=extract.isRemoved()%>"> This item has been flagged for deletion<br></base:icon>
236          <base:icon image="shared.gif" 
237            visible="<%=extract.isShared()%>"> This item is shared to other user, groups and/or projects</base:icon>
238        </div>
239        <%
240      }
241      %>
242      <table class="form" cellspacing=0>
243      <tr>
244        <td class="prompt">Name</td>
245        <td><%=HTML.encodeTags(extract.getName())%></td>
246      </tr>
247      <tr>
248        <td class="prompt">Label</td>
249        <td><base:propertyvalue item="<%=extract%>" property="label"/></td>
250      </tr>
251      <tr>
252        <td class="prompt">External ID</td>
253        <td><%=HTML.encodeTags(extract.getExternalId())%></td>
254      </tr>
255      <tr>
256        <td class="prompt">Created</td>
257        <td><%=Values.formatDate(creationEvent.getEventDate())%></td>
258      </tr>
259      <tr>
260        <td class="prompt">Registered</td>
261        <td><%=Values.formatDate(creationEvent.getEntryDate())%></td>
262      </tr>
263      <%
264      if (!extract.isPooled())
265      {       
266        %>
267        <tr>
268          <td class="prompt">Extract</td>
269          <td>
270            <base:propertyvalue item="<%=extract%>" property="parent"/>
271            <%
272            try
273            {
274            %>
275              <%=extract.getExtract() != null ? "(" + Values.formatNumber(creationEvent.getUsedQuantity(extract.getExtract()), 2, " µg") + ")": ""%>
276            <%
277            }
278            catch (PermissionDeniedException ex)
279            {}
280            %>
281          </td>
282        </tr>
283        <%
284      }
285      %>
286      <tr>
287        <td class="prompt">Protocol</td>
288        <td><base:propertyvalue item="<%=creationEvent%>" property="protocol"/>
289      </tr>
290      <tr>
291        <td class="prompt">Original quantity</td>
292        <td><%=Values.formatNumber(extract.getOriginalQuantity(), 2, " µg")%></td>
293      </tr>
294      <tr>
295        <td class="prompt">Remaining quantity</td>
296        <td><%=Values.formatNumber(extract.getRemainingQuantity(), 2, " µg")%></td>
297      </tr>
298      <tr>
299        <td class="prompt">Owner</td>
300        <td><base:propertyvalue item="<%=extract%>" property="owner"/></td>
301      </tr>
302      <tr valign="baseline">
303        <td class="prompt">Description</td>
304        <td><%=HTML.niceFormat(extract.getDescription())%></td>
305      </tr>
306      </table>
307 
308      <%
309      if (extract.isPooled())
310      {
311        ItemQuery<LabeledExtract> extractsQuery = (ItemQuery<LabeledExtract>)creationEvent.getSources();
312        extractsQuery.include(Include.MINE, Include.SHARED, Include.IN_PROJECT, Include.OTHERS);
313        extractsQuery.order(Orders.asc(Hql.property("name")));
314        ItemResultList<LabeledExtract> extracts = extractsQuery.list(dc);
315        String extractLink = "index.jsp?ID="+ID;
316        %>
317        <h4 class="docked">Pooled from labeled extracts</h4>
318        <tbl:table
319          id="pooled"
320          clazz="itemlist"
321          columns="all"
322          >
323        <tbl:columndef 
324          id="name"
325          title="Name"
326        />
327        <tbl:columndef 
328          id="quantity"
329          title="Used quantity (µg)"
330        />
331        <tbl:columndef 
332          id="description"
333          title="Description"
334        />
335        <tbl:data>
336          <tbl:columns>
337          </tbl:columns>
338          <tbl:rows>
339          <%
340          for (LabeledExtract item : extracts)
341          {
342            %>
343            <tbl:row>
344              <tbl:cell column="name"><%=Base.getEncodedName(item, false, extractLink)%></tbl:cell>
345              <tbl:cell column="quantity"><%=Values.formatNumber(creationEvent.getUsedQuantity(item), 2)%></tbl:cell>
346              <tbl:cell column="description"><%=HTML.encodeTags(item.getDescription())%></tbl:cell>
347            </tbl:row>
348            <%
349          }
350          %>
351          </tbl:rows>
352        </tbl:data>
353        </tbl:table>
354        <%
355      }
356      ItemQuery<Hybridization> hybridizationQuery = extract.getHybridizations();
357      hybridizationQuery.include(Include.MINE, Include.SHARED, Include.OTHERS, Include.IN_PROJECT);
358      hybridizationQuery.order(Orders.asc(Hql.property("name")));
359      ItemResultList<Hybridization>hybridizations = hybridizationQuery.list(dc);
360      if (hybridizations.size() == 0)
361      {
362        %>
363        <h4>Hybridizations</h4>
364        No hybridizations have been created from this labeled extract
365        (or you don't have the permission to view them)
366        <%
367      }
368      else
369      {
370        %>
371        <h4 class="docked">Hybridizations</h4>
372        <tbl:table
373          id="hybridizations"
374          clazz="itemlist"
375          columns="all"
376          >
377          <tbl:columndef
378            id="name"
379            title="Name"
380          />         
381          <tbl:columndef
382            id="description"
383            title="Description"
384          />
385          <tbl:data>
386            <tbl:columns></tbl:columns>
387            <tbl:rows>
388              <%
389              for (Hybridization hyb : hybridizations)
390              {
391                %>
392                <tbl:row>
393                  <tbl:cell column="name"><%=Base.getLinkedName(ID, hyb, false, true)%></tbl:cell>
394                  <tbl:cell column="description"><%=HTML.encodeTags(hyb.getDescription())%></tbl:cell>
395                </tbl:row>
396                <%
397              }
398              %>
399            </tbl:rows>
400          </tbl:data>
401        </tbl:table>
402        <%
403      }
404      %>
405     
406    </div>
407      </t:tab>
408     
409      <t:tab id="annotations" title="Annotations &amp; parameters" 
410        tooltip="View annotation values and protocol parameters">
411        <div class="boxed">
412        <jsp:include page="../../common/annotations/list_annotations.jsp">
413          <jsp:param name="item_type" value="<%=itemType.name()%>" />
414          <jsp:param name="item_id" value="<%=itemId%>" />
415          <jsp:param name="ID" value="<%=ID%>" />
416        </jsp:include>
417        </div>
418      </t:tab>
419     
420      <t:tab id="events" title="Events" />
421     
422      </t:tabcontrol>
423
424
425  </base:body>
426  </base:page>
427  <%
428}
429finally
430{
431  if (dc != null) dc.close();
432}
433
434%>
435
Note: See TracBrowser for help on using the repository browser.