source: trunk/www/lims/arraybatches/view_batch.jsp @ 5044

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

References #360 Covering the submenu items in 'Biomaterial LIMS' and 'Array LIMS' menus.

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