source: trunk/www/views/scans/view_scan.jsp @ 5045

Last change on this file since 5045 was 5045, checked in by Martin Svensson, 14 years ago

Fixes #360 Make subsections on view pages hideable.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 17.8 KB
Line 
1<%-- $Id: view_scan.jsp 5045 2009-08-12 07:42:51Z martin $
2  ------------------------------------------------------------------
3  Copyright (C) 2006 Jari Häkkinen, Nicklas Nordborg, Martin Svensson
4  Copyright (C) 2007 Martin Svensson
5
6  This file is part of BASE - BioArray Software Environment.
7  Available at http://base.thep.lu.se/
8
9  BASE is free software; you can redistribute it and/or
10  modify it under the terms of the GNU General Public License
11  as published by the Free Software Foundation; either version 3
12  of the License, or (at your option) any later version.
13
14  BASE is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  GNU General Public License for more details.
18
19  You should have received a copy of the GNU General Public License
20  along with BASE. If not, see <http://www.gnu.org/licenses/>.
21  ------------------------------------------------------------------
22
23  @author Nicklas
24  @version 2.0
25--%>
26<%@ page session="false"
27  import="net.sf.basedb.core.SessionControl"
28  import="net.sf.basedb.core.DbControl"
29  import="net.sf.basedb.core.SystemItems"
30  import="net.sf.basedb.core.Item"
31  import="net.sf.basedb.core.ItemContext"
32  import="net.sf.basedb.core.Permission"
33  import="net.sf.basedb.core.AnnotationType"
34  import="net.sf.basedb.core.AnnotationSet"
35  import="net.sf.basedb.core.Scan"
36  import="net.sf.basedb.core.RawBioAssay"
37  import="net.sf.basedb.core.Protocol"
38  import="net.sf.basedb.core.Hardware"
39  import="net.sf.basedb.core.Hybridization"
40  import="net.sf.basedb.core.User"
41  import="net.sf.basedb.core.Group"
42  import="net.sf.basedb.core.ItemQuery"
43  import="net.sf.basedb.core.ItemResultList"
44  import="net.sf.basedb.core.Include"
45  import="net.sf.basedb.core.MultiPermissions"
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.core.Project"
51  import="net.sf.basedb.core.query.Orders"
52  import="net.sf.basedb.core.query.Hql"
53  import="net.sf.basedb.clients.web.Base"
54  import="net.sf.basedb.clients.web.PermissionUtil"
55  import="net.sf.basedb.clients.web.util.HTML"
56  import="net.sf.basedb.util.Values"
57  import="net.sf.basedb.util.formatter.Formatter"
58  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
59  import="net.sf.basedb.clients.web.extensions.ExtensionsControl"
60  import="net.sf.basedb.clients.web.extensions.JspContext"
61  import="net.sf.basedb.clients.web.extensions.renderer.PrefixSuffixRenderer"
62  import="net.sf.basedb.clients.web.extensions.toolbar.ToolbarUtil"
63  import="net.sf.basedb.util.extensions.ExtensionsInvoker"
64  import="java.util.Collections"
65  import="java.util.Date"
66  import="java.util.Map"
67  import="java.util.Set"
68  import="java.util.List"
69%>
70<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
71<%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %>
72<%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %>
73<%@ taglib prefix="p" uri="/WEB-INF/path.tld" %>
74<%@ taglib prefix="ext" uri="/WEB-INF/extensions.tld" %>
75<%!
76  private static final Item itemType = Item.SCAN;
77  private static final GuiContext guiContext = new GuiContext(itemType, GuiContext.Type.ITEM);
78%>
79<%
80final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
81final String ID = sc.getId();
82final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
83final int itemId = cc.getId();
84final String tab = Values.getString(request.getParameter("tab"), "properties");
85final float scale = Base.getScale(sc);
86final DbControl dc = sc.newDbControl();
87try
88{
89  Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc);
90  Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext);
91
92  String title = null;
93  Scan scan = Scan.getById(dc, itemId);
94 
95  final boolean usePermission = scan.hasPermission(Permission.USE);
96  final boolean writePermission = scan.hasPermission(Permission.WRITE);
97  final boolean deletePermission = scan.hasPermission(Permission.DELETE);
98  final boolean sharePermission = scan.hasPermission(Permission.SET_PERMISSION);
99  final boolean setOwnerPermission = scan.hasPermission(Permission.SET_OWNER);
100  final boolean isRemoved = scan.isRemoved();
101  final boolean isUsed = isRemoved && scan.isUsed();
102  final boolean deletePermanentlyPermission = deletePermission && !isUsed;
103  final boolean isOwner = scan.isOwner();
104  JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, guiContext, scan);
105  ExtensionsInvoker invoker = ToolbarUtil.useExtensions(jspContext);
106  %>
107  <base:page title="<%=title%>">
108  <base:head scripts="table.js,tabcontrol.js" styles="table.css,toolbar.css,headertabcontrol.css,path.css">
109    <ext:scripts context="<%=jspContext%>" />
110    <ext:stylesheets context="<%=jspContext%>" />
111    <script language="JavaScript">
112    function editItem()
113    {
114      Main.viewOrEditItem('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>, true);
115    }
116    function shareItem()
117    {
118      Main.openPopup('index.jsp?ID=<%=ID%>&cmd=ShareItem&item_id=<%=itemId%>', 'ShareScan', 600, 400);
119    }
120    function deleteItem()
121    {
122      location.replace('index.jsp?ID=<%=ID%>&cmd=DeleteItem&item_id=<%=itemId%>');
123    }
124    function restoreItem()
125    {
126      location.replace('index.jsp?ID=<%=ID%>&cmd=RestoreItem&item_id=<%=itemId%>');
127    }
128    function deleteItemPermanently()
129    {
130      Main.deleteItemPermanently('<%=ID%>', true, '<%=itemType.name()%>', <%=itemId%>, '&callback=itemDeleted');
131    }
132    function itemDeleted()
133    {
134      Main.listItems('<%=ID%>', '<%=itemType.name()%>');
135    }
136    function showUsingItems()
137    {
138      Main.showUsingItems('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>);
139    }
140    function setOwner()
141    {
142      Main.openPopup('index.jsp?ID=<%=ID%>&cmd=SetOwnerOfItem&item_id=<%=itemId%>', 'SetOwnerOfItem', 450, 150);
143    }
144    function runPlugin(cmd)
145    {
146      Main.openPopup('index.jsp?ID=<%=ID%>&cmd='+cmd+'&item_id=<%=itemId%>', 'RunPlugin'+cmd, 740, 540);
147    }
148    function viewImages()
149    {
150      location.href = 'images/index.jsp?ID=<%=ID%>&cmd=List&scan_id=<%=itemId%>';
151    }
152    function switchTab(tabControlId, tabId)
153    {
154      if (TabControl.isActive(tabControlId, tabId)) return;
155      if (tabId == 'overview' && tabId != '<%=tab%>')
156      {
157        location.href = 'index.jsp?ID=<%=ID%>&cmd=ViewItem&item_id=<%=itemId%>&tab='+tabId;
158      }
159      else if (tabId == 'images')
160      {
161        viewImages();
162      }
163      else
164      {
165        TabControl.setActiveTab(tabControlId, tabId);
166      }
167    }
168    function newRawBioAssay()
169    {
170      Main.viewOrEditItem('<%=ID%>', 'RAWBIOASSAY', 0, true, '&scan_id=<%=itemId%>');
171    }
172    </script>
173  </base:head>
174  <base:body>
175    <p>
176    <p:path>
177      <p:pathelement title="Scans" href="<%="index.jsp?ID="+ID%>" />
178      <p:pathelement title="<%=HTML.encodeTags(scan.getName())%>" />
179    </p:path>
180   
181    <t:tabcontrol id="main" active="<%=tab%>" switch="switchTab" remember="false">
182    <t:tab id="properties" title="Properties">
183
184    <tbl:toolbar
185      >
186      <tbl:button 
187        disabled="<%=writePermission ? false : true%>" 
188        image="<%=writePermission ? "edit.gif" : "edit_disabled.gif"%>" 
189        onclick="editItem()" 
190        title="Edit&hellip;" 
191        tooltip="<%=writePermission ? "Edit this scan" : "You do not have permission to edit this scan"%>" 
192      />
193      <tbl:button 
194        disabled="<%=deletePermission ? false : true%>" 
195        image="<%=deletePermission ? "delete.gif" : "delete_disabled.gif"%>" 
196        onclick="deleteItem()" 
197        title="Delete"
198        visible="<%=!scan.isRemoved()%>"
199        tooltip="<%=deletePermission ? "Delete this scan" : "You do not have permission to delete this scan"%>" 
200      />
201      <tbl:button 
202        disabled="<%=writePermission ? false : true%>" 
203        image="<%=writePermission ? "restore.gif" : "restore_disabled.gif"%>" 
204        onclick="restoreItem()" 
205        title="Restore"
206        visible="<%=scan.isRemoved()%>"
207        tooltip="<%=writePermission ? "Restore this scan" : "You do not have permission to restore this scan"%>" 
208      />
209      <tbl:button 
210        disabled="<%=sharePermission ? false : true%>"
211        image="<%=sharePermission ? "share.gif" : "share_disabled.gif"%>"
212        onclick="shareItem()" 
213        title="Share&hellip;" 
214        tooltip="<%=sharePermission ? "Share this scan to other user, groups and projects" : "You do not have permission to share this scan"%>"
215      />
216      <tbl:button 
217        disabled="<%=setOwnerPermission ? false : true%>"
218        image="<%=setOwnerPermission ? "take_ownership.png" : "take_ownership_disabled.png"%>"
219        onclick="setOwner()" 
220        title="Set owner&hellip;"
221        tooltip="<%=setOwnerPermission ? "Change owner of this item" : "You do not have permission to change ownership of this item"%>"
222      />
223      <tbl:button
224        image="add.png"
225        onclick="newRawBioAssay()"
226        title="New raw bioassay&hellip;"
227        tooltip="Create a new raw bioassay from this scan"
228        visible="<%=sc.hasPermission(Permission.CREATE, Item.RAWBIOASSAY) && usePermission%>"
229      />
230      <tbl:button 
231        image="import.gif" 
232        onclick="runPlugin('ImportItem')" 
233        title="Import&hellip;" 
234        tooltip="Import data" 
235        visible="<%=pluginCount.containsKey(Plugin.MainType.IMPORT)%>"
236      />
237      <tbl:button 
238        image="export.gif" 
239        onclick="runPlugin('ExportItem')" 
240        title="Export&hellip;" 
241        tooltip="Export data" 
242        visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>"
243      />
244      <tbl:button 
245        image="runplugin.gif" 
246        onclick="runPlugin('RunPlugin')" 
247        title="Run plugin&hellip;" 
248        tooltip="Run a plugin" 
249        visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>"
250      />
251      <ext:render extensions="<%=invoker%>" context="<%=jspContext%>" 
252        wrapper="<%=new PrefixSuffixRenderer(jspContext, "<td>", "</td>") %>"/>
253      <tbl:button
254        image="help.gif"
255        onclick="<%="Main.openHelp('" + ID +"', 'scan.view.properties')"%>"
256        title="Help&hellip;"
257        tooltip="Get help about this page"
258      />
259      </tbl:toolbar>
260    <div class="boxedbottom">
261      <div class="itemstatus">Permissions on this item: <i><%=PermissionUtil.getFullPermissionNames(scan)%></i></div>
262      <%
263      if (scan.isRemoved() || scan.isShared())
264      {
265        %>
266        <div class="itemstatus">
267          <base:icon 
268            image="<%=deletePermanentlyPermission ? "deleted.gif" : "deleted_disabled.gif"%>"
269            onclick="<%=deletePermanentlyPermission ? "deleteItemPermanently()" : null%>"
270            tooltip="<%=deletePermanentlyPermission ? "Permanently delete this item" : null%>"
271            visible="<%=isRemoved%>"> This item has been flagged for deletion<br></base:icon>
272          <base:icon image="used.gif" 
273            onclick="showUsingItems()"
274            tooltip="Show the items that are using this one"
275            visible="<%=isUsed%>"> This item is used by other items and can't be permanently deleted<br></base:icon>
276          <base:icon image="shared.gif" 
277            visible="<%=scan.isShared()%>"> This item is shared to other users, groups and/or projects</base:icon>
278        </div>
279        <%
280      }
281      %>
282      <table class="form" cellspacing="0">
283      <tr>
284        <td class="prompt">Name</td>
285        <td><%=HTML.encodeTags(scan.getName())%></td>
286      </tr>
287      <tr>
288        <td class="prompt">Registered</td>
289        <td><%=dateFormatter.format(scan.getEntryDate())%></td>
290      </tr>
291      <tr>
292        <td class="prompt">Hybridization</td>
293        <td><base:propertyvalue item="<%=scan%>" property="hybridization" /></td>
294      </tr>
295      <tr>
296        <td class="prompt">Scanner</td>
297        <td><base:propertyvalue item="<%=scan%>" property="scanner" /></td>
298      </tr>
299      <tr>
300        <td class="prompt">Protocol</td>
301        <td><base:propertyvalue item="<%=scan%>" property="protocol" /></td>
302      </tr>
303      <tr>
304        <td class="prompt">Owner</td>
305        <td><base:propertyvalue item="<%=scan%>" property="owner" /></td>
306      </tr>
307      <tr>
308        <td class="prompt">Description</td>
309        <td><%=HTML.niceFormat(scan.getDescription())%></td>
310      </tr>
311      </table>
312 
313      <%
314      ItemQuery<RawBioAssay> rawQuery = scan.getRawBioAssays();
315      rawQuery.include(Include.ALL);
316      rawQuery.order(Orders.asc(Hql.property("name")));
317      ItemResultList<RawBioAssay> raw = rawQuery.list(dc);
318      if (raw.size() == 0)
319      {
320        %>
321        <h4>Raw bioassays</h4>
322        No raw bioassays has been created from this scan
323        (or, you don't have permission to view them).
324        <%
325      }
326      else
327      {
328        %>
329        <base:section
330          id="rawBioAssaySection"
331          title="<%="Raw bioassays (" + raw.size() + ")"%>"
332          context="<%=cc%>"
333          >
334          <tbl:table
335            id="rawBioAssays"
336            clazz="itemlist"
337            columns="all"
338            >
339          <tbl:columndef 
340            id="name"
341            title="Name"
342          />
343          <tbl:columndef
344            id="type"
345            title="Type"
346          />
347          <tbl:columndef 
348            id="arrayNum"
349            title="Array index" 
350          />
351          <tbl:columndef
352            id="software"
353            title="Software"
354          />
355          <tbl:columndef
356            id="data"
357            title="Data"
358          />
359          <tbl:columndef
360            id="arrayDesign"
361            title="Array design"
362          />
363          <tbl:columndef 
364            id="description"
365            title="Description"
366          />
367          <tbl:data>
368            <tbl:columns>
369            </tbl:columns>
370            <tbl:rows>
371            <%
372            for (RawBioAssay item : raw)
373            {
374              %>
375              <tbl:row>
376                <tbl:cell column="name"><base:icon 
377                    image="deleted.gif" 
378                    tooltip="This item has been scheduled for deletion" 
379                    visible="<%=item.isRemoved()%>"
380                  /><%=Base.getLinkedName(ID, item, false, true)%></tbl:cell>
381                <tbl:cell column="type"><%=HTML.encodeTags(item.getRawDataType().getName())%></tbl:cell>
382                <tbl:cell column="arrayNum"><%=item.getArrayNum()%></tbl:cell>
383                <tbl:cell column="software"><base:propertyvalue item="<%=item%>" property="software" /></tbl:cell>
384                <tbl:cell column="data"><%=item.hasData() ? "yes (" + item.getSpots() + " spots)" : "no"%></tbl:cell>
385                <tbl:cell column="arrayDesign"><base:propertyvalue item="<%=item%>" property="arrayDesign" /></tbl:cell>
386                <tbl:cell column="description"><%=HTML.encodeTags(item.getDescription())%></tbl:cell>
387              </tbl:row>
388              <%
389            }
390            %>
391            </tbl:rows>
392          </tbl:data>
393          </tbl:table>
394        </base:section>
395        <%
396      }     
397     
398      // Tables with users/groups/projects that this item is shared to
399      MultiPermissions mp = new MultiPermissions(Collections.singleton(scan));
400      ItemResultList<User> users = mp.getUsers().list(dc);
401      ItemResultList<Group> groups = mp.getGroups().list(dc);
402      ItemResultList<Project> projects = mp.getProjects().list(dc);
403      int totalShare = users.size() + groups.size() + projects.size();
404     
405      if (totalShare > 0)
406      {
407        %>
408        <base:section
409          id="sharedTo"
410          title="<%="Shared to (" + totalShare + ")"%>"
411          context="<%=cc%>"
412          >
413          <tbl:table 
414            id="itemsSharedTo"
415            clazz="itemlist"
416            columns="all"
417          >
418            <tbl:columndef 
419              id="itemType"
420              title="Item type"
421            />
422            <tbl:columndef 
423              id="name"
424              title="Name"
425            />
426            <tbl:columndef 
427              id="permissions"
428              title="Permissions"
429            />
430            <tbl:data>
431              <tbl:columns>
432              </tbl:columns>
433              <tbl:rows>
434              <%
435              for (Project project : projects)
436              {
437                Set<Permission> permissions = mp.getPermissions(project).values().iterator().next();
438                %>     
439                <tbl:row>
440                  <tbl:cell column="itemType"><%=project.getType()%></tbl:cell>
441                  <tbl:cell column="name"><base:icon 
442                    image="deleted.gif" 
443                    tooltip="This item has been scheduled for deletion" 
444                    visible="<%=project.isRemoved()%>"
445                  /><%=Base.getLinkedName(ID, project, false, true)%></tbl:cell>
446                  <tbl:cell column="permissions">
447                    <%=PermissionUtil.translatePermissionsToString(permissions)%>
448                  </tbl:cell>
449                </tbl:row>
450                <%
451              }
452              for (Group group : groups)
453              {
454                Set<Permission> permissions = mp.getPermissions(group).values().iterator().next();
455                %>
456                <tbl:row>             
457                  <tbl:cell column="itemType"><%=group.getType()%></tbl:cell>
458                  <tbl:cell column="name"><base:icon 
459                    image="deleted.gif" 
460                    tooltip="This item has been scheduled for deletion" 
461                    visible="<%=group.isRemoved()%>"
462                  /><%=Base.getLinkedName(ID, group, false, true)%></tbl:cell>
463                  <tbl:cell column="permissions">
464                    <%=PermissionUtil.translatePermissionsToString(permissions)%>
465                  </tbl:cell>
466                </tbl:row>
467                <% 
468              }
469              for (User user : users)
470              {
471                Set<Permission> permissions = mp.getPermissions(user).values().iterator().next();
472                %>
473                <tbl:row>             
474                  <tbl:cell column="itemType"><%=user.getType()%></tbl:cell>
475                  <tbl:cell column="name"><base:icon 
476                    image="deleted.gif" 
477                    tooltip="This item has been scheduled for deletion" 
478                    visible="<%=user.isRemoved()%>"
479                  /><%=Base.getLinkedName(ID, user, false, true)%></tbl:cell>
480                  <tbl:cell column="permissions">
481                    <%=PermissionUtil.translatePermissionsToString(permissions)%>
482                  </tbl:cell>
483                </tbl:row>
484                <%
485              }
486              %>
487              </tbl:rows>
488            </tbl:data>
489          </tbl:table>
490        </base:section>
491        <%
492      }
493      else
494      {
495        %>
496        <h4>Shared to</h4>
497        This scan is not shared
498        (or, you don't have permission to view the ones it is shared to).
499        <%
500      }
501      %>
502 
503    </div>
504      </t:tab>
505     
506      <t:tab id="annotations" title="Annotations &amp; parameters" 
507        tooltip="View annotation values and protocol parameters">
508        <div class="boxed">
509        <jsp:include page="../../common/annotations/list_annotations.jsp">
510          <jsp:param name="item_type" value="<%=itemType.name()%>" />
511          <jsp:param name="item_id" value="<%=itemId%>" />
512          <jsp:param name="ID" value="<%=ID%>" />
513        </jsp:include>
514        </div>
515      </t:tab>
516      <t:tab id="images" title="Images" />
517      <t:tab id="overview" title="Overview" 
518        tooltip="Display a tree overview of related items">
519        <%
520        if ("overview".equals(tab))
521        {
522          %>
523          <jsp:include page="../../common/overview/overview.jsp">
524            <jsp:param name="item_type" value="<%=itemType.name()%>" />
525            <jsp:param name="item_id" value="<%=itemId%>" />
526            <jsp:param name="ID" value="<%=ID%>" />
527          </jsp:include>
528          <%
529        }
530        %>
531      </t:tab>
532      </t:tabcontrol>
533
534
535  </base:body>
536  </base:page>
537  <%
538}
539finally
540{
541  if (dc != null) dc.close();
542}
543
544%>
Note: See TracBrowser for help on using the repository browser.