Handle exception for retrieving non existed resource for deposit product
This commit is contained in:
+88
-10
@@ -1041,16 +1041,26 @@
|
|||||||
<td><a href="#audit_searchtemplate">Retrieve Audit
|
<td><a href="#audit_searchtemplate">Retrieve Audit
|
||||||
Search Data</a></td>
|
Search Data</a></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="alt">
|
<tr>
|
||||||
<td>depositproducts/template</td>
|
<td>depositproducts/template</td>
|
||||||
<td><a href="#depositproducts_template">Retrieve Deposit
|
<td><a href="#depositproducts_template">Retrieve Deposit
|
||||||
Product Details Template</a></td>
|
Product Details Template</a></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="alt">
|
<tr class="alt">
|
||||||
<td>loanproducts/template</td>
|
<td>savingproducts/template</td>
|
||||||
<td><a href="#savingproducts_template">Retrieve Saving
|
<td><a href="#savingproducts_template">Retrieve Saving
|
||||||
Product Details Template</a></td>
|
Product Details Template</a></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>depositaccounts/template</td>
|
||||||
|
<td><a href="#fixeddeposits_template">Retrieve Deposit
|
||||||
|
Account Details Template</a></td>
|
||||||
|
</tr>
|
||||||
|
<tr class="alt">
|
||||||
|
<td>savingaccounts/template</td>
|
||||||
|
<td><a href="#savingaccounts_template">Retrieve Saving
|
||||||
|
Account Details Template</a></td>
|
||||||
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -1102,14 +1112,6 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</table></td>
|
</table></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="alt">
|
|
||||||
<td>Work in Progress</a></td>
|
|
||||||
<td></td>
|
|
||||||
<td></td>
|
|
||||||
<td></td>
|
|
||||||
<td></td>
|
|
||||||
<td></td>
|
|
||||||
</tr>
|
|
||||||
<tr class="alt">
|
<tr class="alt">
|
||||||
<td><a href="#fixeddeposits">FIXED DEPOSITS</a></td>
|
<td><a href="#fixeddeposits">FIXED DEPOSITS</a></td>
|
||||||
<td>depositaccounts</td>
|
<td>depositaccounts</td>
|
||||||
@@ -11291,6 +11293,82 @@ Content-Type: application/json
|
|||||||
<td></td>
|
<td></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr class="alt">
|
||||||
|
<td><a href="#depositproducts">DEPOSIT PRODUCT</a></td>
|
||||||
|
<td>depositproducts</td>
|
||||||
|
<td><a href="#depositproducts_create">Create a Deposit product</a></td>
|
||||||
|
<td><a href="#depositproducts_list">List Deposit products</a></td>
|
||||||
|
<td></td>
|
||||||
|
<td></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td></td>
|
||||||
|
<td>depositproducts/{prodcutId}</td>
|
||||||
|
<td></td>
|
||||||
|
<td><a href="#depositproducts_retrieve">Retrieve a Deposit product</a></td>
|
||||||
|
<td><a href="#depositproducts_update">Update a Deposit product</a></td>
|
||||||
|
<td><a href="#depositproducts_delete">Delete a Deposit product</a></td>
|
||||||
|
</tr>
|
||||||
|
<tr class="alt">
|
||||||
|
<td><a href="#savingproducts">SAVING PRODUCT</a></td>
|
||||||
|
<td>savingproducts</td>
|
||||||
|
<td><a href="#savingproducts_create">Create a Saving product</a></td>
|
||||||
|
<td><a href="#savingproducts_list">List Saving products</a></td>
|
||||||
|
<td></td>
|
||||||
|
<td></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td></td>
|
||||||
|
<td>savingproducts/{prodcutId}</td>
|
||||||
|
<td></td>
|
||||||
|
<td><a href="#savingproducts_retrieve">Retrieve a Saving procduct</a></td>
|
||||||
|
<td><a href="#savingproducts_update">Update a Saving product</a></td>
|
||||||
|
<td><a href="#savingproducts_delete">Delete a Saving product</a></td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr class="alt">
|
||||||
|
<td><a href="#fixeddeposits">FIXED DEPOSITS</a></td>
|
||||||
|
<td>depositaccounts</td>
|
||||||
|
<td><a href="#fixeddeposits_create">Create a New Deposit
|
||||||
|
Application</a></td>
|
||||||
|
<td></td>
|
||||||
|
<td></td>
|
||||||
|
<td></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td></td>
|
||||||
|
<td>depositaccounts/{accountId}</td>
|
||||||
|
<td><a href="#fixeddeposits_approve_etc">Approve, Undo Approve,
|
||||||
|
Interest withdraw, Reject a Deposit Application or Withdraw a
|
||||||
|
Deposit Application</a></td>
|
||||||
|
<td><a href="#fixeddeposits_retrieve">Retrieve a Deposit
|
||||||
|
Application</a></td>
|
||||||
|
<td></td>
|
||||||
|
<td><a href="#fixeddeposits_delete">Delete a Deposit
|
||||||
|
Application</a></td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr class="alt">
|
||||||
|
<td><a href="#savingaccounts">SAVING ACCOUNTS</a></td>
|
||||||
|
<td>savingaccounts</td>
|
||||||
|
<td><a href="#savingaccounts_create">Create a New Saving
|
||||||
|
Application</a></td>
|
||||||
|
<td></td>
|
||||||
|
<td></td>
|
||||||
|
<td></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td></td>
|
||||||
|
<td>savingaccounts/{accountId}</td>
|
||||||
|
<td><a href="#savingaccounts_approve_etc">Approve, Undo Approve,
|
||||||
|
Interest withdraw, Reject a Saving Application or Withdraw a
|
||||||
|
Saving Application</a></td>
|
||||||
|
<td><a href="#savingaccounts_retrieve">Retrieve a Saving
|
||||||
|
Application</a></td>
|
||||||
|
<td></td>
|
||||||
|
<td><a href="#savingaccounts_delete">Delete a Saving
|
||||||
|
Application</a></td>
|
||||||
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
<br>
|
<br>
|
||||||
<table class=matrixHeading>
|
<table class=matrixHeading>
|
||||||
|
|||||||
-4
@@ -37,7 +37,6 @@ import org.mifosplatform.organisation.monetary.service.CurrencyReadPlatformServi
|
|||||||
import org.mifosplatform.portfolio.loanproduct.domain.PeriodFrequencyType;
|
import org.mifosplatform.portfolio.loanproduct.domain.PeriodFrequencyType;
|
||||||
import org.mifosplatform.portfolio.savingsaccountproduct.service.SavingsDepositEnumerations;
|
import org.mifosplatform.portfolio.savingsaccountproduct.service.SavingsDepositEnumerations;
|
||||||
import org.mifosplatform.portfolio.savingsdepositproduct.data.DepositProductData;
|
import org.mifosplatform.portfolio.savingsdepositproduct.data.DepositProductData;
|
||||||
import org.mifosplatform.portfolio.savingsdepositproduct.exception.DepositProductNotFoundException;
|
|
||||||
import org.mifosplatform.portfolio.savingsdepositproduct.service.DepositProductReadPlatformService;
|
import org.mifosplatform.portfolio.savingsdepositproduct.service.DepositProductReadPlatformService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.Scope;
|
import org.springframework.context.annotation.Scope;
|
||||||
@@ -133,9 +132,6 @@ public class DepositProductsApiResource {
|
|||||||
|
|
||||||
context.authenticatedUser().validateHasReadPermission(entityType);
|
context.authenticatedUser().validateHasReadPermission(entityType);
|
||||||
DepositProductData productData = this.depositProductReadPlatformService.retrieveDepositProductData(productId);
|
DepositProductData productData = this.depositProductReadPlatformService.retrieveDepositProductData(productId);
|
||||||
if (productData.isDeleted()) {
|
|
||||||
throw new DepositProductNotFoundException(productId);
|
|
||||||
}
|
|
||||||
final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
||||||
|
|
||||||
if (settings.isTemplate()) {
|
if (settings.isTemplate()) {
|
||||||
|
|||||||
+1
-9
@@ -45,7 +45,6 @@ public class DepositProductData {
|
|||||||
|
|
||||||
private final Collection<CurrencyData> currencyOptions;
|
private final Collection<CurrencyData> currencyOptions;
|
||||||
private final List<EnumOptionData> interestCompoundedEveryPeriodTypeOptions;
|
private final List<EnumOptionData> interestCompoundedEveryPeriodTypeOptions;
|
||||||
private final Boolean isDeleted;
|
|
||||||
|
|
||||||
public DepositProductData(final Long id, final String externalId,
|
public DepositProductData(final Long id, final String externalId,
|
||||||
final String name, final String description, final String currencyCode, final Integer digitsAfterDecimal,
|
final String name, final String description, final String currencyCode, final Integer digitsAfterDecimal,
|
||||||
@@ -54,7 +53,7 @@ public class DepositProductData {
|
|||||||
final BigDecimal maturityMaxInterestRate, final Integer interestCompoundedEvery,
|
final BigDecimal maturityMaxInterestRate, final Integer interestCompoundedEvery,
|
||||||
final EnumOptionData interestCompoundedEveryPeriodType, final boolean renewalAllowed, final boolean preClosureAllowed,
|
final EnumOptionData interestCompoundedEveryPeriodType, final boolean renewalAllowed, final boolean preClosureAllowed,
|
||||||
final BigDecimal preClosureInterestRate, final boolean interestCompoundingAllowed, final boolean isLockinPeriodAllowed,
|
final BigDecimal preClosureInterestRate, final boolean interestCompoundingAllowed, final boolean isLockinPeriodAllowed,
|
||||||
final Integer lockinPeriod, final EnumOptionData lockinPeriodType,final CurrencyData currencyData, final Boolean isDeleted) {
|
final Integer lockinPeriod, final EnumOptionData lockinPeriodType,final CurrencyData currencyData) {
|
||||||
|
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.externalId = externalId;
|
this.externalId = externalId;
|
||||||
@@ -82,7 +81,6 @@ public class DepositProductData {
|
|||||||
this.currency = currencyData;
|
this.currency = currencyData;
|
||||||
this.currencyOptions = null;
|
this.currencyOptions = null;
|
||||||
this.interestCompoundedEveryPeriodTypeOptions = null;
|
this.interestCompoundedEveryPeriodTypeOptions = null;
|
||||||
this.isDeleted = isDeleted;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public DepositProductData(final Collection<CurrencyData> currencyOptions,
|
public DepositProductData(final Collection<CurrencyData> currencyOptions,
|
||||||
@@ -117,7 +115,6 @@ public class DepositProductData {
|
|||||||
|
|
||||||
this.currencyOptions = currencyOptions;
|
this.currencyOptions = currencyOptions;
|
||||||
this.interestCompoundedEveryPeriodTypeOptions = interestCompoundedEveryPeriodTypeOptions;
|
this.interestCompoundedEveryPeriodTypeOptions = interestCompoundedEveryPeriodTypeOptions;
|
||||||
this.isDeleted = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public DepositProductData(final DepositProductData product, final Collection<CurrencyData> currencyOptions,
|
public DepositProductData(final DepositProductData product, final Collection<CurrencyData> currencyOptions,
|
||||||
@@ -156,7 +153,6 @@ public class DepositProductData {
|
|||||||
this.currency = product.currency;
|
this.currency = product.currency;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.isDeleted = product.isDeleted;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getId() {
|
public Long getId() {
|
||||||
@@ -251,8 +247,4 @@ public class DepositProductData {
|
|||||||
return lockinPeriodType;
|
return lockinPeriodType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean isDeleted() {
|
|
||||||
return this.isDeleted;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
+12
-7
@@ -20,7 +20,9 @@ import org.mifosplatform.portfolio.loanproduct.domain.PeriodFrequencyType;
|
|||||||
import org.mifosplatform.portfolio.savingsaccountproduct.service.SavingsDepositEnumerations;
|
import org.mifosplatform.portfolio.savingsaccountproduct.service.SavingsDepositEnumerations;
|
||||||
import org.mifosplatform.portfolio.savingsdepositproduct.data.DepositProductData;
|
import org.mifosplatform.portfolio.savingsdepositproduct.data.DepositProductData;
|
||||||
import org.mifosplatform.portfolio.savingsdepositproduct.data.DepositProductLookup;
|
import org.mifosplatform.portfolio.savingsdepositproduct.data.DepositProductLookup;
|
||||||
|
import org.mifosplatform.portfolio.savingsdepositproduct.exception.DepositProductNotFoundException;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.dao.EmptyResultDataAccessException;
|
||||||
import org.springframework.jdbc.core.JdbcTemplate;
|
import org.springframework.jdbc.core.JdbcTemplate;
|
||||||
import org.springframework.jdbc.core.RowMapper;
|
import org.springframework.jdbc.core.RowMapper;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@@ -58,10 +60,14 @@ public class DepositProductReadPlatformServiceImpl implements DepositProductRead
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DepositProductData retrieveDepositProductData(Long productId) {
|
public DepositProductData retrieveDepositProductData(Long productId) {
|
||||||
DepositProductMapper depositProductMapper = new DepositProductMapper();
|
try{
|
||||||
String sql = "select " + depositProductMapper.depositProductSchema() + " where dp.id = ? ";
|
this.context.authenticatedUser();
|
||||||
|
DepositProductMapper depositProductMapper = new DepositProductMapper();
|
||||||
return this.jdbcTemplate.queryForObject(sql, depositProductMapper, new Object[] { productId });
|
String sql = "select " + depositProductMapper.depositProductSchema() + " where dp.id = ? and dp.is_deleted=0";
|
||||||
|
return this.jdbcTemplate.queryForObject(sql, depositProductMapper, new Object[] { productId });
|
||||||
|
} catch (EmptyResultDataAccessException e){
|
||||||
|
throw new DepositProductNotFoundException(productId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -84,7 +90,7 @@ public class DepositProductReadPlatformServiceImpl implements DepositProductRead
|
|||||||
+ "dp.maturity_min_interest_rate as maturityMinInterestRate, dp.maturity_max_interest_rate as maturityMaxInterestRate, "
|
+ "dp.maturity_min_interest_rate as maturityMinInterestRate, dp.maturity_max_interest_rate as maturityMaxInterestRate, "
|
||||||
+ "dp.is_renewal_allowed as canRenew, dp.is_preclosure_allowed as canPreClose, dp.pre_closure_interest_rate as preClosureInterestRate, "
|
+ "dp.is_renewal_allowed as canRenew, dp.is_preclosure_allowed as canPreClose, dp.pre_closure_interest_rate as preClosureInterestRate, "
|
||||||
+ "dp.is_lock_in_period_allowed as isLockinPeriodAllowed, dp.lock_in_period as lockinPeriod, dp.lock_in_period_type as lockinPeriodType, "
|
+ "dp.is_lock_in_period_allowed as isLockinPeriodAllowed, dp.lock_in_period as lockinPeriod, dp.lock_in_period_type as lockinPeriodType, "
|
||||||
+ "curr.name as currencyName, curr.internationalized_name_code as currencyNameCode, curr.display_symbol as currencyDisplaySymbol, dp.is_deleted as isDeleted "
|
+ "curr.name as currencyName, curr.internationalized_name_code as currencyNameCode, curr.display_symbol as currencyDisplaySymbol "
|
||||||
+ "from m_product_deposit dp join m_currency curr on curr.code = dp.currency_code ";
|
+ "from m_product_deposit dp join m_currency curr on curr.code = dp.currency_code ";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -126,12 +132,11 @@ public class DepositProductReadPlatformServiceImpl implements DepositProductRead
|
|||||||
Integer lockinPeriod = JdbcSupport.getInteger(rs, "lockinPeriod");
|
Integer lockinPeriod = JdbcSupport.getInteger(rs, "lockinPeriod");
|
||||||
Integer lockinPeriodTypeValue = JdbcSupport.getInteger(rs, "lockinPeriodType");
|
Integer lockinPeriodTypeValue = JdbcSupport.getInteger(rs, "lockinPeriodType");
|
||||||
EnumOptionData lockinPeriodType = SavingsDepositEnumerations.interestCompoundingPeriodType(lockinPeriodTypeValue);
|
EnumOptionData lockinPeriodType = SavingsDepositEnumerations.interestCompoundingPeriodType(lockinPeriodTypeValue);
|
||||||
Boolean isDeleted = rs.getBoolean("isDeleted");
|
|
||||||
|
|
||||||
return new DepositProductData(id, exernalId, name, description, currencyCode, currencyDigits,
|
return new DepositProductData(id, exernalId, name, description, currencyCode, currencyDigits,
|
||||||
minimumBalance, maximumBalance, tenureMonths, maturityDefaultInterestRate, maturityMinInterestRate,
|
minimumBalance, maximumBalance, tenureMonths, maturityDefaultInterestRate, maturityMinInterestRate,
|
||||||
maturityMaxInterestRate, interestCompoundedEvery, interestCompoundedEveryPeriodType, canRenew, canPreClose,
|
maturityMaxInterestRate, interestCompoundedEvery, interestCompoundedEveryPeriodType, canRenew, canPreClose,
|
||||||
preClosureInterestRate, interestCompoundingAllowed, isLockinPeriodAllowed, lockinPeriod, lockinPeriodType, currencyData,isDeleted);
|
preClosureInterestRate, interestCompoundingAllowed, isLockinPeriodAllowed, lockinPeriod, lockinPeriodType, currencyData);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user