jBPM Overview & Alfresco Workflows


Published on

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

Published in: Technology
No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

jBPM Overview & Alfresco Workflows

  1. 1. JBPM Overview & Alfresco Workflows @author: Francesco Valente @email: francesco83.valente@gmail.com @franko_valente
  2. 2. ./Road map 1. Introduction Business Process Management Domain Specific Languages Graph Oriented Programming 2. jBPM Overview Workflows Process Definition 3. jBPM-jPDL Suite Installing the jBPM engine Installing the jBPM Designer 4. jBPM In Action! Review & Approve workflow Step-by-Step jBoss jBPM WF API usage A Real jBPM use case: Alfresco WF Step-by-Step Alfresco Advanced Workflow
  3. 3. ./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 requirements The developer : creates executable software In small teams, these two roles can of course be fullfilled by one person.
  4. 4. ./Introduction | BPM The business analyst and the developer NEED to communicate in a common language with the help of the graphical view of the process.
  5. 5. ./Introduction |DSL Each process language can be considered a Domain Specific Language (DSL)
  6. 6. ./Introduction |DSL Domain Specific Languages Each language has a certain grammar That 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.
  7. 7. ./Introduction |DSL Domain 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 FluentInterfaces External 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)
  8. 8. ./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
  9. 9. ./Introduction |GOP Graph Oriented Programming Two main features: support for wait states graphical rappresentation
  10. 10. ./Introduction |GOP Support for wait states With an imperative language there's no wait instruction Blocking threads is not a solution: threads are not persistable To achive persistance we need a database interaction. RAM based programs are not sufficients.
  11. 11. ./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.
  12. 12. ./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).
  13. 13. ./jBPM |Workflows A 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.
  14. 14. ./jPDL |Process Definition Example: jPDL notation of an approve & reject process of documents.
  15. 15. ./jPDL |Process Definition
  16. 16. ./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.
  17. 17. ./jPDL |Process Definition The 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.
  18. 18. ./jPDL |Process Definition Action : 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.
  19. 19. ./jBPM-jPDL Suite Architecture
  20. 20. ./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
  21. 21. ./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.
  22. 22. ./Installing jBPM-jPDL suite ... 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 environment db, SQL scripts for DB creation and compatibility information designer, the eclipse plugin to author jPDL processes and installation scripts (this is not part of the plain jpdl download ).
  23. 23. ./Installing jBPM-jPDL suite ... doc, userguide and javadocs examples lib, libraries on which jbpm depends server, 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
  24. 24. ./Installing jBPM-jPDL suite ... 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/
  25. 25. ./Installing jBPM-jPDL suite ... The workflow application bundled with jBPM
  26. 26. ./Installing jBPM-jPDL suite Step 3/3 - Install the JBoss jBPM designer We need Eclipse 3.3.x NOTE: for the installation of Eclipse jBPM Designer, consult the guide on the official site of JBoss.
  27. 27. ./Installing jBPM-jPDL suite ...
  28. 28. ./jBPM Workflow |In action! We'll cover 3 examples: Review & Approve Workflow API usage A real jBPM use case: Alfresco Workflows
  29. 29. ./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.
  30. 30. ./Review & Approve Workflow Process Graphical Design
  31. 31. ./Review & Approve Workflow Process Definition Properties Two swimlanes : editors approvers
  32. 32. ./Review & Approve Workflow Start State Properties
  33. 33. ./Review & Approve Workflow Start State Properties Process Variables declaration: Data inizio Descrizione (... si potrebbero aggiungere altre variabili come ad esempio il corpo dell'articolo)
  34. 34. ./Review & Approve Workflow Transition Properties Transition "submit" start -> review It's possible to bind it an Action to perform...
  35. 35. ./Review & Approve Workflow processdefinition.xml
  36. 36. ./Review & Approve Workflow 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.
  37. 37. ./Review & Approve Workflow 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.
  38. 38. ./Review & Approve Workflow JSF ???
  39. 39. ./Review & Approve Workflow
  40. 40. ./Review & Approve Workflow Fortunately we have the jBPM Designer ... For each task you can automatically generate the form!
  41. 41. ./Review & Approve Workflow submitReviewTask.xhtml
  42. 42. ./Review & Approve Workflow Deploying the process
  43. 43. ./Review & Approve Workflow Investigate the web console First we create two groups: editors and approvers . Then we add two users respectively: editor1 and approver1
  44. 44. ./Review & Approve Workflow Investigate the web console
  45. 45. ./Review & Approve Workflow Investigate the web console
  46. 46. ./Review & Approve Workflow Investigate the web console
  47. 47. ./Review & Approve Workflow Investigate the web console
  48. 48. ./Review & Approve Workflow Investigate the web console
  49. 49. ./jBPM API Usage Hello World Test
  50. 50. ./jBPM API Usage ...
  51. 51. ./jBPM API Usage Process Variables Test
  52. 52. ./jBPM API Usage Custom Action Example
  53. 53. ./jBPM API Usage Custom Action Example
  54. 54. ./jBPM API Usage ...
  55. 55. ./Alfresco Workflows Alfresco supports two different types of workflow: Simple Workflow: content-oriented. Advanced Workflow: task-oriented.
  56. 56. ./Alfresco Workflows Simple 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.
  57. 57. ./Alfresco Workflows Simple 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 ;
  58. 58. ./Alfresco Workflows Advanced 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.
  59. 59. ./Alfresco Workflows A 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.
  60. 60. ./Alfresco Workflows A real use case
  61. 61. ./Alfresco Workflows Components
  62. 62. ./Alfresco Workflows Components Process definition Task 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 Title Properties e Associations
  63. 63. ./Alfresco Workflows Components Web client configuration: Specifies the presentation of the Task inside the Alfresco Web Client. The configuration allows you to: Control which task properties are displayed Control which task properties are read-only or required Check 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.
  64. 64. ./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
  65. 65. ./Creating an Advanced Workflow Step 1: Create the Process Definition
  66. 66. ./Creating an Advanced Workflow ...processdefinition.xml
  67. 67. ./Creating an Advanced Workflow ...processdefinition.xml Swimlane Swimlanes 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 Task A 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.
  68. 68. ./Creating an Advanced Workflow ...processdefinition.xml Alfresco provide all the power of Javascript to express the business logic within a workflow
  69. 69. ./Creating an Advanced Workflow ...processdefinition.xml
  70. 70. ./Creating an Advanced Workflow ...processdefinition.xml
  71. 71. ./Creating an Advanced Workflow ...processdefinition.xml
  72. 72. ./Creating an Advanced Workflow Step 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 Alfresco 2. 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.
  73. 73. ./Creating an Advanced Workflow Step 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
  74. 74. ./Creating an Advanced Workflow ...
  75. 75. ./Creating an Advanced Workflow Step 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.
  76. 76. ./Creating an Advanced Workflow ... reviewPublishModel.xml
  77. 77. ./Creating an Advanced Workflow ... reviewPublishModel.xml
  78. 78. ./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
  79. 79. ./Creating an Advanced Workflow ... reviewPublishModel.xml Alfresco 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 …....
  80. 80. ./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 group bpm:groupAssignees select one or more groups.
  81. 81. ./Creating an Advanced Workflow Step 3: Update the Web client configuration The configuration allows you to: Control which Tasks properties are displayed Control which Tasks properties are read-only or required Control how Tasks properties are displayed into the UI. The file interested is the web-client-config-custom.xml :
  82. 82. ./Creating an Advanced Workflow ...web-client-config-custom.xml
  83. 83. ./Creating an Advanced Workflow Step 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.
  84. 84. ./Creating an Advanced Workflow Step 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.
  85. 85. ./References jBPM jBoss jBPMWebsite http://www.jboss.org/jbossjbpm/ jPDL Guide http://docs.jboss.com/jbpm/v3.2/userguide/html_single/ jbpm-jpdl-3.2.3.zip http://bit.ly/j357v Javadoc API http://docs.jboss.org/jbpm/v3/javadoc/index.html [PACKT-BOOK] - "Business Process Management with jBoss jBPM" - Matt Cumberlidge
  86. 86. ./References Alfresco Website http://www.alfresco.com/ Alfresco Wiki http://wiki.alfresco.com WorkflowAdministration http://wiki.alfresco.com/wiki/WorkflowAdministration Javascript API http://wiki.alfresco.com/wiki/Workflow_JavaScript_API [PACKT-BOOK] - "Alfresco Developer Guide" - Jeff Potts Others Wikipedia Mokabyte http://bit.ly/4D8ZKz
  87. 87. Copyright (C) 2009 - QBR engineering http://www.qbreng.it released under CreativeCommons 3.0 by-nc-sa NOTE:Some images and contents are property of the respective copyright holders and are used for purely educational purposes.