【发布时间】:2018-03-07 08:50:20
【问题描述】:
我可以使用 kie-workbench 规则引擎并创建了许多规则。一切运作良好。但我无法成功归还多项资产。 RESPONSE 中的“LoanApplication”在哪里?
我的规则:
package mortgages.mortgages;
import java.lang.Boolean;
import java.lang.Number;
import java.lang.String;
import java.util.Date;
import java.lang.Integer;
//from row number: 1
rule "Row 1 Gdt2"
dialect "mvel"
when
f2 : Applicant( age > 18 )
then
f2.setAge( 18 );
f2.setApproved( true );
Applicant f10 = new Applicant();
f10.setAge( 18 );
insert( f10 );
LoanApplication f12 = new LoanApplication();
f12.setAmount( 20000 );
insert( f12 );
end
如果我通过 SOAP UI restful 调用上述规则:http://localhost:8080/kie-server/services/rest/server/containers/instances/mortgages_1.0.0-SNAPSHOT
请求:
{
"commands": [
{
"insert": {
"object": {
"Applicant": {
"age": 20
}
},
"out-identifier": "t1",
"return-object": true
}
}, {
"insert": {
"object": {
"Applicant": {
"age": 22
}
},
"out-identifier": "t2",
"return-object": true
}
},
{
"fire-all-rules": {}
}
]
}
回应:
{
"type": "SUCCESS",
"msg": "Container mortgages_1.0.0-SNAPSHOT successfully called.",
"result": {"execution-results": {
"results": [
{
"value": {"mortgages.mortgages.Applicant": {
"age": 18,
"applicationDate": null,
"approved": true,
"creditRating": null,
"name": null
}},
"key": "t1"
},
{
"value": {"mortgages.mortgages.Applicant": {
"age": 18,
"applicationDate": null,
"approved": true,
"creditRating": null,
"name": null
}},
"key": "t2"
}
],
"facts": [
{
"value": {"org.drools.core.common.DefaultFactHandle": {"external-form": "0:73:1097496811:1097496811:73:DEFAULT:NON_TRAIT:mortgages.mortgages.Applicant"}},
"key": "t1"
},
{
"value": {"org.drools.core.common.DefaultFactHandle": {"external-form": "0:74:1887265498:1887265498:74:DEFAULT:NON_TRAIT:mortgages.mortgages.Applicant"}},
"key": "t2"
}
]
}}
}
如果你看:
LoanApplication f12 = new LoanApplication();
f12.setAmount( 20000 );
insert( f12 );
此规则阻止了代码。我看不到 RESPONSE 这样的价值。我该怎么做?
"value": {"mortgages.mortgages.LoanApplication": {
"Amount": 20000...
......
.....
}},
......
【问题讨论】:
标签: java jboss drools rule-engine kie