0

I am working in ilog rules. I want to validate a field which is inside an array list of objects.

Like,

class Company {
    List<Employee> employee;
}

class Employee {
    String Name;
    int age;
}

Here I want to validate the age field is not negative. I have company object passed as input parameter,

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

Now how can I iterate employee which is an arraylist and check for age validations.

halfer
  • 19,824
  • 17
  • 99
  • 186
Lolly
  • 34,250
  • 42
  • 115
  • 150
  • I am sure you would have tried age > 0 condition. Just to understand a bit more, where are you trying to validate? – Devesh Sep 07 '14 at 12:24

1 Answers1

0

Use the 'in' BAL construct to bind a single employee from your collection to a variable in your definitions statement, then write your validation rule for this employee.

See the Knowledge Center / infocenter for your IBM ODM version, for instance:

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

You could try something like:

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 ; 
ratiaris
  • 327
  • 2
  • 10