AnsweredAssumed Answered

Get current ScriptNode object from ExecutionEntity in ExecutionListener?

Question asked by ungawunga on Mar 20, 2013
Latest reply on Mar 21, 2013 by ungawunga
What's the best way to get a hold of the ScriptNode instance that triggered an ExecutionListener in a workflow? I've been poking around and printing out the IDs, but haven't found a path to the ScriptNode that's embedded in the workflow.

In javascript, I can get it via the following code:

function wfGetNode()
{
   if( bpm_package.children.length <= 0 )
   {
      throw "no node attached to workflow";
   }
   return bpm_package.children[0];
}


What's the equivalent in Java? I'm trying to get it through the ExecutionEntity task since I haven't been able to get Spring to give me a reference to the ServiceRegistry.

Thanks


public class IssuePost extends BaseJavaDelegate implements ExecutionListener
{
   private Logger _logger = Logger.getLogger( IssuePost.class );

   @Override
   public void notify( DelegateExecution task ) throws Exception
   {
      try
      {
            NodeRef workflowPackage = null;
            ActivitiScriptNode scriptNode =
                  ( ActivitiScriptNode )(( ExecutionEntity ) task ).getVariable( WorkflowNotificationUtils.PROP_PACKAGE );
            if( scriptNode != null )
            {
                workflowPackage = scriptNode.getNodeRef();
                _logger.info( "IssuePost: workflowPackage " + workflowPackage.getId() + "  workflow task " + task.getId() + "  scriptNode " + scriptNode.getId() + " " + scriptNode.getName());

               Scriptable nodeKids = scriptNode.getChildren();
               for( int i=0; i < nodeKids.getIds().length; i++ )
               {
                  _logger.info( "IssuePost:  nodeKids.getIds()[" + i + "] = " + nodeKids.getIds() );
               }


Outcomes