added check for blank feilds
This commit is contained in:
+38
-19
@@ -227,22 +227,28 @@ public class LoanProduct extends AbstractPersistable<Long> {
|
||||
BigDecimal maxValue = null;
|
||||
Integer cycleNumber = null;
|
||||
Integer valueUsageCondition = null;
|
||||
if (jsonObject.has(LoanProductConstants.defaultValueParameterName) && jsonObject.get(LoanProductConstants.defaultValueParameterName).isJsonPrimitive()) {
|
||||
if (jsonObject.has(LoanProductConstants.defaultValueParameterName)
|
||||
&& jsonObject.get(LoanProductConstants.defaultValueParameterName).isJsonPrimitive()) {
|
||||
defaultValue = jsonObject.getAsJsonPrimitive(LoanProductConstants.defaultValueParameterName).getAsBigDecimal();
|
||||
}
|
||||
if (jsonObject.has(LoanProductConstants.minValueParameterName) && jsonObject.get(LoanProductConstants.minValueParameterName).isJsonPrimitive()) {
|
||||
if (jsonObject.has(LoanProductConstants.minValueParameterName)
|
||||
&& jsonObject.get(LoanProductConstants.minValueParameterName).isJsonPrimitive()) {
|
||||
minValue = jsonObject.getAsJsonPrimitive(LoanProductConstants.minValueParameterName).getAsBigDecimal();
|
||||
}
|
||||
if (jsonObject.has(LoanProductConstants.maxValueParameterName) && jsonObject.get(LoanProductConstants.maxValueParameterName).isJsonPrimitive()) {
|
||||
if (jsonObject.has(LoanProductConstants.maxValueParameterName)
|
||||
&& jsonObject.get(LoanProductConstants.maxValueParameterName).isJsonPrimitive()) {
|
||||
maxValue = jsonObject.getAsJsonPrimitive(LoanProductConstants.maxValueParameterName).getAsBigDecimal();
|
||||
}
|
||||
if (jsonObject.has(LoanProductConstants.borrowerCycleNumberParamName) && jsonObject.get(LoanProductConstants.borrowerCycleNumberParamName).isJsonPrimitive()) {
|
||||
if (jsonObject.has(LoanProductConstants.borrowerCycleNumberParamName)
|
||||
&& jsonObject.get(LoanProductConstants.borrowerCycleNumberParamName).isJsonPrimitive()) {
|
||||
cycleNumber = jsonObject.getAsJsonPrimitive(LoanProductConstants.borrowerCycleNumberParamName).getAsInt();
|
||||
}
|
||||
if (jsonObject.has(LoanProductConstants.valueConditionTypeParamName) && jsonObject.get(LoanProductConstants.valueConditionTypeParamName).isJsonPrimitive()) {
|
||||
if (jsonObject.has(LoanProductConstants.valueConditionTypeParamName)
|
||||
&& jsonObject.get(LoanProductConstants.valueConditionTypeParamName).isJsonPrimitive()) {
|
||||
valueUsageCondition = jsonObject.getAsJsonPrimitive(LoanProductConstants.valueConditionTypeParamName).getAsInt();
|
||||
}
|
||||
LoanProductBorrowerCycleVariations borrowerCycleVariations= new LoanProductBorrowerCycleVariations(cycleNumber, paramType, valueUsageCondition, minValue, maxValue, defaultValue);
|
||||
LoanProductBorrowerCycleVariations borrowerCycleVariations = new LoanProductBorrowerCycleVariations(cycleNumber,
|
||||
paramType, valueUsageCondition, minValue, maxValue, defaultValue);
|
||||
loanProductBorrowerCycleVariations.add(borrowerCycleVariations);
|
||||
i++;
|
||||
} while (i < variationArray.size());
|
||||
@@ -253,14 +259,18 @@ public class LoanProduct extends AbstractPersistable<Long> {
|
||||
private Map<String, Object> updateBorrowerCycleVariations(final JsonCommand command) {
|
||||
final Map<String, Object> actualChanges = new LinkedHashMap<String, Object>(20);
|
||||
List<Long> variationIds = fetchAllVariationIds();
|
||||
updateBorrowerCycleVaritions(command, LoanProductParamType.PRINCIPAL.getValue(), LoanProductConstants.principalVariationsForBorrowerCycleParameterName, actualChanges, variationIds);
|
||||
updateBorrowerCycleVaritions(command, LoanProductParamType.INTERESTRATE.getValue(), LoanProductConstants.interestRateVariationsForBorrowerCycleParameterName, actualChanges, variationIds);
|
||||
updateBorrowerCycleVaritions(command, LoanProductParamType.REPAYMENT.getValue(), LoanProductConstants.numberOfRepaymentVariationsForBorrowerCycleParameterName, actualChanges, variationIds);
|
||||
updateBorrowerCycleVaritions(command, LoanProductParamType.PRINCIPAL.getValue(),
|
||||
LoanProductConstants.principalVariationsForBorrowerCycleParameterName, actualChanges, variationIds);
|
||||
updateBorrowerCycleVaritions(command, LoanProductParamType.INTERESTRATE.getValue(),
|
||||
LoanProductConstants.interestRateVariationsForBorrowerCycleParameterName, actualChanges, variationIds);
|
||||
updateBorrowerCycleVaritions(command, LoanProductParamType.REPAYMENT.getValue(),
|
||||
LoanProductConstants.numberOfRepaymentVariationsForBorrowerCycleParameterName, actualChanges, variationIds);
|
||||
for (Long id : variationIds) {
|
||||
this.borrowerCycleVariations.remove(fetchLoanProductBorrowerCycleVariationById(id));
|
||||
}
|
||||
return actualChanges;
|
||||
}
|
||||
|
||||
private List<Long> fetchAllVariationIds() {
|
||||
List<Long> list = new ArrayList<Long>();
|
||||
for (LoanProductBorrowerCycleVariations cycleVariation : this.borrowerCycleVariations) {
|
||||
@@ -269,8 +279,8 @@ public class LoanProduct extends AbstractPersistable<Long> {
|
||||
return list;
|
||||
}
|
||||
|
||||
private void updateBorrowerCycleVaritions(final JsonCommand command,Integer paramType,
|
||||
String variationParameterName,final Map<String, Object> actualChanges, List<Long> variationIds){
|
||||
private void updateBorrowerCycleVaritions(final JsonCommand command, Integer paramType, String variationParameterName,
|
||||
final Map<String, Object> actualChanges, List<Long> variationIds) {
|
||||
if (command.parameterExists(variationParameterName)) {
|
||||
final JsonArray variationArray = command.arrayOfParameterNamed(variationParameterName);
|
||||
if (variationArray != null && variationArray.size() > 0) {
|
||||
@@ -283,25 +293,35 @@ public class LoanProduct extends AbstractPersistable<Long> {
|
||||
Integer cycleNumber = null;
|
||||
Integer valueUsageCondition = null;
|
||||
Long id = null;
|
||||
if (jsonObject.has(LoanProductConstants.defaultValueParameterName) && jsonObject.get(LoanProductConstants.defaultValueParameterName).isJsonPrimitive()) {
|
||||
if (jsonObject.has(LoanProductConstants.defaultValueParameterName)
|
||||
&& jsonObject.get(LoanProductConstants.defaultValueParameterName).isJsonPrimitive()) {
|
||||
defaultValue = jsonObject.getAsJsonPrimitive(LoanProductConstants.defaultValueParameterName).getAsBigDecimal();
|
||||
}
|
||||
if (jsonObject.has(LoanProductConstants.minValueParameterName) && jsonObject.get(LoanProductConstants.minValueParameterName).isJsonPrimitive()) {
|
||||
if (jsonObject.has(LoanProductConstants.minValueParameterName)
|
||||
&& jsonObject.get(LoanProductConstants.minValueParameterName).isJsonPrimitive()
|
||||
&& StringUtils.isNotBlank((jsonObject.get(LoanProductConstants.minValueParameterName).getAsString()))) {
|
||||
minValue = jsonObject.getAsJsonPrimitive(LoanProductConstants.minValueParameterName).getAsBigDecimal();
|
||||
}
|
||||
if (jsonObject.has(LoanProductConstants.maxValueParameterName) && jsonObject.get(LoanProductConstants.maxValueParameterName).isJsonPrimitive()) {
|
||||
if (jsonObject.has(LoanProductConstants.maxValueParameterName)
|
||||
&& jsonObject.get(LoanProductConstants.maxValueParameterName).isJsonPrimitive()
|
||||
&& StringUtils.isNotBlank((jsonObject.get(LoanProductConstants.maxValueParameterName).getAsString()))) {
|
||||
maxValue = jsonObject.getAsJsonPrimitive(LoanProductConstants.maxValueParameterName).getAsBigDecimal();
|
||||
}
|
||||
if (jsonObject.has(LoanProductConstants.borrowerCycleNumberParamName) && jsonObject.get(LoanProductConstants.borrowerCycleNumberParamName).isJsonPrimitive()) {
|
||||
if (jsonObject.has(LoanProductConstants.borrowerCycleNumberParamName)
|
||||
&& jsonObject.get(LoanProductConstants.borrowerCycleNumberParamName).isJsonPrimitive()) {
|
||||
cycleNumber = jsonObject.getAsJsonPrimitive(LoanProductConstants.borrowerCycleNumberParamName).getAsInt();
|
||||
}
|
||||
if (jsonObject.has(LoanProductConstants.valueConditionTypeParamName) && jsonObject.get(LoanProductConstants.valueConditionTypeParamName).isJsonPrimitive()) {
|
||||
if (jsonObject.has(LoanProductConstants.valueConditionTypeParamName)
|
||||
&& jsonObject.get(LoanProductConstants.valueConditionTypeParamName).isJsonPrimitive()) {
|
||||
valueUsageCondition = jsonObject.getAsJsonPrimitive(LoanProductConstants.valueConditionTypeParamName).getAsInt();
|
||||
}
|
||||
if (jsonObject.has(LoanProductConstants.borrowerCycleIdParameterName) && jsonObject.get(LoanProductConstants.borrowerCycleIdParameterName).isJsonPrimitive()) {
|
||||
if (jsonObject.has(LoanProductConstants.borrowerCycleIdParameterName)
|
||||
&& jsonObject.get(LoanProductConstants.borrowerCycleIdParameterName).isJsonPrimitive()
|
||||
&& StringUtils.isNotBlank((jsonObject.get(LoanProductConstants.borrowerCycleIdParameterName).getAsString()))) {
|
||||
id = jsonObject.getAsJsonPrimitive(LoanProductConstants.borrowerCycleIdParameterName).getAsLong();
|
||||
}
|
||||
LoanProductBorrowerCycleVariations borrowerCycleVariations= new LoanProductBorrowerCycleVariations(cycleNumber, paramType, valueUsageCondition, minValue, maxValue, defaultValue);
|
||||
LoanProductBorrowerCycleVariations borrowerCycleVariations = new LoanProductBorrowerCycleVariations(cycleNumber,
|
||||
paramType, valueUsageCondition, minValue, maxValue, defaultValue);
|
||||
if (id == null) {
|
||||
borrowerCycleVariations.updateLoanProduct(this);
|
||||
this.borrowerCycleVariations.add(borrowerCycleVariations);
|
||||
@@ -320,7 +340,6 @@ public class LoanProduct extends AbstractPersistable<Long> {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void clearVariations(LoanProductParamType paramType, boolean clearAll) {
|
||||
if (clearAll) {
|
||||
this.borrowerCycleVariations.clear();
|
||||
|
||||
Reference in New Issue
Block a user