From 3743d182d99dbed9d2be84dc357f6839ffe4d2ec Mon Sep 17 00:00:00 2001 From: Andrew Branson Date: Thu, 18 Sep 2014 10:39:05 +0200 Subject: Hierarchical Roles. Fixes #199 --- .../com/c2kernel/lifecycle/instance/Activity.java | 48 +++++++++++++++------- 1 file changed, 33 insertions(+), 15 deletions(-) (limited to 'src/main/java/com/c2kernel/lifecycle/instance/Activity.java') diff --git a/src/main/java/com/c2kernel/lifecycle/instance/Activity.java b/src/main/java/com/c2kernel/lifecycle/instance/Activity.java index 95e0ede..3dd94b0 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/Activity.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/Activity.java @@ -1,5 +1,6 @@ package com.c2kernel.lifecycle.instance; import java.util.ArrayList; +import java.util.Iterator; import java.util.Map; import java.util.Vector; @@ -21,6 +22,7 @@ import com.c2kernel.lifecycle.instance.stateMachine.Transition; import com.c2kernel.lookup.AgentPath; import com.c2kernel.lookup.InvalidAgentPathException; import com.c2kernel.lookup.ItemPath; +import com.c2kernel.lookup.Path; import com.c2kernel.lookup.RolePath; import com.c2kernel.persistency.ClusterStorageException; import com.c2kernel.persistency.outcome.Outcome; @@ -203,7 +205,16 @@ public class Activity extends WfVertex DateUtility.setToNow(mStateDate); //refresh all the job lists - pushJobsToAgents(itemPath); + String agentRole = getCurrentAgentRole(); + if (agentRole != null && agentRole.length()>0) { + try { + RolePath myRole = Gateway.getLookup().getRolePath(agentRole); + pushJobsToAgents(itemPath, myRole); + } catch (ObjectNotFoundException ex) { // non-existent role + Logger.msg(7, "Activity.pushJobsToAgents() - Activity role '"+agentRole+" not found."); + } + } + return outcome; } @@ -451,22 +462,29 @@ public class Activity extends WfVertex } return jobs; } - - public void pushJobsToAgents(ItemPath itemPath) - { - String agentRole = getCurrentAgentRole(); - if (agentRole == null || agentRole.length()==0) return; - RolePath myRole; - try { - myRole = Gateway.getLookup().getRolePath(agentRole); - } catch (ObjectNotFoundException ex) { // non-existent role - Logger.msg(7, "Activity.pushJobsToAgents() - Activity role '"+agentRole+" not found."); - return; - } - if (myRole.hasJobList()) - new JobPusher(this, itemPath, myRole).start(); + public void pushJobsToAgents(ItemPath itemPath) { + String agentRole = getCurrentAgentRole(); + if (agentRole != null && agentRole.length()>0) { + try { + RolePath myRole = Gateway.getLookup().getRolePath(agentRole); + pushJobsToAgents(itemPath, myRole); + } catch (ObjectNotFoundException ex) { // non-existent role + Logger.msg(7, "Activity.pushJobsToAgents() - Activity role '"+agentRole+" not found."); + } + } + } + + public void pushJobsToAgents(ItemPath itemPath, RolePath role) + { + if (role.hasJobList()) + new JobPusher(this, itemPath, role).start(); + Iterator childRoles = role.getChildren(); + while (childRoles.hasNext()) { + RolePath childRole = (RolePath)childRoles.next(); + pushJobsToAgents(itemPath, childRole); + } } /** -- cgit v1.2.3