private StepStateChange createStepStateChange(ExecutionState executionState, Map metadata) {
    INodeEntry currentNode = stepContext.getCurrentNode();

    return StateUtils.stepStateChange(
        StateUtils.stepState(executionState, metadata),
        null != currentNode ? currentNode.getNodename() : null);
  }
 public void finishWorkflowItem(int step, StepExecutionItem item, StepExecutionResult result) {
   if (NodeDispatchStepExecutor.STEP_EXECUTION_TYPE.equals(item.getType())
       || item instanceof NodeStepExecutionItem) {
     // dont notify
   } else {
     notifyAllStepState(createIdentifier(), createStepStateChange(result), new Date());
   }
   stepContext.finishStepContext();
 }
 @Override
 public void beginWorkflowItemErrorHandler(int step, StepExecutionItem item) {
   stepContext.beginStepContext(StateUtils.stepContextId(step, true));
   HashMap<String, String> ehMap = new HashMap<String, String>();
   ehMap.put("handlerTriggered", "true");
   notifyAllStepState(
       createIdentifier(),
       createStepStateChange(ExecutionState.RUNNING_HANDLER, ehMap),
       new Date());
 }
 public void finishWorkflowExecution(
     WorkflowExecutionResult result,
     StepExecutionContext executionContext,
     WorkflowExecutionItem item) {
   List<Pair<StepContextId, INodeEntry>> currentContext = stepContext.getCurrentContextPairs();
   if (null == currentContext || currentContext.size() < 1) {
     notifyAllWorkflowState(
         null != result && result.isSuccess() ? ExecutionState.SUCCEEDED : ExecutionState.FAILED,
         new Date(),
         null);
   } else {
     notifyAllSubWorkflowState(
         createIdentifier(),
         null != result && result.isSuccess() ? ExecutionState.SUCCEEDED : ExecutionState.FAILED,
         new Date(),
         null);
   }
   stepContext.finishContext();
 }
 public void beginWorkflowExecution(
     StepExecutionContext executionContext, WorkflowExecutionItem item) {
   StepContextId currentStep = stepContext.getCurrentStep();
   INodeEntry currentNode = stepContext.getCurrentNode();
   if (null != currentNode && null != currentStep) {
     // if already node context, begin a parameterized sub workflow
     // change step context to include node name parameter for the step id
     HashMap<String, String> params = new HashMap<String, String>();
     params.put("node", currentNode.getNodename());
     stepContext.beginStepContext(
         StateUtils.stepContextId(
             currentStep.getStep(), !currentStep.getAspect().isMain(), params));
   }
   stepContext.beginContext();
   List<Pair<StepContextId, INodeEntry>> currentContext = stepContext.getCurrentContextPairs();
   List<String> names = getNodeNames(executionContext);
   if (null == currentContext) {
     notifyAllWorkflowState(ExecutionState.RUNNING, new Date(), names);
   } else {
     notifyAllSubWorkflowState(createIdentifier(), ExecutionState.RUNNING, new Date(), names);
   }
 }
 public void beginExecuteNodeStep(
     ExecutionContext context, NodeStepExecutionItem item, INodeEntry node) {
   // if node step item is not state transitionable, ignore it
   stepContext.beginNodeContext(node);
   StepIdentifier identifier = createIdentifier();
   notifyAllStepState(
       identifier,
       createStepStateChange(
           StateUtils.last(identifier).getAspect().isMain()
               ? ExecutionState.RUNNING
               : ExecutionState.RUNNING_HANDLER),
       new Date());
 }
 public void finishExecuteNodeStep(
     NodeStepResult result, ExecutionContext context, StepExecutionItem item, INodeEntry node) {
   // if node step item is not state transitionable, ignore it
   notifyAllStepState(createIdentifier(), createStepStateChange(result), new Date());
   stepContext.finishNodeContext();
 }
 public void beginWorkflowItem(int step, StepExecutionItem item) {
   stepContext.beginStepContext(StateUtils.stepContextId(step, false));
   notifyAllStepState(
       createIdentifier(), createStepStateChange(ExecutionState.RUNNING), new Date());
 }
 private StepStateChange createStepStateChange(StepExecutionResult result) {
   INodeEntry currentNode = stepContext.getCurrentNode();
   return createStepStateChange(result, currentNode);
 }
 private StepIdentifier createIdentifier() {
   return StateUtils.stepIdentifier(stepContext.getCurrentContext());
 }