代码之家  ›  专栏  ›  技术社区  ›  auhuman

Drools错误:找不到@位置字段

  •  6
  • auhuman  · 技术社区  · 7 年前

    我创建了一个drool文件PersonTotalAccountsBalance。drl如下所示。我是规则引擎领域的初学者。

    package com.auhuman.rules;
    
    import com.auhuman.Person;
    import com.auhuman.Account;
    
    function float getTotalBalance(Person person) {
         float totalBalance = 0;
         for (Account account : person.getAccounts()){
             totalBalance += account.getBalance();
         }
         return totalBalance;
    }
    
    rule "PersonTotalAccountsBalance"
        when
            $node : Person(active == true)
        then
            float totalBalance = getTotalBalance($node)
    
            modify($node) {
               setTotalBalance(totalBalance);
            }
    end
    

    编译后,我得到以下错误

    Unable to compile the file: PersonTotalAccountsBalance.drl. Errors = [Unable to find @positional field 0 for class Person
     : [Rule name='PersonTotalAccountsBalance']
    ]
    
    1 回复  |  直到 7 年前
        1
  •  3
  •   Guillermo    3 年前

    虽然这个问题很古老: 我收到了相同的错误消息,但我正在中处理决策表 xls (excel)格式。桌子是这样的:

    merged cells

    请注意 $order:Order 位于合并单元格中,该单元格跨越 CONDITION 以及 ACTION 柱。该单元格仅允许位于上方 条件 表,而不是 行动 桌子。取消合并后,我再也没有收到错误:

    unmerged cells

    行动 用于设置属性的列。使用不带引号的值时 String 模型中的属性 Order 我遇到以下错误:

    Unable to get KieModule, Errors Existed: Error Messages:
    Message [id=1, kieBase=defaultKieBase, level=ERROR, path=status_rules/status.xls, line=21, column=0
       text=Rule Compilation error The method setNextStatus(String) in the type Order is not applicable for the arguments (int)]
    Message [id=2, kieBase=defaultKieBase, level=ERROR, path=status_rules/status.xls, line=5, column=0
       text=Rule Compilation error The method setNextStatus(String) in the type Order is not applicable for the arguments (int)]
    Message [id=3, kieBase=defaultKieBase, level=ERROR, path=status_rules/status.xls, line=13, column=0
       text=Rule Compilation error The method setNextStatus(String) in the type Order is not applicable for the arguments (int)]
    

    然而,在这种情况下,错误消息更为精确。