1 Reply Latest reply on Jul 7, 2008 4:15 PM by Mauricio Salatino

    Automate Workflow Steps

    Ashish Chawla Newbie

      Hi All,
      I have create a simple workflow which has 2 nodes, a start state and an end state. Here is the source...

      <?xml version="1.0" encoding="UTF-8"?>
      <process-definition xmlns="urn:jbpm.org:jpdl-3.2" name="http-demo-process">
      <swimlane name="initiator">
       <assignment actor-id="manager" />
       <start-state name="start">
       <transition to="call action"></transition>
       <node name="call action">
       <action class="com.sample.action.MessageActionHandler">
       <message>First Message</message>
       <transition to="post data"></transition>
       <node name="post data">
       <action class="com.sample.action.PostActionHandler">
       <message>First Message</message>
       <transition to="end"></transition>
       <end-state name="end"></end-state>

      Now after I deploy, in the jbpm-console, I have to click to start the workflow and then at every step I have to click start-end to finally reach the end of the workflow.

      Is there someway I can automate the entire process??

      Here is the action class for the node above:

      package com.sample.action;
      import org.jbpm.graph.def.ActionHandler;
      import org.jbpm.graph.exe.ExecutionContext;
      import org.apache.commons.logging.Log;
      import org.apache.commons.logging.LogFactory;
      public class MessageActionHandler implements ActionHandler {
       Log log = LogFactory.getLog(this.getClass());
       private static final long serialVersionUID = 1L;
       * The message member gets its value from the configuration in the
       * process definition. The value is injected directly by the engine.
       String message;
       * A message process variable is assigned the value of the message
       * member. The process variable is created if it doesn't exist yet.
       public void execute(ExecutionContext context) throws Exception {
       context.getContextInstance().setVariable("message", message);
       log.info("Printing Message at end: " + message);
       String taskName = context.getTaskInstance().getName();
       log.info("taask name " + taskName);

      What I want to do is start the workflow and then it goes through all the steps and reaches end.

      Also whats the best way to pass data (or values) from one step to another in the jbpm Workflow.

      Please advise.


        • 1. Re: Automate Workflow Steps
          Mauricio Salatino Master

          You have both answers in your code:
          First, when you define an action in a node, you must implement the code to
          continue the execution with:


          At the end of your code in your ActionHandler execute method.

          Second, if you want to pass values from one node to another the best way is ProcessVariables that you can store doing:
           context.getContextInstance().setVariable("Variable1", "Hello");

          and then in the other action handler you can get the value with
           String var1=b(String) context.getContextInstance().getVariable("Variable1");

          Hope it helps