I added an object from a custom class in a HashMap. When you insert the Drools code, I can iterate through the HashMap and get a pair of keys and values. But I cannot access the attributes inside the user class, which is a section of HashMap values.
This is a POJO file used to store data. This POJO will be inserted into LinkedHashMap using a separate key. Currently, this key is only being created using a simple loop.
package com.sample.pojos; import java.util.Date; public class DateSet { public DateSet() {
This is the Java code used to add values ββto LinkedHashMap. I used LinkedHashMap because I need to access the elements in the correct order. The HashMap key is int, and the value will be a DateSet.
outHash.put(incrementedId, new DateSet(training.getTrainingType(), training.getCompletionDate(), training.getExpirationDate()));
This is the Drools rule that I use to handle the HashMap. The commented part of the code is how I would like to use an object inside Drools. "entry.getValue ()" prints a DateSet, but I cannot access the attributes inside it.
rule "Validate test" agenda-group "validate_init" when someClass: SomeClass($tMap : outHash) entry : Entry($valueV : value) from $tMap.entrySet() //Boolean(booleanValue == true) from ($valueV.getTrainingType() == "NEW") then //System.out.println($valueV.getTrainingType()); System.out.println(entry.getKey() + "-" + entry.getValue()); end
source share