Drools 如何知道使用特定属性的规则
假设我有一个如下所示的规则文件。以下规则基于2个属性Instrument和MaverickModelAppingId构建。Drools能告诉我有多少规则使用“仪器”字段吗?我的用例是,我想知道是否要删除属性或字段,有多少规则以及哪些规则将受到影响Drools 如何知道使用特定属性的规则,drools,rules,rule-engine,Drools,Rules,Rule Engine,假设我有一个如下所示的规则文件。以下规则基于2个属性Instrument和MaverickModelAppingId构建。Drools能告诉我有多少规则使用“仪器”字段吗?我的用例是,我想知道是否要删除属性或字段,有多少规则以及哪些规则将受到影响 package abc.modelMapping.ruleEngine; dialect "java" declare FRONTOFFICESYSTEM Instrument : String maverickMode
package abc.modelMapping.ruleEngine;
dialect "java"
declare FRONTOFFICESYSTEM
Instrument : String
maverickModelMappingId : String
end
rule "rule_MurexCredit_Rule_3"
salience 3
no-loop true
when
$frontOfficeSystem : FRONTOFFICESYSTEM("Default swap".equalsIgnoreCase(Instrument))
then
$frontOfficeSystem.setMaverickModelMappingId("001282");
System.out.println("001282 "+"MurexCredit_Rule_3+");
end
rule "rule_MurexCredit_Rule_2"
salience 2
no-loop true
when
$frontOfficeSystem : FRONTOFFICESYSTEM("Euro credit index option".equalsIgnoreCase(Instrument))
then
$frontOfficeSystem.setMaverickModelMappingId("001283");
System.out.println("001283 "+"MurexCredit_Rule_2+");
end
rule "rule_MurexCredit_Rule_1"
salience 1
no-loop true
when
$frontOfficeSystem : FRONTOFFICESYSTEM("Credit index".equalsIgnoreCase(Instrument))
then
$frontOfficeSystem.setMaverickModelMappingId("001282");
System.out.println("001282 "+"MurexCredit_Rule_1+");
end
从当前版本(7.33.0.Final)起,这在Drools中是不可能的。如评论中所述,更好的解决方案是使用IDE的搜索工具(或其他find/grep解决方案)搜索规则文件的文本,以查找对给定属性或方法的引用。Drools本身无法判断有多少规则使用属性。使用IDE的搜索工具将是一个更好的解决方案。