Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maps and strings in Drools rules

I have following Drools rule to which I send map filled with element , but when it gets executed I have element . Why do I get null when it should be "Y" for the value? When I put breakpoint in ACDebug.debug() method and inspect map after $map.put() was executed it looks good, it has "Y" for the value, but after my rules get executed I have null? Has anyone have similar problem?

import java.util.Map;
import java.util.HashMap;
import edu.abc.ACDebug;

rule "POSTPROCESSOR 8"
    ruleflow-group "supress-processor"
    when
        $map:Map(keySet contains "STANDARD_ADDRESS:STREET_NAME")
    then
        ACDebug.debug($map, "Map before PUT: ");
        $map.put("/locationList/sourceAddress/fullStreet",new String("Y"));
        ACDebug.debug($map, "Map after PUT: ");
        $map.remove("STANDARD_ADDRESS:STREET_NAME");
end
like image 471
azec-pdx Avatar asked Nov 15 '10 17:11

azec-pdx


1 Answers

After you have done the changes to the map, you need to do an update. This lets the working memory know that you modified the map.

Add the following line:

update( $map );
like image 189
Toni Rikkola Avatar answered Sep 28 '22 19:09

Toni Rikkola