Skip to content

added definition variable container to support EL Resolvers to use th…#4169

Open
WelschChristopher wants to merge 2 commits intoflowable:mainfrom
WelschChristopher:added-definition-variable-container
Open

added definition variable container to support EL Resolvers to use th…#4169
WelschChristopher wants to merge 2 commits intoflowable:mainfrom
WelschChristopher:added-definition-variable-container

Conversation

@WelschChristopher
Copy link
Contributor

…e definition if no VariableScope is available (during deployment)

Check List:

  • Unit tests: YES / NO / NA
  • Documentation: YES / NO / NA

…e definition if no VariableScope is available (during deployment)
*
* @author Christopher Welsch
*/
public class DefinitionVariableContainer implements VariableContainer {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not be in the flowable-engine-common-api module. Instead it should be part of the flowable-engine-common module in org.flowable.common.engine.impl.el. Additionally, I think that it'll also be good if we can pass the definitionKey to the container as well.

Comment on lines +33 to +34
public DefinitionVariableContainer() {
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this needed?

/**
* Determines signal name from definition or expression
*/
public static String determineSignalName(CommandContext commandContext, SignalEventDefinition signalEventDefinition, BpmnModel bpmnModel,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't we change the existing determiniSignalName to take in VariableContainer instead of the DelegateExecution?

/**
* Determines message name from definition or expression
*/
public static String determineMessageName(CommandContext commandContext, MessageEventDefinition messageEventDefinition,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't we change the existing determineMessageName to take VariableContainer instead of DelegateExecution?

Comment on lines -76 to -79
VariableScope scopeForExpression = executionEntity;
if (scopeForExpression == null) {
scopeForExpression = NoExecutionVariableScope.getSharedInstance();
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment above this should also be removed I think

*
* @author Christopher Welsch
*/
public class StartEventExpressionWithDefinitionContainerTest extends PluggableFlowableTestCase {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be good if we can have some test cases that use something like ${variableContainer.scopeType} and / or ${variableContainer.definitionKey}. I believe that some of the tests cases like the ones that only use static strings would pass even without the newly added logic.

/**
* @author Christopher Welsch
*/
class DefinitionVariableContainerTest {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not see the value in this test. Most of the things should be implicitly tested in StartEventExpressionWithDefinitionContainerTest by validating the tenant id, definition id, etc. on the jobs.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't see the expression that is being used here? From what I can see it is using a static timeDuration. You could do something like ${variableContainer.definitionKey == 'timerExpressionProcess' ? 'PT1H' : 'PT2H'} or something in that area

* Takes in a {@link DefinitionVariableContainer} for expression evaluation at deployment time (eg Timer start event).
*/
public static TimerJobEntity createTimerEntityForTimerEventDefinition(TimerEventDefinition timerEventDefinition,
FlowElement currentFlowElement, boolean isInterruptingTimer, DefinitionVariableContainer definitionVariableContainer,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can slightly improve this by passing the ProcessDefinition instead of the DefinitionVariableContainer and remove the instantiation of the container on the caller side and also the setting of the definition and tenant id on the caller side.

assertThat(instances).hasSize(1);

} finally {
processEngineConfiguration.resetClock();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is obsolete since our test harness resets it automatically.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants