-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: validation improvements (#428)
* no message * fix(fe/be): - Fixed validation messages on the BE - Fixed missing return in validation messages component - Added missing validation in contacts section - Refactored code in both FE and BE - Beautified code * fix(be): - Fixed as per recommended (WhitespaceAround: '+' is not followed by whitespace.) * feat(be): - Cleaned and organized imports * feat(fe/be): - Improved code after code reviews * feat/fix(be): - Fixed unit testting bug - Cleaned imports - Beautified code for better readibility * Revert "feat(be):" This reverts commit 12b8122. * fix(be): - Made code reviews * fix(be): - Fixed code smell issues #1 * fix(be): - Removed extra separation in import group to satisfy SonarCloud * fix(be): - Fixed code smell issues #2 * fix(be): - Fixed code smell issues #3 * fix(be): - Code reviews: Defined a constant instead of duplicating literal * fix(be): - Reverted change as I had it before * fix(be): - Fixed typo * fix(be): - Changed field to businessName as the incorporation number is hidden in the UI * fix(be): - Fixed based on code reviews standard - Fixed code smells. Need to discuss this with the team as this doesn't make sense. * feat(fe): - Removed error msgs when value changes * feat(BE): updating bc registry to use document requisition * feat(fe): - FSADT1-736 * fix(be): - Changed wording as per suggested by Paulo --------- Co-authored-by: Maria Martinez <[email protected]> Co-authored-by: Maria Martinez <[email protected]>
- Loading branch information
1 parent
3a6e0b2
commit 645c19a
Showing
27 changed files
with
553 additions
and
161 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
backend/src/main/java/ca/bc/gov/app/dto/bcregistry/BcRegistryBusinessAdressesDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,24 @@ | ||
package ca.bc.gov.app.dto.bcregistry; | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
public record BcRegistryBusinessAdressesDto( | ||
BcRegistryAddressDto mailingAddress, | ||
BcRegistryAddressDto deliveryAddress | ||
) { | ||
public boolean isValid(){ | ||
return mailingAddress != null || deliveryAddress != null; | ||
} | ||
|
||
public Set<BcRegistryAddressDto> addresses(){ | ||
Set<BcRegistryAddressDto> addressDtoSet = new HashSet<>(); | ||
if(mailingAddress != null) | ||
addressDtoSet.add(mailingAddress); | ||
if(deliveryAddress != null) | ||
addressDtoSet.add(deliveryAddress); | ||
return addressDtoSet; | ||
} | ||
} |
2 changes: 2 additions & 0 deletions
2
backend/src/main/java/ca/bc/gov/app/dto/bcregistry/BcRegistryBusinessDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
backend/src/main/java/ca/bc/gov/app/dto/bcregistry/BcRegistryDocumentAccessRequestDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<BcRegistryDocumentAccessTypeDto> documents | ||
) { | ||
} |
13 changes: 13 additions & 0 deletions
13
backend/src/main/java/ca/bc/gov/app/dto/bcregistry/BcRegistryDocumentAccessTypeDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
) { | ||
} |
56 changes: 56 additions & 0 deletions
56
backend/src/main/java/ca/bc/gov/app/dto/bcregistry/BcRegistryDocumentDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package ca.bc.gov.app.dto.bcregistry; | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||
import java.util.HashMap; | ||
import java.util.HashSet; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Set; | ||
import lombok.With; | ||
|
||
@With | ||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
public record BcRegistryDocumentDto( | ||
BcRegistryBusinessDto business, | ||
BcRegistryOfficesDto offices, | ||
List<BcRegistryPartyDto> parties | ||
) { | ||
|
||
/** | ||
* Returns a mapping of addresses to sets of parties associated with those addresses. If the | ||
* offices object is valid, adds all of its addresses to the mapping with an empty set of parties. | ||
* For each valid party, adds it to the set of parties associated with its mailing or delivery | ||
* address in the mapping. | ||
* | ||
* @return a mapping of addresses to sets of parties associated with those addresses | ||
*/ | ||
public Map<BcRegistryAddressDto, Set<BcRegistryPartyDto>> matchOfficesParties() { | ||
|
||
Map<BcRegistryAddressDto, Set<BcRegistryPartyDto>> results = new HashMap<>(); | ||
|
||
// If offices exist and are valid, add all their addresses to the results map | ||
if (offices != null && offices.isValid()) { | ||
offices.addresses().forEach(address -> results.put(address, new HashSet<>())); | ||
} | ||
|
||
// For each party, if it's valid and has a mailing or delivery address, | ||
// add it to the set of parties associated with that address in the results map | ||
for (BcRegistryPartyDto party : parties) { | ||
if (!party.isValid()) { | ||
continue; | ||
} | ||
|
||
BcRegistryAddressDto mailingAddress = party.mailingAddress(); | ||
if (mailingAddress != null) { | ||
results.computeIfAbsent(mailingAddress, key -> new HashSet<>()).add(party); | ||
} | ||
|
||
BcRegistryAddressDto deliveryAddress = party.deliveryAddress(); | ||
if (deliveryAddress != null) { | ||
results.computeIfAbsent(deliveryAddress, key -> new HashSet<>()).add(party); | ||
} | ||
} | ||
|
||
return results; | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
backend/src/main/java/ca/bc/gov/app/dto/bcregistry/BcRegistryDocumentRequestBodyDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
) { | ||
} |
14 changes: 14 additions & 0 deletions
14
backend/src/main/java/ca/bc/gov/app/dto/bcregistry/BcRegistryDocumentRequestDocumentDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
) { | ||
} |
16 changes: 16 additions & 0 deletions
16
backend/src/main/java/ca/bc/gov/app/dto/bcregistry/BcRegistryDocumentRequestResponseDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<BcRegistryDocumentRequestDocumentDto> documents, | ||
String paymentStatus, | ||
String status | ||
) { | ||
} |
12 changes: 12 additions & 0 deletions
12
backend/src/main/java/ca/bc/gov/app/dto/bcregistry/BcRegistryExceptionMessageDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
) { | ||
} |
13 changes: 13 additions & 0 deletions
13
backend/src/main/java/ca/bc/gov/app/dto/bcregistry/BcRegistryOfficerDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package ca.bc.gov.app.dto.bcregistry; | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||
|
||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
public record BcRegistryOfficerDto( | ||
String email, | ||
String firstName, | ||
String lastName, | ||
String middleInitial, | ||
String partyType | ||
) { | ||
} |
25 changes: 25 additions & 0 deletions
25
backend/src/main/java/ca/bc/gov/app/dto/bcregistry/BcRegistryOfficesDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package ca.bc.gov.app.dto.bcregistry; | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||
import java.util.Objects; | ||
import java.util.Optional; | ||
import java.util.Set; | ||
import java.util.stream.Collectors; | ||
import lombok.With; | ||
|
||
@With | ||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
public record BcRegistryOfficesDto( | ||
BcRegistryBusinessAdressesDto businessOffice | ||
) { | ||
public Set<BcRegistryAddressDto> addresses() { | ||
return Optional | ||
.ofNullable(businessOffice) | ||
.filter(BcRegistryBusinessAdressesDto::isValid) | ||
.map(BcRegistryBusinessAdressesDto::addresses) | ||
.orElse(Set.of()); | ||
} | ||
public boolean isValid(){ | ||
return businessOffice != null && businessOffice.isValid(); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
backend/src/main/java/ca/bc/gov/app/dto/bcregistry/BcRegistryPartyDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
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 BcRegistryPartyDto( | ||
BcRegistryAddressDto deliveryAddress, | ||
BcRegistryAddressDto mailingAddress, | ||
BcRegistryOfficerDto officer, | ||
List<BcRegistryRoleDto> roles | ||
) { | ||
public boolean isValid() { | ||
return officer != null && (mailingAddress != null || deliveryAddress != null); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
backend/src/main/java/ca/bc/gov/app/dto/bcregistry/BcRegistryRoleDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
package ca.bc.gov.app.dto.client; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import lombok.With; | ||
|
||
@Schema( | ||
description = "Client information contact", | ||
|
@@ -17,6 +18,7 @@ | |
"email": "[email protected]", | ||
}""" | ||
) | ||
@With | ||
public record ClientContactDto( | ||
@Schema(description = "The type of contact", | ||
example = "person") | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.