【问题标题】:ArrayList in ilog rulesilog 规则中的 ArrayList
【发布时间】:2014-09-05 13:35:45
【问题描述】:

我正在研究 ilog 规则。我想验证对象数组列表中的字段。

喜欢,

class Company {
    List<Employee> employee;
}

class Employee {
    String Name;
    int age;
}

在这里我想验证年龄字段不是负数。我将公司对象作为输入参数传递,

definitions
    set 'Company' to 'The Company to validate' ;
    set 'Employees' to employee working for 'Company'

现在我如何迭代作为数组列表的员工并检查年龄验证。

【问题讨论】:

  • 我相信你会尝试年龄 > 0 的条件。只是为了了解更多,您要在哪里验证?

标签: rule-engine ilog jrules


【解决方案1】:

使用 'in' BAL 构造将集合中的单个员工绑定到 definitions 语句中的变量,然后为该员工编写验证规则。

查看您的 IBM ODM 版本的知识中心/信息中心,例如:

IBM Operational Decision Manager 8.6.0>Operational Decision Manager version 8.6>Decision Server Rules>Reference>Rule Designer reference>Rule languages>Business Action Language (BAL)>BAL constructs>in

你可以试试这样的:

definitions 
    set 'employee' to an employee in the employees of 'the company' ; 
if
    the age of employee is less than 0
then
    print "Age of employee " + the name of employee + "' is negative: " + the age of employee ; 
else
    print "Age of employee " + the name of employee + "' is OK: " + the age of employee ; 

【讨论】:

  • 所以它会自动迭代所有员工对象?
  • 是的,它会按照你的预期运行。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多