Workflow without maker-checker

This document explains how to trigger a workflow on some operation(Create, update, delete, custom) without maker-checker.

Installation

We are assuming that you have already tried the basic oe-cloud and oe-studio. If not please follow this link Getting started with oe-cloud.

Add oe-workflow to oe-cloud

Dependecny

Add the below line to your package.json file in the oe-cloud directory.

	{ "oe-workflow" : "^2.0.0" }
Loading oe-workflow Application

To load oe-workflow application along with oe-cloud, it is necessary to add oe-workflow as an app to server/app-list.json file. Add the following data to the mentioned file.

	{
   	  "path" : "oe-workflow",
   	  "enabled" : true
	}

Model Creation

Product Model

In this section we will create a Product model and we assume that you know how to create a model. If not please follow this link on How to Create a Model. We will provide with all the attributes of the 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"
        }
      }
    }

Workflow Creation

Workflow Basics

oe-workflow follows BPMN(Business Process Management Notation) 2.0 to create the workflows. Workflow Modeler link will walk you through the various elements we can use to design processes. Open the workflow-modeler tab in oe-studio and try few elements in the above document. Additionally you can also visit this BPMN 2.0 Org website for the specification documents.

Workflow Attachment
{
  "modelName": "<<model_name>>",
  "workflowBody": {
	"workflowDefinitionName": "<<Workflow_name>>"
  },
  "operation": "<<operation>>",
  "wfDependent": true,
  "version": "v0"
}
property description
model_name Model name on which you want to trigger the workflow on some operation.
workflow_name Name of the workflow(published) which you to be triggered.
operation The operation on which workflow should be triggered. It value should be one of these ‘create’, ‘update’, ‘save’, ‘delete’, ‘custom’

NOTE : version value should be v0 to attach a workflow without maker-checker.

To attach a workflow on custom remote add the remote property to the workflow mapping and give operation: custom as shown below.

{
  "modelName": "Order",
  "workflowBody": {
	"workflowDefinitionName": "ApprovalWorkflow"
  },
  "operation": "custom",
  "remote":{
    "path":"/special-order/:id",
    "method":"SpclOrderBYId",
    "verb":"put"
  },
  "wfDependent": true,
  "version": "v0"
}
property Description
path The path of the remote method on which workflow should be attached
method The remote method name
verb The remote method HTTP type