JAVA

Thursday 16 April 2020

Rule Model Extension

Rule Model Extension:


Introduction


        The purpose of the document is to give an overview about Rule Model Extension and to provide clear idea about “how the Rule model extension helps to add custom properties of different data types” to the rule and also various steps involved while creating such extension model files and extension data files. Also help us to import the created extension model and extension data files into the file System and visualizes the various actions involved while integrating such developed custom properties with the Rule Studio.

How to add custom properties  to rules?



•    Rule model extension defines the artifacts that are managed in a rule project. These artifacts have associated properties with various types also helps to extend the rule model to provide new properties.

•    Rule model extension helps to create a new type of rule artifact or rule package, or to add properties to existing rule model classes.

Rule model extensions are common to Rule Studio and Rule Team Server environment.


We can define extension once for both the environments. You then need to integrate the rule model extension into Rule Studio or Rule Team Server, and then synchronize the extensions of the two environments.

.
Rule model extension extends to extension model and extension data.

Rule model extension can be defined in both the rule model extension editor and standard xml editor environment.

Extension Schema


     You can define rule model extension in XML file. The default extension file is the extension model file, which defines the structure of the extension model. You can associate extension data file to the extension model file, which defines the values for the properties.
a)    Extension model.xsd
b)    Extension data.xsd

Default Extension model


  The following table shows the default properties associated with the rules.

Rule Extension Model

Rule Model Extension Editor


i.    It helps to change the data in the extension model in the root level or model level.
ii.    To open rule model extension editor, double click on the extension model file (.brmx) and (.brdx) extension data file in the rule explorer.

Actions in the Rule Model Extension Editor
Steps to create Rule Extension Model

1.    Select File-> New-> Other-> Rule Designer-> Rule Model Extension-> Extension Model.

select next.

3.    Select any one rule project as a parent folder.
4.    Ensure that “Fill with default extension content” is selected.
5.    Click Finish.
 Now the Extension Model Editor looks like
Highlighted fields are the default properties

List of custom properties to be added

Let us add four more properties to the action rule

1. RuleId
2. RuleVersion
3. RuleCategory
4. RuleDescription
Steps to add custom properties to the extension model file

Step 1: Right click on Rule: Add Property and select new child -> property


Step 2: In the following screen shot shows the newly added property RuleId of data type Integer

Highlighted value is the new property file (RuleId) which is added recently.
We can also choose the data type of the property from the “drop assistance box”.


Added one more property of type Float. Similarly we can also add more number of properties

RULE EXTENSION DATA


Rule model extension editor to help you create or modify an extension data file.

Extension data file (.brdx) which is associated with the extension model file (.brmx) helps to add values to the properties which is added recently.

Actions in the Rule Extension Data Editor

Steps to create Rule Extension Data

1.    File-> New-> Other-> Rule Designer (or) Rule studio ->Rule Model Extension-> Extension
2.    Actions in the extension data editor:
3.    Click Next.


 4.    Similar to the extension model file we can expand the tree and by making right click on root level node can add same kind of properties as we created in the extension model file.

 
 
5.    Adding values to the properties using extension data.

Steps to add values to the properties:

1.    Adding values to the properties which is added through extension model file (.brmx).
2.    Select the property child element, consider the above screen shot as example RuleVersion
3.    Set the default value as you like or set depends on the requirements.
4.    Save it once.

Integrating Rule Model Extension with the Rule Studio


After integrating the rule model extension with the Rule Studio, the changes which we made will reflect in the property tab once we restart the Rule Studio.

 Above screen shot shows the newly added properties and their default values associated with the simple rules.

How to add a custom property of type “Enum”?


Steps to add an Enum properties


Step: 1 EXTENSION MODEL FILE
1.    Open the Rule Extension Model Editor.
2.    Rule: Add Property -> New Sibling -> Enum.
3.    Following screen shots will helps to add a property of type Enum.

 
4.    Select

5.    Adding Values to the (RuleCategory) property of type “Enum” using extension data file.
6.    Create a new property in the extension data file as follows.
Right Click on <extension data >tree -> New Child -> Enum data.

7.    Enter the property name as “RuleCategory” as given in the extension model file.

8.    Select the button which is highlighted in circle.
9.    It will open a window where we can add our values. Following screen shot will gives a clear idea to add Enum values





10.    Finally we added a custom property “ruleCategory” of type “RuleCategory” which is nothing but an “Enum”.
11.    Following screen shot will clearly explains the “rule category” of type “RuleCategory”.

.
 


12.    Similarly we can add RuleDescription as another property which is of type “Enum”.
13.    The ruleCategory property of type “Enum” will look as follows





Steps to integrate the props with the Rule Studio

Below mentioned are some screen shots to integrate this rule model extension with rule studio.
1.    Select Window-> Preferences -> Rule Designer -> Rule Model Extension.































2.    Click the Change from workspace button.
3.    Select the particular Rule project and expand the tree.
4.    Import both the extension model and extension data files into it.
5.    Click Apply and ok.
6.    Restart your Rule Studio.
7.    Open any one simple rule and check for properties in the property tab.
8.    Finally the custom properties associated with the rules are displayed as follows
9.    Repeat the above steps whenever you add additional properties.


•    This Rule model extension helps to add additional features to the Business Rules and hence we can also display their version status and version of rules.
•    It helps to insert your own code, at specific extension points: for example, to hide a specific property, or to call some code after a property value is changed.
These are few benefits of using properties which is associated with the rules.







2 comments: