MyProblem: Based on TrainData I want to set the value of TrainStatus via postman call but I am not getting expected response.
How i can achieve this ?
I have created two data objects-
TrainData-
| Column A | Column B |
|---|---|
| trainID | integer |
| area | String |
TrainStatus-
| Column A | Column B |
|---|---|
| TrainStatus | String |
| DriverName | String |
Drl file-
rule "set Train status"
when
TDobj : TrainData(trainID==111 && area=="South")
TSobj : TrainStatus()
then
TSobj.setTrainStatus("running");
end
Request:
- Endpoint: http://localhost:8080/kie-server/services/rest/server/containers/instances/demo_1.0.0-SNAPSHOT
{
"lookup": null,
"commands": [
{"insert": { "object":{ "TrainData":{ "trainID":112 , "area":"South"}},
"out-identifier": "TrainData",
"return-object":true
} },
{"insert": { "object":{ "TrainStatus":{ }},
"out-identifier": "TrainStatus",
"return-object":true
} },
{ "fire-all-rules": {}}
]
}
Response:
{
"type": "SUCCESS",
"msg": "Container demo_1.0.0-SNAPSHOT successfully called.",
"result": {
"execution-results": {
"results": [
{
"value": {
"com.dummyspace.demo.TrainData": {
"trainID": 112,
"area": "South",
"trainType": null
}
},
"key": "TrainData"
},
{
"value": {
"com.dummyspace.demo.TrainStatus": {
"trainStatus": "Running",
"auditInterval": null,
"hpbufferAllowance": null
}
},
"key": "TrainStatus"
}
],
"facts": [
{
"value": {
"org.drools.core.common.DefaultFactHandle": {
"external-form": "0:5:2011994629:2011994629:5:DEFAULT:NON_TRAIT:com.dummyspace.demo.TrainData"
}
},
"key": "TrainData"
},
{
"value": {
"org.drools.core.common.DefaultFactHandle": {
"external-form": "0:6:1902014052:1902014052:6:DEFAULT:NON_TRAIT:com.dummyspace.demo.TrainStatus"
}
},
"key": "TrainStatus"
}
]
}
}
}
My rule is if TrainData==111 and area=="south" then set TrainStatus to "Running". but in body if I am entering different train data/area irrespective of condition I am getting TrainStatus = Running.
I am not getting response based on the condition.
In your question, you are reporting that allegedly the TrainStatus is not correctly valorized.
In your description, you say:
In your snippet response, you have:
but on request to provide the actual DRL file, you provide:
which clearly is A. not the actual DRL, B. not the only rule in the rule base, since the setter is valorizing with
"running"(lowercase R) which is inconsistent from the alleged reported issue/question.Based on the information provided, it's difficult to investigate further, and just by the current available information I would suspect there is something else going on based on this inconsistency; consider providing a full reproducer (e.g. the KJAR project shared on github for example).