Decision table final logic

From FlexRule Wiki
Jump to: navigation, search

Decision Table Final Logic

Once a decision table is designed, it will build up all the expressions for actions and conditions based on how it is modeled.

DT-Editor-Toolbar-compile.png

All Decision Tables will be translated (compiled to) Validation logic on execution. To check the executable validation tree logic, click on the Compile to Validation Tree highlighted on the above toolbar.

But you can see the actual expressions that will be evaluated. Let's say you have modelled the following Decision Table:

Car-premium-calc.png

Once you press the button, you can see the XML representing the tree logic of your decision table will all built expressions. For example, the bellow picture shows you the R7 rule:

Car-premium-calc-tree.png

 Please note this is not the whole tree logic of the above decision table. It is just the logic for R7.

Validation Tree

It is also possible to retrieve the Validation Tree programatically. To doing that so you need to:

  1. Get ITable of your decision table
  2. Use TableParser parse and transform your decision table to its validation tree
// Load the decision table model from its content i.e. binary/string 
var decisionTableModel = LoadAdapterUtility.LoadModel(Encoding.UTF8.GetBytes(decisionTable));
 
// Create a table reader to build ITable of the decision table model
var reader = new XmlTableReader(decisionTableModel);
IIterable<ITable> tables = reader.GetTables();
 
// Use TableParser to create the validation tree of the decision table
IElementModel validationModel = TableParser.CreateParser().Parse(tables).First();
 
// If you need the XML equivalent of any IElementModel, you can use ToXml method. 
string validationXml = validationModel.ToXml();