0

I am using rest to fire rules in brms7 defined with ruleflow group, the json data I put like the following:

{        

 "commands": [
                {
                        "insert": {
                                "object": {
                                        "com.myspace.driver_department_traffic_violations.Violation": {
                                                "speedLimit": 40,
                                                "type": "Speed",
                                                "actualSpeed": 55
                                        }
                                }
                        }
                },             
                {
                        "fire-all-rules": {}
                },
                {
                        "get-objects": {
                                "out-identifier": "violation"
                        }
                },
                {
                        "dispose": {}
                }
        ]}

Question is how to assign ruleflow group inside the json data? the rule in server has ruleflow group assigned, I need to assign ruleflow group name in json to fire the rules.

Nimantha
  • 6,405
  • 6
  • 28
  • 69
Lan
  • 119
  • 12

1 Answers1

0

For my example, the ruleflow-group is called "incident".

{
  "lookup": "defaultKieSession",
  "commands": [
    {
      "insert": {
        "object": {
          "com.myspace.driver_department_traffic_violations.Violation": {
            "speedLimit": 40,
            "type": "Speed",
            "actualSpeed": 55
          }
        },
        "out-identifier": "violation"
        
      }
    },
    {
      "set-focus": {
        "name": "incident"
      }
    },
    {
      "fire-all-rules": {}
    }
  ]
}

For remote execution on Decision Server your code should look like this:

List<Command<?>> commands = new ArrayList<>();
KieServices kieServices = KieServices.Factory.get();
KieCommands commandFactory = kieServices.getCommands();
commands.add(commandFactory.newAgendaGroupSetFocus("incident"));

In case you're wondering, AgendaGroups are also treated the same way. You can read this excerpt on Stack Overflow from the documentation.

Nimantha
  • 6,405
  • 6
  • 28
  • 69
LastEmperor
  • 33
  • 1
  • 5