【问题标题】:how to know the rules which are using a particular attribute如何知道使用特定属性的规则
【发布时间】:2020-02-05 23:29:37
【问题描述】:

假设我有一个如下所示的规则文件。以下规则基于 2 个属性 Instrument 和 maverickModelMappingId。 Drools 可以告诉我有多少规则使用“仪器”字段吗?我的用例是我想知道我是要删除一个属性还是一个字段,有多少条规则以及哪些规则会受到影响。

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

【问题讨论】:

  • Drools 本身无法判断有多少规则使用了一个属性。使用 IDE 的搜索工具会是更好的解决方案。

标签: drools rules rule-engine


【解决方案1】:

从当前版本 (7.33.0.Final) 开始,Drools 无法做到这一点。如 cmets 中所述,更好的解决方案是使用 IDE 的搜索工具(或其他查找/grep 解决方案)来搜索规则文件的文本以查找对给定属性或方法的引用。

【讨论】:

    猜你喜欢
    • 2023-03-12
    • 1970-01-01
    • 2021-01-01
    • 2013-04-30
    • 2014-08-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多