Workflow Course: Exercise 6

From OpenKM Documentation
(Redirected from Workflow Course: Exercice 6)
Jump to: navigation, search


Step 1 - Use decision nodes

The idea of this exercise is user put some number value at starting workflow and then in next form try to guess the number.

To do it you should:

  • Create two forms with inputs value, one to put the value and other to guess the number.
  • Create a task where to guess the number and assign task to actor okmAdmin.
  • Create a decision node where to decide if user okmAdmin has guessed the number.


Wf decission.png


Example of forms.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE workflow-forms PUBLIC "-//OpenKM//DTD Workflow Forms 2.1//EN"
  <workflow-form task="run_config">
    <input label="number" name="number" />
    <button name="submit" label="Submit" />
  <workflow-form task="task">
  	<input label="suggested" name="suggested" />
    <button name="submit" label="Submit" />

Example of

package com.openkm.workflow.exercise.exercise5;
import org.jbpm.graph.exe.ExecutionContext;
import org.jbpm.graph.node.DecisionHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.openkm.bean.form.Input;
public class Decision implements DecisionHandler {
    private static final long serialVersionUID = 1L;
    private static Logger log = LoggerFactory.getLogger(Decision.class);
    public String decide(ExecutionContext executionContext) throws Exception {"Decision being evaluated");
        Input number = (Input) executionContext.getContextInstance().getVariable("number");
        Input suggested = (Input) executionContext.getContextInstance().getVariable("suggested");
        if (number != null && suggested != null && number.getValue().equals(suggested.getValue())) {
  "Go to 'good'");
            return "good";
        } else {
  "Go to 'bad'");
            return "bad";