flowable / flowable-engine

A compact and highly efficient workflow and Business Process Management (BPM) platform for developers, system admins and business users.
https://www.flowable.org
Apache License 2.0
8.01k stars 2.63k forks source link

#3884 Expression language support for conditional sequence flow and conditional events #3889

Closed rasmusfaber closed 1 month ago

rasmusfaber commented 6 months ago

This fixes #3884 by adding support for other expression languages as specified by the language tag in the FormalExpression, i.e.

   <sequenceFlow id="flow">
      <conditionExpression xsi:type="tFormalExpression" language="groovy">
          customer.addresses.any { it.country == 'US' }
      </conditionExpression>
    </sequenceFlow>

Check List:

filiphr commented 3 months ago

@rasmusfaber thanks for the PR can you looked into org.flowable.engine.impl.Condition, org.flowable.engine.impl.scripting.ScriptCondition and org.flowable.engine.impl.el.UelExpressionCondition? I think that what you are looking for fits more into using ScriptCondition instead of the UelExpressionCondition.

With that approach we won't need the ScriptEngineExpression and we won't need to get the process engine configuration in the way we are doing it now.

rasmusfaber commented 3 months ago

@rasmusfaber thanks for the PR can you looked into org.flowable.engine.impl.Condition, org.flowable.engine.impl.scripting.ScriptCondition and org.flowable.engine.impl.el.UelExpressionCondition?

@filiphr Oh, yes. That was much cleaner. Thank you. I have updated the PR.

filiphr commented 3 months ago

Thanks @rasmusfaber.

I see now that you did some changes in the ScriptCondition. I would instead prefer to have a new method in the ConditionUtil and create a Condition from there. If the language is null or empty then we create the UelExpressionCondition otherwise we create a ScriptCondition. The ScriptCondition should not behave like a UelExpressionCondition if there is no language

rasmusfaber commented 3 months ago

I would instead prefer to have a new method in the ConditionUtil and create a Condition from there.

@filiphr Sure. How is this? I also renamed the sequenceFlowId parameter to elementId, since it could now also be the id of an event.

filiphr commented 3 months ago

Looks good, thanks @rasmusfaber