Rolf Kremer

Powerful Java API of a Process Engine

leave a comment »

Yesterday, I attend a presentation about the Open Source > Activity BPM platform. A part of it is the Process Engine which has a Java-based API. You can find a > short tutorial about the API on the Activiti website. Of course, other available Process Engine have an API, too. For example > PAVONE Espresso Workflow, which is the core component of > PAVONElive, has a powerful Java API. This code snippet shows you how easy you can import a process definition, create a new process instance based on the process definition and complete the first task of the process.

// STEP 1: Import the process definition
// Imports the file LoanApplication.xml in the directory “c:\ProcessDefinitions”.
WfProcessDefinition wfDef = Session.importXMLProcessDefinition(“c:\\LoanApplication.xml”, “”);

// STEP 3: Initiate a process
// This step initiates a process based on the process definition called ‘Loan Application’
WfProcess process = pcsSession.initiateWfProcess( “”, “Loan Application” , “”, “”);

// STEP 4: Get the first task “Start Loan Application”
// First get all tasks which are in progress and then get the first task of this set.
Set tasks = process.getTasks ( TaskStatus.IN_PROGRESS );
Iterator iterator = tasks.iterator();
WfTask task = (WfTask)iterator.next();

// Place some operations on the task here
// … Your code …

// STEP 5: Complete the first task “Start Loan Application”
boolean success = task.complete();
if ( success == false ) {
// not successful, add error handling
return;
}

Further, you have access to several other features and all the data which will be handled by the engine.

(Source: Excerpt of the Getting Started Guide)

Written by rkremer

April 15, 2011 at 12:32 am

Posted in Processes & Projects

Tagged with

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: