droolsjbpmrule-enginekiekie-workbench

How can I use activation-group while calling kie api container?


I have been tring to use activation-group but I don't have any idea how to call activation-group from Api rest ? Please help me how to add activation-group inside of the request below.


package com.myteam.arduinodevre2;

//from row number: 1
rule "Row 1 Rulduino"
activation-group "gold"
    dialect "mvel"
    when
        f1 : ArduinoEntity( switchOn == true , voltaj >= 1000 , voltaj < 2000 )
    then
        modify( f1 ) {
                setLightOn( true )
        }
end

//from row number: 2
rule "Row 2 Rulduino"
activation-group "gold"
    dialect "mvel"
    when
        f1 : ArduinoEntity( switchOn == true , voltaj >= 5000.0 , voltaj < 10000.0 )
    then
        modify( f1 ) {
                setLightOn( false )
        }
end

//from row number: 3
rule "Row 3 Rulduino"
activation-group "gold"
    dialect "mvel"
    when
        f1 : ArduinoEntity( switchOn == false )
    then
        modify( f1 ) {
                setLightOn( false )
        }
end

//from row number: 4
rule "Row 4 Rulduino"
activation-group "silver"
    dialect "mvel"
    when
        f1 : ArduinoEntity( switchOn == true , voltaj >= 1.0 , voltaj < 3.0 )
    then
        modify( f1 ) {
                setLightOn( false )
        }
end


{

  "commands": [
    {
      "insert": {
        "object": {
          "com.myteam.arduinodevre2.ArduinoEntity": {
            "switchOn": true,
            "voltaj": 1100

          }
        },
        "out-identifier": "ArduinoEntity",
        "return-object": true
      }
    },
    {
      "fire-all-rules": "" ,
            "fire-targetgroup": "silver"
    }
  ]
}

How can I fire my target activation-group by using this kinnd of thing ->"fire-all-rules": "silver" But I cound not find valuable answer by googling.


Solution

  • You can get ActivationGroup from the KieSession, not from the KieContainer. You need to create a KieSession from the KieContainer and then use kieSession.getAgenda().getActivationGroup("").setfocus() method to get the ActivationGroup. You can check this link to check about the method return type and other methods related to it.