Showing posts with label Activiti BPM. Show all posts
Showing posts with label Activiti BPM. Show all posts

Friday, 22 April 2016

Creating our first process in Activiti BPM.

Now is the right time to look at one simple process in Activiti. We will be using the Eclipse IDE for designing the business process. For now, we will just gain an understanding about creating a process.

We will create a simple leave process for employees in which we will have a script task and a user task. A script task is used for adding some logic within a process and a user task is used to indicate that there is some human interaction required in the process. 

Perform the following steps to create a process in Activiti:
  1. Create a new Activiti project in Eclipse by navigating to File > New > Project > Activiti. Project and name your project SimpleLeave-Process.The 
  2. SimpleLeave-Process project will have a folder structure as shown in the following screenshot:
  3. Now create an Activiti Diagram in the src/main/rersource/diagram folder structure.
  4. To create a diagram, navigate to File > New > Other > Activiti Diagram and name your diagram SimpleLeaveProcess. The folder structure is shown in the following screenshot:
  5. On opening the .bpmn file, a white canvas will appear on which you can design the business process.
  6. To draw a business process, there is a Palette option available which contains most of the BPMN diagrams for designing the business process. First, we will be adding a StartEvent on the canvas from the Event tab of the Palette option. All these options  are shown in the following screenshot:
  7. To add a script task, click on StartEvent and it will display the options as shown in the following screenshot. From those options, select the new element option, which will list down all the elements; from those elements, select Create script task, as shown in the following screenshot:
  8. To add a user task, click on Script Task and select new user task, which is the optiondisplayed with a human icon as shown in the following screenshot:
  9. As each and every business process should have at least one end event, to add an end event, click on User Task and select the new end event option, as shown in the following screenshot: 
  10. After adding the end event to the process, your business process should look similar to the following screenshot: 

  11. Now we have to make some changes to the properties of the process.
  12. First, we will change the properties of the start event. Select the start event, open the Properties tab, and add Form Properties in the Form tab using the New button as shown in the following screenshot:
  13. Now, edit the properties for the script task. In the Main config tab, there is a Script field available; within that, insert the print statement out:println"ApplyforLeaveby"+Empname;. The Empname property is the form property that we created in the start event. The script task will print the message on the console when it is executed, as shown in the following screenshot:
  14. Now we will edit the user task properties. In the General tab, we will populate the Name property, which will be displayed in the user task node, as shown in the following screenshot:
  15. As the user task is to be performed by a specific user, we have to provide the name of the user who will be responsible for executing it.
  16. We have to populate the Assignee property of the Main config tab with the name of the person to whom the task should be assigned; as shown in the following screenshot, we will be assigning it to kermit:
  17. We can  view the .bpmn file in the XML format. Right-click on the SimpleLeaveProcess.bpmn  file, browse to OpenWith | XML Editor, and it will be available in the XML format. The result of this step is shown in the following screenshot:

Thursday, 21 April 2016

Getting Started with Activiti BPM

Let's take a quick tour of the Activiti components so you can get an idea of what the core modules are in the Activiti BPM that make it a lightweight and solid framework. You can refer to the following figure for an overview of the Activiti modules:

In this figure, you can see that Activiti is divided into various modules. Activiti Modeler, Activiti Designer, and Activiti Kickstart are part of Modelling, and they are used to design your business process. Activiti Engine can be integrated with your application, and is placed at its center as a part of Runtime. To the right of Runtime, there are Activiti Explorer and Activiti Rest, which are part of Management and used in handling business processes. Let's see each component briefly to get an idea about it. 

The Activiti Engine
The Activiti Engine is a framework that is responsible for deploying the process definitions, starting the business process instance, and executing the tasks. 

The following are the important features of the Activiti Engine:
  1. Performs various tasks of a process engine
  2. Runs a BPMN 2 standard process
  3. ‹‹It can be configured with JTA and Spring
  4. Easy to integrate with other technology
  5. Rock-solid engine
  6. Execution is very fast
  7. Easy to query history information
  8. Provides support for asynchronous execution
  9. It can be built with cloud for scalability.
  10. Ability to test the process execution.‹
  11. Provides support for event listeners, which can be used to add custom logic to the business process.
  12. Using Activiti Engine APIs or the REST API, you can configure a process engine
  13. Workflow execution using services

You can interact with Activiti using various available services. With the help of process engine services, you can interact with workflows using the available APIs. Objects of process engines and services are threadsafe, so you can place a reference to one of them to represent a whole server.

In the preceding figure, you can see that the Process Engine is at the central point and can be instantiated using ProcessEngineConfiguration. The Process Engine provides the following services:

  1. RepositoryService: This service is responsible for storing and retrieving our business process from the repository
  2. RuntimeService: Using this service, we can start our business process and fetch information about a process that is in execution
  3. TaskService: This service specifies the operations needed to manage human (standalone) tasks, such as the claiming, completing, and assigning of tasks
  4. IdentityService: This service is useful for managing users, groups, and the relationships between them
  5. ManagementService: This service exposes engine, admin, and maintenance operations, which have no relation to the runtime execution of business processes
  6. HistoryService: This service provides services for getting information about ongoing and past process instances
  7. FormService: This service provides access to form data and renders forms for starting new process instances and completing tasks

The Activiti Modeler
The Activiti Modeler is an open source modeling tool provided by the KIS BPM process solution. Using the Activiti Modeler, you can manage your Activity Server and the deployments of business processes. It's a web-based tool for managing your Activiti projects. It also provides a web form editor, which helps you to design forms, make changes, and design business processes easily.

The Activiti Designer
The Activiti Designer is used to add technical details to an imported business process model or the process created using the Activiti Modeler, which is only used to design business process workflows. The Activiti Designer can be used to graphically model, test, and deploy BPMN 2.0 processes. It also provides a feature to design processes, just as the Activiti Modeler does. It is mainly used by developers to add technical detail to business processes. The Activiti Designer is an IDE that can only be integrated with the Eclipse plugin.

The Activiti Explorer
The Activiti Explorer is a web-based application that can be easily accessed by a non-technical person who can then run that business process. Apart from running the business process, it also provides an interface for process-instance management, task management, and user management, and also allows you to deploy business processes and to generate reports based on historical data.

The Activiti REST
The Activiti REST provides a REST API to access the Activiti Engine. To access the Activiti REST API, we need to deploy activiti-rest.war to a servlet container, such as Apache Tomcat. You can configure Activiti in your own web application using the Activiti REST API. It uses the JSON format and is built upon Restlet. Activiti also provides a Java API. If you don't want to use the REST API, you can use the Java API.

Create Thumbnail in Video in Spring and ffmpeg

import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import javax.imageio.ImageIO; import org.jcodec.api.Fr...