source: trunk/www/lims/arrayslides/view_slide.jsp @ 5062

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

References #108: Logging the change history of an item

  • Added "Change history" tab to view pages for Array lims items.
  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 15.8 KB
Line 
1<%-- $Id: view_slide.jsp 5062 2009-08-19 09:35:32Z 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.Hybridization"
36  import="net.sf.basedb.core.ArraySlide"
37  import="net.sf.basedb.core.ArrayBatch"
38  import="net.sf.basedb.core.ArrayDesign"
39  import="net.sf.basedb.core.User"
40  import="net.sf.basedb.core.Group"
41  import="net.sf.basedb.core.ItemQuery"
42  import="net.sf.basedb.core.Include"
43  import="net.sf.basedb.core.ItemResultList"
44  import="net.sf.basedb.core.ItemResultList"
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.ARRAYSLIDE;
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  ArraySlide slide = ArraySlide.getById(dc, itemId);
95 
96  final boolean writePermission = slide.hasPermission(Permission.WRITE);
97  final boolean deletePermission = slide.hasPermission(Permission.DELETE);
98  final boolean sharePermission = slide.hasPermission(Permission.SET_PERMISSION);
99  final boolean setOwnerPermission = slide.hasPermission(Permission.SET_OWNER);
100  final boolean isRemoved = slide.isRemoved();
101  final boolean isUsed = isRemoved && slide.isUsed();
102  final boolean deletePermanentlyPermission = deletePermission && !isUsed;
103  final boolean isOwner = slide.isOwner();
104  JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, guiContext, slide);
105  ExtensionsInvoker invoker = ToolbarUtil.useExtensions(jspContext);
106  %>
107  <base:page title="<%=title%>">
108  <base:head scripts="tabcontrol.js,table.js" styles="toolbar.css,table.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%>', 'ShareArraySlide', 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 switchTab(tabControlId, tabId)
149    {
150      if (TabControl.isActive(tabControlId, tabId)) return;
151      if ((tabId == 'overview' || tabId == 'history') && tabId != '<%=tab%>')
152      {
153        location.href = 'index.jsp?ID=<%=ID%>&cmd=ViewItem&item_id=<%=itemId%>&tab='+tabId;
154      }
155      else
156      {
157        TabControl.setActiveTab(tabControlId, tabId);
158      }
159    }
160    </script>
161  </base:head>
162  <base:body>
163    <p>
164    <p:path>
165      <p:pathelement title="Array slides" href="<%="index.jsp?ID="+ID%>" />
166      <p:pathelement title="<%=HTML.encodeTags(slide.getName())%>" />
167    </p:path>
168   
169    <t:tabcontrol id="main" active="<%=tab%>" switch="switchTab" remember="false">
170    <t:tab id="properties" title="Properties">
171    <tbl:toolbar
172      >
173      <tbl:button 
174        disabled="<%=writePermission ? false : true%>" 
175        image="<%=writePermission ? "edit.gif" : "edit_disabled.gif"%>" 
176        onclick="editItem()" 
177        title="Edit&hellip;" 
178        tooltip="<%=writePermission ? "Edit this array slide" : "You do not have permission to edit this array slide"%>" 
179      />
180      <tbl:button 
181        disabled="<%=deletePermission ? false : true%>" 
182        image="<%=deletePermission ? "delete.gif" : "delete_disabled.gif"%>" 
183        onclick="deleteItem()" 
184        title="Delete"
185        visible="<%=!slide.isRemoved()%>"
186        tooltip="<%=deletePermission ? "Delete this array slide" : "You do not have permission to delete this array slide"%>" 
187      />
188      <tbl:button 
189        disabled="<%=writePermission ? false : true%>" 
190        image="<%=writePermission ? "restore.gif" : "restore_disabled.gif"%>" 
191        onclick="restoreItem()" 
192        title="Restore"
193        visible="<%=slide.isRemoved()%>"
194        tooltip="<%=writePermission ? "Restore this array slide" : "You do not have permission to restore this array slide"%>" 
195      />
196      <tbl:button 
197        disabled="<%=sharePermission ? false : true%>"
198        image="<%=sharePermission ? "share.gif" : "share_disabled.gif"%>"
199        onclick="shareItem()" 
200        title="Share&hellip;" 
201        tooltip="<%=sharePermission ? "Share this array slide to other user, groups and projects" : "You do not have permission to share this array slide"%>"
202      />
203      <tbl:button 
204        disabled="<%=setOwnerPermission ? false : true%>"
205        image="<%=setOwnerPermission ? "take_ownership.png" : "take_ownership_disabled.png"%>"
206        onclick="setOwner()" 
207        title="Set owner&hellip;"
208        tooltip="<%=setOwnerPermission ? "Change owner of this item" : "You do not have permission to change ownership of this item"%>"
209      />
210      <tbl:button 
211        image="import.gif" 
212        onclick="runPlugin('ImportItem')" 
213        title="Import&hellip;" 
214        tooltip="Import data" 
215        visible="<%=pluginCount.containsKey(Plugin.MainType.IMPORT)%>"
216      />
217      <tbl:button 
218        image="export.gif" 
219        onclick="runPlugin('ExportItem')" 
220        title="Export&hellip;" 
221        tooltip="Export data" 
222        visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>"
223      />
224      <tbl:button 
225        image="runplugin.gif" 
226        onclick="runPlugin('RunPlugin')" 
227        title="Run plugin&hellip;" 
228        tooltip="Run a plugin" 
229        visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>"
230      />
231      <ext:render extensions="<%=invoker%>" context="<%=jspContext%>" 
232        wrapper="<%=new PrefixSuffixRenderer(jspContext, "<td>", "</td>") %>"/>
233      <tbl:button
234        image="help.gif"
235        onclick="<%="Main.openHelp('" + ID +"', 'arrayslide.view.properties')"%>"
236        title="Help&hellip;"
237        tooltip="Get help about this page"
238      />
239      </tbl:toolbar>
240    <div class="boxedbottom">
241      <div class="itemstatus">Permissions on this item: <i><%=PermissionUtil.getFullPermissionNames(slide)%></i></div>
242      <%
243      if (slide.isRemoved() || slide.isShared())
244      {
245        %>
246        <div class="itemstatus">
247          <base:icon 
248            image="<%=deletePermanentlyPermission ? "deleted.gif" : "deleted_disabled.gif"%>"
249            onclick="<%=deletePermanentlyPermission ? "deleteItemPermanently()" : null%>"
250            tooltip="<%=deletePermanentlyPermission ? "Permanently delete this item" : null%>"
251            visible="<%=isRemoved%>"> This item has been flagged for deletion<br></base:icon>
252          <base:icon image="used.gif" 
253            onclick="showUsingItems()"
254            tooltip="Show the items that are using this one"
255            visible="<%=isUsed%>"> This item is used by other items and can't be permanently deleted<br></base:icon>
256          <base:icon image="shared.gif" 
257            visible="<%=slide.isShared()%>"> This item is shared to other users, groups and/or projects</base:icon>
258        </div>
259        <%
260      }
261      %>
262      <table class="form" cellspacing="0">
263      <tr>
264        <td class="prompt">Name</td>
265        <td><%=HTML.encodeTags(slide.getName())%></td>
266      </tr>
267      <tr>
268        <td class="prompt">Registered</td>
269        <td><%=dateFormatter.format(slide.getEntryDate())%></td>
270      </tr>
271      <tr>
272        <td class="prompt">Barcode</td>
273        <td><%=HTML.encodeTags(slide.getBarcode())%></td>
274      </tr>
275      <tr>
276        <td class="prompt">Destroyed</td>
277        <td><%=slide.isDestroyed() ? "yes" : "no"%></td>
278      </tr>
279      <tr>
280        <td class="prompt">Hybridization</td>
281        <td><base:propertyvalue item="<%=slide%>" property="hybridization" /></td>
282      </tr>
283      <tr>
284        <td class="prompt">Array batch</td>
285        <td><base:propertyvalue item="<%=slide%>" property="arrayBatch" />
286        (index: <%=slide.getBatchIndex()%>)
287        </td>
288      </tr>
289      <tr>
290        <td class="prompt">Array design</td>
291        <td><base:propertyvalue item="<%=slide%>" property="arrayBatch.arrayDesign" /></td>
292      </tr>
293      <tr>
294        <td class="prompt">Owner</td>
295        <td><base:propertyvalue item="<%=slide%>" property="owner" /></td>
296      </tr>
297      <tr>
298        <td class="prompt">Description</td>
299        <td><%=HTML.niceFormat(slide.getDescription())%></td>
300      </tr>
301      </table>
302      <%     
303     
304      // Tables with users/groups/projects that this item is shared to
305      MultiPermissions mp = new MultiPermissions(Collections.singleton(slide));
306      ItemResultList<User> users = mp.getUsers().list(dc);
307      ItemResultList<Group> groups = mp.getGroups().list(dc);
308      ItemResultList<Project> projects = mp.getProjects().list(dc);
309      int totalShare = users.size() + groups.size() + projects.size();
310     
311      if (totalShare > 0)
312      {
313        %>
314        <base:section
315          id="sharedTo"
316          title="<%="Shared to (" + totalShare + ")"%>"
317          context="<%=cc%>"
318          >
319          <tbl:table 
320            id="itemsSharedTo"
321            clazz="itemlist"
322            columns="all"
323          >
324            <tbl:columndef 
325              id="itemType"
326              title="Item type"
327            />
328            <tbl:columndef 
329              id="name"
330              title="Name"
331            />
332            <tbl:columndef 
333              id="permissions"
334              title="Permissions"
335            />
336            <tbl:data>
337              <tbl:columns>
338              </tbl:columns>
339              <tbl:rows>
340              <%
341              for (Project project : projects)
342              {
343                Set<Permission> permissions = mp.getPermissions(project).values().iterator().next();
344                %>     
345                <tbl:row>
346                  <tbl:cell column="itemType"><%=project.getType()%></tbl:cell>
347                  <tbl:cell column="name"><base:icon 
348                    image="deleted.gif" 
349                    tooltip="This item has been scheduled for deletion" 
350                    visible="<%=project.isRemoved()%>"
351                  /><%=Base.getLinkedName(ID, project, false, true)%></tbl:cell>
352                  <tbl:cell column="permissions">
353                    <%=PermissionUtil.translatePermissionsToString(permissions)%>
354                  </tbl:cell>
355                </tbl:row>
356                <%
357              }
358              for (Group group : groups)
359              {
360                Set<Permission> permissions = mp.getPermissions(group).values().iterator().next();
361                %>
362                <tbl:row>             
363                  <tbl:cell column="itemType"><%=group.getType()%></tbl:cell>
364                  <tbl:cell column="name"><base:icon 
365                    image="deleted.gif" 
366                    tooltip="This item has been scheduled for deletion" 
367                    visible="<%=group.isRemoved()%>"
368                  /><%=Base.getLinkedName(ID, group, false, true)%></tbl:cell>
369                  <tbl:cell column="permissions">
370                    <%=PermissionUtil.translatePermissionsToString(permissions)%>
371                  </tbl:cell>
372                </tbl:row>
373                <% 
374              }
375              for (User user : users)
376              {
377                Set<Permission> permissions = mp.getPermissions(user).values().iterator().next();
378                %>
379                <tbl:row>             
380                  <tbl:cell column="itemType"><%=user.getType()%></tbl:cell>
381                  <tbl:cell column="name"><base:icon 
382                    image="deleted.gif" 
383                    tooltip="This item has been scheduled for deletion" 
384                    visible="<%=user.isRemoved()%>"
385                  /><%=Base.getLinkedName(ID, user, false, true)%></tbl:cell>
386                  <tbl:cell column="permissions">
387                    <%=PermissionUtil.translatePermissionsToString(permissions)%>
388                  </tbl:cell>
389                </tbl:row>
390                <%
391              }
392              %>
393              </tbl:rows>
394            </tbl:data>
395          </tbl:table>
396        </base:section>
397        <%
398      }
399      else
400      {
401        %>
402        <h4>Shared to</h4>
403        This array slide is not shared
404        (or, you don't have permission to view the ones it is shared to).
405        <%
406      }
407      %>
408    </div>
409      </t:tab>
410     
411      <t:tab id="annotations" title="Annotations" >
412        <div class="boxed">
413        <jsp:include page="../../common/annotations/list_annotations.jsp">
414          <jsp:param name="item_type" value="<%=itemType.name()%>" />
415          <jsp:param name="item_id" value="<%=itemId%>" />
416          <jsp:param name="ID" value="<%=ID%>" />
417        </jsp:include>
418        </div>
419      </t:tab>
420      <t:tab id="overview" title="Overview" 
421        tooltip="Display a tree overview of related items">
422        <%
423        if ("overview".equals(tab))
424        {
425          %>
426          <jsp:include page="../../common/overview/overview.jsp">
427            <jsp:param name="item_type" value="<%=itemType.name()%>" />
428            <jsp:param name="item_id" value="<%=itemId%>" />
429            <jsp:param name="ID" value="<%=ID%>" />
430          </jsp:include>
431          <%
432        }
433        %>
434      </t:tab>
435      <t:tab id="history" title="Change history" 
436        tooltip="Displays a log of all modifications made to this item"
437        visible="<%=ChangeHistoryUtil.showChangeHistoryTab(sc)%>">
438        <%
439        if ("history".equals(tab))
440        {
441          %>
442          <jsp:include page="../../common/history/frameset.jsp">
443            <jsp:param name="source_type" value="<%=itemType.name()%>" />
444            <jsp:param name="source_id" value="<%=itemId%>" />
445            <jsp:param name="ID" value="<%=ID%>" />
446          </jsp:include>
447          <%
448        }
449        %>
450      </t:tab>
451      </t:tabcontrol>
452
453  </base:body>
454  </base:page>
455  <%
456}
457finally
458{
459  if (dc != null) dc.close();
460}
461
462%>
Note: See TracBrowser for help on using the repository browser.