Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compile drools guided decision table into rules

I am wondering how I could use a guided decision table from the Drools Workbench inside a Java application using the drools runtime. The idea is that a user would work defining rules, processes and some decision tables in the workbench, which will be picked up by the drools runtime.

Still, for some reason, I can't figure out how to execute this in drools, since it stored the table as a gdst file and it does not seem to compile to drools.

With drools, is there a way to: - execute the gdst file as I would with an excel decision table? - or compile a gdst file in rules?

I've been looking for a solution, but can't find a concrete example... :/

like image 770
Kevin Chabot Avatar asked May 21 '15 15:05

Kevin Chabot


People also ask

When to use decision table in drools?

When to Use Drools Decision Tables? Consider using Drools Decision Tables if your business rules exist can be expressed as rule templates and data: each row of a Decision Table provides data that is combined with a template to generate a rule. Many businesses already use spreadsheets for managing data.

What is guided decision table?

With guided decision tables, you are led by a UI-based wizard in Decision Central that helps you define rule attributes, metadata, conditions, and actions based on specified data objects in your project.


1 Answers

Ok, so basically, we could very easily generate drools rules from a guided decision table. For example:

// load the data from the GDST file, for example:
String decisionTableXml = new String ( 
  Files.readAllBytes( 
    Paths.get("./someDecisionTable.gdst") ) );

// parse the table model
GuidedDecisionTable52 model = GuidedDTXMLPersistence.getInstance().unmarshal( decisionTableXml );

// compile it into drools rules
String droolsRules = GuidedDTDRLPersistence.getInstance().marshal( model );

// next, save droolsRules into a file and/or load it into drools as a normal rule

This is one simple example for guided decision tables, but the same utils probably exsist for decision trees,... From there, you can orchestrate any Drools Workbench Asset with your Drools Expert runtime. Better solutions are always welcome ;)

like image 192
Kevin Chabot Avatar answered Oct 13 '22 10:10

Kevin Chabot