www/my_base/messages/view_message.jsp

Code
Comments
Other
Rev Date Author Line
1885 02 Feb 06 nicklas 1 <%-- $Id$
1885 02 Feb 06 nicklas 2   ------------------------------------------------------------------
5425 23 Sep 10 nicklas 3   Copyright (C) 2006 Jari Häkkinen, Nicklas Nordborg
3675 16 Aug 07 jari 4   Copyright (C) 2007 Nicklas Nordborg
1885 02 Feb 06 nicklas 5
2304 22 May 06 jari 6   This file is part of BASE - BioArray Software Environment.
2304 22 May 06 jari 7   Available at http://base.thep.lu.se/
1885 02 Feb 06 nicklas 8
1885 02 Feb 06 nicklas 9   BASE is free software; you can redistribute it and/or
1885 02 Feb 06 nicklas 10   modify it under the terms of the GNU General Public License
4476 05 Sep 08 jari 11   as published by the Free Software Foundation; either version 3
1885 02 Feb 06 nicklas 12   of the License, or (at your option) any later version.
1885 02 Feb 06 nicklas 13
1885 02 Feb 06 nicklas 14   BASE is distributed in the hope that it will be useful,
1885 02 Feb 06 nicklas 15   but WITHOUT ANY WARRANTY; without even the implied warranty of
1885 02 Feb 06 nicklas 16   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1885 02 Feb 06 nicklas 17   GNU General Public License for more details.
1885 02 Feb 06 nicklas 18
1885 02 Feb 06 nicklas 19   You should have received a copy of the GNU General Public License
4511 11 Sep 08 jari 20   along with BASE. If not, see <http://www.gnu.org/licenses/>.
1885 02 Feb 06 nicklas 21   ------------------------------------------------------------------
1885 02 Feb 06 nicklas 22
1885 02 Feb 06 nicklas 23   @author Nicklas
1885 02 Feb 06 nicklas 24   @version 2.0
1885 02 Feb 06 nicklas 25 --%>
5426 24 Sep 10 nicklas 26 <%@ page pageEncoding="UTF-8" session="false"
1885 02 Feb 06 nicklas 27   import="net.sf.basedb.core.SessionControl"
1885 02 Feb 06 nicklas 28   import="net.sf.basedb.core.DbControl"
1885 02 Feb 06 nicklas 29   import="net.sf.basedb.core.SystemItems"
1885 02 Feb 06 nicklas 30   import="net.sf.basedb.core.Item"
1885 02 Feb 06 nicklas 31   import="net.sf.basedb.core.ItemContext"
1885 02 Feb 06 nicklas 32   import="net.sf.basedb.core.Permission"
1885 02 Feb 06 nicklas 33   import="net.sf.basedb.core.Message"
1885 02 Feb 06 nicklas 34   import="net.sf.basedb.core.User"
1885 02 Feb 06 nicklas 35   import="net.sf.basedb.core.Job"
2709 05 Oct 06 nicklas 36   import="net.sf.basedb.core.PluginConfiguration"
2216 05 May 06 nicklas 37   import="net.sf.basedb.core.BasicItem"
2216 05 May 06 nicklas 38   import="net.sf.basedb.core.Nameable"
2216 05 May 06 nicklas 39   import="net.sf.basedb.core.File"
1885 02 Feb 06 nicklas 40   import="net.sf.basedb.core.PermissionDeniedException"
1885 02 Feb 06 nicklas 41   import="net.sf.basedb.core.PluginDefinition"
2348 01 Jun 06 nicklas 42   import="net.sf.basedb.core.ParameterInfo"
1885 02 Feb 06 nicklas 43   import="net.sf.basedb.core.plugin.GuiContext"
1885 02 Feb 06 nicklas 44   import="net.sf.basedb.core.plugin.Plugin"
1885 02 Feb 06 nicklas 45   import="net.sf.basedb.clients.web.Base"
1885 02 Feb 06 nicklas 46   import="net.sf.basedb.clients.web.util.HTML"
2753 20 Oct 06 nicklas 47   import="net.sf.basedb.util.Values"
2942 22 Nov 06 nicklas 48   import="net.sf.basedb.util.formatter.Formatter"
2942 22 Nov 06 nicklas 49   import="net.sf.basedb.clients.web.formatter.FormatterFactory"
1885 02 Feb 06 nicklas 50   import="java.util.Date"
1885 02 Feb 06 nicklas 51   import="java.util.Map"
1885 02 Feb 06 nicklas 52   import="java.util.Set"
1885 02 Feb 06 nicklas 53   import="java.util.List"
2348 01 Jun 06 nicklas 54   import="java.util.Collections"
1885 02 Feb 06 nicklas 55 %>
1885 02 Feb 06 nicklas 56 <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
1885 02 Feb 06 nicklas 57 <%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %>
1885 02 Feb 06 nicklas 58 <%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %>
1885 02 Feb 06 nicklas 59 <%!
1885 02 Feb 06 nicklas 60   private static final Item itemType = Item.MESSAGE;
1885 02 Feb 06 nicklas 61   private static final GuiContext guiContext = new GuiContext(itemType, GuiContext.Type.ITEM);
1885 02 Feb 06 nicklas 62 %>
1885 02 Feb 06 nicklas 63 <%
1885 02 Feb 06 nicklas 64 final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
1885 02 Feb 06 nicklas 65 final String ID = sc.getId();
1885 02 Feb 06 nicklas 66 final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
1885 02 Feb 06 nicklas 67 final int itemId = cc.getId();
1885 02 Feb 06 nicklas 68 final String tab = Values.getString(request.getParameter("tab"), "properties");
1885 02 Feb 06 nicklas 69 final float scale = Base.getScale(sc);
7954 12 May 21 nicklas 70 final DbControl dc = sc.newDbControl(":View "+itemType);
1885 02 Feb 06 nicklas 71 try
1885 02 Feb 06 nicklas 72 {
1885 02 Feb 06 nicklas 73   Message message = Message.getById(dc, itemId);
1885 02 Feb 06 nicklas 74   message.setRead(true);
1885 02 Feb 06 nicklas 75   boolean readJob = true;
1885 02 Feb 06 nicklas 76   Job job = null;
2709 05 Oct 06 nicklas 77   boolean readCurrentConfig = true;
2709 05 Oct 06 nicklas 78   PluginConfiguration currentConfig = null;
1885 02 Feb 06 nicklas 79   try
1885 02 Feb 06 nicklas 80   {
1885 02 Feb 06 nicklas 81     job = message.getJob();
1885 02 Feb 06 nicklas 82   }
1885 02 Feb 06 nicklas 83   catch (Exception ex)
1885 02 Feb 06 nicklas 84   {
1885 02 Feb 06 nicklas 85     readJob = false;
2709 05 Oct 06 nicklas 86     readCurrentConfig = false;
1885 02 Feb 06 nicklas 87   }
2709 05 Oct 06 nicklas 88   if (job != null)
2709 05 Oct 06 nicklas 89   {
2709 05 Oct 06 nicklas 90     try
2709 05 Oct 06 nicklas 91     {
2709 05 Oct 06 nicklas 92       currentConfig = job.getPluginConfiguration();
2709 05 Oct 06 nicklas 93     }
2709 05 Oct 06 nicklas 94     catch (PermissionDeniedException ex)
2709 05 Oct 06 nicklas 95     {
2709 05 Oct 06 nicklas 96       readCurrentConfig = false;
2709 05 Oct 06 nicklas 97     }
2709 05 Oct 06 nicklas 98   }
1885 02 Feb 06 nicklas 99   
1885 02 Feb 06 nicklas 100   String title = "Message -- " + HTML.encodeTags(message.getName());;
2942 22 Nov 06 nicklas 101   Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc);
2942 22 Nov 06 nicklas 102   Formatter<Date> dateTimeFormatter = FormatterFactory.getDateTimeFormatter(sc);
1885 02 Feb 06 nicklas 103   
1885 02 Feb 06 nicklas 104   final boolean writePermission = message.hasPermission(Permission.WRITE);
1885 02 Feb 06 nicklas 105   final boolean deletePermission = message.hasPermission(Permission.DELETE);
4003 26 Nov 07 nicklas 106   final boolean isRemoved = message.isRemoved();
6621 24 Nov 14 nicklas 107   final boolean isUsed = true || isRemoved && message.isUsed();
4003 26 Nov 07 nicklas 108   final boolean deletePermanentlyPermission = deletePermission && !isUsed;
1885 02 Feb 06 nicklas 109   %>
6307 15 Aug 13 nicklas 110   <base:page type="popup" title="<%=title%>" id="view-page">
6307 15 Aug 13 nicklas 111   <base:head scripts="~messages.js" />
6520 18 Aug 14 nicklas 112   <base:body data-read-only="1">    
5909 14 Dec 11 nicklas 113     <h1><%=title%> <base:help tabcontrol="main" /></h1>
6307 15 Aug 13 nicklas 114     <div id="page-data" data-item-id="<%=itemId%>"></div>
5909 14 Dec 11 nicklas 115     
5909 14 Dec 11 nicklas 116     <div class="content bottomborder">
5909 14 Dec 11 nicklas 117       <table class="fullform outlined">
1885 02 Feb 06 nicklas 118       <%
1885 02 Feb 06 nicklas 119       if (message.isRemoved())
1885 02 Feb 06 nicklas 120       {
1885 02 Feb 06 nicklas 121         %>
5909 14 Dec 11 nicklas 122         <tr>
6621 24 Nov 14 nicklas 123           <th></th>
6621 24 Nov 14 nicklas 124           <td>
5909 14 Dec 11 nicklas 125           <div class="itemstatus">
5909 14 Dec 11 nicklas 126             <base:icon 
6307 15 Aug 13 nicklas 127               id="btnDeletePermanently"
5946 03 Feb 12 nicklas 128               image="deleted.png"
6307 15 Aug 13 nicklas 129               data-notify="btnDeletePermanently"
5909 14 Dec 11 nicklas 130               tooltip="<%=deletePermanentlyPermission ? "Permanently delete this item" : null%>"
6307 15 Aug 13 nicklas 131               enabled="<%=deletePermanentlyPermission %>"
5909 14 Dec 11 nicklas 132               visible="<%=isRemoved%>"> This item has been flagged for deletion<br></base:icon>
6307 15 Aug 13 nicklas 133             <base:icon 
6307 15 Aug 13 nicklas 134               id="btnUsingItems"
6307 15 Aug 13 nicklas 135               image="used.png" 
5909 14 Dec 11 nicklas 136               tooltip="Show the items that are using this one"
6621 24 Nov 14 nicklas 137               visible="<%=isUsed%>"> This item is used by other items</base:icon>
5909 14 Dec 11 nicklas 138           </div>
5909 14 Dec 11 nicklas 139           </td>
5909 14 Dec 11 nicklas 140         </tr>
1885 02 Feb 06 nicklas 141         <%
1885 02 Feb 06 nicklas 142       }
1885 02 Feb 06 nicklas 143       %>
5909 14 Dec 11 nicklas 144       <tr>
5909 14 Dec 11 nicklas 145         <th>Subject</th>
1885 02 Feb 06 nicklas 146         <td><%=HTML.encodeTags(message.getName())%></td>
1885 02 Feb 06 nicklas 147       </tr>
5909 14 Dec 11 nicklas 148       <tr>
5909 14 Dec 11 nicklas 149         <th>From</th>
1885 02 Feb 06 nicklas 150         <td><%=HTML.encodeTags(message.getFrom())%></td>
1885 02 Feb 06 nicklas 151       </tr>
5909 14 Dec 11 nicklas 152       <%
5909 14 Dec 11 nicklas 153       if (job != null)
5909 14 Dec 11 nicklas 154       {
5909 14 Dec 11 nicklas 155         %>
5909 14 Dec 11 nicklas 156         <tr>
6142 20 Sep 12 nicklas 157           <th>Job</th>
5909 14 Dec 11 nicklas 158           <td><%=Base.getLinkedName(ID, job, false, false)%></td>
5909 14 Dec 11 nicklas 159         </tr>
5909 14 Dec 11 nicklas 160         <%
5909 14 Dec 11 nicklas 161       }
5909 14 Dec 11 nicklas 162       %>
5909 14 Dec 11 nicklas 163       <tr>
5909 14 Dec 11 nicklas 164         <th>Time sent</th>
2942 22 Nov 06 nicklas 165         <td><%=dateTimeFormatter.format(message.getTimeSent())%></td>
1885 02 Feb 06 nicklas 166       </tr>
5909 14 Dec 11 nicklas 167       <tr class="dynamic">
5909 14 Dec 11 nicklas 168         <th>Message</th>
1885 02 Feb 06 nicklas 169         <td><%=HTML.niceFormat(message.getDescription())%></td>
1885 02 Feb 06 nicklas 170       </tr>
1885 02 Feb 06 nicklas 171       </table>
5909 14 Dec 11 nicklas 172       </div>
5909 14 Dec 11 nicklas 173     <base:buttongroup subclass="dialogbuttons">
6307 15 Aug 13 nicklas 174       <base:button id="close" title="Close" />
1885 02 Feb 06 nicklas 175     </base:buttongroup>
1885 02 Feb 06 nicklas 176
1885 02 Feb 06 nicklas 177   </base:body>
1885 02 Feb 06 nicklas 178   </base:page>
1885 02 Feb 06 nicklas 179   <%
1885 02 Feb 06 nicklas 180 }
1885 02 Feb 06 nicklas 181 finally
1885 02 Feb 06 nicklas 182 {
1886 02 Feb 06 nicklas 183   if (dc != null) dc.commit();
1885 02 Feb 06 nicklas 184 }
1885 02 Feb 06 nicklas 185
1885 02 Feb 06 nicklas 186 %>