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

Last change on this file since 5064 was 5064, checked in by Nicklas Nordborg, 14 years ago

References #108: Logging the change history of an item

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