Question
Code to check roles in a workflow
I have the code (below) to check if a role has someone assigned to it or not. What I need is how to change the code to check for two different roles to make sure that they are both assigned.
wt.workflow.work.WfAssignedActivity act = (wt.workflow.work.WfAssignedActivity) self.getObject();
wt.workflow.engine.WfProcess pro = (wt.workflow.engine.WfProcess) act.getParentProcess();
wt.team.Team t = wt.team.TeamHelper.service.getTeam(pro);
java.util.Map members = t.getRolePrincipalMap();
java.util.Set keys = members.keySet();
java.util.Iterator itr = keys.iterator();
while (itr.hasNext()) {
wt.project.Role role = (wt.project.Role) itr.next();
System.out.println("Role-=-=-=" + role);
if (role.toString().equalsIgnoreCase("MyCustomRole")) {
java.util.ArrayList users = (java.util.ArrayList) members.get(role);
//If there is no user in MyCustomRole role throw exception
if (users.isEmpty()) {
throw new Exception("Select user for " + role.getDisplay());
}
}
}
