Skip to content

Commit

Permalink
MOSIP-28185 Code fix for notification (#1782)
Browse files Browse the repository at this point in the history
Co-authored-by: Sowmya Ujjappa Banakar <[email protected]>
  • Loading branch information
sowmya695 and Sowmya Ujjappa Banakar committed Oct 31, 2023
1 parent f259f93 commit fcdfc39
Showing 1 changed file with 17 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
Expand Down Expand Up @@ -74,7 +75,6 @@
import io.mosip.registration.processor.message.sender.exception.TemplateNotFoundException;
import io.mosip.registration.processor.message.sender.template.TemplateGenerator;
import io.mosip.registration.processor.packet.manager.decryptor.Decryptor;
import io.mosip.registration.processor.packet.storage.dto.ConfigEnum;
import io.mosip.registration.processor.packet.storage.exception.IdRepoAppException;
import io.mosip.registration.processor.packet.storage.utils.PriorityBasedPacketManagerService;
import io.mosip.registration.processor.packet.storage.utils.Utilities;
Expand Down Expand Up @@ -560,7 +560,7 @@ private Map<String, Object> setAttributes(String idJsonString, Map<String, Objec
JsonValue[] jsonValues = JsonUtil.mapJsonNodeToJavaObject(JsonValue.class, node);
for (int count = 0; count < jsonValues.length; count++) {
if(jsonValues[count].getLanguage().equalsIgnoreCase(lang)) {
attribute.put(val , jsonValues[count].getValue());
attribute.put(val + "_" + lang, jsonValues[count].getValue());
}
}
} else if (object instanceof LinkedHashMap) {
Expand Down Expand Up @@ -609,13 +609,21 @@ private Map<String, Object> setAttributesFromIdJson(String id, String process, M
String regType, String lang, StringBuilder phoneNumber, StringBuilder emailId)
throws IOException, ApisResourceAccessException, PacketManagerException, JsonProcessingException, JSONException, PacketDecryptionFailureException, JsonParseException, JsonMappingException, io.mosip.kernel.core.exception.IOException {

JSONObject mapperIdentity = utility.getRegistrationProcessorMappingJson(MappingJsonConstants.IDENTITY);

if (mapperJsonKeys == null) {
String mapperJsonString = Utilities.getJson(utility.getConfigServerFileStorageURL(),
utility.getGetRegProcessorIdentityJson());
JSONObject mapperJson = JsonUtil.objectMapperReadValue(mapperJsonString, JSONObject.class);
mapperIdentity = JsonUtil.getJSONObject(mapperJson, utility.getGetRegProcessorDemographicIdentity());
mapperJsonKeys = new ArrayList<>(mapperIdentity.keySet());
}
List<String> mapperJsonValues = new ArrayList<>();
JsonUtil.getJSONValue(JsonUtil.getJSONObject(mapperIdentity, MappingJsonConstants.INDIVIDUAL_BIOMETRICS), VALUE);
mapperIdentity.keySet().forEach(key -> mapperJsonValues.add(JsonUtil.getJSONValue(JsonUtil.getJSONObject(mapperIdentity, key), VALUE)));

String source = utility.getDefaultSource(process, ConfigEnum.READER);
for (String key : mapperJsonKeys) {
JSONObject jsonValue = JsonUtil.getJSONObject(mapperIdentity, key);
if (jsonValue.get(VALUE) != null && !jsonValue.get(VALUE).toString().isBlank()) {
String[] valueArray = jsonValue.get(VALUE).toString().split(",");
mapperJsonValues.addAll(new ArrayList(Arrays.asList(valueArray)));
}
}
Map<String, String> fieldMap =null;
try {
fieldMap = packetManagerService.getFields(id, mapperJsonValues, process, ProviderStageName.MESSAGE_SENDER);
Expand All @@ -640,7 +648,7 @@ else if (json instanceof org.json.JSONArray) {
Object obj = jsonArray.get(i);
JsonValue jsonValue = mapper.readValue(obj.toString(), JsonValue.class);
if(jsonValue.getLanguage().equalsIgnoreCase(lang)) {
attribute.putIfAbsent(e.getKey().toString(), jsonValue.getValue());
attribute.putIfAbsent(e.getKey().toString() + "_" + lang, jsonValue.getValue());
}
}
} else
Expand Down

0 comments on commit fcdfc39

Please sign in to comment.