KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > info > magnolia > module > workflow > inbox > InboxValueProvider


1 /**
2  *
3  * Magnolia and its source-code is licensed under the LGPL.
4  * You may copy, adapt, and redistribute this file for commercial or non-commercial use.
5  * When copying, adapting, or redistributing this document in keeping with the guidelines above,
6  * you are required to provide proper attribution to obinary.
7  * If you reproduce or distribute the document without making any substantive modifications to its content,
8  * please use the following attribution line:
9  *
10  * Copyright 1993-2005 obinary Ltd. (http://www.obinary.com) All rights reserved.
11  *
12  */

13 package info.magnolia.module.workflow.inbox;
14
15 import info.magnolia.cms.gui.controlx.list.DefaultValueProvider;
16 import info.magnolia.context.Context;
17 import info.magnolia.module.workflow.WorkflowUtil;
18 import openwfe.org.engine.workitem.Attribute;
19 import openwfe.org.engine.workitem.InFlowItem;
20 import openwfe.org.engine.workitem.StringAttribute;
21
22 import org.apache.commons.lang.StringUtils;
23
24
25 /**
26  * @author Philipp Bracher
27  * @version $Revision:3416 $ ($Author:philipp $)
28  */

29 public class InboxValueProvider extends DefaultValueProvider {
30
31     /**
32      * @see info.magnolia.cms.gui.controlx.list.ListModelIteratorImpl#getValue(java.lang.String, java.lang.Object)
33      */

34     public Object JavaDoc getValue(String JavaDoc name, Object JavaDoc obj) {
35         InFlowItem item = (InFlowItem) obj;
36         if (name.equalsIgnoreCase("name")){
37             String JavaDoc path = (String JavaDoc) getValue("path", obj);
38             if(path != null){
39                 return StringUtils.substringAfterLast(path.toString(), "/");
40             }
41             return StringUtils.EMPTY;
42         }
43         else if (name.equalsIgnoreCase("id")) {
44             return WorkflowUtil.getId(item);
45         }
46         else if (name.equalsIgnoreCase("comment")) {
47             if(item.containsAttribute(Context.ATTRIBUTE_EXCEPTION)){
48                 return item.getAttribute(Context.ATTRIBUTE_MESSAGE);
49             }
50             else if (item.containsAttribute("comment")) {
51                 return item.getAttribute("comment");
52             }
53             else{
54                 return StringUtils.EMPTY;
55             }
56         }
57         else if (name.equalsIgnoreCase("workflow")) {
58             return item.getId().getWorkflowDefinitionName();
59         }
60         else if (name.equalsIgnoreCase("workItemPath")) {
61             return WorkflowUtil.getPath(WorkflowUtil.getId(item));
62         }
63         if (item.containsAttribute(name)) {
64             Attribute attribute = item.getAttribute(name);
65             if(attribute instanceof StringAttribute){
66                 return ((StringAttribute)attribute).toString();
67             }
68             return attribute;
69         }
70         else {
71             return super.getValue(name, obj);
72         }
73     }
74 }
75
Popular Tags