简体   繁体   English

将Java POJO转换为Drools DRL,反之亦然

[英]Convert Java POJO to Drools DRL and vice versa

I have rule configuration on UI which builds to Java POJO. 我在UI上有规则配置,构建到Java POJO。 How could I generate Drools DRL (to be passed to other component which will match facts, etc and returns true or false if rule matches). 我怎样才能生成Drools DRL(将传递给与事实相匹配的其他组件,如果规则匹配则返回true或false)。

Also I receive DRL file from database and in order to show rule on UI, I need to convert back to Java POJO. 我也从数据库接收DRL文件,为了在UI上显示规则,我需要转换回Java POJO。

Basiclly is there any tool or script that could convert between Java POJO and Drools DRL file? Basiclly有没有可以在Java POJO和Drools DRL文件之间转换的工具或脚本? If not, what is the best way available? 如果没有,最好的方法是什么?

Thanks much! 非常感谢!

I am not sure what are your Java POJOs? 我不确定你的Java POJO是什么? Are they representing Rules, Patterns, Constraints, etc? 它们代表规则,模式,约束等吗?

If so, Drools has an internal canonical model for representing all types of knowledge assets [1]. 如果是这样,Drools有一个内部规范模型来表示所有类型的知识资产[1]。 We do not recommend using it directly though, as it is an internal API and subject to change. 我们不建议直接使用它,因为它是一个内部API,可能会有变化。

Another option for you is to use the actual rule descriptor builder API [2] to generate your rules dynamically [3]. 另一个选择是使用实际的规则描述符构建器API [2]动态生成规则[3]。

Finally, if you have a web based UI and you want to allow users to author your rules in there, you have the option to embed guvnor's rule editor into your own application [4]. 最后,如果您有基于Web的UI并且希望允许用户在其中编写规则,则可以选择将guvnor的规则编辑器嵌入到您自己的应用程序中[4]。

Hope this helps. 希望这可以帮助。

[1] https://github.com/droolsjbpm/drools/tree/master/drools-compiler/src/main/java/org/drools/lang/descr [1] https://github.com/droolsjbpm/drools/tree/master/drools-compiler/src/main/java/org/drools/lang/descr

[2] https://github.com/droolsjbpm/drools/tree/master/drools-compiler/src/main/java/org/drools/lang/api [2] https://github.com/droolsjbpm/drools/tree/master/drools-compiler/src/main/java/org/drools/lang/api

[3] https://github.com/droolsjbpm/drools/blob/master/drools-compiler/src/test/java/org/drools/lang/api/DescrBuilderTest.java [3] https://github.com/droolsjbpm/drools/blob/master/drools-compiler/src/test/java/org/drools/lang/api/DescrBuilderTest.java

[4] http://www.plugtree.com/guvnor-embed-asset%E2%80%99s-editor-in-your-application/ [4] http://www.plugtree.com/guvnor-embed-asset%E2%80%99s-editor-in-your-application/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM