I am trying to develop a workflow such that a document can be routed for approval to one or more users. The initiator of the workflow would start the workflow. Since he/she is the initiator the first step of the workflow would be to select the list of approvers. This list would be an array of usernames that would iterate through a loop. If they "approve" the document, then it would advance to the next user in the list. If any user "rejects" the document, the workflow would go to the end state. If every user "approves" then the workflow would advance to the quality assurance director who would "release" the document.
Starting simple I have the following workflow based off 1 user, but lacks the last steps of QA release.
In the end I would like the workflow to look more like this...
The first step I would like to change would be change username from a "simple" to a multiple...
The question is, how to I get this array into a variable? I think I can get a handler to iterate through the array, but first how to get a multiple values from a "select" into an array?
I am completely new to all this, including java, but I am determined to figure this out. Any help would be greatly appreciated.
Starting simple I have the following workflow based off 1 user, but lacks the last steps of QA release.
Code: Select all
The forms.xml
<?xml version="1.0" encoding="UTF-8"?>
<process-definition xmlns="urn:jbpm.org:jpdl-3.2" name="DocumentApproval">
<swimlane name="initiator"></swimlane>
<start-state name="start-state">
<task swimlane="initiator"></task>
<transition to="select-user"></transition>
</start-state>
<task-node name="select-user">
<task name="select" swimlane="initiator"></task>
<transition to="Approve-Document"></transition>
</task-node>
<task-node name="Approve-Document">
<task name="approve">
<assignment class="com.openkm.workflow.exercise7.ActorAssignment2"></assignment>
</task>
<transition to="approved?"></transition>
</task-node>
<decision name="approved?">
<handler class="com.openkm.workflow.decision.Decision1"></handler>
<transition to="Approved" name="yes">
<action name="action1" class="com.openkm.workflow.action.Transaction1Action"></action>
</transition>
<transition to="Rejected" name="no">
<action name="action2" class="com.openkm.workflow.action.Transaction2Action"></action>
</transition>
</decision>
<end-state name="Approved"></end-state>
<end-state name="Rejected"></end-state>
</process-definition>
Code: Select all
The ActorAssignment2 handler
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE workflow-forms PUBLIC "-//OpenKM//DTD Workflow Forms 2.4//EN"
"http://www.openkm.com/dtd/workflow-forms-2.4.dtd">
<workflow-forms>
<workflow-form task="select">
<select label="user" name="username" type="simple" optionsQuery="select id, name from User" />
<button name="submit" label="submit"/>
</workflow-form>
<workflow-form task="approve">
<select label="Document Approval" name="approval" type="simple">
<option label="Approve" value="1"/>
<option label="Reject" value="2"/>
</select>
<button name="submit" label="submit"/>
</workflow-form>
</workflow-forms>
Code: Select all
The Decision1 handler
package com.openkm.workflow.exercise7;
import org.jbpm.graph.exe.ExecutionContext;
import org.jbpm.taskmgmt.def.AssignmentHandler;
import org.jbpm.taskmgmt.exe.Assignable;
import com.openkm.bean.form.Select;
public class ActorAssignment2 implements AssignmentHandler {
private static final long serialVersionUID = 1L;
@Override
public void assign(Assignable assignable, ExecutionContext executionContext) throws Exception {
Select username = (Select) executionContext.getContextInstance().getVariable("username");
if (username != null) {
assignable.setActorId(username.getValue());
} else {
assignable.setActorId("okmAdmin");
}
}
}
Code: Select all
Transaction1 and Transaction2 are unchanged from the examples.package com.openkm.workflow.decision;
import org.jbpm.graph.exe.ExecutionContext;
import org.jbpm.graph.node.DecisionHandler;
import com.openkm.bean.form.Select;
public class Decision1 implements DecisionHandler {
private static final long serialVersionUID = 1L;
@Override
public String decide(ExecutionContext executionContext) throws Exception {
Select number = (Select) executionContext.getContextInstance().getVariable("approval");
if (number != null) {
int value = Integer.valueOf(number.getValue());
if (value > 001) {
return "no";
} else {
return "yes";
}
} else {
return "no";
}
}
}
In the end I would like the workflow to look more like this...
The first step I would like to change would be change username from a "simple" to a multiple...
Code: Select all
Then I need to add a step to iterate through that array "username_array" and send the single "username" variable to the ActorAssignment2 handler.<workflow-form task="select">
<select label="user" name="username_array" type="multiple" optionsQuery="select id, name from User" />
<button name="submit" label="submit"/>
</workflow-form>
The question is, how to I get this array into a variable? I think I can get a handler to iterate through the array, but first how to get a multiple values from a "select" into an array?
I am completely new to all this, including java, but I am determined to figure this out. Any help would be greatly appreciated.