Defining Technical Rules

Work with rules if you like to create more complex or technical rules. You can create and edit them in the provided Rules editor.

Creating a new Rule

To create a rule inside a rule set, right-click the rule set in the My Rule Sets tree and select Create Rule.

Creating a Rule
Figure: Creating a Rule

The Rules view opens view displaying the following properties along with the Rules editor:

Adding and Editing Rules Code

To edit a rule, double-click the rule node of the rule in the Outline. The Rule Editor view opens. You can add code or edit code directly in the Rule Editor.

The editor is based on the Ace editor and provides the following functionality for creating and editing technical rules:

Rule Editor
Figure: Rule Editor

Adding Code

To add code for technical rules you need to be familiar with the Drools Rules language. For details on this language, you can refer to according online documentation, e.g. http://docs.jboss.org/drools/release/5.2.0.Final/drools-expert-docs/html/ch05.html.

In our Rules code editor, you do not need the declare section, as parameters are mapped via the Rule Set properties already. However you can use declarations for temporarily required parameters.

Note
For the time being you need to append _field to each variable in the code. This is not implemented for auto-completion yet.

Using the Rule Editor Toolbar

The toolbar provides the following functionality:

Option Icon Description
Select Theme Sets the editor theme (default = Chrome).
Select Font Size Sets the editor font size (default = 12pt)
Line # - Enter the line number to go to in the code field.
Find - Text to search for. Search and Replace functionality
Go to Previous Go to the previous hit in search. This icon is disabled on the first hit.
Go to Next Find the next hit in search.
Replace - Value to replace hit(s) with.
Replace Current/Replace All Replaces hits with value specified in Replace field.
Click the drop arrow to change to the replace action to Replace Current or Replace All.
To apply the selected replace action click the icon.

Using the Auto-Completion Functionality

When adding your rule, you can use the auto-completion functionality provided by the editor. Click Ctrl-Space to show proposals for code, variable or data type completion.

Auto-completion for keywords

If code keywords exist for the letter or letter sequence you enter, the according proposals are given. Choose your keyword in the list to be added to your code.

Auto-completion for code snippets

If code snippets exist for the letter or letter sequence you enter, the according proposals are given. For example, in case you enter the letter r , the following keywords and snippets are offered:

Choosing an auto-completion option
Figure: Choosing an auto-completion option

Choosing the snippet results in the following added code:

Snippet Example
Figure: Snippet added as code

Auto-completion for local variables

Local variables that are defined for the Rule set are proposed for auto-completion.

Snippet Example
Figure: Auto-completion provided for local variables

Auto-completion for data parameters

Auto-completion is provided for data parameters specified for the Rule Set.

Snippet Example
Figure: Auto-completion provided for data

Deleting Rules

To delete a rule from a rule set right-click the rule in the My Rule Sets tree and select Delete.

Deleting a Rule
Figure: Deleting a Rule

A confirmation dialog opens to confirm the deletion of the rule.

Deletion Confirmation Dialog
Figure: Deletion Confirmation Dialog

All open views respective to the deleted Rule will be closed.

Renaming Rules

You can rename a rule by one of the following actions: