Hi All,

I'm trying to determine if it's possible to process arrays of data using Rule 
Templates.  An example of what I'm trying to accomplish.

Spreadsheet of rules, with one of the columns being valid colors.  Valid colors 
contains comma separated data and is variable length.

For example

It might contain: "Blue, Green, Red" or "Blue", or "Red, Green, Purple, Silver" 
 Any number of entries.

I then need to process incoming fact values against this list of colors, using 
either CONTAINS or IN.

For example:

template header
desc
valid_colors[]

package org.drools.examples.templates

global com.sample.Product product;

template "ColorTestTemplate"

rule "ColorRule_@{row.rowNumber}"
when
        product1 : Product (Color in @{valid_colors});
then
        product1.setDesc("@{desc}");
end
end template

I know the following doesn't work: product1 : Product (Color in 
@{valid_colors});

However, I wanted to depict what I'm trying to accomplish.

The challenge is with valid_colors being a variable length array, I can't refer 
to the individual values using constants i.e. valid_colors0, valid_colors1, 
valid_colors3, etc to build my array list.

ie Color in ("@{valid_colors0}", "@{valid_colors1}", "@{valid_colors2}")

Is there a way to iterate through a variable length array in a template?

Any thoughts on how I could build an array list i.e. ("Blue", "Green", "Red") 
when the column contains a variable length array?

Thanks in advance,
Jason
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users

Reply via email to