source: trunk/www/my_base/messages/view_message.jsp @ 2978

Last change on this file since 2978 was 2978, checked in by Nicklas Nordborg, 17 years ago

Added session="false" to all jsp pages so we no longer generate unneeded cookies

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 11.6 KB
Line 
1<%-- $Id: view_message.jsp 2978 2006-11-30 07:27:42Z nicklas $
2  ------------------------------------------------------------------
3  Copyright (C) Authors contributing to this file.
4
5  This file is part of BASE - BioArray Software Environment.
6  Available at http://base.thep.lu.se/
7
8  BASE is free software; you can redistribute it and/or
9  modify it under the terms of the GNU General Public License
10  as published by the Free Software Foundation; either version 2
11  of the License, or (at your option) any later version.
12
13  BASE is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  GNU General Public License for more details.
17
18  You should have received a copy of the GNU General Public License
19  along with this program; if not, write to the Free Software
20  Foundation, Inc., 59 Temple Place - Suite 330,
21  Boston, MA  02111-1307, USA.
22  ------------------------------------------------------------------
23
24  @author Nicklas
25  @version 2.0
26--%>
27<%@ page session="false"
28  import="net.sf.basedb.core.SessionControl"
29  import="net.sf.basedb.core.DbControl"
30  import="net.sf.basedb.core.SystemItems"
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.Message"
35  import="net.sf.basedb.core.User"
36  import="net.sf.basedb.core.Job"
37  import="net.sf.basedb.core.PluginConfiguration"
38  import="net.sf.basedb.core.BasicItem"
39  import="net.sf.basedb.core.Nameable"
40  import="net.sf.basedb.core.File"
41  import="net.sf.basedb.core.PermissionDeniedException"
42  import="net.sf.basedb.core.PluginDefinition"
43  import="net.sf.basedb.core.ParameterInfo"
44  import="net.sf.basedb.core.plugin.GuiContext"
45  import="net.sf.basedb.core.plugin.Plugin"
46  import="net.sf.basedb.clients.web.Base"
47  import="net.sf.basedb.clients.web.util.HTML"
48  import="net.sf.basedb.util.Values"
49  import="net.sf.basedb.util.formatter.Formatter"
50  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
51  import="java.util.Date"
52  import="java.util.Map"
53  import="java.util.Set"
54  import="java.util.List"
55  import="java.util.Collections"
56%>
57<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
58<%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %>
59<%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %>
60<%!
61  private static final Item itemType = Item.MESSAGE;
62  private static final GuiContext guiContext = new GuiContext(itemType, GuiContext.Type.ITEM);
63%>
64<%
65final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
66final String ID = sc.getId();
67final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
68final int itemId = cc.getId();
69final String tab = Values.getString(request.getParameter("tab"), "properties");
70final float scale = Base.getScale(sc);
71final DbControl dc = sc.newDbControl();
72try
73{
74  Message message = Message.getById(dc, itemId);
75  message.setRead(true);
76  boolean readJob = true;
77  Job job = null;
78  boolean readCurrentConfig = true;
79  PluginConfiguration currentConfig = null;
80  try
81  {
82    job = message.getJob();
83  }
84  catch (Exception ex)
85  {
86    readJob = false;
87    readCurrentConfig = false;
88  }
89  if (job != null)
90  {
91    try
92    {
93      currentConfig = job.getPluginConfiguration();
94    }
95    catch (PermissionDeniedException ex)
96    {
97      readCurrentConfig = false;
98    }
99  }
100 
101  String title = "Message -- " + HTML.encodeTags(message.getName());;
102  Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc);
103  Formatter<Date> dateTimeFormatter = FormatterFactory.getDateTimeFormatter(sc);
104 
105  final boolean writePermission = message.hasPermission(Permission.WRITE);
106  final boolean deletePermission = message.hasPermission(Permission.DELETE);
107  %>
108
109  <base:page type="popup" title="<%=title%>">
110  <base:head scripts="tabcontrol.js" styles="tabcontrol.css,progressbar.css">
111  </base:head>
112  <base:body>
113   
114    <h3 class="docked"><%=title%> <base:help tabcontrol="main" /></h3>
115    <t:tabcontrol id="main" active="<%=tab%>" position="bottom" contentstyle="<%="height: "+(int)(scale*320)+"px;"%>">
116    <t:tab id="properties" title="Properties" helpid="message.view.properties">
117
118      <%
119      if (message.isRemoved())
120      {
121        %>
122        <div class="itemstatus">
123          <base:icon image="deleted.gif" 
124            visible="<%=message.isRemoved()%>"> This item has been flagged for deletion<br></base:icon>
125        </div>
126        <%
127      }
128      %>
129      <table class="form" cellspacing=0>
130      <tr valign="top">
131        <td class="prompt">Subject</td>
132        <td><%=HTML.encodeTags(message.getName())%></td>
133      </tr>
134      <tr valign="top">
135        <td class="prompt">From</td>
136        <td><%=HTML.encodeTags(message.getFrom())%></td>
137      </tr>
138      <tr valign="top">
139        <td class="prompt">Time sent</td>
140        <td><%=dateTimeFormatter.format(message.getTimeSent())%></td>
141      </tr>
142      <tr valign="top">
143        <td class="prompt">Message</td>
144        <td><%=HTML.niceFormat(message.getDescription())%></td>
145      </tr>
146      </table>
147      </t:tab>
148 
149  <%
150  if (job != null)
151  {
152    %>
153    <t:tab id="job" title="Job" helpid="message.view.job">
154      <table class="form" cellspacing=0>
155      <tr>
156        <td class="prompt">Name</td>
157        <td><%=HTML.encodeTags(job.getName())%></td>
158      </tr>
159      <tr valign=top>
160        <td class="prompt">Description</td>
161        <td>
162          <%=HTML.encodeTags(job.getDescription())%>
163        </td>
164      </tr>
165      <tr valign=top>
166        <td class="prompt">Priority</td>
167        <td>
168          <%=job.getPriority()%> (1 = highest, 10 = lowest)
169        </td>
170      </tr>
171      <tr valign=top>
172        <td class="prompt">Status</td>
173        <td>
174          <%=job.getStatus()%>: <%=HTML.niceFormat(job.getStatusMessage())%>
175        </td>
176      </tr>
177      <tr valign=top>
178        <td class="prompt">Percent complete</td>
179        <td>
180          <table border=0 cellspacing=0 cellpadding=0>
181          <tr>
182          <td width="100">
183            <table width="100" class="progressbar" border=0 cellspacing=0 cellpadding=0>
184            <tr>
185              <%
186              int percent = job.getPercentComplete();
187              if (percent > 0) 
188              {
189                %>
190                <td width="<%=percent%>%" class="done">&nbsp;</td>
191                <% 
192              }
193              if (percent < 100) 
194              { 
195                %>
196                <td width="<%=100-percent%>%" class="remain">&nbsp;</td>
197                <%
198              }
199              %>
200            </tr>
201            </table>
202          </td>
203          <td>&nbsp;<%=percent%>%</td>
204          </tr>
205          </table>
206        </td>
207      </tr>
208      <tr valign=top>
209        <td class="prompt">Created</td>
210        <td>
211          <%=dateTimeFormatter.format(job.getCreated())%>
212        </td>
213      </tr>
214      <tr valign=top>
215        <td class="prompt">Started</td>
216        <td>
217          <%=dateTimeFormatter.format(job.getStarted())%>
218        </td>
219      </tr>
220      <tr valign=top>
221        <td class="prompt">Ended</td>
222        <td>
223          <%=dateTimeFormatter.format(job.getEnded())%>
224        </td>
225      </tr>
226      <tr valign=top>
227        <td class="prompt">Server</td>
228        <td>
229          <%=HTML.encodeTags(job.getServer())%>
230        </td>
231      </tr>
232      <tr valign=top>
233        <td class="prompt">Plugin</td>
234        <td>
235          <base:propertyvalue item="<%=job%>" property="pluginDefinition.name" />
236        </td>
237      </tr>
238      <tr valign=top>
239        <td class="prompt">Configuration</td>
240        <td>
241          <base:propertyvalue item="<%=job%>" property="pluginConfiguration.name" />
242        </td>
243      </tr>
244      </table>
245    </t:tab>
246    <%
247    if (job.getStackTrace() != null)
248    {
249      %>
250      <t:tab id="stacktrace" title="Stack trace" helpid="message.view.jobstacktrace">
251        <div style="font-family: monospace">
252        <%=HTML.niceFormat(job.getStackTrace())%>
253        </div>
254      </t:tab>
255      <%
256    }
257    %>
258   
259    <t:tab id="Parameters" title="Parameters" helpid="message.view.jobparameters">
260      <h4>Job parameters</h4>
261      <table class="form" cellspacing=0>
262        <%
263        List<String> names = new java.util.ArrayList<String>(job.getParameterNames());
264        Collections.sort(names);
265        for (String name : names)
266        {
267          StringBuilder sb = new StringBuilder();
268          String displayValue = "";
269          String description = "";
270          try
271          {
272            ParameterInfo pi = job.getParameterInfo(name);
273            if (pi.getLabel() != null) name = HTML.encodeTags(pi.getLabel());
274            description = HTML.encodeTags(pi.getDescription());
275            List<?> values = pi.getValues();
276            int i = 0;
277            for (Object value : values)
278            {
279              if (value != null)
280              {
281                if (i > 0) sb.append(", ");
282                i++;
283                if (value instanceof BasicItem)
284                {
285                  BasicItem item = (BasicItem)value;
286                  String itemName = "";
287                  if (item instanceof File)
288                  {
289                    itemName = ((File)item).getPath().toString();
290                  }
291                  else if (item instanceof Nameable)
292                  {
293                    itemName = ((Nameable)item).getName();
294                  }
295                  else
296                  {
297                    itemName = item.toString();
298                  }
299                  sb.append(HTML.encodeTags(itemName));
300                }
301                else if (value instanceof Date)
302                {
303                  sb.append(dateFormatter.format((Date)value));
304                }
305                else
306                {
307                  sb.append(HTML.encodeTags(value.toString()));
308                }
309              }
310            }
311            displayValue = sb.toString();
312          }
313          catch (Throwable ex)
314          {
315            displayValue = "<i>ERROR: "+ex.getMessage()+"</i>";
316          }
317          %>
318          <tr>
319            <td class="prompt"><span title="<%=description%>"><%=name%></span></td>
320            <td>
321              <%=displayValue%>
322            </td>
323          </tr>
324          <%
325        }
326        %>
327      </table>
328
329        <%
330        if (!readCurrentConfig)
331        {
332          %>
333          <h4>Plugin configuration parameters</h4>
334          <i>- denied -</i>
335          <%
336        }
337        else if (currentConfig != null)
338        {
339          int parameterVersion = job.getParameterVersion();
340          int currentVersion = currentConfig.getParameterVersion();
341          %>
342          <h4>Plugin configuration parameters</h4>
343          <table class="form" cellspacing=0>
344          <tr>
345            <td class="prompt"><span 
346              title="The version of the parmeters used for this job, current version in paranthesis">Parameter version</span></td>
347            <td><%=parameterVersion%> (<%=currentVersion %>)</td>
348          </tr>
349          <%
350          names = new java.util.ArrayList<String>(currentConfig.getParameterNames(parameterVersion));
351          Collections.sort(names);
352          for (String name : names)
353          {
354            StringBuilder sb = new StringBuilder();
355            String displayValue = "";
356            String description = "";
357            try
358            {
359              ParameterInfo pi = currentConfig.getParameterInfo(name, parameterVersion);
360              if (pi.getLabel() != null) name = HTML.encodeTags(pi.getLabel());
361              description = HTML.encodeTags(pi.getDescription());
362              List<?> values = pi.getValues();
363              int i = 0;
364              for (Object value : values)
365              {
366                if (value != null)
367                {
368                  if (i > 0) sb.append(", ");
369                  i++;
370                  if (value instanceof BasicItem)
371                  {
372                    BasicItem item = (BasicItem)value;
373                    String itemName = "";
374                    if (item instanceof File)
375                    {
376                      itemName = ((File)item).getPath().toString();
377                    }
378                    else if (item instanceof Nameable)
379                    {
380                      itemName = ((Nameable)item).getName();
381                    }
382                    else
383                    {
384                      itemName = item.toString();
385                    }
386                    sb.append(HTML.encodeTags(itemName));
387                  }
388                  else if (value instanceof Date)
389                  {
390                    sb.append(dateFormatter.format((Date)value));
391                  }
392                  else
393                  {
394                    sb.append(HTML.encodeTags(value.toString()));
395                  }
396                }
397              }
398              displayValue = sb.toString();
399            }
400            catch (Throwable ex)
401            {
402              displayValue = "<i>ERROR: "+ex.getMessage()+"</i>";
403            }
404            %>
405            <tr>
406              <td class="prompt"><span title="<%=description%>"><%=name%></span></td>
407              <td>
408                <%=displayValue%>
409              </td>
410            </tr>
411            <%
412          }
413          %>
414          </table>
415          <%
416        }
417        %>
418     
419    </t:tab>
420    <%
421  }
422  %>
423    </t:tabcontrol>
424     
425    <base:buttongroup align="center">
426      <base:button onclick="window.close()" title="Close" />
427    </base:buttongroup>
428
429  </base:body>
430  </base:page>
431  <%
432}
433finally
434{
435  if (dc != null) dc.commit();
436}
437
438%>
Note: See TracBrowser for help on using the repository browser.