diff --git a/src/main/java/org/sunbird/common/util/CbExtServerProperties.java b/src/main/java/org/sunbird/common/util/CbExtServerProperties.java index cf231963b..df7eea210 100644 --- a/src/main/java/org/sunbird/common/util/CbExtServerProperties.java +++ b/src/main/java/org/sunbird/common/util/CbExtServerProperties.java @@ -750,6 +750,9 @@ public void setRedisWheeboxKey(String redisWheeboxKey) { @Value("#{${organisation.insights.redis.key.mapping}}") private Map organisationInsightRedisKeyMapping; + @Value("${bulk.upload.allowed.roles.creation}") + private String bulkUploadAllowedRolesCreation; + public boolean qListFromCacheEnabled() { return qListFromCacheEnabled; } @@ -2652,4 +2655,12 @@ public Map getOrganisationInsightRedisKeyMapping() { public void setOrganisationInsightRedisKeyMapping(Map organisationInsightRedisKeyMapping) { this.organisationInsightRedisKeyMapping = organisationInsightRedisKeyMapping; } + + public List getBulkUploadAllowedRolesCreation() { + return Arrays.asList(bulkUploadAllowedRolesCreation.split(",", -1)); + } + + public void setBulkUploadAllowedRolesCreation(String bulkUploadAllowedRolesCreation) { + this.bulkUploadAllowedRolesCreation = bulkUploadAllowedRolesCreation; + } } \ No newline at end of file diff --git a/src/main/java/org/sunbird/common/util/Constants.java b/src/main/java/org/sunbird/common/util/Constants.java index fd9fd54f4..8cbe4ff11 100644 --- a/src/main/java/org/sunbird/common/util/Constants.java +++ b/src/main/java/org/sunbird/common/util/Constants.java @@ -1050,6 +1050,9 @@ public class Constants { public static final String TOTAL_COUNT = "totalCount"; public static final String MICROSITE_TOP_CONTENT_API = "api.microsite.top.content"; public static final String ICON = "icon"; + public static final String DOMICILE_MEDIUM = "domicileMedium"; + public static final String PINCODE = "pinCode"; + public static final String EMPLOYEE_CODE = "employeeCode"; private Constants() { throw new IllegalStateException("Utility class"); diff --git a/src/main/java/org/sunbird/profile/service/UserBulkUploadService.java b/src/main/java/org/sunbird/profile/service/UserBulkUploadService.java index 5ab3d9cc4..2e10fe0dc 100644 --- a/src/main/java/org/sunbird/profile/service/UserBulkUploadService.java +++ b/src/main/java/org/sunbird/profile/service/UserBulkUploadService.java @@ -117,13 +117,13 @@ private void processBulkUpload(HashMap inputDataMap) throws IOEx // incrementing the iterator inorder to skip the headers in the first row if (rowIterator.hasNext()) { Row firstRow = rowIterator.next(); - Cell statusCell = firstRow.getCell(7); - Cell errorDetails = firstRow.getCell(8); + Cell statusCell = firstRow.getCell(15); + Cell errorDetails = firstRow.getCell(16); if (statusCell == null) { - statusCell = firstRow.createCell(7); + statusCell = firstRow.createCell(15); } if (errorDetails == null) { - errorDetails = firstRow.createCell(8); + errorDetails = firstRow.createCell(16); } statusCell.setCellValue("Status"); errorDetails.setCellValue("Error Details"); @@ -183,32 +183,69 @@ private void processBulkUpload(HashMap inputDataMap) throws IOEx invalidErrList.add("Invalid column type. Expecting string format"); } } - if (nextRow.getCell(4) != null && nextRow.getCell(4).getCellType() != CellType.BLANK) { + if (nextRow.getCell(4) == null || nextRow.getCell(4).getCellType() == CellType.BLANK) { + errList.add("Designation"); + } else { if (nextRow.getCell(4).getCellType() == CellType.STRING) { - String tagStr = nextRow.getCell(4).getStringCellValue().trim(); - List tagList = new ArrayList(); - if (!StringUtils.isEmpty(tagStr)) { - String[] tagStrList = tagStr.split(",", -1); - for(String tag : tagStrList) { - tagList.add(tag.trim()); - } - } - userRegistration.setTag(tagList); - if (!ProjectUtil.validateTag(userRegistration.getTag())) { - invalidErrList.add("Invalid Tag : Tags are comma seperated string values. A Tag can contain only alphabets with spaces. eg: Bihar Circle, Patna Division"); - } + userRegistration.setPosition(nextRow.getCell(4).getStringCellValue().trim()); } else { invalidErrList.add("Invalid column type. Expecting string format"); } } if (nextRow.getCell(5) != null && nextRow.getCell(5).getCellType() != CellType.BLANK) { if (nextRow.getCell(5).getCellType() == CellType.NUMERIC) { - userRegistration.setExternalSystemId(NumberToTextConverter.toText(nextRow.getCell(5).getNumericCellValue()).trim()); + userRegistration.setEmployeeId(NumberToTextConverter.toText(nextRow.getCell(5).getNumericCellValue()).trim()); + } else if (nextRow.getCell(5).getCellType() == CellType.STRING) { + userRegistration.setEmployeeId(nextRow.getCell(5).getStringCellValue().trim()); + } else { + invalidErrList.add("Invalid column type. Expecting string/number format"); + } + } + if (nextRow.getCell(6) != null && nextRow.getCell(6).getCellType() != CellType.BLANK) { + if (nextRow.getCell(6).getCellType() == CellType.STRING) { + userRegistration.setGender(nextRow.getCell(6).getStringCellValue().trim()); + } else { + invalidErrList.add("Invalid column type. Expecting string format"); + } + } + if (nextRow.getCell(7) != null && nextRow.getCell(7).getCellType() != CellType.BLANK) { + if (nextRow.getCell(7).getCellType() == CellType.STRING) { + userRegistration.setDob(nextRow.getCell(7).getStringCellValue().trim()); + } else { + invalidErrList.add("Invalid column type. Expecting string format"); + } + } + if (nextRow.getCell(8) != null && nextRow.getCell(8).getCellType() != CellType.BLANK) { + if (nextRow.getCell(8).getCellType() == CellType.STRING) { + userRegistration.setDomicileMedium(nextRow.getCell(8).getStringCellValue().trim()); + } else { + invalidErrList.add("Invalid column type. Expecting string format"); + } + } + if (nextRow.getCell(9) != null && nextRow.getCell(9).getCellType() != CellType.BLANK) { + if (nextRow.getCell(9).getCellType() == CellType.STRING) { + userRegistration.setCategory(nextRow.getCell(9).getStringCellValue().trim()); + } else { + invalidErrList.add("Invalid column type. Expecting string format"); + } + } + if (nextRow.getCell(10) != null && nextRow.getCell(10).getCellType() != CellType.BLANK) { + if (nextRow.getCell(10).getCellType() == CellType.NUMERIC) { + userRegistration.setPincode(NumberToTextConverter.toText(nextRow.getCell(10).getNumericCellValue())); + } else if (nextRow.getCell(10).getCellType() == CellType.STRING) { + userRegistration.setPincode(nextRow.getCell(10).getStringCellValue().trim()); + } else { + invalidErrList.add("Invalid column type. Expecting number/string format"); + } + } + if (nextRow.getCell(11) != null && nextRow.getCell(11).getCellType() != CellType.BLANK) { + if (nextRow.getCell(11).getCellType() == CellType.NUMERIC) { + userRegistration.setExternalSystemId(NumberToTextConverter.toText(nextRow.getCell(11).getNumericCellValue()).trim()); if (!ProjectUtil.validateExternalSystemId(userRegistration.getExternalSystemId())) { invalidErrList.add("Invalid External System ID : External System Id can contain alphanumeric characters and have a max length of 30"); } - } else if (nextRow.getCell(5).getCellType() == CellType.STRING) { - userRegistration.setExternalSystemId(nextRow.getCell(5).getStringCellValue().trim()); + } else if (nextRow.getCell(11).getCellType() == CellType.STRING) { + userRegistration.setExternalSystemId(nextRow.getCell(11).getStringCellValue().trim()); if (!ProjectUtil.validateExternalSystemId(userRegistration.getExternalSystemId())) { invalidErrList.add("Invalid External System ID : External System Id can contain alphanumeric characters and have a max length of 30"); } @@ -216,9 +253,9 @@ private void processBulkUpload(HashMap inputDataMap) throws IOEx invalidErrList.add("Invalid column type. Expecting string/number format"); } } - if (nextRow.getCell(6) != null && !StringUtils.isBlank(nextRow.getCell(6).toString())) { - if (nextRow.getCell(6).getCellType() == CellType.STRING) { - userRegistration.setExternalSystem(nextRow.getCell(6).getStringCellValue().trim()); + if (nextRow.getCell(12) != null && !StringUtils.isBlank(nextRow.getCell(12).toString())) { + if (nextRow.getCell(12).getCellType() == CellType.STRING) { + userRegistration.setExternalSystem(nextRow.getCell(12).getStringCellValue().trim()); if (!ProjectUtil.validateExternalSystem(userRegistration.getExternalSystem())) { invalidErrList.add("Invalid External System : External System can contain only alphabets and can have a max length of 255"); } @@ -226,16 +263,52 @@ private void processBulkUpload(HashMap inputDataMap) throws IOEx invalidErrList.add("Invalid column type. Expecting string format"); } } + if (nextRow.getCell(13) != null && nextRow.getCell(13).getCellType() != CellType.BLANK) { + if (nextRow.getCell(13).getCellType() == CellType.STRING) { + String tagStr = nextRow.getCell(13).getStringCellValue().trim(); + List tagList = new ArrayList(); + if (!StringUtils.isEmpty(tagStr)) { + String[] tagStrList = tagStr.split(",", -1); + for(String tag : tagStrList) { + tagList.add(tag.trim()); + } + } + userRegistration.setTag(tagList); + if (!ProjectUtil.validateTag(userRegistration.getTag())) { + invalidErrList.add("Invalid Tag : Tags are comma seperated string values. A Tag can contain only alphabets with spaces. eg: Bihar Circle, Patna Division"); + } + } else { + invalidErrList.add("Invalid column type. Expecting string format"); + } + } + if (nextRow.getCell(14) != null && nextRow.getCell(14).getCellType() != CellType.BLANK) { + if (nextRow.getCell(14).getCellType() == CellType.STRING) { + String rolesStr = nextRow.getCell(14).getStringCellValue().trim(); + List rolesList = new ArrayList(); + if (!StringUtils.isEmpty(rolesStr)) { + String[] rolesStrList = rolesStr.split(",", -1); + for (String role : rolesStrList) { + rolesList.add(role.trim()); + if (!serverProperties.getBulkUploadAllowedRolesCreation().contains(role.trim())) { + invalidErrList.add("Invalid userRoles, allowed Roles are: " + serverProperties.getBulkUploadAllowedRolesCreation()); + } + } + } + userRegistration.setRoles(rolesList); + } else { + invalidErrList.add("Invalid column type. Expecting string format"); + } + } userRegistration.setOrgName(inputDataMap.get(Constants.ORG_NAME)); userRegistration.setChannel(inputDataMap.get(Constants.ORG_NAME)); userRegistration.setSbOrgId(inputDataMap.get(Constants.ROOT_ORG_ID)); - Cell statusCell = nextRow.getCell(7); - Cell errorDetails = nextRow.getCell(8); + Cell statusCell = nextRow.getCell(15); + Cell errorDetails = nextRow.getCell(16); if (statusCell == null) { - statusCell = nextRow.createCell(7); + statusCell = nextRow.createCell(15); } if (errorDetails == null) { - errorDetails = nextRow.createCell(8); + errorDetails = nextRow.createCell(16); } if (totalRecordsCount == 0 && errList.size() == 4) { setErrorDetails(str, errList, statusCell, errorDetails); @@ -274,8 +347,8 @@ private void processBulkUpload(HashMap inputDataMap) throws IOEx } if (totalRecordsCount == 0) { XSSFRow row = sheet.createRow(sheet.getLastRowNum() + 1); - Cell statusCell = row.createCell(7); - Cell errorDetails = row.createCell(8); + Cell statusCell = row.createCell(15); + Cell errorDetails = row.createCell(16); statusCell.setCellValue(Constants.FAILED_UPPERCASE); errorDetails.setCellValue(Constants.EMPTY_FILE_FAILED); diff --git a/src/main/java/org/sunbird/user/registration/model/UserRegistrationInfo.java b/src/main/java/org/sunbird/user/registration/model/UserRegistrationInfo.java index fa13f0424..d9998da17 100644 --- a/src/main/java/org/sunbird/user/registration/model/UserRegistrationInfo.java +++ b/src/main/java/org/sunbird/user/registration/model/UserRegistrationInfo.java @@ -33,6 +33,13 @@ public class UserRegistrationInfo { private List tag; private String externalSystemId; private String externalSystem; + private String employeeId; + private String gender; + private String dob; + private String domicileMedium; + private String category; + private String pincode; + private List roles; public String getRegistrationCode() { return registrationCode; @@ -177,4 +184,60 @@ public String getGroup() { public void setGroup(String group) { this.group = group; } + + public String getEmployeeId() { + return employeeId; + } + + public void setEmployeeId(String employeeId) { + this.employeeId = employeeId; + } + + public String getGender() { + return gender; + } + + public void setGender(String gender) { + this.gender = gender; + } + + public String getDob() { + return dob; + } + + public void setDob(String dob) { + this.dob = dob; + } + + public String getDomicileMedium() { + return domicileMedium; + } + + public void setDomicileMedium(String domicileMedium) { + this.domicileMedium = domicileMedium; + } + + public String getCategory() { + return category; + } + + public void setCategory(String category) { + this.category = category; + } + + public String getPincode() { + return pincode; + } + + public void setPincode(String pincode) { + this.pincode = pincode; + } + + public List getRoles() { + return roles; + } + + public void setRoles(List roles) { + this.roles = roles; + } } diff --git a/src/main/java/org/sunbird/user/service/UserUtilityServiceImpl.java b/src/main/java/org/sunbird/user/service/UserUtilityServiceImpl.java index 54b078b3a..c5ed9c9c3 100644 --- a/src/main/java/org/sunbird/user/service/UserUtilityServiceImpl.java +++ b/src/main/java/org/sunbird/user/service/UserUtilityServiceImpl.java @@ -587,7 +587,11 @@ public String createBulkUploadUser(UserRegistration userRegistration) { requestBody.put(Constants.EMAIL_VERIFIED, true); requestBody.put(Constants.PHONE, userRegistration.getPhone()); requestBody.put(Constants.PHONE_VERIFIED, true); - requestBody.put(Constants.ROLES, Arrays.asList(Constants.PUBLIC)); + if (CollectionUtils.isEmpty(userRegistration.getRoles())) { + requestBody.put(Constants.ROLES, Arrays.asList(Constants.PUBLIC)); + } else { + requestBody.put(Constants.ROLES, userRegistration.getRoles()); + } request.put(Constants.REQUEST, requestBody); Map headerValues = ProjectUtil.getDefaultHeaders(); if (StringUtils.isNotEmpty(userRegistration.getUserAuthToken())) { @@ -622,12 +626,30 @@ public String updateBulkUploadUser(UserRegistration userRegistration) { profileDetails.put(Constants.MANDATORY_FIELDS_EXISTS, false); Map employementDetails = new HashMap(); employementDetails.put(Constants.DEPARTMENTNAME, userRegistration.getOrgName()); + if (StringUtils.isNotEmpty(userRegistration.getEmployeeId())) { + employementDetails.put(Constants.EMPLOYEE_CODE, userRegistration.getEmployeeId()); + } profileDetails.put(Constants.EMPLOYMENTDETAILS, employementDetails); Map personalDetails = new HashMap(); personalDetails.put(Constants.FIRSTNAME.toLowerCase(), userRegistration.getFirstName()); personalDetails.put(Constants.PRIMARY_EMAIL, userRegistration.getEmail()); personalDetails.put(Constants.MOBILE, userRegistration.getPhone()); personalDetails.put(Constants.PHONE_VERIFIED, true); + if (StringUtils.isNotEmpty(userRegistration.getDob())) { + personalDetails.put(Constants.DOB, userRegistration.getDob()); + } + if (StringUtils.isNotEmpty(userRegistration.getCategory())) { + personalDetails.put(Constants.CATEGORY, userRegistration.getCategory()); + } + if (StringUtils.isNotEmpty(userRegistration.getDomicileMedium())) { + personalDetails.put(Constants.DOMICILE_MEDIUM, userRegistration.getDomicileMedium()); + } + if (StringUtils.isNotEmpty(userRegistration.getPincode())) { + personalDetails.put(Constants.PINCODE, userRegistration.getPincode()); + } + if (StringUtils.isNotEmpty(userRegistration.getGender())) { + personalDetails.put(Constants.GENDER, userRegistration.getGender()); + } profileDetails.put(Constants.PERSONAL_DETAILS, personalDetails); Map professionDetailObj = new HashMap(); professionDetailObj.put(Constants.ORGANIZATION_TYPE, Constants.GOVERNMENT); diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index dfdf12c6f..a140bef84 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -418,4 +418,5 @@ cloud.org.store.folder.name=orgStore cloud.public.store.container.name=igot organisation.insights.fields={"Average Course Rating":"https://portal.karmayogi.nic.in/content-store/sb-cb-ext-dev/orgStore/01376822290813747263/1715340042117_star.svg","Content Available":"https://portal.karmayogi.nic.in/content-store/sb-cb-ext-dev/orgStore/01376822290813747263/1715340042117_star.svg","Enrolments So Far":"https://portal.karmayogi.nic.in/content-store/sb-cb-ext-dev/orgStore/01376822290813747263/1715340042117_star.svg","Certificates Issued So Far":"https://portal.karmayogi.nic.in/content-store/sb-cb-ext-dev/orgStore/01376822290813747263/1715340042117_star.svg"} organisation.insights.property.fields={"valueColor": "#FFFFFF","labelColor": "#000000","linebreak":"true","background":"banner-metrics","iconColor": "#FFFFFF"} -organisation.insights.redis.key.mapping={"Average Course Rating":"dashboard_course_average_rating_by_course_org","Content Available":"dashboard_live_course_count_by_course_org","Enrolments So Far":"dashboard_enrolment_count_by_course_org","Certificates Issued So Far":"dashboard_certificates_generated_count_by_course_org"} \ No newline at end of file +organisation.insights.redis.key.mapping={"Average Course Rating":"dashboard_course_average_rating_by_course_org","Content Available":"dashboard_live_course_count_by_course_org","Enrolments So Far":"dashboard_enrolment_count_by_course_org","Certificates Issued So Far":"dashboard_certificates_generated_count_by_course_org"} +bulk.upload.allowed.roles.creation=CBP_ADMIN,CONTENT_CREATOR,CONTENT_REVIEWER,FRAC_ADMIN,FRAC_COMPETENCY_MEMBER,FRAC_COMPETENCY_REVIEWER,FRAC_REVIEWER_L1,FRAC_REVIEWER_L2,IFU_MEMBER,MDO_ADMIN,MDO_LEADER,PUBLIC,WAT_MEMBER,PROGRAM_COORDINATOR,MDO_DASHBOARD_USER \ No newline at end of file