1 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 29 public class InboxValueProvider extends DefaultValueProvider { 30 31 34 public Object getValue(String name, Object obj) { 35 InFlowItem item = (InFlowItem) obj; 36 if (name.equalsIgnoreCase("name")){ 37 String path = (String ) 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 |