How to write a rule which can iterate over multiple level of fact field List ?
Issue
- Consider this typical example of a fact whose specific field is a
java.util.Listof another fact type, and that internally refers to ajava.util.Listof another fact type. Here is an example of how the internal fact hierarchy could look like.
Fact: A
package com.sample.test;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import org.kie.api.definition.type.Label;
public class A
implements Serializable
{
static final long serialVersionUID = 1L;
@Label("B nodes")
private List<com.sample.test.B> bNodes = new ArrayList();
...
}
Fact: B
public class B implements java.io.Serializable
{
static final long serialVersionUID = 1L;
...
@org.kie.api.definition.type.Label(value = "parameters")
private java.util.List<com.sample.test.C> parameters;
...
}
Fact: C
public class C implements java.io.Serializable
{
static final long serialVersionUID = 1L;
@org.kie.api.definition.type.Label("name")
private java.lang.String name;
@org.kie.api.definition.type.Label(value = "value")
private java.lang.String value;
...
}
The requirement is to create a rule that iterate over the List of bNodes from the above example and, for each B type iterate over the parameters type, to update a field from fact C , using a function in DRL. How to achieve this requirement?
Environment
- Red Hat JBoss BRMS (BRMS)
- 6.1.0
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
