Skip to content

Commit

Permalink
Revert "[MOSIP-34112] Release 1.2.0.x code marge for Bio-dedupes upda…
Browse files Browse the repository at this point in the history
…ted flow…"

This reverts commit b9c907c.
  • Loading branch information
vishwa-vyom authored Aug 12, 2024
1 parent 33911bd commit e9e0400
Show file tree
Hide file tree
Showing 4 changed files with 672 additions and 966 deletions.
Original file line number Diff line number Diff line change
@@ -1,47 +1,45 @@
package io.mosip.registration.processor.biodedupe.constants;

public class BioDedupeConstants {

/** The Constant FILE_SEPARATOR. */
public static final String FILE_SEPARATOR = "\\";

/** The Constant INDIVIDUAL_BIOMETRICS. */
public static final String INDIVIDUAL_BIOMETRICS = "individualBiometrics";

public static final String VALUE = "value";

public static final String CBEFF_PRESENT_IN_PACKET = "Cbeff is present in the packet, destination stage is abis_handler";

public static final String CBEFF_NOT_PRESENT_IN_PACKET = "Cbeff is not present in the packet. This will be sent to manual verification.";

public static final String CBEFF_ABSENT_IN_PACKET = "Cbeff is absent in the packet for child, destination stage is UIN";

public static final String UPDATE_PACKET_BIOMETRIC_NOT_NULL = "Update packet individual biometric not null, destination stage is abis_handler";

public static final String UPDATE_PACKET_BIOMETRIC_NULL = "Update packet individual biometric null, destination stage is UIN";

public static final String ABIS_RESPONSE_NOT_NULL = "ABIS response Details not null, destination stage is Manual_verification";

public static final String ABIS_RESPONSE_NULL = "ABIS response Details null, destination stage is UIN";

public static final String CBEFF_NOT_FOUND = "Cbeff not found for the lost packet";

public static final String APPLICANT_TYPE_CHILD = "Applicant type is child and Cbeff not present returning false";

public static final String APPLICANT_TYPE_ADULT = "Applicant type is adult and Cbeff not present throwing exception";

public static final String LOST_PRE_ABIS_IDENTITIFICATION = "Lost Packet Pre abis identification";

public static final String NO_MATCH_FOUND_FOR_LOST = "No match found, rejecting the lost packet for ";

public static final String FOUND_UIN_IN_BIO_CHECK = "Found a matching UIN in bio check for the lost packet ";

public static final String FOUND_UIN_IN_DEMO_CHECK = "Found a matching UIN in demo check for the lost packet ";

public static final String MULTIPLE_RID_FOUND = "Multiple matched regId found, saving data in manual verification";

/** The Constant INTERNAL_ERROR. */
private static final String INTERNAL_ERROR = "Internal error occurred in bio-dedupe stage while processing for registrationId ";

public static final String BIOMETRIC_MATCH_FOUND_WITH_OTHER = "Biometric match found with other user, rejecting packet for ";
}
package io.mosip.registration.processor.biodedupe.constants;

public class BioDedupeConstants {

/** The Constant FILE_SEPARATOR. */
public static final String FILE_SEPARATOR = "\\";

/** The Constant INDIVIDUAL_BIOMETRICS. */
public static final String INDIVIDUAL_BIOMETRICS = "individualBiometrics";

public static final String VALUE = "value";

public static final String CBEFF_PRESENT_IN_PACKET = "Cbeff is present in the packet, destination stage is abis_handler";

public static final String CBEFF_NOT_PRESENT_IN_PACKET = "Cbeff is not present in the packet. This will be sent to manual verification.";

public static final String CBEFF_ABSENT_IN_PACKET = "Cbeff is absent in the packet for child, destination stage is UIN";

public static final String UPDATE_PACKET_BIOMETRIC_NOT_NULL = "Update packet individual biometric not null, destination stage is abis_handler";

public static final String UPDATE_PACKET_BIOMETRIC_NULL = "Update packet individual biometric null, destination stage is UIN";

public static final String ABIS_RESPONSE_NOT_NULL = "ABIS response Details not null, destination stage is Manual_verification";

public static final String ABIS_RESPONSE_NULL = "ABIS response Details null, destination stage is UIN";

public static final String CBEFF_NOT_FOUND = "Cbeff not found for the lost packet";

public static final String APPLICANT_TYPE_CHILD = "Applicant type is child and Cbeff not present returning false";

public static final String APPLICANT_TYPE_ADULT = "Applicant type is adult and Cbeff not present throwing exception";

public static final String LOST_PRE_ABIS_IDENTITIFICATION = "Lost Packet Pre abis identification";

public static final String NO_MATCH_FOUND_FOR_LOST = "No match found, rejecting the lost packet for ";

public static final String FOUND_UIN_IN_BIO_CHECK = "Found a matching UIN in bio check for the lost packet ";

public static final String FOUND_UIN_IN_DEMO_CHECK = "Found a matching UIN in demo check for the lost packet ";

public static final String MULTIPLE_RID_FOUND = "Multiple matched regId found, saving data in manual verification";

/** The Constant INTERNAL_ERROR. */
private static final String INTERNAL_ERROR = "Internal error occurred in bio-dedupe stage while processing for registrationId ";
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
package io.mosip.registration.processor.biodedupe.stage;

import java.io.IOException;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.apache.commons.lang3.exception.ExceptionUtils;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import io.mosip.kernel.core.logger.spi.Logger;
import io.mosip.kernel.core.util.StringUtils;
import io.mosip.kernel.core.util.exception.JsonProcessingException;
Expand All @@ -8,11 +24,19 @@
import io.mosip.registration.processor.biodedupe.stage.exception.CbeffNotFoundException;
import io.mosip.registration.processor.core.abstractverticle.MessageBusAddress;
import io.mosip.registration.processor.core.abstractverticle.MessageDTO;
import io.mosip.registration.processor.core.code.DedupeSourceName;
import io.mosip.registration.processor.core.code.EventId;
import io.mosip.registration.processor.core.code.EventName;
import io.mosip.registration.processor.core.code.EventType;
import io.mosip.registration.processor.core.code.*;
import io.mosip.registration.processor.core.constant.*;
import io.mosip.registration.processor.core.code.ModuleName;
import io.mosip.registration.processor.core.code.RegistrationExceptionTypeCode;
import io.mosip.registration.processor.core.code.RegistrationTransactionStatusCode;
import io.mosip.registration.processor.core.code.RegistrationTransactionTypeCode;
import io.mosip.registration.processor.core.constant.AbisConstant;
import io.mosip.registration.processor.core.constant.LoggerFileConstant;
import io.mosip.registration.processor.core.constant.MappingJsonConstants;
import io.mosip.registration.processor.core.constant.ProviderStageName;
import io.mosip.registration.processor.core.constant.RegistrationType;
import io.mosip.registration.processor.core.exception.ApisResourceAccessException;
import io.mosip.registration.processor.core.exception.PacketDecryptionFailureException;
import io.mosip.registration.processor.core.exception.PacketManagerException;
Expand Down Expand Up @@ -41,17 +65,6 @@
import io.mosip.registration.processor.status.dto.RegistrationStatusDto;
import io.mosip.registration.processor.status.dto.SyncTypeDto;
import io.mosip.registration.processor.status.service.RegistrationStatusService;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.io.IOException;
import java.util.*;

/**
* The Class BioDedupeProcessor.
Expand Down Expand Up @@ -119,9 +132,6 @@ public class BioDedupeProcessor {
@Value("${registration.processor.missing.biometric.verification.enabled:true}")
private boolean missingBiometricVerificationEnabled;

@Value("${registration.processor.biometrics-update.single-match.auto-reject.enabled:false}")
private boolean biometricsUpdateSingleMatchAutoReject;

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

Expand Down Expand Up @@ -170,7 +180,9 @@ public MessageDTO process(MessageDTO object, String stageName) {
newPacketPreAbisIdentification(registrationStatusDto, object);
} else if (packetStatus.equalsIgnoreCase(AbisConstant.POST_ABIS_IDENTIFICATION)) {
postAbisIdentification(registrationStatusDto, object, registrationType);

}

} else if (registrationType.equalsIgnoreCase(SyncTypeDto.UPDATE.toString())
|| registrationType.equalsIgnoreCase(SyncTypeDto.RES_UPDATE.toString())) {
String packetStatus = abisHandlerUtil.getPacketStatus(registrationStatusDto);
Expand Down Expand Up @@ -404,10 +416,6 @@ private void postAbisIdentification(InternalRegistrationStatusDto registrationSt
io.mosip.kernel.core.exception.IOException, JsonProcessingException, PacketManagerException {
String moduleId = "";
String moduleName = ModuleName.BIO_DEDUPE.toString();
/* This method returns combination of below RIDs :
- RIDs which are in PROCESSING state (Except current packet RID)
- RIDs (For which UIN is generated and it reached to RID repo) associated with UINs other than current packet UIN i.e it removes the RIDs which are associated with current packet UIN.
*/
Set<String> matchedRegIds = abisHandlerUtil.getUniqueRegIds(registrationStatusDto.getRegistrationId(),
registrationType, registrationStatusDto.getIteration(), registrationStatusDto.getWorkflowInstanceId(), ProviderStageName.BIO_DEDUPE);
ArrayList<String> matchedRegIdsList = new ArrayList<String>(matchedRegIds);
Expand All @@ -425,83 +433,26 @@ private void postAbisIdentification(InternalRegistrationStatusDto registrationSt
registrationStatusDto.setSubStatusCode(StatusUtil.BIO_DEDUPE_SUCCESS.getCode());
regProcLogger.info(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(),
registrationStatusDto.getRegistrationId(), BioDedupeConstants.ABIS_RESPONSE_NULL);

} else {
if (registrationType.equalsIgnoreCase(RegistrationType.UPDATE.name())) {
handlePostAbisIdentificationForUpdate(registrationStatusDto, object, registrationType, moduleName,
matchedRegIds);
}else {
sendToManualAdjudicationStage(registrationStatusDto, object, registrationType, moduleName, matchedRegIds);
regProcLogger.info(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(),
registrationStatusDto.setStatusCode(RegistrationStatusCode.FAILED.name());
registrationStatusDto.setStatusComment(StatusUtil.BIO_DEDUPE_POTENTIAL_MATCH.getMessage());
registrationStatusDto.setSubStatusCode(StatusUtil.BIO_DEDUPE_POTENTIAL_MATCH.getCode());
registrationStatusDto.setLatestTransactionStatusCode(RegistrationTransactionStatusCode.FAILED.toString());
moduleId = PlatformSuccessMessages.RPR_BIO_METRIC_POTENTIAL_MATCH.getCode();
packetInfoManager.saveManualAdjudicationData(matchedRegIds, object,
DedupeSourceName.BIO, moduleId, moduleName,null,null);
//send message to manual adjudication
object.setInternalError(Boolean.FALSE);
object.setRid(registrationStatusDto.getRegistrationId());
object.setIsValid(Boolean.TRUE);
object.setReg_type(registrationType);
object.setMessageBusAddress(MessageBusAddress.MANUAL_ADJUDICATION_BUS_IN);

regProcLogger.info(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(),
registrationStatusDto.getRegistrationId(), BioDedupeConstants.ABIS_RESPONSE_NOT_NULL);
}
}
}

private void handlePostAbisIdentificationForUpdate(InternalRegistrationStatusDto registrationStatusDto, MessageDTO object,
String registrationType, String moduleName, Set<String> matchedRegIds)
throws IOException, ApisResourceAccessException, PacketManagerException, JsonProcessingException {
Set<String> uniqueUins = new HashSet<String>();
boolean sendToManualAdjudication = false;
for(String matchedRegistrationId:matchedRegIds) {
String uin = idRepoService.getUinByRid(matchedRegistrationId, utilities.getGetRegProcessorDemographicIdentity());
if (StringUtils.isEmpty(uin)) {
InternalRegistrationStatusDto matchedRegistrationStatusDto = registrationStatusService
.getRegistrationStatus(matchedRegistrationId, null, null, null);
if (matchedRegistrationStatusDto.getStatusCode()
.equals(RegistrationStatusCode.PROCESSING.name())) {
sendToManualAdjudication = true;
break;
}
} else {
uniqueUins.add(uin);
}
}
regProcLogger.info(LoggerFileConstant.SESSIONID.toString(),
LoggerFileConstant.REGISTRATIONID.toString(), registrationStatusDto.getRegistrationId(),
"sendToManualAdjudication : " + sendToManualAdjudication + " ::uniqueUins count : " + uniqueUins.size() +
" ::biometricsUpdateSingleMatchAutoReject : " + biometricsUpdateSingleMatchAutoReject);
if (sendToManualAdjudication || uniqueUins.size() > 1) {
sendToManualAdjudicationStage(registrationStatusDto, object, registrationType, moduleName,
matchedRegIds);
} else {
//Single match of uin found which is different from update packet uin.
if (biometricsUpdateSingleMatchAutoReject) {
registrationStatusDto.setLatestTransactionStatusCode(
RegistrationTransactionStatusCode.FAILED.toString());
object.setIsValid(Boolean.FALSE);
registrationStatusDto.setStatusCode(RegistrationStatusCode.REJECTED.name());
registrationStatusDto
.setStatusComment(StatusUtil. UPDATE_PACKET_BIOMETRICS_MATCHED_WITH_OTHER.getMessage());
registrationStatusDto
.setSubStatusCode(StatusUtil. UPDATE_PACKET_BIOMETRICS_MATCHED_WITH_OTHER.getCode());
regProcLogger.info(LoggerFileConstant.SESSIONID.toString(),
LoggerFileConstant.REGISTRATIONID.toString(),
registrationStatusDto.getRegistrationId(),
BioDedupeConstants.BIOMETRIC_MATCH_FOUND_WITH_OTHER
+ registrationStatusDto.getRegistrationId());
} else {
sendToManualAdjudicationStage(registrationStatusDto, object, registrationType, moduleName,
matchedRegIds);
}
}
}

private void sendToManualAdjudicationStage(InternalRegistrationStatusDto registrationStatusDto, MessageDTO object,
String registrationType, String moduleName, Set<String> matchedRegIds) {
String moduleId;
registrationStatusDto.setStatusCode(RegistrationStatusCode.FAILED.name());
registrationStatusDto.setStatusComment(StatusUtil.BIO_DEDUPE_POTENTIAL_MATCH.getMessage());
registrationStatusDto.setSubStatusCode(StatusUtil.BIO_DEDUPE_POTENTIAL_MATCH.getCode());
registrationStatusDto.setLatestTransactionStatusCode(RegistrationTransactionStatusCode.FAILED.toString());
moduleId = PlatformSuccessMessages.RPR_BIO_METRIC_POTENTIAL_MATCH.getCode();
packetInfoManager.saveManualAdjudicationData(matchedRegIds, object,
DedupeSourceName.BIO, moduleId, moduleName,null,null);
//send message to manual adjudication
object.setInternalError(Boolean.FALSE);
object.setRid(registrationStatusDto.getRegistrationId());
object.setIsValid(Boolean.TRUE);
object.setReg_type(registrationType);
object.setMessageBusAddress(MessageBusAddress.MANUAL_ADJUDICATION_BUS_IN);
}

/**
Expand Down
Loading

0 comments on commit e9e0400

Please sign in to comment.