From a94eee63fafba98f5aa5e8706ad4ab7b3f778172 Mon Sep 17 00:00:00 2001 From: Serhii_Nosko Date: Thu, 9 Nov 2023 15:25:16 +0200 Subject: [PATCH] MODFIN-283. More code formatting --- .../fiscalyear/FiscalYearService.java | 28 +++++++++---------- .../fund/FundCodeExpenseClassesService.java | 2 +- .../services/fund/FundDetailsService.java | 21 +++++++------- .../group/GroupFiscalYearTotalsService.java | 6 ++-- .../folio/services/group/GroupService.java | 2 +- 5 files changed, 30 insertions(+), 29 deletions(-) diff --git a/src/main/java/org/folio/services/fiscalyear/FiscalYearService.java b/src/main/java/org/folio/services/fiscalyear/FiscalYearService.java index e1de435c..35cc26c9 100644 --- a/src/main/java/org/folio/services/fiscalyear/FiscalYearService.java +++ b/src/main/java/org/folio/services/fiscalyear/FiscalYearService.java @@ -116,24 +116,24 @@ public Future deleteFiscalYear(String id, RequestContext requestContext) { public Future withFinancialSummary(FiscalYear fiscalYear, RequestContext requestContext) { String query = "fiscalYearId==" + fiscalYear.getId(); return budgetService.getBudgets(query, 0, Integer.MAX_VALUE, requestContext) - .map(budgetsCollection -> populateFinancialSummary(fiscalYear, budgetsCollection.getBudgets())); + .map(budgetsCollection -> populateFinancialSummary(fiscalYear, budgetsCollection.getBudgets())); } private FiscalYear populateFinancialSummary(FiscalYear fiscalYear, List budgets) { FinancialSummary financialSummary = new FinancialSummary() - .withAllocated(HelperUtils.calculateTotals(budgets, Budget::getAllocated)) - .withAvailable(HelperUtils.calculateTotals(budgets, Budget::getAvailable)) - .withUnavailable(HelperUtils.calculateTotals(budgets, Budget::getUnavailable)) - .withInitialAllocation(HelperUtils.calculateTotals(budgets, Budget::getInitialAllocation)) - .withAllocationTo(HelperUtils.calculateTotals(budgets, Budget::getAllocationTo)) - .withAllocationFrom(HelperUtils.calculateTotals(budgets, Budget::getAllocationFrom)) - .withAwaitingPayment(HelperUtils.calculateTotals(budgets, Budget::getAwaitingPayment)) - .withEncumbered(HelperUtils.calculateTotals(budgets, Budget::getEncumbered)) - .withExpenditures(HelperUtils.calculateTotals(budgets, Budget::getExpenditures)) - .withOverEncumbrance(HelperUtils.calculateTotals(budgets, Budget::getOverEncumbrance)) - .withOverExpended(HelperUtils.calculateTotals(budgets, Budget::getOverExpended)) - .withTotalFunding(HelperUtils.calculateTotals(budgets, Budget::getTotalFunding)) - .withCashBalance(HelperUtils.calculateTotals(budgets, Budget::getCashBalance)); + .withAllocated(HelperUtils.calculateTotals(budgets, Budget::getAllocated)) + .withAvailable(HelperUtils.calculateTotals(budgets, Budget::getAvailable)) + .withUnavailable(HelperUtils.calculateTotals(budgets, Budget::getUnavailable)) + .withInitialAllocation(HelperUtils.calculateTotals(budgets, Budget::getInitialAllocation)) + .withAllocationTo(HelperUtils.calculateTotals(budgets, Budget::getAllocationTo)) + .withAllocationFrom(HelperUtils.calculateTotals(budgets, Budget::getAllocationFrom)) + .withAwaitingPayment(HelperUtils.calculateTotals(budgets, Budget::getAwaitingPayment)) + .withEncumbered(HelperUtils.calculateTotals(budgets, Budget::getEncumbered)) + .withExpenditures(HelperUtils.calculateTotals(budgets, Budget::getExpenditures)) + .withOverEncumbrance(HelperUtils.calculateTotals(budgets, Budget::getOverEncumbrance)) + .withOverExpended(HelperUtils.calculateTotals(budgets, Budget::getOverExpended)) + .withTotalFunding(HelperUtils.calculateTotals(budgets, Budget::getTotalFunding)) + .withCashBalance(HelperUtils.calculateTotals(budgets, Budget::getCashBalance)); return fiscalYear.withFinancialSummary(financialSummary); } } diff --git a/src/main/java/org/folio/services/fund/FundCodeExpenseClassesService.java b/src/main/java/org/folio/services/fund/FundCodeExpenseClassesService.java index ef1db1d9..df850028 100644 --- a/src/main/java/org/folio/services/fund/FundCodeExpenseClassesService.java +++ b/src/main/java/org/folio/services/fund/FundCodeExpenseClassesService.java @@ -49,7 +49,7 @@ public FundCodeExpenseClassesService(BudgetService budgetService, BudgetExpenseC } public Future retrieveCombinationFundCodeExpClasses(String fiscalYearCode, - RequestContext requestContext) { + RequestContext requestContext) { FundCodeExpenseClassesHolder fundCodeExpenseClassesHolder = new FundCodeExpenseClassesHolder(); if (fiscalYearCode != null) { FiscalYear fiscalYearUnit = new FiscalYear(); diff --git a/src/main/java/org/folio/services/fund/FundDetailsService.java b/src/main/java/org/folio/services/fund/FundDetailsService.java index 727c922b..022fb3a8 100644 --- a/src/main/java/org/folio/services/fund/FundDetailsService.java +++ b/src/main/java/org/folio/services/fund/FundDetailsService.java @@ -54,11 +54,12 @@ public Future retrieveCurrentBudget(String fundId, String budgetStatus, RequestContext rqContext) { return retrieveCurrentBudget(fundId, budgetStatus, rqContext) .recover(t -> { - logger.error("Failed to retrieve current budget", t); + logger.error("Failed to retrieve current budget for fundId: {}", fundId, t); if (skipThrowException) { return Future.succeededFuture(); } else { - return Future.failedFuture(t); } + return Future.failedFuture(t); + } }); } @@ -99,14 +100,14 @@ public Future> retrieveExpenseClasses(String fundId, String f return retrieveBudget(fundId, fiscalYearId, null, rqContext) .compose(budget -> { - logger.debug("retrieveExpenseClasses:: budget id='{}' was found for fund id='{}': ",budget.getId(), fundId); - var expenseClasses = getExpenseClasses(budget, rqContext); - var budgetExpenseClassIds = getBudgetExpenseClassIds(budget.getId(), budgetStatus, rqContext); - - return GenericCompositeFuture.join(List.of(expenseClasses, budgetExpenseClassIds)) - .map(cf -> expenseClasses.result().stream() - .filter(expenseClass -> budgetExpenseClassIds.result().contains(expenseClass.getId())) - .collect(toList())); + logger.debug("retrieveExpenseClasses:: budget id='{}' was found for fund id='{}': ",budget.getId(), fundId); + var expenseClasses = getExpenseClasses(budget, rqContext); + var budgetExpenseClassIds = getBudgetExpenseClassIds(budget.getId(), budgetStatus, rqContext); + + return GenericCompositeFuture.join(List.of(expenseClasses, budgetExpenseClassIds)) + .map(cf -> expenseClasses.result().stream() + .filter(expenseClass -> budgetExpenseClassIds.result().contains(expenseClass.getId())) + .collect(toList())); }) .onSuccess(expenseClasses -> logger.debug("retrieveExpenseClasses:: found expense classes for fund id='{}', size={} ", fundId, expenseClasses.size())) .onFailure(t -> logger.error("Retrieve expense classes for fund id='{}' failed", fundId, t)); diff --git a/src/main/java/org/folio/services/group/GroupFiscalYearTotalsService.java b/src/main/java/org/folio/services/group/GroupFiscalYearTotalsService.java index 3ee27966..ce145c67 100644 --- a/src/main/java/org/folio/services/group/GroupFiscalYearTotalsService.java +++ b/src/main/java/org/folio/services/group/GroupFiscalYearTotalsService.java @@ -62,12 +62,12 @@ public Future getGroupFiscalYearSummaries(Stri return restClient.get(requestEntry.buildEndpoint(), BudgetsCollection.class, requestContext) .compose(budgetsCollection -> groupFundFiscalYearService.getGroupFundFiscalYears(query, 0, Integer.MAX_VALUE, requestContext) - .map(groupFundFiscalYearCollection -> { + .map(groupFundFiscalYearsCollection -> { Map>> fundIdFiscalYearIdBudgetsMap = budgetsCollection.getBudgets() .stream() .collect(groupingBy(Budget::getFundId, groupingBy(Budget::getFiscalYearId, toList()))); - List summaries = groupSummariesByGroupIdAndFiscalYearId(groupFundFiscalYearCollection, fundIdFiscalYearIdBudgetsMap) + List summaries = groupSummariesByGroupIdAndFiscalYearId(groupFundFiscalYearsCollection, fundIdFiscalYearIdBudgetsMap) .values().stream() .flatMap(summary -> summary.values().stream()) .filter(Optional::isPresent) @@ -78,7 +78,7 @@ public Future getGroupFiscalYearSummaries(Stri .withGroupFiscalYearSummaries(summaries) .withTotalRecords(summaries.size()); - return buildHolderSkeletons(fundIdFiscalYearIdBudgetsMap, collection, groupFundFiscalYearCollection); + return buildHolderSkeletons(fundIdFiscalYearIdBudgetsMap, collection, groupFundFiscalYearsCollection); })) .compose(holders -> updateHoldersWithAllocations(holders, requestContext) .map(holder -> { diff --git a/src/main/java/org/folio/services/group/GroupService.java b/src/main/java/org/folio/services/group/GroupService.java index c1d6f037..421a4593 100644 --- a/src/main/java/org/folio/services/group/GroupService.java +++ b/src/main/java/org/folio/services/group/GroupService.java @@ -40,7 +40,7 @@ public Future createGroup(Group group, RequestContext requestContext) { return restClient.post(resourcesPath(GROUPS), group, Group.class, requestContext); } - public Future getGroups(int limit, int offset, String query, RequestContext requestContext) { + public Future getGroups(int offset, int limit, String query, RequestContext requestContext) { var requestEntry = new RequestEntry(resourcesPath(GROUPS)) .withOffset(offset) .withLimit(limit)