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

Last change on this file since 2414 was 2414, checked in by Nicklas Nordborg, 16 years ago

Use <base:propertyvalue> tag instead of lots of try-catch code.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 11.9 KB
Line 
1<%-- $Id: view_hybridization.jsp 2414 2006-06-22 09:10:41Z 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.clients.web.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
92  %>
93
94  <base:page title="<%=title%>">
95  <base:head scripts="table.js,tabcontrol.js" styles="toolbar.css,table.css,headertabcontrol.css,path.css">
96    <script language="JavaScript">
97    function editItem()
98    {
99      Main.viewOrEditItem('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>, true);
100    }
101    function shareItem()
102    {
103      Main.openPopup('index.jsp?ID=<%=ID%>&cmd=ShareItem&item_id=<%=itemId%>', 'ShareHybridization', 500, 400);
104    }
105    function deleteItem()
106    {
107      location.replace('index.jsp?ID=<%=ID%>&cmd=DeleteItem&item_id=<%=itemId%>');
108    }
109    function restoreItem()
110    {
111      location.replace('index.jsp?ID=<%=ID%>&cmd=RestoreItem&item_id=<%=itemId%>');
112    }
113    function runPlugin(cmd)
114    {
115      Main.openPopup('index.jsp?ID=<%=ID%>&cmd='+cmd+'&item_id=<%=itemId%>', 'RunPlugin'+cmd, 740, 540);
116    }
117    function newScan()
118    {
119      Main.viewOrEditItem('<%=ID%>', 'SCAN', 0, true, '&hybridization_id=<%=itemId%>');
120    }
121    </script>
122  </base:head>
123  <base:body>
124    <p>
125    <p:path>
126      <p:pathelement title="Hybridizations" href="<%="index.jsp?ID="+ID%>" />
127      <p:pathelement title="<%=HTML.encodeTags(hyb.getName())%>" />
128    </p:path>
129   
130    <t:tabcontrol id="main" active="<%=tab%>" >
131    <t:tab id="properties" title="Properties">
132   
133    <tbl:toolbar
134      >
135      <tbl:button 
136        disabled="<%=writePermission ? false : true%>" 
137        image="<%=writePermission ? "edit.gif" : "edit_disabled.gif"%>" 
138        onclick="editItem()" 
139        title="Edit&hellip;" 
140        tooltip="<%=writePermission ? "Edit this hybridization" : "You do not have permission to edit this hybridization"%>" 
141      />
142      <tbl:button 
143        disabled="<%=deletePermission ? false : true%>" 
144        image="<%=deletePermission ? "delete.gif" : "delete_disabled.gif"%>" 
145        onclick="deleteItem()" 
146        title="Delete"
147        visible="<%=!hyb.isRemoved()%>"
148        tooltip="<%=deletePermission ? "Delete this hybridization" : "You do not have permission to delete this hybridization"%>" 
149      />
150      <tbl:button 
151        disabled="<%=writePermission ? false : true%>" 
152        image="<%=writePermission ? "restore.gif" : "restore_disabled.gif"%>" 
153        onclick="restoreItem()" 
154        title="Restore"
155        visible="<%=hyb.isRemoved()%>"
156        tooltip="<%=writePermission ? "Restore this hybridization" : "You do not have permission to restore this hybridization"%>" 
157      />
158      <tbl:button 
159        disabled="<%=sharePermission ? false : true%>"
160        image="<%=sharePermission ? "share.gif" : "share_disabled.gif"%>"
161        onclick="shareItem()" 
162        title="Share&hellip;" 
163        tooltip="<%=sharePermission ? "Share this hybridization to other user, groups and projects" : "You do not have permission to share this hybridization"%>"
164      />
165      <tbl:button
166        image="add.png"
167        onclick="newScan()"
168        title="New scan&hellip;"
169        tooltip="Create a new scan from this hybridization"
170        visible="<%=sc.hasPermission(Permission.CREATE, Item.SCAN) && usePermission%>"
171      />
172      <tbl:button 
173        image="import.gif" 
174        onclick="runPlugin('ImportItem')" 
175        title="Import&hellip;" 
176        tooltip="Import data" 
177        visible="<%=pluginCount.containsKey(Plugin.MainType.IMPORT)%>"
178      />
179      <tbl:button 
180        image="export.gif" 
181        onclick="runPlugin('ExportItem')" 
182        title="Export&hellip;" 
183        tooltip="Export data" 
184        visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>"
185      />
186      <tbl:button 
187        image="runplugin.gif" 
188        onclick="runPlugin('RunPlugin')" 
189        title="Run plugin&hellip;" 
190        tooltip="Run a plugin" 
191        visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>"
192      />
193      <tbl:button
194        image="help.gif"
195        onclick="<%="Main.openHelp('" + ID +"', 'hybridization.view.properties')"%>"
196        title="Help&hellip;"
197        tooltip="Get help about this page"
198      />
199      </tbl:toolbar>
200    <div class="boxedbottom">
201      <div class="itemstatus">Permissions on this item: <i><%=PermissionUtil.getFullPermissionNames(hyb)%></i></div>
202      <%
203      if (hyb.isRemoved() || hyb.isShared())
204      {
205        %>
206        <div class="itemstatus">
207          <base:icon image="deleted.gif" 
208            visible="<%=hyb.isRemoved()%>"> This item has been flagged for deletion<br></base:icon>
209          <base:icon image="shared.gif" 
210            visible="<%=hyb.isShared()%>"> This item is shared to other user, groups and/or projects</base:icon>
211        </div>
212        <%
213      }
214      %>
215      <table class="form" cellspacing=0>
216      <tr>
217        <td class="prompt">Name</td>
218        <td><%=HTML.encodeTags(hyb.getName())%></td>
219      </tr>
220      <tr>
221        <td class="prompt">Array slide</td>
222        <td><base:propertyvalue item="<%=hyb%>" property="arraySlide" /></td>
223      </tr>
224      <tr>
225        <td class="prompt">Created</td>
226        <td><%=Values.formatDate(creationEvent.getEventDate())%></td>
227      </tr>
228      <tr>
229        <td class="prompt">Registered</td>
230        <td><%=Values.formatDate(creationEvent.getEntryDate())%></td>
231      </tr>
232      <tr>
233        <td class="prompt">Protocol</td>
234        <td><base:propertyvalue item="<%=hyb%>" property="protocol" /></td>
235      </tr>
236      <tr>
237        <td class="prompt">Owner</td>
238        <td><base:propertyvalue item="<%=hyb%>" property="owner" /></td>
239      </tr>
240      <tr>
241        <td class="prompt">Description</td>
242        <td><%=HTML.niceFormat(hyb.getDescription())%></td>
243      </tr>
244      </table>
245     
246      <%
247      ItemQuery<LabeledExtract> labeledExtractsQuery = (ItemQuery<LabeledExtract>)creationEvent.getSources();
248      labeledExtractsQuery.include(Include.MINE, Include.SHARED, Include.OTHERS, Include.IN_PROJECT);
249      labeledExtractsQuery.order(Orders.asc(Hql.property("name")));
250      ItemResultList<LabeledExtract> labeledExtracts = labeledExtractsQuery.list(dc);
251      if (labeledExtracts.size() == 0)
252      {
253        %>
254        <h4>Labeled extracts</h4>
255        No labeled extracts has been added to this hybridization
256        (or, you don't have permission to view them).
257        <%
258      }
259      else
260      {
261        %>
262        <h4 class="docked">Labeled extracts</h4>
263        <tbl:table
264          id="labeledextracts"
265          clazz="itemlist"
266          columns="all"
267          >
268        <tbl:columndef 
269          id="name"
270          title="Name"
271        />
272        <tbl:columndef 
273          id="label"
274          title="Label"
275        />
276        <tbl:columndef 
277          id="quantity"
278          title="Used quantity (µg)"
279        />
280        <tbl:columndef 
281          id="description"
282          title="Description"
283        />
284        <tbl:data>
285          <tbl:columns>
286          </tbl:columns>
287          <tbl:rows>
288          <%
289          for (LabeledExtract item : labeledExtracts)
290          {
291            %>
292            <tbl:row>
293              <tbl:cell column="name"><%=Base.getLinkedName(ID, item, false, true)%></tbl:cell>
294              <tbl:cell column="label"><base:propertyvalue item="<%=item%>" property="label" /></tbl:cell>
295              <tbl:cell column="quantity"><%=Values.formatNumber(creationEvent.getUsedQuantity(item), 2)%></tbl:cell>
296              <tbl:cell column="description"><%=HTML.encodeTags(item.getDescription())%></tbl:cell>
297            </tbl:row>
298            <%
299          }
300          %>
301          </tbl:rows>
302        </tbl:data>
303        </tbl:table>
304        <%
305      }
306      %>
307     
308      <%
309      ItemQuery<Scan> scanQuery = (ItemQuery<Scan>)hyb.getScans();
310      scanQuery.include(Include.MINE, Include.SHARED, Include.OTHERS, Include.IN_PROJECT);
311      scanQuery.order(Orders.asc(Hql.property("name")));
312      ItemResultList<Scan> scans = scanQuery.list(dc);
313      if (scans.size() == 0)
314      {
315        %>
316        <h4>Scans</h4>
317        No scans has been created from this hybridization
318        (or, you don't have permission to view them).
319        <%
320      }
321      else
322      {
323        %>
324        <h4 class="docked">Scans</h4>
325        <tbl:table
326          id="scans"
327          clazz="itemlist"
328          columns="all"
329          >
330        <tbl:columndef 
331          id="name"
332          title="Name"
333        />
334        <tbl:columndef 
335          id="scanner"
336          title="Scanner"
337        />
338
339        <tbl:columndef 
340          id="description"
341          title="Description"
342        />
343        <tbl:data>
344          <tbl:columns>
345          </tbl:columns>
346          <tbl:rows>
347          <%
348          for (Scan item : scans)
349          {
350            %>
351            <tbl:row>
352              <tbl:cell column="name"><%=Base.getLinkedName(ID, item, false, true)%></tbl:cell>
353              <tbl:cell column="scanner"><base:propertyvalue item="<%=item%>" property="scanner" /></tbl:cell>
354              <tbl:cell column="description"><%=HTML.encodeTags(item.getDescription())%></tbl:cell>
355            </tbl:row>
356            <%
357          }
358          %>
359          </tbl:rows>
360        </tbl:data>
361        </tbl:table>
362        <%
363      }
364      %>
365     
366    </div>
367      </t:tab>
368     
369      <t:tab id="annotations" title="Annotations" >
370        <div class="boxed">
371        <jsp:include page="../../common/annotations/list_annotations.jsp">
372          <jsp:param name="item_type" value="<%=itemType.name()%>" />
373          <jsp:param name="item_id" value="<%=itemId%>" />
374          <jsp:param name="ID" value="<%=ID%>" />
375        </jsp:include>
376        </div>
377      </t:tab>
378      </t:tabcontrol>
379
380  </base:body>
381  </base:page>
382  <%
383}
384finally
385{
386  if (dc != null) dc.close();
387}
388
389%>
Note: See TracBrowser for help on using the repository browser.