Difference between revisions of "Workflow Course: Exercise 7"

From OpenKM Documentation
Jump to: navigation, search
m (Pavila moved page Workflow Course: Exercise 8 to Workflow Course: Exercise 7 without leaving a redirect)
(No difference)

Revision as of 10:47, 20 February 2015

Step 1 - How user can assign task to other

The idea of this exercise is one user assign a task to other.

To do it you should:

  • Create two forms in one user will set the user who will execute the next task.
  • First task will be assigned to user okmAdmin.
  • Create a class which implements AssignmentHandler and assign to taks2.


Wf assignment.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="task">
    <input label="username" name="username" />
    <button name="submit" label="Submit" />
  <workflow-form task="task2">
    <button name="submit" label="Submit" />

Example of ActorAssignment.java:

package com.openkm.workflow.exercise.exercise6;

import org.jbpm.graph.exe.ExecutionContext;
import org.jbpm.taskmgmt.def.AssignmentHandler;
import org.jbpm.taskmgmt.exe.Assignable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.openkm.bean.form.Input;

public class ActorAssigment implements AssignmentHandler {
    private static final long serialVersionUID = 1L;
    private static Logger log = LoggerFactory.getLogger(ActorAssigment.class);
    public void assign(Assignable assignable, ExecutionContext executionContext) throws Exception {
        log.info("Evaluating assigment");
        Input username = (Input) executionContext.getContextInstance().getVariable("username");
        if (username != null) {
            log.info("Task assigned to '{}'", username.getValue());
        } else {
            log.info("Task assigned to 'okmAdmin'");