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

#192 Support for expressions in BPMN gateways #246

Merged
merged 7 commits into from
Jun 1, 2023

Conversation

tjololo
Copy link
Member

@tjololo tjololo commented May 30, 2023

Description

Support for expressions in process gateways.
This extends the expression code with a function for getting the action performed in the task leading up to the gateway.
By default the dataModel in the expression context is set to the task before the gateway, but it is possible to override what DataType the expression context should be connected to in a gateway by setting connectedDataTypeId in the extensionelements in the BPMN file.

This fixes #192

Related Issue(s)

Verification

  • Your code builds clean without any errors or warnings
  • Manual testing done (required)
  • Relevant automated test added (if you find this hard, leave it and we'll help out)
  • All tests run green

Documentation

  • User documentation is updated with a separate linked PR in altinn-studio-docs. (if applicable)

Comment on lines +123 to +130
catch (Exception e)
{
using var jsonDocument = JsonDocument.Parse(data);

testCase.Name = jsonDocument.RootElement.GetProperty("name").GetString();
testCase.ExpectsFailure = jsonDocument.RootElement.TryGetProperty("expectsFailure", out var expectsFailure) ? expectsFailure.GetString() : null;
testCase.ParsingException = e;
}

Check notice

Code scanning / CodeQL

Generic catch clause

Generic catch clause.
Comment on lines +69 to +75
if(outgoingFlows.Any(a => a.ConditionExpression != null))
{
gatewayFilter = _gatewayFactory.GetProcessExclusiveGateway("AltinnExpressionsExclusiveGateway");
} else
{
gatewayFilter = _gatewayFactory.GetProcessExclusiveGateway(directFlowTarget.Id);
}

Check notice

Code scanning / CodeQL

Missed ternary opportunity

Both branches of this 'if' statement write to the same variable - consider using '?' to express intent better.
@tjololo tjololo marked this pull request as ready for review May 30, 2023 10:06
return layoutSet;
}

private async Task<(string? DataTypeId, Type? DataTypeClassType)> GetDataType(Instance instance, LayoutSet? layoutSet, string? dataTypeId)
Copy link
Member

Choose a reason for hiding this comment

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

This logic seems to belong elsewhere, but we're perhaps missing the natural place to place it. Unless we use similar methods in other parts of the code we should make a note of it and figure out where it should be until next time.

Copy link
Member Author

Choose a reason for hiding this comment

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

Couldn't find a natural home, I will add a TODO comment stating that we should find a home for it

Copy link
Member

@RonnyB71 RonnyB71 left a comment

Choose a reason for hiding this comment

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

🕹️

@sonarqubecloud
Copy link

sonarqubecloud bot commented Jun 1, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 14 Code Smells

90.2% 90.2% Coverage
0.0% 0.0% Duplication

@tjololo tjololo merged commit 775006a into v8 Jun 1, 2023
@tjololo tjololo deleted the feature/192-improved-gateways branch June 1, 2023 11:47
tjololo added a commit that referenced this pull request Jun 1, 2023
* Working gateway filter leveraging expressions to make decisions

* remove logger

* Add tests for expressions function gatewayAction

* move test out of shared tests as it is only supported backend (no process in frontend)

* Add tests and small refactoring

* Fix code smells

* Fixes after review
@tjololo tjololo added the feature Label Pull requests with new features. Used when generation releasenotes label Jun 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Label Pull requests with new features. Used when generation releasenotes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants