Creating a Business Rule Template
com.atlassian.confluence.content.render.xhtml.migration.exceptions.UnknownMacroMigrationException: The macro 'next_previous_link3' is unknown.

Creating a Business Rule Template

To create a business template using the Business Template editor, follow the procedure below:

  1. Go to <SP_HOME> from the terminal and Access the Stream Processor Studio via the http://<HOST_NAME>:<EDITOR_PORT>/editor URL. 

    • On Windows:  editor.bat --run

    • On Linux/Mac OS:  ./editor.sh

  2. Access the Business Rules Template Editor via the http://<HOST_NAME>:<PORT>/template-editor URL. 

  3. The Template Editor opens as shown below. There are two views from which you can interact and create a template group. Design view allows you to visualize a template group and interact with it. Code view allows you to interact with a template group by typing content. (For more information about template group structure, see Business Rules Templates.)



    The following sections explain the two methods of creating a template group.  to create a template group.

     

Create from Design View

To create a business rules template group from the design view, follow the procedure below:

  1. Enter a UUID (Universally Unique Identifier), name and a description for the template group as follows.

  2. Expand the first rule template that exists by default, and enter the following details. (Note that, you need to configure the deployment nodes as explained in Prerequisites for Business Rules)

  3. To include a Siddhi application template, expand the first template that is displayed by default, and enter the following Siddhi application template.

    @App:name('SweetFactory-TrendAnalysis') @source(type='http', @map(type='json')) define stream SweetProductionStream (name string, amount double, factoryId int); @sink(type='log', @map(type='text', @payload(""" Hi ${username}, Production at Factory {{factoryId}} has gone from {{initalamout}} to {{finalAmount}} in ${timeInterval} seconds!"""))) define stream ContinousProdReductionStream (factoryId int, initaltime long, finalTime long, initalamout double, finalAmount double); from SweetProductionStream#window.timeBatch(${timeInterval} sec) select factoryId, sum(amount) as amount, currentTimeMillis() as ts insert into ProdRateStream; partition with ( factoryId of ProdRateStream ) begin from every e1=ProdRateStream, e2=ProdRateStream[ts - e1.ts <= ${timeRange} and e1.amount > amount ]*, e3=ProdRateStream[ts - e1.ts >= ${timeRange} and e1.amount > amount ] select e1.factoryId, e1.ts as initaltime, e3.ts as finalTime, e1.amount as initalamout, e3.amount as finalAmount insert into ContinousProdReductionStream; end;
  4. To add variable attributes to the script, click Add Variables

  5. To specify the attributes that need to be considered as variables, select the relevant check boxes under Select templated elements. In this example, you can select the username and timeRange check boxes to to select the attributes with those names as the variables


    Then click Add Script to update the script with the selected variuables with auto-generated function bodies as shown below.


  6. Edit the script to add the required functions. In this example, let's rename myFunction1(input) to getUsername(email), and myFunction2(input) to validateTimeRange(number).

    var username = getUsername('${userInputForusername}'); var timeRange = validateTimeRange('${userInputFortimeRange}'); /** * Extracts the username from given email * @returns Extracted username * @param email Provided email */ function getUsername(email) { if (email.match(/\S+@\S+/g)) { if (email.match(/\S+@\S+/g)[0] === email) { return email.split('@')[0]; } throw 'Invalid email address provided'; } throw 'Invalid email address provided'; } /** * Validates the given value for time range * @returns Processed input * @param input User given value */ function validateTimeRange(number) { if (!isNaN(number) && (number > 0)) { return number; } else { throw 'A positive number expected for time range'; } }
  7. To generate properties, click Generate against Properties


    This expands the Properties section as follows.
     

  8. Enter values for the available properties as follows. For this example, let's enter values as shown in the following table.

     

  9. To save the template, click the save icon at the top of the page.

 

Create from code view

When you use the code view, the same parameters for which you enter values in the design view are represented as JSON keys. For each parameter, you can specify a value against the relevant JSON key as shown in the extract below.

When you update the code view with a valid template group definition, the design view is updated simultaneously as shown below.

However, if the content you enter in the code view is an invalid template group, the design view is not updated, and an error is displayed as follows.



When an error is detected in the entered template group structure, the Recover button is displayed with the error message.



When you click Recover, the code view is receted to the latest detected valid template group definition. At any given time, the design view displays information based on the latest detected valid template group definition.

It is not recommended to add Siddhi application templates and scripts using the code view because they need to be provided as a single line, and the possible escape characters should be handled carefully.



com.atlassian.confluence.content.render.xhtml.migration.exceptions.UnknownMacroMigrationException: The macro 'next_previous_links2' is unknown.