2. Agenda
• Over view of BPM
• Over view of Activiti BPM
• Activiti BPM Database
• Activiti BPM Reporting
• Analytics using Activiti BPM Database
3. What is Business Process and Business
Process Management
• Business Process:
• A business process is an activity or set of activities that will
accomplish a specific organizational goal.
• Business process management (BPM) is a systematic approach to
improving those processes.
• Business Process Management:
• Business process management (BPM) is a systematic approach to
making an organization's workflow more effective, more efficient and
more capable of adapting to an ever-changing environment.
4. Few important terms
• BPMN(Business Process Modelling Notation):
• BPMN is a method of illustrating business processes in the form of a diagram
similar to a flowchart.
• Can be divided into 2 parts:
• Tasks: represented as rectangular shape.
• Events: represented as circular shape.
• Gateways: represented as diamond shape.
• Connecting objects: represented as arrow shape.
• Swimlanes: represented as path shape.
Tasks Events
Gate
way Swimlanes
5. Few important terms
• BPD (Business Process Discovery):
• Business process discovery, also called process discovery, is a collection of
tools and techniques used to define, map and analyse an organization’s
existing business processes.
• It’s a initial step of BPM.
• Mostly used for BI(Business Intelligence) and BA(Business Analytics).
• We can say it as a way of creating Business Process Diagram logically using
BPMN.
• BPEL (Business Process Execution Language)
• BPEL is an XML-based language that enables task-sharing in a distributed
computing or grid computing environment.
7. Activiti BPM
• Activiti is a light-weight workflow and Business Process Management
(BPM) Platform targeted at business people, developers and system
admins.
• Its core is a super-fast and rock-solid BPMN 2 process engine for Java.
It's open-source and distributed under the Apache license.
• Activiti runs in any Java application, on a server, on a cluster or in the
cloud.
• It integrates perfectly with Spring, it is extremely lightweight and
based on simple concepts.
9. Activiti Database
• Activiti database is a repository which includes all process, tasks,
events and process variables related data, which is used to maintain
different Business Processes and to create their statistics.
• Its stores static information, runtime data, identity, history and
general data.
11. Database Configuration
• Define the JDBC properties of the database:
• jdbcUrl: JDBC URL of the database.
• jdbcDriver: implementation of the driver for the specific database type.
• jdbcUsername: username to connect to the database.
• jdbcPassword: password to connect to the database.
• The following attributes can optionally be set to tweak that connection pool (taken from
the MyBatis documentation):
• jdbcMaxActiveConnections: The number of active connections that the connection pool at
maximum at any time can contain. Default is 10.
• jdbcMaxIdleConnections: The number of idle connections that the connection pool at maximum
at any time can contain.
• jdbcMaxCheckoutTime: The amount of time in milliseconds a connection can be 'checked out'
from the connection pool before it is forcefully returned. Default is 20000 (20 seconds).
• jdbcMaxWaitTime: This is a low level setting that gives the pool a chance to print a log status and
re-attempt the acquisition of a connection in the case that it’s taking unusually long (to avoid
failing silently forever if the pool is misconfigured) Default is 20000 (20 seconds).
• databaseSchemaUpdate: true/false/create-drop
12. Database table names explained
• The database names of Activiti all start with ACT_.
• ACT_RE_*: 'RE' stands for repository. Tables with this prefix contain
'static' information such as process definitions and process
resources(images, rules, etc.).
• ACT_RU_*: 'RU' stands for runtime. These are the runtime tables,
that contain the runtime data of process instances, user tasks,
variables, jobs, etc. Activiti only stores the runtime data during
process instance execution, and removes the records when a process
instance ends. This keeps the runtime tables small and fast.
• ACT_ID_*: 'ID' stands for identity. These tables contain identity
information, such as users, groups, etc.
13. Database table names explained
• ACT_HI_*: 'HI' stands for history. These are the tables that contain
historic data, such as past process instances, variables, tasks, etc.
• ACT_GE_*: ‘GE' stands for general data, which is used in various use
cases.
14. History
• Activiti Database contains all process instance related details.
• There are 5 history entities:
• HistoricProcessInstances containing information about current and past process
instances.
• HistoricVariableInstances containing the latest value of a process variable or task
variable.
• HistoricActivityInstances containing information about a single execution of an
activity (node in the process).
• HistoricTaskInstances containing information about current and past (completed and
deleted) task instances.
• HistoricDetails containing various kinds of information related to either a historic
process instances, an activity instance or a task instance.
15. Query History
• Activiti has provided Java API’s for querying history from Activiti
database.
• These API’s are known as Query API’s.
• Methods to expose all 5 history entities:
• HistoricProcessInstances: createHistoricProcessInstanceQuery()
• HistoricVariableInstances: createHistoricVariableInstanceQuery()
• HistoricActivityInstances: createHistoricActivityInstanceQuery()
• HistoricDetails: createHistoricDetailQuery()
• HistoricTaskInstances: createHistoricTaskInstanceQuery()
16. Query History Examples
• Historic Process Instance Query:
• Get 10 HistoricProcessInstances that are finished and which took the most
time to complete (the longest duration) of all finished processes with
definition ‘XXX‘:
historyService.createHistoricProcessInstanceQuery()
.finished()
.processDefinitionId(“XXX")
.orderByProcessInstanceDuration().desc()
.listPage(0, 10);
17. Query History Examples
• Historic Variable Instance Query:
• Get all Historic Variable Instances from a finished process instance with id
‘XXX' ordered by variable name.
historyService.createHistoricVariableInstanceQuery()
.processInstanceId("XXX")
.orderByVariableName.desc()
.list();
18. Query History Examples
• Historic Activity Instance Query:
• Get the last Historic Activity Instance of type 'serviceTask' that has been
finished in any process that uses the process definition with id XXX.
historyService.createHistoricActivityInstanceQuery()
.activityType("serviceTask")
.processDefinitionId("XXX")
.finished()
.orderByHistoricActivityInstanceEndTime().desc()
.listPage(0, 1);
19. Query History Examples
• Historic Detail Query:
• Get all variable-updates that have been done in process with id ‘XXX’.
• Its possible that a certain variable name has multiple Historic Variable Update
entries, for each time the variable was updated in the process.
historyService.createHistoricDetailQuery()
.variableUpdates()
.processInstanceId(“XXX")
.orderByVariableName().asc()
.list();
20. Query History Examples
• Historic Detail Query:
• Gets all variable updates that were performed on the task with id “XXX".
• This returns all Historic Variable Updates for variables that were set on the
task (task local variables), and NOT on the process instance.
historyService.createHistoricDetailQuery()
.variableUpdates()
.taskId(“XXX")
.orderByVariableName().asc()
.list()
21. Query History Examples
• Historic Detail Query:
• Gets all form-properties that were submitted in any task or when starting the
process with id “XXX".
• Task local variables can be set using the TaskService or on a DelegateTask,
inside TaskListener:
historyService.createHistoricDetailQuery()
.formProperties()
.processInstanceId(“XXX")
.orderByVariableName().asc()
.list()
taskService.setVariableLocal(“XXX", "myVariable", "Variable value");
OR
public void notify(DelegateTask delegateTask) {
delegateTask.setVariableLocal("myVariable", "Variable value");
}
22. Query History Examples
• Historic Task Instance Query:
• Get 10 Historic Task Instances that are finished and which took the most time
to complete (the longest duration) of all tasks.
• Get Historic Task Instances that are deleted with a delete reason that contains
"invalid", which were last assigned to user 'kermit'.
historyService.createHistoricTaskInstanceQuery()
.finished()
.orderByHistoricTaskInstanceDuration().desc()
.list Page(0, 10);
historyService.createHistoricTaskInstanceQuery()
.finished()
.taskDeleteReasonLike("%invalid%")
.taskAssignee("kermit")
.listPage(0, 10);
23. Reporting
• Activiti explorer has 4 important tabs, from reporting is one of the tab.
• Several advantages:
• The process has straight access to the internals of the Activiti engine. It has direct
access to the database used by the engine.
• The job executor can be used as for any other process. This means that you can
asynchronously generate the process or only execute certain steps asynchronously. It
also means you can use timers, eg. to generate the report data on certain points in
time.
• Creating a new report can be done with known tools and known concepts. Also, no
new concepts, services or applications are needed. Deploying or uploading a new
report is the same as deploying a new process.
• It allows to use the BPMN 2.0 constructs. This means that all things like parallel
steps, do branching based on data or even request user input during the generation
are possible out-of-the-box
24. Reporting
• How to generate reports in
Activiti?
• The process produces a variable
called ‘reportData’ is created.
• This variable must be a byte array
representation of a json object.
• This variable is stored in the history
tables of Activiti so it can be
retrieved later when the report is
saved.
25. Reporting
• Reporting JSON structure:
• title: this is the general title for the whole report
• datasets: this is an array of datasets corresponding with
the different charts and lists on the report.
• type: Each dataset has a type. This type will be used to
determine how the data will be rendered. Currently
supported values are: pieChart, lineChart, barChart and list.
• description: each chart can have an optional description
that will be shown in the report.
• x- and y-axis: only usable for type lineChart. Optional
parameter that determines the name of the axes of the
chart
• data: this is the actual data. The data is a json object with
key-value elements.
{
"title": "My Report",
"datasets": [
{
"type" : "lineChart",
"description" : "My first chart",
"xaxis" : "Year"
"yaxis" : "Total sales"
"data" :
{
"2010" : 50,
"2011" : 33,
"2012" : 17,
"2013" : 87,
}
}
]
}
26. Reporting Example
• Generate Reports
between all process
instances and process
instances of different
process definitions
<?xml version="1.0" encoding="UTF-8"?><definitions
xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:activiti="http://activiti.org/bpmn"
xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI"
xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC"
xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI"
typeLanguage="http://www.w3.org/2001/XMLSchema"
expressionLanguage="http://www.w3.org/1999/XPath"
targetNamespace="activiti-report">
<process id="process-instance-overview-report" name="Process
Instance Overview" isExecutable="true">
<startEvent id="startevent1" name="Start" />
<sequenceFlow id="flow1" sourceRef="startevent1"
targetRef="generateDataset" />
<scriptTask id="generateDataset" name="Execute script"
scriptFormat="JavaScript" activiti:autoStoreVariables="false">
<script> <!– write your java script code here </script>
</scriptTask>
<sequenceFlow id="flow3" sourceRef="generateDataset"
targetRef="theEnd" /><endEvent id="theEnd" />
</process>
</definitions>
27. Reporting Example
• JavaScript code:
importPackage(java.sql);
importPackage(java.lang);
importPackage(org.activiti.explorer.reporting);
var result =
ReportingUtil.executeSelectSqlQuery("SELECT PD.NAME_,
PD.VERSION_ , count(*) FROM ACT_HI_PROCINST PI inner
join ACT_RE_PROCDEF PD on PI.PROC_DEF_ID_ = PD.ID_
group by PROC_DEF_ID_");
var reportData = new ReportData;
var dataset = reportData.newDataset();
dataset.type = "pieChart";
dataset.description = "Process instance overview (" +
new java.util.Date() + ")“;
while (result.next()) { // process results one row at a
time
var name = result.getString(1);
var version = result.getLong(2);
var count = result.getLong(3);
dataset.add(name + " (v" + version + ")",
count);
}
execution.setVariable("reportData",
reportData.toBytes());
30. Activiti BPM Database and Analytics
• Analytics is a technology and field that helps any organization in
decision making and enhancing their business in more profitable and
more predictive way, by using their own huge data.
• Most of the organization analysis their business mostly in terms of
cost and time.
• Activiti has their own database where it maintains each every task
and process related data, so we can say somehow its possible to do
analytics on it.
31. Activiti BPM Database and Analytics
• Analytics can be of 2 types on Activiti database:
• Process Analytics
• Data Analytics
• Demo on Process Analytics using Disco (Fluxicon).
32. Activiti BPM Database and Analytics Example
• Here will take an example of Travel Domain.
• Most time taking tasks.
• Most costly and cost efficient tasks.
• Total cost of travels per quarter on company v/s cost per BU per quarter v/s
cost per BU per account per quarter v/s cost per BU per account per project
per quarter (v/s total cost revenue generated by company in that quarter)
Company revenue per account per project v/s expenditure on travel per quarter