Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ MOSIP-35378 ] selected handles in uin generator stage. #1920

Merged
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@
import io.mosip.registration.processor.status.dto.RegistrationStatusDto;
import io.mosip.registration.processor.status.service.RegistrationStatusService;

import javax.swing.plaf.IconUIResource;
ase-101 marked this conversation as resolved.
Show resolved Hide resolved

/**
* The Class UinGeneratorStage.
*
Expand Down Expand Up @@ -463,35 +465,48 @@ public MessageDTO process(MessageDTO object) {
return object;
}

private void loadDemographicIdentity(Map<String, String> fieldMap, JSONObject demographicIdentity) throws IOException, JSONException {
for (Map.Entry e : fieldMap.entrySet()) {
if (e.getValue() != null) {
String value = e.getValue().toString();
if (value != null) {
Object json = new JSONTokener(value).nextValue();
if (json instanceof org.json.JSONObject) {
HashMap<String, Object> hashMap = objectMapper.readValue(value, HashMap.class);
demographicIdentity.putIfAbsent(e.getKey(), hashMap);
}
else if (json instanceof JSONArray) {
List jsonList = new ArrayList<>();
JSONArray jsonArray = new JSONArray(value);
for (int i = 0; i < jsonArray.length(); i++) {
Object obj = jsonArray.get(i);
HashMap<String, Object> hashMap = objectMapper.readValue(obj.toString(), HashMap.class);
if(trimWhitespaces && hashMap.get("value") instanceof String) {
hashMap.put("value",((String)hashMap.get("value")).trim());
}
jsonList.add(hashMap);
}
demographicIdentity.putIfAbsent(e.getKey(), jsonList);
} else
demographicIdentity.putIfAbsent(e.getKey(), value);
} else
demographicIdentity.putIfAbsent(e.getKey(), value);
}
}
}
private void loadDemographicIdentity(Map<String, String> fieldMap, JSONObject demographicIdentity) throws IOException, JSONException {
for (Map.Entry e : fieldMap.entrySet()) {
if (e.getValue() == null) {
continue;
}

String value = e.getValue().toString();
if (value == null) {
demographicIdentity.putIfAbsent(e.getKey(), value);
continue;
}

Object json = new JSONTokener(value).nextValue();
if (json instanceof org.json.JSONObject) {
HashMap<String, Object> hashMap = objectMapper.readValue(value, HashMap.class);
demographicIdentity.putIfAbsent(e.getKey(), hashMap);
continue;
}

if (json instanceof JSONArray) {
List jsonList = new ArrayList<>();
JSONArray jsonArray = new JSONArray(value);
for (int i = 0; i < jsonArray.length(); i++) {
Object obj = jsonArray.get(i);
if (obj instanceof String) {
jsonList.add(obj);
} else {
HashMap<String, Object> hashMap = objectMapper.readValue(obj.toString(), HashMap.class);

if (trimWhitespaces && hashMap.containsKey("value") && hashMap.get("value") instanceof String) {
hashMap.put("value", ((String) hashMap.get("value")).trim());
}
jsonList.add(hashMap);
}
}
demographicIdentity.putIfAbsent(e.getKey(), jsonList);
}
else {
demographicIdentity.putIfAbsent(e.getKey(), value);
}
}
}

/**
* Send id repo with uin.
Expand Down