Rule and Action Templates

Templates are predefined blocks of code or functions that contain common logic. Templates make common logic reusable across different Rules and Actions. They help ensure consistency by allowing you to define a set of operations once and use them multiple times. Templates are separated by type; Rules and Actions, and can be used in Templates of the same type.

Notes when using Templates

Templates cannot reference themselves as this would create a circular reference and make the rule loop infinitely.

If a modification is made, the change is picked up by all items referencing the template.

You cannot delete a template once it is referenced.

Referencing one template inside another template allows trees of Rule templates that can be created with a Rule or Action at the root.

If a template tree is too deep, you may experience performance issues.

Templates can start with a Value or a Predicate. Action Templates start with an Operation.

     Example: A template can be used to define the relationship between road elements that make up a roundabout. The parameters are the objects that define the roundabout, and the output is a geometry value. This template can then be used in all Rules that need to access roundabout geometries.

Parameters

Parameters are added to templates to pass in Values or Attributes. Parameters act as placeholders for the objects that the template will process. When you add a Template to a Rule or Action, the calling Rule or Action specifies which in-context objects to use as input parameters.

Parameters allow you to determine the class or type of data that the Template operates on.

Creating Templates

Create a Template using the New icon or via the context menu in the Navigation pane in either the Rules or Actions tabs. The object is defined in an Read and Commit parameter to the template. A template can have zero to many parameters.

     Note: Action Templates can only be inserted into other Actions.

A Template that is fully configured

Parameters can be added, removed, and changed even when the template is referenced.

     Warning: If the first node of a Template has its type changed (eg. Predicate to Value) then any Rules/Actions using the template will lose functionality until the correct component type is used.

ClosedCreate a new Template

  1. Navigate to the Rules/Actions tab.

  2. In the Navigation Pane, create a Rule Template or an Action Template.

  3. (Optional) Set the Context and add parameters with the Add icon .

    Set the Class and Name parameters

    Add more Class and Name pairs if needed.

  4. Add component nodes as you would with any other Rule or Action.

  5. Click Save.

    The Template is now ready to use.

ClosedExtract A Template

  1. Open a Rule or Action that has the structure that you want for your Template.

  2. Right click the node you want to make a Template from.

  3. Click Extract to Template.

  4. Name the template and click Create.

Using a Template

Templates can be used within Rules, Actions, or other Templates.

A Template that has been inserted into a Rule

Templates automatically inherit the Class and Attribute parameters from the Root node at the point in time they are added. This can be manually changed if needed.

ClosedAdding a Rule Template

  1. Open the Rule that you want to add the Template to.

  2. Click the required node and select Rule Template.

  3. Select a Template and click Select. The Rule Template is inserted into the rule.

ClosedAdding an Action Template

  1. Open the Action that you want to add the Template to.

  2. Click the required node and select Action Template.

  3. Select a Template and click Select. The Action Template is inserted into the action.