-
Notifications
You must be signed in to change notification settings - Fork 2
fix(#2395): prevent contact deletion when linked to other systems #2402
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
a6d61bd
fix(#2395): prevent contact deletion when linked to other systems
mamartinezmejia b4840a2
no message
mamartinezmejia 39df735
Potential fix for pull request finding
mamartinezmejia 8b83006
no message
mamartinezmejia 96af52a
Fixed order of imports
mamartinezmejia 5fc254c
Merge branch 'main' into feat/2395
mamartinezmejia a30a114
Used a primitive boolean expression
mamartinezmejia f8b9e65
Added javadocs
mamartinezmejia 35ac333
Merge branch 'main' into feat/2395
mamartinezmejia 1567f0a
Fixed checkstyle violations
mamartinezmejia 0ce9423
Fixed checkstyle violations
mamartinezmejia 84bb4f4
Merge branch 'main' into feat/2395
paulushcgcj 0850d95
fix(#2395): validate all contacts before deleting any on removal
mamartinezmejia 06f97be
Updated frontend test
mamartinezmejia 96b0778
Updated the GET_ALL_CONTACT_IDS query in ForestClientQueries.java to …
mamartinezmejia e06b2ce
fix(#2395): wrap contact removal check-and-delete in a transaction
mamartinezmejia 1d05ef4
Merge branch 'main' into feat/2395
mamartinezmejia File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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
79 changes: 79 additions & 0 deletions
79
legacy/src/main/java/ca/bc/gov/app/entity/ScaleSiteContactEntity.java
This file contains hidden or 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,79 @@ | ||
| package ca.bc.gov.app.entity; | ||
|
|
||
| import static ca.bc.gov.app.ApplicationConstants.ORACLE_ATTRIBUTE_SCHEMA; | ||
|
|
||
| import java.time.LocalDate; | ||
| import java.time.LocalDateTime; | ||
| import jakarta.validation.constraints.NotNull; | ||
| import jakarta.validation.constraints.Size; | ||
| import lombok.AllArgsConstructor; | ||
| import lombok.Builder; | ||
| import lombok.Data; | ||
| import lombok.NoArgsConstructor; | ||
| import lombok.With; | ||
| import org.springframework.data.annotation.Id; | ||
| import org.springframework.data.relational.core.mapping.Column; | ||
| import org.springframework.data.relational.core.mapping.Table; | ||
|
|
||
| @NoArgsConstructor | ||
| @AllArgsConstructor | ||
| @Data | ||
| @Builder | ||
| @With | ||
| @Table(name = "SCALE_SITE_CONTACT", schema = ORACLE_ATTRIBUTE_SCHEMA) | ||
| public class ScaleSiteContactEntity { | ||
|
|
||
| @Id | ||
| @Column("CLIENT_CONTACT_ID") | ||
| private Long clientContactId; | ||
|
|
||
| @Column("SCALE_SITE_ID_NMBR") | ||
| @NotNull | ||
| @Size(min = 1, max = 4) | ||
| private String scaleSiteIdNumber; | ||
|
|
||
| @Column("CONTACT_ROLE_DESCRIPTION") | ||
| @NotNull | ||
| @Size(min = 1, max = 40) | ||
| private String contactRoleDescription; | ||
|
|
||
| @Column("PRIMARY_CONTACT_IND") | ||
| @NotNull | ||
| @Size(min = 1, max = 1) | ||
| private String primaryContactInd; | ||
|
|
||
| @Column("SITE_INFORMATION_ACCESS_IND") | ||
| @NotNull | ||
| @Size(min = 1, max = 1) | ||
| private String siteInformationAccessInd; | ||
|
|
||
| @Column("EFFECTIVE_DATE") | ||
| @NotNull | ||
| private LocalDate effectiveDate; | ||
|
|
||
| @Column("EXPIRY_DATE") | ||
| private LocalDate expiryDate; | ||
|
|
||
| @Column("ENTRY_TIMESTAMP") | ||
| @NotNull | ||
| private LocalDateTime createdAt; | ||
|
|
||
| @Column("ENTRY_USERID") | ||
| @NotNull | ||
| @Size(min = 1, max = 30) | ||
| private String createdBy; | ||
|
|
||
| @Column("UPDATE_TIMESTAMP") | ||
| @NotNull | ||
| private LocalDateTime updatedAt; | ||
|
|
||
| @Column("UPDATE_USERID") | ||
| @NotNull | ||
| @Size(min = 1, max = 30) | ||
| private String updatedBy; | ||
|
|
||
| @Column("REVISION_COUNT") | ||
| @NotNull | ||
| private Long revision; | ||
|
|
||
| } |
22 changes: 22 additions & 0 deletions
22
legacy/src/main/java/ca/bc/gov/app/exception/ContactInUseException.java
This file contains hidden or 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,22 @@ | ||
| package ca.bc.gov.app.exception; | ||
|
|
||
| import org.springframework.http.HttpStatus; | ||
| import org.springframework.web.bind.annotation.ResponseStatus; | ||
| import org.springframework.web.server.ResponseStatusException; | ||
|
|
||
| /** | ||
| * Exception thrown when an attempt is made to delete a client contact that is still | ||
| * referenced by another system (e.g. EMS, GAS2, LEXIS, or SCS). | ||
| */ | ||
| @ResponseStatus(HttpStatus.CONFLICT) | ||
| public class ContactInUseException extends ResponseStatusException { | ||
|
|
||
| public ContactInUseException() { | ||
| super( | ||
| HttpStatus.CONFLICT, | ||
| "You can't delete this contact yet because it's being used by EMS, GAS2, LEXIS, or SCS. " | ||
| + "Remove it from the other system first, then try again." | ||
| ); | ||
| } | ||
|
|
||
| } |
27 changes: 27 additions & 0 deletions
27
legacy/src/main/java/ca/bc/gov/app/repository/ScaleSiteContactRepository.java
This file contains hidden or 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,27 @@ | ||
| package ca.bc.gov.app.repository; | ||
|
|
||
| import ca.bc.gov.app.entity.ScaleSiteContactEntity; | ||
| import org.springframework.data.repository.reactive.ReactiveCrudRepository; | ||
| import org.springframework.stereotype.Repository; | ||
| import reactor.core.publisher.Mono; | ||
|
|
||
| /** | ||
| * Repository for the {@link ScaleSiteContactEntity}. | ||
| * | ||
| * <p>Provides methods to query the SCALE_SITE_CONTACT table, which is used by other | ||
| * systems (EMS, GAS2, LEXIS, SCS) to reference client contacts.</p> | ||
| */ | ||
| @Repository | ||
| public interface ScaleSiteContactRepository | ||
| extends ReactiveCrudRepository<ScaleSiteContactEntity, Long> { | ||
|
|
||
| /** | ||
| * Checks whether a record exists in SCALE_SITE_CONTACT for the given client contact id. | ||
| * | ||
| * @param clientContactId the client contact id to check | ||
| * @return a {@link Mono} emitting {@code true} if a matching record exists, {@code false} | ||
| * otherwise | ||
| */ | ||
| Mono<Boolean> existsByClientContactId(Long clientContactId); | ||
|
|
||
| } |
This file contains hidden or 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 hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.