www/biomaterials/kits/view_kit.jsp

Code
Comments
Other
Rev Date Author Line
6991 02 Nov 15 nicklas 1 <%-- $Id$
6991 02 Nov 15 nicklas 2   ------------------------------------------------------------------
6991 02 Nov 15 nicklas 3   Copyright (C) 2015 Nicklas Nordborg
6991 02 Nov 15 nicklas 4
6991 02 Nov 15 nicklas 5   This file is part of BASE - BioArray Software Environment.
6991 02 Nov 15 nicklas 6   Available at http://base.thep.lu.se/
6991 02 Nov 15 nicklas 7
6991 02 Nov 15 nicklas 8   BASE is free software; you can redistribute it and/or
6991 02 Nov 15 nicklas 9   modify it under the terms of the GNU General Public License
6991 02 Nov 15 nicklas 10   as published by the Free Software Foundation; either version 3
6991 02 Nov 15 nicklas 11   of the License, or (at your option) any later version.
6991 02 Nov 15 nicklas 12
6991 02 Nov 15 nicklas 13   BASE is distributed in the hope that it will be useful,
6991 02 Nov 15 nicklas 14   but WITHOUT ANY WARRANTY; without even the implied warranty of
6991 02 Nov 15 nicklas 15   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
6991 02 Nov 15 nicklas 16   GNU General Public License for more details.
6991 02 Nov 15 nicklas 17
6991 02 Nov 15 nicklas 18   You should have received a copy of the GNU General Public License
6991 02 Nov 15 nicklas 19   along with BASE. If not, see <http://www.gnu.org/licenses/>.
6991 02 Nov 15 nicklas 20   ------------------------------------------------------------------
6991 02 Nov 15 nicklas 21
6991 02 Nov 15 nicklas 22   @author Nicklas
6991 02 Nov 15 nicklas 23 --%>
6991 02 Nov 15 nicklas 24 <%@ page pageEncoding="UTF-8" session="false"
6991 02 Nov 15 nicklas 25   import="net.sf.basedb.core.SessionControl"
6991 02 Nov 15 nicklas 26   import="net.sf.basedb.core.DbControl"
6991 02 Nov 15 nicklas 27   import="net.sf.basedb.core.SystemItems"
6991 02 Nov 15 nicklas 28   import="net.sf.basedb.core.Group"
6991 02 Nov 15 nicklas 29   import="net.sf.basedb.core.Item"
6991 02 Nov 15 nicklas 30   import="net.sf.basedb.core.ItemContext"
6991 02 Nov 15 nicklas 31   import="net.sf.basedb.core.Permission"
6991 02 Nov 15 nicklas 32   import="net.sf.basedb.core.Kit"
6991 02 Nov 15 nicklas 33   import="net.sf.basedb.core.User"
6991 02 Nov 15 nicklas 34   import="net.sf.basedb.core.PermissionDeniedException"
6991 02 Nov 15 nicklas 35   import="net.sf.basedb.core.PluginDefinition"
6991 02 Nov 15 nicklas 36   import="net.sf.basedb.core.ItemQuery"
6991 02 Nov 15 nicklas 37   import="net.sf.basedb.core.ItemResultList"
6991 02 Nov 15 nicklas 38   import="net.sf.basedb.core.Include"
6991 02 Nov 15 nicklas 39   import="net.sf.basedb.core.MultiPermissions"
6991 02 Nov 15 nicklas 40   import="net.sf.basedb.core.plugin.GuiContext"
6991 02 Nov 15 nicklas 41   import="net.sf.basedb.core.plugin.Plugin"
6991 02 Nov 15 nicklas 42   import="net.sf.basedb.core.Project"
6991 02 Nov 15 nicklas 43   import="net.sf.basedb.core.query.Orders"
6991 02 Nov 15 nicklas 44   import="net.sf.basedb.core.query.Hql"
6991 02 Nov 15 nicklas 45   import="net.sf.basedb.clients.web.Base"
6991 02 Nov 15 nicklas 46   import="net.sf.basedb.clients.web.ChangeHistoryUtil"
6991 02 Nov 15 nicklas 47   import="net.sf.basedb.clients.web.PermissionUtil"
6991 02 Nov 15 nicklas 48   import="net.sf.basedb.clients.web.util.HTML"
6991 02 Nov 15 nicklas 49   import="net.sf.basedb.util.formatter.Formatter"
6991 02 Nov 15 nicklas 50   import="net.sf.basedb.clients.web.formatter.FormatterFactory"
6991 02 Nov 15 nicklas 51   import="net.sf.basedb.clients.web.extensions.ExtensionsControl"
6991 02 Nov 15 nicklas 52   import="net.sf.basedb.clients.web.extensions.JspContext"
6991 02 Nov 15 nicklas 53   import="net.sf.basedb.clients.web.extensions.renderer.PrefixSuffixRenderer"
7604 25 Feb 19 nicklas 54   import="net.sf.basedb.clients.web.extensions.toolbar.ButtonAction" 
6991 02 Nov 15 nicklas 55   import="net.sf.basedb.clients.web.extensions.toolbar.ToolbarUtil"
6991 02 Nov 15 nicklas 56   import="net.sf.basedb.util.extensions.ExtensionsInvoker"
6991 02 Nov 15 nicklas 57   import="java.util.Date"
6991 02 Nov 15 nicklas 58   import="net.sf.basedb.util.Values"
6991 02 Nov 15 nicklas 59   import="java.util.Collections"
6991 02 Nov 15 nicklas 60   import="java.util.Map"
6991 02 Nov 15 nicklas 61   import="java.util.Set"
6991 02 Nov 15 nicklas 62 %>
6991 02 Nov 15 nicklas 63 <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
6991 02 Nov 15 nicklas 64 <%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %>
6991 02 Nov 15 nicklas 65 <%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %>
6991 02 Nov 15 nicklas 66 <%@ taglib prefix="p" uri="/WEB-INF/path.tld" %>
6991 02 Nov 15 nicklas 67 <%@ taglib prefix="ext" uri="/WEB-INF/extensions.tld" %>
6991 02 Nov 15 nicklas 68 <%!
6991 02 Nov 15 nicklas 69   private static final Item itemType = Item.KIT;
6991 02 Nov 15 nicklas 70   private static final GuiContext guiContext = new GuiContext(itemType, GuiContext.Type.ITEM);
6991 02 Nov 15 nicklas 71 %>
6991 02 Nov 15 nicklas 72 <%
6991 02 Nov 15 nicklas 73 final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
6991 02 Nov 15 nicklas 74 final String ID = sc.getId();
6991 02 Nov 15 nicklas 75 final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
6991 02 Nov 15 nicklas 76 final int itemId = cc.getId();
6991 02 Nov 15 nicklas 77 final String tab = Values.getStringOrNull(request.getParameter("tab"));
6991 02 Nov 15 nicklas 78 final float scale = Base.getScale(sc);
7954 12 May 21 nicklas 79 final DbControl dc = sc.newDbControl(":View "+itemType);
6991 02 Nov 15 nicklas 80 try
6991 02 Nov 15 nicklas 81 {
6991 02 Nov 15 nicklas 82   Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc);
6991 02 Nov 15 nicklas 83   Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext);
6991 02 Nov 15 nicklas 84
6991 02 Nov 15 nicklas 85   String title = null;
6991 02 Nov 15 nicklas 86   Kit kit = Kit.getById(dc, itemId);
6991 02 Nov 15 nicklas 87   
6991 02 Nov 15 nicklas 88   final boolean writePermission = kit.hasPermission(Permission.WRITE);
6991 02 Nov 15 nicklas 89   final boolean deletePermission = kit.hasPermission(Permission.DELETE);
6991 02 Nov 15 nicklas 90   final boolean sharePermission = kit.hasPermission(Permission.SET_PERMISSION);
6991 02 Nov 15 nicklas 91   final boolean setOwnerPermission = kit.hasPermission(Permission.SET_OWNER);
6991 02 Nov 15 nicklas 92   final boolean isRemoved = kit.isRemoved();
6991 02 Nov 15 nicklas 93   final boolean isUsed = isRemoved && kit.isUsed();
6991 02 Nov 15 nicklas 94   final boolean deletePermanentlyPermission = deletePermission && !isUsed;
6991 02 Nov 15 nicklas 95   final boolean isOwner = kit.isOwner();
6991 02 Nov 15 nicklas 96   JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, guiContext, kit);
7604 25 Feb 19 nicklas 97   ExtensionsInvoker<ButtonAction> invoker = ToolbarUtil.useExtensions(jspContext);
6991 02 Nov 15 nicklas 98   %>
6991 02 Nov 15 nicklas 99   <base:page title="<%=title%>" id="view-page">
6991 02 Nov 15 nicklas 100   <base:head scripts="tabcontrol-2.js,table.js,~kits.js" styles="toolbar.css,headertabcontrol.css,path.css,table.css">
6991 02 Nov 15 nicklas 101     <ext:scripts context="<%=jspContext%>" />
6991 02 Nov 15 nicklas 102     <ext:stylesheets context="<%=jspContext%>" />
6991 02 Nov 15 nicklas 103   </base:head>
6991 02 Nov 15 nicklas 104   <base:body>
6991 02 Nov 15 nicklas 105     <p:path><p:pathelement 
6991 02 Nov 15 nicklas 106       title="Kits" href="<%="index.jsp?ID="+ID%>" 
6991 02 Nov 15 nicklas 107       /><p:pathelement title="<%=HTML.encodeTags(kit.getName())%>" 
6991 02 Nov 15 nicklas 108       /></p:path>
6991 02 Nov 15 nicklas 109     <div id="page-data" data-item-id="<%=itemId%>"></div>
6991 02 Nov 15 nicklas 110     
6991 02 Nov 15 nicklas 111     <t:tabcontrol 
6991 02 Nov 15 nicklas 112       id="main" 
6991 02 Nov 15 nicklas 113       subclass="content mastertabcontrol" 
6991 02 Nov 15 nicklas 114       active="<%=tab%>">
6991 02 Nov 15 nicklas 115     <t:tab id="properties" title="Properties">
6991 02 Nov 15 nicklas 116       <div>
6991 02 Nov 15 nicklas 117       <table class="fullform bottomborder">
6991 02 Nov 15 nicklas 118       <tr>
6991 02 Nov 15 nicklas 119         <th class="itemstatus">
6991 02 Nov 15 nicklas 120           <base:icon 
6991 02 Nov 15 nicklas 121             image="shared.png" 
6991 02 Nov 15 nicklas 122             visible="<%=kit.isShared()%>"
6991 02 Nov 15 nicklas 123             tooltip="This item is shared to other users, groups and/or projects"
6991 02 Nov 15 nicklas 124           />
6991 02 Nov 15 nicklas 125           <base:icon 
6991 02 Nov 15 nicklas 126             id="btnDeletePermanently"
6991 02 Nov 15 nicklas 127             image="deleted.png"
6991 02 Nov 15 nicklas 128             tooltip="This item has been flagged for deletion. Click to delete it now."
6991 02 Nov 15 nicklas 129             enabled="<%=deletePermanentlyPermission %>"
6991 02 Nov 15 nicklas 130             visible="<%=isRemoved%>" 
6991 02 Nov 15 nicklas 131           />
6991 02 Nov 15 nicklas 132           <base:icon 
6991 02 Nov 15 nicklas 133             id="btnUsingItems"
6991 02 Nov 15 nicklas 134             image="used.png" 
6991 02 Nov 15 nicklas 135             tooltip="This item is used by other items and can't be permanently deleted. Show the items that are using this one"
6991 02 Nov 15 nicklas 136             visible="<%=isRemoved && isUsed%>" />
6991 02 Nov 15 nicklas 137         </th>
6991 02 Nov 15 nicklas 138         <td style="padding: 0px;">
6991 02 Nov 15 nicklas 139           <tbl:toolbar subclass="bottomborder bg-filled-50">
6991 02 Nov 15 nicklas 140             <tbl:button 
6991 02 Nov 15 nicklas 141               id="btnEdit"
6991 02 Nov 15 nicklas 142               disabled="<%=!writePermission%>" 
6991 02 Nov 15 nicklas 143               image="edit.png" 
6991 02 Nov 15 nicklas 144               title="Edit&hellip;" 
6991 02 Nov 15 nicklas 145               tooltip="<%=writePermission ? "Edit this kit" : "You do not have permission to edit this kit"%>" 
6991 02 Nov 15 nicklas 146             />
6991 02 Nov 15 nicklas 147             <tbl:button 
6991 02 Nov 15 nicklas 148               id="btnDelete"
6991 02 Nov 15 nicklas 149               disabled="<%=!deletePermission%>" 
6991 02 Nov 15 nicklas 150               image="delete.png" 
6991 02 Nov 15 nicklas 151               title="Delete"
6991 02 Nov 15 nicklas 152               visible="<%=!kit.isRemoved()%>"
6991 02 Nov 15 nicklas 153               tooltip="<%=deletePermission ? "Delete this kit" : "You do not have permission to delete this kit"%>" 
6991 02 Nov 15 nicklas 154             />
6991 02 Nov 15 nicklas 155             <tbl:button 
6991 02 Nov 15 nicklas 156               id="btnRestore"
6991 02 Nov 15 nicklas 157               disabled="<%=!writePermission%>" 
6991 02 Nov 15 nicklas 158               image="restore.png" 
6991 02 Nov 15 nicklas 159               title="Restore"
6991 02 Nov 15 nicklas 160               visible="<%=kit.isRemoved()%>"
6991 02 Nov 15 nicklas 161               tooltip="<%=writePermission ? "Restore this kit" : "You do not have permission to restore this kit"%>" 
6991 02 Nov 15 nicklas 162             />
6991 02 Nov 15 nicklas 163             <tbl:button 
6991 02 Nov 15 nicklas 164               id="btnShare"
6991 02 Nov 15 nicklas 165               disabled="<%=!sharePermission%>"
6991 02 Nov 15 nicklas 166               image="share.png"
6991 02 Nov 15 nicklas 167               title="Share&hellip;" 
6991 02 Nov 15 nicklas 168               tooltip="<%=sharePermission ? "Share this kit to other user, groups and projects" : "You do not have permission to share this kit"%>"
6991 02 Nov 15 nicklas 169             />
6991 02 Nov 15 nicklas 170             <tbl:button 
6991 02 Nov 15 nicklas 171               id="btnSetOwner"
6991 02 Nov 15 nicklas 172               disabled="<%=!setOwnerPermission%>"
6991 02 Nov 15 nicklas 173               image="take_ownership.png"
6991 02 Nov 15 nicklas 174               title="Set owner&hellip;"
6991 02 Nov 15 nicklas 175               tooltip="<%=setOwnerPermission ? "Change owner of this item" : "You do not have permission to change ownership of this item"%>"
6991 02 Nov 15 nicklas 176             />
6991 02 Nov 15 nicklas 177             <tbl:button 
6991 02 Nov 15 nicklas 178               id="btnImport"
6991 02 Nov 15 nicklas 179               image="import.png" 
6991 02 Nov 15 nicklas 180               data-plugin-type="IMPORT"  
6991 02 Nov 15 nicklas 181               title="Import&hellip;" 
6991 02 Nov 15 nicklas 182               tooltip="Import data" 
6991 02 Nov 15 nicklas 183               visible="<%=pluginCount.containsKey(Plugin.MainType.IMPORT)%>"
6991 02 Nov 15 nicklas 184             />
6991 02 Nov 15 nicklas 185             <tbl:button 
6991 02 Nov 15 nicklas 186               id="btnExport"
6991 02 Nov 15 nicklas 187               image="export.png"
6991 02 Nov 15 nicklas 188               data-plugin-type="EXPORT" 
6991 02 Nov 15 nicklas 189               title="Export&hellip;" 
6991 02 Nov 15 nicklas 190               tooltip="Export data" 
6991 02 Nov 15 nicklas 191               visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>"
6991 02 Nov 15 nicklas 192             />
6991 02 Nov 15 nicklas 193             <tbl:button 
6991 02 Nov 15 nicklas 194               id="btnRunPlugin"
6991 02 Nov 15 nicklas 195               image="runplugin.png"  
6991 02 Nov 15 nicklas 196               data-plugin-type="OTHER" 
6991 02 Nov 15 nicklas 197               title="Run plugin&hellip;" 
6991 02 Nov 15 nicklas 198               tooltip="Run a plugin" 
6991 02 Nov 15 nicklas 199               visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>"
6991 02 Nov 15 nicklas 200             />
6991 02 Nov 15 nicklas 201             <ext:render extensions="<%=invoker%>" context="<%=jspContext%>" 
7604 25 Feb 19 nicklas 202               wrapper="<%=new PrefixSuffixRenderer<ButtonAction>(jspContext, "<td>", "</td>") %>"/>
6991 02 Nov 15 nicklas 203             <tbl:button
6991 02 Nov 15 nicklas 204               image="help.png"
6991 02 Nov 15 nicklas 205               subclass="auto-init"
6991 02 Nov 15 nicklas 206               data-auto-init="help"
6991 02 Nov 15 nicklas 207               data-help-id="kit.view.properties"
6991 02 Nov 15 nicklas 208               title="Help&hellip;"
6991 02 Nov 15 nicklas 209               tooltip="Get help about this page"
6991 02 Nov 15 nicklas 210             />
6991 02 Nov 15 nicklas 211           </tbl:toolbar>
6991 02 Nov 15 nicklas 212         </td>
6991 02 Nov 15 nicklas 213       </tr>
6991 02 Nov 15 nicklas 214       <tr>
6991 02 Nov 15 nicklas 215         <th>Name</th>
6991 02 Nov 15 nicklas 216         <td><%=HTML.encodeTags(kit.getName())%></td>
6991 02 Nov 15 nicklas 217       </tr>
6991 02 Nov 15 nicklas 218       <tr>
6991 02 Nov 15 nicklas 219         <th>Type</th>
6991 02 Nov 15 nicklas 220         <td><base:propertyvalue item="<%=kit%>" property="itemSubtype" /></td>
6991 02 Nov 15 nicklas 221       </tr>
6991 02 Nov 15 nicklas 222       <tr>
6991 02 Nov 15 nicklas 223         <th>Registered</th>
6991 02 Nov 15 nicklas 224         <td><%=dateFormatter.format(kit.getEntryDate())%></td>
6991 02 Nov 15 nicklas 225       </tr>
6991 02 Nov 15 nicklas 226       <tr>
6991 02 Nov 15 nicklas 227         <th>Expiration date</th>
6991 02 Nov 15 nicklas 228         <td><%=dateFormatter.format(kit.getExpirationDate())%></td>
6991 02 Nov 15 nicklas 229       </tr>
6991 02 Nov 15 nicklas 230       <tr>
6991 02 Nov 15 nicklas 231         <th>Inactive</th>
6991 02 Nov 15 nicklas 232         <td><%=kit.isInactive() ? "Yes" : "No"%></td>
6991 02 Nov 15 nicklas 233       </tr>
6991 02 Nov 15 nicklas 234       <tr>
6991 02 Nov 15 nicklas 235         <th>Owner</th>
6991 02 Nov 15 nicklas 236         <td><base:propertyvalue item="<%=kit%>" property="owner" /></td>
6991 02 Nov 15 nicklas 237       </tr>
6991 02 Nov 15 nicklas 238       <tr>
6991 02 Nov 15 nicklas 239         <th>Permissions</th>
6991 02 Nov 15 nicklas 240         <td><%=PermissionUtil.getFullPermissionNames(kit)%></td>
6991 02 Nov 15 nicklas 241       </tr>
6991 02 Nov 15 nicklas 242       <tr>
6991 02 Nov 15 nicklas 243         <th>Description</th>
6991 02 Nov 15 nicklas 244         <td><%=HTML.niceFormat(kit.getDescription())%></td>
6991 02 Nov 15 nicklas 245       </tr>
6991 02 Nov 15 nicklas 246       </table>
6991 02 Nov 15 nicklas 247       </div>
6991 02 Nov 15 nicklas 248
6991 02 Nov 15 nicklas 249       <jsp:include page="../../common/anytoany/list_anytoany.jsp">
6991 02 Nov 15 nicklas 250         <jsp:param name="ID" value="<%=ID%>" />
6991 02 Nov 15 nicklas 251         <jsp:param name="item_type" value="<%=itemType.name()%>" />
6991 02 Nov 15 nicklas 252         <jsp:param name="item_id" value="<%=itemId%>" />
6991 02 Nov 15 nicklas 253         <jsp:param name="title" value="Other items related to this kit" />
6991 02 Nov 15 nicklas 254       </jsp:include>
6991 02 Nov 15 nicklas 255       <jsp:include page="../../common/share/list_share.jsp">
6991 02 Nov 15 nicklas 256         <jsp:param name="ID" value="<%=ID%>" />
6991 02 Nov 15 nicklas 257         <jsp:param name="item_type" value="<%=itemType.name()%>" />
6991 02 Nov 15 nicklas 258         <jsp:param name="item_id" value="<%=itemId%>" />
6991 02 Nov 15 nicklas 259         <jsp:param name="title" value="Shared to" />
6991 02 Nov 15 nicklas 260       </jsp:include>
6991 02 Nov 15 nicklas 261     </t:tab>
6991 02 Nov 15 nicklas 262     <t:tab id="annotations" title="Annotations" 
6991 02 Nov 15 nicklas 263       tooltip="View annotation values" clazz="white">
6991 02 Nov 15 nicklas 264       <jsp:include page="../../common/annotations/list_frameset.jsp">
6991 02 Nov 15 nicklas 265         <jsp:param name="item_type" value="<%=itemType.name()%>" />
6991 02 Nov 15 nicklas 266         <jsp:param name="item_id" value="<%=itemId%>" />
6991 02 Nov 15 nicklas 267         <jsp:param name="ID" value="<%=ID%>" />
6991 02 Nov 15 nicklas 268       </jsp:include>
6991 02 Nov 15 nicklas 269     </t:tab>
7166 07 Jun 16 nicklas 270     <t:tab id="history" title="History"
7166 07 Jun 16 nicklas 271       tooltip="Displays a log with the history of this item"
6991 02 Nov 15 nicklas 272       visible="<%=ChangeHistoryUtil.showChangeHistoryTab(sc)%>">
6991 02 Nov 15 nicklas 273       <jsp:include page="../../common/history/frameset.jsp">
6991 02 Nov 15 nicklas 274         <jsp:param name="item_type" value="<%=itemType.name()%>" />
6991 02 Nov 15 nicklas 275         <jsp:param name="item_id" value="<%=itemId%>" />
6991 02 Nov 15 nicklas 276         <jsp:param name="ID" value="<%=ID%>" />
6991 02 Nov 15 nicklas 277       </jsp:include>
6991 02 Nov 15 nicklas 278     </t:tab>
6991 02 Nov 15 nicklas 279     </t:tabcontrol>
6991 02 Nov 15 nicklas 280
6991 02 Nov 15 nicklas 281   </base:body>
6991 02 Nov 15 nicklas 282   </base:page>
6991 02 Nov 15 nicklas 283   <%
6991 02 Nov 15 nicklas 284 }
6991 02 Nov 15 nicklas 285 finally
6991 02 Nov 15 nicklas 286 {
6991 02 Nov 15 nicklas 287   if (dc != null) dc.close();
6991 02 Nov 15 nicklas 288 }
6991 02 Nov 15 nicklas 289
6991 02 Nov 15 nicklas 290 %>