Re: [drools-usage] Unable to execute rules with rest api which are defined with Guided decision table

42 views
Skip to first unread message
Message has been deleted

SANTHOSH GUDLA

unread,
Oct 26, 2021, 1:14:28 PM10/26/21
to drools...@googlegroups.com
There are some spell corrections in the request body employess changed to employee even after that I am getting action null in response.

On Tue, Oct 26, 2021 at 10:38 PM SANTHOSH GUDLA <santho...@gmail.com> wrote:
Hi,

I have data models like a department with a list of employees and an Action.
There are conditions like if employee age is greater than 35 then set is eligible true in Action.
If employee skill is "JAVA" then set skill true in Action and if the above 2 conditions are true then set both fields to true.
I did create a Guided decision table from the workbench then I could see rules like the below source.

package com.myspace.organizationrules;

//from row number: 1
rule "Row 1 OrgGuidedDecisions"
salience 9
ruleflow-group "orgRule"
dialect "mvel"
when
$d : Department( )
(Employee( age > ( 35 ) ) from $d.employees)
then
Action action = new Action();
action.setIsEligible(true);
$d.setAction(action);
update($d);
end

//from row number: 2
rule "Row 2 OrgGuidedDecisions"
salience 8
ruleflow-group "orgRule"
dialect "mvel"
when
$d1 : Department( )
(Employee( skill == ( "JAVA" ) ) from $d1.employees)
then
Action action = new Action();
action.setIsSkill(true);
$d1.setAction(action);
update($d1);
end

//from row number: 3
rule "Row 3 OrgGuidedDecisions"
salience 10
ruleflow-group "orgRule"
dialect "mvel"
when
$d2 : Department( )
(Employee( age > ( 35 ) , skill == ( "JAVA" ) ) from $d2.employees)
then
Action action = new Action();
action.setIsEligible(true);
action.setIsSkill(true);
$d2.setAction(action);
update($d2);
end

I did deploy changes to Kie-Server and tried to execute the above rules with API like below.

--header 'Authorization: Basic d2JhZG1pbjp3YmFkbWlu' \
--header 'Content-Type: application/json' \
--data-raw '{
    "commands": [
        {
            "insert": {
                "out-identifier": "orgRule",
                "object": {
                    "Department": {
                        "employess": [
                            {
                                "id": 1,
                                "name": "Santhosh",
                                "age": 30,
                                "skill": "JAVA"
                            },
                            {
                                "id": 2,
                                "name": "Sri",
                                "age": 36,
                                "skill": "JAVA"
                            },
                            {
                                "id": 2,
                                "name": "Vas",
                                "age": 36,
                                "skill": "PYTHON"
                            },
                            {
                                "id": 2,
                                "name": "Vasu",
                                "age": 34,
                                "skill": "PYTHON"
                            }
                        ]
                    }
                },
                "return-object": true
            }
        },
        {
            "fire-all-rules": {
                "max": "1",
                "out-identifier": "orgRule"
            }
        }
    ]
}'

response is: 
{
  "type" : "SUCCESS",
  "msg" : "Container OrganizationRules_1.0.0-SNAPSHOT successfully called.",
  "result" : {
    "execution-results" : {
      "results" : [ {
        "value" : 0,
        "key" : "orgRule"
      } ],
      "facts" : [ {
        "value" : {"org.drools.core.common.DefaultFactHandle":{
  "external-form" : "0:1:1428226676:1428226676:1:DEFAULT:NON_TRAIT:com.myspace.organizationrules.Department"
}},
        "key" : "orgRule"
      } ]
    }
  }
}

but rules are not executing. Can someone help me with this?

Thank you!

Regards,
Santhosh Gudla

--
You received this message because you are subscribed to the Google Groups "Drools Usage" group.
To unsubscribe from this group and stop receiving emails from it, send an email to drools-usage...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/drools-usage/b32cf4ca-fa06-404a-8847-000def7b28c9n%40googlegroups.com.

Richard Bourner

unread,
Oct 26, 2021, 2:53:28 PM10/26/21
to drools...@googlegroups.com
It does not look like you have activated the ruleflow group. If you are using a ruleflow, you need to start it.

SANTHOSH GUDLA

unread,
Oct 27, 2021, 12:25:30 AM10/27/21
to Drools Usage
Thank you Richard Bourner.

Now I could able to execute and get the results.

Reply all
Reply to author
Forward
0 new messages