Difference between revisions of "Workflow Course: Exercise 7"

From OpenKM Documentation
Jump to: navigation, search
(Created page with '== Step 1 - How user can assign task to other == The idea of this exercise is one user assign a task to other For doing it you should: * Create two forms in one user will set t…')
 
Line 8: Line 8:
 
* Create a class which implements AssignmentHandler and assign to taks2.
 
* Create a class which implements AssignmentHandler and assign to taks2.
  
[[File:Wf9.png]]
+
[[File:Wf9.png|center]]
  
 
'''forms.xml'''
 
'''forms.xml'''

Revision as of 09:12, 6 May 2013

Step 1 - How user can assign task to other

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

For doing 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.
Wf9.png

forms.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE workflow-forms PUBLIC "-//OpenKM//DTD Workflow Forms 2.1//EN"
                                "http://www.openkm.com/dtd/workflow-forms-2.1.dtd">
<workflow-forms>
  <workflow-form task="task">
  	<input label="username" name="username" />
    <button name="submit" label="Submit" />
  </workflow-form>
  <workflow-form task="task2">
    <button name="submit" label="Submit" />
  </workflow-form>
</workflow-forms>

ActorAssigment

package com.openkm.workflow.exercise.exercise9;

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

import com.openkm.bean.form.Input;

public class ActorAssigment implements AssignmentHandler {

	private static final long serialVersionUID = 1L;

	@Override
	public void assign(Assignable assignable, ExecutionContext executionContext)
			throws Exception {
		// TODO Auto-generated method stub
		Input username = (Input) executionContext.getContextInstance().getVariable("username");
		if (username!=null) {
			assignable.setActorId(username.getValue());
		} else {
			assignable.setActorId("okmAdmin");
		}
	}
}