Skip to content

Commit

Permalink
Merge pull request #32 from sreeragksgh/cbrelease-4.0.1
Browse files Browse the repository at this point in the history
Cbrelease 4.0.1 changes for user profile flow
  • Loading branch information
karthik-tarento authored Jun 1, 2022
2 parents c99d3fa + a5f42d7 commit a4e228a
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public Map<String, Object> updateRequestWithWF(String uuid, List<Map<String, Obj

}

Map<String, Object> objectMap = (Map<String, Object>) request.get(Constants.FIELD_KEY);
Map<String, Object> objectMap = (Map<String, Object>) request.get(Constants.TO_VALUE);
for (Map.Entry entry : objectMap.entrySet())
toChange.put((String) entry.getKey(), entry.getValue());

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
package org.sunbird.cb.hubservices.profile.handler;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;

import org.apache.http.client.HttpClient;
Expand Down Expand Up @@ -110,6 +106,7 @@ private Profile() {
public static final String REQUEST = "request";
public static final String ENTITY_TYPE = "entityType";
public static final String PROFILE_DETAILS = "profileDetails";
public static final String PROFESSIONAL_DETAILS = "professionalDetails";

}

Expand All @@ -135,20 +132,34 @@ public static void merge(Map<String, Object> mapLeft, Map<String, Object> mapRig
public static void mergeLeaf(Map<String, Object> mapLeft, Map<String, Object> mapRight, String leafKey, String id) {
// go over all the keys of the right map

for (String key : mapLeft.keySet()) {
if (mapLeft.containsKey(leafKey)) {
for (String key : mapLeft.keySet()) {

if (key.equalsIgnoreCase(leafKey) && (mapLeft.get(key) instanceof ArrayList) && !id.isEmpty()) {
if (mapLeft.get(key) instanceof ArrayList) {
Set<String> childRequest = mapRight.keySet();
for (String keys : childRequest) {
List<Map<String, Object>> childExisting = (List<Map<String, Object>>) mapLeft.get(key);
Map<String, Object> childExistingIndex = (Map<String, Object>) childExisting.get(0);
childExistingIndex.put(keys, mapRight.get(keys));
}
}
if (key.equalsIgnoreCase(leafKey) && (mapLeft.get(key) instanceof HashMap)) {
mapLeft.put(key, mapRight);

((ArrayList) mapLeft.get(key)).removeIf(
o -> ((Map) o).get("osid") != null && ((Map) o).get("osid").toString().equalsIgnoreCase(id));
((ArrayList) mapLeft.get(key)).add(mapRight);
}

}
if (key.equalsIgnoreCase(leafKey) && (mapLeft.get(key) instanceof HashMap)) {
mapLeft.put(key, mapRight);

} else {
if (leafKey.equals(Profile.PROFESSIONAL_DETAILS)) {
List<Map<String, Object>> professionalData = new ArrayList<>();
Map<String, Object> professionalDataChild = new HashMap<>();
Set<String> childRequest = mapRight.keySet();
for (String keys : childRequest) {
professionalDataChild.put(keys, mapRight.get(keys));
}
professionalData.add(professionalDataChild);
mapLeft.put(Profile.PROFESSIONAL_DETAILS, professionalData);
}

}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

public class Constants {

public static final String TO_VALUE = "toValue";
public static final String FIELD_KEY = "fieldKey";
public static final String OFFSET = "offset";
public static final String LIMIT = "limit";
Expand Down

0 comments on commit a4e228a

Please sign in to comment.