Compile drools guided decision table into rules

懵懂的女人 提交于 2019-12-06 20:05:46

问题


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... :/


回答1:


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!