将Java POJO转换为Drools DRL,反之亦然 [英] Convert Java POJO to Drools DRL and vice versa

查看:166
本文介绍了将Java POJO转换为Drools DRL,反之亦然的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在构建到Java POJO的UI上有规则配置。我该如何生成Drools DRL(将其传递到其他将与事实匹配的组件,如果规则匹配则返回true或false)。

I have rule configuration on UI which builds to 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).

我还从数据库并为了在UI上显示规则,我需要转换回Java POJO。

Also I receive DRL file from database and in order to show rule on UI, I need to convert back to Java POJO.

Basiclly是否有任何工具或脚本可以在Java POJO和Drools DRL文件之间转换?如果没有,什么是最好的方法?

Basiclly is there any tool or script that could convert between Java POJO and Drools DRL file? If not, what is the best way available?

非常感谢!

推荐答案

我不确定您的Java POJO是什么?它们代表规则,模式,约束等吗?

I am not sure what are your Java POJOs? Are they representing Rules, Patterns, Constraints, etc?

如果是这样,Drools有一个内部规范模型可以代表所有类型的知识资产[1]。我们不建议您直接使用它,因为它是一个内部API,并且可能会发生更改。

If so, Drools has an internal canonical model for representing all types of knowledge assets [1]. We do not recommend using it directly though, as it is an internal API and subject to change.

您的另一种选择是使用实际的规则描述符构建器API [2 ]动态生成规则[3]。

Another option for you is to use the actual rule descriptor builder API [2] to generate your rules dynamically [3].

最后,如果您有基于Web的UI,并且希望允许用户在其中编写规则,则可以选择将guvnor的规则编辑器嵌入到自己的应用程序中[4]。

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].

希望这会有所帮助。

[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

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

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

这篇关于将Java POJO转换为Drools DRL,反之亦然的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆