add back in support for associations parameter as per the documentation.
This commit is contained in:
@@ -99,8 +99,7 @@ public class LoansApiResource {
|
|||||||
"repaymentFrequencyType", "interestRateFrequencyType", "amortizationType", "interestType", "interestCalculationPeriodType",
|
"repaymentFrequencyType", "interestRateFrequencyType", "amortizationType", "interestType", "interestCalculationPeriodType",
|
||||||
"submittedOnDate", "approvedOnDate", "expectedDisbursementDate", "actualDisbursementDate",
|
"submittedOnDate", "approvedOnDate", "expectedDisbursementDate", "actualDisbursementDate",
|
||||||
"expectedFirstRepaymentOnDate", "interestChargedFromDate", "closedOnDate", "expectedMaturityDate",
|
"expectedFirstRepaymentOnDate", "interestChargedFromDate", "closedOnDate", "expectedMaturityDate",
|
||||||
"lifeCycleStatusId", "lifeCycleStatusText", "lifeCycleStatusDate",
|
"lifeCycleStatusId", "lifeCycleStatusText", "lifeCycleStatusDate")
|
||||||
"summary", "repaymentSchedule", "loanRepayments", "permissions", "convenienceData")
|
|
||||||
);
|
);
|
||||||
|
|
||||||
Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters());
|
Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters());
|
||||||
@@ -110,15 +109,28 @@ public class LoansApiResource {
|
|||||||
boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters());
|
boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters());
|
||||||
|
|
||||||
LoanBasicDetailsData loanBasicDetails = this.loanReadPlatformService.retrieveLoanAccountDetails(loanId);
|
LoanBasicDetailsData loanBasicDetails = this.loanReadPlatformService.retrieveLoanAccountDetails(loanId);
|
||||||
|
|
||||||
|
Collection<LoanRepaymentTransactionData> loanRepayments = null;
|
||||||
|
Collection<LoanRepaymentPeriodData> repaymentSchedule = null;
|
||||||
|
LoanAccountSummaryData summary = null;
|
||||||
|
LoanPermissionData permissions = null;
|
||||||
|
|
||||||
|
Set<String> associationParameters = ApiParameterHelper.extractAssociationsForResponseIfProvided(uriInfo.getQueryParameters());
|
||||||
|
if (!associationParameters.isEmpty()) {
|
||||||
|
if (associationParameters.contains("all")) {
|
||||||
|
responseParameters.addAll(Arrays.asList("summary", "repaymentSchedule", "loanRepayments", "permissions", "convenienceData"));
|
||||||
|
} else {
|
||||||
|
responseParameters.addAll(associationParameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
loanRepayments = this.loanReadPlatformService.retrieveLoanPayments(loanId);
|
||||||
|
repaymentSchedule = this.loanReadPlatformService.retrieveRepaymentSchedule(loanId);
|
||||||
|
|
||||||
Collection<LoanRepaymentTransactionData> loanRepayments = this.loanReadPlatformService.retrieveLoanPayments(loanId);
|
summary = this.loanReadPlatformService.retrieveSummary(loanBasicDetails.getPrincipal(), repaymentSchedule, loanRepayments);
|
||||||
Collection<LoanRepaymentPeriodData> repaymentSchedule = this.loanReadPlatformService.retrieveRepaymentSchedule(loanId);
|
|
||||||
|
|
||||||
LoanAccountSummaryData summary = this.loanReadPlatformService.retrieveSummary(loanBasicDetails.getPrincipal(), repaymentSchedule, loanRepayments);
|
boolean isWaiveAllowed = summary.isWaiveAllowed(loanBasicDetails.getInArrearsTolerance());
|
||||||
|
permissions = this.loanReadPlatformService.retrieveLoanPermissions(loanBasicDetails, isWaiveAllowed, loanRepayments.size());
|
||||||
LoanPermissionData permissions = this.loanReadPlatformService.retrieveLoanPermissions(loanBasicDetails,
|
}
|
||||||
summary.isWaiveAllowed(loanBasicDetails.getInArrearsTolerance()),
|
|
||||||
loanRepayments.size());
|
|
||||||
|
|
||||||
LoanAccountData loanAccount = new LoanAccountData(loanBasicDetails, summary, repaymentSchedule, loanRepayments, permissions);
|
LoanAccountData loanAccount = new LoanAccountData(loanBasicDetails, summary, repaymentSchedule, loanRepayments, permissions);
|
||||||
|
|
||||||
|
|||||||
+13
-1
@@ -22,6 +22,18 @@ public class ApiParameterHelper {
|
|||||||
return fields;
|
return fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Set<String> extractAssociationsForResponseIfProvided(final MultivaluedMap<String, String> queryParams) {
|
||||||
|
Set<String> fields = new HashSet<String>();
|
||||||
|
String commaSerperatedParameters = "";
|
||||||
|
if (queryParams.getFirst("associations") != null) {
|
||||||
|
commaSerperatedParameters = queryParams.getFirst("associations");
|
||||||
|
if (StringUtils.isNotBlank(commaSerperatedParameters)) {
|
||||||
|
fields = new HashSet<String>(Arrays.asList(commaSerperatedParameters.split("\\s*,\\s*")));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return fields;
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean prettyPrint(final MultivaluedMap<String, String> queryParams) {
|
public static boolean prettyPrint(final MultivaluedMap<String, String> queryParams) {
|
||||||
boolean prettyPrint = false;
|
boolean prettyPrint = false;
|
||||||
if (queryParams.getFirst("pretty") != null) {
|
if (queryParams.getFirst("pretty") != null) {
|
||||||
@@ -39,4 +51,4 @@ public class ApiParameterHelper {
|
|||||||
}
|
}
|
||||||
return template;
|
return template;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user