我正在使用drools(kie-wb Web界面),并且我有一个bpm流程,该流程将使用loanApplication并以更新的数据返回该loanApplication(这是目标)。但是当我尝试这样做时,我会回来的。
"Unable to create response: [LoanApplicationReviewer.LoanApplicationReview:21 - Age Knockout:1] -- [LoanApplicationReviewer.LoanApplicationReview:21 - Age Knockout:1] -- null"
我的数据模型:
public class LoanApplication implements java.io.Serializable {
static final long serialVersionUID = 1L;
private java.lang.Integer id;
private java.lang.Integer age;
private boolean accepted = true;
private java.util.List<java.lang.String> knockoutReasons = new java.util.ArrayList<java.lang.String>();
public LoanApplication() {
}
public java.lang.Integer getId() {
return this.id;
}
public void setId(java.lang.Integer id) {
this.id = id;
}
public java.lang.Integer getAge() {
return this.age;
}
public void setAge(java.lang.Integer age) {
this.age = age;
}
public boolean isAccepted() {
return this.accepted;
}
public void setAccepted(boolean accepted) {
this.accepted = accepted;
}
public java.util.List<java.lang.String> getKnockoutReasons() {
return this.knockoutReasons;
}
public void setKnockoutReasons(
java.util.List<java.lang.String> knockoutReasons) {
this.knockoutReasons = knockoutReasons;
}
public void addKnockoutReason(String knockoutReason) {
if (this.knockoutReasons == null) {
this.knockoutReasons = new java.util.ArrayList<java.lang.String>();
}
this.knockoutReasons.add(knockoutReason);
}
public String toString() {
return "loanApplicationResponse::[accepted=" + this.accepted
+ ",knockoutReasons="
+ this.knockoutReasons.toString() + "]";
}
public LoanApplication(java.lang.Integer id, java.lang.Integer age,
boolean accepted, java.util.List
knockoutReasons) {
this.id = id;
this.age = age;
this.accepted = accepted;
this.knockoutReasons = knockoutReasons;
}
}
我的规则是:
package com.xyz.loanapplicationreviewer;
import com.xyz.loanapplicationreviewer.LoanApplication;
import org.kie.api.runtime.process.WorkflowProcessInstance;
rule 'age less than 30 do not accept'
ruleflow-group 'ageKnockoutGroup'
dialect "mvel"
when
$process : WorkflowProcessInstance();
$loanApp : LoanApplication() from (LoanApplication)$process.getVariable("loanApplication");
eval ($loanApp.getAge() < 30);
then
$loanApp.setAccepted(false);
$loanApp.addKnockoutReason("age under 30");
((WorkflowProcessInstance)kcontext.getKnowledgeRuntime().getProcessInstance($process.getId())).setVariable("loanApplication", $loanApp);
System.out.println("Age less than 30 knockout");
end
我在业务规则步骤上添加了一个入口脚本,以填充流程实例,如下所示:
kcontext.getKnowledgeRuntime().insert(kcontext.getProcessInstance());
我还填写了我希望做的数据分配。看来是要获取数据,因为当我创建一个新实例并从具有数据的表单中运行它并执行规则时,只是使用sragger从其余接口中获取了以上错误。
答案 0 :(得分:1)
看了很久很久了
看来我必须稍微修改一下我的请求才能成为:
{
"loanApplication" : {
"com.xyz.abc.LoanApplication" : {
"id" : 1,
"age": 1,
"accepted" : true
}
}
}
我还必须将规则更改为:
rule 'age less than 30 do not accept'
ruleflow-group 'ageKnockoutGroup'
dialect "mvel"
when
loanApplication : LoanApplication(age < 30);
//process : WorkflowProcessInstance();
//loanApp : LoanApplication() from (LoanApplication)process.getVariable("loanApplication");
//eval (loanApp.getAge() < 30);
then
loanApplication.setAccepted(false);
loanApplication.addKnockoutReason("age under 30");
System.out.println("in then less than 30 with loanApp:" + loanApplication.toString());
String knockoutReasonFact = "age under 30";
boolean acceptedFact = false;
insert(knockoutReasonFact);
insert(acceptedFact);
update(loanApplication);
end
使用所有相同的端点,最终我得到了预期的响应。我刚刚结束了对业务中心如何调用我的drools / jbpm流程的跟踪,并进行了镜像。