0

我尝试将我的流程变量放入业务规则任务并在此任务中更改此变量,但值保持不变。我究竟做错了什么?流程在kie workbench中开发,不使用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}

数据分配没问题,并且 tomcat 日志包含调试消息,例如“Phys !!!!”。我究竟做错了什么?

谢谢您的帮助!

4

1 回答 1

1

好吧,一切都很好。我查看了变量历史并没有看到变化。kie-wb 出现问题。我的变量已更改,但在 kie-wb 中显示的是旧值。

于 2015-06-10T12:22:57.613 回答