Skip to content

Commit

Permalink
Merge branch 'main' into fix/FSADT1-1189
Browse files Browse the repository at this point in the history
  • Loading branch information
paulushcgcj authored Feb 7, 2024
2 parents c81831d + c507263 commit 2ade6de
Show file tree
Hide file tree
Showing 27 changed files with 680 additions and 204 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/merge-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,25 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Deploy Database Backup
uses: bcgov-nr/[email protected]
with:
file: database/openshift.backup.yml
oc_namespace: ${{ secrets.OC_NAMESPACE }}
oc_server: ${{ secrets.OC_SERVER }}
oc_token: ${{ secrets.OC_TOKEN }}
overwrite: true
parameters:
-p ZONE=${{ github.event.number }} -p NAME=${{ github.event.repository.name }}
-p PROMOTE=${{ github.repository }}/database:${{ github.event.number }}

- name: Backup database before update
run: |
oc login --token=${{ secrets.OC_TOKEN }} --server=${{ secrets.OC_SERVER }}
oc project ${{ secrets.OC_NAMESPACE }}
# Run a backup before deploying a new version
oc create job --from=cronjob/${{ github.event.repository.name }}-${{ github.event.number }}-database-backup ${{ github.event.repository.name }}-${{ github.event.number }}-database-backup-$(date +%Y%m%d%H%M%S)
- name: Deploy Database
uses: bcgov-nr/[email protected]
with:
Expand Down Expand Up @@ -381,6 +400,25 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Deploy Database Backup
uses: bcgov-nr/[email protected]
with:
file: database/openshift.backup.yml
oc_namespace: ${{ secrets.OC_NAMESPACE }}
oc_server: ${{ secrets.OC_SERVER }}
oc_token: ${{ secrets.OC_TOKEN }}
overwrite: true
parameters:
-p ZONE=${{ github.event.number }} -p NAME=${{ github.event.repository.name }}
-p PROMOTE=${{ github.repository }}/database:${{ github.event.number }}

- name: Backup database before update
run: |
oc login --token=${{ secrets.OC_TOKEN }} --server=${{ secrets.OC_SERVER }}
oc project ${{ secrets.OC_NAMESPACE }}
# Run a backup before deploying a new version
oc create job --from=cronjob/${{ github.event.repository.name }}-${{ github.event.number }}-database-backup ${{ github.event.repository.name }}-${{ github.event.number }}-database-backup-$(date +%Y%m%d%H%M%S)
- name: Deploy Database
uses: bcgov-nr/[email protected]
with:
Expand Down
25 changes: 22 additions & 3 deletions .github/workflows/pr-open.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ concurrency:
jobs:
pr-validation:
name: Pull Request Validation
runs-on: ubuntu-latest
runs-on: ubuntu-latest
outputs:
version: ${{ steps.changelog.outputs.version }}
url_zone: ${{ steps.calculate.outputs.url_zone }}
Expand Down Expand Up @@ -62,7 +62,7 @@ jobs:
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}

- name: Comment PR
continue-on-error: true
uses: thollander/actions-comment-pull-request@v2
Expand Down Expand Up @@ -183,6 +183,25 @@ jobs:
-p COGNITO_LOGOUT_URI='https://logontest7.gov.bc.ca/clp-cgi/logoff.cgi?retnow=1&returl=https://dev.loginproxy.gov.bc.ca/auth/realms/standard/protocol/openid-connect/logout?redirect_uri=https://${{ env.PREFIX }}-frontend.${{ env.DOMAIN }}'
-p CHES_MAIL_COPY=${{ secrets.CHES_MAIL_COPY }}

- name: Deploy Database Backup
uses: bcgov-nr/[email protected]
with:
file: database/openshift.backup.yml
oc_namespace: ${{ secrets.OC_NAMESPACE }}
oc_server: ${{ secrets.OC_SERVER }}
oc_token: ${{ secrets.OC_TOKEN }}
overwrite: true
parameters:
-p ZONE=${{ github.event.number }} -p NAME=${{ github.event.repository.name }}
-p PROMOTE=${{ github.repository }}/database:${{ github.event.number }}

- name: Backup database before update
run: |
oc login --token=${{ secrets.OC_TOKEN }} --server=${{ secrets.OC_SERVER }}
oc project ${{ secrets.OC_NAMESPACE }}
# Run a backup before deploying a new version
oc create job --from=cronjob/${{ github.event.repository.name }}-${{ github.event.number }}-database-backup ${{ github.event.repository.name }}-${{ github.event.number }}-database-backup-$(date +%Y%m%d%H%M%S)
- name: Deploy Database
uses: bcgov-nr/[email protected]
with:
Expand Down Expand Up @@ -257,7 +276,7 @@ jobs:
-p PROMOTE=${{ github.repository }}/processor:${{ github.event.number }}
-p URL_ZONE=${{ needs.pr-validation.outputs.url_zone }}
-p BCREGISTRY_URI='https://bcregistry-prod.apigee.net'

cypress-run:
name: "User flow test"
runs-on: ubuntu-22.04
Expand Down
5 changes: 4 additions & 1 deletion backend/src/main/java/ca/bc/gov/app/ApplicationConstant.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,15 @@ public final class ApplicationConstant {
ctc.client_type_code as client_type,
ctc.description as client_type_desc,
sd.good_standing_ind as good_standing,
sd.birthdate
sd.birthdate,
dc.district_code as district,
dc.district_code || ' - ' || dc.description as district_desc
FROM nrfc.submission s
left join nrfc.submission_status_code ssc on ssc.submission_status_code = s.submission_status_code\s
left join nrfc.submission_type_code stc on stc.submission_type_code = s.submission_type_code
left join nrfc.submission_detail sd on sd.submission_id = s.submission_id\s
left join nrfc.business_type_code btc on btc.business_type_code = sd.business_type_code\s
left join nrfc.district_code dc on dc.district_code = sd.district_code\s
left join nrfc.client_type_code ctc on ctc.client_type_code = sd.client_type_code\s
where s.submission_id = :submissionId""";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import ca.bc.gov.app.dto.bcregistry.ClientDetailsDto;
import ca.bc.gov.app.dto.client.ClientLookUpDto;
import ca.bc.gov.app.dto.client.CodeNameDto;
import ca.bc.gov.app.dto.client.DistrictDto;
import ca.bc.gov.app.dto.client.EmailRequestDto;
import ca.bc.gov.app.exception.NoClientDataFound;
import ca.bc.gov.app.service.client.ClientService;
Expand Down Expand Up @@ -45,6 +46,22 @@ public Mono<ClientDetailsDto> getClientDetails(
log.info("Requesting client details for client number {} from the client service.", clientNumber);
return clientService.getClientDetails(clientNumber,userId,businessId);
}

@GetMapping("/activeDistrictCodes")
public Flux<CodeNameDto> getActiveDistrictCodes(
@RequestParam(value = "page", required = false, defaultValue = "0")
Integer page,
@RequestParam(value = "size", required = false, defaultValue = "10")
Integer size) {
log.info("Requesting a list of districts from the client service.");
return clientService.getActiveDistrictCodes(page, size);
}

@GetMapping("/activeDistrictCodes/{districtCode}")
public Mono<DistrictDto> getDistrictByCode(@PathVariable String districtCode) {
log.info("Requesting a district by code {} from the client service.", districtCode);
return clientService.getDistrictByCode(districtCode);
}

@GetMapping("/activeCountryCodes")
public Flux<CodeNameDto> listCountries(
Expand All @@ -53,8 +70,7 @@ public Flux<CodeNameDto> listCountries(
@RequestParam(value = "size", required = false, defaultValue = "10")
Integer size) {
log.info("Requesting a list of countries from the client service.");
return clientService
.listCountries(page, size);
return clientService.listCountries(page, size);
}

@GetMapping("/getCountryByCode/{countryCode}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,16 @@ public Flux<ClientListSubmissionDto> listSubmissions(
@RequestParam(required = false)
String[] clientType,
@RequestParam(required = false)
String[] district,
@RequestParam(required = false)
String[] name,
@RequestParam(required = false)
String[] updatedAt,
ServerHttpResponse serverResponse
) {
log.info(
"Listing submissions: page={}, size={}, requestType={}, requestStatus={}, clientType={}, name={}, updatedAt={}",
page, size, requestType, requestStatus, clientType, name, updatedAt);
page, size, requestType, requestStatus, clientType, district, name, updatedAt);

return clientService
.listSubmissions(
Expand All @@ -77,6 +79,7 @@ public Flux<ClientListSubmissionDto> listSubmissions(
requestType,
requestStatus,
clientType,
district,
name,
updatedAt
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ public record ClientBusinessInformationDto(
String businessName,
String businessType,
String clientType,
String goodStandingInd,
String goodStandingInd,
String legalType,
LocalDate birthdate) {
LocalDate birthdate,
String district) {
/**
* Returns a map containing the description of the client's business information.
*
Expand All @@ -21,13 +22,13 @@ public record ClientBusinessInformationDto(
public Map<String, Object> description() {
return Map.of(
"incorporation", StringUtils.isBlank(incorporationNumber) ? "" : incorporationNumber,
"name", StringUtils.isBlank(businessName) ? "" : businessName,
"businessType", StringUtils.isBlank(businessType) ? "" : businessType,
"clientType", StringUtils.isBlank(clientType) ? "" : clientType,
"goodStanding", StringUtils.isBlank(goodStandingInd) ? "" : goodStandingInd,
"legalType", StringUtils.isBlank(legalType) ? "" : legalType,
"birthdate", Optional.ofNullable(birthdate).isPresent()
? birthdate : LocalDate.of(1975, 1, 31)
);
"name", StringUtils.isBlank(businessName) ? "" : businessName,
"businessType", StringUtils.isBlank(businessType) ? "" : businessType,
"clientType", StringUtils.isBlank(clientType) ? "" : clientType,
"goodStanding", StringUtils.isBlank(goodStandingInd) ? "" : goodStandingInd,
"legalType", StringUtils.isBlank(legalType) ? "" : legalType,
"birthdate", Optional.ofNullable(birthdate).isPresent() ? birthdate : LocalDate.of(1975, 1, 31),
"district", StringUtils.isBlank(district) ? "" : district
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ public record ClientListSubmissionDto(
String requestType,
String name,
String clientType,
String district,
String updated,
String user,
String status,
Expand Down
10 changes: 10 additions & 0 deletions backend/src/main/java/ca/bc/gov/app/dto/client/DistrictDto.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package ca.bc.gov.app.dto.client;


public record DistrictDto(
String code,
String description,
String emails
) {

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ public record SubmissionBusinessDto(
String clientType,
String clientTypeDesc,
String goodStandingInd,
LocalDate birthdate
LocalDate birthdate,
String district,
String districtDesc
) {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package ca.bc.gov.app.entity.client;

import ca.bc.gov.app.ApplicationConstant;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;
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;

@Table(name = "district_code", schema = ApplicationConstant.POSTGRES_ATTRIBUTE_SCHEMA)
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
@With
public class DistrictCodeEntity extends ExpirableBaseEntity {

@Id
@Column("district_code")
@NotNull
@Size(min = 2, max = 5)
private String code;

@Column("email_address")
@NotNull
private String emailAddress;

}
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,7 @@ public class SubmissionDetailEntity {
@Column("birthdate")
private LocalDate birthdate;

@Column("district_code")
private String districtCode;

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@
public interface CountryCodeRepository extends ReactiveCrudRepository<CountryCodeEntity, String>,
ReactiveSortingRepository<CountryCodeEntity, String> {

Flux<CountryCodeEntity> findBy(Pageable pageable);
Flux<CountryCodeEntity> findAllBy(Pageable pageable);

Mono<CountryCodeEntity> findByCountryCode(String code);

Mono<CountryCodeEntity> findByDescription(String description);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package ca.bc.gov.app.repository.client;

import ca.bc.gov.app.entity.client.DistrictCodeEntity;
import org.springframework.data.domain.Pageable;
import org.springframework.data.repository.reactive.ReactiveCrudRepository;
import org.springframework.data.repository.reactive.ReactiveSortingRepository;
import org.springframework.stereotype.Repository;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

@Repository
public interface DistrictCodeRepository
extends ReactiveCrudRepository<DistrictCodeEntity, String>,
ReactiveSortingRepository<DistrictCodeEntity, String> {

Flux<DistrictCodeEntity> findAllBy(Pageable pageable);

Mono<DistrictCodeEntity> findByCode(String code);

}
Loading

0 comments on commit 2ade6de

Please sign in to comment.