Skip to content

Commit

Permalink
4.8.14 dev v5 (#572)
Browse files Browse the repository at this point in the history
* Updated flag for profile status snack bar

* Fixed date format
  • Loading branch information
karthik-tarento authored May 27, 2024
1 parent 342aad6 commit 87249cd
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 13 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 @@ -1055,6 +1055,8 @@ public class Constants {
public static final String EMPLOYEE_CODE = "employeeCode";
public static final String PROFILE_STATUS = "profileStatus";
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";

private Constants() {
throw new IllegalStateException("Utility class");
Expand Down
44 changes: 31 additions & 13 deletions src/main/java/org/sunbird/profile/service/ProfileServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.gson.Gson;
import io.jsonwebtoken.ExpiredJwtException;
import io.jsonwebtoken.MalformedJwtException;
import io.jsonwebtoken.SignatureException;
import io.jsonwebtoken.UnsupportedJwtException;

import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.ListUtils;
import org.apache.commons.collections.MapUtils;
Expand Down Expand Up @@ -58,6 +55,7 @@
import java.nio.file.Path;
import java.nio.file.Paths;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.Map.Entry;
import java.util.concurrent.TimeUnit;
Expand Down Expand Up @@ -1783,31 +1781,51 @@ public SBApiResponse profileMDOAdminUpdate(Map<String, Object> request, String u
if (Constants.PROFESSIONAL_DETAILS.equalsIgnoreCase(changedObj)) {
List<Map<String, Object>> professionalList = (List<Map<String, Object>>) existingProfileDetails
.get(Constants.PROFESSIONAL_DETAILS);
;
Map<String, Object> existingProfessionalDetailsMap = null;
boolean isGroupOrDesignationUpdated = false;
// professional detail is empty... just replace...
if (CollectionUtils.isEmpty(professionalList)) {
existingProfileDetails.put(changedObj, profileDetailsMap.get(changedObj));
professionalList = (List<Map<String, Object>>) existingProfileDetails
.get(Constants.PROFESSIONAL_DETAILS);
existingProfessionalDetailsMap = professionalList.get(0);
isGroupOrDesignationUpdated = true;
} else {
existingProfessionalDetailsMap = professionalList.get(0);
Map<String, Object> updatedProfessionalDetailsMap = ((List<Map<String, Object>>) profileDetailsMap
.get(changedObj)).get(0);
for (String childKey : updatedProfessionalDetailsMap.keySet()) {
String updatedValue = (String) updatedProfessionalDetailsMap.get(childKey);
if ((Constants.GROUP.equalsIgnoreCase(childKey)
|| Constants.DESIGNATION.equalsIgnoreCase(childKey)) &&
!updatedValue.equalsIgnoreCase(
(String) existingProfessionalDetailsMap.get(childKey))) {
isGroupOrDesignationUpdated = true;
}
existingProfessionalDetailsMap.put(childKey,
updatedProfessionalDetailsMap.get(childKey));
}
}
if (StringUtils
.isNotBlank((String) existingProfessionalDetailsMap.get(Constants.GROUP)) &&
StringUtils
.isNotBlank((String) existingProfessionalDetailsMap
.get(Constants.DESIGNATION))) {
existingProfileDetails.put(Constants.PROFILE_STATUS, Constants.VERIFIED);
} else {
existingProfileDetails.put(Constants.PROFILE_STATUS, Constants.NOT_VERIFIED);
if (isGroupOrDesignationUpdated) {
if (StringUtils
.isNotBlank((String) existingProfessionalDetailsMap.get(Constants.GROUP)) &&
StringUtils
.isNotBlank((String) existingProfessionalDetailsMap
.get(Constants.DESIGNATION))) {
existingProfileDetails.put(Constants.PROFILE_STATUS, Constants.VERIFIED);
} else {
existingProfileDetails.put(Constants.PROFILE_STATUS, Constants.NOT_VERIFIED);
}

String timeStamp = new SimpleDateFormat("dd-MM-yyyy HH.mm.ss").format(new java.util.Date());
existingProfileDetails.put(Constants.PROFILE_STATUS_UPDATED_ON, timeStamp);
Map<String, Object> additionalProperties = (Map<String, Object>) existingProfileDetails
.get(Constants.ADDITIONAL_PROPERTIES);
if (ObjectUtils.isEmpty(additionalProperties)) {
additionalProperties = new HashMap<>();
}
additionalProperties.put(Constants.PROFILE_STATUS_UPDATED_MSG_VIEWED, false);
existingProfileDetails.put(Constants.ADDITIONAL_PROPERTIES, additionalProperties);
}
} else {
existingProfileDetails.put(changedObj, profileDetailsMap.get(changedObj));
Expand Down

0 comments on commit 87249cd

Please sign in to comment.