source: trunk/www/views/rawbioassays/view_rawbioassay.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: 14.6 KB
Line 
1<%-- $Id: view_rawbioassay.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  buffer="500kb"
29  import="net.sf.basedb.core.SessionControl"
30  import="net.sf.basedb.core.DbControl"
31  import="net.sf.basedb.core.SystemItems"
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.AnnotationType"
36  import="net.sf.basedb.core.AnnotationSet"
37  import="net.sf.basedb.core.ExtendedProperties"
38  import="net.sf.basedb.core.ExtendedProperty"
39  import="net.sf.basedb.core.RawBioAssay"
40  import="net.sf.basedb.core.Experiment"
41  import="net.sf.basedb.core.RawDataType"
42  import="net.sf.basedb.core.Affymetrix"
43  import="net.sf.basedb.core.SpotImages"
44  import="net.sf.basedb.core.Scan"
45  import="net.sf.basedb.core.Protocol"
46  import="net.sf.basedb.core.Software"
47  import="net.sf.basedb.core.ArrayDesign"
48  import="net.sf.basedb.core.File"
49  import="net.sf.basedb.core.User"
50  import="net.sf.basedb.core.ItemQuery"
51  import="net.sf.basedb.core.ItemResultList"
52  import="net.sf.basedb.core.Include"
53  import="net.sf.basedb.core.PermissionDeniedException"
54  import="net.sf.basedb.core.PluginDefinition"
55  import="net.sf.basedb.core.plugin.GuiContext"
56  import="net.sf.basedb.core.plugin.Plugin"
57  import="net.sf.basedb.core.query.Orders"
58  import="net.sf.basedb.core.query.Hql"
59  import="net.sf.basedb.clients.web.Base"
60  import="net.sf.basedb.clients.web.PermissionUtil"
61  import="net.sf.basedb.clients.web.util.HTML"
62  import="net.sf.basedb.util.Values"
63  import="java.util.Date"
64  import="java.util.Map"
65  import="java.util.Set"
66  import="java.util.List"
67%>
68<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
69<%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %>
70<%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %>
71<%@ taglib prefix="p" uri="/WEB-INF/path.tld" %>
72<%!
73  private static final Item itemType = Item.RAWBIOASSAY;
74  private static final GuiContext guiContext = new GuiContext(itemType, GuiContext.Type.ITEM);
75%>
76<%
77final String root = request.getContextPath()+"/";
78final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
79final String ID = sc.getId();
80final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
81final int itemId = cc.getId();
82final String tab = Values.getString(request.getParameter("tab"), "properties");
83final float scale = Base.getScale(sc);
84final DbControl dc = sc.newDbControl();
85try
86{
87  Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext);
88
89  String title = null;
90  RawBioAssay rawBioAssay = RawBioAssay.getById(dc, itemId);
91  RawDataType rawDataType = rawBioAssay.getRawDataType();
92 
93  final boolean writePermission = rawBioAssay.hasPermission(Permission.WRITE);
94  final boolean deletePermission = rawBioAssay.hasPermission(Permission.DELETE);
95  final boolean sharePermission = rawBioAssay.hasPermission(Permission.SET_PERMISSION);
96  final boolean setOwnerPermission = rawBioAssay.hasPermission(Permission.SET_OWNER);
97  final boolean isOwner = rawBioAssay.isOwner();
98  %>
99
100  <base:page title="<%=title%>">
101  <base:head scripts="table.js,tabcontrol.js" styles="table.css,toolbar.css,headertabcontrol.css,path.css">
102    <script language="JavaScript">
103    function editItem()
104    {
105      Main.viewOrEditItem('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>, true);
106    }
107    function shareItem()
108    {
109      Main.openPopup('index.jsp?ID=<%=ID%>&cmd=ShareItem&item_id=<%=itemId%>', 'ShareRawBioAssay', 500, 400);
110    }
111    function deleteItem()
112    {
113      location.replace('index.jsp?ID=<%=ID%>&cmd=DeleteItem&item_id=<%=itemId%>');
114    }
115    function restoreItem()
116    {
117      location.replace('index.jsp?ID=<%=ID%>&cmd=RestoreItem&item_id=<%=itemId%>');
118    }
119    function takeOwnership()
120    {
121      if (confirm('Are you sure that you want to take ownership of this item? It can\'t be undone.'))
122      {
123        location.replace('index.jsp?ID=<%=ID%>&cmd=TakeOwnershipOfItem&item_id=<%=itemId%>');
124      }
125    }
126    function runPlugin(cmd)
127    {
128      Main.openPopup('index.jsp?ID=<%=ID%>&cmd='+cmd+'&item_id=<%=itemId%>', 'RunPlugin'+cmd, 740, 540);
129    }
130    function viewRawData()
131    {
132      location.href = 'rawdata/index.jsp?ID=<%=ID%>&cmd=List&rawbioassay_id=<%=itemId%>';
133    }
134    function editSpotImages()
135    {
136      Main.openPopup('index.jsp?ID=<%=ID%>&cmd=EditSpotImages&item_id=<%=itemId%>', 'EditSpotImages', 540, 460);
137    }
138    function switchTab(tabControlId, tabId)
139    {
140      if (tabId == 'rawdata')
141      {
142        viewRawData();
143      }
144      else
145      {
146        TabControl.setActiveTab(tabControlId, tabId);
147      }
148    }
149    </script>
150  </base:head>
151  <base:body>
152    <p>
153    <p:path>
154      <p:pathelement title="Raw bioassays" href="<%="index.jsp?ID="+ID%>" />
155      <p:pathelement title="<%=HTML.encodeTags(rawBioAssay.getName())%>" />
156    </p:path>
157   
158    <t:tabcontrol id="main" active="<%=tab%>" switch="switchTab">
159    <t:tab id="properties" title="Properties">
160   
161    <tbl:toolbar
162      >
163      <tbl:button 
164        disabled="<%=writePermission ? false : true%>" 
165        image="<%=writePermission ? "edit.gif" : "edit_disabled.gif"%>" 
166        onclick="editItem()" 
167        title="Edit&hellip;" 
168        tooltip="<%=writePermission ? "Edit this raw bioassay" : "You do not have permission to edit this raw bioassay"%>" 
169      />
170      <tbl:button 
171        disabled="<%=deletePermission ? false : true%>" 
172        image="<%=deletePermission ? "delete.gif" : "delete_disabled.gif"%>" 
173        onclick="deleteItem()" 
174        title="Delete"
175        visible="<%=!rawBioAssay.isRemoved()%>"
176        tooltip="<%=deletePermission ? "Delete this raw bioassay" : "You do not have permission to delete this rawbioassay"%>" 
177      />
178      <tbl:button 
179        disabled="<%=writePermission ? false : true%>" 
180        image="<%=writePermission ? "restore.gif" : "restore_disabled.gif"%>" 
181        onclick="restoreItem()" 
182        title="Restore"
183        visible="<%=rawBioAssay.isRemoved()%>"
184        tooltip="<%=writePermission ? "Restore this raw bioassay" : "You do not have permission to restore this rawbioassay"%>" 
185      />
186      <tbl:button 
187        disabled="<%=sharePermission ? false : true%>"
188        image="<%=sharePermission ? "share.gif" : "share_disabled.gif"%>"
189        onclick="shareItem()" 
190        title="Share&hellip;" 
191        tooltip="<%=sharePermission ? "Share this raw bioassay to other user, groups and projects" : "You do not have permission to share this raw bioassay"%>"
192      />
193      <tbl:button 
194        disabled="<%=setOwnerPermission ? false : true%>"
195        image="<%=setOwnerPermission ? "take_ownership.png" : "take_ownership_disabled.png"%>"
196        onclick="takeOwnership()" 
197        title="Take ownership&hellip;"
198        visible="<%=!isOwner%>"
199        tooltip="<%=setOwnerPermission ? "Take ownership of this item" : "You do not have permission to take ownership of this item"%>"
200      />
201      <tbl:button 
202        image="import.gif" 
203        onclick="runPlugin('ImportItem')" 
204        title="Import&hellip;" 
205        tooltip="Import data" 
206        visible="<%=pluginCount.containsKey(Plugin.MainType.IMPORT)%>"
207      />
208      <tbl:button 
209        image="export.gif" 
210        onclick="runPlugin('ExportItem')" 
211        title="Export&hellip;" 
212        tooltip="Export data" 
213        visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>"
214      />
215      <tbl:button 
216        image="runplugin.gif" 
217        onclick="runPlugin('RunPlugin')" 
218        title="Run plugin&hellip;" 
219        tooltip="Run a plugin" 
220        visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>"
221      />
222      <tbl:button
223        onclick="editSpotImages()"
224        image="runplugin.gif" 
225        title="Create spot images&hellip;"
226        visible="<%=writePermission && (rawBioAssay.getSpots() > 0) && rawDataType.isStoredInDb()%>"
227      />
228      <tbl:button
229        image="help.gif"
230        onclick="<%="Main.openHelp('" + ID +"', 'rawbioassay.view.properties')"%>"
231        title="Help&hellip;"
232        tooltip="Get help about this page"
233      />
234      </tbl:toolbar>
235    <div class="boxedbottom">
236      <div class="itemstatus">Permissions on this item: <i><%=PermissionUtil.getFullPermissionNames(rawBioAssay)%></i></div>
237      <%
238      if (rawBioAssay.isRemoved() || rawBioAssay.isShared())
239      {
240        %>
241        <div class="itemstatus">
242          <base:icon image="deleted.gif" 
243            visible="<%=rawBioAssay.isRemoved()%>"> This item has been flagged for deletion<br></base:icon>
244          <base:icon image="shared.gif" 
245            visible="<%=rawBioAssay.isShared()%>"> This item is shared to other user, groups and/or projects</base:icon>
246        </div>
247        <%
248      }
249      %>
250     
251      <table width="100%">
252      <tr valign="top">
253      <td>
254     
255      <table class="form" cellspacing=0>
256      <tr>
257        <td class="prompt">Name</td>
258        <td><%=HTML.encodeTags(rawBioAssay.getName())%></td>
259      </tr>
260      <tr>
261        <td class="prompt">Raw data type</td>
262        <td><%=HTML.encodeTags(rawDataType.getName())%></td>
263      </tr>
264      <tr>
265        <td class="prompt">Has data</td>
266        <td><%=rawBioAssay.hasData() ? "yes" : "no" %></td>
267      </tr>
268      <tr>
269        <td class="prompt">Spots</td>
270        <td><%=rawBioAssay.getSpots()%></td>
271      </tr>
272      <%
273      if (rawDataType.isAffymetrix())
274      {
275        boolean readCurrentCelFile = true;
276        File currentCelFile = null; 
277        try
278        {
279          currentCelFile = Affymetrix.getCelFile(rawBioAssay);
280        }
281        catch (PermissionDeniedException ex)
282        {
283          readCurrentCelFile = false;
284        }
285        %>
286        <tr>
287          <td class="prompt">CEL file</td>
288          <td><%=Base.getLinkedFile(ID, currentCelFile, !readCurrentCelFile, true, true, root)%></td>
289        </tr>
290        <%
291      }
292      %>
293      <tr>
294        <td class="prompt">Protocol</td>
295        <td><base:propertyvalue item="<%=rawBioAssay%>" property="protocol" /></td>
296      </tr>
297      <tr>
298        <td class="prompt">Scan</td>
299        <td><base:propertyvalue item="<%=rawBioAssay%>" property="scan" /></td>
300      </tr>
301      <tr>
302        <td class="prompt">Software</td>
303        <td><base:propertyvalue item="<%=rawBioAssay%>" property="software" /></td>
304      </tr>
305      <tr>
306        <td class="prompt">Array design</td>
307        <td><base:propertyvalue item="<%=rawBioAssay%>" property="arrayDesign" /></td>
308      </tr>
309      <tr>
310        <td class="prompt">Owner</td>
311        <td><base:propertyvalue item="<%=rawBioAssay%>" property="owner" /></td>
312      </tr>
313      <tr>
314        <td class="prompt">Description</td>
315        <td><%=HTML.niceFormat(rawBioAssay.getDescription())%></td>
316      </tr>
317      </table>
318     
319      </td>
320      <td>
321      <h4>Spot images</h4>
322      <%
323      if (!rawBioAssay.hasSpotImages())
324      {
325        %>
326        No spot images has been created for this raw bioassay.
327        <%
328      }
329      else
330      {
331        SpotImages spi = rawBioAssay.getSpotImages();
332        %>
333        <table class="form" cellspacing=0>
334        <tr>
335          <td class="prompt">X scale</td>
336          <td><%=spi.getXScale()%></td>
337          <td>&nbsp;&nbsp;</td>
338          <td class="prompt">Spot size</td>
339          <td><%=spi.getSpotsize()%></td>
340        </tr>
341        <tr>
342          <td class="prompt">Y scale</td>
343          <td><%=spi.getYScale()%></td>
344          <td>&nbsp;&nbsp;</td>
345          <td class="prompt">Gamma correction</td>
346          <td><%=spi.getGamma()%></td>
347        </tr>
348        <tr>
349          <td class="prompt">X offset</td>
350          <td><%=spi.getXOffset()%></td>
351          <td>&nbsp;&nbsp;</td>
352          <td class="prompt">Quality</td>
353          <td><%=spi.getQuality()%></td>
354        </tr>
355        <tr>
356          <td class="prompt">Y offset</td>
357          <td><%=spi.getYOffset()%></td>
358        </tr>
359        <tr>
360          <td class="prompt">Red image file</td>
361          <td><base:propertyvalue item="<%=spi%>" property="redImageFile" /></td>
362        </tr>
363        <tr>
364          <td class="prompt">Green image file</td>
365          <td><base:propertyvalue item="<%=spi%>" property="greenImageFile" /></td>
366        </tr>
367        <tr>
368          <td class="prompt">Blue image file</td>
369          <td><base:propertyvalue item="<%=spi%>" property="blueImageFile" /></td>
370        </tr>
371        <tr>
372          <td class="prompt">Spot images file</td>
373          <td><base:propertyvalue item="<%=spi%>" property="spotImagesFile" /></td>
374        </tr>
375        </table>
376        <%
377      }
378      %>
379
380      </td>
381      </tr>
382      </table>
383     
384      <h4>Raw data headers</h4>
385      <table class="form" cellspacing=0>
386      <%
387      Set<String> names = rawBioAssay.getHeaderNames();
388      boolean needsTr = true;
389      if (names != null)
390      {
391        for (String name : names)
392        {
393          %>
394          <%=needsTr ? "<tr valign=\"top\">" : "" %>
395            <td class="prompt"><%=HTML.encodeTags(name)%></td>
396            <td><%=HTML.encodeTags(rawBioAssay.getHeader(name))%></td>
397            <td>&nbsp;&nbsp;</td>
398          <%=needsTr ? "" : "</tr>"%>
399          <%
400          needsTr = !needsTr;
401        }
402        %>
403        <%=needsTr ? "" : "</tr>"%>
404        <%
405      }
406      %>
407      </table>
408
409      <%
410      ItemQuery<Experiment> experimentQuery = rawBioAssay.getExperiments();
411      experimentQuery.include(Include.MINE, Include.SHARED, Include.OTHERS, Include.IN_PROJECT);
412      experimentQuery.order(Orders.asc(Hql.property("name")));
413      ItemResultList<Experiment> experiments = experimentQuery.list(dc);
414      if (experiments.size() == 0)
415      {
416        %>
417        <h4>Experiments</h4>
418        This raw bioassay isn't used in any experiments
419        (or, you don't have permission to view them).
420        <%
421      }
422      else
423      {
424        %>
425        <h4 class="docked">Experiments</h4>
426        <tbl:table
427          id="experiments"
428          clazz="itemlist"
429          columns="all"
430          >
431        <tbl:columndef 
432          id="name"
433          title="Name"
434        />
435        <tbl:columndef 
436          id="description"
437          title="Description"
438        />
439        <tbl:data>
440          <tbl:columns>
441          </tbl:columns>
442          <tbl:rows>
443          <%
444          for (Experiment item : experiments)
445          {
446            %>
447            <tbl:row>
448              <tbl:cell column="name"><%=Base.getLinkedName(ID, item, false, true)%></tbl:cell>
449              <tbl:cell column="description"><%=HTML.encodeTags(item.getDescription())%></tbl:cell>
450            </tbl:row>
451            <%
452          }
453          %>
454          </tbl:rows>
455        </tbl:data>
456        </tbl:table>
457        <%
458      }
459      %>
460      </div>
461      </t:tab>
462     
463      <t:tab id="annotations" title="Annotations &amp; parameters" 
464        tooltip="View annotation values and protocol parameters">
465        <div class="boxed">
466        <jsp:include page="../../common/annotations/list_annotations.jsp">
467          <jsp:param name="item_type" value="<%=itemType.name()%>" />
468          <jsp:param name="item_id" value="<%=itemId%>" />
469          <jsp:param name="ID" value="<%=ID%>" />
470        </jsp:include>
471        </div>
472      </t:tab>
473     
474      <t:tab id="rawdata" title="Raw data" visible="<%=rawBioAssay.getSpots() > 0 && rawDataType.isStoredInDb() %>" />
475      </t:tabcontrol>
476
477  </base:body>
478  </base:page>
479  <%
480}
481finally
482{
483  if (dc != null) dc.close();
484}
485
486%>
Note: See TracBrowser for help on using the repository browser.