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-27209 code fix #1723

Merged
merged 53 commits into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
aa08d86
MOSIP-27210 code fix
Jun 15, 2023
0b17847
MOSIP-27209 code chnages
Jun 26, 2023
9ee44e8
MOSIP-27209 added test cases
Jun 26, 2023
7fa3856
New print logic change and code re-factor
MuralitharanK Jun 20, 2023
f8a9858
New print logic change and code re-factor
MuralitharanK Jun 22, 2023
1e32ab9
New print logic change and code re-factor
MuralitharanK Jun 22, 2023
2784dd0
MOSIP-23715 code fix
Jun 19, 2023
a564c3b
MOSIP-23715 code review comments fixed
Jun 20, 2023
26dfe43
New print logic change and code re-factor
MuralitharanK Jun 22, 2023
3da63bb
MOSIP-23715 missed stages added for consumer health check
Jun 23, 2023
28c85ec
MOSIP-23715 fixed review comments
Jun 23, 2023
b639ff6
MOSIP-28025 Code fix (#1733) (#1734)
sowmya695 Jul 4, 2023
178c22f
[MOSIP-28484] Added error handling for deploy.sh script (#1755)
akilalakshmanan Aug 21, 2023
640d318
MOSIP-20644 0 bytes code issue (#1762)
sowmya695 Aug 31, 2023
c85bc9d
[DSD-3341]Updated Dockerfile (#1769)
Rakshitha650 Sep 5, 2023
2d5097e
Merge pull request #1752 from sowmya695/health_check_camel
vishwa-vyom Jul 13, 2023
3cf945f
Merge pull request #1753 from sowmya695/MOSIP-28478
vishwa-vyom Jul 17, 2023
af5e2f3
MOSIP-28559 trying one approach (#1772)
sowmya695 Sep 11, 2023
6a99fc4
quality checker level tags more specific
Khuddusshariff0022 Sep 14, 2023
1f1b821
Added levels to test MOSIP-29419
Khuddusshariff0022 Sep 15, 2023
a25d0fc
Added levels to test MOSIP-29419
Khuddusshariff0022 Sep 15, 2023
59798f0
quality checker level tags more specific MOSIP-29419
Khuddusshariff0022 Sep 15, 2023
70ecf1d
[MOSIP-29167]added reusable workflow (#1777)
Rakshitha650 Sep 22, 2023
f7a7d7a
MOSIP-28185 Code fix for notification (#1782)
sowmya695 Oct 21, 2023
1e02383
MOSIP-29118 Code fix (#1763)
sowmya695 Oct 31, 2023
63fa07b
MOSIP-29780 code fix
Nov 6, 2023
ca07fc3
MOSIP-29780 fixed test cases
Nov 6, 2023
93659cb
[ MOSIP-27859 ] Adding pkt_cr_dtimes and setting the packet date and …
Khuddusshariff0022 Oct 30, 2023
38c86cb
[Mosip-27859] [ MOSIP-29896 ] Adding pkt_cr_dtimes and setting the pa…
Khuddusshariff0022 Nov 6, 2023
1d1e910
[Mosip-27859] [ MOSIP-29896 ] Adding pkt_cr_dtimes and setting the pa…
Khuddusshariff0022 Nov 6, 2023
062f3f4
MOSIP-28185 registration confirmation notification corrected (#1789)
sowmya695 Nov 10, 2023
8fba241
[MOSIP-29918] added db-test.yml (#1792)
Rakshithb1 Nov 15, 2023
2f81dab
MOSIP-28121 : opencrvs stage funationalities moved to common stage
Sep 12, 2023
efbfaad
MOSIP-28121 : renamed print stage to event handler stage
Sep 13, 2023
12436dd
MOSIP-28121 : Fixed review comments
Sep 22, 2023
0df924b
MOSIP-28121 : Fixed review comments
Sep 22, 2023
c529655
MOSIP-28121 : added partner profile feature
Nov 8, 2023
680437c
MOSIP-28121 : added partner profile feature
Nov 16, 2023
99dc4bc
[ MOSIP-29896 ] Adding pkt_cr_dtimes and setting the packet date and …
Khuddusshariff0022 Nov 28, 2023
2731e30
[DSD-3932] removed release-changes.yml, tag.yml and updated push-trig…
Prafulrakhade Dec 20, 2023
e610ad2
MOSIP-29935 Code changes (#1800)
sowmya695 Dec 26, 2023
e91bc76
[MOSIP-29961] removed paths from db-test.yml (#1816)
Rakshithb1 Jan 2, 2024
1e05699
MOSIP-28121 : calling idrepo instead of packetmanager in credential r…
Jan 2, 2024
5e51989
MOSIP-31016 code changes (#1824)
sowmya695 Jan 10, 2024
4bf02a6
[Mosip-28440] changes to compare the biometric records only with the …
Khuddusshariff0022 Jan 3, 2024
cce16e6
[Mosip-30241] triming the demographic data based on the property
Khuddusshariff0022 Jan 17, 2024
8d93f91
[Mosip-30241] triming the demographic data based on the property
Khuddusshariff0022 Jan 17, 2024
e988d4f
[Mosip-30417] Regproc -Landing zone config property naming convention…
Khuddusshariff0022 Dec 14, 2023
b9c2bfd
registration-processor/registration-processor-core/src/main/java/io/m…
Jan 23, 2024
bd4209c
[Mosip-30241]adding trim functionality based on property (#1837)
Khuddusshariff0022 Jan 24, 2024
290507c
Merge branch 'develop' of https://github.com/mosip/registration into …
Jan 30, 2024
38c1c84
MOSIP-27210 Code review comments fixed
Feb 6, 2024
87d08f4
Merge branch 'develop' of https://github.com/mosip/registration into …
Feb 9, 2024
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
@@ -1,99 +1,155 @@
package io.mosip.registration.processor.stages.packetclassifier.tagging.impl;

import io.mosip.kernel.core.exception.BaseCheckedException;
import io.mosip.kernel.core.logger.spi.Logger;
import io.mosip.registration.processor.core.constant.JsonConstant;
import io.mosip.registration.processor.core.exception.util.PlatformErrorMessages;
import io.mosip.registration.processor.core.logger.RegProcessorLogger;
import io.mosip.registration.processor.packet.storage.exception.ParsingException;
import io.mosip.registration.processor.stages.packetclassifier.dto.FieldDTO;
import io.mosip.registration.processor.stages.packetclassifier.tagging.TagGenerator;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.StringJoiner;

import org.json.JSONException;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.stereotype.Component;

@Component
@ConditionalOnExpression(value = "'${mosip.regproc.packet.classifier.tag-generators}'.contains('MosipExceptionBiometrics')")
public class ExceptionBiometricsTagGenerator implements TagGenerator {

/** Tag name that will used be while tagging exception biometrics */
@Value("${mosip.regproc.packet.classifier.tagging.exceptionbiometrics.tag-name:EXCEPTION_BIOMETRICS}")
private String tagName;

/** This mapping will contain the short words for each missing biometrics, the values will used for concatenating in the tags */
@Value("#{${mosip.regproc.packet.classifier.tagging.exceptionbiometrics.bio-value-mapping:{'leftLittle':'LL','leftRing':'LR','leftMiddle':'LM','leftIndex':'LI','leftThumb':'LT','rightLittle':'RL','rightRing':'RR','rightMiddle':'RM','rightIndex':'RI','rightThumb':'RT','leftEye':'LE','rightEye':'RE'}}}")
private Map<String,String> bioValueMapping;

/** The tag value that will be used by default when the packet does not have value for the tag field */
@Value("${mosip.regproc.packet.classifier.tagging.not-available-tag-value}")
private String notAvailableTagValue;

/** The reg proc logger. */
private static Logger regProcLogger = RegProcessorLogger.getLogger(ExceptionBiometricsTagGenerator.class);

private static String BIOMETRICS_DELIMITER = ",";

/**
* {@inheritDoc}
*/
@Override
public List<String> getRequiredIdObjectFieldNames() throws BaseCheckedException {
return null;
}

/**
* {@inheritDoc}
*/
@Override
public Map<String, String> generateTags(String workflowInstanceId, String registrationId, String process,
Map<String, FieldDTO> idObjectFieldDTOMap, Map<String, String> metaInfoMap, int iteration) throws BaseCheckedException {
try {
Map<String, String> tags = new HashMap<String, String>(1);
String exceptionBiometricsString = metaInfoMap.get(JsonConstant.EXCEPTIONBIOMETRICS);
if(exceptionBiometricsString == null) {
regProcLogger.warn("{} --> {}, setting tag value as {}",
PlatformErrorMessages.RPR_PCM_EXCEPTION_BIOMETRICS_ENTRY_NOT_AVAILABLE.getCode(),
PlatformErrorMessages.RPR_PCM_EXCEPTION_BIOMETRICS_ENTRY_NOT_AVAILABLE.getMessage(),
notAvailableTagValue);
tags.put(tagName, notAvailableTagValue);
return tags;
}
JSONObject exceptionBiometricsJsonObject = new JSONObject(exceptionBiometricsString);
if(!exceptionBiometricsJsonObject.has(JsonConstant.EXCEPTIONBIOMETRICSAPPLICANT)) {
regProcLogger.warn("{} --> {}, setting tag value as {}",
PlatformErrorMessages.RPR_PCM_EXCEPTION_BIOMETRICS_APPLICANT_ENTRY_NOT_AVAILABLE.getCode(),
PlatformErrorMessages.RPR_PCM_EXCEPTION_BIOMETRICS_APPLICANT_ENTRY_NOT_AVAILABLE.getMessage(),
notAvailableTagValue);
tags.put(tagName, notAvailableTagValue);
return tags;
}
JSONObject applicantJsonObject = exceptionBiometricsJsonObject.getJSONObject(
JsonConstant.EXCEPTIONBIOMETRICSAPPLICANT);

if (applicantJsonObject == null || applicantJsonObject.length() == 0)
tags.put(tagName, "");
else {
StringJoiner exceptionBiometricStringJoiner = new StringJoiner(BIOMETRICS_DELIMITER);
for(Map.Entry<String,String> entry : bioValueMapping.entrySet()) {
if(applicantJsonObject.has(entry.getKey()))
exceptionBiometricStringJoiner.add(entry.getValue());
}
tags.put(tagName, exceptionBiometricStringJoiner.toString());
}

return tags;
} catch (JSONException e) {
throw new ParsingException(
PlatformErrorMessages.RPR_PCM_META_INFO_JSON_PARSING_FAILED.getMessage(), e);
}
}

}
package io.mosip.registration.processor.stages.packetclassifier.tagging.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.StringJoiner;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.stereotype.Component;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

import io.mosip.kernel.core.exception.BaseCheckedException;
import io.mosip.kernel.core.logger.spi.Logger;
import io.mosip.kernel.core.util.StringUtils;
import io.mosip.registration.processor.core.constant.JsonConstant;
import io.mosip.registration.processor.core.exception.util.PlatformErrorMessages;
import io.mosip.registration.processor.core.logger.RegProcessorLogger;
import io.mosip.registration.processor.core.packet.dto.FieldValue;
import io.mosip.registration.processor.packet.storage.exception.ParsingException;
import io.mosip.registration.processor.stages.packetclassifier.dto.FieldDTO;
import io.mosip.registration.processor.stages.packetclassifier.tagging.TagGenerator;

@Component
@ConditionalOnExpression(value = "'${mosip.regproc.packet.classifier.tag-generators}'.contains('MosipExceptionBiometrics')")
public class ExceptionBiometricsTagGenerator implements TagGenerator {

/** Tag name that will used be while tagging exception biometrics */
@Value("${mosip.regproc.packet.classifier.tagging.exceptionbiometrics.tag-name:EXCEPTION_BIOMETRICS}")
private String tagName;

/** This mapping will contain the short words for each missing biometrics, the values will used for concatenating in the tags */
@Value("#{${mosip.regproc.packet.classifier.tagging.exceptionbiometrics.bio-value-mapping:{'leftLittle':'LL','leftRing':'LR','leftMiddle':'LM','leftIndex':'LI','leftThumb':'LT','rightLittle':'RL','rightRing':'RR','rightMiddle':'RM','rightIndex':'RI','rightThumb':'RT','leftEye':'LE','rightEye':'RE'}}}")
private Map<String,String> bioValueMapping;

/** The tag value that will be used by default when the packet does not have value for the tag field */
@Value("${mosip.regproc.packet.classifier.tagging.not-available-tag-value}")
private String notAvailableTagValue;

@Value("#{T(java.util.Arrays).asList('${mosip.regproc.packet.classifier.tagging.exceptionbiometrics.before-exception-metainfo-change.reg-client-versions:}')}")
private List<String> regClientVersionsBeforeExceptionMetaInfoChange;

/** The reg proc logger. */
private static Logger regProcLogger = RegProcessorLogger.getLogger(ExceptionBiometricsTagGenerator.class);

private static String BIOMETRICS_DELIMITER = ",";

@Autowired
ObjectMapper mapper;

/**
* {@inheritDoc}
*/
@Override
public List<String> getRequiredIdObjectFieldNames() throws BaseCheckedException {
return null;
}

/**
* {@inheritDoc}
*/
@Override
public Map<String, String> generateTags(String workflowInstanceId, String registrationId, String process,
Map<String, FieldDTO> idObjectFieldDTOMap, Map<String, String> metaInfoMap, int iteration) throws BaseCheckedException {
try {
Map<String, String> tags = new HashMap<String, String>(1);
String exceptionBiometricsString = metaInfoMap.get(JsonConstant.EXCEPTIONBIOMETRICS);
if(exceptionBiometricsString == null) {
regProcLogger.warn("{} --> {}, setting tag value as {}",
PlatformErrorMessages.RPR_PCM_EXCEPTION_BIOMETRICS_ENTRY_NOT_AVAILABLE.getCode(),
PlatformErrorMessages.RPR_PCM_EXCEPTION_BIOMETRICS_ENTRY_NOT_AVAILABLE.getMessage(),
notAvailableTagValue);
tags.put(tagName, notAvailableTagValue);
return tags;
}
JSONObject exceptionBiometricsJsonObject = new JSONObject(exceptionBiometricsString);
String regClientVersion = getRegClientVersionFromMetaInfo(registrationId, process, metaInfoMap);
JSONObject applicantJsonObject = null;
// if the version is not found in metainfo then consider it is as older and
// expect applicant to be available inside the exception biometrics
if (regClientVersion == null || (regClientVersion != null
&& regClientVersionsBeforeExceptionMetaInfoChange.contains(regClientVersion))) {
if (!exceptionBiometricsJsonObject.has(JsonConstant.EXCEPTIONBIOMETRICSAPPLICANT)) {
regProcLogger.warn("{} --> {}, setting tag value as {}",
PlatformErrorMessages.RPR_PCM_EXCEPTION_BIOMETRICS_APPLICANT_ENTRY_NOT_AVAILABLE.getCode(),
PlatformErrorMessages.RPR_PCM_EXCEPTION_BIOMETRICS_APPLICANT_ENTRY_NOT_AVAILABLE
.getMessage(),
notAvailableTagValue);
tags.put(tagName, notAvailableTagValue);
return tags;
}
applicantJsonObject = exceptionBiometricsJsonObject
.getJSONObject(JsonConstant.EXCEPTIONBIOMETRICSAPPLICANT);

} else {
if (!exceptionBiometricsJsonObject.has(JsonConstant.INDIVIDUAL_BIOMETRICS)) {
regProcLogger.warn("{} --> {}, setting tag value as {}",
PlatformErrorMessages.RPR_PCM_EXCEPTION_BIOMETRICS_APPLICANT_ENTRY_NOT_AVAILABLE.getCode(),
PlatformErrorMessages.RPR_PCM_EXCEPTION_BIOMETRICS_APPLICANT_ENTRY_NOT_AVAILABLE
.getMessage(),
notAvailableTagValue);
tags.put(tagName, notAvailableTagValue);
return tags;
}
applicantJsonObject = exceptionBiometricsJsonObject
.getJSONObject(JsonConstant.INDIVIDUAL_BIOMETRICS);
}


if (applicantJsonObject == null || applicantJsonObject.length() == 0)
tags.put(tagName, "");
else {
StringJoiner exceptionBiometricStringJoiner = new StringJoiner(BIOMETRICS_DELIMITER);
for(Map.Entry<String,String> entry : bioValueMapping.entrySet()) {
if(applicantJsonObject.has(entry.getKey()))
exceptionBiometricStringJoiner.add(entry.getValue());
}
tags.put(tagName, exceptionBiometricStringJoiner.toString());
}

return tags;
} catch (JSONException | JsonProcessingException e) {
throw new ParsingException(
PlatformErrorMessages.RPR_PCM_META_INFO_JSON_PARSING_FAILED.getMessage(), e);
}
}

private String getRegClientVersionFromMetaInfo(String id, String process, Map<String, String> metaInfoMap)
throws JSONException, JsonProcessingException
{
String metadata = metaInfoMap.get(JsonConstant.METADATA);
String version = null;
if (StringUtils.isNotEmpty(metadata)) {
JSONArray jsonArray = new JSONArray(metadata);

for (int i = 0; i < jsonArray.length(); i++) {
if (!jsonArray.isNull(i)) {
org.json.JSONObject jsonObject = (org.json.JSONObject) jsonArray.get(i);
FieldValue fieldValue = mapper.readValue(jsonObject.toString(), FieldValue.class);
if (fieldValue.getLabel().equalsIgnoreCase(JsonConstant.REGCLIENTVERSION)) {
version = fieldValue.getValue();
break;
}
}
}
}
return version;
}
}
Loading
Loading