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 26 public class StatusCondition implements Condition { 27 29 public boolean passesCondition(Map transientVars, Map args, PropertySet ps) throws StoreException { 30 String status = TextUtils.noNull((String ) args.get("status")); 31 int stepId = 0; 32 Object stepIdVal = args.get("stepId"); 33 34 if (stepIdVal != null) { 35 try { 36 stepId = Integer.parseInt(stepIdVal.toString()); 37 } catch (Exception ex) { 38 } 39 } 40 41 WorkflowEntry entry = (WorkflowEntry) transientVars.get("entry"); 42 WorkflowStore store = (WorkflowStore) transientVars.get("store"); 43 List currentSteps = store.findCurrentSteps(entry.getId()); 44 45 if (stepId == 0) { 46 for (Iterator iterator = currentSteps.iterator(); 47 iterator.hasNext();) { 48 Step step = (Step) iterator.next(); 49 50 if (status.equals(step.getStatus())) { 51 return true; 52 } 53 } 54 } else { 55 for (Iterator iterator = currentSteps.iterator(); 56 iterator.hasNext();) { 57 Step step = (Step) iterator.next(); 58 59 if (stepId == step.getStepId()) { 60 if (status.equals(step.getStatus())) { 61 return true; 62 } 63 } 64 } 65 } 66 67 return false; 68 } 69 } 70 | Popular Tags |