1 | <%-- $Id: view_message.jsp 3593 2007-07-24 07:55:04Z 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 | <% |
---|
65 | final SessionControl sc = Base.getExistingSessionControl(pageContext, true); |
---|
66 | final String ID = sc.getId(); |
---|
67 | final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null); |
---|
68 | final int itemId = cc.getId(); |
---|
69 | final String tab = Values.getString(request.getParameter("tab"), "properties"); |
---|
70 | final float scale = Base.getScale(sc); |
---|
71 | final DbControl dc = sc.newDbControl(); |
---|
72 | try |
---|
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"> </td> |
---|
191 | <% |
---|
192 | } |
---|
193 | if (percent < 100) |
---|
194 | { |
---|
195 | %> |
---|
196 | <td width="<%=100-percent%>%" class="remain"> </td> |
---|
197 | <% |
---|
198 | } |
---|
199 | %> |
---|
200 | </tr> |
---|
201 | </table> |
---|
202 | </td> |
---|
203 | <td> <%=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">User</td> |
---|
234 | <td> |
---|
235 | <base:propertyvalue item="<%=job%>" property="owner.name" /> |
---|
236 | </td> |
---|
237 | </tr> |
---|
238 | <tr valign="top"> |
---|
239 | <td class="prompt">Experiment</td> |
---|
240 | <td> |
---|
241 | <base:propertyvalue item="<%=job%>" property="experiment.name" /> |
---|
242 | </td> |
---|
243 | </tr> |
---|
244 | <tr valign="top"> |
---|
245 | <td class="prompt">Plugin</td> |
---|
246 | <td> |
---|
247 | <base:propertyvalue item="<%=job%>" property="pluginDefinition.name" /> |
---|
248 | </td> |
---|
249 | </tr> |
---|
250 | <tr valign="top"> |
---|
251 | <td class="prompt">Configuration</td> |
---|
252 | <td> |
---|
253 | <base:propertyvalue item="<%=job%>" property="pluginConfiguration.name" /> |
---|
254 | </td> |
---|
255 | </tr> |
---|
256 | </table> |
---|
257 | </t:tab> |
---|
258 | <% |
---|
259 | if (job.getStackTrace() != null) |
---|
260 | { |
---|
261 | %> |
---|
262 | <t:tab id="stacktrace" title="Stack trace" helpid="message.view.jobstacktrace"> |
---|
263 | <div style="font-family: monospace"> |
---|
264 | <%=HTML.niceFormat(job.getStackTrace())%> |
---|
265 | </div> |
---|
266 | </t:tab> |
---|
267 | <% |
---|
268 | } |
---|
269 | %> |
---|
270 | |
---|
271 | <t:tab id="Parameters" title="Parameters" helpid="message.view.jobparameters"> |
---|
272 | <h4>Job parameters</h4> |
---|
273 | <table class="form" cellspacing=0> |
---|
274 | <% |
---|
275 | List<String> names = new java.util.ArrayList<String>(job.getParameterNames()); |
---|
276 | Collections.sort(names); |
---|
277 | for (String name : names) |
---|
278 | { |
---|
279 | StringBuilder sb = new StringBuilder(); |
---|
280 | String displayValue = ""; |
---|
281 | String description = ""; |
---|
282 | try |
---|
283 | { |
---|
284 | ParameterInfo pi = job.getParameterInfo(name); |
---|
285 | if (pi.getLabel() != null) name = HTML.encodeTags(pi.getLabel()); |
---|
286 | description = HTML.encodeTags(pi.getDescription()); |
---|
287 | List<?> values = pi.getValues(); |
---|
288 | int i = 0; |
---|
289 | for (Object value : values) |
---|
290 | { |
---|
291 | if (value != null) |
---|
292 | { |
---|
293 | if (i > 0) sb.append(", "); |
---|
294 | i++; |
---|
295 | if (value instanceof BasicItem) |
---|
296 | { |
---|
297 | BasicItem item = (BasicItem)value; |
---|
298 | String itemName = ""; |
---|
299 | if (item instanceof File) |
---|
300 | { |
---|
301 | itemName = ((File)item).getPath().toString(); |
---|
302 | } |
---|
303 | else if (item instanceof Nameable) |
---|
304 | { |
---|
305 | itemName = ((Nameable)item).getName(); |
---|
306 | } |
---|
307 | else |
---|
308 | { |
---|
309 | itemName = item.toString(); |
---|
310 | } |
---|
311 | sb.append(HTML.encodeTags(itemName)); |
---|
312 | } |
---|
313 | else if (value instanceof Date) |
---|
314 | { |
---|
315 | sb.append(dateFormatter.format((Date)value)); |
---|
316 | } |
---|
317 | else |
---|
318 | { |
---|
319 | sb.append(HTML.encodeTags(value.toString())); |
---|
320 | } |
---|
321 | } |
---|
322 | } |
---|
323 | displayValue = sb.toString(); |
---|
324 | } |
---|
325 | catch (Throwable ex) |
---|
326 | { |
---|
327 | displayValue = "<i>ERROR: "+ex.getMessage()+"</i>"; |
---|
328 | } |
---|
329 | %> |
---|
330 | <tr> |
---|
331 | <td class="prompt"><span title="<%=description%>"><%=name%></span></td> |
---|
332 | <td> |
---|
333 | <%=displayValue%> |
---|
334 | </td> |
---|
335 | </tr> |
---|
336 | <% |
---|
337 | } |
---|
338 | %> |
---|
339 | </table> |
---|
340 | |
---|
341 | <% |
---|
342 | if (!readCurrentConfig) |
---|
343 | { |
---|
344 | %> |
---|
345 | <h4>Plugin configuration parameters</h4> |
---|
346 | <i>- denied -</i> |
---|
347 | <% |
---|
348 | } |
---|
349 | else if (currentConfig != null) |
---|
350 | { |
---|
351 | int parameterVersion = job.getParameterVersion(); |
---|
352 | int currentVersion = currentConfig.getParameterVersion(); |
---|
353 | %> |
---|
354 | <h4>Plugin configuration parameters</h4> |
---|
355 | <table class="form" cellspacing=0> |
---|
356 | <tr> |
---|
357 | <td class="prompt"><span |
---|
358 | title="The version of the parmeters used for this job, current version in paranthesis">Parameter version</span></td> |
---|
359 | <td><%=parameterVersion%> (<%=currentVersion %>)</td> |
---|
360 | </tr> |
---|
361 | <% |
---|
362 | names = new java.util.ArrayList<String>(currentConfig.getParameterNames(parameterVersion)); |
---|
363 | Collections.sort(names); |
---|
364 | for (String name : names) |
---|
365 | { |
---|
366 | StringBuilder sb = new StringBuilder(); |
---|
367 | String displayValue = ""; |
---|
368 | String description = ""; |
---|
369 | try |
---|
370 | { |
---|
371 | ParameterInfo pi = currentConfig.getParameterInfo(name, parameterVersion); |
---|
372 | if (pi.getLabel() != null) name = HTML.encodeTags(pi.getLabel()); |
---|
373 | description = HTML.encodeTags(pi.getDescription()); |
---|
374 | List<?> values = pi.getValues(); |
---|
375 | int i = 0; |
---|
376 | for (Object value : values) |
---|
377 | { |
---|
378 | if (value != null) |
---|
379 | { |
---|
380 | if (i > 0) sb.append(", "); |
---|
381 | i++; |
---|
382 | if (value instanceof BasicItem) |
---|
383 | { |
---|
384 | BasicItem item = (BasicItem)value; |
---|
385 | String itemName = ""; |
---|
386 | if (item instanceof File) |
---|
387 | { |
---|
388 | itemName = ((File)item).getPath().toString(); |
---|
389 | } |
---|
390 | else if (item instanceof Nameable) |
---|
391 | { |
---|
392 | itemName = ((Nameable)item).getName(); |
---|
393 | } |
---|
394 | else |
---|
395 | { |
---|
396 | itemName = item.toString(); |
---|
397 | } |
---|
398 | sb.append(HTML.encodeTags(itemName)); |
---|
399 | } |
---|
400 | else if (value instanceof Date) |
---|
401 | { |
---|
402 | sb.append(dateFormatter.format((Date)value)); |
---|
403 | } |
---|
404 | else |
---|
405 | { |
---|
406 | sb.append(HTML.encodeTags(value.toString())); |
---|
407 | } |
---|
408 | } |
---|
409 | } |
---|
410 | displayValue = sb.toString(); |
---|
411 | } |
---|
412 | catch (Throwable ex) |
---|
413 | { |
---|
414 | displayValue = "<i>ERROR: "+ex.getMessage()+"</i>"; |
---|
415 | } |
---|
416 | %> |
---|
417 | <tr> |
---|
418 | <td class="prompt"><span title="<%=description%>"><%=name%></span></td> |
---|
419 | <td> |
---|
420 | <%=displayValue%> |
---|
421 | </td> |
---|
422 | </tr> |
---|
423 | <% |
---|
424 | } |
---|
425 | %> |
---|
426 | </table> |
---|
427 | <% |
---|
428 | } |
---|
429 | %> |
---|
430 | |
---|
431 | </t:tab> |
---|
432 | <% |
---|
433 | } |
---|
434 | %> |
---|
435 | </t:tabcontrol> |
---|
436 | |
---|
437 | <base:buttongroup align="center"> |
---|
438 | <base:button onclick="window.close()" title="Close" /> |
---|
439 | </base:buttongroup> |
---|
440 | |
---|
441 | </base:body> |
---|
442 | </base:page> |
---|
443 | <% |
---|
444 | } |
---|
445 | finally |
---|
446 | { |
---|
447 | if (dc != null) dc.commit(); |
---|
448 | } |
---|
449 | |
---|
450 | %> |
---|