1 package za.co.csir.icomtek.workflow.handlers; 2 3 import java.util.Vector ; 4 import java.util.ArrayList ; 5 import java.util.Iterator ; 6 7 import za.co.csir.icomtek.workflow.interfaces.WorkflowContext; 8 import za.co.csir.icomtek.workflow.model.Action; 9 import za.co.csir.icomtek.workflow.model.State; 10 import za.co.csir.icomtek.workflow.model.StateTransition; 11 12 33 public class ActionHandler extends BaseHandler { 34 35 42 public static void performActions (WorkflowContext ctx, 43 State state) 44 throws Exception 45 { 46 if (state.getEntryStateActions() != null && 47 state.getEntryStateActions().getActionAsReference() != null) { 48 performActions(ctx, state.getEntryStateActions() 49 .getActionAsReference()); 50 } 51 } 52 53 61 public static void performActions (WorkflowContext ctx, 62 StateTransition st) 63 throws Exception 64 { 65 if (st.getExitStateActions() != null && 66 st.getExitStateActions().getActionAsReference() != null) { 67 performActions(ctx, st.getExitStateActions() 68 .getActionAsReference()); 69 } 70 } 71 72 private static void performActions (WorkflowContext ctx, 73 Vector actions) 74 throws Exception 75 { 76 try { 78 ctx.beginWorkflowAction(); 79 for (Iterator it = actions.iterator(); it.hasNext(); ) { 80 Action action = (Action)it.next(); 81 ArrayList reqAttVals = new ArrayList (); 82 try { 83 Object [] paramVals = populateParameterValues(action.getParameterElementAsReference(), ctx, reqAttVals); 84 executeAction(ctx, action, paramVals); 85 clearRequestAttributes(ctx, reqAttVals); 86 } catch (Exception e) { 87 e.printStackTrace(); 88 } 90 } 91 } finally { 92 ctx.endWorkflowAction(); 93 } 94 } 95 } 96 | Popular Tags |