How to write a rule which can iterate over multiple level of fact field List ?

Solution Unverified - Updated -

Issue

  • Consider this typical example of a fact whose specific field is a java.util.List of another fact type, and that internally refers to a java.util.List of 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, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content