-
Notifications
You must be signed in to change notification settings - Fork 176
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1841 from sowmya695/MOSIP-29868_Feb
[MOSIP-29868] Code fix after testing
- Loading branch information
Showing
4 changed files
with
367 additions
and
327 deletions.
There are no files selected for viewing
222 changes: 115 additions & 107 deletions
222
...upe-stage/src/main/java/io/mosip/registration/processor/stages/demodedupe/DemoDedupe.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,107 +1,115 @@ | ||
package io.mosip.registration.processor.stages.demodedupe; | ||
|
||
import java.util.ArrayList; | ||
import java.util.HashSet; | ||
import java.util.List; | ||
import java.util.Set; | ||
import java.util.stream.Collectors; | ||
|
||
import io.mosip.registration.processor.core.packet.dto.Identity; | ||
import io.mosip.registration.processor.core.packet.dto.abis.RegBioRefDto; | ||
import io.mosip.registration.processor.core.spi.packetmanager.PacketInfoManager; | ||
import io.mosip.registration.processor.packet.storage.dto.ApplicantInfoDto; | ||
import org.apache.commons.collections.CollectionUtils; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.core.env.Environment; | ||
import org.springframework.stereotype.Component; | ||
|
||
import io.mosip.kernel.core.logger.spi.Logger; | ||
import io.mosip.registration.processor.core.constant.LoggerFileConstant; | ||
import io.mosip.registration.processor.core.logger.RegProcessorLogger; | ||
import io.mosip.registration.processor.core.packet.dto.demographicinfo.DemographicInfoDto; | ||
import io.mosip.registration.processor.packet.storage.dao.PacketInfoDao; | ||
import io.mosip.registration.processor.stages.app.constants.DemoDedupeConstants; | ||
import io.mosip.registration.processor.status.service.RegistrationStatusService; | ||
|
||
/** | ||
* The Class DemoDedupe. | ||
* | ||
* @author M1048358 Alok Ranjan | ||
* @author M1048860 Kiran Raj | ||
*/ | ||
@Component | ||
public class DemoDedupe { | ||
|
||
/** The reg proc logger. */ | ||
private static Logger regProcLogger = RegProcessorLogger.getLogger(DemoDedupe.class); | ||
|
||
/** The env. */ | ||
@Autowired | ||
private Environment env; | ||
|
||
@Autowired | ||
private RegistrationStatusService registrationStatusService; | ||
|
||
/** The packet info dao. */ | ||
@Autowired | ||
private PacketInfoDao packetInfoDao; | ||
|
||
/** The packet info manager. */ | ||
@Autowired | ||
private PacketInfoManager<Identity, ApplicantInfoDto> packetInfoManager; | ||
|
||
/** | ||
* Perform dedupe. | ||
* | ||
* @param refId | ||
* the ref id | ||
* @return the list | ||
*/ | ||
public List<DemographicInfoDto> performDedupe(String refId) { | ||
regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REFFERENCEID.toString(), refId, | ||
"DemoDedupe::performDedupe()::entry"); | ||
|
||
List<DemographicInfoDto> applicantDemoDto = packetInfoDao.findDemoById(refId); | ||
List<DemographicInfoDto> matchedIdsWithUin; | ||
List<DemographicInfoDto> demographicInfoDtos; | ||
Set<DemographicInfoDto> infoDtos = new HashSet<>(); | ||
for (DemographicInfoDto demoDto : applicantDemoDto) { | ||
infoDtos.addAll(packetInfoDao.getAllDemographicInfoDtos(demoDto.getName(), demoDto.getGenderCode(), | ||
demoDto.getDob(), demoDto.getLangCode())); | ||
} | ||
matchedIdsWithUin = getAllDemographicInfoDtosWithUin(infoDtos); | ||
demographicInfoDtos = filterByRefIdAvailability(matchedIdsWithUin); | ||
|
||
regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REFFERENCEID.toString(), refId, | ||
"DemoDedupe::performDedupe()::exit"); | ||
return demographicInfoDtos; | ||
} | ||
|
||
private List<DemographicInfoDto> getAllDemographicInfoDtosWithUin( | ||
Set<DemographicInfoDto> duplicateDemographicDtos) { | ||
List<DemographicInfoDto> demographicInfoDtosWithUin = new ArrayList<>(); | ||
for (DemographicInfoDto demographicDto : duplicateDemographicDtos) { | ||
if (registrationStatusService.checkUinAvailabilityForRid(demographicDto.getRegId())) { | ||
demographicInfoDtosWithUin.add(demographicDto); | ||
} | ||
|
||
} | ||
return demographicInfoDtosWithUin; | ||
} | ||
|
||
private List<DemographicInfoDto> filterByRefIdAvailability(List<DemographicInfoDto> duplicateDemographicDtos) { | ||
List<DemographicInfoDto> demographicInfoDtosWithRefId = new ArrayList<>(); | ||
if (CollectionUtils.isNotEmpty(duplicateDemographicDtos)) { | ||
List<String> regIds = duplicateDemographicDtos.stream().map(dto -> dto.getRegId()).collect(Collectors.toList()); | ||
List<RegBioRefDto> finalRegBioRefDtos = packetInfoManager.getBioRefIdsByRegIds(regIds); | ||
if (CollectionUtils.isNotEmpty(finalRegBioRefDtos)) { | ||
List<String> finalRegIds = finalRegBioRefDtos.stream().map(dto -> dto.getRegId()).collect(Collectors.toList()); | ||
demographicInfoDtosWithRefId.addAll(duplicateDemographicDtos.stream().filter( | ||
dto -> finalRegIds.contains(dto.getRegId())).collect(Collectors.toList())); | ||
} | ||
} | ||
return demographicInfoDtosWithRefId; | ||
} | ||
|
||
|
||
} | ||
package io.mosip.registration.processor.stages.demodedupe; | ||
|
||
import java.util.ArrayList; | ||
import java.util.HashSet; | ||
import java.util.List; | ||
import java.util.Set; | ||
import java.util.stream.Collectors; | ||
|
||
import org.apache.commons.collections.CollectionUtils; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.core.env.Environment; | ||
import org.springframework.stereotype.Component; | ||
|
||
import io.mosip.kernel.core.logger.spi.Logger; | ||
import io.mosip.registration.processor.core.constant.LoggerFileConstant; | ||
import io.mosip.registration.processor.core.logger.RegProcessorLogger; | ||
import io.mosip.registration.processor.core.packet.dto.Identity; | ||
import io.mosip.registration.processor.core.packet.dto.abis.RegBioRefDto; | ||
import io.mosip.registration.processor.core.packet.dto.demographicinfo.DemographicInfoDto; | ||
import io.mosip.registration.processor.core.spi.packetmanager.PacketInfoManager; | ||
import io.mosip.registration.processor.packet.storage.dao.PacketInfoDao; | ||
import io.mosip.registration.processor.packet.storage.dto.ApplicantInfoDto; | ||
import io.mosip.registration.processor.status.service.RegistrationStatusService; | ||
|
||
/** | ||
* The Class DemoDedupe. | ||
* | ||
* @author M1048358 Alok Ranjan | ||
* @author M1048860 Kiran Raj | ||
*/ | ||
@Component | ||
public class DemoDedupe { | ||
|
||
/** The reg proc logger. */ | ||
private static Logger regProcLogger = RegProcessorLogger.getLogger(DemoDedupe.class); | ||
|
||
/** The env. */ | ||
@Autowired | ||
private Environment env; | ||
|
||
@Autowired | ||
private RegistrationStatusService registrationStatusService; | ||
|
||
/** The packet info dao. */ | ||
@Autowired | ||
private PacketInfoDao packetInfoDao; | ||
|
||
/** The packet info manager. */ | ||
@Autowired | ||
private PacketInfoManager<Identity, ApplicantInfoDto> packetInfoManager; | ||
|
||
@Value("${mosip.regproc.demo.dedupe.skip-refid-check-for-infant-dedupe:false}") | ||
private boolean skipRefIdCheckForInfantDeduplication; | ||
|
||
/** | ||
* Perform dedupe. | ||
* | ||
* @param refId | ||
* the ref id | ||
* @return the list | ||
*/ | ||
public List<DemographicInfoDto> performDedupe(String refId, boolean isInfant) { | ||
regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REFFERENCEID.toString(), refId, | ||
"DemoDedupe::performDedupe()::entry"); | ||
|
||
List<DemographicInfoDto> applicantDemoDto = packetInfoDao.findDemoById(refId); | ||
List<DemographicInfoDto> matchedIdsWithUin; | ||
List<DemographicInfoDto> demographicInfoDtos; | ||
Set<DemographicInfoDto> infoDtos = new HashSet<>(); | ||
for (DemographicInfoDto demoDto : applicantDemoDto) { | ||
infoDtos.addAll(packetInfoDao.getAllDemographicInfoDtos(demoDto.getName(), demoDto.getGenderCode(), | ||
demoDto.getDob(), demoDto.getLangCode())); | ||
} | ||
matchedIdsWithUin = getAllDemographicInfoDtosWithUin(infoDtos); | ||
if (isInfant && skipRefIdCheckForInfantDeduplication) { | ||
demographicInfoDtos = new ArrayList<>(); | ||
demographicInfoDtos.addAll(matchedIdsWithUin); | ||
} else { | ||
demographicInfoDtos = filterByRefIdAvailability(matchedIdsWithUin); | ||
} | ||
|
||
regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REFFERENCEID.toString(), refId, | ||
"DemoDedupe::performDedupe()::exit"); | ||
return demographicInfoDtos; | ||
} | ||
|
||
private List<DemographicInfoDto> getAllDemographicInfoDtosWithUin( | ||
Set<DemographicInfoDto> duplicateDemographicDtos) { | ||
List<DemographicInfoDto> demographicInfoDtosWithUin = new ArrayList<>(); | ||
for (DemographicInfoDto demographicDto : duplicateDemographicDtos) { | ||
if (registrationStatusService.checkUinAvailabilityForRid(demographicDto.getRegId())) { | ||
demographicInfoDtosWithUin.add(demographicDto); | ||
} | ||
|
||
} | ||
return demographicInfoDtosWithUin; | ||
} | ||
|
||
private List<DemographicInfoDto> filterByRefIdAvailability(List<DemographicInfoDto> duplicateDemographicDtos) { | ||
List<DemographicInfoDto> demographicInfoDtosWithRefId = new ArrayList<>(); | ||
if (CollectionUtils.isNotEmpty(duplicateDemographicDtos)) { | ||
List<String> regIds = duplicateDemographicDtos.stream().map(dto -> dto.getRegId()).collect(Collectors.toList()); | ||
List<RegBioRefDto> finalRegBioRefDtos = packetInfoManager.getBioRefIdsByRegIds(regIds); | ||
if (CollectionUtils.isNotEmpty(finalRegBioRefDtos)) { | ||
List<String> finalRegIds = finalRegBioRefDtos.stream().map(dto -> dto.getRegId()).collect(Collectors.toList()); | ||
demographicInfoDtosWithRefId.addAll(duplicateDemographicDtos.stream().filter( | ||
dto -> finalRegIds.contains(dto.getRegId())).collect(Collectors.toList())); | ||
} | ||
} | ||
return demographicInfoDtosWithRefId; | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.