Retrieveing Deposit Product,Basic Validation
This commit is contained in:
@@ -264,4 +264,16 @@ public class DataValidatorBuilder {
|
||||
}
|
||||
return this;
|
||||
}
|
||||
public DataValidatorBuilder comapareMinAndMaxOfTwoBigDecmimalNos(BigDecimal min,BigDecimal max){
|
||||
if(min!=null&&max!=null)
|
||||
if(max.compareTo(min)==-1){
|
||||
StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(resource).append(".min.number.should.lessthan.max.number");
|
||||
StringBuilder defaultEnglishMessage = new StringBuilder("The ").append(" min number ").append(min).append(" should less than max number ").append(max).append(".");
|
||||
ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(), parameter, min, max);
|
||||
dataValidationErrors.add(error);
|
||||
return this;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
+6
-3
@@ -83,7 +83,8 @@ public class DepositProductsApiResource {
|
||||
@Produces({MediaType.APPLICATION_JSON})
|
||||
public String retrieveAllDepositProducts(@Context final UriInfo uriInfo){
|
||||
Set<String> typicalResponseParameters = new HashSet<String>(Arrays.asList("id", "name", "description", "createdOn", "lastModifedOn",
|
||||
"currencyCode","digitsAfterDecimal","minimumBalance","maximumBalance"));
|
||||
"currencyCode","digitsAfterDecimal","minimumBalance","maximumBalance","tenureMonths","maturityDefaultInterestRate","maturityMinInterestRate",
|
||||
"maturityMaxInterestRate","canRenew","canPreClose","preClosureInterestRate"));
|
||||
|
||||
Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters());
|
||||
if (responseParameters.isEmpty()) {
|
||||
@@ -101,7 +102,8 @@ public class DepositProductsApiResource {
|
||||
@Produces({MediaType.APPLICATION_JSON})
|
||||
public String retrieveDepositProductDetails(@PathParam("productId") final Long productId, @Context final UriInfo uriInfo){
|
||||
Set<String> typicalResponseParameters = new HashSet<String>(Arrays.asList("id", "name", "description", "createdOn", "lastModifedOn",
|
||||
"currencyCode","digitsAfterDecimal","minimumBalance","maximumBalance"));
|
||||
"currencyCode","digitsAfterDecimal","minimumBalance","maximumBalance","tenureMonths","maturityDefaultInterestRate","maturityMinInterestRate",
|
||||
"maturityMaxInterestRate","canRenew","canPreClose","preClosureInterestRate"));
|
||||
|
||||
Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters());
|
||||
if (responseParameters.isEmpty()) {
|
||||
@@ -123,7 +125,8 @@ public class DepositProductsApiResource {
|
||||
public String retrieveNewDepositProductDetails(@Context final UriInfo uriInfo) {
|
||||
|
||||
Set<String> typicalResponseParameters = new HashSet<String>(
|
||||
Arrays.asList("id", "name", "description", "createdOn", "lastModifedOn","currencyCode","digitsAfterDecimal", "currencyOptions","minimumBalance","maximumBalance"));
|
||||
Arrays.asList("id", "name", "description", "createdOn", "lastModifedOn","currencyCode","digitsAfterDecimal", "currencyOptions","minimumBalance","maximumBalance","tenureMonths","maturityDefaultInterestRate","maturityMinInterestRate",
|
||||
"maturityMaxInterestRate","canRenew","canPreClose","preClosureInterestRate"));
|
||||
|
||||
Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters());
|
||||
if (responseParameters.isEmpty()) {
|
||||
|
||||
+76
-1
@@ -21,13 +21,23 @@ public class DepositProductData implements Serializable {
|
||||
private DateTime createdOn;
|
||||
private DateTime lastModifedOn;
|
||||
|
||||
private Integer tenureMonths;
|
||||
private BigDecimal maturityDefaultInterestRate = BigDecimal.ZERO;
|
||||
private BigDecimal maturityMinInterestRate = BigDecimal.ZERO;
|
||||
private BigDecimal maturityMaxInterestRate = BigDecimal.ZERO;
|
||||
private Boolean canRenew;
|
||||
private Boolean canPreClose;
|
||||
private BigDecimal preClosureInterestRate = BigDecimal.ZERO;
|
||||
|
||||
private List<CurrencyData> currencyOptions = new ArrayList<CurrencyData>();
|
||||
|
||||
public DepositProductData() {
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
public DepositProductData(DateTime createdOn, DateTime lastModifedOn, Long id,String name, String description, String currencyCode, Integer digitsAfterDecimal,BigDecimal minimumBalance,BigDecimal maximumBalance) {
|
||||
public DepositProductData(DateTime createdOn, DateTime lastModifedOn, Long id,String name, String description, String currencyCode, Integer digitsAfterDecimal,BigDecimal minimumBalance,BigDecimal maximumBalance,
|
||||
Integer tenureMonths, BigDecimal maturityDefaultInterestRate, BigDecimal maturityMinInterestRate, BigDecimal maturityMaxInterestRate,
|
||||
Boolean canRenew, Boolean canPreClose, BigDecimal preClosureInterestRate) {
|
||||
|
||||
this.createdOn=createdOn;
|
||||
this.lastModifedOn=lastModifedOn;
|
||||
@@ -38,6 +48,14 @@ public class DepositProductData implements Serializable {
|
||||
this.digitsAfterDecimal=digitsAfterDecimal;
|
||||
this.minimumBalance=minimumBalance;
|
||||
this.maximumBalance=maximumBalance;
|
||||
|
||||
this.tenureMonths=tenureMonths;
|
||||
this.maturityDefaultInterestRate = maturityDefaultInterestRate;
|
||||
this.maturityMinInterestRate=maturityMinInterestRate;
|
||||
this.maturityMaxInterestRate=maturityMaxInterestRate;
|
||||
this.canRenew=canRenew;
|
||||
this.canPreClose=canPreClose;
|
||||
this.preClosureInterestRate=preClosureInterestRate;
|
||||
|
||||
}
|
||||
|
||||
@@ -121,4 +139,61 @@ public class DepositProductData implements Serializable {
|
||||
public void setCurrencyOptions(List<CurrencyData> currencyOptions) {
|
||||
this.currencyOptions = currencyOptions;
|
||||
}
|
||||
|
||||
public Integer getTenureMonths() {
|
||||
return tenureMonths;
|
||||
}
|
||||
|
||||
public void setTenureMonths(Integer tenureMonths) {
|
||||
this.tenureMonths = tenureMonths;
|
||||
}
|
||||
|
||||
public BigDecimal getMaturityDefaultInterestRate() {
|
||||
return maturityDefaultInterestRate;
|
||||
}
|
||||
|
||||
public void setMaturityDefaultInterestRate(
|
||||
BigDecimal maturityDefaultInterestRate) {
|
||||
this.maturityDefaultInterestRate = maturityDefaultInterestRate;
|
||||
}
|
||||
|
||||
public BigDecimal getMaturityMinInterestRate() {
|
||||
return maturityMinInterestRate;
|
||||
}
|
||||
|
||||
public void setMaturityMinInterestRate(BigDecimal maturityMinInterestRate) {
|
||||
this.maturityMinInterestRate = maturityMinInterestRate;
|
||||
}
|
||||
|
||||
public BigDecimal getMaturityMaxInterestRate() {
|
||||
return maturityMaxInterestRate;
|
||||
}
|
||||
|
||||
public void setMaturityMaxInterestRate(BigDecimal maturityMaxInterestRate) {
|
||||
this.maturityMaxInterestRate = maturityMaxInterestRate;
|
||||
}
|
||||
|
||||
public Boolean getCanRenew() {
|
||||
return canRenew;
|
||||
}
|
||||
|
||||
public void setCanRenew(Boolean canRenew) {
|
||||
this.canRenew = canRenew;
|
||||
}
|
||||
|
||||
public Boolean getCanPreClose() {
|
||||
return canPreClose;
|
||||
}
|
||||
|
||||
public void setCanPreClose(Boolean canPreClose) {
|
||||
this.canPreClose = canPreClose;
|
||||
}
|
||||
|
||||
public BigDecimal getPreClosureInterestRate() {
|
||||
return preClosureInterestRate;
|
||||
}
|
||||
|
||||
public void setPreClosureInterestRate(BigDecimal preClosureInterestRate) {
|
||||
this.preClosureInterestRate = preClosureInterestRate;
|
||||
}
|
||||
}
|
||||
|
||||
+3
-4
@@ -1589,10 +1589,9 @@ public class ApiDataConversionServiceImpl implements ApiDataConversionService {
|
||||
public String convertDepositProductDataToJson(boolean prettyPrint,
|
||||
Set<String> responseParameters, DepositProductData... products) {
|
||||
|
||||
Set<String> supportedParameters = new HashSet<String>(
|
||||
Arrays.asList("id", "name", "description","createdOn", "lastModifedOn","currencyCode","digitsAfterDecimal", "currencyOptions",
|
||||
"minimumBalance","maximumBalance"));
|
||||
|
||||
Set<String> supportedParameters = new HashSet<String>(Arrays.asList("id", "name", "description","createdOn", "lastModifedOn","currencyCode","digitsAfterDecimal", "currencyOptions", "minimumBalance","maximumBalance","tenureMonths","maturityDefaultInterestRate","maturityMinInterestRate",
|
||||
"maturityMaxInterestRate","canRenew","canPreClose","preClosureInterestRate"));
|
||||
|
||||
final Set<String> parameterNamesToSkip = new HashSet<String>();
|
||||
|
||||
if (!responseParameters.isEmpty()) {
|
||||
|
||||
+10
@@ -43,6 +43,12 @@ public class DepositProductCommandValidator {
|
||||
baseDataValidator.reset().parameter("preClosureInterestRate").value(command.getPreClosureInterestRate()).zeroOrPositiveAmount();
|
||||
|
||||
baseDataValidator.reset().comapareMinimumAndMaximumAmounts(command.getMinimumBalance(), command.getMaximumBalance());
|
||||
baseDataValidator.reset().comapareMinAndMaxOfTwoBigDecmimalNos(command.getMaturityMinInterestRate(), command.getMaturityMaxInterestRate());
|
||||
baseDataValidator.reset().comapareMinAndMaxOfTwoBigDecmimalNos(command.getMaturityDefaultInterestRate(), command.getMaturityMaxInterestRate());
|
||||
baseDataValidator.reset().comapareMinAndMaxOfTwoBigDecmimalNos(command.getMaturityMinInterestRate(), command.getMaturityDefaultInterestRate());
|
||||
baseDataValidator.reset().comapareMinAndMaxOfTwoBigDecmimalNos(command.getPreClosureInterestRate(), command.getMaturityMinInterestRate());
|
||||
|
||||
|
||||
|
||||
if (!dataValidationErrors.isEmpty()) {
|
||||
throw new PlatformApiDataValidationException("validation.msg.validation.errors.exist", "Validation errors exist.", dataValidationErrors);
|
||||
@@ -78,6 +84,10 @@ public class DepositProductCommandValidator {
|
||||
baseDataValidator.reset().parameter("preClosureInterestRate").value(command.getPreClosureInterestRate()).zeroOrPositiveAmount();
|
||||
|
||||
baseDataValidator.reset().comapareMinimumAndMaximumAmounts(command.getMinimumBalance(), command.getMaximumBalance());
|
||||
baseDataValidator.reset().comapareMinAndMaxOfTwoBigDecmimalNos(command.getMaturityMinInterestRate(), command.getMaturityMaxInterestRate());
|
||||
baseDataValidator.reset().comapareMinAndMaxOfTwoBigDecmimalNos(command.getMaturityDefaultInterestRate(), command.getMaturityMaxInterestRate());
|
||||
baseDataValidator.reset().comapareMinAndMaxOfTwoBigDecmimalNos(command.getMaturityMinInterestRate(), command.getMaturityDefaultInterestRate());
|
||||
baseDataValidator.reset().comapareMinAndMaxOfTwoBigDecmimalNos(command.getPreClosureInterestRate(), command.getMaturityMinInterestRate());
|
||||
|
||||
baseDataValidator.reset().anyOfNotNull(command.getName(), command.getDescription(),command.getCurrencyCode(),command.getDigitsAfterDecimal(),command.getMinimumBalance(),command.getMaximumBalance(),command.getTenureMonths(),command.getMaturityDefaultInterestRate(),command.getMaturityMaxInterestRate(),command.getMaturityMinInterestRate(),command.getCanRenew(),command.getCanPreClose(),command.getPreClosureInterestRate());
|
||||
|
||||
|
||||
+18
-4
@@ -38,7 +38,7 @@ public class DepositProductReadPlatformServiceImpl implements
|
||||
public Collection<DepositProductData> retrieveAllDepositProducts() {
|
||||
this.context.authenticatedUser();
|
||||
DepositProductMapper depositProductMapper= new DepositProductMapper();
|
||||
String sql= "select " + depositProductMapper.depositProductSchema() + " where dp.is_deleted=0";
|
||||
String sql="select "+depositProductMapper.depositProductSchema() + " where dp.is_deleted=0";
|
||||
return this.jdbcTemplate.query(sql,depositProductMapper, new Object[]{});
|
||||
}
|
||||
|
||||
@@ -70,7 +70,9 @@ public class DepositProductReadPlatformServiceImpl implements
|
||||
private static final class DepositProductMapper implements RowMapper<DepositProductData>{
|
||||
|
||||
public String depositProductSchema(){
|
||||
return "dp.id as id,dp.name as name, dp.description as description,dp.currency_code as currencyCode, dp.currency_digits as currencyDigits,dp.minimum_balance as minimumBalance,dp.maximum_balance as maximumBalance,dp.created_date as createdon, dp.lastmodified_date as modifiedon, " +
|
||||
return "dp.id as id,dp.name as name, dp.description as description,dp.currency_code as currencyCode, dp.currency_digits as currencyDigits,dp.minimum_balance as minimumBalance,dp.maximum_balance as maximumBalance," +
|
||||
"dp.created_date as createdon, dp.lastmodified_date as modifiedon,dp.tenure_months as tenureMonths, dp.maturity_default_interest_rate as maturityDefaultInterestRate, " +
|
||||
"dp.maturity_min_interest_rate as maturityMinInterestRate, dp.maturity_max_interest_rate as maturityMaxInterestRate, dp.can_renew as canRenew, dp.can_pre_close as canPreClose, dp.pre_closure_interest_rate as preClosureInterestRate, " +
|
||||
"curr.name as currencyName, curr.internationalized_name_code as currencyNameCode, curr.display_symbol as currencyDisplaySymbol " +
|
||||
"from portfolio_product_deposit dp join ref_currency curr on curr.code = dp.currency_code ";
|
||||
}
|
||||
@@ -91,7 +93,19 @@ public class DepositProductReadPlatformServiceImpl implements
|
||||
|
||||
BigDecimal minimumBalance=rs.getBigDecimal("minimumBalance");
|
||||
BigDecimal maximumBalance=rs.getBigDecimal("maximumBalance");
|
||||
return new DepositProductData(createdOn, lastModifedOn, id, name, description, currencyCode, currencyDigits, minimumBalance, maximumBalance);
|
||||
|
||||
Integer tenureMonths = JdbcSupport.getInteger(rs, "tenureMonths");
|
||||
BigDecimal maturityDefaultInterestRate=rs.getBigDecimal("maturityDefaultInterestRate");
|
||||
BigDecimal maturityMinInterestRate= rs.getBigDecimal("maturityMinInterestRate");
|
||||
BigDecimal maturityMaxInterestRate = rs.getBigDecimal("maturityMaxInterestRate");
|
||||
|
||||
Boolean canRenew = rs.getBoolean("canRenew");
|
||||
Boolean canPreClose=rs.getBoolean("canPreClose");
|
||||
|
||||
BigDecimal preClosureInterestRate=rs.getBigDecimal("preClosureInterestRate");
|
||||
|
||||
return new DepositProductData(createdOn, lastModifedOn, id, name, description, currencyCode, currencyDigits, minimumBalance, maximumBalance,
|
||||
tenureMonths, maturityDefaultInterestRate,maturityMinInterestRate,maturityMaxInterestRate,canRenew,canPreClose,preClosureInterestRate);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -118,4 +132,4 @@ public class DepositProductReadPlatformServiceImpl implements
|
||||
List<CurrencyData> currencyOptions = currencyReadPlatformService.retrieveAllowedCurrencies();
|
||||
productData.setCurrencyOptions(currencyOptions);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user