1 17 18 19 20 package org.apache.lenya.cms.workflow; 21 22 import java.util.HashSet ; 23 import java.util.Set ; 24 25 import org.apache.lenya.workflow.Situation; 26 import org.apache.lenya.workflow.WorkflowException; 27 import org.apache.lenya.workflow.WorkflowInstance; 28 import org.apache.lenya.workflow.impl.AbstractCondition; 29 30 public class RoleCondition extends AbstractCondition { 31 32 private Set roleIds = new HashSet (); 33 34 protected static final String SEPARATOR = ","; 35 36 39 public void setExpression(String expression) throws WorkflowException { 40 super.setExpression(expression); 41 42 String [] roles = expression.split(SEPARATOR); 43 for (int i = 0; i < roles.length; i++) { 44 roleIds.add(roles[i].trim()); 45 } 46 } 47 48 54 public boolean isComplied(Situation situation, WorkflowInstance instance) throws WorkflowException { 55 CMSSituation situationImpl = (CMSSituation) situation; 56 String [] roles = situationImpl.getRoleIds(); 57 58 boolean complied = false; 59 60 for (int i = 0; i < roles.length; i++) { 61 if (roleIds.contains(roles[i])) { 62 complied = true; 63 } 64 } 65 66 return complied; 67 } 68 69 } 70 | Popular Tags |