1 5 package com.opensymphony.workflow.util; 6 7 import com.opensymphony.module.propertyset.PropertySet; 8 9 import com.opensymphony.util.TextUtils; 10 11 import com.opensymphony.workflow.*; 12 import com.opensymphony.workflow.spi.Step; 13 import com.opensymphony.workflow.spi.WorkflowEntry; 14 import com.opensymphony.workflow.spi.WorkflowStore; 15 16 import java.util.*; 17 18 19 33 public class MostRecentOwner implements FunctionProvider { 34 36 public void execute(Map transientVars, Map args, PropertySet ps) throws WorkflowException { 37 String stepIdString = (String ) args.get("stepId"); 39 WorkflowEntry entry = (WorkflowEntry) transientVars.get("entry"); 40 41 if (stepIdString == null) { 42 throw new WorkflowException("This function expects a stepId!"); 43 } 44 45 StringTokenizer st = new StringTokenizer(stepIdString, ","); 46 List stepIds = new LinkedList(); 47 48 while (st.hasMoreTokens()) { 49 stepIds.add(st.nextToken().trim()); 50 } 51 52 WorkflowStore store = (WorkflowStore) transientVars.get("store"); 53 List historySteps = store.findHistorySteps(entry.getId()); 54 55 for (Iterator iterator = historySteps.iterator(); iterator.hasNext();) { 56 Step step = (Step) iterator.next(); 57 58 if (stepIds.contains(String.valueOf(step.getStepId())) && TextUtils.stringSet(step.getOwner())) { 59 transientVars.put("mostRecentOwner", step.getOwner()); 60 61 break; 62 } 63 } 64 } 65 } 66 | Popular Tags |