source: trunk/www/biomaterials/bioplates/view_bioplate.jsp @ 4732

Last change on this file since 4732 was 4732, checked in by Martin Svensson, 15 years ago

Fixes #979 Biomaterial LIMS

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 13.7 KB
Line 
1<%-- $Id: view_bioplate.jsp 4732 2009-01-21 14:47:38Z martin $
2  ------------------------------------------------------------------
3  Copyright (C) 2006 Jari Hakkinen, 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 Martin
24  @version 2.10
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.Group"
31  import="net.sf.basedb.core.Item"
32  import="net.sf.basedb.core.ItemContext"
33  import="net.sf.basedb.core.Permission"
34  import="net.sf.basedb.core.AnnotationType"
35  import="net.sf.basedb.core.AnnotationSet"
36  import="net.sf.basedb.core.BioPlate"
37  import="net.sf.basedb.core.PlateGeometry"
38  import="net.sf.basedb.core.User"
39  import="net.sf.basedb.core.ItemQuery"
40  import="net.sf.basedb.core.Include"
41  import="net.sf.basedb.core.ItemResultIterator"
42  import="net.sf.basedb.core.ItemResultList"
43  import="net.sf.basedb.core.MultiPermissions"
44  import="net.sf.basedb.core.PermissionDeniedException"
45  import="net.sf.basedb.core.PluginDefinition"
46  import="net.sf.basedb.core.plugin.GuiContext"
47  import="net.sf.basedb.core.plugin.Plugin"
48  import="net.sf.basedb.core.Project"
49  import="net.sf.basedb.core.query.Orders"
50  import="net.sf.basedb.core.query.Hql"
51  import="net.sf.basedb.clients.web.Base"
52  import="net.sf.basedb.clients.web.PermissionUtil"
53  import="net.sf.basedb.clients.web.util.HTML"
54  import="net.sf.basedb.util.Values"
55  import="java.util.Collections"
56  import="java.util.Date"
57  import="java.util.Map"
58  import="java.util.Set"
59  import="java.util.List"
60%>
61<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
62<%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %>
63<%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %>
64<%@ taglib prefix="p" uri="/WEB-INF/path.tld" %>
65<%!
66  private static final Item itemType = Item.BIOPLATE;
67  private static final GuiContext guiContext = new GuiContext(itemType, GuiContext.Type.ITEM);
68%>
69<%
70final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
71final String ID = sc.getId();
72final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
73final int itemId = cc.getId();
74final String tab = Values.getString(request.getParameter("tab"), "properties");
75final float scale = Base.getScale(sc);
76final DbControl dc = sc.newDbControl();
77try
78{
79  Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext);
80
81  String title = null;
82  BioPlate bioplate = BioPlate.getById(dc, itemId);
83 
84  final boolean writePermission = bioplate.hasPermission(Permission.WRITE);
85  final boolean deletePermission = bioplate.hasPermission(Permission.DELETE);
86  final boolean sharePermission = bioplate.hasPermission(Permission.SET_PERMISSION);
87  final boolean setOwnerPermission = bioplate.hasPermission(Permission.SET_OWNER);
88  final boolean isRemoved = bioplate.isRemoved();
89  final boolean isUsed = isRemoved && bioplate.isUsed();
90  final boolean deletePermanentlyPermission = deletePermission && !isUsed;
91  final boolean isOwner = bioplate.isOwner();
92  %>
93  <base:page title="<%=title%>">
94  <base:head scripts="tabcontrol.js,table.js" styles="toolbar.css,table.css,headertabcontrol.css,path.css">
95    <script language="JavaScript">
96    function editItem()
97    {
98      Main.viewOrEditItem('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>, true);
99    }
100    function shareItem()
101    {
102      Main.openPopup('index.jsp?ID=<%=ID%>&cmd=ShareItem&item_id=<%=itemId%>', 'SharePlate', 600, 400);
103    }
104    function deleteItem()
105    {
106      location.replace('index.jsp?ID=<%=ID%>&cmd=DeleteItem&item_id=<%=itemId%>');
107    }
108    function restoreItem()
109    {
110      location.replace('index.jsp?ID=<%=ID%>&cmd=RestoreItem&item_id=<%=itemId%>');
111    }
112    function deleteItemPermanently()
113    {
114      Main.deleteItemPermanently('<%=ID%>', true, '<%=itemType.name()%>', <%=itemId%>, '&callback=itemDeleted');
115    }
116    function itemDeleted()
117    {
118      Main.listItems('<%=ID%>', '<%=itemType.name()%>');
119    }
120    function showUsingItems()
121    {
122      Main.showUsingItems('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>);
123    }
124    function setOwner()
125    {
126      Main.openPopup('index.jsp?ID=<%=ID%>&cmd=SetOwnerOfItem&item_id=<%=itemId%>', 'SetOwnerOfItem', 450, 150);
127    }
128    function runPlugin(cmd)
129    {
130      Main.openPopup('index.jsp?ID=<%=ID%>&cmd='+cmd+'&item_id=<%=itemId%>', 'RunPlugin'+cmd, 740, 540);
131    }
132    function viewWells()
133    {
134      location.href = 'wells/index.jsp?ID=<%=ID%>&bioplate_id=<%=itemId%>';
135    }
136    function switchTab(tabControlId, tabId)
137    {
138      if (tabId == 'wells')
139      {
140        viewWells();
141      }
142      else
143      {
144        TabControl.setActiveTab(tabControlId, tabId);
145      }
146    }
147    </script>
148  </base:head>
149  <base:body>
150    <p>
151    <p:path>
152      <p:pathelement title="Bioplates" href="<%="index.jsp?ID="+ID%>" />
153      <p:pathelement title="<%=HTML.encodeTags(bioplate.getName())%>" />
154    </p:path>
155   
156    <t:tabcontrol id="main" active="<%=tab%>" switch="switchTab">
157    <t:tab id="properties" title="Properties">
158    <tbl:toolbar
159      >
160      <tbl:button 
161        disabled="<%=writePermission ? false : true%>" 
162        image="<%=writePermission ? "edit.gif" : "edit_disabled.gif"%>" 
163        onclick="editItem()" 
164        title="Edit&hellip;" 
165        tooltip="<%=writePermission ? "Edit this bioplate" : "You do not have permission to edit this bioplate"%>" 
166      />
167      <tbl:button 
168        disabled="<%=writePermission ? false : true%>" 
169        image="<%=writePermission ? "" : ""%>" 
170        onclick="bioPlateAct()" 
171        title="Bioplate Act&hellip;" 
172        tooltip="<%=writePermission ? "Edit the biomaterials on this bioplate" : 
173          "You do not have permission to edit the biomaterials on this bioplate"%>" 
174      />
175      <tbl:button 
176        disabled="<%=deletePermission ? false : true%>" 
177        image="<%=deletePermission ? "delete.gif" : "delete_disabled.gif"%>" 
178        onclick="deleteItem()" 
179        title="Delete"
180        visible="<%=!bioplate.isRemoved()%>"
181        tooltip="<%=deletePermission ? "Delete this bioplate" : "You do not have permission to delete this bioplate"%>" 
182      />
183      <tbl:button 
184        disabled="<%=writePermission ? false : true%>" 
185        image="<%=writePermission ? "restore.gif" : "restore_disabled.gif"%>" 
186        onclick="restoreItem()" 
187        title="Restore"
188        visible="<%=bioplate.isRemoved()%>"
189        tooltip="<%=writePermission ? "Restore this bioplate" : "You do not have permission to restore this bioplate"%>" 
190      />
191      <tbl:button 
192        disabled="<%=sharePermission ? false : true%>"
193        image="<%=sharePermission ? "share.gif" : "share_disabled.gif"%>"
194        onclick="shareItem()" 
195        title="Share&hellip;" 
196        tooltip="<%=sharePermission ? "Share this bioplate to other user, groups and projects" : "You do not have permission to share this bioplate"%>"
197      />
198      <tbl:button 
199        disabled="<%=setOwnerPermission ? false : true%>"
200        image="<%=setOwnerPermission ? "take_ownership.png" : "take_ownership_disabled.png"%>"
201        onclick="setOwner()" 
202        title="Set owner&hellip;"
203        tooltip="<%=setOwnerPermission ? "Change owner of this item" : "You do not have permission to change ownership of this item"%>"
204      />
205      <tbl:button 
206        image="import.gif" 
207        onclick="runPlugin('ImportItem')" 
208        title="Import&hellip;" 
209        tooltip="Import data" 
210        visible="<%=pluginCount.containsKey(Plugin.MainType.IMPORT)%>"
211      />
212      <tbl:button 
213        image="export.gif" 
214        onclick="runPlugin('ExportItem')" 
215        title="Export&hellip;" 
216        tooltip="Export data" 
217        visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>"
218      />
219      <tbl:button 
220        image="runplugin.gif" 
221        onclick="runPlugin('RunPlugin')" 
222        title="Run plugin&hellip;" 
223        tooltip="Run a plugin" 
224        visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>"
225      />
226      <tbl:button
227        image="help.gif"
228        onclick="<%="Main.openHelp('" + ID +"', 'plate.view.properties')"%>"
229        title="Help&hellip;"
230        tooltip="Get help about this page"
231      />
232      </tbl:toolbar>
233    <div class="boxedbottom">
234      <div class="itemstatus">Permissions on this item: <i><%=PermissionUtil.getFullPermissionNames(bioplate)%></i></div>
235      <%
236      if (bioplate.isRemoved() || bioplate.isShared())
237      {
238        %>
239        <div class="itemstatus">
240          <base:icon 
241            image="<%=deletePermanentlyPermission ? "deleted.gif" : "deleted_disabled.gif"%>"
242            onclick="<%=deletePermanentlyPermission ? "deleteItemPermanently()" : null%>"
243            tooltip="<%=deletePermanentlyPermission ? "Permanently delete this item" : null%>"
244            visible="<%=isRemoved%>"> This item has been flagged for deletion<br></base:icon>
245          <base:icon image="used.gif" 
246            onclick="showUsingItems()"
247            tooltip="Show the items that are using this one"
248            visible="<%=isUsed%>"> This item is used by other items and can't be permanently deleted<br></base:icon>
249          <base:icon image="shared.gif" 
250            visible="<%=bioplate.isShared()%>"> This item is shared to other users, groups and/or projects</base:icon>
251        </div>
252        <%
253      }
254      %>
255      <table class="form" cellspacing="0">
256      <tr>
257        <td class="prompt">Name</td>
258        <td><%=HTML.encodeTags(bioplate.getName())%></td>
259      </tr>
260      <tr>
261        <td class="prompt">Barcode</td>
262        <td><%=HTML.encodeTags(bioplate.getBarcode())%></td>
263      </tr>
264      <tr>
265        <td class="prompt">Geometry</td>
266        <td><base:propertyvalue item="<%=bioplate%>" property="plateGeometry" /></td>
267      </tr>
268      <tr>
269        <td class="prompt">Freezer</td>
270        <td><base:propertyvalue item="<%=bioplate%>" property="freezer"></base:propertyvalue>
271      </tr>
272      <tr>
273        <td class="prompt">Owner</td>
274        <td><base:propertyvalue item="<%=bioplate%>" property="owner" /></td>
275      </tr>
276      <tr>
277        <td class="prompt">Description</td>
278        <td><%=HTML.niceFormat(bioplate.getDescription())%></td>
279      </tr>
280      </table>
281     
282      <%
283     
284      // Tables with users/groups/projects that this item is shared to
285      MultiPermissions mp = new MultiPermissions(Collections.singleton(bioplate));
286      ItemResultIterator<User> users = mp.getUsers().iterate(dc);
287      ItemResultIterator<Group> groups = mp.getGroups().iterate(dc);
288      ItemResultIterator<Project> projects = mp.getProjects().iterate(dc);
289     
290      if (users.hasNext() || groups.hasNext() || projects.hasNext())
291      {
292        %>
293        <h4 class="docked">Shared to</h4>
294        <tbl:table 
295          id="itemsSharedTo"
296          clazz="itemlist"
297          columns="all"
298        >
299          <tbl:columndef 
300            id="itemType"
301            title="Item type"
302          />
303          <tbl:columndef 
304            id="name"
305            title="Name"
306          />
307          <tbl:columndef 
308            id="permissions"
309            title="Permissions"
310          />
311          <tbl:data>
312            <tbl:columns>
313            </tbl:columns>
314            <tbl:rows>
315            <%
316            while(projects.hasNext())
317            {
318              Project project = projects.next();
319              Set<Permission> permissions = mp.getPermissions(project).values().iterator().next();
320              %>     
321              <tbl:row>
322                <tbl:cell column="itemType"><%=project.getType()%></tbl:cell>
323                <tbl:cell column="name"><base:icon 
324                  image="deleted.gif" 
325                  tooltip="This item has been scheduled for deletion" 
326                  visible="<%=project.isRemoved()%>"
327                /><%=Base.getLinkedName(ID, project, false, true)%></tbl:cell>
328                <tbl:cell column="permissions">
329                  <%=PermissionUtil.translatePermissionsToString(permissions)%>
330                </tbl:cell>
331              </tbl:row>
332              <%
333            }
334            while(groups.hasNext())
335            {
336              Group group = groups.next();
337              Set<Permission> permissions = mp.getPermissions(group).values().iterator().next();
338              %>
339              <tbl:row>             
340                <tbl:cell column="itemType"><%=group.getType()%></tbl:cell>
341                <tbl:cell column="name"><base:icon 
342                  image="deleted.gif" 
343                  tooltip="This item has been scheduled for deletion" 
344                  visible="<%=group.isRemoved()%>"
345                /><%=Base.getLinkedName(ID, group, false, true)%></tbl:cell>
346                <tbl:cell column="permissions">
347                  <%=PermissionUtil.translatePermissionsToString(permissions)%>
348                </tbl:cell>
349              </tbl:row>
350              <% 
351            }
352            while (users.hasNext())
353            {
354              User user = users.next();
355              Set<Permission> permissions = mp.getPermissions(user).values().iterator().next();
356              %>
357              <tbl:row>             
358                <tbl:cell column="itemType"><%=user.getType()%></tbl:cell>
359                <tbl:cell column="name"><base:icon 
360                  image="deleted.gif" 
361                  tooltip="This item has been scheduled for deletion" 
362                  visible="<%=user.isRemoved()%>"
363                /><%=Base.getLinkedName(ID, user, false, true)%></tbl:cell>
364                <tbl:cell column="permissions">
365                  <%=PermissionUtil.translatePermissionsToString(permissions)%>
366                </tbl:cell>
367              </tbl:row>
368              <%
369            }
370            %>
371            </tbl:rows>
372          </tbl:data>
373        </tbl:table>
374        <%
375      }
376      else
377      {
378        %>
379        <h4>Shared to</h4>
380        This bioplate is not shared
381        (or, you don't have permission to view the ones it is shared to).
382        <%
383      }
384      %>
385
386
387    </div>
388      </t:tab>
389     
390      <t:tab id="annotations" title="Annotations" >
391        <div class="boxed">
392        <jsp:include page="../../common/annotations/list_annotations.jsp">
393          <jsp:param name="item_type" value="<%=itemType.name()%>" />
394          <jsp:param name="item_id" value="<%=itemId%>" />
395          <jsp:param name="ID" value="<%=ID%>" />
396        </jsp:include>
397        </div>
398      </t:tab>
399      <t:tab id="wells" title="Wells" />
400      </t:tabcontrol>
401  </base:body>
402  </base:page>
403  <%
404}
405finally
406{
407  if (dc != null) dc.close();
408}
409%>
Note: See TracBrowser for help on using the repository browser.