Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conditional Events #299

Closed
rsoika opened this issue Sep 9, 2017 · 10 comments
Closed

Conditional Events #299

rsoika opened this issue Sep 9, 2017 · 10 comments

Comments

@rsoika
Copy link
Member

rsoika commented Sep 9, 2017

In order to avoid the fact that behind each gateway output an event must be defined, ' conditional events ' will be introduced in the future.

Problem

To compute the next Task in a processing life cycle the WorkflowKernel expects either an attribute 'numnextprocessid' or the attributes 'keyFollowUp=1' and 'numNextActivityID' pointing to another Event to be processed next.
This behavior makes it necessary that an Event unambiguous points to only one Task or Event.
As a result conditional gateways could not be modeled without additional Events at the output of the gateway.

Solution

The idea is to support Models like this one:

bpmn_conditional_sequence_flows

In this model the output of the Event is a Gateway defining Flow-Conditions.
The Imixs-Workflow Engine should be aware of this Eventtype (which can be called 'conditional event') and evaluate the conditions during processing to determine the next output Task or Event.

Implementation:

Currently I expect that the BPMN Parser is throwing an exception for the model example above, because the output is not unique.
We can extend the parser in a way where we analyse if a Conditional-Gateway is the next output. If so, the conditions can be added into the Event which now becomes a 'Conditional-Event'. We can add an attribute 'txtconditions' containing a list of conditions like:

TARGET-TASK= (workitem.budget && workitem.budget[0]>100)

With this information the WorkflowKernel now can evaluate the conditions of a 'Conditional-Event' to determine the next output Task/Event.

@rsoika rsoika added this to the 4.2.0 milestone Sep 9, 2017
rsoika added a commit that referenced this issue Sep 9, 2017
@rsoika
Copy link
Member Author

rsoika commented Sep 9, 2017

parser does not break in example model.

Test-Model: https://github.com/imixs/imixs-workflow/blob/master/imixs-workflow-core/src/test/resources/bpmn/conditional_event.bpmn

So we can add the conditions from the gateway to the event....

@chrisw14
Copy link

chrisw14 commented Sep 10, 2017

Great!

So we can add the conditions from the gateway to the event....

Didn't you mean the way around from the event to the gateway?

And maybe the condition can only look like this?
workitem.amount && workitem.amount > 100
Without if, return and so on...

@rsoika
Copy link
Member Author

rsoika commented Sep 10, 2017

Yes I think so, some refactoring is necessary but it looks good....

@rsoika rsoika mentioned this issue Sep 10, 2017
rsoika added a commit that referenced this issue Sep 10, 2017
rsoika added a commit that referenced this issue Sep 10, 2017
rsoika added a commit that referenced this issue Sep 10, 2017
rsoika added a commit that referenced this issue Sep 10, 2017
issue #299
@rsoika
Copy link
Member Author

rsoika commented Sep 10, 2017

@chrisw14 can you please verify the latest snapshot release 4.2.0-SNAPSHOT.

This version should work with conditional events.
The important part in the WorkflowKernel is the new logic at line 418

@chrisw14
Copy link

chrisw14 commented Sep 10, 2017

Oh great, that was fast :-)

But if I use the format mentioned above (without if and return) I got the following exception. The same with your format with if and return:

Caused by: java.lang.NumberFormatException: For input string: "=3"
	at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
	at java.lang.Integer.parseInt(Integer.java:580)
	at java.lang.Integer.parseInt(Integer.java:615)
	at org.imixs.workflow.WorkflowKernel.getNextTask(WorkflowKernel.java:425)
	at org.imixs.workflow.WorkflowKernel.processActivity(WorkflowKernel.java:345)
	at org.imixs.workflow.WorkflowKernel.process(WorkflowKernel.java:264)

Maybe it's only a small issue because the processid 3 would be the right process :-)

See here: 14245d3#diff-4ac9d1ea072a9a3767b7925c3484ed5cR425

PS: But in my model the new processid will always be 3. What is the right condition notation? And how can I set a condition to default?

@rsoika
Copy link
Member Author

rsoika commented Sep 10, 2017

Please take a look at this example model (it is part of the junit tests)

https://github.com/imixs/imixs-workflow/blob/master/imixs-workflow-core/src/test/resources/bpmn/conditional_event1.bpmn

a condition should look like this:

(workitem._budget && workitem._budget[0]>100)

The expression is simply evaluated to an boolean.

@rsoika
Copy link
Member Author

rsoika commented Sep 10, 2017

maybe you can share your model? It would be easier to discuss...

@rsoika
Copy link
Member Author

rsoika commented Sep 10, 2017

You were right, I fixed this bug. Now it should work.

rsoika added a commit that referenced this issue Sep 10, 2017
rsoika added a commit that referenced this issue Sep 10, 2017
@rsoika rsoika added the testing label Sep 10, 2017
@rsoika
Copy link
Member Author

rsoika commented Sep 10, 2017

I updated the docu too:

http://www.imixs.org/doc/modelling/howto.html

rsoika added a commit that referenced this issue Sep 12, 2017
@chrisw14
Copy link

Great! It works fine, thank you very much!

rsoika added a commit that referenced this issue Sep 14, 2017
@rsoika rsoika closed this as completed Oct 23, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants