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-28185 Code fix for notification (#1782) #1787

Merged
merged 3 commits into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,18 @@ public void sendNotification(RegistrationAdditionalInfoDTO registrationAdditiona
String nameField = JsonUtil.getJSONValue(
JsonUtil.getJSONObject(regProcessorIdentityJson, MappingJsonConstants.NAME),
MappingJsonConstants.VALUE);
String[] nameArray = nameField.toString().split(",");
for(String preferredLanguage:preferredLanguages) {
if (registrationAdditionalInfoDTO.getName() != null) {
attributes.put(nameField , registrationAdditionalInfoDTO.getName());
attributes.put(nameArray[0] + "_" + preferredLanguage, registrationAdditionalInfoDTO.getName());
} else {
attributes.put(nameField, "");
attributes.put(nameArray[0] + "_" + preferredLanguage, "");
}
if (nameArray.length > 1) {
for (int i = 1; i < nameArray.length; i++) {
attributes.put(nameArray[i] + "_" + preferredLanguage, "");
}
}

if (isProcessingSuccess) {
type = setNotificationTemplateType(registrationStatusDto, type);
} else if (!isValidSupervisorStatus) {
Expand Down
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
Loading