Skip to content

Commit

Permalink
fix: adding filter to remove dupped values
Browse files Browse the repository at this point in the history
  • Loading branch information
Paulo Gomes da Cruz Junior committed Feb 14, 2023
1 parent bd3e0a0 commit a0f3ee5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,16 @@

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import java.util.List;

@Schema(name = "NamedResult")
@JsonIgnoreProperties(ignoreUnknown = true)
public record OrgBookNameDto(
@Schema(
name = "value",
title = "Name of the entity being searched",
example = "U3 POWER CORP",
requiredMode = Schema.RequiredMode.REQUIRED
)
String value,

@Schema(
name = "topic_source_id",
title = "The incorporation ID",
example = "BC0772006",
requiredMode = Schema.RequiredMode.REQUIRED
)
String value,
@JsonProperty("sub_type")
String subType,
@JsonProperty("topic_source_id")
String topicSourceId
String topicSourceId,
List<String>names
) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,20 @@ public Flux<ClientNameCodeDto> findByClientName(String clientName) {
uriBuilder
.path("/v3/search/autocomplete")
.queryParam("q", CoreUtil.encodeString(clientName))
.queryParam("inactive", "false")
.queryParam("revoked", "false")
.build(new HashMap<>())
)
.accept(MediaType.APPLICATION_JSON)
.exchangeToMono(
clientResponse -> clientResponse.bodyToMono(OrgBookResultListResponse.class)
)
.flatMapMany(orgBookResultListResponse -> Flux.fromIterable(orgBookResultListResponse.results()))
.map(orgBookNameDto -> new ClientNameCodeDto(orgBookNameDto.topicSourceId(),orgBookNameDto.value()))
.log()
.flatMapMany(
orgBookResultListResponse -> Flux.fromIterable(orgBookResultListResponse.results()))
.filter(orgBookNameDto -> orgBookNameDto.subType().equalsIgnoreCase("entity_name"))
.map(orgBookNameDto -> new ClientNameCodeDto(orgBookNameDto.topicSourceId(),
orgBookNameDto.value()))
.doOnNext(content -> log.info("OrgBook Name Lookup {} -> {}", clientName, content));

}
Expand Down

0 comments on commit a0f3ee5

Please sign in to comment.