diff --git a/.github/workflows/reusable-tests-be.yml b/.github/workflows/reusable-tests-be.yml index 4f6e959..988c0c6 100644 --- a/.github/workflows/reusable-tests-be.yml +++ b/.github/workflows/reusable-tests-be.yml @@ -48,7 +48,7 @@ jobs: -Dsonar.projectKey=bcgov_nr-forest-client-commons -Dsonar.coverage.jacoco.xmlReportPaths=target/coverage-reports/merged-test-report/jacoco.xml -Dsonar.java.checkstyle.reportPaths=target/checkstyle-result.xml - -Dsonar.coverage.exclusions= **/dto/**,**/*$*Builder*,**/LogUtil* + -Dsonar.coverage.exclusions= **/dto/**,**/*$*Builder* sonar_token: ${{ secrets.SONAR_TOKEN_COMMONS }} triggers: ('core/') diff --git a/certextractor/Dockerfile b/certextractor/Dockerfile index cd47890..cb515ee 100644 --- a/certextractor/Dockerfile +++ b/certextractor/Dockerfile @@ -15,9 +15,9 @@ LABEL org.opencontainers.image.vendor="Government of British Columbia" LABEL org.opencontainers.image.description="Extracts the Oracle Database Client certificates from the Oracle connection and adds them to the Java Truststore." LABEL org.opencontainers.image.base.name="eclipse-temurin:17.0.11_9-jdk-alpine" -ENV LANG en_CA.UTF-8 -ENV LANGUAGE en_CA.UTF-8 -ENV LC_ALL en_CA.UTF-8 +ENV LANG=en_CA.UTF-8 +ENV LANGUAGE=en_CA.UTF-8 +ENV LC_ALL=en_CA.UTF-8 WORKDIR /app diff --git a/core/pom.xml b/core/pom.xml index 05e09e8..6794e59 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -44,14 +44,12 @@ **/dto/**, **/*$*Builder*, - **/LogUtil* target/checkstyle-result.xml - 5.9.1 - 1.9.1 - 3.24.2 + 5.10.5 ${project.version} + 3.25.3 @@ -80,6 +78,36 @@ swagger-annotations 2.2.25 + + jakarta.validation + jakarta.validation-api + 3.0.2 + + + + + org.junit.jupiter + junit-jupiter-api + ${junit-jupiter-api.version} + test + + + org.junit.jupiter + junit-jupiter-engine + ${junit-jupiter-api.version} + test + + + org.junit.jupiter + junit-jupiter-params + ${junit-jupiter-api.version} + test + + + org.assertj + assertj-core + ${assertj-core.version} + @@ -117,7 +145,6 @@ **/dto/** **/*$*Builder* - **/LogUtil* diff --git a/core/src/main/java/ca/bc/gov/app/dto/ValidationError.java b/core/src/main/java/ca/bc/gov/app/dto/ValidationError.java index d4a23d7..120c1fc 100644 --- a/core/src/main/java/ca/bc/gov/app/dto/ValidationError.java +++ b/core/src/main/java/ca/bc/gov/app/dto/ValidationError.java @@ -1,23 +1,29 @@ -package ca.bc.gov.app.dto; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.With; - -@Schema( - description = "Represents a validation error during submission", - title = "ValidationError", - example = """ - { - "fieldId": "person.name", - "errorMsg": "Name is required" - }""" -) -@With -public record ValidationError( - @Schema(description = "The field id that failed validation", example = "person.name") - String fieldId, - @Schema(description = "The error message for that specific field", example = "Name is required") - String errorMsg -) { - -} +package ca.bc.gov.app.dto; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.With; +import org.apache.commons.lang3.StringUtils; + +@Schema( + description = "Represents a validation error during submission", + title = "ValidationError", + example = """ + { + "fieldId": "person.name", + "errorMsg": "Name is required" + }""" +) +@With +public record ValidationError( + @Schema(description = "The field id that failed validation", example = "person.name") + String fieldId, + @Schema(description = "The error message for that specific field", example = "Name is required") + String errorMsg +) { + + @JsonIgnore + public boolean isValid() { + return !StringUtils.isAllBlank(fieldId, errorMsg); + } +} diff --git a/core/src/main/java/ca/bc/gov/app/dto/bcregistry/BcRegistryAddressDto.java b/core/src/main/java/ca/bc/gov/app/dto/bcregistry/BcRegistryAddressDto.java new file mode 100644 index 0000000..f9d4120 --- /dev/null +++ b/core/src/main/java/ca/bc/gov/app/dto/bcregistry/BcRegistryAddressDto.java @@ -0,0 +1,76 @@ +package ca.bc.gov.app.dto.bcregistry; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import java.util.Objects; +import lombok.With; +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; + +/** + * Data Transfer Object (DTO) representing an address in the BC Registry. + */ +@JsonIgnoreProperties(ignoreUnknown = true) +@With +public record BcRegistryAddressDto( + String addressCity, + String addressCountry, + String addressRegion, + String deliveryInstructions, + String postalCode, + String streetAddress, + String streetAddressAdditional, + String addressType +) { + + /** + * Checks if this object is equal to another object. + * + * @param o the object to compare with + * @return true if the objects are equal, false otherwise + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + + if (o == null || getClass() != o.getClass()) { + return false; + } + + BcRegistryAddressDto that = (BcRegistryAddressDto) o; + + return new EqualsBuilder() + .append(addressCity, that.addressCity) + .append(addressCountry, that.addressCountry) + .append(addressRegion, that.addressRegion) + .append(postalCode, that.postalCode) + .append(streetAddress, that.streetAddress) + .isEquals(); + } + + /** + * Generates a hash code for this object. + * + * @return the hash code + */ + @Override + public int hashCode() { + return new HashCodeBuilder(17, 37) + .append(addressCity) + .append(addressCountry) + .append(addressRegion) + .append(postalCode) + .append(streetAddress) + .toHashCode(); + } + + /** + * Validates the address. + * + * @return true if the street address and postal code are not null, false otherwise + */ + public boolean isValid() { + return !Objects.isNull(streetAddress) && !Objects.isNull(postalCode); + } +} \ No newline at end of file diff --git a/core/src/main/java/ca/bc/gov/app/dto/bcregistry/BcRegistryAlternateNameDto.java b/core/src/main/java/ca/bc/gov/app/dto/bcregistry/BcRegistryAlternateNameDto.java new file mode 100644 index 0000000..e9289eb --- /dev/null +++ b/core/src/main/java/ca/bc/gov/app/dto/bcregistry/BcRegistryAlternateNameDto.java @@ -0,0 +1,21 @@ +package ca.bc.gov.app.dto.bcregistry; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import java.time.LocalDate; +import java.time.ZonedDateTime; +import lombok.With; + +/** + * Data Transfer Object (DTO) representing an alternate name in the BC Registry. + */ +@With +@JsonIgnoreProperties(ignoreUnknown = true) +public record BcRegistryAlternateNameDto( + String entityType, // The type of entity + String identifier, // The identifier of the entity + String name, // The alternate name of the entity + ZonedDateTime registeredDate, // The date when the name was registered + LocalDate startDate // The start date of the alternate name +) { + +} \ No newline at end of file diff --git a/core/src/main/java/ca/bc/gov/app/dto/bcregistry/BcRegistryBusinessAdressesDto.java b/core/src/main/java/ca/bc/gov/app/dto/bcregistry/BcRegistryBusinessAdressesDto.java new file mode 100644 index 0000000..3fdbc84 --- /dev/null +++ b/core/src/main/java/ca/bc/gov/app/dto/bcregistry/BcRegistryBusinessAdressesDto.java @@ -0,0 +1,40 @@ +package ca.bc.gov.app.dto.bcregistry; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import java.util.HashSet; +import java.util.Set; + +/** + * Data Transfer Object (DTO) representing business addresses in the BC Registry. + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public record BcRegistryBusinessAdressesDto( + BcRegistryAddressDto mailingAddress, // The mailing address of the business + BcRegistryAddressDto deliveryAddress // The delivery address of the business +) { + + /** + * Validates the business addresses. + * + * @return true if either the mailing address or the delivery address is not null, false otherwise + */ + public boolean isValid() { + return mailingAddress != null || deliveryAddress != null; + } + + /** + * Retrieves a set of business addresses with their types. + * + * @return a set of business addresses with their types + */ + public Set addresses() { + Set addressDtoSet = new HashSet<>(); + if (mailingAddress != null) { + addressDtoSet.add(mailingAddress.withAddressType("mailing")); + } + if (deliveryAddress != null) { + addressDtoSet.add(deliveryAddress.withAddressType("delivery")); + } + return addressDtoSet; + } +} \ No newline at end of file diff --git a/core/src/main/java/ca/bc/gov/app/dto/bcregistry/BcRegistryBusinessDto.java b/core/src/main/java/ca/bc/gov/app/dto/bcregistry/BcRegistryBusinessDto.java new file mode 100644 index 0000000..d2aa049 --- /dev/null +++ b/core/src/main/java/ca/bc/gov/app/dto/bcregistry/BcRegistryBusinessDto.java @@ -0,0 +1,48 @@ +package ca.bc.gov.app.dto.bcregistry; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import java.util.Comparator; +import java.util.List; +import lombok.With; + +/** + * Data Transfer Object (DTO) representing a business in the BC Registry. + */ +@With +@JsonIgnoreProperties(ignoreUnknown = true) +public record BcRegistryBusinessDto( + List alternateNames, // List of alternate names for the business + Boolean goodStanding, + // Indicates if the business is in good standing + Boolean hasCorrections, // Indicates if the business has corrections + Boolean hasCourtOrders, // Indicates if the business has court orders + Boolean hasRestrictions, // Indicates if the business has restrictions + String identifier, // The identifier of the business + String legalName, // The legal name of the business + String legalType, // The legal type of the business + String state // The state of the business +) { + + /** + * Resolves and returns the legal name of the business. If alternate names are available, it + * returns the first registered alternate name. Otherwise, it returns the legal name. + * + * @return the resolved legal name of the business + */ + public String getResolvedLegalName() { + + List names = + (alternateNames == null || alternateNames.isEmpty()) + ? List.of() + : alternateNames; + + return + names + .stream() + .sorted(Comparator.comparing(BcRegistryAlternateNameDto::registeredDate)) + .map(BcRegistryAlternateNameDto::name) + .findFirst() + .orElse(legalName); + } + +} \ No newline at end of file diff --git a/core/src/main/java/ca/bc/gov/app/dto/bcregistry/BcRegistryDocumentAccessRequestDto.java b/core/src/main/java/ca/bc/gov/app/dto/bcregistry/BcRegistryDocumentAccessRequestDto.java new file mode 100644 index 0000000..6f55330 --- /dev/null +++ b/core/src/main/java/ca/bc/gov/app/dto/bcregistry/BcRegistryDocumentAccessRequestDto.java @@ -0,0 +1,12 @@ +package ca.bc.gov.app.dto.bcregistry; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import java.util.List; +import lombok.With; + +@With +@JsonIgnoreProperties(ignoreUnknown = true) +public record BcRegistryDocumentAccessRequestDto( + List documents +) { +} diff --git a/core/src/main/java/ca/bc/gov/app/dto/bcregistry/BcRegistryDocumentAccessTypeDto.java b/core/src/main/java/ca/bc/gov/app/dto/bcregistry/BcRegistryDocumentAccessTypeDto.java new file mode 100644 index 0000000..5f03073 --- /dev/null +++ b/core/src/main/java/ca/bc/gov/app/dto/bcregistry/BcRegistryDocumentAccessTypeDto.java @@ -0,0 +1,13 @@ +package ca.bc.gov.app.dto.bcregistry; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.With; + +@With +@JsonIgnoreProperties(ignoreUnknown = true) +public record BcRegistryDocumentAccessTypeDto( + @JsonProperty("type") + String documentType +) { +} diff --git a/core/src/main/java/ca/bc/gov/app/dto/bcregistry/BcRegistryDocumentDto.java b/core/src/main/java/ca/bc/gov/app/dto/bcregistry/BcRegistryDocumentDto.java new file mode 100644 index 0000000..7b329a1 --- /dev/null +++ b/core/src/main/java/ca/bc/gov/app/dto/bcregistry/BcRegistryDocumentDto.java @@ -0,0 +1,31 @@ +package ca.bc.gov.app.dto.bcregistry; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import java.util.List; +import lombok.With; + +@With +@JsonIgnoreProperties(ignoreUnknown = true) +public record BcRegistryDocumentDto( + BcRegistryBusinessDto business, + BcRegistryOfficesDto offices, + List parties +) { + + public boolean isOwnedByPerson() { + List localParties = parties == null ? List.of() : parties; + return localParties.stream().anyMatch(BcRegistryPartyDto::isPerson); + } + + public BcRegistryPartyDto getProprietor() { + if (parties == null) { + return null; + } + return parties + .stream() + .filter(BcRegistryPartyDto::isProprietor) + .findFirst() + .orElse(null); + } + +} \ No newline at end of file diff --git a/core/src/main/java/ca/bc/gov/app/dto/bcregistry/BcRegistryDocumentRequestBodyDto.java b/core/src/main/java/ca/bc/gov/app/dto/bcregistry/BcRegistryDocumentRequestBodyDto.java new file mode 100644 index 0000000..c4cbcaa --- /dev/null +++ b/core/src/main/java/ca/bc/gov/app/dto/bcregistry/BcRegistryDocumentRequestBodyDto.java @@ -0,0 +1,11 @@ +package ca.bc.gov.app.dto.bcregistry; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.With; + +@With +@JsonIgnoreProperties(ignoreUnknown = true) +public record BcRegistryDocumentRequestBodyDto( + BcRegistryDocumentAccessRequestDto documentAccessRequest +) { +} diff --git a/core/src/main/java/ca/bc/gov/app/dto/bcregistry/BcRegistryDocumentRequestDocumentDto.java b/core/src/main/java/ca/bc/gov/app/dto/bcregistry/BcRegistryDocumentRequestDocumentDto.java new file mode 100644 index 0000000..cde4ef9 --- /dev/null +++ b/core/src/main/java/ca/bc/gov/app/dto/bcregistry/BcRegistryDocumentRequestDocumentDto.java @@ -0,0 +1,14 @@ +package ca.bc.gov.app.dto.bcregistry; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.With; + +@With +@JsonIgnoreProperties(ignoreUnknown = true) +public record BcRegistryDocumentRequestDocumentDto( + String documentKey, + String documentType, + String fileName, + Long id +) { +} diff --git a/core/src/main/java/ca/bc/gov/app/dto/bcregistry/BcRegistryDocumentRequestResponseDto.java b/core/src/main/java/ca/bc/gov/app/dto/bcregistry/BcRegistryDocumentRequestResponseDto.java new file mode 100644 index 0000000..ef00c42 --- /dev/null +++ b/core/src/main/java/ca/bc/gov/app/dto/bcregistry/BcRegistryDocumentRequestResponseDto.java @@ -0,0 +1,16 @@ +package ca.bc.gov.app.dto.bcregistry; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import java.util.List; +import lombok.With; + +@With +@JsonIgnoreProperties(ignoreUnknown = true) +public record BcRegistryDocumentRequestResponseDto( + String businessIdentifier, + String businessName, + List documents, + String paymentStatus, + String status +) { +} diff --git a/core/src/main/java/ca/bc/gov/app/dto/bcregistry/BcRegistryExceptionMessageDto.java b/core/src/main/java/ca/bc/gov/app/dto/bcregistry/BcRegistryExceptionMessageDto.java new file mode 100644 index 0000000..0126c1b --- /dev/null +++ b/core/src/main/java/ca/bc/gov/app/dto/bcregistry/BcRegistryExceptionMessageDto.java @@ -0,0 +1,12 @@ +package ca.bc.gov.app.dto.bcregistry; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.With; + +@With +@JsonIgnoreProperties(ignoreUnknown = true) +public record BcRegistryExceptionMessageDto( + String errorMessage, + String rootCause +) { +} diff --git a/core/src/main/java/ca/bc/gov/app/dto/bcregistry/BcRegistryFacetPartyDto.java b/core/src/main/java/ca/bc/gov/app/dto/bcregistry/BcRegistryFacetPartyDto.java new file mode 100644 index 0000000..bf931a9 --- /dev/null +++ b/core/src/main/java/ca/bc/gov/app/dto/bcregistry/BcRegistryFacetPartyDto.java @@ -0,0 +1,15 @@ +package ca.bc.gov.app.dto.bcregistry; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import java.util.List; +import lombok.With; + +@With +@JsonIgnoreProperties(ignoreUnknown = true) +public record BcRegistryFacetPartyDto( + String partyName, + List partyRoles, + String partyType +) { + +} diff --git a/core/src/main/java/ca/bc/gov/app/dto/bcregistry/BcRegistryFacetRequestBodyDto.java b/core/src/main/java/ca/bc/gov/app/dto/bcregistry/BcRegistryFacetRequestBodyDto.java new file mode 100644 index 0000000..d70ba6b --- /dev/null +++ b/core/src/main/java/ca/bc/gov/app/dto/bcregistry/BcRegistryFacetRequestBodyDto.java @@ -0,0 +1,17 @@ +package ca.bc.gov.app.dto.bcregistry; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import java.util.List; +import java.util.Map; +import lombok.With; + +@With +@JsonIgnoreProperties(ignoreUnknown = true) +public record BcRegistryFacetRequestBodyDto( + BcRegistryFacetRequestQueryDto query, + Map> categories, + int rows, + int start +) { + +} diff --git a/core/src/main/java/ca/bc/gov/app/dto/bcregistry/BcRegistryFacetRequestQueryDto.java b/core/src/main/java/ca/bc/gov/app/dto/bcregistry/BcRegistryFacetRequestQueryDto.java new file mode 100644 index 0000000..32e004d --- /dev/null +++ b/core/src/main/java/ca/bc/gov/app/dto/bcregistry/BcRegistryFacetRequestQueryDto.java @@ -0,0 +1,16 @@ +package ca.bc.gov.app.dto.bcregistry; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.With; + +@With +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public record BcRegistryFacetRequestQueryDto( + String value, + String name, + String identifier +) { + +} diff --git a/core/src/main/java/ca/bc/gov/app/dto/bcregistry/BcRegistryFacetResponseDto.java b/core/src/main/java/ca/bc/gov/app/dto/bcregistry/BcRegistryFacetResponseDto.java new file mode 100644 index 0000000..a6d5304 --- /dev/null +++ b/core/src/main/java/ca/bc/gov/app/dto/bcregistry/BcRegistryFacetResponseDto.java @@ -0,0 +1,11 @@ +package ca.bc.gov.app.dto.bcregistry; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.With; + +@With +@JsonIgnoreProperties(ignoreUnknown = true) +public record BcRegistryFacetResponseDto( + BcRegistryFacetSearchResultsDto searchResults +) { +} diff --git a/core/src/main/java/ca/bc/gov/app/dto/bcregistry/BcRegistryFacetSearchResultEntryDto.java b/core/src/main/java/ca/bc/gov/app/dto/bcregistry/BcRegistryFacetSearchResultEntryDto.java new file mode 100644 index 0000000..25a5dd2 --- /dev/null +++ b/core/src/main/java/ca/bc/gov/app/dto/bcregistry/BcRegistryFacetSearchResultEntryDto.java @@ -0,0 +1,19 @@ +package ca.bc.gov.app.dto.bcregistry; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import java.util.List; +import lombok.With; + +@With +@JsonIgnoreProperties(ignoreUnknown = true) +public record BcRegistryFacetSearchResultEntryDto( + String bn, + String identifier, + String legalType, + String name, + String status, + Boolean goodStanding, + List parties +) { + +} diff --git a/core/src/main/java/ca/bc/gov/app/dto/bcregistry/BcRegistryFacetSearchResultsDto.java b/core/src/main/java/ca/bc/gov/app/dto/bcregistry/BcRegistryFacetSearchResultsDto.java new file mode 100644 index 0000000..c969bdb --- /dev/null +++ b/core/src/main/java/ca/bc/gov/app/dto/bcregistry/BcRegistryFacetSearchResultsDto.java @@ -0,0 +1,13 @@ +package ca.bc.gov.app.dto.bcregistry; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import java.util.List; +import lombok.With; + +@With +@JsonIgnoreProperties(ignoreUnknown = true) +public record BcRegistryFacetSearchResultsDto( + List results, + long totalResults +) { +} diff --git a/core/src/main/java/ca/bc/gov/app/dto/bcregistry/BcRegistryIdentificationDto.java b/core/src/main/java/ca/bc/gov/app/dto/bcregistry/BcRegistryIdentificationDto.java new file mode 100644 index 0000000..631ceff --- /dev/null +++ b/core/src/main/java/ca/bc/gov/app/dto/bcregistry/BcRegistryIdentificationDto.java @@ -0,0 +1,10 @@ +package ca.bc.gov.app.dto.bcregistry; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public record BcRegistryIdentificationDto( + BcRegistryBusinessDto business, + BcRegistryBusinessAdressesDto businessOffice +) { +} diff --git a/core/src/main/java/ca/bc/gov/app/dto/bcregistry/BcRegistryOfficerDto.java b/core/src/main/java/ca/bc/gov/app/dto/bcregistry/BcRegistryOfficerDto.java new file mode 100644 index 0000000..96e4a49 --- /dev/null +++ b/core/src/main/java/ca/bc/gov/app/dto/bcregistry/BcRegistryOfficerDto.java @@ -0,0 +1,20 @@ +package ca.bc.gov.app.dto.bcregistry; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import org.apache.commons.lang3.StringUtils; + +@JsonIgnoreProperties(ignoreUnknown = true) +public record BcRegistryOfficerDto( + String email, + String firstName, + String lastName, + String middleInitial, + String identifier, + String organizationName, + String partyType +) { + + public boolean isPerson() { + return StringUtils.isNotBlank(partyType) && partyType.equalsIgnoreCase("Person"); + } +} diff --git a/core/src/main/java/ca/bc/gov/app/dto/bcregistry/BcRegistryOfficesDto.java b/core/src/main/java/ca/bc/gov/app/dto/bcregistry/BcRegistryOfficesDto.java new file mode 100644 index 0000000..bd3ad53 --- /dev/null +++ b/core/src/main/java/ca/bc/gov/app/dto/bcregistry/BcRegistryOfficesDto.java @@ -0,0 +1,24 @@ +package ca.bc.gov.app.dto.bcregistry; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import java.util.Optional; +import java.util.Set; +import lombok.With; + +@With +@JsonIgnoreProperties(ignoreUnknown = true) +public record BcRegistryOfficesDto( + BcRegistryBusinessAdressesDto businessOffice +) { + public Set addresses() { + return Optional + .ofNullable(businessOffice) + .filter(BcRegistryBusinessAdressesDto::isValid) + .map(BcRegistryBusinessAdressesDto::addresses) + .orElse(Set.of()); + } + + public boolean isValid() { + return businessOffice != null && businessOffice.isValid(); + } +} diff --git a/core/src/main/java/ca/bc/gov/app/dto/bcregistry/BcRegistryPartyDto.java b/core/src/main/java/ca/bc/gov/app/dto/bcregistry/BcRegistryPartyDto.java new file mode 100644 index 0000000..43ec042 --- /dev/null +++ b/core/src/main/java/ca/bc/gov/app/dto/bcregistry/BcRegistryPartyDto.java @@ -0,0 +1,71 @@ +package ca.bc.gov.app.dto.bcregistry; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import java.util.List; +import java.util.Objects; +import java.util.Set; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import lombok.With; +import org.apache.commons.lang3.StringUtils; + +@With +@JsonIgnoreProperties(ignoreUnknown = true) +public record BcRegistryPartyDto( + BcRegistryAddressDto deliveryAddress, + BcRegistryAddressDto mailingAddress, + BcRegistryOfficerDto officer, + List roles +) { + public boolean isValid() { + return officer != null && (mailingAddress != null || deliveryAddress != null); + } + + public Set addresses() { + return + Stream + .of( + mailingAddress, + deliveryAddress + ) + .filter(Objects::nonNull) + .collect(Collectors.toSet()); + } + + public boolean isMatch( + String city, + String country, + String region, + String postalCode, + String streetAddress + ) { + BcRegistryAddressDto provided = new BcRegistryAddressDto( + city, + country, + region, + StringUtils.EMPTY, + postalCode, + streetAddress, + StringUtils.EMPTY, + StringUtils.EMPTY + ); + + return addresses() + .stream() + .anyMatch(provided::equals); + } + + public boolean isPerson() { + return officer != null && officer().isPerson(); + } + + public boolean isProprietor() { + if (roles == null) { + return false; + } + return roles + .stream() + .filter(BcRegistryRoleDto::active) + .anyMatch(role -> StringUtils.equalsIgnoreCase(role.roleType(), "Proprietor")); + } +} diff --git a/core/src/main/java/ca/bc/gov/app/dto/bcregistry/BcRegistryRoleDto.java b/core/src/main/java/ca/bc/gov/app/dto/bcregistry/BcRegistryRoleDto.java new file mode 100644 index 0000000..debea97 --- /dev/null +++ b/core/src/main/java/ca/bc/gov/app/dto/bcregistry/BcRegistryRoleDto.java @@ -0,0 +1,17 @@ +package ca.bc.gov.app.dto.bcregistry; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import java.time.LocalDate; +import lombok.With; + +@With +@JsonIgnoreProperties(ignoreUnknown = true) +public record BcRegistryRoleDto( + LocalDate appointmentDate, + LocalDate cessationDate, + String roleType +) { + public boolean active() { + return cessationDate == null || LocalDate.now().isBefore(cessationDate); + } +} diff --git a/core/src/main/java/ca/bc/gov/app/dto/bcregistry/ClientDetailsDto.java b/core/src/main/java/ca/bc/gov/app/dto/bcregistry/ClientDetailsDto.java new file mode 100644 index 0000000..004243a --- /dev/null +++ b/core/src/main/java/ca/bc/gov/app/dto/bcregistry/ClientDetailsDto.java @@ -0,0 +1,22 @@ +package ca.bc.gov.app.dto.bcregistry; + +import ca.bc.gov.app.dto.client.ClientAddressDto; +import ca.bc.gov.app.dto.client.ClientContactDto; +import java.util.List; +import lombok.With; + +/** + * A data transfer object representing the details of a client. + */ +@With +public record ClientDetailsDto( + String name, + String id, + Boolean goodStanding, + String clientType, + List addresses, + List contacts, + boolean isOwnedByPerson +) { + +} diff --git a/core/src/main/java/ca/bc/gov/app/dto/ches/ChesMailAttachment.java b/core/src/main/java/ca/bc/gov/app/dto/ches/ChesMailAttachment.java new file mode 100644 index 0000000..cd97418 --- /dev/null +++ b/core/src/main/java/ca/bc/gov/app/dto/ches/ChesMailAttachment.java @@ -0,0 +1,20 @@ +package ca.bc.gov.app.dto.ches; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "content", + "contentType", + "encoding", + "filename" +}) +public record ChesMailAttachment( + + String content, + String contentType, + ChesMailEncoding encoding, + String filename +) { +} diff --git a/core/src/main/java/ca/bc/gov/app/dto/ches/ChesMailBodyType.java b/core/src/main/java/ca/bc/gov/app/dto/ches/ChesMailBodyType.java new file mode 100644 index 0000000..4382f08 --- /dev/null +++ b/core/src/main/java/ca/bc/gov/app/dto/ches/ChesMailBodyType.java @@ -0,0 +1,51 @@ +package ca.bc.gov.app.dto.ches; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.HashMap; +import java.util.Map; +import lombok.Getter; + +public enum ChesMailBodyType { + + HTML("html"), + TEXT("text"); + + @Getter + private final String value; + private static final Map + CONSTANTS = new HashMap<>(); + + static { + for (ChesMailBodyType c : values()) { + CONSTANTS.put(c.value, c); + } + } + + ChesMailBodyType(String value) { + this.value = value; + } + + @JsonValue + public String value() { + return this.value; + } + + /** + * Returns the enum constant with the specified string value. + * + * @param value the string value representing the enum constant + * @return the enum constant with the specified string value + * @throws IllegalArgumentException if no enum constant with the specified string value exists + */ + @JsonCreator + public static ChesMailBodyType fromValue(String value) { + ChesMailBodyType constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + +} diff --git a/core/src/main/java/ca/bc/gov/app/dto/ches/ChesMailEncoding.java b/core/src/main/java/ca/bc/gov/app/dto/ches/ChesMailEncoding.java new file mode 100644 index 0000000..40d5774 --- /dev/null +++ b/core/src/main/java/ca/bc/gov/app/dto/ches/ChesMailEncoding.java @@ -0,0 +1,52 @@ +package ca.bc.gov.app.dto.ches; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.HashMap; +import java.util.Map; +import lombok.Getter; + +public enum ChesMailEncoding { + + BASE_64("base64"), + BINARY("binary"), + HEX("hex"), + UTF_8("utf-8"); + @Getter + private final String value; + private static final Map + CONSTANTS = new HashMap<>(); + + static { + for (ChesMailEncoding c : values()) { + CONSTANTS.put(c.value, c); + } + } + + ChesMailEncoding(String value) { + this.value = value; + } + + @JsonValue + public String value() { + return this.value; + } + + /** + * Returns the enum constant with the specified string value. + * + * @param value the string value representing the enum constant + * @return the enum constant with the specified string value + * @throws IllegalArgumentException if no enum constant with the specified string value exists + */ + @JsonCreator + public static ChesMailEncoding fromValue(String value) { + ChesMailEncoding constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + +} diff --git a/core/src/main/java/ca/bc/gov/app/dto/ches/ChesMailError.java b/core/src/main/java/ca/bc/gov/app/dto/ches/ChesMailError.java new file mode 100644 index 0000000..808b7ed --- /dev/null +++ b/core/src/main/java/ca/bc/gov/app/dto/ches/ChesMailError.java @@ -0,0 +1,7 @@ +package ca.bc.gov.app.dto.ches; + +public record ChesMailError( + String message, + String value +) { +} diff --git a/core/src/main/java/ca/bc/gov/app/dto/ches/ChesMailErrorResponse.java b/core/src/main/java/ca/bc/gov/app/dto/ches/ChesMailErrorResponse.java new file mode 100644 index 0000000..3917a65 --- /dev/null +++ b/core/src/main/java/ca/bc/gov/app/dto/ches/ChesMailErrorResponse.java @@ -0,0 +1,12 @@ +package ca.bc.gov.app.dto.ches; + +import java.util.List; + +public record ChesMailErrorResponse( + String type, + String title, + int status, + String detail, + List errors +) { +} diff --git a/core/src/main/java/ca/bc/gov/app/dto/ches/ChesMailPriority.java b/core/src/main/java/ca/bc/gov/app/dto/ches/ChesMailPriority.java new file mode 100644 index 0000000..870db28 --- /dev/null +++ b/core/src/main/java/ca/bc/gov/app/dto/ches/ChesMailPriority.java @@ -0,0 +1,52 @@ +package ca.bc.gov.app.dto.ches; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.HashMap; +import java.util.Map; +import lombok.Getter; + +public enum ChesMailPriority { + + NORMAL("normal"), + LOW("low"), + HIGH("high"); + + @Getter + private final String value; + private static final Map + CONSTANTS = new HashMap<>(); + + static { + for (ChesMailPriority c : values()) { + CONSTANTS.put(c.value, c); + } + } + + ChesMailPriority(String value) { + this.value = value; + } + + @JsonValue + public String value() { + return this.value; + } + + /** + * Returns the enum constant with the specified string value. + * + * @param value the string value representing the enum constant + * @return the enum constant with the specified string value + * @throws IllegalArgumentException if no enum constant with the specified string value exists + */ + @JsonCreator + public static ChesMailPriority fromValue(String value) { + ChesMailPriority constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + +} diff --git a/core/src/main/java/ca/bc/gov/app/dto/ches/ChesMailRequest.java b/core/src/main/java/ca/bc/gov/app/dto/ches/ChesMailRequest.java new file mode 100644 index 0000000..a1d5096 --- /dev/null +++ b/core/src/main/java/ca/bc/gov/app/dto/ches/ChesMailRequest.java @@ -0,0 +1,37 @@ +package ca.bc.gov.app.dto.ches; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.List; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "attachments", + "bcc", + "bodyType", + "body", + "cc", + "delay", + "encoding", + "from", + "priority", + "subject", + "tag", + "to" +}) +public record ChesMailRequest( + + List attachments, + List bcc, + ChesMailBodyType bodyType, + String body, + List cc, + Integer delay, + ChesMailEncoding encoding, + String from, + ChesMailPriority priority, + String subject, + String tag, + List to +) { +} diff --git a/core/src/main/java/ca/bc/gov/app/dto/ches/ChesMailResponse.java b/core/src/main/java/ca/bc/gov/app/dto/ches/ChesMailResponse.java new file mode 100644 index 0000000..b609cf9 --- /dev/null +++ b/core/src/main/java/ca/bc/gov/app/dto/ches/ChesMailResponse.java @@ -0,0 +1,28 @@ +package ca.bc.gov.app.dto.ches; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import jakarta.validation.Valid; +import jakarta.validation.constraints.NotNull; +import java.util.List; +import java.util.UUID; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "messages", + "txId" +}) +public record ChesMailResponse( + + @JsonProperty("messages") + @Valid + @NotNull + List messages, + + @JsonPropertyDescription("A corresponding transaction uuid") + @NotNull + UUID txId +) { +} diff --git a/core/src/main/java/ca/bc/gov/app/dto/ches/ChesMailResponseMessage.java b/core/src/main/java/ca/bc/gov/app/dto/ches/ChesMailResponseMessage.java new file mode 100644 index 0000000..e659f69 --- /dev/null +++ b/core/src/main/java/ca/bc/gov/app/dto/ches/ChesMailResponseMessage.java @@ -0,0 +1,30 @@ +package ca.bc.gov.app.dto.ches; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import jakarta.validation.Valid; +import jakarta.validation.constraints.NotNull; +import java.util.List; +import java.util.UUID; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "msgId", + "tag", + "to" +}) +public record ChesMailResponseMessage( + @JsonPropertyDescription("A corresponding message uuid") + @NotNull + UUID msgId, + + @JsonPropertyDescription("A unique string which is associated with the message") + String tag, + + @JsonPropertyDescription("An array of recipient email addresses that this message will go to") + @Valid + @NotNull + List to +) { +} diff --git a/core/src/main/java/ca/bc/gov/app/dto/ches/ChesRequestDto.java b/core/src/main/java/ca/bc/gov/app/dto/ches/ChesRequestDto.java new file mode 100644 index 0000000..c962395 --- /dev/null +++ b/core/src/main/java/ca/bc/gov/app/dto/ches/ChesRequestDto.java @@ -0,0 +1,24 @@ +package ca.bc.gov.app.dto.ches; + + +import jakarta.validation.constraints.Email; +import jakarta.validation.constraints.Min; +import jakarta.validation.constraints.NotNull; +import java.util.List; + +/** + * The type Ches request dto. + * + * @param emailTo list of emails to send message to + * @param emailBody body of the email, can be html + */ +public record ChesRequestDto( + @NotNull + @Min(1) + @Email + List emailTo, + @NotNull + String emailBody +) { + +} diff --git a/core/src/main/java/ca/bc/gov/app/dto/ches/CommonExposureJwtDto.java b/core/src/main/java/ca/bc/gov/app/dto/ches/CommonExposureJwtDto.java new file mode 100644 index 0000000..e71f254 --- /dev/null +++ b/core/src/main/java/ca/bc/gov/app/dto/ches/CommonExposureJwtDto.java @@ -0,0 +1,14 @@ +package ca.bc.gov.app.dto.ches; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public record CommonExposureJwtDto( + + @JsonProperty("access_token") String accessToken, + @JsonProperty("expires_in") long expiresIn, + @JsonProperty("refresh_expires_in") long refreshExpiresIn, + @JsonProperty("token_type") String tokenType, + @JsonProperty("not-before-policy") long notBeforePolicy, + @JsonProperty("scope") String scope +) { +} diff --git a/core/src/main/java/ca/bc/gov/app/dto/client/AddressCompleteFindDto.java b/core/src/main/java/ca/bc/gov/app/dto/client/AddressCompleteFindDto.java new file mode 100644 index 0000000..d1c0d13 --- /dev/null +++ b/core/src/main/java/ca/bc/gov/app/dto/client/AddressCompleteFindDto.java @@ -0,0 +1,26 @@ +package ca.bc.gov.app.dto.client; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonIgnoreProperties(ignoreUnknown = true) +public record AddressCompleteFindDto( + @JsonProperty("Id") + String id, + @JsonProperty("Text") + String text, + @JsonProperty("Description") + String description, + + @JsonProperty("Next") + String next, + + @JsonProperty("Error") + String error, + + @JsonProperty("Cause") + String cause, + + @JsonProperty("Resolution") + String resolution) implements AddressError { +} diff --git a/core/src/main/java/ca/bc/gov/app/dto/client/AddressCompleteFindListDto.java b/core/src/main/java/ca/bc/gov/app/dto/client/AddressCompleteFindListDto.java new file mode 100644 index 0000000..89234d5 --- /dev/null +++ b/core/src/main/java/ca/bc/gov/app/dto/client/AddressCompleteFindListDto.java @@ -0,0 +1,11 @@ +package ca.bc.gov.app.dto.client; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; + +@JsonIgnoreProperties(ignoreUnknown = true) +public record AddressCompleteFindListDto( + @JsonProperty("Items") + List items) { +} diff --git a/core/src/main/java/ca/bc/gov/app/dto/client/AddressCompleteRetrieveDto.java b/core/src/main/java/ca/bc/gov/app/dto/client/AddressCompleteRetrieveDto.java new file mode 100644 index 0000000..c6abd7d --- /dev/null +++ b/core/src/main/java/ca/bc/gov/app/dto/client/AddressCompleteRetrieveDto.java @@ -0,0 +1,55 @@ +package ca.bc.gov.app.dto.client; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonIgnoreProperties(ignoreUnknown = true) +public record AddressCompleteRetrieveDto( + @JsonProperty("Language") + String language, + + @JsonProperty("City") + String city, + + @JsonProperty("Province") + String province, + + @JsonProperty("ProvinceName") + String provinceName, + + @JsonProperty("CountryName") + String countryName, + + @JsonProperty("CountryIso2") + String countryIso2, + + @JsonProperty("PostalCode") + String postalCode, + + @JsonProperty("Line1") + String line1, + + @JsonProperty("Line2") + String line2, + + @JsonProperty("Line3") + String line3, + + @JsonProperty("Line4") + String line4, + + @JsonProperty("Line5") + String line5, + + @JsonProperty("Error") + String error, + + @JsonProperty("Description") + String description, + + @JsonProperty("Cause") + String cause, + + @JsonProperty("Resolution") + String resolution) implements AddressError { +} diff --git a/core/src/main/java/ca/bc/gov/app/dto/client/AddressCompleteRetrieveListDto.java b/core/src/main/java/ca/bc/gov/app/dto/client/AddressCompleteRetrieveListDto.java new file mode 100644 index 0000000..728be8b --- /dev/null +++ b/core/src/main/java/ca/bc/gov/app/dto/client/AddressCompleteRetrieveListDto.java @@ -0,0 +1,11 @@ +package ca.bc.gov.app.dto.client; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; + +@JsonIgnoreProperties(ignoreUnknown = true) +public record AddressCompleteRetrieveListDto( + @JsonProperty("Items") + List items) { +} diff --git a/core/src/main/java/ca/bc/gov/app/dto/client/AddressError.java b/core/src/main/java/ca/bc/gov/app/dto/client/AddressError.java new file mode 100644 index 0000000..419d513 --- /dev/null +++ b/core/src/main/java/ca/bc/gov/app/dto/client/AddressError.java @@ -0,0 +1,12 @@ +package ca.bc.gov.app.dto.client; + +public interface AddressError { + + String error(); + + String description(); + + String cause(); + + String resolution(); +} diff --git a/core/src/main/java/ca/bc/gov/app/dto/client/BusinessTypeEnum.java b/core/src/main/java/ca/bc/gov/app/dto/client/BusinessTypeEnum.java new file mode 100644 index 0000000..9f48d02 --- /dev/null +++ b/core/src/main/java/ca/bc/gov/app/dto/client/BusinessTypeEnum.java @@ -0,0 +1,46 @@ +package ca.bc.gov.app.dto.client; + +import com.fasterxml.jackson.annotation.JsonCreator; +import java.util.HashMap; +import java.util.Map; + +/** + * Enumeration representing different types of business entities. + *

+ * This enum defines two types of business entities, represented by single characters: R + * (Registered) and U (Unregistered). It includes a static block to initialize a map for reverse + * lookup, allowing retrieval of enum instances by their name. + *

+ */ +public enum BusinessTypeEnum { + // Enum constants representing business types + R, // Registered + U; // Unregistered + + // A map for reverse lookup of enum constants by their name + private static final Map CONSTANTS = new HashMap<>(); + + static { + // Populates the CONSTANTS map with enum names and their corresponding enum instances + for (BusinessTypeEnum c : values()) { + CONSTANTS.put(c.name(), c); + } + } + + /** + * Retrieves the enum instance corresponding to the given string value. + *

+ * This method allows for reverse lookup of enum instances by their name, facilitating the + * conversion from strings to enum instances. It supports dynamic retrieval of enum instances in + * scenarios where the enum type is determined at runtime. + *

+ * + * @param value The string representation of the enum constant to be retrieved. + * @return The {@link BusinessTypeEnum} instance corresponding to the given string value, or null + * if no matching instance is found. + */ + @JsonCreator + public static BusinessTypeEnum fromValue(String value) { + return CONSTANTS.get(value); + } +} diff --git a/core/src/main/java/ca/bc/gov/app/dto/client/ClientAddressDto.java b/core/src/main/java/ca/bc/gov/app/dto/client/ClientAddressDto.java new file mode 100644 index 0000000..bc97388 --- /dev/null +++ b/core/src/main/java/ca/bc/gov/app/dto/client/ClientAddressDto.java @@ -0,0 +1,68 @@ +package ca.bc.gov.app.dto.client; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import java.util.HashMap; +import java.util.Map; +import lombok.With; +import org.apache.commons.lang3.StringUtils; + + +@With +public record ClientAddressDto( + String streetAddress, + String complementaryAddressOne, + String complementaryAddressTwo, + ClientValueTextDto country, + ClientValueTextDto province, + String city, + String postalCode, + String businessPhoneNumber, + String secondaryPhoneNumber, + String faxNumber, + String emailAddress, + String notes, + int index, + String locationName +) { + + public Map description() { + + final String indexFormatted = String.format("address.[%d]", index); + + Map descMap = new HashMap<>(); + descMap.put("name", StringUtils.defaultString(locationName)); + descMap.put("address", StringUtils.defaultString(streetAddress)); + descMap.put("complementaryAddressOne", StringUtils.defaultString(complementaryAddressOne)); + descMap.put("complementaryAddressTwo", StringUtils.defaultString(complementaryAddressTwo)); + descMap.put("country", StringUtils.defaultString(country.text())); + descMap.put("province", StringUtils.defaultString(province.text())); + descMap.put("city", StringUtils.defaultString(city)); + descMap.put("postalCode", StringUtils.defaultString(postalCode)); + descMap.put("businessPhoneNumber", StringUtils.defaultString(businessPhoneNumber)); + descMap.put("secondaryPhoneNumber", StringUtils.defaultString(secondaryPhoneNumber)); + descMap.put("faxNumber", StringUtils.defaultString(faxNumber)); + descMap.put("emailAddress", StringUtils.defaultString(emailAddress)); + descMap.put("notes", StringUtils.defaultString(notes)); + + return Map.of(indexFormatted, descMap); + + } + + public ClientAddressDto withIndexed(int index) { + if (this.index == index) { + return this; + } + return this.withIndex(index); + } + + @JsonIgnore + public boolean isValid() { + return + StringUtils.isNotBlank(streetAddress) + && (country != null && StringUtils.isNotBlank(country.value())) + && (province != null && StringUtils.isNotBlank(province.value())) + && StringUtils.isNotBlank(city) + && StringUtils.isNotBlank(postalCode) + && StringUtils.isNotBlank(locationName); + } +} diff --git a/core/src/main/java/ca/bc/gov/app/dto/client/ClientBusinessInformationDto.java b/core/src/main/java/ca/bc/gov/app/dto/client/ClientBusinessInformationDto.java new file mode 100644 index 0000000..08530f2 --- /dev/null +++ b/core/src/main/java/ca/bc/gov/app/dto/client/ClientBusinessInformationDto.java @@ -0,0 +1,83 @@ +package ca.bc.gov.app.dto.client; + +import java.time.LocalDate; +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; +import lombok.With; +import org.apache.commons.lang3.StringUtils; + +@With +public record ClientBusinessInformationDto(String registrationNumber, String businessName, + String businessType, String clientType, + String goodStandingInd, String legalType, + LocalDate birthdate, String district, + String workSafeBcNumber, String doingBusinessAs, + String clientAcronym, String firstName, + String middleName, String lastName, String notes, + ClientValueTextDto identificationType, + String clientIdentification, + String identificationCountry, + String identificationProvince) { + + /** + * Returns a map containing the description of the client's business information. + * + * @return a map with keys representing the description fields and corresponding values + */ + public Map description() { + Map descMap = new HashMap<>(); + descMap.put("registrationNumber", StringUtils.defaultString(registrationNumber)); + descMap.put("name", StringUtils.defaultString(businessName)); + descMap.put("businessType", StringUtils.defaultString(businessType)); + descMap.put("clientType", StringUtils.defaultString(clientType)); + descMap.put("goodStanding", StringUtils.defaultString(goodStandingInd)); + descMap.put("legalType", StringUtils.defaultString(legalType)); + descMap.put("birthdate", Optional.ofNullable(birthdate).orElse(LocalDate.of(1975, 1, 31))); + descMap.put("district", StringUtils.defaultString(district)); + descMap.put("workSafeBcNumber", StringUtils.defaultString(workSafeBcNumber)); + descMap.put("doingBusinessAs", StringUtils.defaultString(doingBusinessAs)); + descMap.put("clientAcronym", StringUtils.defaultString(clientAcronym)); + descMap.put("firstName", StringUtils.defaultString(firstName)); + descMap.put("middleName", StringUtils.defaultString(middleName)); + descMap.put("lastName", StringUtils.defaultString(lastName)); + descMap.put("notes", StringUtils.defaultString(notes)); + descMap.put("identificationType", StringUtils.defaultString(idType())); + descMap.put("clientIdentification", StringUtils.defaultString(clientIdentification)); + descMap.put("identificationCountry", StringUtils.defaultString(identificationCountry)); + descMap.put("identificationProvince", StringUtils.defaultString(identificationProvince)); + return descMap; + } + + /** + * This method is used to determine the identification type of the client. + * + *

+ * It first checks if both the identificationType and clientIdentification fields are not blank. + * If they are not, it then checks if the identificationType is either CDDL or USDL and if the + * identificationProvince is not blank. If these conditions are met, it returns the + * identificationProvince concatenated with "DL". If these conditions are not met, it simply + * returns the identificationType. + *

+ * If either the identificationType or clientIdentification fields are blank, it returns null. + * + * @return The identification type of the client, or null if the necessary fields are blank. + */ + public String idType() { + + if (identificationType == null || StringUtils.isBlank(identificationType.value()) + || IdentificationTypeEnum.fromValue(identificationType.value()) == null) { + return null; + } + + if ((IdentificationTypeEnum.CDDL.equals( + IdentificationTypeEnum.fromValue(identificationType.value())) + || IdentificationTypeEnum.USDL.equals( + IdentificationTypeEnum.fromValue(identificationType.value()))) && StringUtils.isNotBlank( + identificationProvince)) { + return identificationProvince + "DL"; + } + return identificationType.value(); + } + +} diff --git a/core/src/main/java/ca/bc/gov/app/dto/client/ClientContactDto.java b/core/src/main/java/ca/bc/gov/app/dto/client/ClientContactDto.java new file mode 100644 index 0000000..e93b818 --- /dev/null +++ b/core/src/main/java/ca/bc/gov/app/dto/client/ClientContactDto.java @@ -0,0 +1,64 @@ +package ca.bc.gov.app.dto.client; + +import java.util.List; +import java.util.Map; +import lombok.With; +import org.apache.commons.lang3.StringUtils; + +/** + * The type Client contact dto. + * + * @param contactType the contact type + * @param firstName the first name + * @param lastName the last name + * @param phoneNumber the phone number + * @param email the email + * @param index zero-based index of the contact + * @param locationNames name of locations associated to this contact + */ +@With +public record ClientContactDto( + ClientValueTextDto contactType, + String firstName, + String lastName, + String phoneNumber, + String secondaryPhoneNumber, + String faxNumber, + String email, + int index, + List locationNames +) { + + public Map description() { + final String indexFormatted = String.format("contact.[%d]", index); + + return + Map.of(indexFormatted, + Map.of( + "firstName", StringUtils.defaultString(firstName), + "lastName", StringUtils.defaultString(lastName), + "name", String.join(" ", firstName, lastName), + "phone", StringUtils.defaultString(phoneNumber), + "secondaryPhoneNumber", StringUtils.defaultString(secondaryPhoneNumber), + "faxNumber", StringUtils.defaultString(faxNumber), + "email", StringUtils.defaultString(email) + ) + ); + } + + public ClientContactDto withIndexed(int index) { + if (this.index() == index) { + return this; + } + return this.withIndex(index); + } + + public boolean isValid() { + return !StringUtils.isAnyBlank( + firstName, + lastName, + phoneNumber, + email + ); + } +} diff --git a/core/src/main/java/ca/bc/gov/app/dto/client/ClientListDto.java b/core/src/main/java/ca/bc/gov/app/dto/client/ClientListDto.java new file mode 100644 index 0000000..d633432 --- /dev/null +++ b/core/src/main/java/ca/bc/gov/app/dto/client/ClientListDto.java @@ -0,0 +1,10 @@ +package ca.bc.gov.app.dto.client; + +public record ClientListDto( + String clientNumber, + String clientAcronym, + String clientFullName, + String clientType, + String city, + String clientStatus) { +} diff --git a/core/src/main/java/ca/bc/gov/app/dto/client/ClientListSubmissionDto.java b/core/src/main/java/ca/bc/gov/app/dto/client/ClientListSubmissionDto.java new file mode 100644 index 0000000..f12c09f --- /dev/null +++ b/core/src/main/java/ca/bc/gov/app/dto/client/ClientListSubmissionDto.java @@ -0,0 +1,14 @@ +package ca.bc.gov.app.dto.client; + +public record ClientListSubmissionDto( + long id, + String requestType, + String name, + String clientType, + String district, + String submittedAt, + String user, + String status, + Long count +) { +} diff --git a/core/src/main/java/ca/bc/gov/app/dto/client/ClientLocationDto.java b/core/src/main/java/ca/bc/gov/app/dto/client/ClientLocationDto.java new file mode 100644 index 0000000..eafcf6a --- /dev/null +++ b/core/src/main/java/ca/bc/gov/app/dto/client/ClientLocationDto.java @@ -0,0 +1,34 @@ +package ca.bc.gov.app.dto.client; + +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import lombok.With; + +@With +public record ClientLocationDto( + List addresses, + + List contacts +) { + + public Map description() { + return + Stream.concat( + contacts + .stream() + .map(ClientContactDto::description), + addresses + .stream() + .map(ClientAddressDto::description) + ) + .flatMap(map -> map.entrySet().stream()) + .collect(Collectors.toMap( + Map.Entry::getKey, + Map.Entry::getValue, + (v1, v2) -> v2 + ) + ); + } +} diff --git a/core/src/main/java/ca/bc/gov/app/dto/client/ClientLookUpDto.java b/core/src/main/java/ca/bc/gov/app/dto/client/ClientLookUpDto.java new file mode 100644 index 0000000..27814b5 --- /dev/null +++ b/core/src/main/java/ca/bc/gov/app/dto/client/ClientLookUpDto.java @@ -0,0 +1,14 @@ +package ca.bc.gov.app.dto.client; + +import lombok.With; + + +@With +public record ClientLookUpDto( + String code, + String name, + String status, + String legalType +) { + +} diff --git a/core/src/main/java/ca/bc/gov/app/dto/client/ClientStatusCodeEnum.java b/core/src/main/java/ca/bc/gov/app/dto/client/ClientStatusCodeEnum.java deleted file mode 100644 index 27c15a3..0000000 --- a/core/src/main/java/ca/bc/gov/app/dto/client/ClientStatusCodeEnum.java +++ /dev/null @@ -1,18 +0,0 @@ -package ca.bc.gov.app.dto.client; - -import lombok.Getter; - -@Getter -public enum ClientStatusCodeEnum { - ACT("Active"), - DAC("Deactivated"), - DEC("Deceased"), - REC("Receivership"), - SPN("Suspended"); - - private final String description; - - ClientStatusCodeEnum(String description) { - this.description = description; - } -} diff --git a/core/src/main/java/ca/bc/gov/app/dto/client/ClientSubmissionDto.java b/core/src/main/java/ca/bc/gov/app/dto/client/ClientSubmissionDto.java new file mode 100644 index 0000000..6876e1f --- /dev/null +++ b/core/src/main/java/ca/bc/gov/app/dto/client/ClientSubmissionDto.java @@ -0,0 +1,23 @@ +package ca.bc.gov.app.dto.client; + +import java.util.Map; +import lombok.With; + +@With +public record ClientSubmissionDto( + ClientBusinessInformationDto businessInformation, + ClientLocationDto location, + String userId) { + /** + * Returns a map containing the description of the client's business information. + * + * @return a map with keys representing the description fields and corresponding values + */ + public Map description(String userName) { + Map descriptions = location.description(); + descriptions.put("business", businessInformation.description()); + descriptions.put("userName", userName); + return descriptions; + } + +} diff --git a/core/src/main/java/ca/bc/gov/app/dto/client/ClientTypeCodeEnum.java b/core/src/main/java/ca/bc/gov/app/dto/client/ClientTypeCodeEnum.java deleted file mode 100644 index ee51f41..0000000 --- a/core/src/main/java/ca/bc/gov/app/dto/client/ClientTypeCodeEnum.java +++ /dev/null @@ -1,25 +0,0 @@ -package ca.bc.gov.app.dto.client; - -import lombok.Getter; - -@Getter -public enum ClientTypeCodeEnum { - A("Association"), - B("First Nation Band"), - C("Corporation"), - F("Ministry of Forests and Range"), - G("Government"), - I("Individual"), - L("Limited Partnership"), - P("General Partnership"), - R("First Nation Group"), - S("Society"), - T("First Nation Tribal Council"), - U("Unregistered Company"); - - private final String description; - - ClientTypeCodeEnum(String description) { - this.description = description; - } -} diff --git a/core/src/main/java/ca/bc/gov/app/dto/client/ClientTypeEnum.java b/core/src/main/java/ca/bc/gov/app/dto/client/ClientTypeEnum.java new file mode 100644 index 0000000..b439625 --- /dev/null +++ b/core/src/main/java/ca/bc/gov/app/dto/client/ClientTypeEnum.java @@ -0,0 +1,44 @@ +package ca.bc.gov.app.dto.client; + +import com.fasterxml.jackson.annotation.JsonCreator; +import java.util.HashMap; +import java.util.Map; + +/** + * Defines the types of clients using an enumeration. + *

+ * This enumeration represents different types of clients identified by single or multiple + * characters (e.g., C, S, A, I, P, L, RSP, USP). It includes a static block to initialize a map for + * reverse lookup, allowing retrieval of enum instances by their name. + *

+ */ +public enum ClientTypeEnum { + // Enum constants representing client types + C, S, A, I, P, L, RSP, USP, B, G, F, U; + + // A map for reverse lookup of enum constants by their name + private static final Map CONSTANTS = new HashMap<>(); + + static { + // Populates the CONSTANTS map with enum names and their corresponding enum instances + for (ClientTypeEnum c : values()) { + CONSTANTS.put(c.name(), c); + } + } + + /** + * Retrieves the enum instance corresponding to the given string value. + *

+ * This method allows for reverse lookup of enum instances by their name, facilitating the + * conversion from strings to enum instances. + *

+ * + * @param value The string representation of the enum constant to be retrieved. + * @return The {@link ClientTypeEnum} instance corresponding to the given string value, or null if + * no matching instance is found. + */ + @JsonCreator + public static ClientTypeEnum fromValue(String value) { + return CONSTANTS.get(value); + } +} diff --git a/core/src/main/java/ca/bc/gov/app/dto/client/ClientValueTextDto.java b/core/src/main/java/ca/bc/gov/app/dto/client/ClientValueTextDto.java new file mode 100644 index 0000000..90f0303 --- /dev/null +++ b/core/src/main/java/ca/bc/gov/app/dto/client/ClientValueTextDto.java @@ -0,0 +1,13 @@ +package ca.bc.gov.app.dto.client; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public record ClientValueTextDto( + + String value, + + String text +) { + +} diff --git a/core/src/main/java/ca/bc/gov/app/dto/client/CodeNameDto.java b/core/src/main/java/ca/bc/gov/app/dto/client/CodeNameDto.java new file mode 100644 index 0000000..ee8d1b1 --- /dev/null +++ b/core/src/main/java/ca/bc/gov/app/dto/client/CodeNameDto.java @@ -0,0 +1,16 @@ +package ca.bc.gov.app.dto.client; + +/** + * The {@code CodeNameDto} class represents a simple data transfer object (DTO) that encapsulates a + * name and code for a specific object. It is used to transfer this information between different + * parts of an application. This class is annotated with Swagger annotations for generating API + * documentation. It provides a description and example JSON representation for the object it + * represents. + */ +public record CodeNameDto( + String code, + + String name +) { + +} diff --git a/core/src/main/java/ca/bc/gov/app/dto/client/DistrictDto.java b/core/src/main/java/ca/bc/gov/app/dto/client/DistrictDto.java new file mode 100644 index 0000000..b2b9209 --- /dev/null +++ b/core/src/main/java/ca/bc/gov/app/dto/client/DistrictDto.java @@ -0,0 +1,9 @@ +package ca.bc.gov.app.dto.client; + +public record DistrictDto( + String code, + String description, + String emails +) { + +} \ No newline at end of file diff --git a/core/src/main/java/ca/bc/gov/app/dto/client/EmailLogDto.java b/core/src/main/java/ca/bc/gov/app/dto/client/EmailLogDto.java new file mode 100644 index 0000000..d4aa9f4 --- /dev/null +++ b/core/src/main/java/ca/bc/gov/app/dto/client/EmailLogDto.java @@ -0,0 +1,15 @@ +package ca.bc.gov.app.dto.client; + +import java.util.Map; + +public record EmailLogDto( + Integer emailLogId, + String templateName, + String emailAddress, + String subject, + String emailSentInd, + String emailId, + String exceptionMessage, + Map variables +) { +} diff --git a/core/src/main/java/ca/bc/gov/app/dto/client/EmailRequestDto.java b/core/src/main/java/ca/bc/gov/app/dto/client/EmailRequestDto.java new file mode 100644 index 0000000..81d7771 --- /dev/null +++ b/core/src/main/java/ca/bc/gov/app/dto/client/EmailRequestDto.java @@ -0,0 +1,29 @@ +package ca.bc.gov.app.dto.client; + +import java.util.Map; + +/** + * Represents a request object for sending emails via CHES (Common Hosted Email Service). This data + * transfer object (DTO) encapsulates the necessary information to send an email. + * + * @param registrationNumber The registration number associated with the client. + * @param name The name of the client or recipient of the email. + * @param userId The unique identifier of the user initiating the email. + * @param userName The name of the user initiating the email (not to be confused with the client's + * name or username). + * @param email The email address to which the email will be sent. + * @param templateName The name of the email template to be used for formatting the email content. + * @param subject The subject of the email. + * @param variables A map of variables to be used in the email template, allowing dynamic content. + */ +public record EmailRequestDto( + String registrationNumber, + String name, + String userId, + String userName, + String email, + String templateName, + String subject, + Map variables +) { +} diff --git a/core/src/main/java/ca/bc/gov/app/dto/client/IdentificationTypeDto.java b/core/src/main/java/ca/bc/gov/app/dto/client/IdentificationTypeDto.java new file mode 100644 index 0000000..c08108b --- /dev/null +++ b/core/src/main/java/ca/bc/gov/app/dto/client/IdentificationTypeDto.java @@ -0,0 +1,9 @@ +package ca.bc.gov.app.dto.client; + +public record IdentificationTypeDto( + String code, + String name, + String countryCode +) { + +} diff --git a/core/src/main/java/ca/bc/gov/app/dto/client/IdentificationTypeEnum.java b/core/src/main/java/ca/bc/gov/app/dto/client/IdentificationTypeEnum.java new file mode 100644 index 0000000..ed3203f --- /dev/null +++ b/core/src/main/java/ca/bc/gov/app/dto/client/IdentificationTypeEnum.java @@ -0,0 +1,52 @@ +package ca.bc.gov.app.dto.client; + +import com.fasterxml.jackson.annotation.JsonCreator; +import java.util.Map; + +/** + * Enumeration representing different types of identification used by clients. + *

+ * This enum defines various types of identification documents, such as birth certificates (BRTH), + * Canadian driver's licenses (CDDL), passports (PASS), citizenship documents (CITZ), First Nations + * ID (FNID), US driver's licenses (USDL), and other forms of identification (OTHR). It includes a + * static block to initialize a map for reverse lookup, allowing retrieval of enum instances by + * their name. + *

+ */ +public enum IdentificationTypeEnum { + // Enum constants representing identification types + BRTH, // Birth Certificate + CDDL, // Canadian Driver's License + PASS, // Passport + CITZ, // Citizenship Document + FNID, // First Nations ID + USDL, // US Driver's License + OTHR; // Other forms of identification + + // A map for reverse lookup of enum constants by their name + private static final Map CONSTANTS = new java.util.HashMap<>(); + + static { + // Populates the CONSTANTS map with enum names and their corresponding enum instances + for (IdentificationTypeEnum c : values()) { + CONSTANTS.put(c.name(), c); + } + } + + /** + * Retrieves the enum instance corresponding to the given string value. + *

+ * This method allows for reverse lookup of enum instances by their name, facilitating the + * conversion from strings to enum instances. It supports dynamic retrieval of enum instances in + * scenarios where the enum type is determined at runtime. + *

+ * + * @param value The string representation of the enum constant to be retrieved. + * @return The {@link IdentificationTypeEnum} instance corresponding to the given string value, or + * null if no matching instance is found. + */ + @JsonCreator + public static IdentificationTypeEnum fromValue(String value) { + return CONSTANTS.get(value); + } +} diff --git a/core/src/main/java/ca/bc/gov/app/dto/client/LegalTypeEnum.java b/core/src/main/java/ca/bc/gov/app/dto/client/LegalTypeEnum.java new file mode 100644 index 0000000..09c8454 --- /dev/null +++ b/core/src/main/java/ca/bc/gov/app/dto/client/LegalTypeEnum.java @@ -0,0 +1,47 @@ +package ca.bc.gov.app.dto.client; + +import com.fasterxml.jackson.annotation.JsonCreator; +import java.util.HashMap; +import java.util.Map; + +/** + * Enumeration representing different legal entity types. + *

+ * This enum defines various legal entity types identified by unique codes (e.g., A, B, BC, C, + * etc.). It includes a static block to initialize a map for reverse lookup, allowing retrieval of + * enum instances by their name. This feature facilitates the conversion from string values to their + * corresponding enum instances, especially useful in parsing data from external sources or user + * input. + *

+ */ +public enum LegalTypeEnum { + // Enum constants representing legal entity types + A, B, BC, C, CP, EPR, FOR, LIC, REG, S, XS, XCP, SP, GP, LP, XL, XP, LL; + + // A map for reverse lookup of enum constants by their name + private static final Map CONSTANTS = new HashMap<>(); + + static { + // Populates the CONSTANTS map with enum names and their corresponding enum instances + for (LegalTypeEnum c : values()) { + CONSTANTS.put(c.name(), c); + } + } + + /** + * Retrieves the enum instance corresponding to the given string value. + *

+ * This method allows for reverse lookup of enum instances by their name, facilitating the + * conversion from strings to enum instances. It supports dynamic retrieval of enum instances in + * scenarios where the enum type is determined at runtime. + *

+ * + * @param value The string representation of the enum constant to be retrieved. + * @return The {@link LegalTypeEnum} instance corresponding to the given string value, or null if + * no matching instance is found. + */ + @JsonCreator + public static LegalTypeEnum fromValue(String value) { + return CONSTANTS.get(value); + } +} diff --git a/core/src/main/java/ca/bc/gov/app/dto/client/MatchResult.java b/core/src/main/java/ca/bc/gov/app/dto/client/MatchResult.java new file mode 100644 index 0000000..f3dc273 --- /dev/null +++ b/core/src/main/java/ca/bc/gov/app/dto/client/MatchResult.java @@ -0,0 +1,9 @@ +package ca.bc.gov.app.dto.client; + +public record MatchResult( + String field, + String match, + boolean fuzzy, + boolean partialMatch +) { +} diff --git a/core/src/main/java/ca/bc/gov/app/dto/client/StepMatchEnum.java b/core/src/main/java/ca/bc/gov/app/dto/client/StepMatchEnum.java new file mode 100644 index 0000000..f36a7bc --- /dev/null +++ b/core/src/main/java/ca/bc/gov/app/dto/client/StepMatchEnum.java @@ -0,0 +1,39 @@ +package ca.bc.gov.app.dto.client; + +import com.fasterxml.jackson.annotation.JsonCreator; +import java.util.HashMap; +import java.util.Map; + +/** + * Enumeration representing different steps in the staff submission process. + *

+ * This enum defines various steps in the staff submission process, including sub-variations for + * step 1 (individual, registered, others, and First Nations). It includes a static block + * initializing a map for reverse lookup, allowing retrieval of enum instances by their name. + *

+ */ +public enum StepMatchEnum { + STEP1INDIVIDUAL, STEP1REGISTERED, STEP1OTHERS, STEP1FIRSTNATION, STEP2, STEP3; + + // A map for reverse lookup of enum constants by their name + private static final Map CONSTANTS = new HashMap<>(); + + static { + // Populates the CONSTANTS map with enum names and their corresponding enum instances + for (StepMatchEnum c : values()) { + CONSTANTS.put(c.name(), c); + } + } + + /** + * Returns the enum constant of this type with the specified name. + * + * @param value the name of the enum constant to be returned. + * @return the enum constant with the specified name, or null if no constant with the specified + * name exists. + */ + @JsonCreator + public static StepMatchEnum fromValue(String value) { + return CONSTANTS.get(value); + } +} diff --git a/core/src/main/java/ca/bc/gov/app/dto/client/SubmissionStatusEnum.java b/core/src/main/java/ca/bc/gov/app/dto/client/SubmissionStatusEnum.java index 56cdd62..0bed488 100644 --- a/core/src/main/java/ca/bc/gov/app/dto/client/SubmissionStatusEnum.java +++ b/core/src/main/java/ca/bc/gov/app/dto/client/SubmissionStatusEnum.java @@ -7,6 +7,9 @@ import lombok.AllArgsConstructor; import lombok.Getter; +/** + * Enumeration representing the status of a submission. + */ @Getter @AllArgsConstructor public enum SubmissionStatusEnum { diff --git a/core/src/main/java/ca/bc/gov/app/dto/client/SubmissionTypeCodeEnum.java b/core/src/main/java/ca/bc/gov/app/dto/client/SubmissionTypeCodeEnum.java index ab2aafe..923e8f8 100644 --- a/core/src/main/java/ca/bc/gov/app/dto/client/SubmissionTypeCodeEnum.java +++ b/core/src/main/java/ca/bc/gov/app/dto/client/SubmissionTypeCodeEnum.java @@ -7,12 +7,24 @@ import lombok.AllArgsConstructor; import lombok.Getter; +/** + * Enumeration representing different types of submissions. + *

+ * This enum defines various types of submissions identified by unique codes (e.g., SPP, RNC, AAC). + * It includes a static block to initialize a map for reverse lookup, allowing retrieval of enum + * instances by their name. This feature facilitates the conversion from string values to their + * corresponding enum instances, especially useful in parsing data from external sources or user + * input. + *

+ */ @Getter @AllArgsConstructor public enum SubmissionTypeCodeEnum { SPP("Submission pending processing"), RNC("Review new client"), - AAC("Auto approved client"); + AAC("Auto approved client"), + RAC("Review approved client"), + SSD("Staff submitted data"); private final String description; private static final Map diff --git a/core/src/main/java/ca/bc/gov/app/dto/client/ValidationSourceEnum.java b/core/src/main/java/ca/bc/gov/app/dto/client/ValidationSourceEnum.java new file mode 100644 index 0000000..9232b9e --- /dev/null +++ b/core/src/main/java/ca/bc/gov/app/dto/client/ValidationSourceEnum.java @@ -0,0 +1,42 @@ +package ca.bc.gov.app.dto.client; + +import com.fasterxml.jackson.annotation.JsonCreator; +import java.util.HashMap; +import java.util.Map; + +/** + * Enumeration representing the source of validation. + *

+ * This enum defines the sources of validation, such as external (EXTERNAL) and staff (STAFF). It + * includes a static block to initialize a map for reverse lookup, allowing retrieval of enum + * instances by their name. + *

+ */ +public enum ValidationSourceEnum { + EXTERNAL, STAFF; + + private static final Map CONSTANTS = new HashMap<>(); + + static { + for (ValidationSourceEnum c : values()) { + CONSTANTS.put(c.name(), c); + } + } + + /** + * Retrieves the enum instance corresponding to the given string value. + *

+ * This method allows for reverse lookup of enum instances by their name, facilitating the + * conversion from strings to enum instances. It supports dynamic retrieval of enum instances in + * scenarios where the enum type is determined at runtime. + *

+ * + * @param value The string representation of the enum constant to be retrieved. + * @return The {@link ValidationSourceEnum} instance corresponding to the given string value, or + * null if no matching instance is found. + */ + @JsonCreator + public static ValidationSourceEnum fromValue(String value) { + return CONSTANTS.get(value); + } +} diff --git a/core/src/main/java/ca/bc/gov/app/dto/legacy/AddressSearchDto.java b/core/src/main/java/ca/bc/gov/app/dto/legacy/AddressSearchDto.java new file mode 100644 index 0000000..cd3271b --- /dev/null +++ b/core/src/main/java/ca/bc/gov/app/dto/legacy/AddressSearchDto.java @@ -0,0 +1,17 @@ +package ca.bc.gov.app.dto.legacy; + +import org.apache.commons.lang3.StringUtils; + +public record AddressSearchDto( + String address, + String city, + String province, + String postalCode, + String country +) { + + public boolean isValid() { + return !StringUtils.isAnyBlank(address, city, province, postalCode, country); + } + +} diff --git a/core/src/main/java/ca/bc/gov/app/dto/legacy/ClientDoingBusinessAsDto.java b/core/src/main/java/ca/bc/gov/app/dto/legacy/ClientDoingBusinessAsDto.java new file mode 100644 index 0000000..26102c4 --- /dev/null +++ b/core/src/main/java/ca/bc/gov/app/dto/legacy/ClientDoingBusinessAsDto.java @@ -0,0 +1,14 @@ +package ca.bc.gov.app.dto.legacy; + +import lombok.With; + +@With +public record ClientDoingBusinessAsDto( + String clientNumber, + String doingBusinessAsName, + String createdBy, + String updatedBy, + Long orgUnit +) { + +} diff --git a/core/src/main/java/ca/bc/gov/app/dto/legacy/ClientStatusCodeEnum.java b/core/src/main/java/ca/bc/gov/app/dto/legacy/ClientStatusCodeEnum.java new file mode 100644 index 0000000..9bba77b --- /dev/null +++ b/core/src/main/java/ca/bc/gov/app/dto/legacy/ClientStatusCodeEnum.java @@ -0,0 +1,57 @@ +package ca.bc.gov.app.dto.legacy; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.HashMap; +import java.util.Map; +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * Enumeration representing different client status codes. + *

+ * This enum defines various client status codes identified by unique codes (e.g., ACT, DAC, DEC, + * REC, SPN). It includes a static block to initialize a map for reverse lookup, allowing retrieval + * of enum instances by their name. This feature facilitates the conversion from string values to + * their corresponding enum instances, especially useful in parsing data from external sources or + * user input. + *

+ */ +@Getter +@AllArgsConstructor +public enum ClientStatusCodeEnum { + ACT("Active"), DAC("Deactivated"), DEC("Deceased"), REC("Receivership"), SPN("Suspended"); + + private final String description; + private static final Map CONSTANTS = new HashMap<>(); + + static { + for (ClientStatusCodeEnum c : values()) { + CONSTANTS.put(c.description, c); + } + } + + /** + * Retrieves the enum instance corresponding to the given string value. + *

+ * This method allows for reverse lookup of enum instances by their name, facilitating the + * conversion from strings to enum instances. It supports dynamic retrieval of enum instances in + * scenarios where the enum type is determined at runtime. + *

+ * + * @param value The string representation of the enum constant to be retrieved. + * @return The {@link ClientStatusCodeEnum} instance corresponding to the given string value, or + * throws an {@link IllegalArgumentException} if no matching instance is found. + */ + @JsonCreator + public static ClientStatusCodeEnum fromValue(String value) { + ClientStatusCodeEnum constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + +} diff --git a/core/src/main/java/ca/bc/gov/app/dto/legacy/ClientTypeCodeEnum.java b/core/src/main/java/ca/bc/gov/app/dto/legacy/ClientTypeCodeEnum.java new file mode 100644 index 0000000..8dd5259 --- /dev/null +++ b/core/src/main/java/ca/bc/gov/app/dto/legacy/ClientTypeCodeEnum.java @@ -0,0 +1,55 @@ +package ca.bc.gov.app.dto.legacy; + +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.HashMap; +import java.util.Map; +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * Enumeration representing different types of clients. + *

+ * This enum defines various types of clients identified by single or multiple characters (e.g., C, + * S, A, I, P, L, RSP, USP). It includes a static block to initialize a map for reverse lookup, + * allowing retrieval of enum instances by their name. + *

+ */ +@Getter +@AllArgsConstructor +public enum ClientTypeCodeEnum { + A("Association"), B("First Nation Band"), C("Corporation"), F("Ministry of Forests and Range"), G( + "Government"), I("Individual"), L("Limited Partnership"), P("General Partnership"), R( + "First Nation Group"), S("Society"), T("First Nation Tribal Council"), U( + "Unregistered Company"); + + private final String description; + private static final Map CONSTANTS = new HashMap<>(); + + static { + for (ClientTypeCodeEnum c : values()) { + CONSTANTS.put(c.description, c); + } + } + + /** + * Retrieves the enum instance corresponding to the given string value. + *

+ * This method allows for reverse lookup of enum instances by their name, facilitating the + * conversion from strings to enum instances. It supports dynamic retrieval of enum instances in + * scenarios where the enum type is determined at runtime. + *

+ * + * @param value The string representation of the enum constant to be retrieved. + * @return The {@link ClientTypeCodeEnum} instance corresponding to the given string value, or + * throws an {@link IllegalArgumentException} if no matching instance is found. + */ + public static ClientTypeCodeEnum fromValue(String value) { + ClientTypeCodeEnum constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + +} diff --git a/core/src/main/java/ca/bc/gov/app/dto/legacy/ContactSearchDto.java b/core/src/main/java/ca/bc/gov/app/dto/legacy/ContactSearchDto.java new file mode 100644 index 0000000..536819d --- /dev/null +++ b/core/src/main/java/ca/bc/gov/app/dto/legacy/ContactSearchDto.java @@ -0,0 +1,19 @@ +package ca.bc.gov.app.dto.legacy; + +import org.apache.commons.lang3.StringUtils; + +public record ContactSearchDto( + String firstName, + String middleName, + String lastName, + String email, + String phone, + String phone2, + String fax +) { + + public boolean isValid() { + return !StringUtils.isAnyBlank(firstName, lastName, email, phone); + } + +} diff --git a/core/src/main/java/ca/bc/gov/app/dto/legacy/ForestClientContactDto.java b/core/src/main/java/ca/bc/gov/app/dto/legacy/ForestClientContactDto.java new file mode 100644 index 0000000..352a4f7 --- /dev/null +++ b/core/src/main/java/ca/bc/gov/app/dto/legacy/ForestClientContactDto.java @@ -0,0 +1,20 @@ +package ca.bc.gov.app.dto.legacy; + +import lombok.With; + +@With +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 +) { + +} diff --git a/core/src/main/java/ca/bc/gov/app/dto/legacy/ForestClientDto.java b/core/src/main/java/ca/bc/gov/app/dto/legacy/ForestClientDto.java index 4eca569..96ba2ae 100644 --- a/core/src/main/java/ca/bc/gov/app/dto/legacy/ForestClientDto.java +++ b/core/src/main/java/ca/bc/gov/app/dto/legacy/ForestClientDto.java @@ -1,131 +1,35 @@ package ca.bc.gov.app.dto.legacy; -import ca.bc.gov.app.dto.client.ClientStatusCodeEnum; -import ca.bc.gov.app.dto.client.ClientTypeCodeEnum; -import io.swagger.v3.oas.annotations.media.Schema; +import java.time.LocalDate; import java.util.Map; import java.util.stream.Collectors; import java.util.stream.Stream; +import lombok.With; import org.apache.commons.lang3.StringUtils; -@Schema( - description = "Represents a client from the legacy forest database.", - title = "ForestClient", - example = """ - { - "clientNumber": "00000002", - "clientName": "BAXTER", - "legalFirstName": "", - "legalMiddleName": "", - "clientStatusCode": "ACT", - "clientTypeCode": "I", - "clientIdTypeCode": "C", - "clientIdentification": "00000002", - "registryCompanyTypeCode": "BC", - "corpRegnNmbr": "00000002", - "clientAcronym": "", - "wcbFirmNumber": "", - "ocgSupplierNmbr": "", - "clientComment": "" - }""" -) +@With public record ForestClientDto( - @Schema( - description = "The client number.", - example = "00000002" - ) String clientNumber, - @Schema(description = """ - The client last name if it's an individual or - the company name if it's a company""", - example = "BAXTER" - ) String clientName, - @Schema(description = """ - The first name of the individual, - or null if it's a company""", - example = "JAMES") String legalFirstName, - @Schema(description = """ - The middle name of the individual, - or null if it's a company""", - example = "Canter") String legalMiddleName, - @Schema(description = """ - The status of the client, can be any of the following:
- - ACT (Active)
- DAC (Deactivated)
- DEC (Deceased)
- REC (Receivership)
- SPN (Suspended)""", - example = "ACT") String clientStatusCode, - @Schema(description = """ - The type of client, can be any of the following:
- - A (Association)
- B (First Nation Band)
- C (Corporation)
- F (Ministry of Forests and Range)
- G (Government)
- I (Individual)
- L (Limited Partnership)
- P (General Partnership)
- R (First Nation Group)
- S (Society)
- T (First Nation Tribal Council)
- U (Unregistered Company)""", - example = "I") String clientTypeCode, - - @Schema(description = """ - The type of client, can be any of the following:
- - A (Association)
- B (First Nation Band)
- C (Corporation)
- F (Ministry of Forests and Range)
- G (Government)
- I (Individual)
- L (Limited Partnership)
- P (General Partnership)
- R (First Nation Group)
- S (Society)
- T (First Nation Tribal Council)
- U (Unregistered Company)""", - example = "C") + LocalDate birthdate, String clientIdTypeCode, - @Schema(description = "An ID to identify companies",example = "Wull.") String clientIdentification, - @Schema(description = """ - The type of company, such as:
- - BC (BC Registered Business)
- FM (Sole Proprietorship)""", - example = "FM") String registryCompanyTypeCode, - @Schema(description = "Company registration number", - example = "00000002") String corpRegnNmbr, - @Schema(description = "An acronyms for this client", - example = "JAMES BAXTER") - String clientAcronym, - @Schema(description = "WCB firm number", - example = "00000002") + String clientComment, + String createdBy, + String updatedBy, + Long orgUnit, + String acronym, String wcbFirmNumber, - @Schema(description = "OCG supplier number", - example = "00000002") - String ocgSupplierNmbr, - @Schema(description = "A comment for this client", - example = "This is a comment") - String clientComment + String ocgSupplierNmbr + ) { - /** - * Returns the legal name of the client already formatted - * @return A string with the legal name - */ public String legalName() { if (StringUtils.defaultString(clientTypeCode).equalsIgnoreCase("I")) { return @@ -140,20 +44,18 @@ public String legalName() { return StringUtils.defaultString(clientName); } - /** - * Returns a map with the client information - * @return A map with the client information - */ - public Map description() { + public Map description(String userName) { return Map.of( + "userName", userName, "number", clientNumber, "name", legalName(), "status", ClientStatusCodeEnum.valueOf(clientStatusCode), "type", ClientTypeCodeEnum.valueOf(clientTypeCode), "identifier", - StringUtils.defaultString(registryCompanyTypeCode) + - StringUtils.defaultString(corpRegnNmbr) + StringUtils.defaultString(registryCompanyTypeCode) + + StringUtils.defaultString(corpRegnNmbr) ); } + } \ No newline at end of file diff --git a/core/src/main/java/ca/bc/gov/app/dto/legacy/ForestClientLocationDto.java b/core/src/main/java/ca/bc/gov/app/dto/legacy/ForestClientLocationDto.java new file mode 100644 index 0000000..860066f --- /dev/null +++ b/core/src/main/java/ca/bc/gov/app/dto/legacy/ForestClientLocationDto.java @@ -0,0 +1,34 @@ +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 updateOrgUnit, + Long addOrgUnit +) { + +} diff --git a/core/src/main/java/ca/bc/gov/app/dto/legacy/PredictiveSearchResultDto.java b/core/src/main/java/ca/bc/gov/app/dto/legacy/PredictiveSearchResultDto.java new file mode 100644 index 0000000..f751576 --- /dev/null +++ b/core/src/main/java/ca/bc/gov/app/dto/legacy/PredictiveSearchResultDto.java @@ -0,0 +1,34 @@ +package ca.bc.gov.app.dto.legacy; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import org.apache.commons.lang3.StringUtils; + +public record PredictiveSearchResultDto( + String clientNumber, + String clientAcronym, + String clientName, + String clientFirstName, + String doingBusinessAs, + String clientIdentification, + String clientMiddleName, + String city, + String clientType, + String clientStatus, + long score +) { + + @JsonProperty("clientFullName") + public String clientFullName() { + String finalName = Stream.of(this.clientFirstName, this.clientMiddleName, this.clientName) + .filter(StringUtils::isNotBlank) + .map(String::trim) + .collect(Collectors.joining(" ")); + + return StringUtils.isNotBlank(this.doingBusinessAs) + ? finalName + " (" + this.doingBusinessAs + ")" + : finalName; + } + +} diff --git a/core/src/main/java/ca/bc/gov/app/dto/opendata/Crs.java b/core/src/main/java/ca/bc/gov/app/dto/opendata/Crs.java new file mode 100644 index 0000000..451ddcb --- /dev/null +++ b/core/src/main/java/ca/bc/gov/app/dto/opendata/Crs.java @@ -0,0 +1,7 @@ +package ca.bc.gov.app.dto.opendata; + +public record Crs( + String type, + CrsProperties properties +) { +} diff --git a/core/src/main/java/ca/bc/gov/app/dto/opendata/CrsProperties.java b/core/src/main/java/ca/bc/gov/app/dto/opendata/CrsProperties.java new file mode 100644 index 0000000..9e3d260 --- /dev/null +++ b/core/src/main/java/ca/bc/gov/app/dto/opendata/CrsProperties.java @@ -0,0 +1,6 @@ +package ca.bc.gov.app.dto.opendata; + +public record CrsProperties( + String name +) { +} diff --git a/core/src/main/java/ca/bc/gov/app/dto/opendata/Feature.java b/core/src/main/java/ca/bc/gov/app/dto/opendata/Feature.java new file mode 100644 index 0000000..b501f5d --- /dev/null +++ b/core/src/main/java/ca/bc/gov/app/dto/opendata/Feature.java @@ -0,0 +1,12 @@ +package ca.bc.gov.app.dto.opendata; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public record Feature( + String type, + String id, + Geometry geometry, + @JsonProperty("geometry_name") String geometryName, + FeatureProperties properties +) { +} diff --git a/core/src/main/java/ca/bc/gov/app/dto/opendata/FeatureProperties.java b/core/src/main/java/ca/bc/gov/app/dto/opendata/FeatureProperties.java new file mode 100644 index 0000000..ff2a368 --- /dev/null +++ b/core/src/main/java/ca/bc/gov/app/dto/opendata/FeatureProperties.java @@ -0,0 +1,68 @@ +package ca.bc.gov.app.dto.opendata; + +import ca.bc.gov.app.dto.legacy.ClientTypeCodeEnum; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.Objects; +import java.util.stream.IntStream; +import java.util.stream.Stream; +import org.apache.commons.lang3.StringUtils; + +@JsonIgnoreProperties(ignoreUnknown = true) +public record FeatureProperties( + @JsonProperty("GmlID") String gmlId, + @JsonProperty("OBJECTID") int objectId, + @JsonProperty("Numéro_de_bande___Band_Number") int bandNumber, + @JsonProperty("Numéro_du_conseil_tribal___Tribal_Council_Number") int tribeNumber, + @JsonProperty("Nom_de_bande___Band_Name") String bandName, + @JsonProperty("Nom_du_conseil_tribal___Tribal_Council_Name") String tribeName, + @JsonProperty("COMMUNITY_LOCATION_ID") int communityLocationId, + @JsonProperty("FIRST_NATION_BC_NAME") String firstNationBCName, + @JsonProperty("FIRST_NATION_FEDERAL_NAME") String firstNationFederalName, + @JsonProperty("FIRST_NATION_FEDERAL_ID") int firstNationFederalId, + @JsonProperty("URL_TO_BC_WEBSITE") String urlToBCWebsite, + @JsonProperty("URL_TO_FEDERAL_WEBSITE") String urlToFederalWebsite, + @JsonProperty("URL_TO_FIRST_NATION_WEBSITE") String urlToFirstNationWebsite, + @JsonProperty("MEMBER_ORGANIZATION_NAMES") String memberOrganizationNames, + @JsonProperty("LANGUAGE_GROUP") String languageGroup, + @JsonProperty("BC_REGIONAL_OFFICE") String bcRegionalOffice, + @JsonProperty("MAPSHEET_NUMBER") String mapsheetNumber, + @JsonProperty("PREFERRED_NAME") String preferredName, + @JsonProperty("ALTERNATIVE_NAME_1") String alternativeName1, + @JsonProperty("ALTERNATIVE_NAME_2") String alternativeName2, + @JsonProperty("ADDRESS_LINE1") String addressLine1, + @JsonProperty("ADDRESS_LINE2") String addressLine2, + @JsonProperty("OFFICE_CITY") String officeCity, + @JsonProperty("OFFICE_PROVINCE") String officeProvince, + @JsonProperty("OFFICE_POSTAL_CODE") String officePostalCode, + @JsonProperty("LOCATION_DESCRIPTION") String locationDescription, + @JsonProperty("SITE_NAME") String siteName, + @JsonProperty("SITE_NUMBER") String siteNumber, + @JsonProperty("COMMENTS") String comments, + @JsonProperty("SE_ANNO_CAD_DATA") Object seAnnoCadData, + @JsonProperty("CPC_CODE") String cpcCode +) { + + public String getNationName() { + return Stream + .of(firstNationBCName(), bandName(), tribeName()) + .filter(StringUtils::isNotBlank) + .findFirst() + .orElse(StringUtils.EMPTY); + } + + public int getNationId() { + return IntStream + .of(firstNationFederalId(), bandNumber(), tribeNumber()) + .filter(id -> id > 0) + .filter(Objects::nonNull) + .findFirst() + .orElse(0); + } + + public ClientTypeCodeEnum getFirstNationType() { + return + StringUtils.isNotBlank(tribeName()) ? ClientTypeCodeEnum.T : ClientTypeCodeEnum.B; + } + +} \ No newline at end of file diff --git a/core/src/main/java/ca/bc/gov/app/dto/opendata/Geometry.java b/core/src/main/java/ca/bc/gov/app/dto/opendata/Geometry.java new file mode 100644 index 0000000..7e70272 --- /dev/null +++ b/core/src/main/java/ca/bc/gov/app/dto/opendata/Geometry.java @@ -0,0 +1,9 @@ +package ca.bc.gov.app.dto.opendata; + +import java.util.List; + +public record Geometry( + String type, + List coordinates +) { +} diff --git a/core/src/main/java/ca/bc/gov/app/dto/opendata/OpenData.java b/core/src/main/java/ca/bc/gov/app/dto/opendata/OpenData.java new file mode 100644 index 0000000..74ab997 --- /dev/null +++ b/core/src/main/java/ca/bc/gov/app/dto/opendata/OpenData.java @@ -0,0 +1,10 @@ +package ca.bc.gov.app.dto.opendata; + +import java.util.List; + +public record OpenData( + String type, + Crs crs, + List features +) { +} diff --git a/core/src/main/java/ca/bc/gov/app/dto/processor/MessagingWrapper.java b/core/src/main/java/ca/bc/gov/app/dto/processor/MessagingWrapper.java new file mode 100644 index 0000000..4f2daf0 --- /dev/null +++ b/core/src/main/java/ca/bc/gov/app/dto/processor/MessagingWrapper.java @@ -0,0 +1,37 @@ +package ca.bc.gov.app.dto.processor; + +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +public record MessagingWrapper( + T payload, + Map parameters +) { + + public MessagingWrapper(T payload, Map parameters) { + this.payload = payload; + this.parameters = new HashMap<>(parameters); + } + + + public MessagingWrapper withParameter(String key, Object value) { + this.parameters.put(key, value); + return this; + } + + @SuppressWarnings({"unchecked", "unused"}) + public

P getParameter(String key,Class

clazz) { + if (Objects.isNull(this.parameters.get(key))) + return null; + return (P) this.parameters.get(key); + } + + public

P getInfoParameter(String key,Class

clazz) { + Map info = getParameter("info",Map.class); + if (Objects.isNull(info)) + return null; + return (P) info.get(key); + } + +} diff --git a/core/src/main/java/ca/bc/gov/app/dto/submissions/MatcherResult.java b/core/src/main/java/ca/bc/gov/app/dto/submissions/MatcherResult.java new file mode 100644 index 0000000..2123c3b --- /dev/null +++ b/core/src/main/java/ca/bc/gov/app/dto/submissions/MatcherResult.java @@ -0,0 +1,46 @@ +package ca.bc.gov.app.dto.submissions; + +import java.util.Set; +import org.apache.commons.lang3.StringUtils; + +/** + * This record represents the result of a matching operation. + * It contains the name of the field that was matched and a set of values that were found. + */ +public record MatcherResult( + String fieldName, // The name of the field that was matched + Set values // The set of values that were found +) { + + /** + * This method is used to add a value to the set of values. + * It checks if the value is not blank and the set of values is not null before adding the value. + * + * @param value The value to be added to the set of values. + */ + public void addValue(String value) { + if (StringUtils.isNotBlank(value) && this.values != null) { + this.values.add(value); + } + } + + /** + * This method is used to get a string representation of the set of values. + * It joins the values with a comma. + * + * @return A string representation of the set of values. + */ + public String value() { + return String.join(",", this.values); + } + + /** + * This method is used to check if there is a match. + * It checks if the set of values is not null and not empty. + * + * @return A boolean indicating if there is a match. + */ + public boolean hasMatch() { + return this.values != null && !this.values.isEmpty(); + } +} \ No newline at end of file diff --git a/core/src/main/java/ca/bc/gov/app/dto/submissions/SubmissionAddressDto.java b/core/src/main/java/ca/bc/gov/app/dto/submissions/SubmissionAddressDto.java new file mode 100644 index 0000000..3652827 --- /dev/null +++ b/core/src/main/java/ca/bc/gov/app/dto/submissions/SubmissionAddressDto.java @@ -0,0 +1,13 @@ +package ca.bc.gov.app.dto.submissions; + +public record SubmissionAddressDto( + Integer index, + String streetAddress, + String country, + String province, + String city, + String postalCode, + String name +) { + +} diff --git a/core/src/main/java/ca/bc/gov/app/dto/submissions/SubmissionApproveRejectDto.java b/core/src/main/java/ca/bc/gov/app/dto/submissions/SubmissionApproveRejectDto.java new file mode 100644 index 0000000..1cdd976 --- /dev/null +++ b/core/src/main/java/ca/bc/gov/app/dto/submissions/SubmissionApproveRejectDto.java @@ -0,0 +1,11 @@ +package ca.bc.gov.app.dto.submissions; + +import java.util.List; + +public record SubmissionApproveRejectDto( + boolean approved, + List reasons, + String message +) { + +} diff --git a/core/src/main/java/ca/bc/gov/app/dto/submissions/SubmissionBusinessDto.java b/core/src/main/java/ca/bc/gov/app/dto/submissions/SubmissionBusinessDto.java new file mode 100644 index 0000000..e5192c3 --- /dev/null +++ b/core/src/main/java/ca/bc/gov/app/dto/submissions/SubmissionBusinessDto.java @@ -0,0 +1,18 @@ +package ca.bc.gov.app.dto.submissions; + +import java.time.LocalDate; + +public record SubmissionBusinessDto( + String businessType, + String registrationNumber, + String clientNumber, + String organizationName, + String clientType, + String clientTypeDesc, + String goodStandingInd, + LocalDate birthdate, + String district, + String districtDesc +) { + +} diff --git a/core/src/main/java/ca/bc/gov/app/dto/submissions/SubmissionContactDto.java b/core/src/main/java/ca/bc/gov/app/dto/submissions/SubmissionContactDto.java new file mode 100644 index 0000000..39d1e9b --- /dev/null +++ b/core/src/main/java/ca/bc/gov/app/dto/submissions/SubmissionContactDto.java @@ -0,0 +1,16 @@ +package ca.bc.gov.app.dto.submissions; + +import java.util.Set; + +public record SubmissionContactDto( + Integer index, + String contactType, + String firstName, + String lastName, + String phoneNumber, + String emailAddress, + Set locations, + String userId +) { + +} diff --git a/core/src/main/java/ca/bc/gov/app/dto/submissions/SubmissionDetailsDto.java b/core/src/main/java/ca/bc/gov/app/dto/submissions/SubmissionDetailsDto.java new file mode 100644 index 0000000..5f91ef6 --- /dev/null +++ b/core/src/main/java/ca/bc/gov/app/dto/submissions/SubmissionDetailsDto.java @@ -0,0 +1,25 @@ +package ca.bc.gov.app.dto.submissions; + +import java.time.LocalDateTime; +import java.util.List; +import java.util.Map; +import lombok.With; + +@With +public record SubmissionDetailsDto( + Long submissionId, + String submissionStatus, + String submissionType, + LocalDateTime submittedTimestamp, + LocalDateTime updateTimestamp, + LocalDateTime approvedTimestamp, + String updateUser, + SubmissionBusinessDto business, + List contact, + List address, + Map matchers, + String rejectionReason, + String confirmedMatchUserId +) { + +} diff --git a/core/src/main/java/ca/bc/gov/app/dto/submissions/SubmissionInformationDto.java b/core/src/main/java/ca/bc/gov/app/dto/submissions/SubmissionInformationDto.java new file mode 100644 index 0000000..366e2b6 --- /dev/null +++ b/core/src/main/java/ca/bc/gov/app/dto/submissions/SubmissionInformationDto.java @@ -0,0 +1,15 @@ +package ca.bc.gov.app.dto.submissions; + +import java.time.LocalDate; +import lombok.With; + +@With +public record SubmissionInformationDto( + Integer submissionId, + String corporationName, + LocalDate dateOfBirth, + String registrationNumber, + String goodStanding, + String clientType +) { +} diff --git a/core/src/main/java/ca/bc/gov/app/dto/submissions/SubmissionProcessKindEnum.java b/core/src/main/java/ca/bc/gov/app/dto/submissions/SubmissionProcessKindEnum.java new file mode 100644 index 0000000..b467d78 --- /dev/null +++ b/core/src/main/java/ca/bc/gov/app/dto/submissions/SubmissionProcessKindEnum.java @@ -0,0 +1,33 @@ +package ca.bc.gov.app.dto.submissions; + +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** + * Enum representing the kind of submission process. + */ +public enum SubmissionProcessKindEnum { + HOT, + COLD; + + private static final Map CONSTANTS = new HashMap<>(); + + static { + for (SubmissionProcessKindEnum c : values()) { + CONSTANTS.put(c.name(), c); + } + } + + /** + * Returns the SubmissionProcessKindEnum corresponding to the given value. + * If the value is not found, it defaults to COLD. + * + * @param value the value to look up + * @return the corresponding SubmissionProcessKindEnum, or COLD if not found + */ + public static SubmissionProcessKindEnum fromValue(String value) { + SubmissionProcessKindEnum constant = CONSTANTS.get(value); + return Objects.requireNonNullElse(constant, COLD); + } +} \ No newline at end of file diff --git a/core/src/main/java/ca/bc/gov/app/util/LogUtil.java b/core/src/main/java/ca/bc/gov/app/util/LogUtil.java deleted file mode 100644 index 6f090d7..0000000 --- a/core/src/main/java/ca/bc/gov/app/util/LogUtil.java +++ /dev/null @@ -1,26 +0,0 @@ -package ca.bc.gov.app.util; - -import java.util.function.Consumer; -import lombok.AccessLevel; -import lombok.NoArgsConstructor; -import org.slf4j.Logger; -import org.slf4j.event.Level; - -/** - *

Log Util

- *

Utility class for logging.

- */ -@NoArgsConstructor(access = AccessLevel.PRIVATE) -public class LogUtil { - - /** - *

Log Content

- * Log the content of the future at the specified level. - * - * @param The type that will be passed through the future. - * @return the same content of the future - */ - public static Consumer logContent(Logger logger, Level logLevel) { - return message -> logger.atLevel(logLevel).log("{}", message); - } -} diff --git a/core/src/main/java/ca/bc/gov/app/util/PkceUtil.java b/core/src/main/java/ca/bc/gov/app/util/PkceUtil.java new file mode 100644 index 0000000..94a4ef4 --- /dev/null +++ b/core/src/main/java/ca/bc/gov/app/util/PkceUtil.java @@ -0,0 +1,43 @@ +package ca.bc.gov.app.util; + +import java.nio.charset.StandardCharsets; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.security.SecureRandom; +import java.util.Base64; +import lombok.AccessLevel; +import lombok.NoArgsConstructor; + +/** + * Utility class for generating PKCE code verifier and code challenge. + */ +@NoArgsConstructor(access = AccessLevel.PRIVATE) +public class PkceUtil { + + /** + * Generates a random string of 43 characters (256 bits) for use as a code verifier. + * + * @return a random string of 43 characters (256 bits) + */ + public static String generateCodeVerifier() { + SecureRandom random = new SecureRandom(); + byte[] codeVerifierBytes = new byte[32]; // 256 bits (43 characters after base64 encoding) + random.nextBytes(codeVerifierBytes); + return Base64.getUrlEncoder().withoutPadding().encodeToString(codeVerifierBytes); + } + + /** + * Generates a code challenge from the given code verifier. + * + * @param codeVerifier the code verifier to generate a code challenge from + * + * @return the code challenge + * @throws NoSuchAlgorithmException if the SHA-256 algorithm is not available + */ + public static String generateCodeChallenge(String codeVerifier) throws NoSuchAlgorithmException { + MessageDigest digest = MessageDigest.getInstance("SHA-256"); + byte[] codeChallengeBytes = digest.digest(codeVerifier.getBytes(StandardCharsets.US_ASCII)); + return Base64.getUrlEncoder().withoutPadding().encodeToString(codeChallengeBytes); + } + +} diff --git a/core/src/test/java/ca/bc/gov/app/util/PkceUtilTest.java b/core/src/test/java/ca/bc/gov/app/util/PkceUtilTest.java new file mode 100644 index 0000000..1e1a057 --- /dev/null +++ b/core/src/test/java/ca/bc/gov/app/util/PkceUtilTest.java @@ -0,0 +1,30 @@ +package ca.bc.gov.app.util; + +import static org.assertj.core.api.AssertionsForClassTypes.assertThat; + +import java.security.NoSuchAlgorithmException; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +@DisplayName("Unit Test | PkceUtil") +class PkceUtilTest { + + @Test + @DisplayName("should generate code verifier") + void shouldGenerateCodeVerifier() { + assertThat(PkceUtil.generateCodeVerifier()) + .isNotNull() + .isNotEmpty() + .hasSize(43); + } + + @Test + @DisplayName("should generate code challenge") + void shouldGenerateCodeChallenge() throws NoSuchAlgorithmException { + assertThat(PkceUtil.generateCodeChallenge(PkceUtil.generateCodeVerifier())) + .isNotNull() + .isNotEmpty() + .hasSize(43); + } + +} \ No newline at end of file