Skip to content

Commit

Permalink
KB-4794 fix for individual status
Browse files Browse the repository at this point in the history
  • Loading branch information
karthik-tarento committed May 31, 2024
1 parent 85e33e2 commit 6fc3c2c
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 8 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 @@ -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");
Expand Down
27 changes: 22 additions & 5 deletions src/main/java/org/sunbird/profile/service/ProfileServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -1806,13 +1806,30 @@ public SBApiResponse profileMDOAdminUpdate(Map<String, Object> 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);
}
Expand Down
21 changes: 18 additions & 3 deletions src/main/java/org/sunbird/user/service/UserUtilityServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<String, Object> professionDetailObj = new HashMap<String, Object>();
professionDetailObj.put(Constants.ORGANIZATION_TYPE, Constants.GOVERNMENT);
if (StringUtils.isNotEmpty(userRegistration.getPosition())) {
Expand Down Expand Up @@ -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<String, Object> professionDetailObj = new HashMap<String, Object>();
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<Map<String, Object>> professionalDetailsList = new ArrayList<Map<String, Object>>();
professionalDetailsList.add(professionDetailObj);
Expand All @@ -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<String, Object> readData = (Map<String, Object>) outboundRequestHandlerService.fetchResultUsingPatch(
Expand Down

0 comments on commit 6fc3c2c

Please sign in to comment.