Vous êtes sur la page 1sur 27

Alfresco Activiti Workflow

Student Guide

Publication Date: 23rd November 2011


Version: 1.0

Alfresco
Training
Alfresco Activiti Workflow

Document Information
Information in this document is subject to change without notice. No part of this document may be reproduced or transmitted in any form or by any means, electronic or mechanical,
for any purpose, without the express written permission of Alfresco. The trademarks, service marks, logos, or other intellectual property rights of Alfresco and others used in this
documentation ("Trademarks") are the property of Alfresco and their respective owners. The furnishing of this document does not give you license to these patents, trademarks,
copyrights, or other intellectual property except as expressly provided in any written agreement from Alfresco.

The United States export control laws and regulations, including the Export Administration Regulations of the U.S. Department of Commerce, and other applicable laws and regulations
apply to this documentation which prohibit the export or re-export of content, products, services, and technology to certain countries and persons. You agree to comply with all export
laws, regulations, and restrictions of the United States and any foreign agency or authority and assume sole responsibility for any such unauthorized exportation.

You may not use this documentation if you are a competitor of Alfresco, except with Alfresco's prior written consent. In addition, you may not use the documentation for purposes of
evaluating its functionality or for any other competitive purposes.

If you need technical support for this product, contact Customer Support by email at support@alfresco.com. If you have comments or suggestions about this documentation, contact us
at training@alfresco.com.

 Alfresco 2011

Revision History
This shows the history of the course software and materials and the applicable releases of Alfresco software
which this course relates to.

Reference Course Version Alfresco Releases Publication Date Notes


460 1.0 4.0 onwards 2011-01-23 New course created for
Activiti

Typographical Conventions
The following conventions are used in this guide to indicate types of information.

Convention Type of Information


bold Identifies user interface elements and items to select, such as menu options,
command buttons, and items in a list.
monospace Identifies file and path names, input text, standard output, code, and so on.
italics Emphasizes importance and used to introduce new concepts and terms.

23 November 2011 Page 2


Alfresco Activiti Workflow

Contents
Document Information................................................................................................................2
Revision History ................................................................................................................................................ 2
Typographical Conventions .............................................................................................................................. 2
Contents .....................................................................................................................................3
Exercises .....................................................................................................................................5
New instructions go here ................................................................................................................................. 5
Welcome ....................................................................................................................................6
Course Summary .............................................................................................................................................. 6
Objectives ......................................................................................................................................................... 6
Audience........................................................................................................................................................... 6
Course Outline .................................................................................................................................................. 6
1. Alfresco Workflow Overview ...................................................................................................7
Learning Objectives .......................................................................................................................................... 7
What is covered in this section ........................................................................................................................ 7
Labs .................................................................................................................................................................. 7
Exercise 1 ..................................................................................................................................................... 7
Authenticate and Login ................................................................................................................................ 7
Stretch Goals ................................................................................................................................................ 8
2. Defining Workflows .................................................................................................................9
Learning Objectives .......................................................................................................................................... 9
What is covered in this section ........................................................................................................................ 9
Labs .................................................................................................................................................................. 9
Background .................................................................................................................................................. 9
Exercise 2 ................................................................................................................................................... 10
Exercise 3 ................................................................................................................................................... 11
3. Process Definition Language .................................................................................................. 12
Learning Objectives ........................................................................................................................................ 12
What is covered in this section ...................................................................................................................... 12
Labs ................................................................................................................................................................ 12
Exercise 4 ................................................................................................................................................... 12
 An artist initiates a workflow, with an image...................................................................................... 12
 The user admin reviews the image and can comment. ...................................................................... 12
 Alice Beecher gets a notification of the review................................................................................... 12
Exercise 5 ................................................................................................................................................... 13
SOP Case Study Setup ................................................................................................................................ 14
Exercise 6 ................................................................................................................................................... 15
Exercise 7 ................................................................................................................................................... 15
4. Task Definition ...................................................................................................................... 17
Learning Objectives ........................................................................................................................................ 17
What is covered in this section ...................................................................................................................... 17

23 November 2011 Page 3


Alfresco Activiti Workflow

Exercise........................................................................................................................................................... 17
Part 1 – Developing the Task Model .......................................................................................................... 17
Part 2 – Adding Logic ................................................................................................................................. 21
5. Alfresco Explorer Integration ................................................................................................. 22
Learning Objectives ........................................................................................................................................ 22
What is covered in this section ...................................................................................................................... 22
Exercise........................................................................................................................................................... 22
Part 1 - Display the Properties ................................................................................................................... 22
Part 2 – Package Control ............................................................................................................................ 23
6. Workflow and the Repository ................................................................................................ 24
Learning Objectives ........................................................................................................................................ 24
What is covered in this section ...................................................................................................................... 24
Exercise........................................................................................................................................................... 24
7. Process Completion ............................................................................................................... 25
8. Stretch Goals ......................................................................................................................... 26
Solutions ..........................................................................................Error! Bookmark not defined.
Part 6 – Process Creation ................................................................................... Error! Bookmark not defined.
Part 7 – Process Enhancement ........................................................................... Error! Bookmark not defined.
Part 8 – Process Enhancement Multiple Tokens ................................................ Error! Bookmark not defined.
Alfresco Explorer Integration ............................................................................. Error! Bookmark not defined.
Part 1 – Display the Properties ...................................................................... Error! Bookmark not defined.
Part 2 – Package Control ................................................................................ Error! Bookmark not defined.
References................................................................................................................................ 27
Alfresco Training............................................................................................................................................. 27
jBPM ............................................................................................................................................................... 27
Alfresco Community ....................................................................................................................................... 27
Trade and Industry Organizations .................................................................................................................. 27
Books .............................................................................................................................................................. 27

23 November 2011 Page 4


Alfresco Activiti Workflow

Exercises
This is an interactive course where the exercises have been designed to augment what you learn in class and
re-enforce your knowledge through progressively more complex labs.

A lab environment is provided to you in the form of a virtual machine based on VMWare’s VMWare Server
product. In order to run these labs you must install either of these products on your laptop:

 For Windows: VMWare Player 3 or 4


 For Linux: VMware Player 3 for Linux Operating Systems
 For Mac: VMware Fusion 3 or 4

VMWare Player for Windows and Linux is free, although you will need to register with www.vmware.com,
VMWare Fusion for the Mac is however a purchasable product which can be acquired for a small sum. If you
have not used the product before you can download a 30 day free trial for use on the course.

New instructions go here


This machine is intended to be used to support course exercises and is not intended for
production use.

23 November 2011 Page 5


Alfresco Activiti Workflow

Welcome
Welcome to the Alfresco Activiti Workflow Course. Your Student Guide is designed to help you through the
course, contains the exercises or Labs and provides supplementary information that you might find useful.

Course Summary
This course covers Alfresco Activiti Workflows from start to finish, and will enable the design, development,
and deployment of custom workflows that meet your business needs.

Objectives
At the end of this course you will:

 Understand workflows

 Know how to define workflows

 Know how to define task models

 Be able to customize the Alfresco Share for workflow

 Understand how workflow can interact with content

 Know how to deploy custom workflows

Audience
This course is aimed at developers who have prior knowledge of Alfresco and now want to be able to create
and deploy workflows in an Alfresco environment.

Delegates are expected to understand workflow concepts and have used Alfresco, they should be familiar with
java and an Integrated Development Environment (IDE) such as Eclipse.

It is desirable and helpful if delegates have been on the Alfresco Fundamentals training course and the Share
Configuration training course.

Course Outline
 Alfresco Workflow Overview

 Defining and Viewing Workflows

 Process Definition

 Task Definition

 Alfresco Share Integration

 Workflow and the Repository

23 November 2011 Page 6


Alfresco Activiti Workflow

1. Alfresco Workflow Overview


Learning Objectives
Our goal in this section is to begin to understand workflow concepts and some of the terminology that Alfresco
uses in these contexts.

What is covered in this section


 What is a workflow

 How end users see workflows

 Workflow architecture

 Administering workflow

 Developer features

Labs

Exercise 1
Our goal in this section is to explore the user interface functions for workflow by initiating and running a
workflow through to completion based on the in-built process definitions.

Authenticate and Login


1. Point your browser to http://<server name>:8080/share

2. Login as Tom Small (tom:small)

3. Navigate to the Web Site Design Project Site. Go to the Project Library > Presentations.

4. Choose one of the documents you find in here and then initiate a Review & Approve workflow.

5. Enter some instructions in the Message field and choose Harriet Slim as the Reviewer.

6. Once the workflow has started login as Harriet (harriet:slim).

7. Complete the task (Approve) that has been delivered to Harriet.

8. Repeat steps 2 through 6, this time when you login as Harriet reject the task and note what happens.

9. From your dashboard, click the Start Workflow in the My Tasks dashlet, start a Group Review and
Approve workflow.

10. Enter some instructions in the Message field and choose Documentation as the Review Group.

11. Set the following fields on the rest of the form:

a. Enter today as the Due date.


b. Set the priority to high.
c. Set the Required Approval Percentage at 40.
d. Add the budget.xls file as a package from Web Site Design Project Site > Project Library >
Budget Files.

23 November 2011 Page 7


Alfresco Activiti Workflow

12. Once the workflow has started login navigate to More > Workflows I’ve Started and find out where
the workflow tasks have gone.

13. For each task in the workflow login as the assigned individual and complete the task. Make sure that
you reject one and approve the other.

14. What happened, can you explain the behavior you see?

Stretch Goals
1. Re-run the Group Review and Approve Workflow, this time set the Required Approval Percentage to
60 and see what happens.

2. Turn to the Default Workflow Process Definitions section of this guide and review the workflow
definitions for the Ad-Hoc and Review & Approve Workflows; this will start to familiarize you with the
process definitions that Alfresco uses.

23 November 2011 Page 8


Alfresco Activiti Workflow

2. Defining Workflows
Learning Objectives
In this section we introduce you to Activiti the workflow engine used by Alfresco and we look at how it
integrates into the Alfresco architecture. We also looks at the different approaches to defining workflows, this
will allow you to understand the best way for you to define workflows and begin to understand the best
practices involved in the definition and building of Alfresco workflows.

What is covered in this section


 Activiti

 Workflow definitions

 Approaches to defining workflows

Labs
Our goal in this section is to create our first workflow by using the Activiti workflow modeler in Eclipse

Background
Our case study focuses around an imaginary company called Green Energy whose mission is:

Provide scientifically sound, high quality products to save the environment through
renewable energy.

As part of their product release processes Green Energy must create artwork which is used in various different
mediums, such as print and the website. This artwork is created by various artists, to ensure quality and
consistency they want to make sure that the artwork is always reviewed by the graphic designer.

Not only will be designing and developing the workflow but you will play the part of an artist starting a
workflow.

Our case study creates a workflow for the review of artwork based on the business process shown in the
following diagram. We will use this case study now through the remainder of this course. Building up the
workflow over the course of a number of exercises.

Notes about the process:

 An artist initiates workflow, with a piece of artwork

 The graphic designer can reject or approve the artwork

 The artist gets a final notification of approval

 Approval also marks the document as approved

 On rejection the artist should makes changes and resubmit with new artwork

23 November 2011 Page 9


Alfresco Activiti Workflow

Exercise 2
In this exercises you will be creating the tasks in the workflow and joining them together with sequence flows,
complete only the approval path do not attempt to add in the reject pathway at this point. It is a good idea to
keep saving your project as you go along at regular intervals.

1. Open Eclipse you will find it on the desktop.

2. In Project Explorer create a new folder called “Artwork Review”

3. In this folder create a new Activiti Diagram called artworkReview

a. Choose New  Other

b. In the select wizard box choose Activiti and select Activiti Diagram

c. Enter “artworkReview” for the filename.

d. If you are prompted for a template choose an empty diagram

4. Layout your workflow tasks. Make sure you use AlfrescoUserTasks for all the tasks.

5. Create the start and end events, the start event should be an AlfrescoStartEvent.

6. The Id for the process must be artworkReview; this can be set in the general properties for the
process as a whole.

7. Next fill in the properties for the events and tasks:

a. The start event should have a form key of bpm:startTask, you can find this setting under
Properties  Main Config.

b. The review task:

i. must have a form key of bpm:workflowTask.

ii. the performer type should be Assignee and the expression should be admin

c. The notify task:

i. must have a form key of bpm:workflowTask.

ii. the performer type should be Assignee and the expression should be admin

8. Save your diagram again and then check that the generated bpmn20.xml file corresponds to your
diagram.

9. Deploy your workflow.

a. Select the *.bpmn20.xml file and export (File  Export  File System) it to Documents.

b. Login to Share as the administrator, from the toolbar choose More, under Admin choose
Application. This will take you to the new Admin Console, from here choose Workflow. This
now displays the Workflow panel, click on Activiti Workflow Console.

23 November 2011 Page 10


Alfresco Activiti Workflow

c. Once in the Activiti Workflow Console navigate to Deployments  Upload new and then
browse to Documents where you saved your bpmn20.xml file. Your file should upload
successfully, if not you will need to check the error and make any correction in Eclipse before
repeating this process.

10. Once the workflow has been deployed start the workflow and use any document you wish from the
Sample Web Site Design Project site document library as an artwork attachment.

11. Since you have assigned the tasks to yourself (admin) they will start to appear in the My Tasks
dashlet. Complete the tasks.

12. Congratulations on your first Activiti workflow.

Exercise 3
In the previous exercise you created a workflow which always follows an approve path. The review task needs
to have a reject path as well. This is a decision hence you will need to add a gateway to your workflow. The
second problem your previous workflow may have experienced is not so self evident (and may not exist
depending on how you constructed it) but the start event displays a form where the workflow initiator
attaches the artwork, then they immediately get the "create" task, so effectively it is like having two create
tasks. We need to stop this happening.

1. Edit your artworkReview workflow in Eclipse and re-work your process so that you now you have the
following tasks:

a. Marketing Approval
b. Revise Artwork
c. Notify Product Manager

2. Add in an exclusive gateway.

3. Make sure you have the correct sequence flows setup and label them by giving them a name, e.g.
Approve/Reject.

4. Save your diagram again and then check that the generated bpmn20.xml file corresponds to your
diagram.

5. Deploy your workflow as your did previously.

6. Once the workflow has been deployed start the workflow and use any document you wish from the
Sample Site as an artwork attachment.

7. Complete the task (approve the task).

8. Start another workflow instance; this time try to reject the review task. What do you notice?

23 November 2011 Page 11


Alfresco Activiti Workflow

3. Process Definition Language


Learning Objectives
In this section you will build and deploy a simple process definition. You will use a Eclipse to create the BPMN
(XML) process definition and deploy the workflow using the Activiti Explorer. This will familiarize you with
BPMN, troubleshooting and creating workflow process definitions from scratch. We will also start to develop
our case study workflow using Eclipse to author the XML.

What is covered in this section


 BPMN

 Workflow definitions

 Approaches to defining workflows

Labs

Exercise 4
The goal of this exercise is to create a simple workflow, deploy the workflow and run it. This workflow is kept
intentionally simple. We are moving away from the marketing artwork review for short while as we are going
to create a BPMN process from scratch. This is the only time we do this, in practice you will most likely always
use the workflow designer and add your own BPMN though the extensions points, like TaskListeners. Note the
diagram is a business representation created by a business analyst – your workflow may not look like this. You
will be using the existing bpm model for the tasks and Share has been pre-configured for you.

Notes about the process:

 An artist initiates a workflow, with an image.

 The user admin reviews the image and can comment.

 Alice Beecher gets a notification of the review.

Instructions

1. Go to Eclipse in Project Explorer create a new folder called “Image Review”

2. In this folder create a new Activiti Diagram called imageReview, if you are prompted for a template
choose an empty diagram.

3. DO NOT add any tasks to the Activiti diagram, simply save the diagram, this will generate a
bpmn20.xml file for you. Double click this file to edit it, creating the Activiti diagram has given you the
required process definition elements and the necessary namespace definitions.

23 November 2011 Page 12


Alfresco Activiti Workflow

4. You can now start creating your workflow to match the business process, remember to add:

a. Start and end events


b. User tasks each with their own unique id, assignee.
c. Sequence flows between the events and tasks with their own unique ids.

5. Add the formKey attribute for the start event and user tasks as follows:

a. Start event: bpm:startTask


b. User tasks: bpm:workflowTask

Note that the ids you specify for elements must be unique across all the elements in your
process; therefore you cannot have a task and sequence flow with the same id.

6. Save your workflow and deploy it in the usual way.

7. Test your workflow.

Exercise 5
In this exercise we revert back to the Artwork Review we started in exercise 2. To recap you should have a
workflow that looks similar to the figure below.

Next you will change the type of the tasks to support the decision variables and add in the required login, in a
listen handler, to implement the approve/reject cycle. You will also change the assignee so that the tasks are
assigned dynamically as follows:

 Approval Task: dynamic assignee chosen by the workflow initiator


 Revise Task: workflow initiator
 Notify: workflow initiator

Instructions

1. In Eclipse got back to your artworkReview process.

2. Edit each task and change the assignee to model the new requirement shown above.

3. Edit each task and start process, changing the formKey to the required task type from the wf model to
support the decision logic, you should use: wf:submitReviewTask, wf:activitiReviewTask,
wf:approvedTask and wf:rejectedTask.

4. Create a task listen handler on the approval task to capture the value of the review outcome and pass
that back to the execution level.

23 November 2011 Page 13


Alfresco Activiti Workflow

5. On one of the flows from the exclusive gateway add in the condition check to check the review
outcome so that the right flow is selected depending on the outcome of the approval task.

6. Save your diagram, check that the generated bpmn20.xml file corresponds to your diagram. Deploy
and test your workflow, making sure that you test both approver and reject flows.

7. Congratulations your Artwork Review process is now fully functioning.

SOP Case Study Setup


We now change our focus to the SOP case study. Our case study focuses around an imaginary company called
Green Energy whose mission is:

Provide scientifically sound, high quality products to save the environment through
renewable energy.

As part of their manufacturing processes Green Energy use Standard Operating Procedures (SOPs) to ensure
quality and consistency and to make sure that they comply with Health and Safety Regulations. These SOPs are
detailed instructions for carrying out a process such as the start-up and shutdown of a complex machine, or
the process for measuring the quality of manufactured goods.

Sometimes a new SOP is required for a new process or an existing SOP has to be changed because a new
machine is introduced for example.

A subject matter expert will revise an existing SOP or author a new one, this SOP must then be reviewed and
approved before it can be used.

Our case study creates a workflow for the review and approval of SOPs based on the business process shown
in the following diagram. We will use this case study now through the remainder of this course. Building up the
workflow over the course of a number of exercises.

Notes about the process:

 An SOP author initiates workflow, with a newly revised SOP

 The SOP must be reviewed by manufacturing and documentation and one person from each
department must approve

 The Quality Assurance director can reject the SOP

 The Quality Assurance director must enter an effective date against the SOP

 The author gets a final notification of approval, approval also marks the document as approved

 On rejection the product manager can decide to resubmit with a revised SOP or cancel the workflow

23 November 2011 Page 14


Alfresco Activiti Workflow

1. In Eclipse create a new project and give it a name; this can be whatever you want. We refer to this as
Alfresco Workflows.

2. Create a new Activiti process in this project and name your process; this can be whatever you want.
We refer to this as SOP Review and Approve.

3. You can now start creating your workflow definition.

If you have not already done so, turn on debug logging so that you can track your workflow in the
alfresco.log file.

Exercise 6
Using the business process diagram as the basis for your workflow, use the graphical process designer to
complete the following:

1. Add in the user tasks, those done by or interacting with a human, for now you can name these
whatever makes sense based on the diagram.

2. Add in the sequence flows between the nodes.

3. Add in reject flows.

4. Deal with the fact that you can’t reject back to the start event, we also want the SOP Author who
initiated the workflow to revise it.

5. Add in appropriate gateways to support decisions.

6. Make sure that the SOP author is able to terminate the workflow if the SOP has not been approved,
rather than revising.

7. Set the FormKey for each task to ones that you think are appropriate for the task in the workflow, use
tasks from the wf model.

8. Set the Assignee for each task to the workflow initiator for now. Do not at this point add in any of the
logic for the approval decisions.

9. Deploy and test your workflow.

How will you model the review step, as two tasks or as a multi-instance task?
If you have used a multi-instance task, use a loop cardinality of 2 to test the workflow. How will
you choose an assignee for this task?

Exercise 7
In this exercise we develop our SOP Review process to add in the decision logic for the review and approve
tasks.

 Change your workflow to use a multi-instance task

 Add in the decision logic for

 Review SOP (multi-sequence task)

23 November 2011 Page 15


Alfresco Activiti Workflow

 QA Review

1. If you have not already done so change your workflow to use a multi-instance task for the SOP Review
task.

2. Add in the decision logic for the QA Review task, this will be same logic that you used in the Artwork
Review workflow.

3. Modify the SOP Review multi-instance task give it the following behaviour: a pooled task with one
person from the Manufacturing group and one person from the Documentation group to review and
approve/reject the task.

 You will need to create a variable to hold the group names as a collection for the multi-
instance task.
 The performer time will need to be “candidate groups”
 You will need to create, and manage a variable, that tracks the number of people who has
approved so that your decision logic can check this.
 You will need to create the appropriate conditions on the flows leaving the exclusive
gateways.

4. When you are ready save you diagram and check the generated BPMN, then deploy your workflow
and test it.

23 November 2011 Page 16


Alfresco Activiti Workflow

4. Task Definition
Learning Objectives
In this section you will learn how a workflow process can interact with the repository and the users. This will
require you to put your prior knowledge of content modeling to create a new task model for the case study
workflow. You will build upon the case study workflow and move away from the graphical process designer to
editing the process definition by hand and adding in the required logic to the workflow.

This will familiarize you with the process of creating a task model to interact with a process, understand how
they link together and how additional logic can be added to the process definition.

What is covered in this section


 The workflow content model

 The task model

 Task types

 Starting tasks

 The relationship of tasks to aspects

Exercise
The goal of this exercise is to create the required task mode, change the process definition to reference the
task model. You will also transition from using the graphical process designer to updating the process
definition directly.

Part 1 – Developing the Task Model


We are now going to develop a bespoke task model for our workflow based on the following table.

Activity Required Task Type Description


Information

Start Instructions wfge:startSopReview We want the following reviewers to see the instructions.
(parent bpm:startTask)

SOP Approval Instructions wfge:sopReview We want the approval group to see the instructions and
Comments (parent provide comments
wf:activitiReviewTask)

QA Approval Instructions wfge:sopReview We want the QA director to see the instructions and
Comments (parent provide comments back
wf:activitiReviewTask)

Revise Instructions wfge:sopRevise If we are at this task it means that the SOP has been
Comments (copied from rejected so we want the author to be able to write the
wf:activitiReviewTask) changes in the instructions, after reviewing the
comments.

Notification Comments wfge:sopNotifcation This is for the initiator to be told that the approval has
(parent been successful, they should still be able to see the
wf:approvedTask) comments.

23 November 2011 Page 17


Alfresco Activiti Workflow

Notes

a. Because Instructions and Comments are common across a number of tasks we will define these as
aspects.

b. The abbreviation for our model is going to be wfge (workflow green energy).

You should be familiar with defining models from the Content Modelling Course, however if you
have difficulties please see the solution or follow the step-by-step instructions below.

Exercise

Use your favorite means for creating a new model and deploying it to Alfresco, based on the table above. Your
model will have four (4) types and two (2) aspects. Use the following as the basis for your model:

<model name="wfge:workflow-green-energy" xmlns="http://www.alfresco.org/model/dictionary/1.0">

<description>Green Energy Workflow Model</description>


<author>Alfresco Training</author>
<version>1.0</version>

<imports>
<import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d"/>
<import uri="http://www.alfresco.org/model/bpm/1.0" prefix="bpm"/>
</imports>

<namespaces>
<namespace uri="http://www.alfresco.org/model/training/1.0" prefix="wfge"/>
</namespaces>

</model>

Step-By-Step Instructions

These step by step instructions help you to create the required task model to support the case study workflow,
remember that you can also look at the solutions.

1. Set-Up the Green Energy Workflow model.

a. Using a text editor create a file called wfGreenEnergyModel.xml in the directory


{TOMCAT_HOME}/webapps/alfresco/WEB-INF/classes/alfresco/workflow

b. Type or copy the above model definition into the file and save it.

c. Go to the directory: {TOMCAT_HOME}/shared/classes/alfresco/extension

d. In this directory rename the file workflow-context.xml.sample to workflow-


context.xml

e. Using a text editor edit workflow-context.xml and add in the following

...
<property name="models">
<list>
<!-- This is the Green Energy Model -->
<value>alfresco/workflow/wfGreenEnergyModel.xml</value>
</list>
</property>
...

23 November 2011 Page 18


Alfresco Activiti Workflow

2. Add in the Aspects to be used in the task definitions, edit the wfGreenEnergyModel.xml file and
add in the following between the tags <model> and </model>. The tasks we create will be
referencing these aspects.

...
<aspects>
<aspect name="wfge:instructions">
<properties>
<property name="wfge:instructions">
<type>d:text</type>
<mandatory>true</mandatory>
</property>
</properties>
</aspect>

<aspect name="wfge:comments">
<properties>
<property name="wfge:comment">
<type>d:text</type>
<mandatory>false</mandatory>
</property>
</properties>
</aspect>
</aspects>
...

23 November 2011 Page 19


Alfresco Activiti Workflow

3. Now add in the tasks to support the workflow, these need to be placed in the
wfGreenEnergyModel.xml file above the <aspects> tag.

...
<types>

<type name="wfge:startSopReview">
<parent>bpm:startTask</parent>
<mandatory-aspects>
<aspect>wfge:instructionAspect</aspect>
</mandatory-aspects>
</type>

<type name="wfge:sopReview">
<parent>bpm:workflowTask</parent>
<mandatory-aspects>
<aspect>wfge:commentAspect</aspect>
<aspect>wfge:instructionAspect</aspect>
</mandatory-aspects>
</type>

<type name="wfge:sopNotification">
<parent>bpm:workflowTask</parent>
<mandatory-aspects>
<aspect>wfge:commentAspect</aspect>
</mandatory-aspects>
</type>

<type name="wfge:sopRevise">
<parent>bpm:workflowTask</parent>
<mandatory-aspects>
<aspect>wfge:commentAspect</aspect>
<aspect>wfge:instructionAspect</aspect>
</mandatory-aspects>
</type>

</types>
...

4. Your content model is now complete and ready to go. You must now update the workflow to
reference the custom model. The tasks (these are the tasks within the task nodes, not the task nodes
themselves) in the workflow need to use the type names defined in the content model. Using the
grpahiucal process designer edit each task and apply the appropriate task name. So for example the
review task by the QA Director will now be called wfge:sopReview.

Before re-deploying and running your workflow restart your server to ensure that the model is
deployed.

23 November 2011 Page 20


Alfresco Activiti Workflow

Part 2 – Adding Logic


With this exercise we are going to move away from the graphical designer and we will start to add in code
directly to the XML of the process definition. You can edit the process definition in Eclipse by clicking on the
Source pane, this has the advantage of still allowing you to use Eclipse for deployment.

By now you will have realized that the decision node always takes the default transition because there is no
decision or conditional logic. This means that in the decision node we need to check to see if both reviews
have approved, the simplest way to accomplish this is to have each review increment a count and then see if
the count is 2 at the decision node.

However since the review and approval workflow may go through several iterations we need to initialize the
count, a good place to do this is in the Submit node as this will be executed for each re-iteration of the
workflow. We can use the node-enter event to do this.

1. Edit the Submit node and add in code to execute when the node is entered. The code should set a
variable (e.g. approvalCount) to zero (0).

2. Edit the two Review nodes and in here add in code (script) to increment the counter variable, but only
on the Approve transition.

3. In the Decision Node we need to check the value of the variable, it should be 2 if both approvals have
happened. Add a condition to the transition to the QA Director Review to check if the variable is set to
2.

4. Re-deploy and re-run your workflow, test that the various combinations work.

23 November 2011 Page 21


Alfresco Activiti Workflow

5. Alfresco Explorer Integration


Learning Objectives
In this section you will learn how the workflow process you have developed integrates with the Alfresco
Explorer so that users can fully interact and control the workflow.

What is covered in this section


 Configuring task dialogs

 Configuring workflow packages

Exercise
The goal of this exercise is to configure the system to change the behavior of the Alfresco Explorer web client.

Part 1 - Display the Properties


We need to change the Alfresco Explorer configuration to show the two new properties we added to the
workflow tasks: instructions and comments.

1. Go to the directory {TOMCAT_HOME}/shared/classes/alfresco/extension and edit the file


web-client-config-custom.xml using a text editor.

2. Add the necessary property support for the two task types: wfge:StartSopReview and
wfge:sopReview. Make the comments appear as a text area.

3. Restart your server and retest your workflow.

The goal of this exercise is to enhance the workflow process to control the package actions each tasks is
allowed to display based on the business requirements.

23 November 2011 Page 22


Alfresco Activiti Workflow

Part 2 – Package Control


We want more refined control of the operations which can be carried out on the packages in different tasks
within the workflow, as shown in the following table.

Node Package Task Type Description


Control

Manufacturing Edit and add wfge:sopReview We want the approval group to see the instructions and provide
Approval comments, be able to check out the package and makes
revisions.

Documentation Edit and add wfge:sopReview We want the approval group to see the instructions and provide
Approval comments, be able to check out the package and makes
revisions.

QA Approval Read only wfge:sopReview We want the QA director to see the instructions and provide
comments back, but the QA Director will not be revising the
content of the SOP.

Revise Edit and add wfge:sopRevise If we are at this task it means that the SOP has been rejected so
we want the author to be able to write the changes in the
instructions, after reviewing the comments. Obviously they need
to be able to revise the package.

Notification Read only wfge:sopNotifcation This is for the initiator to be told that the approval has been
successful; they should still be able to see the comments.
However at this point they should not be able to make changes
to the package.

4. Change your content model wfGreenEnergyModel.xml to reflect the package control outlined in
the table above.

5. Restart your server and retest your workflow.

23 November 2011 Page 23


Alfresco Activiti Workflow

6. Workflow and the Repository


Learning Objectives
In this section you will learn how the workflow process can access the repository to both check objects and
make changes.

What is covered in this section


 Alfresco Javascript

 Adding Lifecycle

Exercise
In this exercise we want to mark the document as approved and we also want to allow the QA director to set
an effective date on the document if it’s approved.

1. There are a number of ways of achieving this goal. Think about the possible options before setting out
on developing the solution.

2. You can use aspects to model this requirement.

3. If the QA Director leaves the date blank set the effective date to today. Otherwise use what they have
entered.

23 November 2011 Page 24


Alfresco Activiti Workflow

7. Process Completion
Up to this point your workflow has always been sending tasks for completion to the workflow initiator. Now
that we have our workflow doing what we want let’s add in the groups and users who should really complete
the tasks. The following table outlines the tasks assignments.

Node Tasks Description Assignment Assignment


Type

Manufacturing Manufacturing This is the SOP review by the SOP pooled actors manufacturing_review
Review Review Review group in manufacturing

Documentation Documentation This is the SOP review by the pooled actors documentation
Review Review Documentation group

QA Review QA Review This is the SOP and approval review actor tom (Tom Klein)
by the QA Director

Revise Revise SOP Allows the Product Manager to swimlane Initiator


revise the artwork if it has been
rejected, or terminate the workflow.

Notification Notify SOP This is a notification to the product swimlane Initiator


Author Manager manager to tell them that their
artwork has been approved

1. Based on the table update the tasks to be completed by the assigned people and groups.

2. Re-deploy and re-run your workflow. In order to help you test your workflow the following users have
been setup, all the user’s passwords are set to “alfresco”.

Username Firstname Lastname Title Role Groups

tom Tom Klein QA Director Quality Assurance

hendrik Hendrik Varius Engineer SOP Author Manufacturing

bijou Bijou Miami Senior Engineer Geo-Thermal Reviewer Manufacturing, Manufacturing Review, Design
Review Board

lennon Lennon Sky Senior Engineer Geo-Thermal Reviewer Manufacturing, Manufacturing Review

bill Bill Dewi Documentation Manager Reviewer Documentation

uschi Uschi Usha Technical Author Reviewer Documentation

23 November 2011 Page 25


Alfresco Activiti Workflow

8. Stretch Goals
These stretch goals can be completed during the course if you have time or alternatively after the course has
finished where you can work at your own pace.

1. Think about changes you could make to the workflow, to make it more robust and meaningful?

2. What changes could you make to the business process to make it more useful?

3. Using the knowledge you gained on the Content Modelling and Alfresco Explorer Integration course
create a resources file with strings for the different elements of the workflow (e.g. task names,
buttons, etc.) in your local language. Deploy and test the web client configuration changes you have
made.

4. The following location in the folder structure:

Company Home > Geo-Thermal Division > Manufacturing > Standard Operating Procedures

has 4 folders Draft, In Review, Effective and Superseded. Enhance the workflow so that the SOP
document moves to the appropriate folder depending on its stage in the workflow. How else could
you have completed the same task.

5. A new business process has been introduced which requires that an SOP can only be changed or
created based on a Change Request. A Change Request is another type of document which lists the
reasons and rationale for creating or altering an existing SOP, this might simply be to make a
correction in grammar or spelling or could be required for a more major reason. The Change Request
may refer to multiple SOPs. When this workflow is invoked it should be associated with the Change
Requests that it addresses. Change Requests also have a lifecycle, they start out open and when they
have been addressed they are closed. How would you model this, would it require significant
changes?

6. A change has been made to the business process which requires a Change Notice to be authored and
associated to an approved SOP(s). The Change Notice is another document which describes the
changes made to the SOPs. When the SOPs are approved the process now has to close all the Change
Requests associated with this Change Notice. How would you model this additional change?

7. Try implementing 5 and 6 into your workflow process. Note that this is not a trivial piece of work.

23 November 2011 Page 26


Alfresco Activiti Workflow

References
Alfresco Training
 Training – Content Modelling and Alfresco Explorer Integration

jBPM
 User Guide docs.jboss.com/jbpm/v3.3/userguide

 BeanShell www.beanshell.org

Alfresco Community
 Forums forums.alfresco.com

 Wiki wiki.alfresco.com/wiki/Workflow

 Workflow JavaScript API wiki.alfresco.com/wiki/Workflow_JavaScript_API

Trade and Industry Organizations


 WFMC (Workflow Management Coalition) www.wfmc.org

 OMG (Object Management Group) BPMN www.bpmn.org

Books
 jBPM Developer Guide by Mauricio Salatino (2009)

 Business Process Management with JBoss jBPM: A Practical Guide for Business Analysts by Matt
Cumberlidge (2007)

 BPMN 2.0 by Thomas Allweye

 Professional Alfresco: Practical Solutions for Enterprise Content Management (2010)

 Alfresco Developer Guide by Jeff Potts (2008)

23 November 2011 Page 27

Vous aimerez peut-être aussi