我尝试将流程变量放入业务规则任务中,并在该任务中更改该变量,但值保持不变。我做错了什么?过程是在kie工作台上开发的,不使用eclipse。
我的变量在规则触发前在脚本任务中初始化,如
kcontext.setVariable("triggers",new com.embeddedwireless.healthdesk.InitialTriggers(false,false,false,false));
kcontext.setVariable("answers",new com.embeddedwireless.healthdesk.InitialAnswers("not","not","not","not","not","not","not","not","not","not","not","not","not","not","not","not","not","twice","not"));
规则看起来像
package com.embeddedwireless.healthdesk;
import com.embeddedwireless.healthdesk.InitialAnswers
import com.embeddedwireless.healthdesk.InitialTriggers
rule "BehavioralHealth" ruleflow-group "InitialCheck"
no-loop
lock-on-active
salience 1
when
answers : InitialAnswers( q9a in ( "always", "most", "some" ) || q10a in ( "always", "most", "some" ) || q12a in ( "always", "most", "some" ) )
triggers_out : InitialTriggers()
then
System.out.println("Beh!!!!");
triggers_out.setBehavioral( true );
update( triggers_out );
end
rule "OccupationalRule" ruleflow-group "InitialCheck"
no-loop
lock-on-active
salience 2
when
answers : InitialAnswers( q3a in ( "some", "rare", "not" ) || q3b in ( "some", "rare", "not" ) || q4a in ( "some", "rare", "not" ) || q7b in ( "always", "most", "some" ) )
triggers_out : InitialTriggers()
then
System.out.println("Occupation!!!!");
triggers_out.setOccupational( true );
update( triggers_out );
end
rule "PhysicalRule" ruleflow-group "InitialCheck"
no-loop
lock-on-active
salience 3
when
answers : InitialAnswers( q1a in ( "some", "rare", "not" ) || q1b in ( "some", "rare", "not" ) || q2a in ( "some", "rare", "not" ) || q2b in ( "some", "rare", "not" ) || q11a in ( "always", "most", "some" ) || q11b in ( "once", "twice", "more", "often" ) )
triggers_out:InitialTriggers()
then
System.out.println("Phys!!!!");
triggers_out.setPhysical( true );
update( triggers_out );
end
rule "Speech Rule" ruleflow-group "InitialCheck"
no-loop
lock-on-active
salience 4
when
answers : InitialAnswers( q7a in ( "always", "most", "some" ) )
triggers_out : InitialTriggers()
then
System.out.println("Speech!!!!");
triggers_out.setSpeech( true );
update( triggers_out );
end
我正在等待触发变量改变,但它保持像
InitialTriggers{physical=false, occupational=false, speech=false, behavioral=false}
数据分配是ok的,tomcat日志包含调试消息,如"物理!!!!"。我做错了什么?
谢谢你的帮助!
一切都很好。我看了变量历史,没有看到变化。kie-wb出了点问题。我的变量被改变了,但是在kie-wb中显示的是旧的值。