Mylos Kathos
2013-05-13 13:56:27 UTC
Mylos Kathos [https://community.jboss.org/people/mylos78] created the discussion
"Use rule to decide flow of process"
To view the discussion, visit: https://community.jboss.org/message/817402#817402
--------------------------------------------------------------
Hi all !
I'm trying to integrate some Drool Rules in a simple process. Basically I'm creating an user class which has some properties:
User user = new User("George",50);
Map<String, Object> params = new HashMap<String, Object>();
params.put("user", user);
ProcessInstance processInstance = ksession.createProcessInstance("DemoProcess", params);
ksession.insert(processInstance);
ksession.insert(user);
ksession.startProcessInstance(processInstance.getId());
ksession.fireAllRules();
When the process is started, there is a Gateway with the following rule in it:
                --------- Node X
[Start] -----X
                --------- Node Y
The Rules in the Gateway(X) are:
user.IsAdult  -->Go to Node X
!user.IsAdult -->Go to Node Y
The problem is that the condition is *always evaluated to Y* because the Rule that sets isAdult seems to be evaluated later (when the process already passed that Gateway)
rule "check user"
  no-loop
when
$p: User( age > 18)
$pi: WorkflowProcessInstanceImpl($user: variables['user'])
then
$p.setIsAdult(true);
$pi.setVariable("user", $p);
update($p);
end
Is there something I am missing in my process ????
Thanks a lot
Mylos
--------------------------------------------------------------
Reply to this message by going to Community
[https://community.jboss.org/message/817402#817402]
Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
"Use rule to decide flow of process"
To view the discussion, visit: https://community.jboss.org/message/817402#817402
--------------------------------------------------------------
Hi all !
I'm trying to integrate some Drool Rules in a simple process. Basically I'm creating an user class which has some properties:
User user = new User("George",50);
Map<String, Object> params = new HashMap<String, Object>();
params.put("user", user);
ProcessInstance processInstance = ksession.createProcessInstance("DemoProcess", params);
ksession.insert(processInstance);
ksession.insert(user);
ksession.startProcessInstance(processInstance.getId());
ksession.fireAllRules();
When the process is started, there is a Gateway with the following rule in it:
                --------- Node X
[Start] -----X
                --------- Node Y
The Rules in the Gateway(X) are:
user.IsAdult  -->Go to Node X
!user.IsAdult -->Go to Node Y
The problem is that the condition is *always evaluated to Y* because the Rule that sets isAdult seems to be evaluated later (when the process already passed that Gateway)
rule "check user"
  no-loop
when
$p: User( age > 18)
$pi: WorkflowProcessInstanceImpl($user: variables['user'])
then
$p.setIsAdult(true);
$pi.setVariable("user", $p);
update($p);
end
Is there something I am missing in my process ????
Thanks a lot
Mylos
--------------------------------------------------------------
Reply to this message by going to Community
[https://community.jboss.org/message/817402#817402]
Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]