Workflow Engine and oeCloud Integration

This is an app which demonstrates how BPMN2.0 compliant workflows are supported by oeCloud.

What is BPMN?

Business Process Model and Notation (BPMN) is a graphical representation for specifying business processes in a business process model.

What you will learn?

To develop an oeCloud based app, which supports BPMN2.0 compliant workflows.

Support for different BPMN workflow engines

Currently oe-workflow Engine and Activiti are supported.

Note: We are exploring the possibility of supporting other bpmn engines like jBPM using generic models.

Flow Chart:

Image

Topics Covered:

  1. Model Definition Overview.
  2. How to Create a model, and attach a workflow to it.
  3. How to Configure a model to attach the workflow(oe-workflow Engine/Activiti)
  4. Demonstration of workflow instance from creation to completion.
  5. Transition of Instance Data with Workflow.

What you will need?

  • You need to have Node and NPM installed.
  • You need to know “How to create a model”.
  • Running instance of Activiti.
  • Basic understanding of BPMN2.0.

Model Definition Overview:

Below is the definition of a model, which we will use for our demo.

Schema of Product Model:

{
    "name": "Product",
    "base": "BaseEntity",
    "strict": false,
    "plural": "Products",
    "idInjection": true,
    "options": {
        "validateUpsert": true
    },
    "properties": {
        "code": {
            "type": "string"
        },
        "name": {
            "type": "string"
        },
        "category": {
            "type": "string"
        },
        "price": {
            "type": "number"
        },
        "offeredSince": {
            "type": "date"
        },
        "active": {
            "type": "boolean"
        },
        "description": {
            "type": "string"
        }
    }
}

How to Create a model, and attach a workflow to it

Follow this Workflow Creation Guide to create a workflow and attach it to a model.

Workflow Model applied on Product model

Image

Note: To make your own workflow you should have knowledge of BPMN2.0 and oe-workflow Modeler.

How to Configure a model to attach the workflow

To configure any model to use workflow, we have to do a POST on an API [/Activiti_Manager/attachWorkflow] of Activiti_Manager model.

Sample Data for oe-workflow Engine POST /WorkflowManager/attachWorkflow

  {
    "modelName" : "Product",
    "workflowBody" : {
      "workflowDefinitionName": "productWorkflow"
    },
    "operation" : "create",
    "wfDependent" : true
  }

Note: workflowBody contains the name of the workflow along with other optional params which will be used to create Process Instances when data is created in the model.

Similar Data for Activiti POST /Activiti_Manager/attachWorkflow

  {
    "modelName" : "Product",
    "workflowBody" : {
        "processDefinitionKey": "productWorkflow"
      },
    "operation" : "create",
    "wfDependent" : true
  }

Similarly, user can configure it for update and delete. So whenever there is any create or update or delete on the model, it will create a WorkflowInstance in workflow engine for the configured WorkflowDefinition.

Example

     {
        "modelName": "Product",
        "workflowBody" : {
            "workflowDefinitionName": "productWorkflow"
          },
        "operation" : "update",
        "wfDependent" : true
    }   
     {
    "modelName": "Product",
    "workflowBody" : {
          "workflowDefinitionName": "productWorkflow"
        },
    "operation" : "delete",
    "wfDependent" : true
    }   

Demonstration of workflow instance from creation to completion

To create a record, use api - POST /Products

Instance posted by USER


  {
        "code": "HC1001",
        "name": "Caffe Latte",
        "description": "Strong Blend Espresso filled up with...",
        "category": "",
        "id": 58b0111b317319fc3ad4131a ,
        "price": 1.23,
        "offeredSince": "01-01-2012",
    }

Imtermediate Instance


  {
    "id": 58b0111b317319fc3ad4131a ,
    "code": "HC1001",
    "name": "Caffe Latte",
    "category": "",
    "price": 1.23,
    "offeredSince": "2011-12-31T18:30:00.000Z",
    "description": "Strong Blend Espresso filled up with...",
    "_createdBy": "user",
    "_createdOn": "2011-12-31T18:30:00.000Z",
    "_modifiedBy": "activiti",
    "_status": "private"
  }

Final Data {Approved By Activiti}


  {
        "id": 58b0111b317319fc3ad4131a ,
        "code": "HC1001",
        "name": "Caffe Latte",
        "category": "",
        "price": 1.23,
        "offeredSince": "2011-12-31T18:30:00.000Z",
        "description": "Strong Blend Espresso filled up with...",
        "_createdBy": "user",
        "_createdOn": "2011-12-31T18:30:00.000Z",
        "_modifiedBy": "system",
        "_modifiedOn": "Strong Blend Espresso filled up with...",
        "_status": "public"
    }

Observation _status changed to “public”

Transition of Instance Data

When a workflow is attached to a model, the model instance goes through various stages, depending on what operation the workflow is attached and how it is attached(wfDependent={True/False}).

Create

When a workflow is attached on create operation to a model, the posted model instance will be instantly visible if it does not depend on workflow(wfDependent=false). But if it is dependent on workflow, the posted data will only be visible after the execution of the workflow if it is accepted. In case of rejection, the instance will not be created.

Image

Update

When a workflow is attached on update operation of a model, any changes to a model instance will be instantly visible if it is workflow independent(wfDependent=false). But if it is dependent on workflow, the posted changes will only be visible after the execution of the workflow if it is accepted. In case of rejection, the posted changes will not be reflected.

Image

Delete

When a workflow is attached on delete operation of a model, the deleted model instance will be deleted instantly(_isDeleted=true), if it is workflow independent(wfDependent=false). If there is a dependency on the workflow, the instance will only be deleted after the execution of the workflow if it is accepted. In case of rejection, the instance will not be deleted.

Image