简体   繁体   English

在Java中获取和编辑Drools规则

[英]Fetch and Edit Drools rules in java

I am new to Drools. 我是Drools的新手。 We have an app where we are consuming rules and we use Drools Guvnor to add/update rules. 我们有一个使用规则的应用程序,并使用Drools Guvnor添加/更新规则。 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. 现在,我们正在尝试创建一个UI,业务用户(非技术人员)可以使用他们可以理解的格式查看/更改规则。 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”中获取规则,从规则中获取LHS和RHS并以矩阵形式显示。

My question here is, how to fetch and play around with the rules in java code? 我的问题是,如何获取并使用Java代码中的规则?

Please suggest if there are any alternative approaches to achieve the same. 请提出是否有其他方法可以达到相同目的。

Happy Coding! 编码愉快!

The rules don't exist as Java code. 规则不作为Java代码存在。 However, you can use the Guvnor REST API to download the DRL source code for the rules and then upload it again. 但是,您可以使用Guvnor REST API下载规则的DRL源代码,然后再次上传。

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. 但是,听起来您想支持在Guvnor中修改,加载到用户界面,修改然后上传回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. 当然,如果您是Drools的新手,我建议您不要尝试实现这一目标。

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

Guvnor is also meant to be used by non-programmers to play with the rules.. You could provide access to Business users to use Guvnor. 非程序员也可以使用Guvnor来遵守规则。.您可以提供访问业务用户的权限以使用Guvnor。

You would want to use Guvnor if 如果要使用Guvnor

-- You have a need to control access to rules and other artifacts -您需要控制对规则和其他工件的访问

-- Have a variety of non programmer users who could use graphical editors to edit rules -有各种各样的非程序员用户可以使用图形编辑器来编辑规则

http://www.jboss.org/drools/drools-guvnor.html http://www.jboss.org/drools/drools-guvnor.html

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

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