Page 1 of 1
Help Creating Workflow
PostPosted:Mon Jun 06, 2011 5:28 pm
by andrew.cy
I'm trying to create a workflow that creates a folder and moves a file to it. However I have been unsuccessful and cannot even add a folder. Im implementing the logic in the action handler of the node that is supposed to create this folder. Any suggestions are greatly appreciated?
Re: Help Creating Workflow
PostPosted:Tue Jun 07, 2011 6:21 pm
by andrew.cy
heres the process definition
Code: Select all<?xml version="1.0" encoding="UTF-8"?>
<process-definition xmlns="urn:jbpm.org:jpdl-3.2" name="Test">
<start-state name="start">
<transition to="clientInfo"></transition>
</start-state>
<task-node name="clientInfo">
<task name="File Delegation">
<assignment actor-id="okmAdmin"></assignment>
<event type="task-create">
<script>
taskInstance.start();
</script>
</event>
</task>
<transition to="moveFile"></transition>
</task-node>
<node name="moveFile">
<action class="com.Test.TestHandler"></action>
<transition to="end"></transition>
</node>
<end-state name="end"></end-state>
</process-definition>
the forms.xml
Code: Select all<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE workflow-forms PUBLIC "-//OpenKM//DTD Workflow Forms 1.0//EN"
"http://www.openkm.com/dtd/workflow-forms-1.0.dtd">
<workflow-forms>
<workflow-form task="File Delegation">
<input label="Enter Client's First Name" name="firstName" />
<input label="Enter Client's Last Name" name="lastName" />
<button label="Submit" />
</workflow-form>
</workflow-forms>
here is the Handler implementation
Code: Select allpackage com.Test;
import org.jbpm.graph.def.ActionHandler;
import org.jbpm.graph.exe.ExecutionContext;
import com.openkm.api.OKMAuth;
import com.openkm.api.OKMDocument;
import com.openkm.api.OKMFolder;
import com.openkm.bean.form.Input;
public class TestHandler implements ActionHandler
{
private static final long serialVersionUID = 1L;
String firstName;
String lastName;
public void execute(ExecutionContext context) throws Exception
{
firstName = context.getContextInstance().getVariable("firstName").toString().trim();
lastName = context.getContextInstance().getVariable("lastName").toString().trim();
String token = OKMAuth.getInstance().login("okmAdmin", "admin");
Input DP = (Input) context.getContextInstance().getVariable("path");
String docPath = DP.getValue().trim();
if (!OKMFolder.getInstance().isValid(token, "/okm:root/" + lastName + ", " + firstName))
OKMFolder.getInstance().createSimple(token, "/okm:root/" + lastName + ", " + firstName);
OKMDocument.getInstance().move(token, docPath, "/okm:root/" + lastName + ", " + firstName);
context.leaveNode();
}
}
Re: Help Creating Workflow
PostPosted:Wed Jun 08, 2011 4:04 pm
by andrew.cy
I figured it out you just need to play with the above code a little and use try catch blocks anyway is there a way to refresh the foldertree through a workflow?
Re: Help Creating Workflow
PostPosted:Sat Jun 11, 2011 6:28 pm
by jllort
You're talking about workflow could made some operations with user interface, like refreshing folders tree etc..., is that the idea ?
Re: Help Creating Workflow
PostPosted:Sat Jun 11, 2011 6:36 pm
by andrew.cy
yes that exactly my idea for a workflow. Also, why can't I use the api classes to write a tab document extension. I keep getting an error that states "no source code found for com.openkm.api.OKMFolder did you forget to inherit a module"
Re: Help Creating Workflow
PostPosted:Sun Jun 12, 2011 3:49 pm
by jllort
Please post the question about TabDocument in other thread.
Actually there's no way to refreshing UI in a workflow process, but really seems interesting and necessary feature.
I've added the issue at
http://issues.openkm.com/view.php?id=1676
Do you consider could be some other features in same way, I only added go to some folder and refresh operation, do you consider could be others ?
Other question is when this events must be fired ... after executing workflow ( submit button )?, before seems has no sence ?