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