Skip to content

Commit

Permalink
Fixing the issues for bulk update (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sahil-tarento authored Oct 22, 2024
1 parent 3069f79 commit 0eca0eb
Showing 1 changed file with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -772,6 +772,7 @@ public void processBulkUploadV1(HashMap<String, String> inputDataMap) throws IOE
}

Map<String, Object> userDetailsForMobile = null;
Map<String, Object> userDetailsForMobileAndEmail = null;
Map<String, Object> filters = null;
boolean isEmailOrPhoneNumberExist = false;
boolean isEmailValid = false;
Expand Down Expand Up @@ -803,10 +804,10 @@ public void processBulkUploadV1(HashMap<String, String> inputDataMap) throws IOE
filters = new HashMap<>();
filters.put(Constants.EMAIL, email);
filters.put(Constants.PHONE, phone);
isEmailOrPhoneNumberExist = this.verifyUserRecordExists(filters, userDetails);
isEmailOrPhoneNumberExist = this.verifyUserRecordExists(filters, userDetailsForMobileAndEmail);
}
if (!CollectionUtils.isEmpty(errList)) {
csvValues.put("Error Details", String.join(",", errList));
csvValues.put("Error Details", String.join(tagsDelimiter, errList));
failedRecordsCount++;
totalRecordsCount++;
updatedRecords.add(csvValues);
Expand All @@ -823,7 +824,7 @@ public void processBulkUploadV1(HashMap<String, String> inputDataMap) throws IOE
if (!mdoAdminRootOrgId.equalsIgnoreCase(userRootOrgId)) {
logger.info("The User belongs to a different MDO Organisation");
errList.add("The User belongs to a different MDO Organisation");
csvValues.put("Error Details", String.join(",", errList));
csvValues.put("Error Details", String.join(tagsDelimiter, errList));
failedRecordsCount++;
totalRecordsCount++;
updatedRecords.add(csvValues);
Expand All @@ -832,7 +833,7 @@ public void processBulkUploadV1(HashMap<String, String> inputDataMap) throws IOE
}

if (!CollectionUtils.isEmpty(errList)) {
csvValues.put("Error Details", String.join(",", errList));
csvValues.put("Error Details", String.join(tagsDelimiter, errList));
failedRecordsCount++;
totalRecordsCount++;
updatedRecords.add(csvValues);
Expand Down Expand Up @@ -880,7 +881,7 @@ public void processBulkUploadV1(HashMap<String, String> inputDataMap) throws IOE
if (validateGender(gender)) {
valuesToBeUpdate.put(Constants.GENDER, gender);
} else {
errList.add("Invalid Gender : Gender can be only among one of these " + configuration.getBulkUploadGenderValue());
errList.add("Invalid Gender : Gender can be only among one of these " + String.join("|", configuration.getBulkUploadGenderValue()));
}
}

Expand All @@ -890,7 +891,7 @@ public void processBulkUploadV1(HashMap<String, String> inputDataMap) throws IOE
if (validateCategory(category)) {
valuesToBeUpdate.put(Constants.CATEGORY, category);
} else {
errList.add("Invalid Category : Category can be only among one of these " + configuration.getBulkUploadCategoryValue());
errList.add("Invalid Category : Category can be only among one of these " + String.join("|", configuration.getBulkUploadCategoryValue()));
}
}

Expand Down Expand Up @@ -962,7 +963,7 @@ public void processBulkUploadV1(HashMap<String, String> inputDataMap) throws IOE
}
if (!ValidationUtil.validateTag(tagList)) {
errList.add("Invalid Tag: " + tagStrList +
" Tags are separated by '|' and can contain only alphabets with spaces. e.g., Bihar Circle|Patna Division");
" Tags are separated by ';' and can contain only alphabets with spaces. e.g., Bihar Circle;Patna Division");
}
valuesToBeUpdate.put(Constants.TAG, tagList);
}
Expand All @@ -971,7 +972,7 @@ public void processBulkUploadV1(HashMap<String, String> inputDataMap) throws IOE
if (!CollectionUtils.isEmpty(errList)) {
String statusValue = errList.isEmpty() ? Constants.SUCCESSFUL_UPERCASE : Constants.FAILED_UPPERCASE;
csvValues.put("Status", statusValue);
csvValues.put("Error Details", errList.isEmpty() ? "" : String.join(", ", errList));
csvValues.put("Error Details", errList.isEmpty() ? "" : String.join(tagsDelimiter, errList));
failedRecordsCount++;
totalRecordsCount++;
updatedRecords.add(csvValues);
Expand Down

0 comments on commit 0eca0eb

Please sign in to comment.