From 6fc3c2c77c8fc2b9c0614809f2da60095e248d74 Mon Sep 17 00:00:00 2001 From: karthik-tarento Date: Fri, 31 May 2024 13:04:45 +0530 Subject: [PATCH] KB-4794 fix for individual status --- .../org/sunbird/common/util/Constants.java | 2 ++ .../profile/service/ProfileServiceImpl.java | 27 +++++++++++++++---- .../user/service/UserUtilityServiceImpl.java | 21 ++++++++++++--- 3 files changed, 42 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/sunbird/common/util/Constants.java b/src/main/java/org/sunbird/common/util/Constants.java index 39f605893..89fbd52eb 100644 --- a/src/main/java/org/sunbird/common/util/Constants.java +++ b/src/main/java/org/sunbird/common/util/Constants.java @@ -1057,6 +1057,8 @@ public class Constants { public static final String NOT_VERIFIED = "NOT-VERIFIED"; public static final String PROFILE_STATUS_UPDATED_ON = "profileStatusUpdatedOn"; public static final String PROFILE_STATUS_UPDATED_MSG_VIEWED = "isProfileUpdatedMsgViewed"; + public static final String PROFILE_GROUP_STATUS = "profileGroupStatus"; + public static final String PROFILE_DESIGNATION_STATUS = "profileDesignationStatus"; private Constants() { throw new IllegalStateException("Utility class"); diff --git a/src/main/java/org/sunbird/profile/service/ProfileServiceImpl.java b/src/main/java/org/sunbird/profile/service/ProfileServiceImpl.java index 92e18b2e9..d081e5b0b 100644 --- a/src/main/java/org/sunbird/profile/service/ProfileServiceImpl.java +++ b/src/main/java/org/sunbird/profile/service/ProfileServiceImpl.java @@ -1806,13 +1806,30 @@ public SBApiResponse profileMDOAdminUpdate(Map request, String u updatedProfessionalDetailsMap.get(childKey)); } } + if (isGroupOrDesignationUpdated) { if (StringUtils - .isNotBlank((String) existingProfessionalDetailsMap.get(Constants.GROUP)) && - StringUtils - .isNotBlank((String) existingProfessionalDetailsMap - .get(Constants.DESIGNATION))) { - existingProfileDetails.put(Constants.PROFILE_STATUS, Constants.VERIFIED); + .isNotBlank((String) existingProfessionalDetailsMap.get(Constants.GROUP))) { + existingProfileDetails.put(Constants.PROFILE_GROUP_STATUS, Constants.VERIFIED); + } else { + existingProfileDetails.put(Constants.PROFILE_GROUP_STATUS, + Constants.NOT_VERIFIED); + } + if (StringUtils + .isNotBlank((String) existingProfessionalDetailsMap + .get(Constants.DESIGNATION))) { + existingProfileDetails.put(Constants.PROFILE_DESIGNATION_STATUS, + Constants.VERIFIED); + } else { + existingProfileDetails.put(Constants.PROFILE_DESIGNATION_STATUS, + Constants.NOT_VERIFIED); + } + + if (Constants.VERIFIED.equalsIgnoreCase( + (String) existingProfileDetails.get(Constants.PROFILE_GROUP_STATUS)) && + Constants.VERIFIED.equalsIgnoreCase((String) existingProfileDetails + .get(Constants.PROFILE_DESIGNATION_STATUS))) { + existingProfileDetails.put(Constants.PROFILE_STATUS, Constants.VERIFIED); } else { existingProfileDetails.put(Constants.PROFILE_STATUS, Constants.NOT_VERIFIED); } diff --git a/src/main/java/org/sunbird/user/service/UserUtilityServiceImpl.java b/src/main/java/org/sunbird/user/service/UserUtilityServiceImpl.java index e51039dc8..011cad287 100644 --- a/src/main/java/org/sunbird/user/service/UserUtilityServiceImpl.java +++ b/src/main/java/org/sunbird/user/service/UserUtilityServiceImpl.java @@ -3,11 +3,11 @@ import java.io.IOException; import java.io.StringWriter; import java.sql.Timestamp; +import java.text.SimpleDateFormat; import java.util.*; import java.util.Map.Entry; import com.fasterxml.jackson.databind.JsonNode; -import com.jcraft.jsch.UserInfo; import org.apache.commons.collections.MapUtils; import org.apache.commons.lang.StringUtils; import org.apache.velocity.VelocityContext; @@ -273,6 +273,13 @@ public boolean updateUser(UserRegistration userRegistration) { personalDetails.put(Constants.MOBILE, userRegistration.getPhone()); personalDetails.put(Constants.PHONE_VERIFIED, true); profileDetails.put(Constants.PERSONAL_DETAILS, personalDetails); + profileDetails.put(Constants.PROFILE_STATUS, Constants.NOT_VERIFIED); + profileDetails.put(Constants.PROFILE_GROUP_STATUS, Constants.NOT_VERIFIED); + profileDetails.put(Constants.PROFILE_DESIGNATION_STATUS, Constants.NOT_VERIFIED); + SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy HH.mm.ss"); + sdf.setTimeZone(TimeZone.getTimeZone("GMT+05:30")); + String timeStamp = sdf.format(new java.util.Date()); + profileDetails.put(Constants.PROFILE_STATUS_UPDATED_ON, timeStamp); Map professionDetailObj = new HashMap(); professionDetailObj.put(Constants.ORGANIZATION_TYPE, Constants.GOVERNMENT); if (StringUtils.isNotEmpty(userRegistration.getPosition())) { @@ -651,13 +658,17 @@ public String updateBulkUploadUser(UserRegistration userRegistration) { personalDetails.put(Constants.GENDER, userRegistration.getGender()); } profileDetails.put(Constants.PERSONAL_DETAILS, personalDetails); + profileDetails.put(Constants.PROFILE_GROUP_STATUS, Constants.NOT_VERIFIED); + profileDetails.put(Constants.PROFILE_DESIGNATION_STATUS, Constants.NOT_VERIFIED); Map professionDetailObj = new HashMap(); professionDetailObj.put(Constants.ORGANIZATION_TYPE, Constants.GOVERNMENT); if (StringUtils.isNotEmpty(userRegistration.getPosition())) { professionDetailObj.put(Constants.DESIGNATION, userRegistration.getPosition()); + profileDetails.put(Constants.PROFILE_DESIGNATION_STATUS, Constants.VERIFIED); } if (!StringUtils.isEmpty(userRegistration.getGroup())) { professionDetailObj.put(Constants.GROUP, userRegistration.getGroup()); + profileDetails.put(Constants.PROFILE_GROUP_STATUS, Constants.VERIFIED); } List> professionalDetailsList = new ArrayList>(); professionalDetailsList.add(professionDetailObj); @@ -675,12 +686,16 @@ public String updateBulkUploadUser(UserRegistration userRegistration) { profileDetails.put(Constants.ADDITIONAL_PROPERTIES, additionalProperties); profileDetails.put(Constants.VERIFIED_KARMAYOGI, false); profileDetails.put(Constants.MANDATORY_FIELDS_EXISTS, false); - if (StringUtils.isNotBlank(userRegistration.getGroup()) - && StringUtils.isNotBlank(userRegistration.getPosition())) { + if (Constants.VERIFIED.equalsIgnoreCase((String) profileDetails.get(Constants.PROFILE_GROUP_STATUS)) + && Constants.VERIFIED.equalsIgnoreCase((String) profileDetails.get(Constants.PROFILE_DESIGNATION_STATUS))) { profileDetails.put(Constants.PROFILE_STATUS, Constants.VERIFIED); } else { profileDetails.put(Constants.PROFILE_STATUS, Constants.NOT_VERIFIED); } + SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy HH.mm.ss"); + sdf.setTimeZone(TimeZone.getTimeZone("GMT+05:30")); + String timeStamp = sdf.format(new java.util.Date()); + profileDetails.put(Constants.PROFILE_STATUS_UPDATED_ON, timeStamp); requestBody.put(Constants.PROFILE_DETAILS, profileDetails); request.put(Constants.REQUEST, requestBody); Map readData = (Map) outboundRequestHandlerService.fetchResultUsingPatch(