Difference between revisions of "Examples: Simple"

From OpenKM Documentation
Jump to: navigation, search
 
(9 intermediate revisions by the same user not shown)
Line 1: Line 1:
 +
{{TOCright}} __TOC__
 +
 +
Download and test this process definition: [[File:Simple.par]].
 +
 
== Process image ==
 
== Process image ==
<center>[[File:Workflow example simple.png]]</center>
+
[[File:Workflow example simple.png|center]]
  
 
== Process definition ==
 
== Process definition ==
 
<source lang="xml">
 
<source lang="xml">
 
<?xml version="1.0" encoding="UTF-8"?>
 
<?xml version="1.0" encoding="UTF-8"?>
 
 
<process-definition xmlns="urn:jbpm.org:jpdl-3.2" name="simple">
 
<process-definition xmlns="urn:jbpm.org:jpdl-3.2" name="simple">
 
   <start-state name="start">
 
   <start-state name="start">
Line 23: Line 26:
 
     </event>
 
     </event>
 
     <transition name="to_end" to="end">
 
     <transition name="to_end" to="end">
       <action name="action" class="com.openkm.MessageActionHandler">
+
       <action name="action" class="com.openkm.sample.MessageActionHandler">
 
         <message>About to finish!</message>
 
         <message>About to finish!</message>
 
       </action>
 
       </action>
Line 37: Line 40:
 
</process-definition>
 
</process-definition>
 
</source>
 
</source>
 +
 +
== Process handlers ==
 +
<source lang="java">
 +
package com.openkm;
 +
 +
import org.jbpm.graph.def.ActionHandler;
 +
import org.jbpm.graph.exe.ExecutionContext;
 +
 +
public class MessageActionHandler implements ActionHandler {
 +
  private static final long serialVersionUID = 1L;
 +
 +
  /**
 +
  * The message member gets its value from the configuration in the
 +
  * processdefinition. 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.
 +
  */
 +
  @Override
 +
  public void execute(ExecutionContext context) throws Exception {
 +
    context.getContextInstance().setVariable("message", message);
 +
    System.out.println("From MessageActionHandler...");
 +
  }
 +
}
 +
</source>
 +
 +
== Form definition ==
 +
None
  
 
[[Category: Workflow Guide]]
 
[[Category: Workflow Guide]]

Latest revision as of 14:42, 30 May 2011

Download and test this process definition: File:Simple.par.

Process image

Workflow example simple.png

Process definition

<?xml version="1.0" encoding="UTF-8"?>
<process-definition xmlns="urn:jbpm.org:jpdl-3.2" name="simple">
  <start-state name="start">
    <transition name="to_state" to="state"></transition>
    <event type="node-leave">
      <script>
        print(&quot;Node start&quot;);
      </script>
    </event>
  </start-state>
  <state name="state">
    <event type="node-enter">
      <script>
        print(&quot;Node state&quot;);
        executionContext.leaveNode();
      </script>
    </event>
    <transition name="to_end" to="end">
      <action name="action" class="com.openkm.sample.MessageActionHandler">
        <message>About to finish!</message>
      </action>
    </transition>
  </state>
  <end-state name="end">
    <event type="node-enter">
      <script>
        print(&quot;Node end (&quot;+executionContext.getVariable(&quot;message&quot;)+&quot;)&quot;);
      </script>
    </event>
  </end-state>
</process-definition>

Process handlers

package com.openkm;

import org.jbpm.graph.def.ActionHandler;
import org.jbpm.graph.exe.ExecutionContext;

public class MessageActionHandler implements ActionHandler {
  private static final long serialVersionUID = 1L;

  /**
   * The message member gets its value from the configuration in the 
   * processdefinition. 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.
   */
  @Override
  public void execute(ExecutionContext context) throws Exception {
    context.getContextInstance().setVariable("message", message);
    System.out.println("From MessageActionHandler...");
  }
}

Form definition

None