在Java中获取和编辑Drools规则 [英] Fetch and Edit Drools rules in java

查看:99
本文介绍了在Java中获取和编辑Drools规则的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Drools的新手.我们有一个使用规则的应用程序,并使用Drools Guvnor添加/更新规则.现在,我们正在尝试创建一个UI,业务用户(非技术人员)可以使用他们可以理解的格式来查看/更改规则.为此,我们首先需要获取"java"中的规则,从它们中获取LHS和RHS并以矩阵之类的格式显示它.

I am new to Drools. We have an app where we are consuming rules and we use Drools Guvnor to add/update rules. Now we are trying to create a UI where business users(non technical) can see/change the rules in the format that they can understand. To achieve this, we first need to fetch the rules in "java", get the LHS and RHS from them and show it in a matrix like format.

我的问题是,如何获取并使用Java代码中的规则?

My question here is, how to fetch and play around with the rules in java code?

请提出是否有其他方法可以实现相同目标.

Please suggest if there are any alternative approaches to achieve the same.

快乐编码!

推荐答案

规则不作为Java代码存在.但是,您可以使用Guvnor REST API下载规则的DRL源代码,然后再次上传.

The rules don't exist as Java code. However, you can use the Guvnor REST API to download the DRL source code for the rules and then upload it again.

但是,听起来您想支持在Guvnor中修改的规则之间的往返行程,然后将其加载到您的UI中,然后进行修改,然后再上传回Guvnor.我想不出做到这一点的方法,这不会非常脆弱.当然,如果您是Drools的新手,我建议您不要尝试实现这一目标.

However, it sounds like you want to support round trips between rules modified in Guvnor, loaded into your UI, modified and then uploaded back to Guvnor. I can't think of a way of doing this, which would not be extremely fragile. Certainly if you are new to Drools, I would recommend staying well away from trying to implement this.

如果要使用完全自定义的UI而不是使用Guvnor规则管理功能,则最好将规则存储在自己的域模型中,并从数据库中生成DRL.这可能会使Guvnor在您的环境中变得多余.如果您还有其他规则需要在Guvnor中进行管理,则可以生成DRL,然后使用REST API将其上传到Guvnor.

If you want to work with a completely custom UI instead of using the Guvnor rule management functionality, you would be better off storing the rules in your own domain model in a database and generating the DRL from that model. This may make Guvnor redundant in your environment. If you have other rules which still need to be managed in Guvnor, then you could generate the DRL and upload it to Guvnor using the REST API.

这篇关于在Java中获取和编辑Drools规则的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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