Skip to content

Commit

Permalink
Merge pull request #460 from Backbase/feature/product_ingestion_funct…
Browse files Browse the repository at this point in the history
…ion_group_optimization

Performance improvement on function groups setup for ProductIngestionSaga
  • Loading branch information
pssm authored Sep 12, 2024
2 parents c8d5a4b + cdd1102 commit 6b3393e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Changelog
All notable changes to this project will be documented in this file.

## [4.1.7](https://github.com/Backbase/stream-services/compare/4.1.4...4.1.6)
### Changed.
- Performance improvement on function groups setup for ProductIngestionSaga

## [4.1.6](https://github.com/Backbase/stream-services/compare/4.1.4...4.1.6)
### Fix
- Fix arrangements being retrieved per payment order instead of once per payment order ingestion request.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import static java.util.Comparator.naturalOrder;
import static java.util.Comparator.nullsFirst;

import com.backbase.dbs.accesscontrol.api.service.v3.model.FunctionGroupItem;
import com.backbase.dbs.arrangement.api.service.v2.model.AccountArrangementItemPost;
import com.backbase.stream.legalentity.model.BaseProduct;
import com.backbase.stream.legalentity.model.BaseProductGroup;
Expand Down Expand Up @@ -320,9 +321,11 @@ protected Mono<BatchProductGroupTask> setupBusinessFunctionsAndPermissionsBatch(

protected Mono<List<BusinessFunctionGroup>> setupBusinessFunctions(BatchProductGroupTask streamTask, ServiceAgreement serviceAgreement, List<JobProfileUser> jobProfileUsers) {
streamTask.info(FUNCTION_GROUP, "setup-business-functions", "", serviceAgreement.getExternalId(), null, "Setting up Business Functions for Users: %s", prettyPrintUsers(jobProfileUsers));
final Mono<List<FunctionGroupItem>> functionGroup = accessGroupService.getFunctionGroupsForServiceAgreement(serviceAgreement.getInternalId()).cache();

return Flux.fromIterable(jobProfileUsers)
.doOnNext(user -> log.info("Setup Business Function for: {} with Product Groups: {}",user.getUser().getExternalId(), prettyPrintProductGroups(streamTask)))
.flatMap(jobProfileUser -> getBusinessFunctionGroups(jobProfileUser, serviceAgreement)
.flatMap(jobProfileUser -> getBusinessFunctionGroups(jobProfileUser, functionGroup)
.map(bfGroups -> {
jobProfileUser.setBusinessFunctionGroups(bfGroups);
return bfGroups;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,16 +142,18 @@ private Mono<JobProfileUser> setupBusinessFunctions(StreamTask streamTask, Servi
streamTask
.info(FUNCTION_GROUP, "setup-business-functions", "", "", null, "Setting up Business Functions User: %s",
jobProfileUser.getUser().getExternalId());
return getBusinessFunctionGroups(jobProfileUser, serviceAgreement)
final Mono<List<FunctionGroupItem>> functionGroup = accessGroupService.getFunctionGroupsForServiceAgreement(serviceAgreement.getInternalId()).cache();
return getBusinessFunctionGroups(jobProfileUser, functionGroup)
.flatMap(businessFunctionGroups -> accessGroupService.setupFunctionGroups(streamTask, serviceAgreement, businessFunctionGroups))
.map(jobProfileUser::businessFunctionGroups);
}

protected Mono<List<BusinessFunctionGroup>> getBusinessFunctionGroups(JobProfileUser jobProfileUser, ServiceAgreement serviceAgreement) {
protected Mono<List<BusinessFunctionGroup>> getBusinessFunctionGroups(JobProfileUser jobProfileUser,
Mono<List<FunctionGroupItem>> functionGroup) {

List<BusinessFunctionGroup> businessFunctionGroups = jobProfileUser.getBusinessFunctionGroups();
if (!isEmpty(jobProfileUser.getReferenceJobRoleNames())) {
return accessGroupService.getFunctionGroupsForServiceAgreement(serviceAgreement.getInternalId())
return functionGroup
.map(functionGroups -> {
Map<String, FunctionGroupItem> idByFunctionGroupName = functionGroups
.stream()
Expand Down

0 comments on commit 6b3393e

Please sign in to comment.