Skip to content

Commit

Permalink
4.8.15 dev v4 (#635)
Browse files Browse the repository at this point in the history
* updated code for user bulk upload

* added code for process both csv and xlsx

* added code for process both csv and xlsx

* added code for process both csv and xlsx
  • Loading branch information
anilkumarkammalapalli authored Jul 4, 2024
1 parent 1519379 commit ff346c9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/main/java/org/sunbird/common/util/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -1097,6 +1097,8 @@ public class Constants {
public static final String SEARCH_COMPETENCY_SUB_THEMES = "competencySubTheme";
public static final String MCQ_MCA_W = "mcq-mca-w";
public static final String MCQ_SCA_TF = "mcq-sca-tf";
public static final String CSV_FILE = ".csv";
public static final String XLSX_FILE = ".xlsx";

private Constants() {
throw new IllegalStateException("Utility class");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,19 @@ public void initiateUserBulkUploadProcess(String inputData) {
if (errList.isEmpty()) {
updateUserBulkUploadStatus(inputDataMap.get(Constants.ROOT_ORG_ID),
inputDataMap.get(Constants.IDENTIFIER), Constants.STATUS_IN_PROGRESS_UPPERCASE, 0, 0, 0);
storageService.downloadFile(inputDataMap.get(Constants.FILE_NAME));
//processBulkUpload(inputDataMap);
processCSVBulkUploadV2(inputDataMap);
String fileName = inputDataMap.get(Constants.FILE_NAME);
logger.info("fileName {} ", fileName);
storageService.downloadFile(fileName);
switch (getFileExtension(fileName)) {
case Constants.CSV_FILE:
processCSVBulkUploadV2(inputDataMap);
break;
case Constants.XLSX_FILE:
processBulkUpload(inputDataMap);
break;
default:
logger.error("Unsupported file type: {}", fileName);
}
} else {
logger.error(String.format("Error in the Kafka Message Received : %s", errList));
}
Expand Down Expand Up @@ -788,5 +798,9 @@ private boolean validateFieldValue(String fieldKey, String fieldValue) {
return !designationsSet.contains(fieldValue);
}
}
private String getFileExtension(String fileName) {
int lastIndexOfDot= fileName.lastIndexOf('.');
return lastIndexOfDot == -1 ? "" : fileName.substring(lastIndexOfDot);
}

}

0 comments on commit ff346c9

Please sign in to comment.