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

feat(FSADT1-1396|FSADT1-1398): added frontend fuzzy match for remaining client types #1081

Merged
merged 26 commits into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
808ae4b
chore: adding new flag to match result and changing contact and location
paulushcgcj Aug 13, 2024
89e6a63
feat(FSADT1-1396): added fuzzy matching for registered business
paulushcgcj Aug 14, 2024
91008aa
feat(FSADT1-1396): renaming some fields on fuzzy match
paulushcgcj Aug 14, 2024
61d559a
feat(FSADT1-1396): updating fuzzy mock and mappings
paulushcgcj Aug 14, 2024
c7ac88f
test(FSADT1-1396): added tests to individual and registered fuzzy match
paulushcgcj Aug 14, 2024
c38c554
test(FSADT1-1398): added tests to other types of fuzzy on step 1
paulushcgcj Aug 14, 2024
40f3fc8
chore(FSADT1-1396): renaming some fields on fuzzy match
paulushcgcj Aug 14, 2024
b92241b
chore(FSADT1-1398): renaming some fields on fuzzy match
paulushcgcj Aug 14, 2024
37148cb
Merge branch 'main' into feat/FSADT1-1396
paulushcgcj Aug 14, 2024
06aff9b
fix(FSADT1-1398): fixing test cases
paulushcgcj Aug 14, 2024
8ae977d
text: fixing failing test
paulushcgcj Aug 14, 2024
3115525
test: reduced the wait time on cypress
paulushcgcj Aug 14, 2024
7470fc2
chore: added missing intercept
paulushcgcj Aug 14, 2024
8dd4e31
chore: added missing stubs
paulushcgcj Aug 14, 2024
00efdd1
Merge branch 'main' into feat/FSADT1-1396
paulushcgcj Aug 15, 2024
a567adb
fix(FSADT1-1396): fixed identification fuzzy
paulushcgcj Aug 15, 2024
fb79e3c
chore: updating fuzzy match
paulushcgcj Aug 15, 2024
ea0edcb
chore(FSADT1-1398): removing pending match for other individual
paulushcgcj Aug 15, 2024
47ecdca
fix: fixed fuzzy match field association
paulushcgcj Aug 15, 2024
eaa7cf1
chore: added missing intercept
paulushcgcj Aug 15, 2024
de3bab4
test: fixing wrong check on test
paulushcgcj Aug 15, 2024
c1d7fbf
Merge branch 'main' into feat/FSADT1-1396
mamartinezmejia Aug 15, 2024
b830c95
fix(FSADT1-1396): fixing field name on grouping
paulushcgcj Aug 15, 2024
35b7f91
test: fixing test params
paulushcgcj Aug 15, 2024
9585655
chore: removing console log
paulushcgcj Aug 15, 2024
21b7f0d
Beautified code
mamartinezmejia Aug 15, 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
Expand Up @@ -3,6 +3,7 @@
public record MatchResult(
String field,
String match,
boolean fuzzy
boolean fuzzy,
boolean partialMatch
) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import ca.bc.gov.app.dto.client.ClientContactDto;
import ca.bc.gov.app.dto.client.ClientSubmissionDto;
import ca.bc.gov.app.dto.client.MatchResult;
import ca.bc.gov.app.dto.client.StepMatchEnum;
import ca.bc.gov.app.dto.legacy.ContactSearchDto;
import ca.bc.gov.app.exception.InvalidRequestObjectException;
Expand Down Expand Up @@ -93,64 +94,82 @@ public Mono<Void> matchStep(ClientSubmissionDto dto) {
.stream()
// Fix nonexistent index
.map(address -> address.withIndexed(indexCounter.getAndIncrement()))
.map(contact ->
//Concat all the results for each address
Flux.concat(
processResult(
legacyService
.searchGeneric(
"email",
contact.email()
),
FIELD_NAME_PREFIX + contact.index() + "].emailAddress",
false
).as(Flux::from),
processResult(
legacyService
.searchGeneric(
PHONE_CONSTANT,
contact.phoneNumber()
),
FIELD_NAME_PREFIX + contact.index() + "].businessPhoneNumber",
false
).as(Flux::from),
processResult(
legacyService
.searchGeneric(
PHONE_CONSTANT,
contact.secondaryPhoneNumber()
),
FIELD_NAME_PREFIX + contact.index() + "].secondaryPhoneNumber",
false
).as(Flux::from),
processResult(
legacyService
.searchGeneric(
PHONE_CONSTANT,
contact.faxNumber()
),
FIELD_NAME_PREFIX + contact.index() + "].faxNumber",
false
).as(Flux::from),
processResult(
legacyService
.searchContact(
new ContactSearchDto(
contact.firstName(),
null,
contact.lastName(),
contact.email(),
contact.phoneNumber(),
contact.secondaryPhoneNumber(),
contact.faxNumber()
)
),
FIELD_NAME_PREFIX + contact.index() + "].firstName",
true
).as(Flux::from)
)
)
//Concat all the results for each address
.map(this::processSingleContact)
.reduce(Flux.empty(), Flux::concat)
.as(this::reduceMatchResults);
}

private Flux<MatchResult> processSingleContact(ClientContactDto contact) {

Mono<MatchResult> contactEmailFull = processResult(
legacyService
.searchGeneric(
"email",
contact.email()
),
FIELD_NAME_PREFIX + contact.index() + "].email",
true,
false
);

Mono<MatchResult> businessPhoneFull = processResult(
legacyService
.searchGeneric(
PHONE_CONSTANT,
contact.phoneNumber()
),
FIELD_NAME_PREFIX + contact.index() + "].phoneNumber",
true,
false
);

Mono<MatchResult> secondaryPhoneFull = processResult(
legacyService
.searchGeneric(
PHONE_CONSTANT,
contact.secondaryPhoneNumber()
),
FIELD_NAME_PREFIX + contact.index() + "].secondaryPhoneNumber",
true,
false
);

Mono<MatchResult> faxPhoneFull = processResult(
legacyService
.searchGeneric(
PHONE_CONSTANT,
contact.faxNumber()
),
FIELD_NAME_PREFIX + contact.index() + "].faxNumber",
true,
false
);

Mono<MatchResult> contactFull = processResult(
legacyService
.searchContact(
new ContactSearchDto(
contact.firstName(),
null,
contact.lastName(),
contact.email(),
contact.phoneNumber(),
contact.secondaryPhoneNumber(),
contact.faxNumber()
)
),
FIELD_NAME_PREFIX + contact.index() + "].firstName",
true,
true
);

return Flux.concat(
contactEmailFull,
businessPhoneFull,
secondaryPhoneFull,
faxPhoneFull,
contactFull
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ public StepMatchEnum getStepMatcher() {
@Override
public Mono<Void> matchStep(ClientSubmissionDto dto) {

//TODO: appears to not being called
//TODO: Update the processor
Flux<ForestClientDto> clientRegistrationFullMatch =
legacyService
.searchLegacy(
Expand Down Expand Up @@ -104,28 +102,32 @@ public Mono<Void> matchStep(ClientSubmissionDto dto) {

processResult(
clientRegistrationFullMatch,
"businessInformation.businessName",
"businessInformation.federalId",
false,
false
),

//A fuzzy match should happen for the Client name
processResult(
clientNameFuzzyMatch,
"businessInformation.businessName",
true,
true
),

//A full match should happen for the Client name
processResult(
clientNameFullMatch,
"businessInformation.businessName",
false,
false
),

//A full match should happen for the Acronym
processResult(
clientAcronymFullMatch,
"businessInformation.clientAcronym",
false,
false
)
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package ca.bc.gov.app.service.client.matches;

import ca.bc.gov.app.dto.client.ClientSubmissionDto;
import ca.bc.gov.app.dto.client.IdentificationTypeEnum;
import ca.bc.gov.app.dto.client.StepMatchEnum;
import ca.bc.gov.app.dto.legacy.ForestClientDto;
import ca.bc.gov.app.service.client.ClientLegacyService;
import io.micrometer.observation.annotation.Observed;
import java.util.Objects;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
Expand All @@ -29,14 +31,14 @@ public class IndividualStepMatcher implements StepMatcher {
private final ClientLegacyService legacyService;

/**
* This method is used to get the logger for this class.
* This is just to allow the default methods to access the logger.
*
* @return The Logger object used for logging in this class.
*/
public Logger getLogger() {
return log;
}
* This method is used to get the logger for this class. This is just to allow the default methods
* to access the logger.
*
* @return The Logger object used for logging in this class.
*/
public Logger getLogger() {
return log;
}

/**
* This method returns the step matcher enumeration value for individual steps.
Expand Down Expand Up @@ -92,8 +94,13 @@ public Mono<Void> matchStep(ClientSubmissionDto dto) {

// Search for document itself
Flux<ForestClientDto> documentFullMatch =
legacyService.searchDocument(dto.businessInformation().idType(),
dto.businessInformation().clientIdentification()
Mono
.justOrEmpty(dto.businessInformation().idType())
.filter(Objects::nonNull)
.filter(idType -> !IdentificationTypeEnum.OTHR.name().equalsIgnoreCase(idType))
.flatMapMany(idType ->
legacyService.searchDocument(idType,
dto.businessInformation().clientIdentification())
)
.doOnNext(client -> log.info("Match found for individual document full match: {}",
client.clientNumber())
Expand All @@ -105,17 +112,24 @@ public Mono<Void> matchStep(ClientSubmissionDto dto) {
.concat(
processResult(
individualFuzzyMatch,
"businessInformation.businessName",
//using this name for reference only to denote that is only the individual
//information that was matched
"businessInformation.individual",
true,
true
),
processResult(
individualFullMatch,
"businessInformation.businessName",
//using this name for reference only to denote that is the individual data
//plus the document id that was matched
"businessInformation.individualAndDocument",
false,
false
),
processResult(
documentFullMatch,
"businessInformation.identification",
"businessInformation.clientIdentification",
false,
false
)
)
Expand Down
Loading
Loading