From 8dc8dcad522299bca9d3cae37ce9c9aee6e08025 Mon Sep 17 00:00:00 2001 From: Keith Woodlock Date: Mon, 24 Dec 2012 13:57:30 +0000 Subject: [PATCH] update api-docs around client and client account summary. --- api-docs/apiLive.htm | 116 +++---- .../client/api/ClientsApiResource.java | 14 +- .../ClientAccountSummaryCollectionData.java | 303 ++++++++---------- .../client/data/ClientAccountSummaryData.java | 25 +- .../portfolio/client/data/ClientData.java | 4 +- .../ClientReadPlatformServiceImpl.java | 14 +- 6 files changed, 226 insertions(+), 250 deletions(-) diff --git a/api-docs/apiLive.htm b/api-docs/apiLive.htm index 9851d3db0..161284049 100644 --- a/api-docs/apiLive.htm +++ b/api-docs/apiLive.htm @@ -513,7 +513,7 @@ var jqxhr = $.ajax({ "firstname" : "Patrick", "lastname" : "Asare-Frimpong", "displayName" : "Patrick Asare-Frimpong", - "externalId" : null, + "externalId" : "123AB", "joinedDate" : [ 2012, 4, 18 ] }, { "officeId" : 5, @@ -522,7 +522,6 @@ var jqxhr = $.ajax({ "firstname" : "firstMajmoua", "lastname" : "client", "displayName" : "firstMajmoua client", - "externalId" : null, "joinedDate" : [ 2011, 12, 1 ] }... ] @@ -589,7 +588,6 @@ var jqxhr = $.ajax({ "firstname" : "Patrick", "lastname" : "O'Meara", "displayName" : "Patrick O'Meara", - "externalId" : null, "joinedDate" : [ 2009, 1, 4 ] } @@ -602,12 +600,11 @@ var jqxhr = $.ajax({

Create a Client

Note: You can enter either:
firstname/lastname - for a person OR
- clientOrBusinessName - for a business or organisation (or person known by one name).

- If you use clientOrBusinessName, the value is placed in the lastname field when you retrieve clients. + clientOrBusinessName - for a business or organisation (or person known by one name).

- +
Mandatory Fields
firstname and lastname OR clientOrBusinessName
, joiningDate, officeId
firstname and lastname OR clientOrBusinessName
, joinedDate, officeId
@@ -620,8 +617,9 @@ Request Body: "firstname": "Petra", "lastname": "Yton", "externalId": "786YYH7", - "dateFormat": "dd MMMM yyyy", - "joiningDate": "04 March 2009" + "dateFormat": "dd MMMM yyyy", + "locale": "en", + "joinedDate": "04 March 2009" } @@ -639,7 +637,8 @@ Request Body: "clientOrBusinessName": "New Business to Create", "externalId": "one/78", "dateFormat": "dd MMMM yyyy", - "joiningDate": "13 June 2006" + "locale": "en", + "joinedDate": "13 June 2006" } @@ -663,7 +662,8 @@ Request Body: { "externalId": "786444UUUYYH7", "dateFormat": "dd MMMM yyyy", - "joiningDate": "09 June 2006" + "locale": "en", + "joinedDate": "09 June 2006" } { "resourceId": 23} @@ -682,44 +682,48 @@ Request Body:

Example Requests:

clients/1/loans


-
clients/1/loans?fields=openLoans,%20closedLoans,activeLoanCount
+
clients/1/loans?fields=openLoans,closedLoans,activeLoanCount
GET https://Domain Name/api/v1/clients/{clientId}/loans { - "pendingApprovalLoans" : [ ], - "awaitingDisbursalLoans" : [ { - "id" : 17, - "externalId" : null, - "loanProductId" : 1, - "loanProductName" : "Agricultural Loan", - "loanStatusId" : 200, - "pendingApproval" : false, - "waitingForDisbursal" : true, - "open" : false, - "closed" : false, - "lifeCycleStatusText" : "Approved", - "lifeCycleStatusDate" : null - } ], - "openLoans" : [ ], - "closedLoans" : [ { - "id" : 1, - "externalId" : null, - "loanProductId" : 1, - "loanProductName" : "Agricultural Loan", - "loanStatusId" : 600, - "pendingApproval" : false, - "waitingForDisbursal" : false, - "open" : false, - "closed" : true, - "lifeCycleStatusText" : "Closed", - "lifeCycleStatusDate" : null - } ], - "anyLoanCount" : 2, - "pendingApprovalLoanCount" : 0, - "awaitingDisbursalLoanCount" : 1, - "activeLoanCount" : 0, - "closedLoanCount" : 1 + "anyLoanCount": 3, + "activeLoanCount": 2, + "openLoans": [ + { + "id": 22, + "productId": 1, + "productName": "Agricultural Loan", + "status": { + "id": 300, + "code": "loanStatusType.active", + "value": "Active" + } + }, + { + "id": 44, + "productId": 1, + "productName": "Agricultural Loan", + "status": { + "id": 300, + "code": "loanStatusType.active", + "value": "Active" + } + } + ], + "closedLoanCount": 1, + "closedLoans": [ + { + "id": 33, + "productId": 1, + "productName": "Agricultural Loan", + "status": { + "id": 601, + "code": "loanStatusType.closed.written.off", + "value": "Closed (written off)" + } + } + ] }
@@ -743,8 +747,6 @@ Request Body: [ { "id" : 20, "clientId" : 2, - "loanId" : null, - "loanTransactionId" : null, "noteType" : { "id" : 100, "code" : "noteType.client", @@ -760,8 +762,6 @@ Request Body: }, { "id" : 16, "clientId" : 2, - "loanId" : null, - "loanTransactionId" : null, "noteType" : { "id" : 100, "code" : "noteType.client", @@ -814,8 +814,6 @@ Request Body: { "id" : 20, "clientId" : 2, - "loanId" : null, - "loanTransactionId" : null, "noteType" : { "id" : 100, "code" : "noteType.client", @@ -1422,8 +1420,6 @@ Request Body: { "id" : 10, "date" : [ 2009, 1, 29 ], - "principal" : null, - "interest" : null, "total" : { "currencyCode" : "XOF", "digitsAfterDecimal" : 0, @@ -1435,8 +1431,6 @@ Request Body: "greaterThanZero" : true, "displaySymbolValue" : "300000 CFA" }, - "totalWaived" : null, - "overpaid" : null, "transactionOffsetFromToday" : -1218 } @@ -1514,13 +1508,10 @@ Request Body: "name" : "Demo MFI Head Office", "externalId" : "1", "openingDate" : [ 2009, 1, 1 ], - "hierarchy" : ".", - "parentName" : null, - "parentId" : null + "hierarchy" : "." }, { "id" : 2, "name" : "B1", - "externalId" : null, "openingDate" : [ 2012, 4, 1 ], "hierarchy" : ".2.", "parentName" : "Demo MFI Head Office", @@ -1528,7 +1519,6 @@ Request Body: }, { "id" : 3, "name" : "B2", - "externalId" : null, "openingDate" : [ 2012, 4, 4 ], "hierarchy" : ".3.", "parentName" : "Demo MFI Head Office", @@ -1588,9 +1578,7 @@ Request Body: "name" : "Demo MFI Head Office", "externalId" : "1", "openingDate" : [ 2009, 1, 1 ], - "hierarchy" : ".", - "parentName" : null, - "parentId" : null + "hierarchy" : "." } @@ -1775,7 +1763,6 @@ Request Body: }, { "id" : 2, "name" : "Brunei Loan", - "description" : null, "principal" : { "currencyCode" : "BND", "digitsAfterDecimal" : 2, @@ -2169,7 +2156,6 @@ Request Body: "code" : "ETB", "name" : "Ethiopian Birr", "decimalPlaces" : 2, - "displaySymbol" : null, "nameCode" : "currency.ETB", "displayLabel" : "Ethiopian Birr [ETB]" } ], @@ -2177,14 +2163,12 @@ Request Body: "code" : "AED", "name" : "UAE Dirham", "decimalPlaces" : 2, - "displaySymbol" : null, "nameCode" : "currency.AED", "displayLabel" : "UAE Dirham [AED]" }, { "code" : "AFN", "name" : "Afghanistan Afghani", "decimalPlaces" : 2, - "displaySymbol" : null, "nameCode" : "currency.AFN", "displayLabel" : "Afghanistan Afghani [AFN]" }, ... diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/api/ClientsApiResource.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/api/ClientsApiResource.java index acf67c803..664596e76 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/api/ClientsApiResource.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/api/ClientsApiResource.java @@ -254,11 +254,15 @@ public class ClientsApiResource { final Set CLIENT_ACCOUNTS_DATA_PARAMETERS = new HashSet(Arrays.asList("pendingApprovalLoans", "awaitingDisbursalLoans", "openLoans", "closedLoans", "anyLoanCount", "pendingApprovalLoanCount", - "awaitingDisbursalLoanCount", "activeLoanCount", "closedLoanCount", "pendingApprovalDespositAccountsCount", - "pendingApprovalDespositAccounts", "approvedDespositAccountsCount", "approvedDespositAccounts", - "withdrawnByClientDespositAccountsCount", "withdrawnByClientDespositAccounts", "closedDepositAccountsCount", - "closedDepositAccounts", "rejectedDepositAccountsCount", "rejectedDepositAccounts", "preclosedDepositAccountsCount", - "preclosedDepositAccounts")); + "awaitingDisbursalLoanCount", "activeLoanCount", "closedLoanCount", "pendingApprovalDepositAccountsCount", + "pendingApprovalDepositAccounts", "approvedDepositAccountsCount", "approvedDepositAccounts", + "withdrawnByClientDepositAccountsCount", "withdrawnByClientDepositAccounts", "closedDepositAccountsCount", + "closedDepositAccounts", "maturedDepositAccountsCount", "maturedDepositAccounts", "rejectedDepositAccountsCount", + "rejectedDepositAccounts", "preclosedDepositAccountsCount", "preclosedDepositAccounts", + + "pendingApprovalSavingAccountsCount", "pendingApprovalSavingAccounts", "approvedSavingAccountsCount", + "approvedSavingAccounts", "withdrawnByClientSavingAccountsCount", "withdrawnByClientSavingAccounts", + "rejectedSavingAccountsCount", "rejectedSavingAccounts", "closedSavingAccountsCount", "closedSavingAccounts")); final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper.process(uriInfo.getQueryParameters()); return this.clientAccountSummaryToApiJsonSerializer.serialize(settings, clientAccount, CLIENT_ACCOUNTS_DATA_PARAMETERS); diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/data/ClientAccountSummaryCollectionData.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/data/ClientAccountSummaryCollectionData.java index daa140f72..ebd2010ba 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/data/ClientAccountSummaryCollectionData.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/data/ClientAccountSummaryCollectionData.java @@ -1,189 +1,152 @@ package org.mifosplatform.portfolio.client.data; -import java.util.List; +import java.util.Collection; /** - * Immutable data object representing a summary of a clients various accounts. + * Immutable data object representing a summary of a clients various accounts. */ public class ClientAccountSummaryCollectionData { - private final int anyLoanCount; - private final int pendingApprovalLoanCount; - private final List pendingApprovalLoans; - private final int awaitingDisbursalLoanCount; - private final List awaitingDisbursalLoans; - private final int activeLoanCount; - private final List openLoans; - private final int closedLoanCount; - private final List closedLoans; - private final int pendingApprovalDespositAccountsCount; - private final List pendingApprovalDepositAccounts; - private final int approvedDespositAccountsCount; - private final List approvedDepositAccounts; - private final int withdrawnByClientDespositAccountsCount; - private final List withdrawnByClientDespositAccounts; - private final int closedDepositAccountsCount; - private final List closedDepositAccounts; - private final int rejectedDepositAccountsCount; - private final List rejectedDepositAccounts; - private final int preclosedDepositAccountsCount; - private final List preclosedDepositAccounts; - private final int maturedDepositAccountsCount; - private final List maturedDepositAccounts; - private final int pendingApprovalSavingAccountsCount; - private final List pendingApprovalSavingAccounts; - private final int approvedSavingAccountsCount; - private final List approvedSavingAccounts; - private final int withdrawnByClientSavingAccountsCount; - private final List withdrawnByClientSavingAccounts; - private final int rejectedSavingAccountsCount; - private final List rejectedSavingAccounts; - private final int closedSavingAccountsCount; - private final List closedSavingAccounts; - - public ClientAccountSummaryCollectionData( - final List pendingApprovalLoans, - final List awaitingDisbursalLoans, - final List openLoans, - final List closedLoans, - final List pendingApprovalDepositAccounts, - final List approvedDepositAccounts, - final List withdrawnByClientDespositAccounts, - final List rejectedDepositAccounts, - final List closedDepositAccounts, - final List preclosedDepositAccounts, - final List maturedDepositAccounts, - final List pendingApprovalSavingAccounts, - final List approvedSavingAccounts, - final List withdrawnByClientSavingAccounts, - final List rejectedSavingAccounts, - final List closedSavingAccounts) { - this.pendingApprovalLoans = pendingApprovalLoans; - this.awaitingDisbursalLoans = awaitingDisbursalLoans; - this.openLoans = openLoans; - this.closedLoans = closedLoans; - this.pendingApprovalDepositAccounts = pendingApprovalDepositAccounts; - this.approvedDepositAccounts = approvedDepositAccounts; - this.withdrawnByClientDespositAccounts = withdrawnByClientDespositAccounts; - this.closedDepositAccounts = closedDepositAccounts; - this.rejectedDepositAccounts = rejectedDepositAccounts; - this.preclosedDepositAccounts = preclosedDepositAccounts; - this.maturedDepositAccounts = maturedDepositAccounts; - - // saving accounts - this.pendingApprovalSavingAccounts = pendingApprovalSavingAccounts; - this.approvedSavingAccounts = approvedSavingAccounts; - this.withdrawnByClientSavingAccounts = withdrawnByClientSavingAccounts; - this.rejectedSavingAccounts = rejectedSavingAccounts; - this.closedSavingAccounts = closedSavingAccounts; - - this.pendingApprovalLoanCount = this.pendingApprovalLoans.size(); - this.awaitingDisbursalLoanCount = this.awaitingDisbursalLoans.size(); - this.activeLoanCount = this.openLoans.size(); - this.closedLoanCount = this.closedLoans.size(); - - this.pendingApprovalDespositAccountsCount = this.pendingApprovalDepositAccounts.size(); - this.approvedDespositAccountsCount = this.approvedDepositAccounts.size(); - this.withdrawnByClientDespositAccountsCount = this.withdrawnByClientDespositAccounts.size(); - this.closedDepositAccountsCount = this.closedDepositAccounts.size(); - this.rejectedDepositAccountsCount = this.rejectedDepositAccounts.size(); - this.preclosedDepositAccountsCount = this.preclosedDepositAccounts.size(); - this.maturedDepositAccountsCount = this.maturedDepositAccounts.size(); - this.pendingApprovalSavingAccountsCount = this.pendingApprovalSavingAccounts.size(); - this.approvedSavingAccountsCount = this.approvedSavingAccounts.size(); - this.withdrawnByClientSavingAccountsCount = this.withdrawnByClientSavingAccounts.size(); - this.rejectedSavingAccountsCount = this.rejectedSavingAccounts.size(); - this.closedSavingAccountsCount = this.closedSavingAccounts.size(); - - this.anyLoanCount = this.pendingApprovalLoanCount + this.awaitingDisbursalLoanCount + this.activeLoanCount + this.closedLoanCount - +this.pendingApprovalDespositAccountsCount+this.approvedDespositAccountsCount+this.withdrawnByClientDespositAccountsCount+this.closedDepositAccountsCount - +this.rejectedDepositAccountsCount+this.preclosedDepositAccountsCount+this.maturedDepositAccountsCount - +this.pendingApprovalSavingAccountsCount+this.approvedSavingAccountsCount+this.withdrawnByClientSavingAccountsCount - +this.rejectedSavingAccountsCount+this.closedSavingAccountsCount; - - } + @SuppressWarnings("unused") + private final Integer anyLoanCount; + private final Integer pendingApprovalLoanCount; + private final Collection pendingApprovalLoans; + private final Integer awaitingDisbursalLoanCount; + private final Collection awaitingDisbursalLoans; + private final Integer activeLoanCount; + private final Collection openLoans; + private final Integer closedLoanCount; + private final Collection closedLoans; + @SuppressWarnings("unused") + private final Integer pendingApprovalDepositAccountsCount; + private final Collection pendingApprovalDepositAccounts; + @SuppressWarnings("unused") + private final Integer approvedDepositAccountsCount; + private final Collection approvedDepositAccounts; + @SuppressWarnings("unused") + private final Integer withdrawnByClientDepositAccountsCount; + private final Collection withdrawnByClientDepositAccounts; + @SuppressWarnings("unused") + private final Integer closedDepositAccountsCount; + private final Collection closedDepositAccounts; + @SuppressWarnings("unused") + private final Integer rejectedDepositAccountsCount; + private final Collection rejectedDepositAccounts; + @SuppressWarnings("unused") + private final Integer preclosedDepositAccountsCount; + private final Collection preclosedDepositAccounts; + @SuppressWarnings("unused") + private final Integer maturedDepositAccountsCount; + private final Collection maturedDepositAccounts; + @SuppressWarnings("unused") + private final Integer pendingApprovalSavingAccountsCount; + private final Collection pendingApprovalSavingAccounts; + @SuppressWarnings("unused") + private final Integer approvedSavingAccountsCount; + private final Collection approvedSavingAccounts; + @SuppressWarnings("unused") + private final Integer withdrawnByClientSavingAccountsCount; + private final Collection withdrawnByClientSavingAccounts; + @SuppressWarnings("unused") + private final Integer rejectedSavingAccountsCount; + private final Collection rejectedSavingAccounts; + @SuppressWarnings("unused") + private final Integer closedSavingAccountsCount; + private final Collection closedSavingAccounts; - public int getAnyLoanCount() { - return anyLoanCount; - } + public ClientAccountSummaryCollectionData(final Collection pendingApprovalLoans, + final Collection awaitingDisbursalLoans, final Collection openLoans, + final Collection closedLoans, + final Collection pendingApprovalDepositAccounts, + final Collection approvedDepositAccounts, + final Collection withdrawnByClientDepositAccounts, + final Collection rejectedDepositAccounts, + final Collection closedDepositAccounts, + final Collection preclosedDepositAccounts, + final Collection maturedDepositAccounts, + final Collection pendingApprovalSavingAccounts, + final Collection approvedSavingAccounts, + final Collection withdrawnByClientSavingAccounts, + final Collection rejectedSavingAccounts, + final Collection closedSavingAccounts) { - public int getPendingApprovalLoanCount() { - return pendingApprovalLoanCount; - } + this.pendingApprovalLoans = defaultIfEmpty(pendingApprovalLoans); + this.awaitingDisbursalLoans = defaultIfEmpty(awaitingDisbursalLoans); + this.openLoans = defaultIfEmpty(openLoans); + this.closedLoans = defaultIfEmpty(closedLoans); - public List getPendingApprovalLoans() { - return pendingApprovalLoans; - } + this.pendingApprovalDepositAccounts = defaultIfEmpty(pendingApprovalDepositAccounts); + this.approvedDepositAccounts = defaultIfEmpty(approvedDepositAccounts); + this.withdrawnByClientDepositAccounts = defaultIfEmpty(withdrawnByClientDepositAccounts); + this.closedDepositAccounts = defaultIfEmpty(closedDepositAccounts); + this.rejectedDepositAccounts = defaultIfEmpty(rejectedDepositAccounts); + this.preclosedDepositAccounts = defaultIfEmpty(preclosedDepositAccounts); + this.maturedDepositAccounts = defaultIfEmpty(maturedDepositAccounts); - public int getAwaitingDisbursalLoanCount() { - return awaitingDisbursalLoanCount; - } + this.pendingApprovalSavingAccounts = defaultIfEmpty(pendingApprovalSavingAccounts); + this.approvedSavingAccounts = defaultIfEmpty(approvedSavingAccounts); + this.withdrawnByClientSavingAccounts = defaultIfEmpty(withdrawnByClientSavingAccounts); + this.rejectedSavingAccounts = defaultIfEmpty(rejectedSavingAccounts); + this.closedSavingAccounts = defaultIfEmpty(closedSavingAccounts); - public List getAwaitingDisbursalLoans() { - return awaitingDisbursalLoans; - } + this.pendingApprovalLoanCount = defaultToNullIfEmpty(this.pendingApprovalLoans); + this.awaitingDisbursalLoanCount = defaultToNullIfEmpty(this.awaitingDisbursalLoans); + this.activeLoanCount = defaultToNullIfEmpty(this.openLoans); + this.closedLoanCount = defaultToNullIfEmpty(this.closedLoans); - public int getActiveLoanCount() { - return activeLoanCount; - } + this.pendingApprovalDepositAccountsCount = defaultToNullIfEmpty(this.pendingApprovalDepositAccounts); + this.approvedDepositAccountsCount = defaultToNullIfEmpty(this.approvedDepositAccounts); + this.withdrawnByClientDepositAccountsCount = defaultToNullIfEmpty(this.withdrawnByClientDepositAccounts); + this.closedDepositAccountsCount = defaultToNullIfEmpty(this.closedDepositAccounts); + this.rejectedDepositAccountsCount = defaultToNullIfEmpty(this.rejectedDepositAccounts); + this.preclosedDepositAccountsCount = defaultToNullIfEmpty(this.preclosedDepositAccounts); + this.maturedDepositAccountsCount = defaultToNullIfEmpty(this.maturedDepositAccounts); + this.pendingApprovalSavingAccountsCount = defaultToNullIfEmpty(this.pendingApprovalSavingAccounts); + this.approvedSavingAccountsCount = defaultToNullIfEmpty(this.approvedSavingAccounts); + this.withdrawnByClientSavingAccountsCount = defaultToNullIfEmpty(this.withdrawnByClientSavingAccounts); + this.rejectedSavingAccountsCount = defaultToNullIfEmpty(this.rejectedSavingAccounts); + this.closedSavingAccountsCount = defaultToNullIfEmpty(this.closedSavingAccounts); - public List getOpenLoans() { - return openLoans; - } + this.anyLoanCount = countOf(this.pendingApprovalLoanCount, this.awaitingDisbursalLoanCount, this.activeLoanCount, + this.closedLoanCount); + // + // , this.pendingApprovalDepositAccountsCount, + // this.approvedDepositAccountsCount + // , this.withdrawnByClientDepositAccountsCount, + // this.closedDepositAccountsCount, this.rejectedDepositAccountsCount + // , this.preclosedDepositAccountsCount, + // this.maturedDepositAccountsCount, + // this.pendingApprovalSavingAccountsCount + // , this.approvedSavingAccountsCount, + // this.withdrawnByClientSavingAccountsCount, + // this.rejectedSavingAccountsCount + // , this.closedSavingAccountsCount); - public int getClosedLoanCount() { - return closedLoanCount; - } + } - public List getClosedLoans() { - return closedLoans; - } + private Integer countOf(final Integer... objects) { + Integer count = Integer.valueOf(0); + for (Integer value : objects) { + if (value != null) { + count = count + value; + } + } + return count; + } - public int getPendingApprovalDespositAccountsCount() { - return pendingApprovalDespositAccountsCount; - } + private Integer defaultToNullIfEmpty(final Collection collection) { + Integer count = null; + if (defaultIfEmpty(collection) != null) { + count = collection.size(); + } + return count; + } - public List getPendingApprovalDepositAccounts() { - return pendingApprovalDepositAccounts; - } - - public int getApprovedDespositAccountsCount() { - return approvedDespositAccountsCount; - } - - public List getApprovedDepositAccounts() { - return approvedDepositAccounts; - } - - public int getWithdrawnByClientDespositAccountsCount() { - return withdrawnByClientDespositAccountsCount; - } - - public List getWithdrawnByClientDespositAccounts() { - return withdrawnByClientDespositAccounts; - } - - public int getClosedDepositAccountsCount() { - return closedDepositAccountsCount; - } - - public List getClosedDepositAccounts() { - return closedDepositAccounts; - } - - public int getRejectedDepositAccountsCount() { - return rejectedDepositAccountsCount; - } - - public List getRejectedDepositAccounts() { - return rejectedDepositAccounts; - } - - public int getPreclosedDepositAccountsCount() { - return preclosedDepositAccountsCount; - } - - public List getPreclosedDepositAccounts() { - return preclosedDepositAccounts; - } + private Collection defaultIfEmpty(final Collection collection) { + Collection returnCollection = null; + if (collection != null && !collection.isEmpty()) { + returnCollection = collection; + } + return returnCollection; + } } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/data/ClientAccountSummaryData.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/data/ClientAccountSummaryData.java index a8dfa06e8..36e9929a7 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/data/ClientAccountSummaryData.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/data/ClientAccountSummaryData.java @@ -1,5 +1,7 @@ package org.mifosplatform.portfolio.client.data; +import org.mifosplatform.infrastructure.core.data.EnumOptionData; + /** * Immutable data object for client loan accounts. */ @@ -13,7 +15,9 @@ public class ClientAccountSummaryData { private final Long productId; @SuppressWarnings("unused") private final String productName; + private final Integer accountStatusId; + private final EnumOptionData status; public ClientAccountSummaryData(final Long id, final String externalId, final Long productId, final String loanProductName, final Integer loanStatusId) { @@ -22,9 +26,28 @@ public class ClientAccountSummaryData { this.productId = productId; this.productName = loanProductName; this.accountStatusId = loanStatusId; + this.status = null; + } + + /** + * Rather than use id, just be consistent and use EnumOptionData for the + * status of an account. + */ + public ClientAccountSummaryData(final Long id, final String externalId, final Long productId, final String loanProductName, + final EnumOptionData loanStatus) { + this.id = id; + this.externalId = externalId; + this.productId = productId; + this.productName = loanProductName; + this.accountStatusId = null; + this.status = loanStatus; } public Integer accountStatusId() { - return accountStatusId; + Integer accountStatus = this.accountStatusId; + if (accountStatus == null && this.status != null) { + accountStatus = this.status.getId().intValue(); + } + return accountStatus; } } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/data/ClientData.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/data/ClientData.java index dc8985d1f..f15b86f57 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/data/ClientData.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/data/ClientData.java @@ -103,7 +103,7 @@ final public class ClientData { this.officeId = officeId; this.officeName = officeName; this.id = id; - this.firstname = firstname; + this.firstname = StringUtils.defaultIfEmpty(firstname, null); /*** unset last name for business name **/ if (StringUtils.isBlank(firstname)) { @@ -114,7 +114,7 @@ final public class ClientData { this.clientOrBusinessName = null; } this.displayName = displayName; - this.externalId = externalId; + this.externalId = StringUtils.defaultIfEmpty(externalId, null); this.joinedDate = joinedDate; this.imageKey = imageKey; if (imageKey != null) { diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/service/ClientReadPlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/service/ClientReadPlatformServiceImpl.java index 47b2ff6df..cc3d1918e 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/service/ClientReadPlatformServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/service/ClientReadPlatformServiceImpl.java @@ -25,6 +25,7 @@ import org.mifosplatform.portfolio.client.domain.NoteEnumerations; import org.mifosplatform.portfolio.client.exception.ClientIdentifierNotFoundException; import org.mifosplatform.portfolio.client.exception.ClientNotFoundException; import org.mifosplatform.portfolio.client.exception.NoteNotFoundException; +import org.mifosplatform.portfolio.loanproduct.service.LoanEnumerations; import org.mifosplatform.useradministration.data.AppUserData; import org.mifosplatform.useradministration.domain.AppUser; import org.mifosplatform.useradministration.service.AppUserReadPlatformService; @@ -314,13 +315,14 @@ public class ClientReadPlatformServiceImpl implements ClientReadPlatformService @Override public ClientAccountSummaryData mapRow(final ResultSet rs, @SuppressWarnings("unused") final int rowNum) throws SQLException { - Long id = JdbcSupport.getLong(rs, "id"); - String externalId = rs.getString("externalId"); - Long productId = JdbcSupport.getLong(rs, "productId"); - String loanProductName = rs.getString("productName"); - Integer loanStatusId = JdbcSupport.getInteger(rs, "statusId"); + final Long id = JdbcSupport.getLong(rs, "id"); + final String externalId = rs.getString("externalId"); + final Long productId = JdbcSupport.getLong(rs, "productId"); + final String loanProductName = rs.getString("productName"); + final Integer loanStatusId = JdbcSupport.getInteger(rs, "statusId"); + final EnumOptionData loanStatus = LoanEnumerations.status(loanStatusId); - return new ClientAccountSummaryData(id, externalId, productId, loanProductName, loanStatusId); + return new ClientAccountSummaryData(id, externalId, productId, loanProductName, loanStatus); } }