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(be:FSADT1-1575): Create read-only Client Summary (BE) #1331

Merged
merged 47 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
f13340b
feat(be:FSADT1-1575): First draft
mamartinezmejia Nov 19, 2024
0d67ebd
no message
mamartinezmejia Nov 21, 2024
ec11b14
Merge branch 'main' into feat/be/FSADT1-1575
mamartinezmejia Nov 21, 2024
9f28db1
Merge branch 'main' into feat/be/FSADT1-1575
mamartinezmejia Nov 25, 2024
0887663
Added missing field in dto
mamartinezmejia Nov 25, 2024
cab7aa1
Added missing field in dto
mamartinezmejia Nov 25, 2024
7b32108
feat(be:feat/be/FSADT1-1575): Populated good standing indicator
mamartinezmejia Nov 26, 2024
66fef15
Added descriptions
mamartinezmejia Nov 26, 2024
ac31f73
no message
mamartinezmejia Nov 26, 2024
7551593
Merge branch 'main' into feat/be/FSADT1-1575
mamartinezmejia Nov 26, 2024
5263735
feat(be:FSADT1-1575): Passed groups to legacy
mamartinezmejia Nov 26, 2024
e1f2aac
feat(be:FSADT1-1575): Passed groups to legacy
mamartinezmejia Nov 27, 2024
9ca2aa1
Updated query
mamartinezmejia Nov 27, 2024
3c2df9e
Added missing dto
mamartinezmejia Nov 27, 2024
4e59490
Merge branch 'main' into feat/be/FSADT1-1575
mamartinezmejia Nov 27, 2024
ffa7bbf
Removed unneeded field
mamartinezmejia Nov 28, 2024
4f2862e
Added new field as per requested
mamartinezmejia Nov 29, 2024
25f8e4e
Merge branch 'main' into feat/be/FSADT1-1575
mamartinezmejia Nov 29, 2024
33b32b9
feat(be:FSADT1-1575): Changes done after code review
mamartinezmejia Nov 29, 2024
401537b
Added javadoc
mamartinezmejia Nov 29, 2024
20b0c09
Added test
mamartinezmejia Nov 29, 2024
fe32550
Fixed test
mamartinezmejia Nov 29, 2024
383bd6d
Improved test
mamartinezmejia Nov 29, 2024
385e9b6
feat(be:FSADT1-1575): Added more tests
mamartinezmejia Dec 2, 2024
8c9bbd0
Fixed test
mamartinezmejia Dec 2, 2024
7f454b1
feat(be:FSADT1-1575): Added more tests
mamartinezmejia Dec 2, 2024
4b6f62c
Added javadoc
mamartinezmejia Dec 3, 2024
405a84b
Made code reviews
mamartinezmejia Dec 3, 2024
9ee4993
Merge branch 'main' into feat/be/FSADT1-1575
mamartinezmejia Dec 3, 2024
d94a817
Added more javadocs
mamartinezmejia Dec 3, 2024
24506ba
Made more code reviews
mamartinezmejia Dec 3, 2024
6a94d5a
Made changes after code reviews
mamartinezmejia Dec 3, 2024
baa8144
SonaCloud fixes
mamartinezmejia Dec 3, 2024
c59f69e
SonarCloud fixes
mamartinezmejia Dec 3, 2024
aae7ceb
Merge branch 'main' into feat/be/FSADT1-1575
mamartinezmejia Dec 3, 2024
6068462
Merge branch 'main' into feat/be/FSADT1-1575
mamartinezmejia Dec 3, 2024
55d6769
Added more tests
mamartinezmejia Dec 3, 2024
c0ad9d1
chore: simplifying boolean check
paulushcgcj Dec 4, 2024
f0671de
Merge branch 'main' into feat/be/FSADT1-1575
paulushcgcj Dec 4, 2024
65fae23
Made more code reviews
mamartinezmejia Dec 4, 2024
4ac46f7
chore: forcing a new build
paulushcgcj Dec 4, 2024
6d7e081
Merge remote-tracking branch 'origin/feat/be/FSADT1-1575' into feat/b…
paulushcgcj Dec 4, 2024
00149d3
chore: forcing a new build
paulushcgcj Dec 4, 2024
403b589
chore: forcing a new build
paulushcgcj Dec 4, 2024
528757e
Made code reviews
mamartinezmejia Dec 4, 2024
9a84c3a
chore: forcing a new build
paulushcgcj Dec 5, 2024
e96c047
chore: forcing a new build
paulushcgcj Dec 5, 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
2 changes: 1 addition & 1 deletion .github/workflows/pr-open.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
matrix:
package: [backend, database, frontend, legacy, legacydb, processor]
steps:
- uses: bcgov-nr/action-builder-ghcr@v2.3.0
- uses: bcgov-nr/action-builder-ghcr@v2.2.0
name: Build (${{ matrix.package }})
with:
package: ${{ matrix.package }}
Expand Down
5 changes: 3 additions & 2 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ RUN mvn versions:set -DnewVersion=${APP_VERSION} -f pom.xml -DskipTests -Dtests.
# Build
RUN mvn -Pnative native:compile


### Deployer
FROM gcr.io/distroless/java-base:nonroot AS deploy
ARG PORT=8080
Expand All @@ -44,5 +43,7 @@ USER 1001
EXPOSE ${PORT}
HEALTHCHECK CMD curl -f http://localhost:${PORT}/actuator/health | grep '"status":"UP"'

ENV SPRING_PROFILES_ACTIVE=container

# Startup
ENTRYPOINT ["/app/nr-forest-client-backend","--spring.profiles.active=container"]
ENTRYPOINT ["/app/nr-forest-client-backend"]
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
import ca.bc.gov.app.dto.bcregistry.ClientDetailsDto;
import ca.bc.gov.app.dto.client.ClientListDto;
import ca.bc.gov.app.dto.client.ClientLookUpDto;
import ca.bc.gov.app.dto.legacy.ForestClientDetailsDto;
import ca.bc.gov.app.exception.NoClientDataFound;
import ca.bc.gov.app.service.client.ClientLegacyService;
import ca.bc.gov.app.service.client.ClientService;
import ca.bc.gov.app.util.JwtPrincipalUtil;
import io.micrometer.observation.annotation.Observed;
import java.util.List;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import java.util.List;
import org.apache.commons.text.WordUtils;
import org.springframework.data.util.Pair;
import org.springframework.http.MediaType;
Expand All @@ -35,8 +36,19 @@ public class ClientController {
private final ClientService clientService;
private final ClientLegacyService clientLegacyService;

/**
* Retrieves the details of a client based on the provided incorporation number.
*
* <p>This endpoint is used to fetch client details by their incorporation number. The request is
* authenticated using a JWT, and additional information (such as user ID, business ID, and
* provider) is extracted from the token to authorize the request.
*
* @param clientNumber the incorporation number of the client whose details are being requested
* @param principal the JWT authentication token containing user and business information
* @return a {@link Mono} emitting the {@link ClientDetailsDto} containing the client's details
*/
@GetMapping("/{clientNumber}")
public Mono<ClientDetailsDto> getClientDetails(
public Mono<ClientDetailsDto> getClientDetailsByIncorporationNumber(
@PathVariable String clientNumber,
JwtAuthenticationToken principal
) {
Expand All @@ -45,48 +57,83 @@ public Mono<ClientDetailsDto> getClientDetails(
JwtPrincipalUtil.getUserId(principal)
);
return clientService
.getClientDetails(
.getClientDetailsByIncorporationNumber(
clientNumber,
JwtPrincipalUtil.getUserId(principal),
JwtPrincipalUtil.getBusinessId(principal),
JwtPrincipalUtil.getProvider(principal)
);
}

/**
* Handles HTTP GET requests to retrieve client details based on the provided client number.
*
* <p>This method fetches the details of a client from the {@code ClientService} using the
* specified {@code clientNumber}. The caller's JWT authentication token is used to extract
* user-related information such as groups and user ID.</p>
*
* @param clientNumber the unique identifier of the client whose details are to be retrieved.
* @param principal the {@link JwtAuthenticationToken} containing the authenticated user's
* information, including their roles and groups.
* @return a {@link Mono} emitting the {@link ForestClientDetailsDto} containing the requested
* client details, or an error if the client cannot be found or accessed.
*/
@GetMapping("/details/{clientNumber}")
public Mono<ForestClientDetailsDto> getClientDetailsByClientNumber(
@PathVariable String clientNumber,
JwtAuthenticationToken principal
) {
log.info("Requesting client details for client number {} from the client service. {}",
clientNumber,
JwtPrincipalUtil.getUserId(principal)
);
return clientService.getClientDetailsByClientNumber(
clientNumber,
JwtPrincipalUtil.getGroups(principal));
}

/**
* Performs a full-text search for clients based on the provided keyword, with pagination support.
*
* <p>This endpoint allows searching for clients by a keyword. The results are paginated, and the
* total count of matching records is included in the response headers.
*
* @param page the page number to retrieve (default is 0)
* @param size the number of records per page (default is 10)
* @param keyword the keyword to search for (default is an empty string, which returns all
* records)
* @param serverResponse the HTTP response to include the total count of records in the headers
* @return a {@link Flux} emitting {@link ClientListDto} objects containing the search results
*/
@GetMapping("/search")
public Flux<ClientListDto> fullSearch(
@RequestParam(required = false, defaultValue = "0") int page,
@RequestParam(required = false, defaultValue = "10") int size,
@RequestParam(required = false, defaultValue = "") String keyword,
ServerHttpResponse serverResponse) {
ServerHttpResponse serverResponse
) {
log.info("Listing clients: page={}, size={}, keyword={}", page, size, keyword);

return clientLegacyService
.search(
page,
size,
keyword
)
.search(page, size, keyword)
.doOnNext(pair -> {
Long count = pair.getSecond();

serverResponse
.getHeaders()
.putIfAbsent(
ApplicationConstant.X_TOTAL_COUNT,
List.of(count.toString())
);
}
)
.getHeaders()
.putIfAbsent(
ApplicationConstant.X_TOTAL_COUNT,
List.of(count.toString())
);
})
.map(Pair::getFirst)
.doFinally(signalType ->
.doFinally(signalType ->
serverResponse
.getHeaders()
.putIfAbsent(
ApplicationConstant.X_TOTAL_COUNT,
List.of("0")
)
.getHeaders()
.putIfAbsent(
ApplicationConstant.X_TOTAL_COUNT,
List.of("0")
)
);
}

Expand All @@ -104,24 +151,45 @@ public Flux<ClientLookUpDto> findByClientName(@PathVariable String name) {
.map(client -> client.withName(WordUtils.capitalize(client.name())));
}

/**
* Finds a client based on their registration number.
*
* <p>This endpoint retrieves client information by searching for a registration number.
* If no client is found, an error is returned.
*
* @param registrationNumber the registration number of the client to look up
* @return a {@link Mono} emitting the {@link ClientLookUpDto} if found, or an error
* if no data exists
*/
@GetMapping(value = "/incorporation/{registrationNumber}")
public Mono<ClientLookUpDto> findByRegistrationNumber(
@PathVariable String registrationNumber) {
log.info("Requesting a client with registration number {} from the client service.",
registrationNumber);
registrationNumber);
return clientService
.findByClientNameOrIncorporation(registrationNumber)
.next()
.switchIfEmpty(Mono.error(new NoClientDataFound(registrationNumber)));
}

/**
* Searches for an individual client by user ID and last name.
*
* <p>This endpoint fetches an individual client using their user ID and last name.
* The request is validated against existing records in the system.
*
* @param userId the unique identifier of the individual to search for
* @param lastName the last name of the individual to search for
* @return a {@link Mono} indicating completion, or an error if the individual is not found
*/
@GetMapping(value = "/individual/{userId}")
public Mono<Void> findByIndividual(
@PathVariable String userId,
@RequestParam String lastName
) {
log.info("Receiving request to search individual with id {} and last name {}", userId,
lastName);
log.info("Receiving request to search individual with id {} and last name {}",
userId,
lastName);
return clientService.findByIndividual(userId, lastName);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package ca.bc.gov.app.dto.legacy;

public record ForestClientContactDto(
String clientNumber,
String clientLocnCode,
String contactCode,
String contactName,
String businessPhone,
String secondaryPhone,
String faxNumber,
String emailAddress,
String createdBy,
String updatedBy,
Long orgUnit
) {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package ca.bc.gov.app.dto.legacy;

import java.time.LocalDate;
import java.util.List;
import lombok.With;

@With
public record ForestClientDetailsDto(
String clientNumber,
String clientName,
String legalFirstName,
String legalMiddleName,
String clientStatusCode,
String clientStatusDesc,
String clientTypeCode,
String clientTypeDesc,
String clientIdTypeCode,
String clientIdTypeDesc,
String clientIdentification,
String registryCompanyTypeCode,
String corpRegnNmbr,
String clientAcronym,
String wcbFirmNumber,
String clientComment,
LocalDate clientCommentUpdateDate,
String clientCommentUpdateUser,
String goodStandingInd,
LocalDate birthdate,

List<ForestClientLocationDto> addresses,
List<ForestClientContactDto> contacts,
List<ForestClientDoingBusinessAsDto> doingBusinessAs
) {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package ca.bc.gov.app.dto.legacy;

import lombok.With;

@With
public record ForestClientDoingBusinessAsDto(
String clientNumber,
String doingBusinessAsName,
String createdBy,
String updatedBy,
Long orgUnit
) {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package ca.bc.gov.app.dto.legacy;

import java.time.LocalDate;
import lombok.With;

@With
public record ForestClientLocationDto(
String clientNumber,
String clientLocnCode,
String clientLocnName,
String addressOne,
String addressTwo,
String addressThree,
String city,
String province,
String postalCode,
String country,
String businessPhone,
String homePhone,
String cellPhone,
String faxNumber,
String emailAddress,
String locnExpiredInd,
LocalDate returnedMailDate,
String trustLocationInd,
String cliLocnComment,
String createdBy,
String updatedBy,
Long orgUnit
) {

}

Loading
Loading