source: trunk/www/views/hybridizations/view_hybridization.jsp @ 2918

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

References #348: Take ownership of items

Implemented on all pages in the "View" menu.

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