This documentation is for WSO2 Stream Processor 4.1.0. View documentation for the latest release.

All docs This doc

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

ParameterDescriptionRequired/Optional
nameA name for the rule templateRequired
uuidA uniquely identifiable id for the rule templateRequired
typeThe type of the rule template. Possible values are as follows:
  • template: Used only to create an entire business rule from template
  • input : Used only in creating a business rule from scratch
  • output : Used only in creating a business rule from scratch
Required
instanceCount

This specifies whether the business rules derived from the template can be deployed only on one node, or whether they can be deployed on many nodes.

Possible values are as follows:

  • one
  • many
Required
script
The Java script to be executed on the templated fields.
Developers can use this script for:
  • validating purposes.
  • deriving values for a templated parameter by combining some other entered parameters

Each templated element that is going to be derived from entered parameters, has to be mentioned as a variable in the global scope of the javascript.

The entered parameters should be templated in the script itself, and will be later replaced with their respective entered values.

Consider the following script

Code Block
languagejs
/* 
* Validates a number and returns after adding 10 to it
* @throws Error when a non number is entered
*/
function deriveValue(value){
    if( !isNan(value) ) {
      return value + 10;
    }
    throw "A number is required";
}

var derivedValue = deriveValue(${enteredValue});


enteredValue should be defined as a property under properties in order to be filled by the user and replaced later.

The derived value stored in derivedValue will be then used to replace ${derivedValue} in the SiddhiApp template.

Optional
descriptionA brief description of the rule template.Optional
templates

These are the artifacts (i.e SiddhiApps) with templated parameters, that will be instantiated with replaced values when a business rule is created.

Required
properties

You can add a field name, description, default value and possible values (optional)
for the templated parameters.

Required


  1. Save the template group you created as a .json file in the <SP_HOME>/wso2/dashboard/resources/businessRules/templates directory.
  2. In the BusinessRules section  section of the <SP_HOME>/conf/dashboard/deployment.yaml file file, add a configuration for the template you created as shown below.

    Code Block
    wso2.business.rules.manager:
    
      datasource: <datasourceName>
        - nodeURL1:
           - ruleTemplateUUID1
           - ruleTemplateUUID2
          nodeURL2:
           - ruleTemplateUUID1
           - ruleTemplateUUID2
    Save the template group as a .json file in the <SP_HOME>/wso2/dashboard/resources/businessRules/templates directory.