update api-docs around client and client account summary.

This commit is contained in:
Keith Woodlock
2012-12-24 13:57:30 +00:00
parent c99053d2a4
commit 8dc8dcad52
6 changed files with 226 additions and 250 deletions
@@ -254,11 +254,15 @@ public class ClientsApiResource {
final Set<String> CLIENT_ACCOUNTS_DATA_PARAMETERS = new HashSet<String>(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);
@@ -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<ClientAccountSummaryData> pendingApprovalLoans;
private final int awaitingDisbursalLoanCount;
private final List<ClientAccountSummaryData> awaitingDisbursalLoans;
private final int activeLoanCount;
private final List<ClientAccountSummaryData> openLoans;
private final int closedLoanCount;
private final List<ClientAccountSummaryData> closedLoans;
private final int pendingApprovalDespositAccountsCount;
private final List<ClientAccountSummaryData> pendingApprovalDepositAccounts;
private final int approvedDespositAccountsCount;
private final List<ClientAccountSummaryData> approvedDepositAccounts;
private final int withdrawnByClientDespositAccountsCount;
private final List<ClientAccountSummaryData> withdrawnByClientDespositAccounts;
private final int closedDepositAccountsCount;
private final List<ClientAccountSummaryData> closedDepositAccounts;
private final int rejectedDepositAccountsCount;
private final List<ClientAccountSummaryData> rejectedDepositAccounts;
private final int preclosedDepositAccountsCount;
private final List<ClientAccountSummaryData> preclosedDepositAccounts;
private final int maturedDepositAccountsCount;
private final List<ClientAccountSummaryData> maturedDepositAccounts;
private final int pendingApprovalSavingAccountsCount;
private final List<ClientAccountSummaryData> pendingApprovalSavingAccounts;
private final int approvedSavingAccountsCount;
private final List<ClientAccountSummaryData> approvedSavingAccounts;
private final int withdrawnByClientSavingAccountsCount;
private final List<ClientAccountSummaryData> withdrawnByClientSavingAccounts;
private final int rejectedSavingAccountsCount;
private final List<ClientAccountSummaryData> rejectedSavingAccounts;
private final int closedSavingAccountsCount;
private final List<ClientAccountSummaryData> closedSavingAccounts;
public ClientAccountSummaryCollectionData(
final List<ClientAccountSummaryData> pendingApprovalLoans,
final List<ClientAccountSummaryData> awaitingDisbursalLoans,
final List<ClientAccountSummaryData> openLoans,
final List<ClientAccountSummaryData> closedLoans,
final List<ClientAccountSummaryData> pendingApprovalDepositAccounts,
final List<ClientAccountSummaryData> approvedDepositAccounts,
final List<ClientAccountSummaryData> withdrawnByClientDespositAccounts,
final List<ClientAccountSummaryData> rejectedDepositAccounts,
final List<ClientAccountSummaryData> closedDepositAccounts,
final List<ClientAccountSummaryData> preclosedDepositAccounts,
final List<ClientAccountSummaryData> maturedDepositAccounts,
final List<ClientAccountSummaryData> pendingApprovalSavingAccounts,
final List<ClientAccountSummaryData> approvedSavingAccounts,
final List<ClientAccountSummaryData> withdrawnByClientSavingAccounts,
final List<ClientAccountSummaryData> rejectedSavingAccounts,
final List<ClientAccountSummaryData> 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<ClientAccountSummaryData> pendingApprovalLoans;
private final Integer awaitingDisbursalLoanCount;
private final Collection<ClientAccountSummaryData> awaitingDisbursalLoans;
private final Integer activeLoanCount;
private final Collection<ClientAccountSummaryData> openLoans;
private final Integer closedLoanCount;
private final Collection<ClientAccountSummaryData> closedLoans;
@SuppressWarnings("unused")
private final Integer pendingApprovalDepositAccountsCount;
private final Collection<ClientAccountSummaryData> pendingApprovalDepositAccounts;
@SuppressWarnings("unused")
private final Integer approvedDepositAccountsCount;
private final Collection<ClientAccountSummaryData> approvedDepositAccounts;
@SuppressWarnings("unused")
private final Integer withdrawnByClientDepositAccountsCount;
private final Collection<ClientAccountSummaryData> withdrawnByClientDepositAccounts;
@SuppressWarnings("unused")
private final Integer closedDepositAccountsCount;
private final Collection<ClientAccountSummaryData> closedDepositAccounts;
@SuppressWarnings("unused")
private final Integer rejectedDepositAccountsCount;
private final Collection<ClientAccountSummaryData> rejectedDepositAccounts;
@SuppressWarnings("unused")
private final Integer preclosedDepositAccountsCount;
private final Collection<ClientAccountSummaryData> preclosedDepositAccounts;
@SuppressWarnings("unused")
private final Integer maturedDepositAccountsCount;
private final Collection<ClientAccountSummaryData> maturedDepositAccounts;
@SuppressWarnings("unused")
private final Integer pendingApprovalSavingAccountsCount;
private final Collection<ClientAccountSummaryData> pendingApprovalSavingAccounts;
@SuppressWarnings("unused")
private final Integer approvedSavingAccountsCount;
private final Collection<ClientAccountSummaryData> approvedSavingAccounts;
@SuppressWarnings("unused")
private final Integer withdrawnByClientSavingAccountsCount;
private final Collection<ClientAccountSummaryData> withdrawnByClientSavingAccounts;
@SuppressWarnings("unused")
private final Integer rejectedSavingAccountsCount;
private final Collection<ClientAccountSummaryData> rejectedSavingAccounts;
@SuppressWarnings("unused")
private final Integer closedSavingAccountsCount;
private final Collection<ClientAccountSummaryData> closedSavingAccounts;
public int getAnyLoanCount() {
return anyLoanCount;
}
public ClientAccountSummaryCollectionData(final Collection<ClientAccountSummaryData> pendingApprovalLoans,
final Collection<ClientAccountSummaryData> awaitingDisbursalLoans, final Collection<ClientAccountSummaryData> openLoans,
final Collection<ClientAccountSummaryData> closedLoans,
final Collection<ClientAccountSummaryData> pendingApprovalDepositAccounts,
final Collection<ClientAccountSummaryData> approvedDepositAccounts,
final Collection<ClientAccountSummaryData> withdrawnByClientDepositAccounts,
final Collection<ClientAccountSummaryData> rejectedDepositAccounts,
final Collection<ClientAccountSummaryData> closedDepositAccounts,
final Collection<ClientAccountSummaryData> preclosedDepositAccounts,
final Collection<ClientAccountSummaryData> maturedDepositAccounts,
final Collection<ClientAccountSummaryData> pendingApprovalSavingAccounts,
final Collection<ClientAccountSummaryData> approvedSavingAccounts,
final Collection<ClientAccountSummaryData> withdrawnByClientSavingAccounts,
final Collection<ClientAccountSummaryData> rejectedSavingAccounts,
final Collection<ClientAccountSummaryData> closedSavingAccounts) {
public int getPendingApprovalLoanCount() {
return pendingApprovalLoanCount;
}
this.pendingApprovalLoans = defaultIfEmpty(pendingApprovalLoans);
this.awaitingDisbursalLoans = defaultIfEmpty(awaitingDisbursalLoans);
this.openLoans = defaultIfEmpty(openLoans);
this.closedLoans = defaultIfEmpty(closedLoans);
public List<ClientAccountSummaryData> 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<ClientAccountSummaryData> 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<ClientAccountSummaryData> 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<ClientAccountSummaryData> 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<ClientAccountSummaryData> collection) {
Integer count = null;
if (defaultIfEmpty(collection) != null) {
count = collection.size();
}
return count;
}
public List<ClientAccountSummaryData> getPendingApprovalDepositAccounts() {
return pendingApprovalDepositAccounts;
}
public int getApprovedDespositAccountsCount() {
return approvedDespositAccountsCount;
}
public List<ClientAccountSummaryData> getApprovedDepositAccounts() {
return approvedDepositAccounts;
}
public int getWithdrawnByClientDespositAccountsCount() {
return withdrawnByClientDespositAccountsCount;
}
public List<ClientAccountSummaryData> getWithdrawnByClientDespositAccounts() {
return withdrawnByClientDespositAccounts;
}
public int getClosedDepositAccountsCount() {
return closedDepositAccountsCount;
}
public List<ClientAccountSummaryData> getClosedDepositAccounts() {
return closedDepositAccounts;
}
public int getRejectedDepositAccountsCount() {
return rejectedDepositAccountsCount;
}
public List<ClientAccountSummaryData> getRejectedDepositAccounts() {
return rejectedDepositAccounts;
}
public int getPreclosedDepositAccountsCount() {
return preclosedDepositAccountsCount;
}
public List<ClientAccountSummaryData> getPreclosedDepositAccounts() {
return preclosedDepositAccounts;
}
private Collection<ClientAccountSummaryData> defaultIfEmpty(final Collection<ClientAccountSummaryData> collection) {
Collection<ClientAccountSummaryData> returnCollection = null;
if (collection != null && !collection.isEmpty()) {
returnCollection = collection;
}
return returnCollection;
}
}
@@ -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;
}
}
@@ -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) {
@@ -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);
}
}