作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 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());
我还填写了我期望的数据分配。它似乎获取了数据,因为当我创建一个新实例并从表单运行它时,它拥有数据并执行规则,仅使用 swagger 从其余界面中得到上述错误。
最佳答案
看了很久之后;
看来我必须稍微修改我的请求才能成为:
{
"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 流程并反射(reflect)了这一点。
关于java - 如何将 LoanApplication 对象从规则返回到 bpm 流程?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56690247/
我正在使用 drools(kie-wb Web 界面),并且我有一个 bpm 流程,该流程接受 LoanApplication 并返回带有更新数据的 LoanApplication(是目标)。但当我尝
我是一名优秀的程序员,十分优秀!