From 83ab788c84b12ae4b0fb2f14be389978f8c779be Mon Sep 17 00:00:00 2001 From: Preyea Regmi Date: Sun, 25 Aug 2019 14:53:42 +0900 Subject: [PATCH] Recipient edit mode validation fixes --- .idea/caches/build_file_checksums.ser | Bin 661 -> 662 bytes .../DynamicValidationModel.java | 98 ++++++++++++++---- .../RecipientDetailValidatorV3.java | 20 +++- 3 files changed, 96 insertions(+), 22 deletions(-) diff --git a/.idea/caches/build_file_checksums.ser b/.idea/caches/build_file_checksums.ser index 15c07ec547b26e271b45accf6a8a2013e67e9fa4..9a64583142532ba42b232c1df7ac1918df79b937 100644 GIT binary patch delta 279 zcmbQrI*oP043^`ntI8(M@lO#*EGURcD$UGE(MvB%Ovy_8 zcVATvJI0dK$=-~zN`GH?sw+9QFWy!uw?nMn$f1Nmx;Qntv?#NrGCQ@hATb4Orl!~~ z_Cr(WJPwp>I&eDZn!8j9gSxX-OlWaxQE`l4epzA+)PXURCot+V3Ia)K!F>XM4wU$3 P)Ov5t=qzkp6jT8KCRuA< delta 261 zcmbQnI+b<843>3~bq6NS@wehHPAw_P%u6rUOD{@H$w@6OVql7PTJu@_2OCGo111KB ziUI}(1_77-&MwV=`_3#dBo=|6i| z!XOAVM_PPKZ=CS8uN{wKPXs@3y^*@Egh3#&pa5*LpjEw;3G1QKA9McoUy5^>*;D}l D8vbQ? diff --git a/app/src/main/java/com/gmeremit/online/gmeremittance_native/recipientV3/model/recipientaddeditV3/dynamicvalidation/DynamicValidationModel.java b/app/src/main/java/com/gmeremit/online/gmeremittance_native/recipientV3/model/recipientaddeditV3/dynamicvalidation/DynamicValidationModel.java index f4d3c577..7c2ac8b3 100644 --- a/app/src/main/java/com/gmeremit/online/gmeremittance_native/recipientV3/model/recipientaddeditV3/dynamicvalidation/DynamicValidationModel.java +++ b/app/src/main/java/com/gmeremit/online/gmeremittance_native/recipientV3/model/recipientaddeditV3/dynamicvalidation/DynamicValidationModel.java @@ -81,8 +81,19 @@ public class DynamicValidationModel { this.proviences = proviences; } + + //TODO remo mock branch + private List mockBranches() { + + List mockedBranches = new ArrayList<>(); + mockedBranches.add("Mocked Branch 1"); + mockedBranches.add("Mocked Branch 2"); + + return mockedBranches; + } + public List getAvailableBranchFromSelectedBank(String id) { - return mockBranches(); + return mockBranches(); // if(id==null||id.length()<1) // return null; // for(PaymentBankModel bank:paymentBankList) @@ -94,35 +105,86 @@ public class DynamicValidationModel { } - private List mockBranches() { - List mockedBranches=new ArrayList<>(); - mockedBranches.add("Mocked Branch 1"); - mockedBranches.add("Mocked Branch 2"); + public List getAvailableDistrictFromSelectedProvinceId(String id) { + if (id == null || id.length() < 1) + return null; + for (PayoutProvincesModel provincesList : proviences) { + if (id.equalsIgnoreCase(provincesList.getId())) + return provincesList.getDistricts(); + } + return null; + } + + public DropDownDTO getTransferReasonFromId(String id) { + if (id == null || id.length() < 1 || transferReasonList == null) + return null; + for (DropDownDTO transferReason : transferReasonList) { + if (id.equalsIgnoreCase(transferReason.getId())) + return transferReason; + } + return null; - return mockedBranches; } - public List getAvailableDistrictFromSelectedProvinceId(String id) { - if(id==null||id.length()<1) + public DropDownDTO getRelationFromId(String id) { + if (id == null || id.length() < 1 || relationsList == null) return null; - for(PayoutProvincesModel provincesList:proviences) - { - if(id.equalsIgnoreCase(provincesList.getId())) - return provincesList.getDistricts(); + for (DropDownDTO relation : relationsList) { + if (id.equalsIgnoreCase(relation.getId())) + return relation; } return null; + } - public DropDownDTO getTransferReasonFromId(String purposeOfRemitId) { - if(purposeOfRemitId==null||purposeOfRemitId.length()<1||transferReasonList==null) + public PaymentBankModel getBankFromId(String id) { + if (id == null || id.length() < 1 || paymentBankList == null) + return null; + for (PaymentBankModel bank : paymentBankList) { + if (id.equalsIgnoreCase(bank.getId())) + return bank; + } return null; - for(DropDownDTO transferReason:transferReasonList) - { - if(purposeOfRemitId.equalsIgnoreCase(transferReason.getId())) - return transferReason; + } + + public PayoutProvincesModel getProvinceFromId(String id) { + if (id == null || id.length() < 1 || proviences == null) + return null; + for (PayoutProvincesModel province : proviences) { + if (id.equalsIgnoreCase(province.getId())) + return province; + } + return null; + + } + + public DropDownDTO getIDTypeFromId(String id) { + if (id == null || id.length() < 1 || receiverIdTypeList == null) + return null; + for (DropDownDTO idType : receiverIdTypeList) { + if (id.equalsIgnoreCase(idType.getId())) + return idType; } return null; } + + + public DropDownDTO getDistrictFromId(String stateId, String districtId) { + if (stateId == null || stateId.length() < 1 || districtId == null || districtId.length() < 1 || proviences == null) + return null; + + PayoutProvincesModel selectedProvince = getProvinceFromId(stateId); + + if (selectedProvince == null) + return null; + else { + for (DropDownDTO district : selectedProvince.getDistricts()) { + if (districtId.equalsIgnoreCase(district.getId())) + return district; + } + } + return null; + } } diff --git a/app/src/main/java/com/gmeremit/online/gmeremittance_native/recipientV3/presenter/recipientaddeditV3/RecipientDetailValidatorV3.java b/app/src/main/java/com/gmeremit/online/gmeremittance_native/recipientV3/presenter/recipientaddeditV3/RecipientDetailValidatorV3.java index 9fad417d..ff266723 100644 --- a/app/src/main/java/com/gmeremit/online/gmeremittance_native/recipientV3/presenter/recipientaddeditV3/RecipientDetailValidatorV3.java +++ b/app/src/main/java/com/gmeremit/online/gmeremittance_native/recipientV3/presenter/recipientaddeditV3/RecipientDetailValidatorV3.java @@ -350,7 +350,6 @@ public class RecipientDetailValidatorV3 { switch (rule.getField()) { case FIELD_BANK_NAME: - break; case FIELD_BRANCH_NAME: @@ -366,7 +365,7 @@ public class RecipientDetailValidatorV3 { break; case FIELD_ID_TYPE: - + updateIdType(getAvailableDynamicValidationModel().getIDTypeFromId(recipientInfo.getIdType())); break; case FIELD_ID_NUMBER: @@ -413,11 +412,11 @@ public class RecipientDetailValidatorV3 { break; case FIELD_PROVINCE: - + updateProvince(getAvailableDynamicValidationModel().getProvinceFromId(recipientInfo.getStateId())); break; case FIELD_DISTRICT: - + updateDistrict(getAvailableDynamicValidationModel().getDistrictFromId(recipientInfo.getStateId(), recipientInfo.getDistrictId())); break; case FIELD_CITY: @@ -429,6 +428,7 @@ public class RecipientDetailValidatorV3 { break; case FIELD_REALATION_GROUP: + updateRelation(getAvailableDynamicValidationModel().getRelationFromId(recipientInfo.getRelationshipId())); break; case FIELD_TRANSFER_REASON: @@ -719,6 +719,8 @@ public class RecipientDetailValidatorV3 { } public void updateBank(PaymentBankModel selectedBank) { + if (selectedBank == null) + return; ValidationRuleModel validationRuleModel = validationRuleModelMap.get(FIELD_BANK_NAME); if (validationRuleModel != null) { recipientInfo.updateSelectedBank(selectedBank); @@ -728,6 +730,8 @@ public class RecipientDetailValidatorV3 { } public void updateBranch(String selectedBranch) { + if (selectedBranch == null) + return; ValidationRuleModel validationRuleModel = validationRuleModelMap.get(FIELD_BRANCH_NAME); if (validationRuleModel != null) { recipientInfo.updateBranch(selectedBranch); @@ -737,6 +741,8 @@ public class RecipientDetailValidatorV3 { } public void updateProvince(PayoutProvincesModel selectedProvinces) { + if (selectedProvinces == null) + return; ValidationRuleModel validationRuleModel = validationRuleModelMap.get(FIELD_PROVINCE); if (validationRuleModel != null) { recipientInfo.updateProvince(selectedProvinces); @@ -746,6 +752,8 @@ public class RecipientDetailValidatorV3 { } public void updateDistrict(DropDownDTO selectedDistrict) { + if (selectedDistrict == null) + return; ValidationRuleModel validationRuleModel = validationRuleModelMap.get(FIELD_DISTRICT); if (validationRuleModel != null) { recipientInfo.updateDistrict(selectedDistrict); @@ -767,6 +775,8 @@ public class RecipientDetailValidatorV3 { } public void updateIdType(DropDownDTO selectedIDType) { + if (selectedIDType == null) + return; ValidationRuleModel validationRuleModel = validationRuleModelMap.get(FIELD_ID_TYPE); if (validationRuleModel != null) { recipientInfo.updateIdType(selectedIDType); @@ -776,6 +786,8 @@ public class RecipientDetailValidatorV3 { } public void updateRelation(DropDownDTO selectedRelation) { + if (selectedRelation == null) + return; ValidationRuleModel validationRuleModel = validationRuleModelMap.get(FIELD_REALATION_GROUP); if (validationRuleModel != null) { recipientInfo.updateRelation(selectedRelation);