return status with deposit account data.

This commit is contained in:
Keith Woodlock
2012-08-30 08:43:50 +01:00
parent 9da34579a0
commit b100fd16a1
6 changed files with 78 additions and 68 deletions
@@ -61,6 +61,15 @@ public class DepositAccountsApiResource {
@Autowired @Autowired
private ApiJsonSerializerService apiJsonSerializerService; private ApiJsonSerializerService apiJsonSerializerService;
private static final Set<String> typicalResponseParameters = new HashSet<String>(
Arrays.asList("id", "externalId", "clientId", "clientName",
"productId", "productName", "status", "currency",
"deposit", "maturityInterestRate", "tenureInMonths",
"interestCompoundedEvery",
"interestCompoundedEveryPeriodType", "renewalAllowed",
"preClosureAllowed", "preClosureInterestRate"));
@POST @POST
@Consumes({MediaType.APPLICATION_JSON}) @Consumes({MediaType.APPLICATION_JSON})
@Produces({MediaType.APPLICATION_JSON}) @Produces({MediaType.APPLICATION_JSON})
@@ -91,14 +100,6 @@ public class DepositAccountsApiResource {
@Produces({MediaType.APPLICATION_JSON}) @Produces({MediaType.APPLICATION_JSON})
public String retrieveAllDepositAccounts(@Context final UriInfo uriInfo) { public String retrieveAllDepositAccounts(@Context final UriInfo uriInfo) {
Set<String> typicalResponseParameters = new HashSet<String>(
Arrays.asList("createdOn", "lastModifedOn",
"id", "externalId", "clientId", "clientName", "productId", "productName",
"currency", "deposit", "maturityInterestRate", "tenureInMonths", "interestCompoundedEvery", "interestCompoundedEveryPeriodType",
"renewalAllowed","preClosureAllowed","preClosureInterestRate"
)
);
Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters()); Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters());
if (responseParameters.isEmpty()) { if (responseParameters.isEmpty()) {
responseParameters.addAll(typicalResponseParameters); responseParameters.addAll(typicalResponseParameters);
@@ -116,14 +117,6 @@ public class DepositAccountsApiResource {
@Produces({MediaType.APPLICATION_JSON}) @Produces({MediaType.APPLICATION_JSON})
public String retrieveDepositAccount(@PathParam("accountId") final Long accountId, @Context final UriInfo uriInfo) { public String retrieveDepositAccount(@PathParam("accountId") final Long accountId, @Context final UriInfo uriInfo) {
Set<String> typicalResponseParameters = new HashSet<String>(
Arrays.asList("createdOn", "lastModifedOn",
"id", "externalId", "clientId", "clientName", "productId", "productName",
"currency", "deposit", "maturityInterestRate", "tenureInMonths", "interestCompoundedEvery", "interestCompoundedEveryPeriodType",
"renewalAllowed","preClosureAllowed","preClosureInterestRate"
)
);
Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters()); Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters());
if (responseParameters.isEmpty()) { if (responseParameters.isEmpty()) {
responseParameters.addAll(typicalResponseParameters); responseParameters.addAll(typicalResponseParameters);
@@ -149,15 +142,6 @@ public class DepositAccountsApiResource {
@QueryParam("productId") final Long productId, @QueryParam("productId") final Long productId,
@Context final UriInfo uriInfo) { @Context final UriInfo uriInfo) {
Set<String> typicalResponseParameters = new HashSet<String>(
Arrays.asList(
"createdOn", "lastModifedOn",
"id", "externalId", "clientId", "clientName", "productId", "productName",
"currency", "deposit", "maturityInterestRate", "tenureInMonths", "interestCompoundedEvery", "interestCompoundedEveryPeriodType",
"renewalAllowed","preClosureAllowed","preClosureInterestRate"
)
);
Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters()); Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters());
if (responseParameters.isEmpty()) { if (responseParameters.isEmpty()) {
responseParameters.addAll(typicalResponseParameters); responseParameters.addAll(typicalResponseParameters);
@@ -5,7 +5,6 @@ import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import org.joda.time.DateTime;
import org.joda.time.LocalDate; import org.joda.time.LocalDate;
/** /**
@@ -15,7 +14,7 @@ public class DepositAccountData {
private final Long id; private final Long id;
private final String externalId; private final String externalId;
private final EnumOptionData status;
private final Long clientId; private final Long clientId;
private final String clientName; private final String clientName;
private final Long productId; private final Long productId;
@@ -41,9 +40,6 @@ public class DepositAccountData {
private final boolean preClosureAllowed; private final boolean preClosureAllowed;
private final BigDecimal preClosureInterestRate; private final BigDecimal preClosureInterestRate;
private final DateTime createdOn;
private final DateTime lastModifedOn;
private final List<EnumOptionData> interestCompoundedEveryPeriodTypeOptions; private final List<EnumOptionData> interestCompoundedEveryPeriodTypeOptions;
private final List<DepositProductLookup> productOptions; private final List<DepositProductLookup> productOptions;
@@ -58,10 +54,9 @@ public class DepositAccountData {
private DepositAccountData( private DepositAccountData(
final Long clientId, final Long clientId,
final String clientName) { final String clientName) {
this.createdOn=null;
this.lastModifedOn=null;
this.id=null; this.id=null;
this.externalId = null; this.externalId = null;
this.status = null;
this.clientId = clientId; this.clientId = clientId;
this.clientName = clientName; this.clientName = clientName;
this.productId = null; this.productId = null;
@@ -92,10 +87,9 @@ public class DepositAccountData {
final DepositAccountData account, final DepositAccountData account,
final List<EnumOptionData> interestCompoundedEveryPeriodTypeOptions, final List<EnumOptionData> interestCompoundedEveryPeriodTypeOptions,
final Collection<DepositProductLookup> productOptions) { final Collection<DepositProductLookup> productOptions) {
this.createdOn = account.getCreatedOn();
this.lastModifedOn = account.getLastModifedOn();
this.id = account.getId(); this.id = account.getId();
this.externalId = account.getExternalId(); this.externalId = account.getExternalId();
this.status = account.getStatus();
this.clientId = account.getClientId(); this.clientId = account.getClientId();
this.clientName = account.getClientName(); this.clientName = account.getClientName();
this.productId = account.getProductId(); this.productId = account.getProductId();
@@ -123,10 +117,9 @@ public class DepositAccountData {
} }
public DepositAccountData( public DepositAccountData(
final DateTime createdOn,
final DateTime lastModifedOn,
final Long id, final Long id,
final String externalId, final String externalId,
final EnumOptionData status,
final Long clientId, final Long clientId,
final String clientName, final String clientName,
final Long productId, final Long productId,
@@ -147,10 +140,9 @@ public class DepositAccountData {
final boolean renewalAllowed, final boolean renewalAllowed,
final boolean preClosureAllowed, final boolean preClosureAllowed,
final BigDecimal preClosureInterestRate) { final BigDecimal preClosureInterestRate) {
this.createdOn=createdOn;
this.lastModifedOn=lastModifedOn;
this.id=id; this.id=id;
this.externalId = externalId; this.externalId = externalId;
this.status = status;
this.clientId = clientId; this.clientId = clientId;
this.clientName = clientName; this.clientName = clientName;
this.productId = productId; this.productId = productId;
@@ -190,10 +182,9 @@ public class DepositAccountData {
final boolean renewalAllowed, final boolean renewalAllowed,
final boolean preClosureAllowed, final boolean preClosureAllowed,
final BigDecimal preClosureInterestRate) { final BigDecimal preClosureInterestRate) {
this.createdOn=null;
this.lastModifedOn=null;
this.id=null; this.id=null;
this.externalId = null; this.externalId = null;
this.status = null;
this.clientId = clientId; this.clientId = clientId;
this.clientName = clientName; this.clientName = clientName;
this.productId = productId; this.productId = productId;
@@ -228,6 +219,10 @@ public class DepositAccountData {
return externalId; return externalId;
} }
public EnumOptionData getStatus() {
return status;
}
public Long getClientId() { public Long getClientId() {
return clientId; return clientId;
} }
@@ -312,14 +307,6 @@ public class DepositAccountData {
return preClosureInterestRate; return preClosureInterestRate;
} }
public DateTime getCreatedOn() {
return createdOn;
}
public DateTime getLastModifedOn() {
return lastModifedOn;
}
public List<EnumOptionData> getInterestCompoundedEveryPeriodTypeOptions() { public List<EnumOptionData> getInterestCompoundedEveryPeriodTypeOptions() {
return interestCompoundedEveryPeriodTypeOptions; return interestCompoundedEveryPeriodTypeOptions;
} }
@@ -97,14 +97,13 @@ public class GoogleGsonApiJsonSerializerService implements
"preClosureAllowed", "preClosureInterestRate")); "preClosureAllowed", "preClosureInterestRate"));
private static final Set<String> SAVINGS_DEPOSIT_ACCOUNT_DATA_PARAMETERS = new HashSet<String>( private static final Set<String> SAVINGS_DEPOSIT_ACCOUNT_DATA_PARAMETERS = new HashSet<String>(
Arrays.asList("productOptions", Arrays.asList("productOptions", "interestCompoundedEveryPeriodTypeOptions",
"interestCompoundedEveryPeriodTypeOptions", "createdOn", "id", "externalId", "clientId", "clientName", "productId", "productName", "status",
"lastModifedOn", "id", "externalId", "clientId", "currency", "deposit", "maturityInterestRate", "tenureInMonths",
"clientName", "productId", "productName", "currency", "interestCompoundedEvery", "interestCompoundedEveryPeriodType",
"deposit", "maturityInterestRate", "tenureInMonths", "renewalAllowed","preClosureAllowed","preClosureInterestRate"
"interestCompoundedEvery", )
"interestCompoundedEveryPeriodType", "renewalAllowed", );
"preClosureAllowed", "preClosureInterestRate"));
private static final Set<String> CLIENT_DATA_PARAMETERS = new HashSet<String>( private static final Set<String> CLIENT_DATA_PARAMETERS = new HashSet<String>(
Arrays.asList("id", "officeId", "officeName", "externalId", Arrays.asList("id", "officeId", "officeName", "externalId",
@@ -8,8 +8,8 @@ public enum DepositStatus {
ACTIVE(300, "depositStatusType.active"), // ACTIVE(300, "depositStatusType.active"), //
WITHDRAWN_BY_CLIENT(400, "depositStatusType.withdrawn.by.client"), // WITHDRAWN_BY_CLIENT(400, "depositStatusType.withdrawn.by.client"), //
REJECTED(500, "depositStatusType.rejected"), // REJECTED(500, "depositStatusType.rejected"), //
MATURED(700,"depositStatusType.matured"), CLOSED(600, "depositStatusType.closed"), //
CLOSED(600, "depositStatusType.closed"); MATURED(700,"depositStatusType.matured");
private final Integer value; private final Integer value;
private final String code; private final String code;
@@ -0,0 +1,42 @@
package org.mifosng.platform.saving.service;
import org.mifosng.platform.api.data.EnumOptionData;
import org.mifosng.platform.saving.domain.DepositStatus;
public class DepositAccountEnumerations {
public static EnumOptionData status(final Integer statusId) {
return status(DepositStatus.fromInt(statusId));
}
public static EnumOptionData status(final DepositStatus status) {
EnumOptionData optionData = null;
switch (status) {
case SUBMITED_AND_PENDING_APPROVAL:
optionData = new EnumOptionData(DepositStatus.SUBMITED_AND_PENDING_APPROVAL.getValue().longValue(), DepositStatus.SUBMITED_AND_PENDING_APPROVAL.getCode(), "Submitted and pending approval");
break;
case APPROVED:
optionData = new EnumOptionData(DepositStatus.APPROVED.getValue().longValue(), DepositStatus.APPROVED.getCode(), "Approved");
break;
case ACTIVE:
optionData = new EnumOptionData(DepositStatus.ACTIVE.getValue().longValue(), DepositStatus.ACTIVE.getCode(), "Active");
break;
case REJECTED:
optionData = new EnumOptionData(DepositStatus.REJECTED.getValue().longValue(), DepositStatus.REJECTED.getCode(), "Rejected");
break;
case WITHDRAWN_BY_CLIENT:
optionData = new EnumOptionData(DepositStatus.WITHDRAWN_BY_CLIENT.getValue().longValue(), DepositStatus.WITHDRAWN_BY_CLIENT.getCode(), "Withdrawn by applicant");
break;
case MATURED:
optionData = new EnumOptionData(DepositStatus.MATURED.getValue().longValue(), DepositStatus.MATURED.getCode(), "Matured");
break;
case CLOSED:
optionData = new EnumOptionData(DepositStatus.CLOSED.getValue().longValue(), DepositStatus.CLOSED.getCode(), "Closed");
break;
default:
optionData = new EnumOptionData(DepositStatus.INVALID.getValue().longValue(), DepositStatus.INVALID.getCode(), "Invalid");
break;
}
return optionData;
}
}
@@ -5,7 +5,6 @@ import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.Collection; import java.util.Collection;
import org.joda.time.DateTime;
import org.joda.time.LocalDate; import org.joda.time.LocalDate;
import org.mifosng.platform.api.data.ClientData; import org.mifosng.platform.api.data.ClientData;
import org.mifosng.platform.api.data.CurrencyData; import org.mifosng.platform.api.data.CurrencyData;
@@ -118,14 +117,13 @@ public class DepositAccountReadPlatformServiceImpl implements DepositAccountRead
public String schema() { public String schema() {
return "da.id as id, da.external_id as externalId, da.client_id as clientId, da.product_id as productId," return "da.id as id, da.external_id as externalId, da.client_id as clientId, da.product_id as productId,"
+ " da.currency_code as currencyCode, da.currency_digits as currencyDigits, " + " da.currency_code as currencyCode, da.currency_digits as currencyDigits, "
+ " da.deposit_amount as depositAmount, " + " da.deposit_amount as depositAmount, da.status_enum as statusId, "
+ " da.maturity_nominal_interest_rate as interestRate, da.tenure_months as termInMonths, da.projected_commencement_date as projectedCommencementDate," + " da.maturity_nominal_interest_rate as interestRate, da.tenure_months as termInMonths, da.projected_commencement_date as projectedCommencementDate,"
+ " da.actual_commencement_date as actualCommencementDate, da.projected_maturity_date as projectedMaturityDate, da.actual_maturity_date as actualMaturityDate," + " da.actual_commencement_date as actualCommencementDate, da.projected_maturity_date as projectedMaturityDate, da.actual_maturity_date as actualMaturityDate,"
+ " da.projected_interest_accrued_on_maturity as projectedInterestAccrued, da.actual_interest_accrued as actualInterestAccrued, " + " da.projected_interest_accrued_on_maturity as projectedInterestAccrued, da.actual_interest_accrued as actualInterestAccrued, "
+ " da.projected_total_maturity_amount as projectedMaturityAmount, da.actual_total_amount as actualMaturityAmount, " + " da.projected_total_maturity_amount as projectedMaturityAmount, da.actual_total_amount as actualMaturityAmount, "
+ " da.interest_compounded_every as interestCompoundedEvery, da.interest_compounded_every_period_enum as interestCompoundedEveryPeriodType, " + " da.interest_compounded_every as interestCompoundedEvery, da.interest_compounded_every_period_enum as interestCompoundedEveryPeriodType, "
+ " da.is_renewal_allowed as renewalAllowed, da.is_preclosure_allowed as preClosureAllowed, da.pre_closure_interest_rate as preClosureInterestRate, " + " da.is_renewal_allowed as renewalAllowed, da.is_preclosure_allowed as preClosureAllowed, da.pre_closure_interest_rate as preClosureInterestRate, "
+ " da.created_date as createdon, da.lastmodified_date as modifiedon, "
+ " c.firstname as firstname, c.lastname as lastname, pd.name as productName," + " c.firstname as firstname, c.lastname as lastname, pd.name as productName,"
+ " curr.name as currencyName, curr.internationalized_name_code as currencyNameCode, curr.display_symbol as currencyDisplaySymbol" + " curr.name as currencyName, curr.internationalized_name_code as currencyNameCode, curr.display_symbol as currencyDisplaySymbol"
+ " from m_deposit_account da " + " from m_deposit_account da "
@@ -145,6 +143,9 @@ public class DepositAccountReadPlatformServiceImpl implements DepositAccountRead
Long productId = rs.getLong("productId"); Long productId = rs.getLong("productId");
String productName = rs.getString("productName"); String productName = rs.getString("productName");
Integer statusId = JdbcSupport.getInteger(rs, "statusId");
EnumOptionData status = DepositAccountEnumerations.status(statusId);
String currencyCode = rs.getString("currencyCode"); String currencyCode = rs.getString("currencyCode");
String currencyName = rs.getString("currencyName"); String currencyName = rs.getString("currencyName");
String currencyNameCode = rs.getString("currencyNameCode"); String currencyNameCode = rs.getString("currencyNameCode");
@@ -176,10 +177,7 @@ public class DepositAccountReadPlatformServiceImpl implements DepositAccountRead
BigDecimal preClosureInterestRate = rs.getBigDecimal("preClosureInterestRate"); BigDecimal preClosureInterestRate = rs.getBigDecimal("preClosureInterestRate");
DateTime createdOn = JdbcSupport.getDateTime(rs, "createdon"); return new DepositAccountData(id, externalId, status, clientId, clientName, productId, productName, currencyData, depositAmount,
DateTime lastModifedOn = JdbcSupport.getDateTime(rs, "modifiedon");
return new DepositAccountData(createdOn, lastModifedOn, id, externalId, clientId, clientName, productId, productName, currencyData, depositAmount,
interestRate, termInMonths, projectedCommencementDate, actualCommencementDate, projectedMaturityDate, actualMaturityDate, interestRate, termInMonths, projectedCommencementDate, actualCommencementDate, projectedMaturityDate, actualMaturityDate,
projectedInterestAccrued, actualInterestAccrued, projectedMaturityAmount, actualMaturityAmount, projectedInterestAccrued, actualInterestAccrued, projectedMaturityAmount, actualMaturityAmount,
interestCompoundedEvery, interestCompoundedEveryPeriodType, interestCompoundedEvery, interestCompoundedEveryPeriodType,