jbpm overview & alfresco workflows

87
JBPM Overview & Alfresco Workflows @author: Francesco Valente @email: [email protected] @franco_valente

Upload: francesco-valente

Post on 27-Jan-2015

139 views

Category:

Technology


1 download

DESCRIPTION

A talk about workflows in jBPM and some real use cases, including detailed explanation on Alfresco Advanced Workflows.

TRANSCRIPT

Page 1: jBPM Overview &  Alfresco Workflows

JBPM Overview & Alfresco Workflows

@author: Francesco Valente@email: [email protected] @franco_valente

Page 2: jBPM Overview &  Alfresco Workflows

./Road map 1. Introduction

Business Process Management Domain Specific LanguagesGraph Oriented Programming

2. jBPMOverviewWorkflowsProcess Definition

3. jBPM-jPDL SuiteInstalling the jBPM engineInstalling the jBPM Designer

4. jBPM In Action!Review & Approve workflow

Step-by-Step jBoss jBPM WFAPI usageA Real jBPM use case: Alfresco WF

Step-by-Step Alfresco Advanced Workflow

Page 3: jBPM Overview &  Alfresco Workflows

./Introduction | BPM

Goals of BPM systems? The main goal of BPM systems is to facilitate the automation of business processes.Two main roles can be distinguished:

The business analyst : studies and describes the business process and specifies the software requirementsThe developer : creates executable software

In small teams, these two roles can of course be fullfilled by one person.

Page 4: jBPM Overview &  Alfresco Workflows

./Introduction | BPMThe business analyst and the developer NEED to communicate in a common language with the help of the graphical view of the process.

Page 5: jBPM Overview &  Alfresco Workflows

./Introduction |DSL

Each process language can be considered a

Domain Specific Language (DSL)

Page 6: jBPM Overview &  Alfresco Workflows

./Introduction |DSLDomain Specific Languages

Each language has a certain grammarThat grammar can be expressed as a domain model. (In case of java this is Class, Method, Field, Constructor,... In jPDL this is Node, Transition, Action...)Developers think in those grammars when authoring artifacts for a specific language. The IDE is build around the grammar of a language.

E.g. a jPDL process has a graphical editor and a XML source view editor.

Page 7: jBPM Overview &  Alfresco Workflows

./Introduction |DSLDomain Specific Languages

Internal DSLs are particular ways of using a host language to give the host language the feel of a particular language. This approach has recently been popularized by the Ruby community. Internal DSLs are also referred to as embedded DSLs or FluentInterfacesExternal DSLs have their own custom syntax and you write a full parser to process them. Many XML configurations have ended up as external DSLs, although XML's syntax is badly suited to this purpose.

(www.martinfowler.com)

Page 8: jBPM Overview &  Alfresco Workflows

./Introduction |GOP

Graph Oriented Programming Is the foundation for all domain specific languages that are based on executing a graph. Is a very simple technique that describes how graphs can be defined and executed on a plain OOP language

Page 9: jBPM Overview &  Alfresco Workflows

./Introduction |GOP

Graph Oriented Programming Two main features:

support for wait states

graphical rappresentation

Page 10: jBPM Overview &  Alfresco Workflows

./Introduction |GOP

Support for wait states

With an imperative language there's no wait instructionBlocking threads is not a solution: threads are not persistableTo achive persistance we need a database interaction. RAM based programs are not sufficients.

Page 11: jBPM Overview &  Alfresco Workflows

./Introduction |GOP

Graphical rappresentation The communication between a business analyst and the developer is improved using the graph based diagram of the business process as the common language.

Page 12: jBPM Overview &  Alfresco Workflows

./jBPM Overview

JBoss JBPM JBoss JBPM is the open source WFMS (WorkFlow Management System) suited by JBoss.

JBPM processes are created using a proprietary language of process definition called jPDL.State Management with jBPM is based on a graph with nodes and transitions that make up the definition of a process (Process Definition).

Page 13: jBPM Overview &  Alfresco Workflows

./jBPM |WorkflowsA workflow therefore, consists of a set of activities related to each other through different types of relationships.Example: BPMN notation of a process of monitoring the availability of an agricultural product in stock.

Page 14: jBPM Overview &  Alfresco Workflows

./jPDL |Process Definition

Example: jPDL notation of an approve & reject process of documents.

Page 15: jBPM Overview &  Alfresco Workflows

./jPDL |Process Definition

Page 16: jBPM Overview &  Alfresco Workflows

./jPDL |Process Definition

The graph of the states provides the structure of the process.The interaction with the process occurs, at "low-level", through the use of specially designed API.The actions are business logic (classes that implement the interface org.jbpm.graph.def.ActionHandler) that can be performed after special events such as entry in a node, the output from one node and the transition between states.The process definitions are contained within the XML file that can be constructed by hand or by using the graphical tool JBoss jBPM Graphical Process Designer (GPD) distributed as an Eclipse plugin.

Page 17: jBPM Overview &  Alfresco Workflows

./jPDL |Process DefinitionThe definition of a process represent what needs to happen within the system during a business process and can be composed of a set of sub-processes.It is formalized in terms of:

State (node) : A state within a process specifies a dependency on external actors. At runtime this means that the workflow engine must wait until an outside actor notification that the execution has been completed.

Page 18: jBPM Overview &  Alfresco Workflows

./jPDL |Process DefinitionAction : An action is the application logic that must be performed by the workflow engine after the occurrence of a specific event. Flows of concurrent execution are modeled with forks and joins, while the exclusive execution flows are modeled with merge and decision points.Transitions : are about moving the process from one state to another through the application of a predetermined action.Process Context : the context of the process managed by workflow.

Page 19: jBPM Overview &  Alfresco Workflows

./jBPM-jPDL SuiteArchitecture

Page 20: jBPM Overview &  Alfresco Workflows

./Installing jBPM-jPDL suite

Step 1/3 - Install Java (easy)

Required java 5.0 or above (I used java 6)Set properly the environment variable JAVA_HOME

Page 21: jBPM Overview &  Alfresco Workflows

./Installing jBPM-jPDL suite

Step 2/3 - Install the jBPM engine and the JBoss application server

We need exactly the jbpm-jpdl-suite-3.2.3.zip file from this url

NOTE: Recent versions (recently has been released Version 4 of jBPM) are not well documented and introduce substantial changes in libraries. Moreover, most of the resources available on the network relies on this version.

Page 22: jBPM Overview &  Alfresco Workflows

...

The suite is a download that contains all the jBPM components bundled in one easy download. The download includes the following folders:

config, configuration files for a standard java environmentdb, SQL scripts for DB creation and compatibility informationdesigner, the eclipse plugin to author jPDL processes and installation scripts (this is not part of the plain jpdl download ).

./Installing jBPM-jPDL suite

Page 23: jBPM Overview &  Alfresco Workflows

...doc, userguide and javadocsexampleslib, libraries on which jbpm dependsserver, a preconfigured jboss that contains jbpm inside the console web application (this is not part of the plain jpdl download)src, the jbpm and identity component java sources

./Installing jBPM-jPDL suite

Page 24: jBPM Overview &  Alfresco Workflows

...

Let's make sure the installation is working correctly:Go into the server directory and lunch ./start.sh

Open the url http://localhost:8080/jbpm-console/

./Installing jBPM-jPDL suite

Page 25: jBPM Overview &  Alfresco Workflows

...The workflow application bundled with jBPM

./Installing jBPM-jPDL suite

Page 26: jBPM Overview &  Alfresco Workflows

./Installing jBPM-jPDL suite

Step 3/3 - Install the JBoss jBPM designerWe need Eclipse 3.3.x

NOTE: for the installation of Eclipse jBPM Designer, consult the guide on the official site of JBoss.

Page 27: jBPM Overview &  Alfresco Workflows

./Installing jBPM-jPDL suite

...

Page 28: jBPM Overview &  Alfresco Workflows

./jBPM Workflow |In action!

We'll cover 3 examples:

Review & Approve Workflow

API usage

A real jBPM use case: Alfresco Workflows

Page 29: jBPM Overview &  Alfresco Workflows

./Review & Approve Workflow

Review & Approve (the Hello World)

A simple workflow for approval and rejection of documents. Consider the case of a news organization that write articles for a magazine. There are "editors" who write articles and submit them to review to a group of "approvers" who decide to approve or deny a particular article.

Page 30: jBPM Overview &  Alfresco Workflows

./Review & Approve WorkflowProcess Graphical Design

Page 31: jBPM Overview &  Alfresco Workflows

Process Definition Properties

Two swimlanes :editorsapprovers

./Review & Approve Workflow

Page 32: jBPM Overview &  Alfresco Workflows

Start State Properties

./Review & Approve Workflow

Page 33: jBPM Overview &  Alfresco Workflows

Start State Properties

Process Variables declaration:Data inizioDescrizione(... si potrebbero aggiungere altre variabili come ad esempio il corpo dell'articolo)

./Review & Approve Workflow

Page 34: jBPM Overview &  Alfresco Workflows

Transition Properties

Transition "submit" start -> reviewIt's possible to bind it an Action to perform...

./Review & Approve Workflow

Page 35: jBPM Overview &  Alfresco Workflows

processdefinition.xml

./Review & Approve Workflow

Page 36: jBPM Overview &  Alfresco Workflows

The prototype user interface

Before you deploy the process on the JBoss server should create the so-called "task forms", or graphical user interfaces pertaining to different tasks, whereby each user can complete tasks assigned to him.

./Review & Approve Workflow

Page 37: jBPM Overview &  Alfresco Workflows

Generate the task forms

We need to generate one of these task forms for every task node in our process.

The task forms use XHTML JavaServer Faces tags.

./Review & Approve Workflow

Page 38: jBPM Overview &  Alfresco Workflows

JSF ???

./Review & Approve Workflow

Page 39: jBPM Overview &  Alfresco Workflows

./Review & Approve Workflow

Page 40: jBPM Overview &  Alfresco Workflows

Fortunately we have the jBPM Designer ...

For each task you can automatically generate the form!

./Review & Approve Workflow

Page 41: jBPM Overview &  Alfresco Workflows

submitReviewTask.xhtml

./Review & Approve Workflow

Page 42: jBPM Overview &  Alfresco Workflows

Deploying the process

./Review & Approve Workflow

Page 43: jBPM Overview &  Alfresco Workflows

Investigate the web consoleFirst we create two groups: editors and approvers . Then we add two users respectively: editor1 and approver1

./Review & Approve Workflow

Page 44: jBPM Overview &  Alfresco Workflows

Investigate the web console

./Review & Approve Workflow

Page 45: jBPM Overview &  Alfresco Workflows

Investigate the web console

./Review & Approve Workflow

Page 46: jBPM Overview &  Alfresco Workflows

Investigate the web console

./Review & Approve Workflow

Page 47: jBPM Overview &  Alfresco Workflows

Investigate the web console

./Review & Approve Workflow

Page 48: jBPM Overview &  Alfresco Workflows

Investigate the web console

./Review & Approve Workflow

Page 49: jBPM Overview &  Alfresco Workflows

./jBPM API UsageHello World Test

Page 50: jBPM Overview &  Alfresco Workflows

./jBPM API Usage...

Page 51: jBPM Overview &  Alfresco Workflows

./jBPM API UsageProcess Variables Test

Page 52: jBPM Overview &  Alfresco Workflows

./jBPM API UsageCustom Action Example

Page 53: jBPM Overview &  Alfresco Workflows

./jBPM API UsageCustom Action Example

Page 54: jBPM Overview &  Alfresco Workflows

./jBPM API Usage...

Page 55: jBPM Overview &  Alfresco Workflows

./Alfresco Workflows

Alfresco supports two different types of workflow:

Simple Workflow: content-oriented.

Advanced Workflow: task-oriented.

Page 56: jBPM Overview &  Alfresco Workflows

./Alfresco WorkflowsSimple Workflow Simple Workflow allows you to implement a type of workflow in which the change of status of the document entails moving the document from one folder to another folder of an organization space. Each state is represented by a folder through which "walk" the documents and move from one state to the next. For more details on Simple Workflow consult the official Alfresco wiki.

Page 57: jBPM Overview &  Alfresco Workflows

./Alfresco WorkflowsSimple Workflow Limitazioni:

It's impossible to create a workflow definition multi-state;Confined to one or two output transitions (the only ones allowed are approve , reject );It's impossible to define "parallel" workflows;There is no concept of task or assignment ;

Page 58: jBPM Overview &  Alfresco Workflows

./Alfresco WorkflowsAdvanced Workflow The Advanced Workflow is task-oriented: a task is created, to which are attached documents, and should be assigned to a particular user. Each user can track the list of tasks assigned to him or instantiated from him. It's possible to change the status of a task, or reassign it to another user, or delete it.

Page 59: jBPM Overview &  Alfresco Workflows

./Alfresco WorkflowsA real use case In our system we have two workgroups: editors and approvers. And we have two separated and simmetric spaces or folders into Alfresco, under the main space called "QBR intranet" : "restricted "and "public" .Editors have write privileges only on the restricted space. John, member of the editors group, create his own article and upload it into any place under the "restricted" folder, then he submit the doc for approval to every approvers in pooled task mode. If the document will be approved (by one of the approvers that has taken the ownership of the revision), the system automatically will copy it from its "restricted" location into the simmetric "public" location, replicating the tree structure of subfolders if the case.

Page 60: jBPM Overview &  Alfresco Workflows

./Alfresco WorkflowsA real use case

Page 61: jBPM Overview &  Alfresco Workflows

./Alfresco WorkflowsComponents

Page 62: jBPM Overview &  Alfresco Workflows

./Alfresco WorkflowsComponents

Process definitionTask Model: provides a description of any human-based tasks within the process.

The task description is used to guide the dialogue between the user and the interface in the display and management of the task. Within the Task Model is used the Alfresco Data Dictionary for a description of the object types to store, view or modify.Each task description consists of:

Name e TitleProperties e Associations

Page 63: jBPM Overview &  Alfresco Workflows

./Alfresco WorkflowsComponents

Web client configuration: Specifies the presentation of the Task inside the Alfresco Web Client. The configuration allows you to:

Control which task properties are displayedControl which task properties are read-only or requiredCheck how task properties are displayed in the UI.

Resource Bundle (optional): The resource bundle provides all the human-readable messages that appear in the UI for workflow management (eg titles of task, the names of properties, etc. ..), thus facilitating also the location of the UI.

Page 64: jBPM Overview &  Alfresco Workflows

./Creating an Advanced Workflow

Step 1: Create the Process Definition Two way for creating the process definition document:

1. “By hand” creating a jPDL xml document 2. Using the jBPM Process Designer

Page 65: jBPM Overview &  Alfresco Workflows

./Creating an Advanced WorkflowStep 1: Create the Process Definition

Page 66: jBPM Overview &  Alfresco Workflows

./Creating an Advanced Workflow...processdefinition.xml

Page 67: jBPM Overview &  Alfresco Workflows

./Creating an Advanced Workflow...processdefinition.xml

SwimlaneSwimlanes are used to declare the roles within the workflow, ie who should do what.A special swimlane is called 'initiator' with which the actor in the workflow is the one that started the workflow.

Pooled TaskA task become a 'pooled task' when it is assigned to a group of people, but only one of them can take the ownership. Once he has taken ownership, the person can perform the task, completes it, or he can put it back again in the pool to be available to other people group.

Page 68: jBPM Overview &  Alfresco Workflows

./Creating an Advanced Workflow...processdefinition.xml

Alfresco provide all the power of Javascript to express the business logic within a workflow

Page 69: jBPM Overview &  Alfresco Workflows

./Creating an Advanced Workflow...processdefinition.xml

Page 70: jBPM Overview &  Alfresco Workflows

./Creating an Advanced Workflow...processdefinition.xml

Page 71: jBPM Overview &  Alfresco Workflows

./Creating an Advanced Workflow...processdefinition.xml

Page 72: jBPM Overview &  Alfresco Workflows

./Creating an Advanced WorkflowStep 2: Deploying into Alfresco ...from the Designer

Through the Process Designer, you can deploy the process on the Alfresco server:1. Make sure the Alfresco server is runnin 2. On the Deployment tab enter:

1. Server Name = name of the machine where you installed Alfresco2. Server Port = port number assigned to Alfresco (default: 8080)3. Server Deployer = /alfresco/jbpm/deployprocess

3. Press Test Connection ... to test the connection.4. Finally, Deploy Process Archive.

Page 73: jBPM Overview &  Alfresco Workflows

./Creating an Advanced WorkflowStep 2: Deploying into Alfresco ...from the Alfresco workflow-console

1. Hand-copy the files related to the process within/alfresco/extension/workflows/{nome_processo}/

2. Start Alfresco and go in the workflow-console URL http://localhost:8080/alfresco/faces/jsp/admin/workflow-console.jsp 3. Deploy the new workflow by typing:deploy alfresco/extension/workflows/{nome_processo}/processdefinition.xml 4. Restart Alfresco

Page 74: jBPM Overview &  Alfresco Workflows

./Creating an Advanced Workflow...

Page 75: jBPM Overview &  Alfresco Workflows

./Creating an Advanced WorkflowStep 3:The Task Model A Task Model is simply a type of Content Model as supported by the Data Dictionary. To create a Task Model: 1. Create a new Content Model for the definition of the process.2. Create a 'type' for each task.3. Within each 'type' describe Properties and Associations required

for that task.

Page 76: jBPM Overview &  Alfresco Workflows

./Creating an Advanced Workflow... reviewPublishModel.xml

Page 77: jBPM Overview &  Alfresco Workflows

./Creating an Advanced Workflow... reviewPublishModel.xml

Page 78: jBPM Overview &  Alfresco Workflows

./Creating an Advanced Workflow... reviewPublishModel.xml

A Workflow Package is used to hold the content that's routed through the workflow. Content within the package may be viewed, edited, or removed.Some Action Groups available for Workflow Packages: read_package_item_actions allow viewing of package items edit_package_item_actions above + allow modification (edit, checkout, ...) of package items edit_and_remove_package_item_actions above + allow removal of package items remove_package_item_actions allow removal (but not modification) of package items

Page 79: jBPM Overview &  Alfresco Workflows

./Creating an Advanced Workflow... reviewPublishModel.xmlAlfresco provides a pre-registered Content Model for the description of common attributes to all tasks, which are:

Start Date Due Date Completion Date Priority Status Workflow Package Context…....

Page 80: jBPM Overview &  Alfresco Workflows

./Creating an Advanced Workflow... reviewPublishModel.xml

These info are defined in the 'bpm:businessprocessmodel' Model, within the file alfresco/model/bpmModel.xml . In this model the two most important type definitions are: 'bpm:workflowTask' and 'bpm:startTask'. All the custom workflow task definitions must inherit from one of these two onces.The start-task in the Task Model must inherit from 'bpm:startTask'. Usually in the Start-task we select participants who have a role within the workflow:

bpm:assignee select a single person.bpm:assignees select one or more persons.bpm:groupAssignee select a single groupbpm:groupAssignees select one or more groups.

Page 81: jBPM Overview &  Alfresco Workflows

./Creating an Advanced WorkflowStep 3: Update the Web client configuration The configuration allows you to:

Control which Tasks properties are displayedControl which Tasks properties are read-only or requiredControl how Tasks properties are displayed into the UI.

The file interested is the web-client-config-custom.xml :

Page 82: jBPM Overview &  Alfresco Workflows

./Creating an Advanced Workflow...web-client-config-custom.xml

Page 83: jBPM Overview &  Alfresco Workflows

./Creating an Advanced WorkflowStep 4: Create the resource bundle The resource bundle provides all the human-readable messages that appear in the UI for workflow management (eg titles of task, the names of properties, etc. ..), thus facilitating also the location of the UI.

Page 84: jBPM Overview &  Alfresco Workflows

./Creating an Advanced WorkflowStep 5: Deploy the Task Model and the resource bundle The Task Model is just a Content Model, so may be deployed like any other Content Model.

Page 85: jBPM Overview &  Alfresco Workflows

./ReferencesjBPMjBoss jBPMWebsitehttp://www.jboss.org/jbossjbpm/

jPDL Guidehttp://docs.jboss.com/jbpm/v3.2/userguide/html_single/

jbpm-jpdl-3.2.3.ziphttp://bit.ly/j357v

Javadoc APIhttp://docs.jboss.org/jbpm/v3/javadoc/index.html

[PACKT-BOOK] - "Business Process Management with jBoss jBPM" - Matt Cumberlidge

Page 86: jBPM Overview &  Alfresco Workflows

./ReferencesAlfrescoWebsitehttp://www.alfresco.com/

Alfresco Wikihttp://wiki.alfresco.com

WorkflowAdministrationhttp://wiki.alfresco.com/wiki/WorkflowAdministration

Javascript APIhttp://wiki.alfresco.com/wiki/Workflow_JavaScript_API

[PACKT-BOOK] - "Alfresco Developer Guide" - Jeff Potts

OthersWikipedia Mokabytehttp://bit.ly/4D8ZKz

Page 87: jBPM Overview &  Alfresco Workflows

Copyright (C) 2009 - QBR engineering

http://www.qbreng.it

released underCreativeCommons 3.0 by-nc-sa

NOTE:Some images and contents are property of the respective copyright

holders and are used for purely educational purposes.