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.Condition; 12 import com.opensymphony.workflow.StoreException; 13 import com.opensymphony.workflow.WorkflowContext; 14 import com.opensymphony.workflow.spi.Step; 15 import com.opensymphony.workflow.spi.WorkflowEntry; 16 import com.opensymphony.workflow.spi.WorkflowStore; 17 18 import java.util.*; 19 20 21 27 public class DenyOwnerCondition implements Condition { 28 30 public boolean passesCondition(Map transientVars, Map args, PropertySet ps) throws StoreException { 31 int stepId = TextUtils.parseInt((String ) args.get("stepId")); 32 WorkflowContext context = (WorkflowContext) transientVars.get("context"); 33 WorkflowEntry entry = (WorkflowEntry) transientVars.get("entry"); 34 WorkflowStore store = (WorkflowStore) transientVars.get("store"); 35 List currentSteps = store.findCurrentSteps(entry.getId()); 36 37 if (stepId == 0) { 38 for (Iterator iterator = currentSteps.iterator(); 39 iterator.hasNext();) { 40 Step step = (Step) iterator.next(); 41 42 if (context.getCaller().equals(step.getOwner())) { 43 return false; 44 } 45 } 46 } else { 47 for (Iterator iterator = currentSteps.iterator(); 48 iterator.hasNext();) { 49 Step step = (Step) iterator.next(); 50 51 if (stepId == step.getStepId()) { 52 if (context.getCaller().equals(step.getOwner())) { 53 return false; 54 } else { 55 return true; 56 } 57 } 58 } 59 } 60 61 return true; 62 } 63 } 64 | Popular Tags |