Skip to content

Commit

Permalink
fix: deleted unneeded code (#1015)
Browse files Browse the repository at this point in the history
cleanup: deleted unneeded code
  • Loading branch information
mamartinezmejia authored Jun 24, 2024
1 parent 8ab7191 commit 560d643
Showing 1 changed file with 1 addition and 55 deletions.
56 changes: 1 addition & 55 deletions legacy/src/main/java/ca/bc/gov/app/service/ClientService.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import ca.bc.gov.app.dto.ForestClientDto;
import ca.bc.gov.app.entity.ForestClientEntity;
import ca.bc.gov.app.mappers.AbstractForestClientMapper;
import ca.bc.gov.app.repository.ForestClientRepository;
import io.micrometer.observation.annotation.Observed;
import java.util.Optional;
import lombok.RequiredArgsConstructor;
Expand All @@ -20,8 +19,6 @@
public class ClientService {

private final R2dbcEntityOperations entityTemplate;
private final ForestClientRepository repository;
private final ClientSearchService searchService;
private final AbstractForestClientMapper<ForestClientDto, ForestClientEntity> mapper;

public Mono<String> saveAndGetIndex(ForestClientDto dto) {
Expand All @@ -38,7 +35,6 @@ public Mono<String> saveAndGetIndex(ForestClientDto dto) {
)
)
.map(mapper::toEntity)
.filterWhen(this::locateClient)
.flatMap(entity -> getNextClientNumber().map(entity::withClientNumber))
.flatMap(entity -> entityTemplate
.insert(ForestClientEntity.class)
Expand All @@ -64,57 +60,7 @@ public Mono<String> saveAndGetIndex(ForestClientDto dto) {
)
);
}

private Mono<Boolean> locateClient(
ForestClientEntity entity
) {

log.info("Searching forest client {}", entity.getName());

if (
entity
.getClientTypeCode()
.equalsIgnoreCase("I")
) {
return
searchService
.findByIndividual(
entity.getLegalFirstName(),
entity.getClientName(),
entity.getBirthdate().toLocalDate(),
null,
false
)
.map(client -> false) // means you can't create it
.defaultIfEmpty(true)
.doOnNext(
tag -> log.info("Individual {} forest client missing? {}", entity.getName(), tag))
.last();
}

return
repository
.findClientByIncorporationOrName(
entity.getClientName().toUpperCase(),
String.join(
StringUtils.EMPTY,
entity.getRegistryCompanyTypeCode().toUpperCase(),
entity.getCorpRegnNmbr()
)
)
.map(client -> false) // means you can't create it
.defaultIfEmpty(true)
.doOnNext(tag ->
log.info(
"Forest client {} with type {} missing? {}",
entity.getName(),
entity.getClientTypeCode(),
tag
)
)
.last();
}


private Mono<String> getNextClientNumber() {
return
entityTemplate
Expand Down

0 comments on commit 560d643

Please sign in to comment.