Working with Application Rule

The Application or API Rule is the interface between the process engine and the application, including any parameters to be passed. The supported Application rule types are SQL, JAVA, Stored Procedure, Function, Java External API, Rest Service, Outcome Rules, Expressions, Attribute Expression, Advanced Attribute Expression, and JSON Path Expression.

Based on their usage these are categorized into three types.

For example, select v_created_by from fct_expenses where id=101

Adding Application/ API Rule

To add Application Rule

  1. From the Process Modeller window, select the required Process and click Edit. The Process Editor window is displayed.

  2. Select the Application Rule tab.

  3. Click Add and select the appropriate Application Execution type from the drop-down list. The options are SQL, JAVA, Stored Procedure, Function, Java External API, Rest Service, Attribute Expression, Outcome Rules, Expressions, JSON Path Expression, JSON Read From DB, and JSON Write To DB. The Rule Details window is displayed.

Based on the type of the Application Rule, enter the details as tabulated:

SQL Application Rule:

This Application Rule is used to execute any SQL queries in the Process Flow.

Field Name

Description

Name

Enter a unique name for the SQL Application Rule.

Rule Type

Select the rule type from the drop-down list. The SQL Application Rule can be used as Decision Rule, Execution Rule or Selection Rule based on your requirement.

Execution Type

Displays the Application Execution Type as SQL.

Implementation Detail

Decision Rule- For Decision Rule the SQL Statement should return ‘PASS’ for success condition.

For example, select ‘PASS’ from dual where {EXPENSES} <= {THRESHOLD}

Note: {EXPENSES}, {THRESHOLD} are user defined Data Fields.

Execution Rule- For Execution Rule the SQL Statement can be any DML statement.

For example, update fct_expenses set expenses={EXPENSES} where id = {WF_ENTITYID}

Selection Rule- For Selection Rule the SQL Statement should be a Select statement which returns a list of values.

For example, select v_created_by from fct_expenses id = {WF_ENTITYID}

Return Parameter

Select the Data Field which will receive the return parameter of the SQL Rule, from the drop-down list.

For ExecutionRule type, the business logic is implemented in the method and the parameter value returned from the SQL Rule is saved in the mapped Data Field.

In case of SelectionRule type, the Java method should be a String value.

In case of DecisionRule type, the Java method should return Boolean values “True/False”.

Scope

Select the scope of the Application Rule from the drop-down list. The options are:

§   Process- Select Process if you want to use the Application Rule only in the current process.

§   Package- Select Package if you want to use the Application Rule across all the processes in the package.

Back to Top

Stored Procedure Application Rule:

This Application Rule is used to call a Stored Procedure in your Process Flow.

Field Name

Description

Name

Enter a unique name for the Application Rule.

Rule Type

Select the rule type from the drop-down list. The available rule types are Decision Rule, Execution Rule, and Selection Rule.

Execution Type

Displays the Application Execution Type as Stored Procedure.

Procedure Name

Enter the Stored Procedure Name which you want to call in your process flow.

Input Parameters

You can pass Input Parameters for the stored Procedure using Data Fields. Select the required Data Fields from the drop-down list.

Parameter Mode

Enter the Parameter Mode in JSON format. For example, suppose you have given 3 parameters as input parameters, enter parameter mode as [“IN”,”IN”,”OUT”].During Execution of Stored Procedure,

§   In case of Decision Rule type, the first return parameter should return value ‘PASS’ for success evaluation.

§   In case of Selection Rule type, the first return parameter value is taken as Selection data.

§   In case of Execution Rule, the procedure return OUT parameter value overwrites the current value of respective mapped Data Field.

Scope

Select the scope of the Application Rule from the drop-down list. The options are:

§   Process- Select Process if you want to use the Application Rule only in the current process.

§   Package- Select Package if you want to use the Application Rule across all the processes in the Application Package.

Back to Top

Function Application Rule:

This Application Rule is used to call Database functions in your Process Flow.

Field Name

Description

Name

Enter a unique name for the Application Rule.

Rule Type

Select the rule type from the drop-down list. The available rule types are Decision Rule, Execution Rule and Selection Rule.

Execution Type

Displays the Application Execution Type as Function.

Function Name

Enter the Function Name.

Input Parameters

Select the list of Data Fields which will be passed as input parameters, from the drop-down list.

Parameter Mode

Enter the Parameter Mode in JSON format. For example, suppose you have given 3 parameters as input parameters, enter parameter mode as [“IN”,”IN”,”OUT”].

During Execution of Function,

  • In case of Decision Rule type, the first return parameter should return value ‘PASS’ for success evaluation.

  • In case of Selection Rule type, the first return parameter value is taken as Selection data.

  • In case of Execution Rule, the procedure return OUT parameter value overwrites the current value of respective mapped Data Field.

Return Parameter

Select the Data Field which will receive the return parameter of the Java function, from the drop-down list.

For ExecutionRule type, the business logic is implemented in the method and the parameter value returned from the Java method is saved in the mapped Data Field.

In case of SelectionRule type, the Java method should be a String value.

In case of DecisionRule type, the Java method should return Boolean values “True/False”.

Scope

Select the scope of the Application Rule from the drop-down list. The options are:

  • Process- Select Process if you want to use the Application Rule only in the current process.

  • Package- Select Package if you want to use the Application Rule across all the processes in the Application package.

Back to Top

Java Application Rule:

This Application Rule is used to call Java functions in your Process flow.

Field Name

Description

Name

Enter a unique name for the Application Rule.

Rule Type

Java Rule supports only Execution Rule Type.

Execution Type

Displays the Application Execution Type as Java.

Implementation Detail

Enter the complete java class name which implements the Interface :

 com.ofs.aai.service.wf.external.base.Activity.

The implementation class has to override the method with the Business Logic.

executeTask(List<Data Field> Data Fields)

The Data Fields are passed by reference, so changes can be made in Data Fields value directly by the implementation class, which will be recognized by the WorkflowEngine.

Return Parameter

Select the Data Field which will receive the return parameter of the Java function, from the drop-down list.

For Execution Rule type, the business logic is implemented in the method and the parameter value returned from the Java method is saved in the mapped Data Field.

In case of Selection Rule type, the Java method should be a String value.

In case of Decision Rule type, the Java method should return Boolean values “True/False”.

Scope

Select the scope of the Application Rule from the drop-down list. The options are:

§   Process- Select Process if you want to use the Application Rule only in the current process.

§   Package- Select Package if you want to use the Application Rule across all the processes in the package.

Note: The class and its dependent file (or jar) needs to be available in webcontainer class path.

For example, <TOMCAT_HOME>/webapps/<context>/WEB-INF/lib/ <forecast.jar>

Back to Top

Java External API Application Rule:

This Application Rule is used to call Java External API in your process flow. You need to specify the Class Name and the method of the API.

Field Name

Description

Name

Enter a unique name for the Application Rule.

Rule Type

Select the rule type from the drop-down list. The available rule types are Decision Rule, Execution Rule and Selection Rule.

Execution Type

Displays the Application Execution Type as Java External API.

Class Name

Enter the complete java class name which implements the Business Logic.

Method

Enter the method which implements the Business Logic.

Input Parameters

Select the list of Data Fields which will be passed as input parameters, from the drop-down list.

Return Parameters

Select the Data Field which will receive the return parameter of the Java function, from the drop-down list.

For Execution Rule type, the business logic is implemented in the method and the parameter value returned from the Java method is saved in the mapped Data Field.

In case of Selection Rule type, the Java method should be a String value.

In case of Decision Rule type, the Java method should return Boolean values “True/False”.

Scope

Select the scope of the Application Rule from the drop-down list. The options are:

§   Process- Select Process if you want to use the Application Rule only in the current process.

§   Package- Select Package if you want to use the Application Rule across all the processes in the Application package.

Back to Top

Outcome Rules Application Rule:

Field Name

Description

Name

Enter a unique name for the Application Rule.

Rule Type

Displays the rule type as DecisionRule. This Rule Execution type supports only DecisionRule type.

Execution Type

Displays the Application Execution Type as Outcome.

Outcomes

Select the outcome for which you want to add the rule.

Scope

Select the scope of the Application Rule from the drop-down list. The options are:

§   Process- Select Process if you want to use the Application Rule only in the current process.

§   Package- Select Package if you want to use the Application Rule across all the processes in the package.

Back to Top

Expression Application Rule

This is same as SQL execution type. You need to specify only the where clause in the Expression field. It can be any SQL expressions including ‘AND’/ ‘OR’.

Field Name

Description

Name

Enter a unique name for the Application Rule.

Rule Type

Select the rule type from the drop-down list. The available rule types are Decision Rule, Execution Rule and Selection Rule.

Execution Type

Displays the Application Execution Type as Expression.

Expression Type

Select Expression Type as SQL to use SQL expressions or JSON to use JSON expressions.

Expression

Enter the Expression in SQL format or JSON format.

Return Parameter

Select the Data Field which will receive the return parameter of the Expression Rule, from the drop-down list.

For ExecutionRule type, the business logic is implemented in the method and the parameter value returned from the Application Rule is saved in the mapped Data Field.

In case of SelectionRule type, the Application Rule should be a String value.

In case of DecisionRule type, the Application Rule should return Boolean values “True/False”.

Scope

Select the scope of the Application Rule from the drop-down list. The options are:

§   Process- Select Process if you want to use the Application Rule only in the current process.

§   Package- Select Package if you want to use the Application Rule across all the processes in the Application package.

Back to Top

REST Service Application Rule

This Application Rule is used to call external components in your Process flow.

Field Name

Description

Name

Enter a unique name for the Application Rule.

Rule Type

Select the rule type from the drop-down list. The available rule types are Decision Rule, Execution Rule and Selection Rule.

Execution Type

Displays the Application Execution Type as Rest Service.

Method Type

Select the Method Type as GET or POST from the drop-down list.

URL

Enter the REST URL that needs to be called.

For example, <IP Address/hostname of the Web Server >:<servlet port>/<context name>/restPMF/PMFService/startWorkflowProcess ( A rest URL to start the workflow)

Query Param

Enter the Query parameters that needs to be passed to the rest API.

For example, http://example.com/foo?bar

Headers

Enter any headers that needs to be passed to the rest API.

For example, "content-type": "application/json"

Data

Enter if any actual data that needs to be passed to the rest API. Data can be of type RAW, JSON, Form Data and so on.

For example, "{\n \"objectid\":\"912\",\n \"objecttype\":\"1000\",\n \"infodom\":\"OFSCAPADQINFO\",\n \"segment\":\"OFSCAPADQINFO\",\n \"userid\":\"ORMUSER\",\n \"locale\":\"en_US\",\n \"securityMap\" :{},\n \"applicationParams\" :{\n \"testparam\":\"value1\",\n \"testparam2\":\"value2\"\n }\n \n}

Return Parameter

Select the Data Field which will receive the return parameter of the Webservices Rule, from the drop-down list.

For ExecutionRule type, the business logic is implemented in the method and the parameter value returned from the Application Rule is saved in the mapped Data Field.

In case of SelectionRule type, the Application Rule should be a String value.

In case of DecisionRule type, the Application Rule should return Boolean values “True/False”.

Scope

Select the scope of the Application Rule from the drop-down list. The options are:

§   Process- Select Process if you want to use the Application Rule only in the current process.

§   Package- Select Package if you want to use the Application Rule across all the processes in the Application package.

Is Proxy Required

Select Yes if proxy is required for the webservice. That is, if the Rest API is outside OFSAA . For information on how to enable proxy, see Enabling Proxy for REST Service Application Rule in the OFSAAI Process Modelling Framework Orchestration Guide.

Back to Top

Attribute Expression Application Rule

Field Name

Description

Name

Enter a unique name for the Application Rule.

Rule Type

Displays the rule type as DecisionRule. This Rule Execution type supports only DecisionRule type.

Execution Type

Displays the Application Execution Type as Attribute Expression.

Attribute

Select the attribute for which you want to define the application rule, from the drop-down list. The list displays the attributes configured for the selected application and component. For more information, see Configuring Application Object Model (AOM) section.

Click Add to add values to the selected attributes. A row is added in the Attribute Values pane. Click the Value column to select the values for the attribute from the drop-down. You can select one or more values.

You can delete a row by clicking button.

You can select multiple attributes and click Add to assign values to those attributes.

Back to Top

Advanced Attribute Expression Application Rule

This is an advanced version of Attribute Expression Application Rule with additional logical conditions and assignment operators. The expression can be dynamically built and will return True or False value after evaluation. This is used as a DecisionRule in transitions.

You can define this application rule with multiple conditions and nested groups.

Field Name

Description

Rule Name

Enter a unique name for the Application Rule.

AND/ OR

Select the logical operator to be used for the conditions in a group.

Add Condition

When you click Add Condition, a new row gets added. To define a condition, select the attribute, the operator and the value from the drop-down lists. Multiple values can be selected for each attribute.

  • Attribute- The drop-down list displays the attributes configured for the selected application and component. For more information, seeConfiguring Application Object Model (AOM) section.

  • Operator- Available options are in,=,<>,<,<=,>,>=.

  • Value- Displays the values configured for the selected attributes. Select the required value.

Click Remove Condition to delete already added condition.

Add Group

Click Add Group if you want to have nested conditions. For each group, select the required logical operator as AND or OR.

Click Remove Group to delete a group of conditions.

Back to Top

JSON Path Expression Application Rule

This Application rule is used to extract data from the JSON Path Expression, which gets returned from a Rest API or Web Service call, and you can store it into a Data Field for further processing.

Field Name

Description

Name

Enter a unique name for the Application Rule.

Rule Type

Select the rule type from the drop-down list. The available rule types are Decision Rule and Execution Rule.

For Decision Rule, output of JSON Path Expression will be compared with RHS expression and rule will return either true or false accordingly.

For execution rule, JSON Path Expression is evaluated and the output is returned to the DataField selected as Output DataField.

Execution Type

Displays the Application Execution Type as JSON Path Expression.

JSON Input

Select the JSON Input from the drop-down list. The list displays the DataFields. The selected DataField should have JSON as its value.

JSON Path Expression

Enter the JSON path expression. For more information, see JsonPath Expressions section in the OFSAAI Process Modelling Framework Orchestration Guide.

Operator

This field is displayed only if Rule Type is selected as Decision Rule.

Select the required operator for comparison from the drop-down list. The options are =,<,>,>= and <=.

RHS Expression

This field is displayed only if Rule Type is selected as Decision Rule.

Enter the expression to which you want to compare the JSON path expression.

Output DataField

This field is displayed only if Rule Type is selected as Execution Rule.

Select the DataField to which you want to return the value of JSON Path Expression, from the drop-down list.

Scope

Select the scope of the Application Rule from the drop-down list. The options are:

  • Process- Select Process if you want to use the Application Rule only in the current process.

  • Package- Select Package if you want to use the Application Rule across all the processes in the Application package.

Convert To Type

Select JSON ARRAY to store the output in Array format or select String to store as a string, from the drop-down list.

Back to Top

JSON Read From DB Application Rule

This Application Rule is used to read data from the database in JSON format.

Field Name

Description

Name

Enter a unique name for the Application Rule.

Rule Type

Only Execution Rule type is supported.

Execution Type

Displays the Execution Type as JSON Read From DB.

Table Name

Enter the table name from which you want to read the data.

Column List

Enter the column names of the selected table.

Where Condition

Enter the filter condition (where clause) of the SQL query.

Return JSON Type

Select the JSON type of the returned value as JSON Object or JSON Array based on your requirement.

  • JSON Object- Select this option if the returned value is a single row.

  • JSON Array- Select this option if the returned data has multiple rows.

Output DataField

Select the DataField to which you want to return the value of the SQL query, from the drop-down list.

Scope

Select the scope of the Application Rule from the drop-down list. The options are:

  • Process- Select Process if you want to use the Application Rule only in the current process.

  • Package- Select Package if you want to use the Application Rule across all the processes in the Application package.

Back to Top

JSON Write To DB Application Rule

This Application Rule is used to write the data in JSON format into the database.

Field Name

Description

Name

Enter a unique name for the Application Rule.

Rule Type

Only Execution Rule type is supported.

Execution Type

Displays the Execution Type as JSON Write To DB.

Table Name

Enter the table name to which you want to write the data in JSON format.

Source JSON

Enter the data in the JSON format that you want to write to the database.

Output DataField

This field is not applicable.

Scope

Select the scope of the Application Rule from the drop-down list. The options are:

  • Process- Select Process if you want to use the Application Rule only in the current process.

  • Package- Select Package if you want to use the Application Rule across all the processes in the Application package.

Back to Top