Drool 7 SpreadSheet Decision & Template 笔记

1 Excel Decision table

1.1 很棒的示意图,来自https://blog.csdn.net/justlpf/article/details/128109731
Drool 7 SpreadSheet Decision & Template 笔记_第1张图片

1.2 参考URL
1.2.1 https://blog.csdn.net/justlpf/article/details/128109731
1.3 多sheet 模式

  • 默认是用第一个sheet
  • 如果要支持多sheet,需要创建一个同名的.properties文件
    • sheets=Sheet1,Sheet2

1.4 sheet内主要内容
1.4.1 一个RuleSet :注意RuleSet里面的定义都是对package有影响,不仅仅是excel文件
默认package 名就是Ruleset 名称

  • 具体实现代码-final Package ruleset = new Package( (showPackage) ? rulesetName : null );

属性

  • RuleSet
    The package name for the generated DRL file. Optional, the default is rule_table.
  • Sequential
    true or false. If true, then salience is used to ensure that rules fire from the top down.
  • SequentialMaxPriority
    Optional, at most once. In sequential mode, this option is used to set the start value of the salience. If omitted, the default value is 65535.
  • SequentialMinPriorit
    Optional, at most once. In sequential mode, this option is used to check if this minimum salience value is not violated. If omitted, the default value is 0.
  • EscapeQuotes
  • NumericDisabled
    If true, then a String representation is used for DRL instead of a double value from a Numeric cell. It would also skip additional numeric processing for the double value.
  • IgnoreNumericFormat
    If true, then the format for numeric values is ignored
  • Import
    可以多行
  • Variables
    可以多行
  • Functions
    可以多行
  • Queries
    可以多行
  • Declare
    可以多行
  • Unit 实验性,不用
  • Dialect
    java or mvel. The dialect used in the actions of the decision table.

1.4.2 一个或者多个RuleTable

  • 以空行分割多个RuleTable
  • 无论CONDITION/RULE,值为空代表忽略
  • metadata
    • Code snippet and interpolated values for constructing a metadata entry for the rule.
    • 没有google到例子

Properties 和rule 属性差不多,但注意salience 被priority代替

  • PRIORITY An integer defining the salience value of the rule
  • DATE-EFFECTIVE
    Example: DATE-EFFECTIVE “4-Sep-2018”
  • DATE-EXPIRES
  • NO-LOOP
  • AGENDA-GROUP
  • ACTIVATION-GROUP
  • DURATION
  • TIMER
  • CALENDAR
  • AUTO-FOCUS
  • LOCK-ON-ACTIVE
  • RULEFLOW-GROUP

1.5 excel 转换为drl文件的核心类是public class DefaultRuleSheetListener
1.5.1 核心函数buildRuleSet()

2 template

2.1 用途

  • 使用外部存储的变量列表:如数据库、excel 生成drl文件
  • 默认提供了从excel ,对象、list导入数据模式

2.2 相关生成drl的compiler

  • ExternalSpreadsheetCompiler
  • DataProviderCompiler
    可以以DataProviderCompiler为父类,自行定义开发新的compiler
  • ObjectDataCompiler
    • extends DataProviderCompiler
    • 当对象有null值被引用的时候,DefaultGenerator如下代码可能返回空condition
String drl = String.valueOf( TemplateRuntime.execute( template,vars,factory,registry ) );

你可能感兴趣的:(规则引擎,Drools,spreadsheet,decision,table,template)