Skip to content

Commit

Permalink
MODFIN-283. More code formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
SerhiiNosko committed Nov 9, 2023
1 parent d4683af commit a94eee6
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 29 deletions.
28 changes: 14 additions & 14 deletions src/main/java/org/folio/services/fiscalyear/FiscalYearService.java
Original file line number Diff line number Diff line change
Expand Up @@ -116,24 +116,24 @@ public Future<Void> deleteFiscalYear(String id, RequestContext requestContext) {
public Future<FiscalYear> 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<Budget> 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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public FundCodeExpenseClassesService(BudgetService budgetService, BudgetExpenseC
}

public Future<FundCodeExpenseClassesCollection> retrieveCombinationFundCodeExpClasses(String fiscalYearCode,
RequestContext requestContext) {
RequestContext requestContext) {
FundCodeExpenseClassesHolder fundCodeExpenseClassesHolder = new FundCodeExpenseClassesHolder();
if (fiscalYearCode != null) {
FiscalYear fiscalYearUnit = new FiscalYear();
Expand Down
21 changes: 11 additions & 10 deletions src/main/java/org/folio/services/fund/FundDetailsService.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,12 @@ public Future<Budget> 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);
}
});
}

Expand Down Expand Up @@ -99,14 +100,14 @@ public Future<List<ExpenseClass>> 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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@ public Future<GroupFiscalYearSummaryCollection> 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<String, Map<String, List<Budget>>> fundIdFiscalYearIdBudgetsMap = budgetsCollection.getBudgets()
.stream()
.collect(groupingBy(Budget::getFundId, groupingBy(Budget::getFiscalYearId, toList())));

List<GroupFiscalYearSummary> summaries = groupSummariesByGroupIdAndFiscalYearId(groupFundFiscalYearCollection, fundIdFiscalYearIdBudgetsMap)
List<GroupFiscalYearSummary> summaries = groupSummariesByGroupIdAndFiscalYearId(groupFundFiscalYearsCollection, fundIdFiscalYearIdBudgetsMap)
.values().stream()
.flatMap(summary -> summary.values().stream())
.filter(Optional::isPresent)
Expand All @@ -78,7 +78,7 @@ public Future<GroupFiscalYearSummaryCollection> getGroupFiscalYearSummaries(Stri
.withGroupFiscalYearSummaries(summaries)
.withTotalRecords(summaries.size());

return buildHolderSkeletons(fundIdFiscalYearIdBudgetsMap, collection, groupFundFiscalYearCollection);
return buildHolderSkeletons(fundIdFiscalYearIdBudgetsMap, collection, groupFundFiscalYearsCollection);
}))
.compose(holders -> updateHoldersWithAllocations(holders, requestContext)
.map(holder -> {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/folio/services/group/GroupService.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public Future<Group> createGroup(Group group, RequestContext requestContext) {
return restClient.post(resourcesPath(GROUPS), group, Group.class, requestContext);
}

public Future<GroupCollection> getGroups(int limit, int offset, String query, RequestContext requestContext) {
public Future<GroupCollection> getGroups(int offset, int limit, String query, RequestContext requestContext) {
var requestEntry = new RequestEntry(resourcesPath(GROUPS))
.withOffset(offset)
.withLimit(limit)
Expand Down

0 comments on commit a94eee6

Please sign in to comment.