Skip to content

Commit

Permalink
feat(FSADT1-1396|FSADT1-1398): added frontend fuzzy match for remaini…
Browse files Browse the repository at this point in the history
…ng client types (#1081)

* chore: adding new flag to match result and changing contact and location

setting contact and location as fuzzy true to allow the frontend to deal with its visual, while adding new flag to represent the source of the result

* feat(FSADT1-1396): added fuzzy matching for registered business

* feat(FSADT1-1396): renaming some fields on fuzzy match

* feat(FSADT1-1396): updating fuzzy mock and mappings

* test(FSADT1-1396): added tests to individual and registered fuzzy match

* test(FSADT1-1398): added tests to other types of fuzzy on step 1

* chore(FSADT1-1396): renaming some fields on fuzzy match

* chore(FSADT1-1398): renaming some fields on fuzzy match

* fix(FSADT1-1398): fixing test cases

* text: fixing failing test

* test: reduced the wait time on cypress

* chore: added missing intercept

* chore: added missing stubs

* fix(FSADT1-1396): fixed identification fuzzy

* chore: updating fuzzy match

* chore(FSADT1-1398): removing pending match for other individual

* fix: fixed fuzzy match field association

* chore: added missing intercept

* test: fixing wrong check on test

* fix(FSADT1-1396): fixing field name on grouping

* test: fixing test params

* chore: removing console log

---------

Co-authored-by: Maria Martinez <[email protected]>
  • Loading branch information
paulushcgcj and mamartinezmejia committed Aug 16, 2024
1 parent b138599 commit 2d6221f
Show file tree
Hide file tree
Showing 62 changed files with 2,611 additions and 1,173 deletions.
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

0 comments on commit 2d6221f

Please sign in to comment.