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... :/
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 ;)
来源:https://stackoverflow.com/questions/30378587/compile-drools-guided-decision-table-into-rules