我使用 Kie Workbench 学习 Drools。我的输入将是机会产品类中的名称,我期待机会类中的 Ip 中的输出。规则引擎执行后,我在输出中只得到空值。
Pojo 结构:
Opportunity.Java :
private java.lang.Boolean result;
private java.lang.String ip;
private java.util.List<com.sample2.sampledemo2.OpportunityProduct> productlist;
OpportunityProduct.Java
private java.lang.String name;
输入:
{
"commands":[
{
"insert":{
"out-identifier":"com.sample2.sampledemo2.Opportunity",
"return-object":true,
"object":{
"com.sample2.sampledemo2.Opportunity":{
"productlist":[
{
"name":"abc"
}
]
}
}
}
},
{
"fire-all-rules":""
}
]
}
输出:
{
"type":"SUCCESS",
"msg":"Container abcdef successfully called.",
"result":{
"execution-results":{
"results":[
{
"key":"",
"value":0
},
{
"key":"com.sample2.sampledemo2.Opportunity",
"value":{
"com..sample2.sampledemo2.Opportunity":{
"result":null,
"ip":null,
"productlist":[
{
"name":"abc"
}
]
}
}
}
],
"facts":[
{
"key":"com.sample2.sampledemo2.Opportunity",
"value":{
"org.drools.core.common.DefaultFactHandle":{
"external-form":"0:2:1366747666:1366747666:2:DEFAULT:NON_TRAIT:com.sample2.sampledemo2.Opportunity"
}
}
}
]
}
}
}
决策表:
NAME CONDITION ACTION
o:Opportunity(pd: productlist)
OpportunityProduct
(name == $param , this memberOf pd) o.setIp($param);
Origination "abc" "IPP"
博士升 :
rule "Origination"
when
o:Opportunity(pd: productlist)
(OpportunityProduct(name == "abc" , this memberOf pd))
then
o.setIp("IPP");
end
我无法确定我的输入是否错误或决策表中的条件是否错误。