From 09f5a415e2790cfcbcab4feb02616aa31069fc35 Mon Sep 17 00:00:00 2001 From: Paulo Gomes da Cruz Junior Date: Mon, 28 Oct 2024 05:16:14 -0700 Subject: [PATCH 01/10] chore(deps): code refactor Small code refactor to change some dependencies --- backend/pom.xml | 7 +------ .../AbstractTestContainerIntegrationTest.java | 2 +- .../extensions/CustomOracleContainer.java | 16 +--------------- 3 files changed, 3 insertions(+), 22 deletions(-) diff --git a/backend/pom.xml b/backend/pom.xml index 26a098a7..f8459cdb 100644 --- a/backend/pom.xml +++ b/backend/pom.xml @@ -176,7 +176,7 @@ org.testcontainers - oracle-xe + oracle-free test @@ -186,11 +186,6 @@ spring-boot-starter-test test - - com.h2database - h2 - test - org.springframework.security spring-security-test diff --git a/backend/src/test/java/ca/bc/gov/restapi/results/extensions/AbstractTestContainerIntegrationTest.java b/backend/src/test/java/ca/bc/gov/restapi/results/extensions/AbstractTestContainerIntegrationTest.java index b2a8e96b..969847e2 100644 --- a/backend/src/test/java/ca/bc/gov/restapi/results/extensions/AbstractTestContainerIntegrationTest.java +++ b/backend/src/test/java/ca/bc/gov/restapi/results/extensions/AbstractTestContainerIntegrationTest.java @@ -10,9 +10,9 @@ import org.springframework.test.context.DynamicPropertyRegistry; import org.springframework.test.context.DynamicPropertySource; import org.springframework.test.context.junit.jupiter.SpringExtension; -import org.testcontainers.containers.OracleContainer; import org.testcontainers.containers.PostgreSQLContainer; import org.testcontainers.junit.jupiter.Testcontainers; +import org.testcontainers.oracle.OracleContainer; /** * Abstract base class for integration tests using Testcontainers for PostgreSQL and Oracle diff --git a/backend/src/test/java/ca/bc/gov/restapi/results/extensions/CustomOracleContainer.java b/backend/src/test/java/ca/bc/gov/restapi/results/extensions/CustomOracleContainer.java index e23c832e..7905d33c 100644 --- a/backend/src/test/java/ca/bc/gov/restapi/results/extensions/CustomOracleContainer.java +++ b/backend/src/test/java/ca/bc/gov/restapi/results/extensions/CustomOracleContainer.java @@ -2,25 +2,15 @@ import java.time.Duration; import java.util.UUID; -import org.testcontainers.containers.OracleContainer; +import org.testcontainers.oracle.OracleContainer; import org.testcontainers.utility.DockerImageName; -/** - * CustomOracleContainer extends OracleContainer to provide a customized Oracle database container. - * This is because by default, the library expects the Oracle database to come from a different - * image. - */ public class CustomOracleContainer extends OracleContainer { - /** - * Constructs a CustomOracleContainer with predefined settings. Sets the Docker image, database - * name, username, and a random password. - */ public CustomOracleContainer() { super( DockerImageName .parse("gvenzl/oracle-free:23.5-slim-faststart") - .asCompatibleSubstituteFor("gvenzl/oracle-xe") ); this.withDatabaseName("legacyfsa") @@ -28,10 +18,6 @@ public CustomOracleContainer() { .withPassword(UUID.randomUUID().toString().substring(24)); } - /** - * Overrides the waitUntilContainerStarted method to set a custom startup timeout. The Oracle - * image tends to be slow, so we set a longer timeout. - */ @Override protected void waitUntilContainerStarted() { getWaitStrategy() From 5ceb7e6f1c3d94467aba570889b79023e030321a Mon Sep 17 00:00:00 2001 From: Paulo Gomes da Cruz Junior Date: Mon, 28 Oct 2024 05:40:02 -0700 Subject: [PATCH 02/10] chore(deps): removing swagger Swagger is not required for the backend api as the only consumer should be the frontend app --- backend/pom.xml | 12 +- .../results/common/config/SwaggerConfig.java | 70 ----- .../results/common/dto/ForestClientDto.java | 29 +-- .../endpoint/FeatureServiceEndpoint.java | 38 +-- .../common/endpoint/ForestClientEndpoint.java | 40 +-- .../endpoint/SecretsServiceEndpoint.java | 6 +- .../common/pagination/PaginatedResult.java | 11 - .../common/pagination/PaginatedViaQuery.java | 13 - .../pagination/PaginationParameters.java | 2 - .../oracle/dto/OpeningSearchResponseDto.java | 108 -------- .../results/oracle/dto/RecentOpeningDto.java | 49 +--- .../oracle/endpoint/OpeningEndpoint.java | 21 -- .../endpoint/OpeningSearchEndpoint.java | 240 +++--------------- .../dto/FreeGrowingMilestonesDto.java | 11 +- .../dto/MyRecentActionsRequestsDto.java | 23 +- .../postgres/dto/OpeningsPerYearDto.java | 16 +- .../endpoint/DashboardExtractionEndpoint.java | 62 +---- .../endpoint/DashboardMetricsEndpoint.java | 140 ++-------- .../endpoint/UserOpeningEndpoint.java | 75 +----- 19 files changed, 101 insertions(+), 865 deletions(-) delete mode 100644 backend/src/main/java/ca/bc/gov/restapi/results/common/config/SwaggerConfig.java diff --git a/backend/pom.xml b/backend/pom.xml index f8459cdb..9049a571 100644 --- a/backend/pom.xml +++ b/backend/pom.xml @@ -125,6 +125,11 @@ org.springframework.boot spring-boot-starter-web + + org.springframework.boot + spring-boot-starter-validation + + org.projectlombok lombok @@ -207,13 +212,6 @@ test - - - org.springdoc - springdoc-openapi-starter-webmvc-ui - 2.6.0 - - org.springframework.boot diff --git a/backend/src/main/java/ca/bc/gov/restapi/results/common/config/SwaggerConfig.java b/backend/src/main/java/ca/bc/gov/restapi/results/common/config/SwaggerConfig.java deleted file mode 100644 index 243d6a78..00000000 --- a/backend/src/main/java/ca/bc/gov/restapi/results/common/config/SwaggerConfig.java +++ /dev/null @@ -1,70 +0,0 @@ -package ca.bc.gov.restapi.results.common.config; - -import io.swagger.v3.oas.models.Components; -import io.swagger.v3.oas.models.ExternalDocumentation; -import io.swagger.v3.oas.models.OpenAPI; -import io.swagger.v3.oas.models.info.Contact; -import io.swagger.v3.oas.models.info.Info; -import io.swagger.v3.oas.models.info.License; -import io.swagger.v3.oas.models.security.SecurityRequirement; -import io.swagger.v3.oas.models.security.SecurityScheme; -import io.swagger.v3.oas.models.security.SecurityScheme.Type; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -/** This class contains base configuration for Swagger API documentation. */ -@Configuration -public class SwaggerConfig { - - private static final String DESCRIPTION = - "A REST service API to provide SILVA Application database and backend capabilities."; - private static final String TERMS_OF_SERVICE = - "https://www2.gov.bc.ca/gov/content/data/open-data/api-terms-of-use-for-ogl-information"; - private static final String LICENSE_URL = - "https://www2.gov.bc.ca/gov/content/data/open-data/open-government-licence-bc"; - - /** - * Creates an {@link OpenAPI} with all needed and related information. - * - * @return An {@link OpenAPI} instance - */ - @Bean - public OpenAPI theRestApi() { - Info info = new Info(); - info.setTitle("SILVA Back-end REST API"); - info.setDescription(DESCRIPTION); - info.setVersion("0.0.1"); - info.setTermsOfService(TERMS_OF_SERVICE); - - Contact contact = new Contact(); - contact.setName("Team Silva"); - contact.setEmail("team.silva@gov.bc.ca"); - contact.setUrl("https://github.com/bcgov/nr-silva"); - info.setContact(contact); - - License license = new License(); - license.setName("OGL-BC"); - license.setUrl(LICENSE_URL); - info.setLicense(license); - - ExternalDocumentation externalDoc = new ExternalDocumentation(); - externalDoc.setDescription("Swagger login How-To"); - externalDoc.setUrl("https://github.com/bcgov/nr-silva/wiki/Getting-a-Bearer-JWT-Token"); - - SecurityScheme securityScheme = new SecurityScheme(); - securityScheme.setType(Type.HTTP); - securityScheme.setScheme("bearer"); - securityScheme.setBearerFormat("JWT"); - - Components components = new Components(); - components.addSecuritySchemes("bearerAuth", securityScheme); - - OpenAPI openApi = new OpenAPI(); - openApi.setInfo(info); - openApi.setExternalDocs(externalDoc); - openApi.addSecurityItem(new SecurityRequirement().addList("bearerAuth")); - openApi.setComponents(components); - - return openApi; - } -} diff --git a/backend/src/main/java/ca/bc/gov/restapi/results/common/dto/ForestClientDto.java b/backend/src/main/java/ca/bc/gov/restapi/results/common/dto/ForestClientDto.java index c088433a..74531628 100644 --- a/backend/src/main/java/ca/bc/gov/restapi/results/common/dto/ForestClientDto.java +++ b/backend/src/main/java/ca/bc/gov/restapi/results/common/dto/ForestClientDto.java @@ -2,47 +2,22 @@ import ca.bc.gov.restapi.results.common.enums.ForestClientStatusEnum; import ca.bc.gov.restapi.results.common.enums.ForestClientTypeEnum; -import io.swagger.v3.oas.annotations.media.Schema; import lombok.Builder; import lombok.With; /** * This record represents a Forest Client object. */ -@Schema(description = "One of the many agencies that work with the ministry.") @Builder @With public record ForestClientDto( - @Schema(description = "An eight-digit number that identifies the client.", example = "00149081") String clientNumber, - @Schema( - description = - "The client last name if it's an individual or the company name if it's a company.", - example = "WESTERN FOREST PRODUCTS INC.") String clientName, - @Schema( - description = "The first name of the individual, or null if it's a company.", - example = "Maria") String legalFirstName, - @Schema( - description = "The middle name of the individual, or null if it's a company", - example = "Bricks") String legalMiddleName, - @Schema( - description = - "A code indicating the status of ministry client. Examples include but are not" - + " limited to: Active, Deactivated, Deceased...", - example = "ACT") ForestClientStatusEnum clientStatusCode, - @Schema( - description = - "A code indicating a type of ministry client. Examples include but are not limited" - + " to: Corporation, Individual, Association, First Nation..", - example = "C") ForestClientTypeEnum clientTypeCode, - @Schema( - description = "An acronym for this client; works as an alternative identifier.", - example = "WFP") - String acronym) { + String acronym +) { } diff --git a/backend/src/main/java/ca/bc/gov/restapi/results/common/endpoint/FeatureServiceEndpoint.java b/backend/src/main/java/ca/bc/gov/restapi/results/common/endpoint/FeatureServiceEndpoint.java index 514fbd10..8ff8e91d 100644 --- a/backend/src/main/java/ca/bc/gov/restapi/results/common/endpoint/FeatureServiceEndpoint.java +++ b/backend/src/main/java/ca/bc/gov/restapi/results/common/endpoint/FeatureServiceEndpoint.java @@ -1,26 +1,18 @@ package ca.bc.gov.restapi.results.common.endpoint; import ca.bc.gov.restapi.results.common.service.RestService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.enums.ParameterIn; -import io.swagger.v3.oas.annotations.media.Content; -import io.swagger.v3.oas.annotations.media.Schema; -import io.swagger.v3.oas.annotations.responses.ApiResponse; -import io.swagger.v3.oas.annotations.tags.Tag; import lombok.AllArgsConstructor; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -/** This class holds resources for calling WFS. */ +/** + * This class holds resources for calling WFS. + */ @RestController @RequestMapping("/api/feature-service") @AllArgsConstructor -@Tag( - name = "Feature Service to call WFS (Common)", - description = "Endpoints for handle WFS (Web Feature Service) within BC Geo Warehouse") public class FeatureServiceEndpoint { private final RestService restService; @@ -32,29 +24,9 @@ public class FeatureServiceEndpoint { * @return JSON object with response from WFS request */ @GetMapping("/polygon-and-props/{openingId}") - @Operation( - summary = "Fetch Opening data from WFS", - description = - "Fetch Opening data (polygon raster data and properties) from WFS. These are the props " - + "being fetched: OPENING_ID, GEOMETRY, REGION_NAME, REGION_CODE, DISTRICT_NAME, " - + "DISTRICT_CODE, CLIENT_NAME, CLIENT_NUMBER, and OPENING_WHEN_CREATED", - responses = { - @ApiResponse( - responseCode = "200", - description = "An object with the response from WFS request."), - @ApiResponse( - responseCode = "401", - description = "Access token is missing or invalid", - content = @Content(schema = @Schema(implementation = Void.class))) - }) public Object getOpeningPolygonAndProperties( - @Parameter( - name = "openingId", - in = ParameterIn.PATH, - description = "The opening Id.", - required = true) - @PathVariable - String openingId) { + @PathVariable + String openingId) { return restService.getOpeningPolygonAndProperties(openingId); } } diff --git a/backend/src/main/java/ca/bc/gov/restapi/results/common/endpoint/ForestClientEndpoint.java b/backend/src/main/java/ca/bc/gov/restapi/results/common/endpoint/ForestClientEndpoint.java index d15a665e..c46deefd 100644 --- a/backend/src/main/java/ca/bc/gov/restapi/results/common/endpoint/ForestClientEndpoint.java +++ b/backend/src/main/java/ca/bc/gov/restapi/results/common/endpoint/ForestClientEndpoint.java @@ -3,26 +3,17 @@ import ca.bc.gov.restapi.results.common.dto.ForestClientDto; import ca.bc.gov.restapi.results.common.exception.ForestClientNotFoundException; import ca.bc.gov.restapi.results.common.service.ForestClientService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.enums.ParameterIn; -import io.swagger.v3.oas.annotations.media.Content; -import io.swagger.v3.oas.annotations.media.Schema; -import io.swagger.v3.oas.annotations.responses.ApiResponse; -import io.swagger.v3.oas.annotations.tags.Tag; import lombok.AllArgsConstructor; import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -/** This class holds resources for the Forest Client API interaction. */ +/** + * This class holds resources for the Forest Client API interaction. + */ @RestController @RequestMapping("/api/forest-clients") @AllArgsConstructor -@Tag( - name = "Forest Client (Common)", - description = "Endpoints for fetching client information from Forest Client API") public class ForestClientEndpoint { private final ForestClientService forestClientService; @@ -35,30 +26,7 @@ public class ForestClientEndpoint { * @throws ForestClientNotFoundException when client not found */ @GetMapping("/{clientNumber}") - @Operation( - summary = "Fetch a forest client given its number.", - description = - "Fetch a forest client directly from the ForestClient API given the client number.", - responses = { - @ApiResponse( - responseCode = "200", - description = "An object with all client properties provided by the ForestClient API."), - @ApiResponse( - responseCode = "400", - description = "Something wrong with the client number, make sure you're sending it."), - @ApiResponse( - responseCode = "401", - description = "Access token is missing or invalid", - content = @Content(schema = @Schema(implementation = Void.class))) - }) - public ForestClientDto getForestClient( - @Parameter( - name = "clientNumber", - in = ParameterIn.PATH, - description = "The client number to be fetched.", - required = true) - @PathVariable - String clientNumber) { + public ForestClientDto getForestClient(String clientNumber) { return forestClientService .getClientByNumber(clientNumber) .orElseThrow(ForestClientNotFoundException::new); diff --git a/backend/src/main/java/ca/bc/gov/restapi/results/common/endpoint/SecretsServiceEndpoint.java b/backend/src/main/java/ca/bc/gov/restapi/results/common/endpoint/SecretsServiceEndpoint.java index 65346d88..9cf98a00 100644 --- a/backend/src/main/java/ca/bc/gov/restapi/results/common/endpoint/SecretsServiceEndpoint.java +++ b/backend/src/main/java/ca/bc/gov/restapi/results/common/endpoint/SecretsServiceEndpoint.java @@ -1,7 +1,6 @@ package ca.bc.gov.restapi.results.common.endpoint; import ca.bc.gov.restapi.results.common.dto.WmsLayersWhitelistUserDto; -import io.swagger.v3.oas.annotations.Hidden; import java.util.List; import java.util.stream.Stream; import org.springframework.beans.factory.annotation.Value; @@ -9,10 +8,11 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -/** This class holds resources for getting secrets from the backend. */ +/** + * This class holds resources for getting secrets from the backend. + */ @RestController @RequestMapping("/api/secrets") -@Hidden public class SecretsServiceEndpoint { @Value("${nr.results.config.wms-layers.whitelist}") diff --git a/backend/src/main/java/ca/bc/gov/restapi/results/common/pagination/PaginatedResult.java b/backend/src/main/java/ca/bc/gov/restapi/results/common/pagination/PaginatedResult.java index 985d6885..83a156e4 100644 --- a/backend/src/main/java/ca/bc/gov/restapi/results/common/pagination/PaginatedResult.java +++ b/backend/src/main/java/ca/bc/gov/restapi/results/common/pagination/PaginatedResult.java @@ -1,6 +1,5 @@ package ca.bc.gov.restapi.results.common.pagination; -import io.swagger.v3.oas.annotations.media.Schema; import java.util.List; import lombok.Getter; import lombok.Setter; @@ -8,21 +7,11 @@ /** Holds an API response with pagination information and data. */ @Getter @Setter -@Schema(description = "Holds an API response with pagination information and data.") public class PaginatedResult { - @Schema(description = "Current page index, zero-based.", example = "2") private int pageIndex; - - @Schema(description = "The amount of records per page.", example = "15") private int perPage; - - @Schema(description = "The amount of pages", example = "3") private int totalPages; - - @Schema(description = "Defines if there's more records to fetch", example = "false") private boolean hasNextPage; - - @Schema(description = "List of records, or empty list if no records.") private List data; } diff --git a/backend/src/main/java/ca/bc/gov/restapi/results/common/pagination/PaginatedViaQuery.java b/backend/src/main/java/ca/bc/gov/restapi/results/common/pagination/PaginatedViaQuery.java index dbc47937..492c44ff 100644 --- a/backend/src/main/java/ca/bc/gov/restapi/results/common/pagination/PaginatedViaQuery.java +++ b/backend/src/main/java/ca/bc/gov/restapi/results/common/pagination/PaginatedViaQuery.java @@ -1,8 +1,5 @@ package ca.bc.gov.restapi.results.common.pagination; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.enums.ParameterIn; -import io.swagger.v3.oas.annotations.media.Schema; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -13,16 +10,6 @@ */ @Target({ElementType.METHOD}) @Retention(RetentionPolicy.RUNTIME) -@Parameter( - in = ParameterIn.QUERY, - description = "Zero-based page index indicating the page to be returned.", - name = "page", - schema = @Schema(type = "integer", defaultValue = "0", minimum = "0")) -@Parameter( - in = ParameterIn.QUERY, - description = "The maximum number of results in a page.", - name = "perPage", - schema = @Schema(type = "integer", defaultValue = "5", minimum = "1")) public @interface PaginatedViaQuery { } diff --git a/backend/src/main/java/ca/bc/gov/restapi/results/common/pagination/PaginationParameters.java b/backend/src/main/java/ca/bc/gov/restapi/results/common/pagination/PaginationParameters.java index bd233ef1..c8711001 100644 --- a/backend/src/main/java/ca/bc/gov/restapi/results/common/pagination/PaginationParameters.java +++ b/backend/src/main/java/ca/bc/gov/restapi/results/common/pagination/PaginationParameters.java @@ -1,6 +1,5 @@ package ca.bc.gov.restapi.results.common.pagination; -import io.swagger.v3.oas.annotations.Hidden; import jakarta.validation.constraints.Positive; import jakarta.validation.constraints.PositiveOrZero; @@ -10,7 +9,6 @@ * @param page The page to be returned. Zero-based, and must be non-negative; defaults to 0 * @param perPage The maximum number of results in each page. Defaults to 20 */ -@Hidden public record PaginationParameters(@PositiveOrZero Integer page, @Positive Integer perPage) { /** diff --git a/backend/src/main/java/ca/bc/gov/restapi/results/oracle/dto/OpeningSearchResponseDto.java b/backend/src/main/java/ca/bc/gov/restapi/results/oracle/dto/OpeningSearchResponseDto.java index 63508fe5..b658b5da 100644 --- a/backend/src/main/java/ca/bc/gov/restapi/results/oracle/dto/OpeningSearchResponseDto.java +++ b/backend/src/main/java/ca/bc/gov/restapi/results/oracle/dto/OpeningSearchResponseDto.java @@ -2,16 +2,12 @@ import ca.bc.gov.restapi.results.oracle.enums.OpeningCategoryEnum; import ca.bc.gov.restapi.results.oracle.enums.OpeningStatusEnum; -import io.swagger.v3.oas.annotations.media.Schema; import java.math.BigDecimal; import java.time.LocalDateTime; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; -import lombok.Getter; import lombok.NoArgsConstructor; -import lombok.Setter; -import lombok.ToString; import lombok.With; /** @@ -24,131 +20,27 @@ @AllArgsConstructor public class OpeningSearchResponseDto { - @Schema( - description = "System generated value uniquely identifying the opening.", - example = "114207") private Integer openingId; - - @Schema( - description = - """ - An unique identifier up to four characters long that describes the opening on a - specified mapsheet.""", - example = "1234") private String openingNumber; - - @Schema( - description = - """ - A code used to describe the category for the opening. The opening categories - reference the governing applicable legislation and are determined by responsibility, - opening origin, tenure type and prescription type. - """, - example = "FTML") private OpeningCategoryEnum category; - - @Schema( - description = - """ - A code indicating the status of the prescription. Examples include but are not - limited to DFT (draft) and APP (approved). A subset of the STATUS_CODE table. - """, - example = "APP") private OpeningStatusEnum status; - - @Schema( - description = - "Identifier for a cutting permit associated with a quota type harvesting tenure.", - example = "12T") private String cuttingPermitId; - - @Schema( - description = - """ - Unique identifying set of characters to be stamped or marked on the end of each log - to associate the log with the specific authority to harvest and move timber. - """, - example = "47/12S") private String timberMark; - - @Schema( - description = - """ - Identifier for a cut block of a harvesting tenure (within a cutting permit for - tenures with cp's). - """, - example = "12-69") private String cutBlockId; - - @Schema(description = "Gross area of the opening, in hectares.", example = "12.9") private BigDecimal openingGrossAreaHa; - - @Schema(description = "Actual date that harvesting started on the cut block.") private LocalDateTime disturbanceStartDate; - - @Schema( - description = - """ - Identifies any office within the ministry. First character identifiesExec, - HQ Branch, Region, or District; next two chars identify the office name; next two - the section (HQ Branch) or program (Region or District); last char identifies the - subsection.""", - example = "DPG") private String orgUnitCode; - - @Schema( - description = - """ - The name or title of a ministry office or section; for example Kamloops Forest - Region; Silviculture Branch; Kispiox Forest District Protection program. - """, - example = "Prince George Natural District") private String orgUnitName; - - @Schema( - description = "Sequentially assigned number to identify a ministry client.", - example = "00012797") private String clientNumber; - - @Schema( - description = "Sequentially assigned number to identify a ministry client location.", - example = "01") private String clientLocation; - - @Schema( - description = - """ - A familiar alphabetic acronym to be used as an alternative to the Ministry's Client - Number for data entry and display. - """, - example = "MOF") private String clientAcronym; - private String clientName; - - @Schema(description = "The final date based on the EARLY and LATE offset years.") private LocalDateTime regenDelayDate; - - @Schema(description = "The final date based on the EARLY offset years.") private LocalDateTime earlyFreeGrowingDate; - - @Schema(description = "The final date based on the LATE offset years.") private LocalDateTime lateFreeGrowingDate; - - @Schema(description = "The date and time of the last update.") private LocalDateTime updateTimestamp; - - @Schema(description = "The USERID of the individual who entered the information.") private String entryUserId; - - @Schema(description = "Describes if the opening got submitted to FRPA section 108") private Boolean submittedToFrpa; - - @Schema(description = "Uniquely identifies the attached file.", example = "407") private String forestFileId; - - @Schema( - description = "Uniquely identifies an Application for Relief from obligations.", - example = "56") private Long silvaReliefAppId; } diff --git a/backend/src/main/java/ca/bc/gov/restapi/results/oracle/dto/RecentOpeningDto.java b/backend/src/main/java/ca/bc/gov/restapi/results/oracle/dto/RecentOpeningDto.java index ac222221..7ce691a7 100644 --- a/backend/src/main/java/ca/bc/gov/restapi/results/oracle/dto/RecentOpeningDto.java +++ b/backend/src/main/java/ca/bc/gov/restapi/results/oracle/dto/RecentOpeningDto.java @@ -2,7 +2,6 @@ import ca.bc.gov.restapi.results.oracle.enums.OpeningCategoryEnum; import ca.bc.gov.restapi.results.oracle.enums.OpeningStatusEnum; -import io.swagger.v3.oas.annotations.media.Schema; import java.math.BigDecimal; import java.time.LocalDate; import java.time.LocalDateTime; @@ -10,63 +9,21 @@ import lombok.With; /** - * Represents an Recent Opening in the Home screen. + * Represents a Recent Opening in the Home screen. */ -@Schema(description = "Represents an Recent Opening in the Home screen.") @Builder @With public record RecentOpeningDto( - @Schema( - description = "System generated value uniquely identifying the opening.", - example = "114207") Long openingId, - @Schema( - description = """ - File identification assigned to Provincial Forest Use files. Assigned file number. - Usually the Licence, Tenure or Private Mark number. - """, - example = "TFL47") String fileId, - @Schema( - description = - "Identifier for a cutting permit associated with a quota type harvesting tenure.", - example = "12T") String cuttingPermit, - @Schema( - description = """ - Unique identifying set of characters to be stamped or marked on the end of each log - to associate the log with the specific authority to harvest and move timber. - """, - example = "47/12S") String timberMark, - @Schema( - description = """ - Identifier for a cut block of a harvesting tenure (within a cutting permit for - tenures with cp's). - """, - example = "12-69") String cutBlock, - @Schema(description = "Gross area of the opening, in hectares.", example = "12.9") BigDecimal grossAreaHa, - @Schema( - description = """ - A code indicating the status of the prescription. Examples include but are not - limited to DFT (draft) and APP (approved). A subset of the STATUS_CODE table. - """, - example = "APP") OpeningStatusEnum status, - @Schema( - description = """ - A code used to describe the category for the opening. The opening categories - reference the governing applicable legislation and are determined by responsibility, - opening origin, tenure type and prescription type. - """, - example = "FTML") OpeningCategoryEnum category, - @Schema(description = "Actual date that harvesting started on the cut block.") LocalDate disturbanceStart, - @Schema(description = "The date and time the information was entered.") LocalDateTime entryTimestamp, - @Schema(description = "The date and time of the last update.") LocalDateTime updateTimestamp) { - + LocalDateTime updateTimestamp +) { } diff --git a/backend/src/main/java/ca/bc/gov/restapi/results/oracle/endpoint/OpeningEndpoint.java b/backend/src/main/java/ca/bc/gov/restapi/results/oracle/endpoint/OpeningEndpoint.java index e21c1660..ed8e804f 100644 --- a/backend/src/main/java/ca/bc/gov/restapi/results/oracle/endpoint/OpeningEndpoint.java +++ b/backend/src/main/java/ca/bc/gov/restapi/results/oracle/endpoint/OpeningEndpoint.java @@ -5,11 +5,6 @@ import ca.bc.gov.restapi.results.common.pagination.PaginationParameters; import ca.bc.gov.restapi.results.oracle.dto.RecentOpeningDto; import ca.bc.gov.restapi.results.oracle.service.OpeningService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.media.Content; -import io.swagger.v3.oas.annotations.media.Schema; -import io.swagger.v3.oas.annotations.responses.ApiResponse; -import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; import org.springframework.http.HttpHeaders; @@ -24,9 +19,6 @@ @RestController @RequestMapping(path = "/api/openings", produces = MediaType.APPLICATION_JSON_VALUE) @RequiredArgsConstructor -@Tag( - name = "Openings (Oracle)", - description = "Endpoints to handle Openings on Oracle on `THE` schema.") public class OpeningEndpoint { private final OpeningService openingService; @@ -38,19 +30,6 @@ public class OpeningEndpoint { * @return List of {@link RecentOpeningDto} or empty list. */ @GetMapping(path = "/recent-openings", produces = MediaType.APPLICATION_JSON_VALUE) - @Operation( - summary = "Fetches all recent openings for the home screen.", - description = - "List all recent openings using a paginated search with a page size 5 by default.", - responses = { - @ApiResponse( - responseCode = "200", - description = "An array with all recent openings, ordered by the most recent ones."), - @ApiResponse( - responseCode = "401", - description = "Access token is missing or invalid", - content = @Content(schema = @Schema(implementation = Void.class))) - }) @PaginatedViaQuery @CrossOrigin(exposedHeaders = "x-opening-source") public ResponseEntity> getRecentOpenings( diff --git a/backend/src/main/java/ca/bc/gov/restapi/results/oracle/endpoint/OpeningSearchEndpoint.java b/backend/src/main/java/ca/bc/gov/restapi/results/oracle/endpoint/OpeningSearchEndpoint.java index 0a12031a..536413d5 100644 --- a/backend/src/main/java/ca/bc/gov/restapi/results/oracle/endpoint/OpeningSearchEndpoint.java +++ b/backend/src/main/java/ca/bc/gov/restapi/results/oracle/endpoint/OpeningSearchEndpoint.java @@ -10,13 +10,6 @@ import ca.bc.gov.restapi.results.oracle.service.OpenCategoryCodeService; import ca.bc.gov.restapi.results.oracle.service.OpeningService; import ca.bc.gov.restapi.results.oracle.service.OrgUnitService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.enums.ParameterIn; -import io.swagger.v3.oas.annotations.media.Content; -import io.swagger.v3.oas.annotations.media.Schema; -import io.swagger.v3.oas.annotations.responses.ApiResponse; -import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.validation.Valid; import java.util.List; import lombok.RequiredArgsConstructor; @@ -25,13 +18,12 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; -/** This class contains resources for the opening search api. */ +/** + * This class contains resources for the opening search api. + */ @RestController @RequestMapping("/api/opening-search") @RequiredArgsConstructor -@Tag( - name = "Search Openings (THE)", - description = "Endpoints to handle the Opening Search feature in the `THE` schema.") public class OpeningSearchEndpoint { private final OpeningService openingService; @@ -43,171 +35,64 @@ public class OpeningSearchEndpoint { /** * Search for Openings with different filters. * - * @param mainSearchTerm Number representing one of Opening ID | Opening Number | Timber Mark ID | - * File - * @param orgUnit Org Unit code filter, same as District. - * @param category Opening category code filter. - * @param statusList Opening statuses codes filter. - * @param myOpenings Openings created by the request user - * @param submittedToFrpa Submitted to FRPA + * @param mainSearchTerm Number representing one of Opening ID | Opening Number | Timber + * Mark ID | File + * @param orgUnit Org Unit code filter, same as District. + * @param category Opening category code filter. + * @param statusList Opening statuses codes filter. + * @param myOpenings Openings created by the request user + * @param submittedToFrpa Submitted to FRPA * @param disturbanceDateStart Disturbance start date filter - * @param disturbanceDateEnd Disturbance end date filter - * @param regenDelayDateStart Regen start date filter - * @param regenDelayDateEnd Regen end date filter + * @param disturbanceDateEnd Disturbance end date filter + * @param regenDelayDateStart Regen start date filter + * @param regenDelayDateEnd Regen end date filter * @param freeGrowingDateStart Free growing start date filter - * @param freeGrowingDateEnd Free growing end date filter - * @param updateDateStart Opening update start date filter - * @param updateDateEnd Opening update end date filter - * @param cuttingPermitId The cutting permit identification filter - * @param cutBlockId Cute block identification filter - * @param timberMark Timber mark filter + * @param freeGrowingDateEnd Free growing end date filter + * @param updateDateStart Opening update start date filter + * @param updateDateEnd Opening update end date filter + * @param cuttingPermitId The cutting permit identification filter + * @param cutBlockId Cute block identification filter + * @param timberMark Timber mark filter * @param paginationParameters Pagination settings * @return PaginatedResult with found records. */ @GetMapping - @Operation( - summary = "Search for Openings", - description = "Opening search feature with filters and pagination.", - responses = { - @ApiResponse( - responseCode = "200", - description = "An array with found objects, or an empty array.", - content = @Content(mediaType = "application/json")), - @ApiResponse( - responseCode = "401", - description = "Access token is missing or invalid", - content = @Content(schema = @Schema(implementation = Void.class))) - }) @PaginatedViaQuery public PaginatedResult openingSearch( @RequestParam(value = "mainSearchTerm", required = false) - @Parameter( - name = "mainSearchTerm", - in = ParameterIn.QUERY, - description = - "Search term representing one of Opening ID | Opening Number | Timber Mark ID |" - + " Forest File ID. Eg: Opening ID 1022833, Opening Number 1012, Timber Mark" - + " EM2184, Forest File ID TFL47", - required = false) - String mainSearchTerm, + String mainSearchTerm, @RequestParam(value = "orgUnit", required = false) - @Parameter( - name = "orgUnit", - in = ParameterIn.QUERY, - description = "Org Unit code filter, same as District. E.g.: DCR, FTL47", - required = false) - String orgUnit, + String orgUnit, @RequestParam(value = "category", required = false) - @Parameter( - name = "category", - in = ParameterIn.QUERY, - description = "Opening category code filter. E.g.: FTML", - required = false) - String category, + String category, @RequestParam(value = "statusList", required = false) - @Parameter( - name = "statusList", - in = ParameterIn.QUERY, - description = "Opening status code filter. E.g.: APP", - required = false) - List statusList, + List statusList, @RequestParam(value = "myOpenings", required = false) - @Parameter( - name = "myOpenings", - in = ParameterIn.QUERY, - description = "Openings created by the request user", - required = false) - Boolean myOpenings, + Boolean myOpenings, @RequestParam(value = "submittedToFrpa", required = false) - @Parameter( - name = "submittedToFrpa", - in = ParameterIn.QUERY, - description = "Submitted to FRPA Section 108, true or false.", - required = false) - Boolean submittedToFrpa, + Boolean submittedToFrpa, @RequestParam(value = "disturbanceDateStart", required = false) - @Parameter( - name = "disturbanceDateStart", - in = ParameterIn.QUERY, - description = "Disturbance start date filter, format yyyy-MM-dd.", - required = false) - String disturbanceDateStart, + String disturbanceDateStart, @RequestParam(value = "disturbanceDateEnd", required = false) - @Parameter( - name = "disturbanceDateEnd", - in = ParameterIn.QUERY, - description = "Disturbance end date filter, format yyyy-MM-dd.", - required = false) - String disturbanceDateEnd, + String disturbanceDateEnd, @RequestParam(value = "regenDelayDateStart", required = false) - @Parameter( - name = "regenDelayDateStart", - in = ParameterIn.QUERY, - description = "Regen delay start date filter, format yyyy-MM-dd.", - required = false) - String regenDelayDateStart, + String regenDelayDateStart, @RequestParam(value = "regenDelayDateEnd", required = false) - @Parameter( - name = "regenDelayDateEnd", - in = ParameterIn.QUERY, - description = "Regen delay end date filter, format yyyy-MM-dd.", - required = false) - String regenDelayDateEnd, + String regenDelayDateEnd, @RequestParam(value = "freeGrowingDateStart", required = false) - @Parameter( - name = "freeGrowingDateStart", - in = ParameterIn.QUERY, - description = "Free growing start date filter, format yyyy-MM-dd.", - required = false) - String freeGrowingDateStart, + String freeGrowingDateStart, @RequestParam(value = "freeGrowingDateEnd", required = false) - @Parameter( - name = "freeGrowingDateEnd", - in = ParameterIn.QUERY, - description = "Free growing end date filter, format yyyy-MM-dd.", - required = false) - String freeGrowingDateEnd, + String freeGrowingDateEnd, @RequestParam(value = "updateDateStart", required = false) - @Parameter( - name = "updateDateStart", - in = ParameterIn.QUERY, - description = "Opening update start date filter, format yyyy-MM-dd.", - required = false) - String updateDateStart, + String updateDateStart, @RequestParam(value = "updateDateEnd", required = false) - @Parameter( - name = "updateDateEnd", - in = ParameterIn.QUERY, - description = "Opening update end date filter, format yyyy-MM-dd.", - required = false) - String updateDateEnd, + String updateDateEnd, @RequestParam(value = "cuttingPermitId", required = false) - @Parameter( - name = "cuttingPermitId", - in = ParameterIn.QUERY, - description = - "Identifier for a cutting permit associated with a quota type harvesting tenure.", - required = false) - String cuttingPermitId, + String cuttingPermitId, @RequestParam(value = "cutBlockId", required = false) - @Parameter( - name = "cutBlockId", - in = ParameterIn.QUERY, - description = - "Identifier for a cut block of a harvesting tenure (within a cutting permit for" - + " tenures with cp's).", - required = false) - String cutBlockId, + String cutBlockId, @RequestParam(value = "timberMark", required = false) - @Parameter( - name = "timberMark", - in = ParameterIn.QUERY, - description = - "Unique identifying set of characters to be stamped or marked on the end of each" - + " log to associate the log with the specific authority to harvest and move" - + " timber.", - required = false) - String timberMark, + String timberMark, @Valid PaginationParameters paginationParameters) { OpeningSearchFiltersDto filtersDto = new OpeningSearchFiltersDto( @@ -238,27 +123,9 @@ public PaginatedResult openingSearch( * @return List of OpenCategoryCodeEntity with found categories. */ @GetMapping("/categories") - @Operation( - summary = "Get all opening categories", - description = "Get all opening categories. Optionally you can ask for the expired ones.", - responses = { - @ApiResponse( - responseCode = "200", - description = "An array with found objects, or an empty array.", - content = @Content(mediaType = "application/json")), - @ApiResponse( - responseCode = "401", - description = "Access token is missing or invalid", - content = @Content(schema = @Schema(implementation = Void.class))) - }) public List getOpeningCategories( @RequestParam(value = "includeExpired", required = false) - @Parameter( - name = "includeExpired", - in = ParameterIn.QUERY, - description = "Defines if the API should include expired categories", - required = false) - Boolean includeExpired) { + Boolean includeExpired) { boolean addExpired = Boolean.TRUE.equals(includeExpired); return openCategoryCodeService.findAllCategories(addExpired); } @@ -269,19 +136,6 @@ public List getOpeningCategories( * @return List of OrgUnitEntity with found org units. */ @GetMapping("/org-units") - @Operation( - summary = "Get all opening org units", - description = "Get all opening org units. Optionally you can ask for the expired ones.", - responses = { - @ApiResponse( - responseCode = "200", - description = "An array with found objects, or an empty array.", - content = @Content(mediaType = "application/json")), - @ApiResponse( - responseCode = "401", - description = "Access token is missing or invalid", - content = @Content(schema = @Schema(implementation = Void.class))) - }) public List getOpeningOrgUnits() { return orgUnitService.findAllOrgUnits(); } @@ -293,27 +147,9 @@ public List getOpeningOrgUnits() { * @return List of OrgUnitEntity with found org units. */ @GetMapping("/org-units-by-code") - @Operation( - summary = "Get all opening org units by code", - description = "Get all opening org units by code.", - responses = { - @ApiResponse( - responseCode = "200", - description = "An array with found objects, or an empty array.", - content = @Content(mediaType = "application/json")), - @ApiResponse( - responseCode = "401", - description = "Access token is missing or invalid", - content = @Content(schema = @Schema(implementation = Void.class))) - }) public List getOpeningOrgUnitsByCode( @RequestParam(value = "orgUnitCodes", required = true) - @Parameter( - name = "orgUnitCodes", - in = ParameterIn.QUERY, - description = "Defines the org units that should be included in the search", - required = false) - String[] codes) { + String[] codes) { return orgUnitService.findAllOrgUnitsByCode(codes); } } diff --git a/backend/src/main/java/ca/bc/gov/restapi/results/postgres/dto/FreeGrowingMilestonesDto.java b/backend/src/main/java/ca/bc/gov/restapi/results/postgres/dto/FreeGrowingMilestonesDto.java index 99a10dbf..82ec92da 100644 --- a/backend/src/main/java/ca/bc/gov/restapi/results/postgres/dto/FreeGrowingMilestonesDto.java +++ b/backend/src/main/java/ca/bc/gov/restapi/results/postgres/dto/FreeGrowingMilestonesDto.java @@ -1,6 +1,5 @@ package ca.bc.gov.restapi.results.postgres.dto; -import io.swagger.v3.oas.annotations.media.Schema; import java.math.BigDecimal; import lombok.Builder; import lombok.With; @@ -11,17 +10,9 @@ @Builder @With public record FreeGrowingMilestonesDto( - @Schema(description = "Number representing the index, between 0 and 3.", example = "1") Integer index, - @Schema( - description = "Label of the current slice. E.g.: 0 - 5 month, 6 - 11 months", - example = "12 - 17 months") String label, - @Schema(description = "Amount of openings in the slice", example = "33") Integer amount, - @Schema( - description = - "Percentage of this slice considering the total of openings on the period.", - example = "28") + Integer amount, BigDecimal percentage) { } diff --git a/backend/src/main/java/ca/bc/gov/restapi/results/postgres/dto/MyRecentActionsRequestsDto.java b/backend/src/main/java/ca/bc/gov/restapi/results/postgres/dto/MyRecentActionsRequestsDto.java index 28fb238c..ffe64fea 100644 --- a/backend/src/main/java/ca/bc/gov/restapi/results/postgres/dto/MyRecentActionsRequestsDto.java +++ b/backend/src/main/java/ca/bc/gov/restapi/results/postgres/dto/MyRecentActionsRequestsDto.java @@ -1,6 +1,5 @@ package ca.bc.gov.restapi.results.postgres.dto; -import io.swagger.v3.oas.annotations.media.Schema; import java.time.LocalDateTime; import lombok.Builder; import lombok.With; @@ -11,30 +10,12 @@ @Builder @With public record MyRecentActionsRequestsDto( - @Schema(description = "Full description of the action made by the user.", example = "Update") String activityType, - @Schema( - description = "System generated value uniquely identifying the opening.", - example = "1541297") Long openingId, - @Schema( - description = """ - A code indicating the status of the prescription. Examples include but are not - limited to DFT (draft) and APP (approved). A subset of the STATUS_CODE table. - """, - example = "APP") String statusCode, - @Schema( - description = """ - The code description indicating the status of the prescription. Examples include but - are not limited to Draft (DFT) and Approved (APP). A subset of the STATUS_CODE table. - """, - example = "Approved") String statusDescription, - @Schema( - description = "The date and time of the activity action in for 'time ago' format", - example = "1 minute ago") String lastUpdatedLabel, - @Schema(description = "The date and time of the activity action") LocalDateTime lastUpdated) { + LocalDateTime lastUpdated +) { } diff --git a/backend/src/main/java/ca/bc/gov/restapi/results/postgres/dto/OpeningsPerYearDto.java b/backend/src/main/java/ca/bc/gov/restapi/results/postgres/dto/OpeningsPerYearDto.java index fd0cd931..d00dcc6c 100644 --- a/backend/src/main/java/ca/bc/gov/restapi/results/postgres/dto/OpeningsPerYearDto.java +++ b/backend/src/main/java/ca/bc/gov/restapi/results/postgres/dto/OpeningsPerYearDto.java @@ -1,15 +1,17 @@ package ca.bc.gov.restapi.results.postgres.dto; -import io.swagger.v3.oas.annotations.media.Schema; import lombok.Builder; import lombok.With; -/** This record represents a record for the "Opening submission trends" chart. */ +/** + * This record represents a record for the "Opening submission trends" chart. + */ @Builder @With -@Schema( - description = "This record represents a record for the \"Opening submission trends\" chart.") public record OpeningsPerYearDto( - @Schema(description = "The `x` value with the month number.", example = "3") Integer month, - @Schema(description = "The `x` value with the month name.", example = "Mar") String monthName, - @Schema(description = "The `y` value with the month value.", example = "70") Integer amount) {} + Integer month, + String monthName, + Integer amount +) { + +} diff --git a/backend/src/main/java/ca/bc/gov/restapi/results/postgres/endpoint/DashboardExtractionEndpoint.java b/backend/src/main/java/ca/bc/gov/restapi/results/postgres/endpoint/DashboardExtractionEndpoint.java index db05cef0..f0e10711 100644 --- a/backend/src/main/java/ca/bc/gov/restapi/results/postgres/endpoint/DashboardExtractionEndpoint.java +++ b/backend/src/main/java/ca/bc/gov/restapi/results/postgres/endpoint/DashboardExtractionEndpoint.java @@ -5,13 +5,6 @@ import ca.bc.gov.restapi.results.postgres.config.DashboardUserManagerConfig; import ca.bc.gov.restapi.results.postgres.entity.OracleExtractionLogsEntity; import ca.bc.gov.restapi.results.postgres.repository.OracleExtractionLogsRepository; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.enums.ParameterIn; -import io.swagger.v3.oas.annotations.media.Content; -import io.swagger.v3.oas.annotations.media.Schema; -import io.swagger.v3.oas.annotations.responses.ApiResponse; -import io.swagger.v3.oas.annotations.tags.Tag; import java.util.List; import lombok.AllArgsConstructor; import org.springframework.data.domain.Sort; @@ -23,13 +16,12 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; -/** This class holds resources for the Dashboard extraction process. */ +/** + * This class holds resources for the Dashboard extraction process. + */ @RestController @RequestMapping("/api/dashboard-extraction") @AllArgsConstructor -@Tag( - name = "Dashboard Extraction (Postgres)", - description = "Endpoints for the Dashboard extraction process on `SILVA` schema") public class DashboardExtractionEndpoint { private final OracleExtractionLogsRepository oracleExtractionLogsRepository; @@ -44,41 +36,15 @@ public class DashboardExtractionEndpoint { * Manually triggers the dashboard extraction job. * * @param months Optional. The number of months to extract data. Default: 24. - * @param debug Optional. Enables debug mode. Default: `false`. + * @param debug Optional. Enables debug mode. Default: `false`. * @return Http codes 204 if success or 401 if unauthorized. */ @PostMapping("/start") - @Operation( - summary = "Manually triggers the dashboard extraction job.", - description = - "Manually calls the job responsible for fetching and loading data. There's a debug mode" - + " that can be enabled", - responses = { - @ApiResponse( - responseCode = "204", - description = "Job successfully triggered. No response body (asynchronous task)."), - @ApiResponse( - responseCode = "401", - description = "Access token is missing, invalid or user not allowed", - content = @Content(schema = @Schema(implementation = Void.class))) - }) public ResponseEntity startExtractionProcessManually( @RequestParam(value = "months", required = false) - @Parameter( - name = "months", - in = ParameterIn.QUERY, - description = "Optional. The number of months to extract data. Default: 24", - required = false, - example = "12") - Integer months, + Integer months, @RequestParam(value = "debug", required = false) - @Parameter( - name = "debug", - in = ParameterIn.QUERY, - description = "Optional. Enables debug mode. Default: `false`", - required = false, - example = "true") - Boolean debug) { + Boolean debug) { if (dashboardUserManagerConfig.getUserList().isEmpty()) { return ResponseEntity.status(HttpStatus.UNAUTHORIZED).build(); } @@ -98,22 +64,6 @@ public ResponseEntity startExtractionProcessManually( * @return A list of oracle logs records with the last extraction logs. */ @GetMapping("/logs") - @Operation( - summary = "Gets all log messages from the last extraction process.", - description = "Fetches all logged messages from the last extraction with or without debug.", - responses = { - @ApiResponse( - responseCode = "200", - description = "An array with all logs messages.", - content = @Content(mediaType = "application/json")), - @ApiResponse( - responseCode = "204", - description = "No data found on the table. No response body."), - @ApiResponse( - responseCode = "401", - description = "Access token is missing or invalid", - content = @Content(schema = @Schema(implementation = Void.class))) - }) public ResponseEntity> getLastExtractionLogs() { List logs = oracleExtractionLogsRepository.findAll(Sort.by("id").ascending()); diff --git a/backend/src/main/java/ca/bc/gov/restapi/results/postgres/endpoint/DashboardMetricsEndpoint.java b/backend/src/main/java/ca/bc/gov/restapi/results/postgres/endpoint/DashboardMetricsEndpoint.java index 7445d104..9fb42c5b 100644 --- a/backend/src/main/java/ca/bc/gov/restapi/results/postgres/endpoint/DashboardMetricsEndpoint.java +++ b/backend/src/main/java/ca/bc/gov/restapi/results/postgres/endpoint/DashboardMetricsEndpoint.java @@ -6,13 +6,6 @@ import ca.bc.gov.restapi.results.postgres.dto.MyRecentActionsRequestsDto; import ca.bc.gov.restapi.results.postgres.dto.OpeningsPerYearDto; import ca.bc.gov.restapi.results.postgres.service.DashboardMetricsService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.enums.ParameterIn; -import io.swagger.v3.oas.annotations.media.Content; -import io.swagger.v3.oas.annotations.media.Schema; -import io.swagger.v3.oas.annotations.responses.ApiResponse; -import io.swagger.v3.oas.annotations.tags.Tag; import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.http.ResponseEntity; @@ -21,12 +14,11 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; -/** This class holds resources for the dashboard metrics page. */ +/** + * This class holds resources for the dashboard metrics page. + */ @RestController @RequestMapping("/api/dashboard-metrics") -@Tag( - name = "Dashboard Metrics (Postgres)", - description = "Endpoints for the Dashboard metrics charts on `SILVA` schema") @RequiredArgsConstructor public class DashboardMetricsEndpoint { @@ -36,62 +28,22 @@ public class DashboardMetricsEndpoint { * Gets data for the Opening submission trends Chart (Openings per year) on the Dashboard SILVA * page. * - * @param orgUnitCode Optional district code filter. - * @param statusCode Optional opening status code filter. + * @param orgUnitCode Optional district code filter. + * @param statusCode Optional opening status code filter. * @param entryDateStart Optional opening entry timestamp start date filter. - * @param entryDateEnd Optional opening entry timestamp end date filter. + * @param entryDateEnd Optional opening entry timestamp end date filter. * @return A list of values to populate the chart or 204 no content if no data. */ @GetMapping("/submission-trends") - @Operation( - summary = "Gets data for the Opening submission trends Chart (Openings per year).", - description = "Fetches data from the last twelve months for the openings per year chart.", - responses = { - @ApiResponse( - responseCode = "200", - description = "An array with twelve objects for the last 12 months.", - content = @Content(mediaType = "application/json")), - @ApiResponse( - responseCode = "204", - description = "No data found on the table. No response body."), - @ApiResponse( - responseCode = "401", - description = "Access token is missing or invalid", - content = @Content(schema = @Schema(implementation = Void.class))) - }) public ResponseEntity> getOpeningsSubmissionTrends( @RequestParam(value = "orgUnitCode", required = false) - @Parameter( - name = "orgUnitCode", - in = ParameterIn.QUERY, - description = "The Org Unit code to filter, same as District", - required = false, - example = "DCR") - String orgUnitCode, + String orgUnitCode, @RequestParam(value = "statusCode", required = false) - @Parameter( - name = "statusCode", - in = ParameterIn.QUERY, - description = "The Openings Status code to filter", - required = false, - example = "APP") - String statusCode, + String statusCode, @RequestParam(value = "entryDateStart", required = false) - @Parameter( - name = "entryDateStart", - in = ParameterIn.QUERY, - description = "The Openings entry timestamp start date to filter, format yyyy-MM-dd", - required = false, - example = "2024-03-11") - String entryDateStart, + String entryDateStart, @RequestParam(value = "entryDateEnd", required = false) - @Parameter( - name = "entryDateEnd", - in = ParameterIn.QUERY, - description = "The Openings entry timestamp end date to filter, format yyyy-MM-dd", - required = false, - example = "2024-03-11") - String entryDateEnd) { + String entryDateEnd) { DashboardFiltersDto filtersDto = new DashboardFiltersDto( orgUnitCode, @@ -113,64 +65,22 @@ public ResponseEntity> getOpeningsSubmissionTrends( /** * Gets data for the Free growing Chart on the Dashboard SILVA page. * - * @param orgUnitCode Optional district code filter. - * @param clientNumber Optional client number filter. + * @param orgUnitCode Optional district code filter. + * @param clientNumber Optional client number filter. * @param entryDateStart Optional opening entry timestamp start date filter. - * @param entryDateEnd Optional opening entry timestamp end date filter. + * @param entryDateEnd Optional opening entry timestamp end date filter. * @return A list of values to populate the chart or 204 no content if no data. */ @GetMapping("/free-growing-milestones") - @Operation( - summary = "Gets data for the Free growing Chart on the Dashboard SILVA page.", - description = - "Fetches data from the last 24 months and group them into periods for the Free growing" - + " chart.", - responses = { - @ApiResponse( - responseCode = "200", - description = "An array with four objects, one for each piece of the chart.", - content = @Content(mediaType = "application/json")), - @ApiResponse( - responseCode = "204", - description = "No data found on the table. No response body."), - @ApiResponse( - responseCode = "401", - description = "Access token is missing or invalid", - content = @Content(schema = @Schema(implementation = Void.class))) - }) public ResponseEntity> getFreeGrowingMilestonesData( @RequestParam(value = "orgUnitCode", required = false) - @Parameter( - name = "orgUnitCode", - in = ParameterIn.QUERY, - description = "The Org Unit code to filter, same as District", - required = false, - example = "DCR") - String orgUnitCode, + String orgUnitCode, @RequestParam(value = "clientNumber", required = false) - @Parameter( - name = "clientNumber", - in = ParameterIn.QUERY, - description = "The Client Number to filter", - required = false, - example = "00012797") - String clientNumber, + String clientNumber, @RequestParam(value = "entryDateStart", required = false) - @Parameter( - name = "entryDateStart", - in = ParameterIn.QUERY, - description = "The Openings entry timestamp start date to filter, format yyyy-MM-dd", - required = false, - example = "2024-03-11") - String entryDateStart, + String entryDateStart, @RequestParam(value = "entryDateEnd", required = false) - @Parameter( - name = "entryDateEnd", - in = ParameterIn.QUERY, - description = "The Openings entry timestamp end date to filter, format yyyy-MM-dd", - required = false, - example = "2024-03-11") - String entryDateEnd) { + String entryDateEnd) { DashboardFiltersDto filtersDto = new DashboardFiltersDto( orgUnitCode, @@ -194,22 +104,6 @@ public ResponseEntity> getFreeGrowingMilestonesDa * @return A list of values to populate the chart or 204 no content if no data. */ @GetMapping("/my-recent-actions/requests") - @Operation( - summary = "Gets the last 5 most recent updated openings for the request user.", - description = "Fetches data for the My recent actions table, Requests tab", - responses = { - @ApiResponse( - responseCode = "200", - description = "An array with five objects, one for opening row.", - content = @Content(mediaType = "application/json")), - @ApiResponse( - responseCode = "204", - description = "No data found for the user. No response body."), - @ApiResponse( - responseCode = "401", - description = "Access token is missing or invalid", - content = @Content(schema = @Schema(implementation = Void.class))) - }) public ResponseEntity> getUserRecentOpeningsActions() { List actionsDto = dashboardMetricsService.getUserRecentOpeningsActions(); diff --git a/backend/src/main/java/ca/bc/gov/restapi/results/postgres/endpoint/UserOpeningEndpoint.java b/backend/src/main/java/ca/bc/gov/restapi/results/postgres/endpoint/UserOpeningEndpoint.java index e548216f..c1bb619f 100644 --- a/backend/src/main/java/ca/bc/gov/restapi/results/postgres/endpoint/UserOpeningEndpoint.java +++ b/backend/src/main/java/ca/bc/gov/restapi/results/postgres/endpoint/UserOpeningEndpoint.java @@ -2,13 +2,6 @@ import ca.bc.gov.restapi.results.postgres.dto.MyRecentActionsRequestsDto; import ca.bc.gov.restapi.results.postgres.service.UserOpeningService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.enums.ParameterIn; -import io.swagger.v3.oas.annotations.media.Content; -import io.swagger.v3.oas.annotations.media.Schema; -import io.swagger.v3.oas.annotations.responses.ApiResponse; -import io.swagger.v3.oas.annotations.tags.Tag; import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.http.HttpStatus; @@ -20,12 +13,11 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -/** This class holds resources for exposing user openings saved as favourites. */ +/** + * This class holds resources for exposing user openings saved as favourites. + */ @RestController @RequestMapping("/api/user-openings") -@Tag( - name = "User Openings (Postgres)", - description = "Endpoints to handle user favourite Openings on `SILVA` schema.") @RequiredArgsConstructor public class UserOpeningEndpoint { @@ -37,22 +29,6 @@ public class UserOpeningEndpoint { * @return A list of openings or the http code 204-No Content. */ @GetMapping("/dashboard-track-openings") - @Operation( - summary = "Gets up to three updated Openings to a user", - description = "Gets up to three updated openings that got saved by the user.", - responses = { - @ApiResponse( - responseCode = "200", - description = "An array containing up to three Openings for the user.", - content = @Content(mediaType = "application/json")), - @ApiResponse( - responseCode = "204", - description = "No data found for this user. No response body."), - @ApiResponse( - responseCode = "401", - description = "Access token is missing or invalid", - content = @Content(schema = @Schema(implementation = Void.class))) - }) public ResponseEntity> getUserTrackedOpenings() { List userOpenings = userOpeningService.getUserTrackedOpenings(); if (userOpenings.isEmpty()) { @@ -69,25 +45,7 @@ public ResponseEntity> getUserTrackedOpenings() * @return HTTP status code 201 if success, no response body. */ @PostMapping("/{id}") - @Operation( - summary = "Saves one Opening ID as favourite to an user", - description = "Allow users to save Opening IDs to track them easily in the dashboard.", - responses = { - @ApiResponse(responseCode = "201", description = "Opening successfully saved to the user."), - @ApiResponse( - responseCode = "401", - description = "Access token is missing or invalid", - content = @Content(schema = @Schema(implementation = Void.class))) - }) - public ResponseEntity saveUserOpening( - @Parameter( - name = "id", - in = ParameterIn.PATH, - description = "Opening ID", - required = true, - schema = @Schema(type = "integer", format = "int64")) - @PathVariable - Long id) { + public ResponseEntity saveUserOpening(Long id) { userOpeningService.saveOpeningToUser(id); return ResponseEntity.status(HttpStatus.CREATED).build(); } @@ -99,30 +57,9 @@ public ResponseEntity saveUserOpening( * @return HTTP status code 204 if success, no response body. */ @DeleteMapping("/{id}") - @Operation( - summary = "Deleted an Opening ID from the user's favourite", - description = "Allow users to remove saved Opening IDs from their favourite list.", - responses = { - @ApiResponse( - responseCode = "204", - description = "Opening successfully removed. No content body."), - @ApiResponse( - responseCode = "401", - description = "Access token is missing or invalid", - content = @Content(schema = @Schema(implementation = Void.class))), - @ApiResponse( - responseCode = "404", - description = "Opening not found in the user's favourite.") - }) public ResponseEntity deleteUserOpening( - @Parameter( - name = "id", - in = ParameterIn.PATH, - description = "Opening ID", - required = true, - schema = @Schema(type = "integer", format = "int64")) - @PathVariable - Long id) { + @PathVariable + Long id) { userOpeningService.deleteOpeningFromUserFavourite(id); return ResponseEntity.status(HttpStatus.NO_CONTENT).build(); } From 4d36f7cf6c26548957fe4bed10d3a2f9cde4394a Mon Sep 17 00:00:00 2001 From: Paulo Gomes da Cruz Junior Date: Mon, 28 Oct 2024 05:40:43 -0700 Subject: [PATCH 03/10] chore: changing annoying checkstyle config --- backend/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/pom.xml b/backend/pom.xml index 9049a571..4c69cd58 100644 --- a/backend/pom.xml +++ b/backend/pom.xml @@ -31,7 +31,7 @@ true true true - true + false true ${project.build.directory}/coverage-reports ${maven.build.timestamp} From aa4746a0dc0a25cc76784e940417edc63a8b2f6a Mon Sep 17 00:00:00 2001 From: Paulo Gomes da Cruz Junior Date: Mon, 28 Oct 2024 05:48:37 -0700 Subject: [PATCH 04/10] chore: fixing test --- .../restapi/results/common/endpoint/ForestClientEndpoint.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/backend/src/main/java/ca/bc/gov/restapi/results/common/endpoint/ForestClientEndpoint.java b/backend/src/main/java/ca/bc/gov/restapi/results/common/endpoint/ForestClientEndpoint.java index c46deefd..f0c7a27a 100644 --- a/backend/src/main/java/ca/bc/gov/restapi/results/common/endpoint/ForestClientEndpoint.java +++ b/backend/src/main/java/ca/bc/gov/restapi/results/common/endpoint/ForestClientEndpoint.java @@ -5,6 +5,7 @@ import ca.bc.gov.restapi.results.common.service.ForestClientService; import lombok.AllArgsConstructor; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @@ -26,7 +27,7 @@ public class ForestClientEndpoint { * @throws ForestClientNotFoundException when client not found */ @GetMapping("/{clientNumber}") - public ForestClientDto getForestClient(String clientNumber) { + public ForestClientDto getForestClient(@PathVariable String clientNumber) { return forestClientService .getClientByNumber(clientNumber) .orElseThrow(ForestClientNotFoundException::new); From 3cb574ac65e56ea7354e07134576914044db9d7c Mon Sep 17 00:00:00 2001 From: Paulo Gomes da Cruz Junior Date: Mon, 28 Oct 2024 06:03:04 -0700 Subject: [PATCH 05/10] chore(test): updating test related config and data --- backend/pom.xml | 8 +- .../test/resources/application-default.yml | 32 +- .../migration/oracle/V001__oracle_init.sql | 695 +++++++++++++----- .../oracle/V002__oracle_code_tables.sql | 52 +- .../oracle/V003__oracle_test_data.sql | 251 ++++++- 5 files changed, 828 insertions(+), 210 deletions(-) diff --git a/backend/pom.xml b/backend/pom.xml index 4c69cd58..c6d3b09a 100644 --- a/backend/pom.xml +++ b/backend/pom.xml @@ -120,7 +120,7 @@ - + org.springframework.boot spring-boot-starter-web @@ -130,6 +130,7 @@ spring-boot-starter-validation + org.projectlombok lombok @@ -141,6 +142,11 @@ prettytime 5.0.9.Final + + org.apache.commons + commons-lang3 + 3.17.0 + diff --git a/backend/src/test/resources/application-default.yml b/backend/src/test/resources/application-default.yml index 9e9be1e6..67b39a04 100644 --- a/backend/src/test/resources/application-default.yml +++ b/backend/src/test/resources/application-default.yml @@ -1,7 +1,7 @@ spring: flyway: enabled: false -# FAM + # FAM security: oauth2: resourceserver: @@ -10,19 +10,25 @@ spring: jwk-set-uri: https://aws-cognito-issuer-uri.aws.com/.well-known/jwks.json # Users allowed to see and download WMS layers information -nr: - results: - config: - wms-layers: - whitelist: ${WMS_LAYERS_WHITELIST_USERS:NONE} - opening-search: - org-units: ${OPENING_SEARCH_ORG_UNITS:DCK} +ca: + bc: + gov: + nrs: + results: + wms-layers: + whitelist: ${WMS_LAYERS_WHITELIST_USERS:NONE} + opening-search: + org-units: ${OPENING_SEARCH_ORG_UNITS:DAS} + forest-client-api: + address: http://localhost:10000 + key: 123456789abcdef + open-maps: + address: http://localhost:10001 -# Forest Client API -#forest-client-api: -# address: https://nonexistent.org -# key: 123456789abcdef logging: level: - ca.bc.gov.restapi.results: ${LOGGING_LEVEL:INFO} \ No newline at end of file + #root: DEBUG + ca.bc.gov.restapi.results: ${LOGGING_LEVEL:INFO} + org.springframework.web.client: DEBUG + org.springframework.http.client: DEBUG \ No newline at end of file diff --git a/backend/src/test/resources/migration/oracle/V001__oracle_init.sql b/backend/src/test/resources/migration/oracle/V001__oracle_init.sql index b7628d26..6ebb03fb 100644 --- a/backend/src/test/resources/migration/oracle/V001__oracle_init.sql +++ b/backend/src/test/resources/migration/oracle/V001__oracle_init.sql @@ -1,3 +1,160 @@ +-- All the code tables required so far + +CREATE TABLE THE.OPEN_CATEGORY_CODE ( + OPEN_CATEGORY_CODE VARCHAR2(7), + DESCRIPTION VARCHAR2(120), + EFFECTIVE_DATE DATE, + EXPIRY_DATE DATE, + UPDATE_TIMESTAMP DATE, + CONSTRAINT OCC_PK PRIMARY KEY (OPEN_CATEGORY_CODE), + CONSTRAINT SYS_C007655_OCC_CT CHECK ("OPEN_CATEGORY_CODE" IS NOT NULL), + CONSTRAINT SYS_C007656_OCC_CT CHECK ("DESCRIPTION" IS NOT NULL), + CONSTRAINT SYS_C007657_OCC_CT CHECK ("EFFECTIVE_DATE" IS NOT NULL), + CONSTRAINT SYS_C007658_OCC_CT CHECK ("EXPIRY_DATE" IS NOT NULL), + CONSTRAINT SYS_C007659_OCC_CT CHECK ("UPDATE_TIMESTAMP" IS NOT NULL) +); + +CREATE TABLE THE.AGE_CLASS_CODE ( + AGE_CLASS_CODE VARCHAR2(1), + DESCRIPTION VARCHAR2(120), + EFFECTIVE_DATE DATE, + EXPIRY_DATE DATE, + UPDATE_TIMESTAMP DATE, + CONSTRAINT ACC_PK PRIMARY KEY (AGE_CLASS_CODE), + CONSTRAINT SYS_C007687_ACC_CT CHECK ("AGE_CLASS_CODE" IS NOT NULL), + CONSTRAINT SYS_C007689_ACC_CT CHECK ("DESCRIPTION" IS NOT NULL), + CONSTRAINT SYS_C007690_ACC_CT CHECK ("EFFECTIVE_DATE" IS NOT NULL), + CONSTRAINT SYS_C007691_ACC_CT CHECK ("EXPIRY_DATE" IS NOT NULL), + CONSTRAINT SYS_C007692_ACC_CT CHECK ("UPDATE_TIMESTAMP" IS NOT NULL) +); + +CREATE TABLE THE.HEIGHT_CLASS_CODE ( + HEIGHT_CLASS_CODE VARCHAR2(1), + DESCRIPTION VARCHAR2(120), + EFFECTIVE_DATE DATE, + EXPIRY_DATE DATE, + UPDATE_TIMESTAMP DATE, + CONSTRAINT HCC_PK PRIMARY KEY (HEIGHT_CLASS_CODE), + CONSTRAINT SYS_C0039387_HCC_CT CHECK ("HEIGHT_CLASS_CODE" IS NOT NULL), + CONSTRAINT SYS_C0039388_HCC_CT CHECK ("DESCRIPTION" IS NOT NULL), + CONSTRAINT SYS_C0039389_HCC_CT CHECK ("EFFECTIVE_DATE" IS NOT NULL), + CONSTRAINT SYS_C0039390_HCC_CT CHECK ("EXPIRY_DATE" IS NOT NULL), + CONSTRAINT SYS_C0039391_HCC_CT CHECK ("UPDATE_TIMESTAMP" IS NOT NULL) +); + +CREATE TABLE THE.OPENING_STATUS_CODE ( + OPENING_STATUS_CODE VARCHAR2(3), + DESCRIPTION VARCHAR2(120), + EFFECTIVE_DATE DATE, + EXPIRY_DATE DATE, + UPDATE_TIMESTAMP DATE, + CONSTRAINT OSC_PK PRIMARY KEY (OPENING_STATUS_CODE), + CONSTRAINT SYS_C008336_OSC_CT CHECK ("OPENING_STATUS_CODE" IS NOT NULL), + CONSTRAINT SYS_C008337_OSC_CT CHECK ("DESCRIPTION" IS NOT NULL), + CONSTRAINT SYS_C008338_OSC_CT CHECK ("EFFECTIVE_DATE" IS NOT NULL), + CONSTRAINT SYS_C008339_OSC_CT CHECK ("EXPIRY_DATE" IS NOT NULL), + CONSTRAINT SYS_C008340_OSC_CT CHECK ("UPDATE_TIMESTAMP" IS NOT NULL) +); + +CREATE TABLE THE.STOCKING_CLASS_CODE ( + STOCKING_CLASS_CODE VARCHAR2(1), + DESCRIPTION VARCHAR2(120), + EFFECTIVE_DATE DATE, + EXPIRY_DATE DATE, + UPDATE_TIMESTAMP DATE, + CONSTRAINT SCC1_PK PRIMARY KEY (STOCKING_CLASS_CODE), + CONSTRAINT SYS_C008214_SCC1_CT CHECK ("STOCKING_CLASS_CODE" IS NOT NULL), + CONSTRAINT SYS_C008215_SCC1_CT CHECK ("DESCRIPTION" IS NOT NULL), + CONSTRAINT SYS_C008216_SCC1_CT CHECK ("EFFECTIVE_DATE" IS NOT NULL), + CONSTRAINT SYS_C008217_SCC1_CT CHECK ("EXPIRY_DATE" IS NOT NULL), + CONSTRAINT SYS_C008218_SCC1_CT CHECK ("UPDATE_TIMESTAMP" IS NOT NULL) +); + +CREATE TABLE THE.SITE_CLASS_CODE ( + SITE_CLASS_CODE VARCHAR2(1), + DESCRIPTION VARCHAR2(120), + EFFECTIVE_DATE DATE, + EXPIRY_DATE DATE, + UPDATE_TIMESTAMP DATE, + CONSTRAINT SITE_CLASS_CODE_PK PRIMARY KEY (SITE_CLASS_CODE), + CONSTRAINT SYS_C008260_SCC_CT CHECK ("SITE_CLASS_CODE" IS NOT NULL), + CONSTRAINT SYS_C008262_SCC_CT CHECK ("DESCRIPTION" IS NOT NULL), + CONSTRAINT SYS_C008264_SCC_CT CHECK ("EFFECTIVE_DATE" IS NOT NULL), + CONSTRAINT SYS_C008265_SCC_CT CHECK ("EXPIRY_DATE" IS NOT NULL), + CONSTRAINT SYS_C008266_SCC_CT CHECK ("UPDATE_TIMESTAMP" IS NOT NULL) +); + +CREATE TABLE THE.SITE_INDEX_SOURCE_CODE ( + SITE_INDEX_SOURCE_CODE VARCHAR2(1), + DESCRIPTION VARCHAR2(120), + EFFECTIVE_DATE DATE, + EXPIRY_DATE DATE, + UPDATE_TIMESTAMP DATE, + CONSTRAINT SISC_PK PRIMARY KEY (SITE_INDEX_SOURCE_CODE), + CONSTRAINT SYS_C008567_SISC_CT CHECK ("SITE_INDEX_SOURCE_CODE" IS NOT NULL), + CONSTRAINT SYS_C008569_SISC_CT CHECK ("DESCRIPTION" IS NOT NULL), + CONSTRAINT SYS_C008571_SISC_CT CHECK ("EFFECTIVE_DATE" IS NOT NULL), + CONSTRAINT SYS_C008572_SISC_CT CHECK ("EXPIRY_DATE" IS NOT NULL), + CONSTRAINT SYS_C008573_SISC_CT CHECK ("UPDATE_TIMESTAMP" IS NOT NULL) +); + +CREATE TABLE THE.STOCKING_STATUS_CODE ( + STOCKING_STATUS_CODE VARCHAR2(3), + DESCRIPTION VARCHAR2(120), + EFFECTIVE_DATE DATE, + EXPIRY_DATE DATE, + UPDATE_TIMESTAMP DATE, + CONSTRAINT SSC6_PK PRIMARY KEY (STOCKING_STATUS_CODE), + CONSTRAINT SYS_C007771_SSC6_CT CHECK ("STOCKING_STATUS_CODE" IS NOT NULL), + CONSTRAINT SYS_C007772_SSC6_CT CHECK ("DESCRIPTION" IS NOT NULL), + CONSTRAINT SYS_C007773_SSC6_CT CHECK ("EFFECTIVE_DATE" IS NOT NULL), + CONSTRAINT SYS_C007774_SSC6_CT CHECK ("EXPIRY_DATE" IS NOT NULL), + CONSTRAINT SYS_C007775_SSC6_CT CHECK ("UPDATE_TIMESTAMP" IS NOT NULL) +); + +CREATE TABLE THE.TSB_NUMBER_CODE ( + TSB_NUMBER_CODE VARCHAR2(3), + DESCRIPTION VARCHAR2(120), + EFFECTIVE_DATE DATE, + EXPIRY_DATE DATE, + UPDATE_TIMESTAMP DATE, + CONSTRAINT SYS_C0016369_TSBNC_CT CHECK ("TSB_NUMBER_CODE" IS NOT NULL), + CONSTRAINT SYS_C0016370_TSBNC_CT CHECK ("DESCRIPTION" IS NOT NULL), + CONSTRAINT SYS_C0016371_TSBNC_CT CHECK ("EFFECTIVE_DATE" IS NOT NULL), + CONSTRAINT SYS_C0016372_TSBNC_CT CHECK ("EXPIRY_DATE" IS NOT NULL), + CONSTRAINT SYS_C0016374_TSBNC_CT CHECK ("UPDATE_TIMESTAMP" IS NOT NULL), + CONSTRAINT TSBNC_PK PRIMARY KEY (TSB_NUMBER_CODE) +); + +CREATE TABLE THE.TREE_SPECIES_CODE ( + TREE_SPECIES_CODE VARCHAR2(3), + DESCRIPTION VARCHAR2(120), + EFFECTIVE_DATE DATE, + EXPIRY_DATE DATE, + UPDATE_TIMESTAMP DATE, + CONSTRAINT SYS_C0031659_TSC_CT CHECK ("TREE_SPECIES_CODE" IS NOT NULL), + CONSTRAINT SYS_C0031660_TSC_CT CHECK ("DESCRIPTION" IS NOT NULL), + CONSTRAINT SYS_C0031661_TSC_CT CHECK ("EFFECTIVE_DATE" IS NOT NULL), + CONSTRAINT SYS_C0031662_TSC_CT CHECK ("EXPIRY_DATE" IS NOT NULL), + CONSTRAINT SYS_C0031663_TSC_CT CHECK ("UPDATE_TIMESTAMP" IS NOT NULL), + CONSTRAINT TSC_PK PRIMARY KEY (TREE_SPECIES_CODE) +); + +CREATE TABLE THE.RESULTS_AUDIT_ACTION_CODE ( + RESULTS_AUDIT_ACTION_CODE VARCHAR2(3), + DESCRIPTION VARCHAR2(120), + EFFECTIVE_DATE DATE, + EXPIRY_DATE DATE, + UPDATE_TIMESTAMP DATE, + CONSTRAINT RAAC_PK PRIMARY KEY (RESULTS_AUDIT_ACTION_CODE), + CONSTRAINT SYS_C007760_RAAC_CT CHECK ("RESULTS_AUDIT_ACTION_CODE" IS NOT NULL), + CONSTRAINT SYS_C007761_RAAC_CT CHECK ("DESCRIPTION" IS NOT NULL), + CONSTRAINT SYS_C007762_RAAC_CT CHECK ("EFFECTIVE_DATE" IS NOT NULL), + CONSTRAINT SYS_C007763_RAAC_CT CHECK ("EXPIRY_DATE" IS NOT NULL), + CONSTRAINT SYS_C007764_RAAC_CT CHECK ("UPDATE_TIMESTAMP" IS NOT NULL) +); +-- Other domain tables + CREATE TABLE THE.CUT_BLOCK_OPEN_ADMIN ( CUT_BLOCK_OPEN_ADMIN_ID NUMBER(10,0), FOREST_FILE_ID VARCHAR2(10), @@ -23,12 +180,12 @@ CREATE TABLE THE.CUT_BLOCK_OPEN_ADMIN ( OPENING_PRIME_LICENCE_IND IN ('N', 'Y') ), CONSTRAINT CBOA_PK PRIMARY KEY (CUT_BLOCK_OPEN_ADMIN_ID), - CONSTRAINT SYS_C0021117 CHECK ("CUT_BLOCK_OPEN_ADMIN_ID" IS NOT NULL), - CONSTRAINT SYS_C0021119 CHECK ("REVISION_COUNT" IS NOT NULL), - CONSTRAINT SYS_C0021121 CHECK ("ENTRY_USERID" IS NOT NULL), - CONSTRAINT SYS_C0021123 CHECK ("ENTRY_TIMESTAMP" IS NOT NULL), - CONSTRAINT SYS_C0021124 CHECK ("UPDATE_USERID" IS NOT NULL), - CONSTRAINT SYS_C0021125 CHECK ("UPDATE_TIMESTAMP" IS NOT NULL) + CONSTRAINT SYS_C0021117_CBOA_CT CHECK ("CUT_BLOCK_OPEN_ADMIN_ID" IS NOT NULL), + CONSTRAINT SYS_C0021119_CBOA_CT CHECK ("REVISION_COUNT" IS NOT NULL), + CONSTRAINT SYS_C0021121_CBOA_CT CHECK ("ENTRY_USERID" IS NOT NULL), + CONSTRAINT SYS_C0021123_CBOA_CT CHECK ("ENTRY_TIMESTAMP" IS NOT NULL), + CONSTRAINT SYS_C0021124_CBOA_CT CHECK ("UPDATE_USERID" IS NOT NULL), + CONSTRAINT SYS_C0021125_CBOA_CT CHECK ("UPDATE_TIMESTAMP" IS NOT NULL) ); CREATE INDEX CBOA_CBLK_FK_I ON THE.CUT_BLOCK_OPEN_ADMIN (CUT_BLOCK_ID,TIMBER_MARK,FOREST_FILE_ID); CREATE INDEX CBOA_CBSKEY_I ON THE.CUT_BLOCK_OPEN_ADMIN (CB_SKEY); @@ -36,20 +193,6 @@ CREATE INDEX CBOA_FFID_MARK_BLK_I ON THE.CUT_BLOCK_OPEN_ADMIN (FOREST_FILE_ID,TI CREATE INDEX CBOA_MARK_BLK_I ON THE.CUT_BLOCK_OPEN_ADMIN (TIMBER_MARK,CUT_BLOCK_ID); CREATE INDEX CBOA_O_FK_I ON THE.CUT_BLOCK_OPEN_ADMIN (OPENING_ID); -CREATE TABLE THE.OPEN_CATEGORY_CODE ( - OPEN_CATEGORY_CODE VARCHAR2(7), - DESCRIPTION VARCHAR2(120), - EFFECTIVE_DATE DATE, - EXPIRY_DATE DATE, - UPDATE_TIMESTAMP DATE, - CONSTRAINT OCC_PK PRIMARY KEY (OPEN_CATEGORY_CODE), - CONSTRAINT SYS_C007655 CHECK ("OPEN_CATEGORY_CODE" IS NOT NULL), - CONSTRAINT SYS_C007656 CHECK ("DESCRIPTION" IS NOT NULL), - CONSTRAINT SYS_C007657 CHECK ("EFFECTIVE_DATE" IS NOT NULL), - CONSTRAINT SYS_C007658 CHECK ("EXPIRY_DATE" IS NOT NULL), - CONSTRAINT SYS_C007659 CHECK ("UPDATE_TIMESTAMP" IS NOT NULL) -); - CREATE TABLE THE.OPENING_ATTACHMENT ( OPENING_ATTACHMENT_FILE_ID NUMBER(10,0), OPENING_ID NUMBER(10,0), @@ -65,21 +208,20 @@ CREATE TABLE THE.OPENING_ATTACHMENT ( OPENING_ATTACHMENT_GUID RAW(16) DEFAULT sys_guid() , CONSTRAINT OPATT_GUID_UK UNIQUE (OPENING_ATTACHMENT_GUID), CONSTRAINT OPENING_ATTACHMENT_PK PRIMARY KEY (OPENING_ATTACHMENT_FILE_ID), - CONSTRAINT SYS_C00170771 CHECK ("OPENING_ATTACHMENT_GUID" IS NOT NULL), - CONSTRAINT SYS_C0040027 CHECK ("OPENING_ATTACHMENT_FILE_ID" IS NOT NULL), - CONSTRAINT SYS_C0040028 CHECK ("OPENING_ID" IS NOT NULL), - CONSTRAINT SYS_C0040029 CHECK ("ATTACHMENT_NAME" IS NOT NULL), - CONSTRAINT SYS_C0040030 CHECK ("ATTACHMENT_DATA" IS NOT NULL), - CONSTRAINT SYS_C0040031 CHECK ("ENTRY_USERID" IS NOT NULL), - CONSTRAINT SYS_C0040032 CHECK ("ENTRY_TIMESTAMP" IS NOT NULL), - CONSTRAINT SYS_C0040033 CHECK ("UPDATE_USERID" IS NOT NULL), - CONSTRAINT SYS_C0040034 CHECK ("UPDATE_TIMESTAMP" IS NOT NULL), - CONSTRAINT SYS_C0040035 CHECK ("REVISION_COUNT" IS NOT NULL) + CONSTRAINT SYS_C00170771_OPATT_CT CHECK ("OPENING_ATTACHMENT_GUID" IS NOT NULL), + CONSTRAINT SYS_C0040027_OPATT_CT CHECK ("OPENING_ATTACHMENT_FILE_ID" IS NOT NULL), + CONSTRAINT SYS_C0040028_OPATT_CT CHECK ("OPENING_ID" IS NOT NULL), + CONSTRAINT SYS_C0040029_OPATT_CT CHECK ("ATTACHMENT_NAME" IS NOT NULL), + CONSTRAINT SYS_C0040030_OPATT_CT CHECK ("ATTACHMENT_DATA" IS NOT NULL), + CONSTRAINT SYS_C0040031_OPATT_CT CHECK ("ENTRY_USERID" IS NOT NULL), + CONSTRAINT SYS_C0040032_OPATT_CT CHECK ("ENTRY_TIMESTAMP" IS NOT NULL), + CONSTRAINT SYS_C0040033_OPATT_CT CHECK ("UPDATE_USERID" IS NOT NULL), + CONSTRAINT SYS_C0040034_OPATT_CT CHECK ("UPDATE_TIMESTAMP" IS NOT NULL), + CONSTRAINT SYS_C0040035_OPATT_CT CHECK ("REVISION_COUNT" IS NOT NULL) ); CREATE INDEX OA_MTC_FK_I ON THE.OPENING_ATTACHMENT (MIME_TYPE_CODE); CREATE INDEX OA_O_FK_I ON THE.OPENING_ATTACHMENT (OPENING_ID); - CREATE TABLE THE.OPENING ( OPENING_ID NUMBER(10,0), GEO_DISTRICT_NO NUMBER(10,0), @@ -117,16 +259,16 @@ CREATE TABLE THE.OPENING ( UPDATE_TIMESTAMP DATE, REVISION_COUNT NUMBER(5,0), CONSTRAINT O_PK PRIMARY KEY (OPENING_ID), - CONSTRAINT SYS_C0039363 CHECK ("OPENING_ID" IS NOT NULL), - CONSTRAINT SYS_C0039364 CHECK ("GEO_DISTRICT_NO" IS NOT NULL), - CONSTRAINT SYS_C0039365 CHECK ("ADMIN_DISTRICT_NO" IS NOT NULL), - CONSTRAINT SYS_C0039366 CHECK ("OPEN_CATEGORY_CODE" IS NOT NULL), - CONSTRAINT SYS_C0039367 CHECK ("OPENING_STATUS_CODE" IS NOT NULL), - CONSTRAINT SYS_C0039368 CHECK ("ENTRY_USERID" IS NOT NULL), - CONSTRAINT SYS_C0039369 CHECK ("ENTRY_TIMESTAMP" IS NOT NULL), - CONSTRAINT SYS_C0039370 CHECK ("UPDATE_USERID" IS NOT NULL), - CONSTRAINT SYS_C0039371 CHECK ("UPDATE_TIMESTAMP" IS NOT NULL), - CONSTRAINT SYS_C0039372 CHECK ("REVISION_COUNT" IS NOT NULL) + CONSTRAINT SYS_C0039363_O_CT CHECK ("OPENING_ID" IS NOT NULL), + CONSTRAINT SYS_C0039364_O_CT CHECK ("GEO_DISTRICT_NO" IS NOT NULL), + CONSTRAINT SYS_C0039365_O_CT CHECK ("ADMIN_DISTRICT_NO" IS NOT NULL), + CONSTRAINT SYS_C0039366_O_CT CHECK ("OPEN_CATEGORY_CODE" IS NOT NULL), + CONSTRAINT SYS_C0039367_O_CT CHECK ("OPENING_STATUS_CODE" IS NOT NULL), + CONSTRAINT SYS_C0039368_O_CT CHECK ("ENTRY_USERID" IS NOT NULL), + CONSTRAINT SYS_C0039369_O_CT CHECK ("ENTRY_TIMESTAMP" IS NOT NULL), + CONSTRAINT SYS_C0039370_O_CT CHECK ("UPDATE_USERID" IS NOT NULL), + CONSTRAINT SYS_C0039371_O_CT CHECK ("UPDATE_TIMESTAMP" IS NOT NULL), + CONSTRAINT SYS_C0039372_O_CT CHECK ("REVISION_COUNT" IS NOT NULL) ); CREATE INDEX O_LICENSEE_ID_I ON THE.OPENING (LICENSEE_OPENING_ID); CREATE INDEX O_OPENING_NUMBER_I ON THE.OPENING (MAPSHEET_GRID,MAPSHEET_LETTER,MAPSHEET_QUAD,MAPSHEET_SQUARE,MAPSHEET_SUB_QUAD,OPENING_NUMBER); @@ -134,7 +276,6 @@ CREATE INDEX O_OPEN_CATEGORY_CODE_I ON THE.OPENING (OPEN_CATEGORY_CODE); CREATE INDEX O_OU_FK_I ON THE.OPENING (ADMIN_DISTRICT_NO); CREATE INDEX O_STATUS_I ON THE.OPENING (OPENING_STATUS_CODE); - CREATE TABLE THE.ORG_UNIT ( ORG_UNIT_NO NUMBER(10,0), ORG_UNIT_CODE VARCHAR2(6), @@ -152,20 +293,20 @@ CREATE TABLE THE.ORG_UNIT ( EXPIRY_DATE DATE, UPDATE_TIMESTAMP DATE, CONSTRAINT ORG_UNIT_PK PRIMARY KEY (ORG_UNIT_NO), - CONSTRAINT SYS_C0035144 CHECK ("ORG_UNIT_NO" IS NOT NULL), - CONSTRAINT SYS_C0035146 CHECK ("ORG_UNIT_CODE" IS NOT NULL), - CONSTRAINT SYS_C0035148 CHECK ("ORG_UNIT_NAME" IS NOT NULL), - CONSTRAINT SYS_C0035150 CHECK ("LOCATION_CODE" IS NOT NULL), - CONSTRAINT SYS_C0035152 CHECK ("AREA_CODE" IS NOT NULL), - CONSTRAINT SYS_C0035154 CHECK ("TELEPHONE_NO" IS NOT NULL), - CONSTRAINT SYS_C0035156 CHECK ("ORG_LEVEL_CODE" IS NOT NULL), - CONSTRAINT SYS_C0035158 CHECK ("OFFICE_NAME_CODE" IS NOT NULL), - CONSTRAINT SYS_C0035160 CHECK ("ROLLUP_REGION_NO" IS NOT NULL), - CONSTRAINT SYS_C0035162 CHECK ("ROLLUP_REGION_CODE" IS NOT NULL), - CONSTRAINT SYS_C0035164 CHECK ("ROLLUP_DIST_NO" IS NOT NULL), - CONSTRAINT SYS_C0035166 CHECK ("ROLLUP_DIST_CODE" IS NOT NULL), - CONSTRAINT SYS_C0035168 CHECK ("EFFECTIVE_DATE" IS NOT NULL), - CONSTRAINT SYS_C0035169 CHECK ("EXPIRY_DATE" IS NOT NULL) + CONSTRAINT SYS_C0035144_OU_CT CHECK ("ORG_UNIT_NO" IS NOT NULL), + CONSTRAINT SYS_C0035146_OU_CT CHECK ("ORG_UNIT_CODE" IS NOT NULL), + CONSTRAINT SYS_C0035148_OU_CT CHECK ("ORG_UNIT_NAME" IS NOT NULL), + CONSTRAINT SYS_C0035150_OU_CT CHECK ("LOCATION_CODE" IS NOT NULL), + CONSTRAINT SYS_C0035152_OU_CT CHECK ("AREA_CODE" IS NOT NULL), + CONSTRAINT SYS_C0035154_OU_CT CHECK ("TELEPHONE_NO" IS NOT NULL), + CONSTRAINT SYS_C0035156_OU_CT CHECK ("ORG_LEVEL_CODE" IS NOT NULL), + CONSTRAINT SYS_C0035158_OU_CT CHECK ("OFFICE_NAME_CODE" IS NOT NULL), + CONSTRAINT SYS_C0035160_OU_CT CHECK ("ROLLUP_REGION_NO" IS NOT NULL), + CONSTRAINT SYS_C0035162_OU_CT CHECK ("ROLLUP_REGION_CODE" IS NOT NULL), + CONSTRAINT SYS_C0035164_OU_CT CHECK ("ROLLUP_DIST_NO" IS NOT NULL), + CONSTRAINT SYS_C0035166_OU_CT CHECK ("ROLLUP_DIST_CODE" IS NOT NULL), + CONSTRAINT SYS_C0035168_OU_CT CHECK ("EFFECTIVE_DATE" IS NOT NULL), + CONSTRAINT SYS_C0035169_OU_CT CHECK ("EXPIRY_DATE" IS NOT NULL) ); CREATE UNIQUE INDEX "I2$_ORG_UNIT" ON THE.ORG_UNIT (ORG_UNIT_CODE,ORG_UNIT_NO); CREATE UNIQUE INDEX "I3$_ORG_UNIT" ON THE.ORG_UNIT (ORG_UNIT_CODE); @@ -176,7 +317,6 @@ CREATE INDEX "I7$_ORG_UNIT" ON THE.ORG_UNIT (ROLLUP_REGION_CODE,ROLLUP_DIST_CODE CREATE UNIQUE INDEX "I8$_ORG_UNIT" ON THE.ORG_UNIT (ORG_UNIT_NO,ORG_UNIT_CODE); CREATE UNIQUE INDEX "I9$_ORG_UNIT" ON THE.ORG_UNIT (ORG_UNIT_CODE,ORG_LEVEL_CODE,ORG_UNIT_NO,ORG_UNIT_NAME); - CREATE TABLE THE.RESULTS_ELECTRONIC_SUBMISSION ( RESULTS_SUBMISSION_ID NUMBER(10,0), SUBMISSION_TIMESTAMP DATE, @@ -192,56 +332,14 @@ CREATE TABLE THE.RESULTS_ELECTRONIC_SUBMISSION ( UPDATE_TIMESTAMP DATE, REVISION_COUNT NUMBER(5,0), CONSTRAINT RES_PK PRIMARY KEY (RESULTS_SUBMISSION_ID), - CONSTRAINT SYS_C008001 CHECK ("RESULTS_SUBMISSION_ID" IS NOT NULL), - CONSTRAINT SYS_C008002 CHECK ("SUBMISSION_TIMESTAMP" IS NOT NULL), - CONSTRAINT SYS_C008003 CHECK ("SUBMITTED_BY" IS NOT NULL), - CONSTRAINT SYS_C008004 CHECK ("ENTRY_USERID" IS NOT NULL), - CONSTRAINT SYS_C008005 CHECK ("ENTRY_TIMESTAMP" IS NOT NULL), - CONSTRAINT SYS_C008006 CHECK ("UPDATE_USERID" IS NOT NULL), - CONSTRAINT SYS_C008007 CHECK ("UPDATE_TIMESTAMP" IS NOT NULL), - CONSTRAINT SYS_C008008 CHECK ("REVISION_COUNT" IS NOT NULL) -); - -CREATE TABLE THE.AGE_CLASS_CODE ( - AGE_CLASS_CODE VARCHAR2(1), - DESCRIPTION VARCHAR2(120), - EFFECTIVE_DATE DATE, - EXPIRY_DATE DATE, - UPDATE_TIMESTAMP DATE, - CONSTRAINT ACC_PK PRIMARY KEY (AGE_CLASS_CODE), - CONSTRAINT SYS_C007687 CHECK ("AGE_CLASS_CODE" IS NOT NULL), - CONSTRAINT SYS_C007689 CHECK ("DESCRIPTION" IS NOT NULL), - CONSTRAINT SYS_C007690 CHECK ("EFFECTIVE_DATE" IS NOT NULL), - CONSTRAINT SYS_C007691 CHECK ("EXPIRY_DATE" IS NOT NULL), - CONSTRAINT SYS_C007692 CHECK ("UPDATE_TIMESTAMP" IS NOT NULL) -); - -CREATE TABLE THE.HEIGHT_CLASS_CODE ( - HEIGHT_CLASS_CODE VARCHAR2(1), - DESCRIPTION VARCHAR2(120), - EFFECTIVE_DATE DATE, - EXPIRY_DATE DATE, - UPDATE_TIMESTAMP DATE, - CONSTRAINT HCC_PK PRIMARY KEY (HEIGHT_CLASS_CODE), - CONSTRAINT SYS_C0039387 CHECK ("HEIGHT_CLASS_CODE" IS NOT NULL), - CONSTRAINT SYS_C0039388 CHECK ("DESCRIPTION" IS NOT NULL), - CONSTRAINT SYS_C0039389 CHECK ("EFFECTIVE_DATE" IS NOT NULL), - CONSTRAINT SYS_C0039390 CHECK ("EXPIRY_DATE" IS NOT NULL), - CONSTRAINT SYS_C0039391 CHECK ("UPDATE_TIMESTAMP" IS NOT NULL) -); - -CREATE TABLE THE.OPENING_STATUS_CODE ( - OPENING_STATUS_CODE VARCHAR2(3), - DESCRIPTION VARCHAR2(120), - EFFECTIVE_DATE DATE, - EXPIRY_DATE DATE, - UPDATE_TIMESTAMP DATE, - CONSTRAINT OSC_PK PRIMARY KEY (OPENING_STATUS_CODE), - CONSTRAINT SYS_C008336 CHECK ("OPENING_STATUS_CODE" IS NOT NULL), - CONSTRAINT SYS_C008337 CHECK ("DESCRIPTION" IS NOT NULL), - CONSTRAINT SYS_C008338 CHECK ("EFFECTIVE_DATE" IS NOT NULL), - CONSTRAINT SYS_C008339 CHECK ("EXPIRY_DATE" IS NOT NULL), - CONSTRAINT SYS_C008340 CHECK ("UPDATE_TIMESTAMP" IS NOT NULL) + CONSTRAINT SYS_C008001_RES_CT CHECK ("RESULTS_SUBMISSION_ID" IS NOT NULL), + CONSTRAINT SYS_C008002_RES_CT CHECK ("SUBMISSION_TIMESTAMP" IS NOT NULL), + CONSTRAINT SYS_C008003_RES_CT CHECK ("SUBMITTED_BY" IS NOT NULL), + CONSTRAINT SYS_C008004_RES_CT CHECK ("ENTRY_USERID" IS NOT NULL), + CONSTRAINT SYS_C008005_RES_CT CHECK ("ENTRY_TIMESTAMP" IS NOT NULL), + CONSTRAINT SYS_C008006_RES_CT CHECK ("UPDATE_USERID" IS NOT NULL), + CONSTRAINT SYS_C008007_RES_CT CHECK ("UPDATE_TIMESTAMP" IS NOT NULL), + CONSTRAINT SYS_C008008_RES_CT CHECK ("REVISION_COUNT" IS NOT NULL) ); CREATE TABLE THE.SILV_ADMIN_ZONE ( @@ -250,96 +348,275 @@ CREATE TABLE THE.SILV_ADMIN_ZONE ( ADMIN_ZONE_DESC VARCHAR2(50), REVISION_COUNT NUMBER(5,0), CONSTRAINT SILV_ADMIN_ZONE_PK PRIMARY KEY (ORG_UNIT_NO,DIST_ADMIN_ZONE), - CONSTRAINT SYS_C007705 CHECK ("DIST_ADMIN_ZONE" IS NOT NULL), - CONSTRAINT SYS_C007706 CHECK ("ORG_UNIT_NO" IS NOT NULL), - CONSTRAINT SYS_C007707 CHECK ("ADMIN_ZONE_DESC" IS NOT NULL), - CONSTRAINT SYS_C007708 CHECK ("REVISION_COUNT" IS NOT NULL), + CONSTRAINT SYS_C007705_SAZ_CT CHECK ("DIST_ADMIN_ZONE" IS NOT NULL), + CONSTRAINT SYS_C007706_SAZ_CT CHECK ("ORG_UNIT_NO" IS NOT NULL), + CONSTRAINT SYS_C007707_SAZ_CT CHECK ("ADMIN_ZONE_DESC" IS NOT NULL), + CONSTRAINT SYS_C007708_SAZ_CT CHECK ("REVISION_COUNT" IS NOT NULL), CONSTRAINT SAZ_OU_FK FOREIGN KEY (ORG_UNIT_NO) REFERENCES THE.ORG_UNIT(ORG_UNIT_NO) ); -CREATE TABLE THE.STOCKING_CLASS_CODE ( - STOCKING_CLASS_CODE VARCHAR2(1), - DESCRIPTION VARCHAR2(120), - EFFECTIVE_DATE DATE, - EXPIRY_DATE DATE, +CREATE TABLE THE.OPENING_AMENDMENT_HISTORY ( + OPENING_ID NUMBER(10,0), + OPENING_AMENDMENT_NUMBER NUMBER(5,0), + AMENDMENT_USERID VARCHAR2(30), + AMENDMENT_DATE DATE, + SUBMITTED_BY_USERID VARCHAR2(30), + SUBMITTED_DATE DATE, + APP_ENT_BY_USERID VARCHAR2(30), + APPROVE_DATE DATE, + ENTRY_USERID VARCHAR2(30), + ENTRY_TIMESTAMP DATE, + UPDATE_USERID VARCHAR2(30), UPDATE_TIMESTAMP DATE, - CONSTRAINT SCC1_PK PRIMARY KEY (STOCKING_CLASS_CODE), - CONSTRAINT SYS_C008214 CHECK ("STOCKING_CLASS_CODE" IS NOT NULL), - CONSTRAINT SYS_C008215 CHECK ("DESCRIPTION" IS NOT NULL), - CONSTRAINT SYS_C008216 CHECK ("EFFECTIVE_DATE" IS NOT NULL), - CONSTRAINT SYS_C008217 CHECK ("EXPIRY_DATE" IS NOT NULL), - CONSTRAINT SYS_C008218 CHECK ("UPDATE_TIMESTAMP" IS NOT NULL) + REVISION_COUNT NUMBER(5,0), + CONSTRAINT OAH_PK PRIMARY KEY (OPENING_ID,OPENING_AMENDMENT_NUMBER), + CONSTRAINT SYS_C0026176_OAH_CT CHECK ("OPENING_ID" IS NOT NULL), + CONSTRAINT SYS_C0026178_OAH_CT CHECK ("OPENING_AMENDMENT_NUMBER" IS NOT NULL), + CONSTRAINT SYS_C0026181_OAH_CT CHECK ("AMENDMENT_USERID" IS NOT NULL), + CONSTRAINT SYS_C0026184_OAH_CT CHECK ("AMENDMENT_DATE" IS NOT NULL), + CONSTRAINT SYS_C0026187_OAH_CT CHECK ("ENTRY_USERID" IS NOT NULL), + CONSTRAINT SYS_C0026190_OAH_CT CHECK ("ENTRY_TIMESTAMP" IS NOT NULL), + CONSTRAINT SYS_C0026193_OAH_CT CHECK ("UPDATE_USERID" IS NOT NULL), + CONSTRAINT SYS_C0026196_OAH_CT CHECK ("UPDATE_TIMESTAMP" IS NOT NULL), + CONSTRAINT SYS_C0026199_OAH_CT CHECK ("REVISION_COUNT" IS NOT NULL) ); -CREATE TABLE THE.SITE_CLASS_CODE ( - SITE_CLASS_CODE VARCHAR2(1), - DESCRIPTION VARCHAR2(120), - EFFECTIVE_DATE DATE, - EXPIRY_DATE DATE, - UPDATE_TIMESTAMP DATE, - CONSTRAINT SITE_CLASS_CODE_PK PRIMARY KEY (SITE_CLASS_CODE), - CONSTRAINT SYS_C008260 CHECK ("SITE_CLASS_CODE" IS NOT NULL), - CONSTRAINT SYS_C008262 CHECK ("DESCRIPTION" IS NOT NULL), - CONSTRAINT SYS_C008264 CHECK ("EFFECTIVE_DATE" IS NOT NULL), - CONSTRAINT SYS_C008265 CHECK ("EXPIRY_DATE" IS NOT NULL), - CONSTRAINT SYS_C008266 CHECK ("UPDATE_TIMESTAMP" IS NOT NULL) +CREATE TABLE THE.STOCKING_EVENT_HISTORY ( + STOCKING_EVENT_HISTORY_ID NUMBER(10,0), + OPENING_ID NUMBER(10,0), + OPENING_AMENDMENT_ID NUMBER(10,0), + OPENING_AMENDMENT_NUMBER NUMBER(5,0), + RESULTS_AUDIT_ACTION_CODE VARCHAR2(3), + SUBMITTED_USERID VARCHAR2(30), + RESULTS_SUBMISSION_ID NUMBER(10,0), + AMEND_EVENT_TIMESTAMP DATE, + ENTRY_USERID VARCHAR2(30), + ENTRY_TIMESTAMP DATE, + REVISION_COUNT NUMBER(5,0), + CONSTRAINT SEH_PK PRIMARY KEY (STOCKING_EVENT_HISTORY_ID), + CONSTRAINT SYS_C0016112_SEH_CT CHECK ("STOCKING_EVENT_HISTORY_ID" IS NOT NULL), + CONSTRAINT SYS_C0016113_SEH_CT CHECK ("OPENING_ID" IS NOT NULL), + CONSTRAINT SYS_C0016114_SEH_CT CHECK ("RESULTS_AUDIT_ACTION_CODE" IS NOT NULL), + CONSTRAINT SYS_C0016115_SEH_CT CHECK ("AMEND_EVENT_TIMESTAMP" IS NOT NULL), + CONSTRAINT SYS_C0016116_SEH_CT CHECK ("ENTRY_USERID" IS NOT NULL), + CONSTRAINT SYS_C0016117_SEH_CT CHECK ("ENTRY_TIMESTAMP" IS NOT NULL), + CONSTRAINT SYS_C0016118_SEH_CT CHECK ("REVISION_COUNT" IS NOT NULL) ); +CREATE INDEX SEH_OAH_FK_I ON THE.STOCKING_EVENT_HISTORY (OPENING_AMENDMENT_ID,OPENING_AMENDMENT_NUMBER); +CREATE INDEX SEH_O_FK_I ON THE.STOCKING_EVENT_HISTORY (OPENING_ID); -CREATE TABLE THE.SITE_INDEX_SOURCE_CODE ( - SITE_INDEX_SOURCE_CODE VARCHAR2(1), - DESCRIPTION VARCHAR2(120), - EFFECTIVE_DATE DATE, - EXPIRY_DATE DATE, +CREATE TABLE THE.RESULTS_AUDIT_EVENT ( + RESULTS_AUDIT_EVENT_ID NUMBER(10,0), + OPENING_ID NUMBER(10,0), + STANDARDS_REGIME_ID NUMBER(10,0), + SILVICULTURE_PROJECT_ID NUMBER(10,0), + RESULTS_AUDIT_ACTION_CODE VARCHAR2(3), + ACTION_DATE DATE, + DESCRIPTION VARCHAR2(2000), + USER_ID VARCHAR2(30), + EMAIL_SENT_IND VARCHAR2(1), + XML_SUBMISSION_ID NUMBER(10,0), + OPENING_AMENDMENT_NUMBER NUMBER(5,0), + ENTRY_USERID VARCHAR2(30), + ENTRY_TIMESTAMP DATE, + CONSTRAINT RAE_PK PRIMARY KEY (RESULTS_AUDIT_EVENT_ID), + CONSTRAINT SYS_C0026137_RAE_CT CHECK ("RESULTS_AUDIT_EVENT_ID" IS NOT NULL), + CONSTRAINT SYS_C0026138_RAE_CT CHECK ("RESULTS_AUDIT_ACTION_CODE" IS NOT NULL), + CONSTRAINT SYS_C0026139_RAE_CT CHECK ("ACTION_DATE" IS NOT NULL), + CONSTRAINT SYS_C0026140_RAE_CT CHECK ("ENTRY_USERID" IS NOT NULL), + CONSTRAINT SYS_C0026141_RAE_CT CHECK ("ENTRY_TIMESTAMP" IS NOT NULL), + CONSTRAINT RAE_RAAC_FK FOREIGN KEY (RESULTS_AUDIT_ACTION_CODE) REFERENCES THE.RESULTS_AUDIT_ACTION_CODE(RESULTS_AUDIT_ACTION_CODE) +); + +CREATE TABLE THE.ACTIVITY_TREATMENT_UNIT ( + ACTIVITY_TREATMENT_UNIT_ID NUMBER(10,0), + ACTIVITY_TU_SEQ_NO NUMBER(5,0), + ORG_UNIT_NO NUMBER(10,0), + OPENING_ID NUMBER(10,0), + SILVICULTURE_PROJECT_ID NUMBER(10,0), + PROJECT_UNIT_ID NUMBER(6,0), + SILV_BASE_CODE VARCHAR2(2), + SILV_TECHNIQUE_CODE VARCHAR2(2), + SILV_METHOD_CODE VARCHAR2(5), + SILV_OBJECTIVE_CODE_1 VARCHAR2(3), + SILV_OBJECTIVE_CODE_2 VARCHAR2(3), + SILV_OBJECTIVE_CODE_3 VARCHAR2(3), + SILV_FUND_SRCE_CODE VARCHAR2(3), + SILV_ACTIVITY_MEASUREMENT_CODE VARCHAR2(3), + ACTIVITY_LICENSEE_ID VARCHAR2(30), + TREATMENT_AMOUNT NUMBER(11,1), + ACTUAL_TREATMENT_COST NUMBER(9,0), + ACT_PLANTED_NO NUMBER(10,0), + PLAN_SILV_TECHNIQUE_CODE VARCHAR2(2), + PLAN_SILV_METHOD_CODE VARCHAR2(5), + PLAN_SILV_FUND_SRCE_CODE VARCHAR2(3), + PLANNED_DATE DATE, + PLANNED_TREATMENT_AMOUNT NUMBER(11,1), + PLANNED_TREATMENT_COST NUMBER(9,0), + PLAN_SILV_OBJECTIVE_CODE_1 VARCHAR2(3), + PLAN_SILV_OBJECTIVE_CODE_2 VARCHAR2(3), + PLAN_SILV_OBJECTIVE_CODE_3 VARCHAR2(3), + TARGET_PREPARED_SPOTS NUMBER(4,0), + PRUNING_MIN_CROWN_PCT NUMBER(3,0), + PRUNE_HEIGHT NUMBER(3,1), + STEMS_TO_PRUNE NUMBER(4,0), + MIN_ACCEPTABLE_DENSITY NUMBER(4,0), + TOTAL_STEMS_PER_HA NUMBER(4,0), + INTER_TREE_TARGET_DISTANCE NUMBER(3,1), + INTER_TREE_VARIATION NUMBER(3,1), + INTER_TREE_MIN_DISTANCE NUMBER(3,1), + MAX_TREES_PER_PLOT NUMBER(2,0), + MAX_TREES_PER_HA NUMBER(4,0), + SURVEY_PLANNED_NUM_PLOTS NUMBER(4,0), + SURVEY_ACTUAL_NUM_PLOTS NUMBER(4,0), + SURVEY_MIN_PLOTS_PER_STRATUM NUMBER(10,0), + SILV_TREE_SPECIES_CODE VARCHAR2(8), + ATU_START_DATE DATE, + ATU_COMPLETION_DATE DATE, + RESULTS_IND VARCHAR2(1), + UNIT_BID_PRICE NUMBER(9,2), + FIA_PROJECT_ID VARCHAR2(10), + RESULTS_SUBMISSION_ID NUMBER(10,0), + DISTURBANCE_CODE VARCHAR2(3), + SILV_SYSTEM_CODE VARCHAR2(5), + SILV_SYSTEM_VARIANT_CODE VARCHAR2(3), + SILV_CUT_PHASE_CODE VARCHAR2(5), + CUT_BLOCK_OPEN_ADMIN_ID NUMBER(10,0), + DISTURBANCE_COMPLETED_IND VARCHAR2(1), + ENTRY_USERID VARCHAR2(30), + ENTRY_TIMESTAMP DATE, + UPDATE_USERID VARCHAR2(30), UPDATE_TIMESTAMP DATE, - CONSTRAINT SISC_PK PRIMARY KEY (SITE_INDEX_SOURCE_CODE), - CONSTRAINT SYS_C008567 CHECK ("SITE_INDEX_SOURCE_CODE" IS NOT NULL), - CONSTRAINT SYS_C008569 CHECK ("DESCRIPTION" IS NOT NULL), - CONSTRAINT SYS_C008571 CHECK ("EFFECTIVE_DATE" IS NOT NULL), - CONSTRAINT SYS_C008572 CHECK ("EXPIRY_DATE" IS NOT NULL), - CONSTRAINT SYS_C008573 CHECK ("UPDATE_TIMESTAMP" IS NOT NULL) + REVISION_COUNT NUMBER(5,0), + CONSTRAINT ATU_PK PRIMARY KEY (ACTIVITY_TREATMENT_UNIT_ID), + CONSTRAINT SYS_C0039733_ATU_CT CHECK ("ACTIVITY_TREATMENT_UNIT_ID" IS NOT NULL), + CONSTRAINT SYS_C0039734_ATU_CT CHECK ("ACTIVITY_TU_SEQ_NO" IS NOT NULL), + CONSTRAINT SYS_C0039735_ATU_CT CHECK ("ORG_UNIT_NO" IS NOT NULL), + CONSTRAINT SYS_C0039736_ATU_CT CHECK ("OPENING_ID" IS NOT NULL), + CONSTRAINT SYS_C0039737_ATU_CT CHECK ("SILV_BASE_CODE" IS NOT NULL), + CONSTRAINT SYS_C0039738_ATU_CT CHECK ("SILV_ACTIVITY_MEASUREMENT_CODE" IS NOT NULL), + CONSTRAINT SYS_C0039739_ATU_CT CHECK ("ENTRY_USERID" IS NOT NULL), + CONSTRAINT SYS_C0039740_ATU_CT CHECK ("ENTRY_TIMESTAMP" IS NOT NULL), + CONSTRAINT SYS_C0039741_ATU_CT CHECK ("UPDATE_USERID" IS NOT NULL), + CONSTRAINT SYS_C0039742_ATU_CT CHECK ("UPDATE_TIMESTAMP" IS NOT NULL), + CONSTRAINT SYS_C0039743_ATU_CT CHECK ("REVISION_COUNT" IS NOT NULL) ); +CREATE INDEX ATU_ATU_I ON THE.ACTIVITY_TREATMENT_UNIT (OPENING_ID,SILV_BASE_CODE,SILV_METHOD_CODE,SILV_TECHNIQUE_CODE,TREATMENT_AMOUNT); +CREATE INDEX ATU_BASE_I ON THE.ACTIVITY_TREATMENT_UNIT (SILV_BASE_CODE,RESULTS_IND); +CREATE INDEX ATU_CBOA_FK_I ON THE.ACTIVITY_TREATMENT_UNIT (CUT_BLOCK_OPEN_ADMIN_ID); +CREATE INDEX ATU_LICENSEE_I ON THE.ACTIVITY_TREATMENT_UNIT (ACTIVITY_LICENSEE_ID); +CREATE INDEX ATU_O_FK_I ON THE.ACTIVITY_TREATMENT_UNIT (OPENING_ID); +CREATE INDEX ATU_PROJECT_I ON THE.ACTIVITY_TREATMENT_UNIT (FIA_PROJECT_ID,RESULTS_IND); +CREATE INDEX ATU_PROJ_FK_I ON THE.ACTIVITY_TREATMENT_UNIT (SILVICULTURE_PROJECT_ID); -CREATE TABLE THE.STOCKING_STATUS_CODE ( - STOCKING_STATUS_CODE VARCHAR2(3), - DESCRIPTION VARCHAR2(120), - EFFECTIVE_DATE DATE, - EXPIRY_DATE DATE, +CREATE TABLE THE.SILV_RELIEF_APPLICATION ( + SILV_RELIEF_APPLICATION_ID NUMBER(10,0), + SILV_RELIEF_APPLICATION_NO NUMBER(3,0), + ACTIVITY_TREATMENT_UNIT_ID NUMBER(10,0), + SILV_RELIEF_APPL_STATUS_CODE VARCHAR2(3), + PRE_EVENT_FOREST_COVER_DATE DATE, + POST_EVENT_FOREST_COVER_DATE DATE, + AMENDMENT_OPENING_ID NUMBER(10,0), + OPENING_AMENDMENT_NUMBER NUMBER(5,0), + OBLIGATION_RELIEF_IND VARCHAR2(1), + OBLIGATION_MET_IND VARCHAR2(1), + CAUSE_DAMAGE_IND VARCHAR2(1), + OFFICIALLY_INDUCED_ERROR_IND VARCHAR2(1), + DUE_DILIGENCE_IND VARCHAR2(1), + AUTHORIZATION_CHECKED_IND VARCHAR2(1), + SUBMITTED_DATE DATE, + SUBMITTED_BY_USERID VARCHAR2(30), + APPROVED_DATE DATE, + APPROVED_BY_USERID VARCHAR2(30), + REJECT_COMMENT VARCHAR2(2000), + ENTRY_USERID VARCHAR2(30), + ENTRY_TIMESTAMP DATE, + UPDATE_USERID VARCHAR2(30), UPDATE_TIMESTAMP DATE, - CONSTRAINT SSC6_PK PRIMARY KEY (STOCKING_STATUS_CODE), - CONSTRAINT SYS_C007771 CHECK ("STOCKING_STATUS_CODE" IS NOT NULL), - CONSTRAINT SYS_C007772 CHECK ("DESCRIPTION" IS NOT NULL), - CONSTRAINT SYS_C007773 CHECK ("EFFECTIVE_DATE" IS NOT NULL), - CONSTRAINT SYS_C007774 CHECK ("EXPIRY_DATE" IS NOT NULL), - CONSTRAINT SYS_C007775 CHECK ("UPDATE_TIMESTAMP" IS NOT NULL) + REVISION_COUNT NUMBER(5,0), + CONSTRAINT SRA_PK PRIMARY KEY (SILV_RELIEF_APPLICATION_ID), + CONSTRAINT SYS_C0030824_SRA_CT CHECK ("SILV_RELIEF_APPLICATION_ID" IS NOT NULL), + CONSTRAINT SYS_C0030825_SRA_CT CHECK ("SILV_RELIEF_APPLICATION_NO" IS NOT NULL), + CONSTRAINT SYS_C0030826_SRA_CT CHECK ("ACTIVITY_TREATMENT_UNIT_ID" IS NOT NULL), + CONSTRAINT SYS_C0030827_SRA_CT CHECK ("SILV_RELIEF_APPL_STATUS_CODE" IS NOT NULL), + CONSTRAINT SYS_C0030828_SRA_CT CHECK ("PRE_EVENT_FOREST_COVER_DATE" IS NOT NULL), + CONSTRAINT SYS_C0030829_SRA_CT CHECK ("POST_EVENT_FOREST_COVER_DATE" IS NOT NULL), + CONSTRAINT SYS_C0030830_SRA_CT CHECK ("OBLIGATION_RELIEF_IND" IS NOT NULL), + CONSTRAINT SYS_C0030831_SRA_CT CHECK ("OBLIGATION_MET_IND" IS NOT NULL), + CONSTRAINT SYS_C0030832_SRA_CT CHECK ("CAUSE_DAMAGE_IND" IS NOT NULL), + CONSTRAINT SYS_C0030833_SRA_CT CHECK ("OFFICIALLY_INDUCED_ERROR_IND" IS NOT NULL), + CONSTRAINT SYS_C0030834_SRA_CT CHECK ("DUE_DILIGENCE_IND" IS NOT NULL), + CONSTRAINT SYS_C0030835_SRA_CT CHECK ("AUTHORIZATION_CHECKED_IND" IS NOT NULL), + CONSTRAINT SYS_C0030836_SRA_CT CHECK ("ENTRY_USERID" IS NOT NULL), + CONSTRAINT SYS_C0030837_SRA_CT CHECK ("ENTRY_TIMESTAMP" IS NOT NULL), + CONSTRAINT SYS_C0030838_SRA_CT CHECK ("UPDATE_USERID" IS NOT NULL), + CONSTRAINT SYS_C0030839_SRA_CT CHECK ("UPDATE_TIMESTAMP" IS NOT NULL), + CONSTRAINT SYS_C0030840_SRA_CT CHECK ("REVISION_COUNT" IS NOT NULL) ); +CREATE INDEX SRA_ATU_FK_I ON THE.SILV_RELIEF_APPLICATION (ACTIVITY_TREATMENT_UNIT_ID); +CREATE INDEX SRA_OAH_FK_I ON THE.SILV_RELIEF_APPLICATION (AMENDMENT_OPENING_ID,OPENING_AMENDMENT_NUMBER); +CREATE INDEX SRA_SRASCD_FK_I ON THE.SILV_RELIEF_APPLICATION (SILV_RELIEF_APPL_STATUS_CODE); -CREATE TABLE THE.TSB_NUMBER_CODE ( - TSB_NUMBER_CODE VARCHAR2(3), - DESCRIPTION VARCHAR2(120), - EFFECTIVE_DATE DATE, - EXPIRY_DATE DATE, +CREATE TABLE THE.STOCKING_STANDARD_UNIT ( + STOCKING_STANDARD_UNIT_ID NUMBER(10,0), + OPENING_ID NUMBER(10,0), + STANDARDS_UNIT_ID VARCHAR2(4), + STANDARDS_REGIME_ID NUMBER(10,0), + NET_AREA NUMBER(7,1), + MAX_ALLOW_SOIL_DISTURBANCE_PCT NUMBER(3,1), + VARIANCE_IND VARCHAR2(1), + ENTRY_USERID VARCHAR2(30), + ENTRY_TIMESTAMP DATE, + UPDATE_USERID VARCHAR2(30), UPDATE_TIMESTAMP DATE, - CONSTRAINT SYS_C0016369 CHECK ("TSB_NUMBER_CODE" IS NOT NULL), - CONSTRAINT SYS_C0016370 CHECK ("DESCRIPTION" IS NOT NULL), - CONSTRAINT SYS_C0016371 CHECK ("EFFECTIVE_DATE" IS NOT NULL), - CONSTRAINT SYS_C0016372 CHECK ("EXPIRY_DATE" IS NOT NULL), - CONSTRAINT SYS_C0016374 CHECK ("UPDATE_TIMESTAMP" IS NOT NULL), - CONSTRAINT TSBNC_PK PRIMARY KEY (TSB_NUMBER_CODE) + REVISION_COUNT NUMBER(5,0), + CONSTRAINT SSU_PK PRIMARY KEY (STOCKING_STANDARD_UNIT_ID), + CONSTRAINT SYS_C0030763_SSU_CT CHECK ("STOCKING_STANDARD_UNIT_ID" IS NOT NULL), + CONSTRAINT SYS_C0030764_SSU_CT CHECK ("OPENING_ID" IS NOT NULL), + CONSTRAINT SYS_C0030765_SSU_CT CHECK ("STANDARDS_UNIT_ID" IS NOT NULL), + CONSTRAINT SYS_C0030767_SSU_CT CHECK ("NET_AREA" IS NOT NULL), + CONSTRAINT SYS_C0030769_SSU_CT CHECK ("ENTRY_USERID" IS NOT NULL), + CONSTRAINT SYS_C0030771_SSU_CT CHECK ("ENTRY_TIMESTAMP" IS NOT NULL), + CONSTRAINT SYS_C0030773_SSU_CT CHECK ("UPDATE_USERID" IS NOT NULL), + CONSTRAINT SYS_C0030775_SSU_CT CHECK ("UPDATE_TIMESTAMP" IS NOT NULL), + CONSTRAINT SYS_C0030776_SSU_CT CHECK ("REVISION_COUNT" IS NOT NULL) ); +CREATE INDEX SSU_O_FK_I ON THE.STOCKING_STANDARD_UNIT (OPENING_ID); +CREATE INDEX SSU_SR_FK_I ON THE.STOCKING_STANDARD_UNIT (STANDARDS_REGIME_ID); +CREATE INDEX SSU_SU_I ON THE.STOCKING_STANDARD_UNIT (OPENING_ID,STANDARDS_UNIT_ID); -CREATE TABLE THE.TREE_SPECIES_CODE ( - TREE_SPECIES_CODE VARCHAR2(3), - DESCRIPTION VARCHAR2(120), - EFFECTIVE_DATE DATE, - EXPIRY_DATE DATE, +CREATE TABLE THE.STOCKING_MILESTONE ( + STOCKING_STANDARD_UNIT_ID NUMBER(10,0), + SILV_MILESTONE_TYPE_CODE VARCHAR2(3), + RESULTS_SUBMISSION_ID NUMBER(10,0), + DECLARED_DATE DATE, + DECLARED_USERID VARCHAR2(30), + DECLARE_IND VARCHAR2(1), + DECLARATION_SUBMITTED_DATE DATE, + EARLY_OFFSET_YEARS NUMBER(2,0), + LATE_OFFSET_YEARS NUMBER(2,0), + DUE_EARLY_DATE DATE, + DUE_LATE_DATE DATE, + ENTRY_USERID VARCHAR2(30), + ENTRY_TIMESTAMP DATE, + UPDATE_USERID VARCHAR2(30), UPDATE_TIMESTAMP DATE, - CONSTRAINT SYS_C0031659 CHECK ("TREE_SPECIES_CODE" IS NOT NULL), - CONSTRAINT SYS_C0031660 CHECK ("DESCRIPTION" IS NOT NULL), - CONSTRAINT SYS_C0031661 CHECK ("EFFECTIVE_DATE" IS NOT NULL), - CONSTRAINT SYS_C0031662 CHECK ("EXPIRY_DATE" IS NOT NULL), - CONSTRAINT SYS_C0031663 CHECK ("UPDATE_TIMESTAMP" IS NOT NULL), - CONSTRAINT TSC_PK PRIMARY KEY (TREE_SPECIES_CODE) + REVISION_COUNT NUMBER(5,0), + EXTENT_FEASIBLE_DECLARED_IND VARCHAR2(1) DEFAULT 'N' , + CONSTRAINT SM_PK PRIMARY KEY (STOCKING_STANDARD_UNIT_ID,SILV_MILESTONE_TYPE_CODE), + CONSTRAINT SYS_C00140760_SM_CT CHECK ("EXTENT_FEASIBLE_DECLARED_IND" IS NOT NULL), + CONSTRAINT SYS_C0026482_SM_CT CHECK ("STOCKING_STANDARD_UNIT_ID" IS NOT NULL), + CONSTRAINT SYS_C0026483_SM_CT CHECK ("SILV_MILESTONE_TYPE_CODE" IS NOT NULL), + CONSTRAINT SYS_C0026484_SM_CT CHECK ("ENTRY_USERID" IS NOT NULL), + CONSTRAINT SYS_C0026485_SM_CT CHECK ("ENTRY_TIMESTAMP" IS NOT NULL), + CONSTRAINT SYS_C0026486_SM_CT CHECK ("UPDATE_USERID" IS NOT NULL), + CONSTRAINT SYS_C0026487_SM_CT CHECK ("UPDATE_TIMESTAMP" IS NOT NULL), + CONSTRAINT SYS_C0026488_SM_CT CHECK ("REVISION_COUNT" IS NOT NULL) ); +CREATE INDEX SM_DED_I ON THE.STOCKING_MILESTONE (DUE_EARLY_DATE); +CREATE INDEX SM_DLD_I ON THE.STOCKING_MILESTONE (DUE_LATE_DATE); + +-- Foreign keys references. Some are commented due to the table not being onboarded yet or due to the table belonging to another application --- There is some FK references that are not properly identified in the model --- ALTER TABLE THE.CUT_BLOCK_OPEN_ADMIN ADD CONSTRAINT CBOA_CB_FK FOREIGN KEY (CB_SKEY) REFERENCES (); @@ -369,8 +646,48 @@ ALTER TABLE THE.OPENING ADD CONSTRAINT O_TSC2_FK FOREIGN KEY (PREV_TREE_SPP2_COD --ALTER TABLE THE.RESULTS_ELECTRONIC_SUBMISSION ADD CONSTRAINT RES_CN_FK FOREIGN KEY (CLIENT_NUMBER,CLIENT_LOCN_CODE) REFERENCES (); ALTER TABLE THE.RESULTS_ELECTRONIC_SUBMISSION ADD CONSTRAINT RES_OU_FK FOREIGN KEY (ORG_UNIT_NO) REFERENCES THE.ORG_UNIT(ORG_UNIT_NO); +ALTER TABLE THE.STOCKING_EVENT_HISTORY ADD CONSTRAINT SEH_OAH_FK FOREIGN KEY (OPENING_AMENDMENT_ID,OPENING_AMENDMENT_NUMBER) REFERENCES THE.OPENING_AMENDMENT_HISTORY(OPENING_ID,OPENING_AMENDMENT_NUMBER); +ALTER TABLE THE.STOCKING_EVENT_HISTORY ADD CONSTRAINT SEH_O_FK FOREIGN KEY (OPENING_ID) REFERENCES THE.OPENING(OPENING_ID); +ALTER TABLE THE.STOCKING_EVENT_HISTORY ADD CONSTRAINT SEH_RAAC_FK FOREIGN KEY (RESULTS_AUDIT_ACTION_CODE) REFERENCES THE.RESULTS_AUDIT_ACTION_CODE(RESULTS_AUDIT_ACTION_CODE); + + +ALTER TABLE THE.ACTIVITY_TREATMENT_UNIT ADD CONSTRAINT ATU_CBOA_FK FOREIGN KEY (CUT_BLOCK_OPEN_ADMIN_ID) REFERENCES THE.CUT_BLOCK_OPEN_ADMIN(CUT_BLOCK_OPEN_ADMIN_ID); +--ALTER TABLE THE.ACTIVITY_TREATMENT_UNIT ADD CONSTRAINT ATU_DC_FK FOREIGN KEY (DISTURBANCE_CODE) REFERENCES THE.DISTURBANCE_CODE(DISTURBANCE_CODE); +ALTER TABLE THE.ACTIVITY_TREATMENT_UNIT ADD CONSTRAINT ATU_OU_FK FOREIGN KEY (ORG_UNIT_NO) REFERENCES THE.ORG_UNIT(ORG_UNIT_NO); +ALTER TABLE THE.ACTIVITY_TREATMENT_UNIT ADD CONSTRAINT ATU_O_FK FOREIGN KEY (OPENING_ID) REFERENCES THE.OPENING(OPENING_ID); +--ALTER TABLE THE.ACTIVITY_TREATMENT_UNIT ADD CONSTRAINT ATU_PROJ_FK FOREIGN KEY (SILVICULTURE_PROJECT_ID) REFERENCES THE.SILVICULTURE_PROJECT(SILVICULTURE_PROJECT_ID); +ALTER TABLE THE.ACTIVITY_TREATMENT_UNIT ADD CONSTRAINT ATU_RES_FK FOREIGN KEY (RESULTS_SUBMISSION_ID) REFERENCES THE.RESULTS_ELECTRONIC_SUBMISSION(RESULTS_SUBMISSION_ID); +--ALTER TABLE THE.ACTIVITY_TREATMENT_UNIT ADD CONSTRAINT ATU_SAM_FK FOREIGN KEY (SILV_ACTIVITY_MEASUREMENT_CODE) REFERENCES THE.SILV_ACTIVITY_MEASUREMENT_CODE(SILV_ACTIVITY_MEASUREMENT_CODE); +--ALTER TABLE THE.ACTIVITY_TREATMENT_UNIT ADD CONSTRAINT ATU_SBC_FK FOREIGN KEY (SILV_BASE_CODE) REFERENCES THE.SILV_BASE_CODE(SILV_BASE_CODE); +--ALTER TABLE THE.ACTIVITY_TREATMENT_UNIT ADD CONSTRAINT ATU_SCPC_FK FOREIGN KEY (SILV_CUT_PHASE_CODE) REFERENCES THE.SILV_CUT_PHASE_CODE(SILV_CUT_PHASE_CODE); +--ALTER TABLE THE.ACTIVITY_TREATMENT_UNIT ADD CONSTRAINT ATU_SFSC_FK FOREIGN KEY (SILV_FUND_SRCE_CODE) REFERENCES THE.SILV_FUND_SRCE_CODE(SILV_FUND_SRCE_CODE); +--ALTER TABLE THE.ACTIVITY_TREATMENT_UNIT ADD CONSTRAINT ATU_SFSC_PLND_FK FOREIGN KEY (PLAN_SILV_FUND_SRCE_CODE) REFERENCES THE.SILV_FUND_SRCE_CODE(SILV_FUND_SRCE_CODE); +--ALTER TABLE THE.ACTIVITY_TREATMENT_UNIT ADD CONSTRAINT ATU_SMC_FK FOREIGN KEY (SILV_METHOD_CODE) REFERENCES THE.SILV_METHOD_CODE(SILV_METHOD_CODE); +--ALTER TABLE THE.ACTIVITY_TREATMENT_UNIT ADD CONSTRAINT ATU_SMC_PLND_FK FOREIGN KEY (PLAN_SILV_METHOD_CODE) REFERENCES THE.SILV_METHOD_CODE(SILV_METHOD_CODE); +--ALTER TABLE THE.ACTIVITY_TREATMENT_UNIT ADD CONSTRAINT ATU_SOC1_FK FOREIGN KEY (SILV_OBJECTIVE_CODE_1) REFERENCES THE.SILV_OBJECTIVE_CODE(SILV_OBJECTIVE_CODE); +--ALTER TABLE THE.ACTIVITY_TREATMENT_UNIT ADD CONSTRAINT ATU_SOC2_FK FOREIGN KEY (SILV_OBJECTIVE_CODE_2) REFERENCES THE.SILV_OBJECTIVE_CODE(SILV_OBJECTIVE_CODE); +--ALTER TABLE THE.ACTIVITY_TREATMENT_UNIT ADD CONSTRAINT ATU_SOC3_FK FOREIGN KEY (SILV_OBJECTIVE_CODE_3) REFERENCES THE.SILV_OBJECTIVE_CODE(SILV_OBJECTIVE_CODE); +--ALTER TABLE THE.ACTIVITY_TREATMENT_UNIT ADD CONSTRAINT ATU_SOC_PLND1_FK FOREIGN KEY (PLAN_SILV_OBJECTIVE_CODE_1) REFERENCES THE.SILV_OBJECTIVE_CODE(SILV_OBJECTIVE_CODE); +--ALTER TABLE THE.ACTIVITY_TREATMENT_UNIT ADD CONSTRAINT ATU_SOC_PLND2_FK FOREIGN KEY (PLAN_SILV_OBJECTIVE_CODE_2) REFERENCES THE.SILV_OBJECTIVE_CODE(SILV_OBJECTIVE_CODE); +--ALTER TABLE THE.ACTIVITY_TREATMENT_UNIT ADD CONSTRAINT ATU_SOC_PLND3_FK FOREIGN KEY (PLAN_SILV_OBJECTIVE_CODE_3) REFERENCES THE.SILV_OBJECTIVE_CODE(SILV_OBJECTIVE_CODE); +--ALTER TABLE THE.ACTIVITY_TREATMENT_UNIT ADD CONSTRAINT ATU_SSC_FK FOREIGN KEY (SILV_SYSTEM_CODE) REFERENCES THE.SILV_SYSTEM_CODE(SILV_SYSTEM_CODE); +--ALTER TABLE THE.ACTIVITY_TREATMENT_UNIT ADD CONSTRAINT ATU_SSVC_FK FOREIGN KEY (SILV_SYSTEM_VARIANT_CODE) REFERENCES THE.SILV_SYSTEM_VARIANT_CODE(SILV_SYSTEM_VARIANT_CODE); +--ALTER TABLE THE.ACTIVITY_TREATMENT_UNIT ADD CONSTRAINT ATU_STC_FK FOREIGN KEY (SILV_TECHNIQUE_CODE) REFERENCES THE.SILV_TECHNIQUE_CODE(SILV_TECHNIQUE_CODE); +--ALTER TABLE THE.ACTIVITY_TREATMENT_UNIT ADD CONSTRAINT ATU_STC_PLND_FK FOREIGN KEY (PLAN_SILV_TECHNIQUE_CODE) REFERENCES THE.SILV_TECHNIQUE_CODE(SILV_TECHNIQUE_CODE); +--ALTER TABLE THE.ACTIVITY_TREATMENT_UNIT ADD CONSTRAINT ATU_STSC_FK FOREIGN KEY (SILV_TREE_SPECIES_CODE) REFERENCES THE.SILV_TREE_SPECIES_CODE(SILV_TREE_SPECIES_CODE); + +-- THE.SILV_RELIEF_APPLICATION foreign keys + +ALTER TABLE THE.SILV_RELIEF_APPLICATION ADD CONSTRAINT SRA_ATU_FK FOREIGN KEY (ACTIVITY_TREATMENT_UNIT_ID) REFERENCES THE.ACTIVITY_TREATMENT_UNIT(ACTIVITY_TREATMENT_UNIT_ID); +ALTER TABLE THE.SILV_RELIEF_APPLICATION ADD CONSTRAINT SRA_OAH_FK FOREIGN KEY (AMENDMENT_OPENING_ID,OPENING_AMENDMENT_NUMBER) REFERENCES THE.OPENING_AMENDMENT_HISTORY(OPENING_ID,OPENING_AMENDMENT_NUMBER); +--ALTER TABLE THE.SILV_RELIEF_APPLICATION ADD CONSTRAINT SRA_SRASCD_FK FOREIGN KEY (SILV_RELIEF_APPL_STATUS_CODE) REFERENCES THE.SILV_RELIEF_APPL_STATUS_CODE(SILV_RELIEF_APPL_STATUS_CODE); + +-- THE.STOCKING_STANDARD_UNIT foreign keys +ALTER TABLE THE.STOCKING_STANDARD_UNIT ADD CONSTRAINT SSU_O_FK FOREIGN KEY (OPENING_ID) REFERENCES THE.OPENING(OPENING_ID); +--ALTER TABLE THE.STOCKING_STANDARD_UNIT ADD CONSTRAINT SSU_SR_FK FOREIGN KEY (STANDARDS_REGIME_ID) REFERENCES THE.STANDARDS_REGIME(STANDARDS_REGIME_ID); -- This table belongs to CLIENT. Is being added here just for the sake of the VIEW below. + CREATE TABLE THE.FOREST_CLIENT ( CLIENT_NUMBER VARCHAR2(8) NOT NULL, CLIENT_NAME VARCHAR2(60) NOT NULL, @@ -395,17 +712,17 @@ CREATE TABLE THE.FOREST_CLIENT ( UPDATE_ORG_UNIT NUMBER(10,0) NOT NULL, REVISION_COUNT NUMBER(5,0) NOT NULL, CONSTRAINT FOREST_CLIENT_PK PRIMARY KEY (CLIENT_NUMBER), - CONSTRAINT SYS_C0029588 CHECK ("CLIENT_NUMBER" IS NOT NULL), - CONSTRAINT SYS_C0029589 CHECK ("CLIENT_NAME" IS NOT NULL), - CONSTRAINT SYS_C0029590 CHECK ("CLIENT_STATUS_CODE" IS NOT NULL), - CONSTRAINT SYS_C0029591 CHECK ("CLIENT_TYPE_CODE" IS NOT NULL), - CONSTRAINT SYS_C0029592 CHECK ("ADD_TIMESTAMP" IS NOT NULL), - CONSTRAINT SYS_C0029593 CHECK ("ADD_USERID" IS NOT NULL), - CONSTRAINT SYS_C0029594 CHECK ("ADD_ORG_UNIT" IS NOT NULL), - CONSTRAINT SYS_C0029595 CHECK ("UPDATE_TIMESTAMP" IS NOT NULL), - CONSTRAINT SYS_C0029596 CHECK ("UPDATE_USERID" IS NOT NULL), - CONSTRAINT SYS_C0029597 CHECK ("UPDATE_ORG_UNIT" IS NOT NULL), - CONSTRAINT SYS_C0029598 CHECK ("REVISION_COUNT" IS NOT NULL) + CONSTRAINT SYS_C0029588_FC_CT CHECK ("CLIENT_NUMBER" IS NOT NULL), + CONSTRAINT SYS_C0029589_FC_CT CHECK ("CLIENT_NAME" IS NOT NULL), + CONSTRAINT SYS_C0029590_FC_CT CHECK ("CLIENT_STATUS_CODE" IS NOT NULL), + CONSTRAINT SYS_C0029591_FC_CT CHECK ("CLIENT_TYPE_CODE" IS NOT NULL), + CONSTRAINT SYS_C0029592_FC_CT CHECK ("ADD_TIMESTAMP" IS NOT NULL), + CONSTRAINT SYS_C0029593_FC_CT CHECK ("ADD_USERID" IS NOT NULL), + CONSTRAINT SYS_C0029594_FC_CT CHECK ("ADD_ORG_UNIT" IS NOT NULL), + CONSTRAINT SYS_C0029595_FC_CT CHECK ("UPDATE_TIMESTAMP" IS NOT NULL), + CONSTRAINT SYS_C0029596_FC_CT CHECK ("UPDATE_USERID" IS NOT NULL), + CONSTRAINT SYS_C0029597_FC_CT CHECK ("UPDATE_ORG_UNIT" IS NOT NULL), + CONSTRAINT SYS_C0029598_FC_CT CHECK ("REVISION_COUNT" IS NOT NULL) ); CREATE UNIQUE INDEX FC_ACRONYM_I ON THE.FOREST_CLIENT (CLIENT_ACRONYM); CREATE INDEX FC_CITC_FK_I ON THE.FOREST_CLIENT (CLIENT_ID_TYPE_CODE); diff --git a/backend/src/test/resources/migration/oracle/V002__oracle_code_tables.sql b/backend/src/test/resources/migration/oracle/V002__oracle_code_tables.sql index e340fb82..d66c0b99 100644 --- a/backend/src/test/resources/migration/oracle/V002__oracle_code_tables.sql +++ b/backend/src/test/resources/migration/oracle/V002__oracle_code_tables.sql @@ -1438,4 +1438,54 @@ INSERT INTO THE.ORG_UNIT (ORG_UNIT_NO,ORG_UNIT_CODE,ORG_UNIT_NAME,LOCATION_CODE, (2, 'TWO', 'Org two', '002', 'BBB', '2233445', 'R', 'CA', 333, '3Code', 444, '44Code', TO_DATE('2020-01-01 00:00:00', 'YYYY-MM-DD HH24:MI:SS'), TO_DATE('2022-12-31 00:00:00', 'YYYY-MM-DD HH24:MI:SS'), TO_DATE('2022-12-31 00:00:00', 'YYYY-MM-DD HH24:MI:SS')), (70,'HVA','Timber Pricing Branch','010','250','3871701','H','VA',0,' ',0,' ',TO_DATE('1905-01-01 00:00:00', 'YYYY-MM-DD HH24:MI:SS'),TO_DATE('9999-12-31 00:00:00', 'YYYY-MM-DD HH24:MI:SS'),TO_DATE('2011-08-29 15:49:08', 'YYYY-MM-DD HH24:MI:SS')); - +INSERT INTO THE.RESULTS_AUDIT_ACTION_CODE +(RESULTS_AUDIT_ACTION_CODE, DESCRIPTION, EFFECTIVE_DATE, EXPIRY_DATE, UPDATE_TIMESTAMP) +VALUES('UPD', 'Update', TIMESTAMP '2001-11-19 00:00:00.000000', TIMESTAMP '9999-12-30 00:00:00.000000', TIMESTAMP '2015-05-12 09:40:54.000000'); +INSERT INTO THE.RESULTS_AUDIT_ACTION_CODE +(RESULTS_AUDIT_ACTION_CODE, DESCRIPTION, EFFECTIVE_DATE, EXPIRY_DATE, UPDATE_TIMESTAMP) +VALUES('COR', 'Correction', TIMESTAMP '1905-01-01 00:00:00.000000', TIMESTAMP '9999-12-31 00:00:00.000000', TIMESTAMP '2015-05-12 09:40:54.000000'); +INSERT INTO THE.RESULTS_AUDIT_ACTION_CODE +(RESULTS_AUDIT_ACTION_CODE, DESCRIPTION, EFFECTIVE_DATE, EXPIRY_DATE, UPDATE_TIMESTAMP) +VALUES('O', 'Original', TIMESTAMP '2005-04-01 00:00:00.000000', TIMESTAMP '9999-12-31 00:00:00.000000', TIMESTAMP '2015-05-12 09:40:54.000000'); +INSERT INTO THE.RESULTS_AUDIT_ACTION_CODE +(RESULTS_AUDIT_ACTION_CODE, DESCRIPTION, EFFECTIVE_DATE, EXPIRY_DATE, UPDATE_TIMESTAMP) +VALUES('197', 'Section 197', TIMESTAMP '2010-02-04 00:00:00.000000', TIMESTAMP '9999-12-31 00:00:00.000000', TIMESTAMP '2015-05-12 09:40:54.000000'); +INSERT INTO THE.RESULTS_AUDIT_ACTION_CODE +(RESULTS_AUDIT_ACTION_CODE, DESCRIPTION, EFFECTIVE_DATE, EXPIRY_DATE, UPDATE_TIMESTAMP) +VALUES('AMG', 'Amalgamate', TIMESTAMP '2005-04-07 00:00:00.000000', TIMESTAMP '9999-12-31 00:00:00.000000', TIMESTAMP '2015-05-12 09:40:54.000000'); +INSERT INTO THE.RESULTS_AUDIT_ACTION_CODE +(RESULTS_AUDIT_ACTION_CODE, DESCRIPTION, EFFECTIVE_DATE, EXPIRY_DATE, UPDATE_TIMESTAMP) +VALUES('ES', 'E-submission', TIMESTAMP '2004-06-01 00:00:00.000000', TIMESTAMP '9999-12-31 00:00:00.000000', TIMESTAMP '2015-05-12 09:40:54.000000'); +INSERT INTO THE.RESULTS_AUDIT_ACTION_CODE +(RESULTS_AUDIT_ACTION_CODE, DESCRIPTION, EFFECTIVE_DATE, EXPIRY_DATE, UPDATE_TIMESTAMP) +VALUES('MIL', 'Milestone', TIMESTAMP '2007-08-07 00:00:00.000000', TIMESTAMP '9999-12-31 00:00:00.000000', TIMESTAMP '2015-05-12 09:40:54.000000'); +INSERT INTO THE.RESULTS_AUDIT_ACTION_CODE +(RESULTS_AUDIT_ACTION_CODE, DESCRIPTION, EFFECTIVE_DATE, EXPIRY_DATE, UPDATE_TIMESTAMP) +VALUES('MIN', 'Amended (Minor)', TIMESTAMP '2005-08-01 00:00:00.000000', TIMESTAMP '9999-12-31 00:00:00.000000', TIMESTAMP '2015-05-12 09:40:54.000000'); +INSERT INTO THE.RESULTS_AUDIT_ACTION_CODE +(RESULTS_AUDIT_ACTION_CODE, DESCRIPTION, EFFECTIVE_DATE, EXPIRY_DATE, UPDATE_TIMESTAMP) +VALUES('SPA', 'Site Plan Amendment', TIMESTAMP '2007-08-07 00:00:00.000000', TIMESTAMP '9999-12-31 00:00:00.000000', TIMESTAMP '2015-05-12 09:40:54.000000'); +INSERT INTO THE.RESULTS_AUDIT_ACTION_CODE +(RESULTS_AUDIT_ACTION_CODE, DESCRIPTION, EFFECTIVE_DATE, EXPIRY_DATE, UPDATE_TIMESTAMP) +VALUES('VAR', 'Variation', TIMESTAMP '2004-05-18 00:00:00.000000', TIMESTAMP '9999-12-31 00:00:00.000000', TIMESTAMP '2015-05-12 09:40:54.000000'); +INSERT INTO THE.RESULTS_AUDIT_ACTION_CODE +(RESULTS_AUDIT_ACTION_CODE, DESCRIPTION, EFFECTIVE_DATE, EXPIRY_DATE, UPDATE_TIMESTAMP) +VALUES('AMD', 'Amended', TIMESTAMP '1905-01-01 00:00:00.000000', TIMESTAMP '9999-12-30 00:00:00.000000', TIMESTAMP '2015-05-12 09:40:54.000000'); +INSERT INTO THE.RESULTS_AUDIT_ACTION_CODE +(RESULTS_AUDIT_ACTION_CODE, DESCRIPTION, EFFECTIVE_DATE, EXPIRY_DATE, UPDATE_TIMESTAMP) +VALUES('APP', 'Approved', TIMESTAMP '1905-01-01 00:00:00.000000', TIMESTAMP '9999-12-30 00:00:00.000000', TIMESTAMP '2015-05-12 09:40:54.000000'); +INSERT INTO THE.RESULTS_AUDIT_ACTION_CODE +(RESULTS_AUDIT_ACTION_CODE, DESCRIPTION, EFFECTIVE_DATE, EXPIRY_DATE, UPDATE_TIMESTAMP) +VALUES('DEL', 'Deleted', TIMESTAMP '1905-01-01 00:00:00.000000', TIMESTAMP '9999-12-30 00:00:00.000000', TIMESTAMP '2015-05-12 09:40:54.000000'); +INSERT INTO THE.RESULTS_AUDIT_ACTION_CODE +(RESULTS_AUDIT_ACTION_CODE, DESCRIPTION, EFFECTIVE_DATE, EXPIRY_DATE, UPDATE_TIMESTAMP) +VALUES('REJ', 'Rejected', TIMESTAMP '1905-01-01 00:00:00.000000', TIMESTAMP '9999-12-30 00:00:00.000000', TIMESTAMP '2015-05-12 09:40:54.000000'); +INSERT INTO THE.RESULTS_AUDIT_ACTION_CODE +(RESULTS_AUDIT_ACTION_CODE, DESCRIPTION, EFFECTIVE_DATE, EXPIRY_DATE, UPDATE_TIMESTAMP) +VALUES('RET', 'Retired', TIMESTAMP '2013-10-21 00:00:00.000000', TIMESTAMP '9999-12-31 00:00:00.000000', TIMESTAMP '2015-05-12 09:40:54.000000'); +INSERT INTO THE.RESULTS_AUDIT_ACTION_CODE +(RESULTS_AUDIT_ACTION_CODE, DESCRIPTION, EFFECTIVE_DATE, EXPIRY_DATE, UPDATE_TIMESTAMP) +VALUES('RMD', 'Removed', TIMESTAMP '2006-08-31 00:00:00.000000', TIMESTAMP '2015-05-11 00:00:00.000000', TIMESTAMP '2015-05-12 09:40:54.000000'); +INSERT INTO THE.RESULTS_AUDIT_ACTION_CODE +(RESULTS_AUDIT_ACTION_CODE, DESCRIPTION, EFFECTIVE_DATE, EXPIRY_DATE, UPDATE_TIMESTAMP) +VALUES('SUB', 'Submitted', TIMESTAMP '1905-01-01 00:00:00.000000', TIMESTAMP '9999-12-30 00:00:00.000000', TIMESTAMP '2015-05-12 09:40:54.000000'); \ No newline at end of file diff --git a/backend/src/test/resources/migration/oracle/V003__oracle_test_data.sql b/backend/src/test/resources/migration/oracle/V003__oracle_test_data.sql index 87eceb37..f9f50115 100644 --- a/backend/src/test/resources/migration/oracle/V003__oracle_test_data.sql +++ b/backend/src/test/resources/migration/oracle/V003__oracle_test_data.sql @@ -1,4 +1,30 @@ - insert into THE.OPEN_CATEGORY_CODE ( +insert into THE.FOREST_CLIENT ( + CLIENT_NUMBER, + CLIENT_TYPE_CODE, + CLIENT_NAME, + LEGAL_FIRST_NAME, + LEGAL_MIDDLE_NAME, + CLIENT_STATUS_CODE, + BIRTHDATE, + REGISTRY_COMPANY_TYPE_CODE, + CORP_REGN_NMBR, + CLIENT_ACRONYM, + CLIENT_ID_TYPE_CODE, + CLIENT_IDENTIFICATION, + WCB_FIRM_NUMBER, + OCG_SUPPLIER_NMBR, + CLIENT_COMMENT, + ADD_TIMESTAMP, + ADD_USERID, + ADD_ORG_UNIT, + UPDATE_TIMESTAMP, + UPDATE_USERID, + UPDATE_ORG_UNIT, + REVISION_COUNT +) +values ('00000001', 'C', 'JERROM', null, null, 'ACT', null, 'BC', '0000001', null, null, null, null, null, null, CURRENT_TIMESTAMP(6), 'IDIR\\ejerrom0', 1, CURRENT_TIMESTAMP(6), 'IDIR\\jjerrom0', 1, 3); + +insert into THE.OPEN_CATEGORY_CODE ( OPEN_CATEGORY_CODE, DESCRIPTION, EFFECTIVE_DATE, @@ -9,7 +35,7 @@ ('BBB', 'BBB description expired', TO_DATE('2020-01-01 00:00:00', 'YYYY-MM-DD HH24:MI:SS'), TO_DATE('2022-12-31 00:00:00', 'YYYY-MM-DD HH24:MI:SS'), TO_DATE('2022-12-31 00:00:00', 'YYYY-MM-DD HH24:MI:SS')); - insert into THE.OPENING ( +insert into THE.OPENING ( OPENING_ID, OPENING_STATUS_CODE, OPEN_CATEGORY_CODE, @@ -19,11 +45,12 @@ ENTRY_USERID, ENTRY_TIMESTAMP, UPDATE_USERID, - UPDATE_TIMESTAMP + UPDATE_TIMESTAMP, + ORG_UNIT_NO ) values - (101,'APP', 'FTML', 1, 1, 1,'idir-here', TO_DATE('2024-01-01 00:00:00', 'YYYY-MM-DD HH24:MI:SS'), 'idir-here', TO_DATE('2024-01-01 00:00:00', 'YYYY-MM-DD HH24:MI:SS')), - (102,'APP', 'FTML', 1, 1, 1,'IDIR\\OTTOMATED', TO_DATE('2024-01-01 00:00:00', 'YYYY-MM-DD HH24:MI:SS'), 'IDIR\\OTTOMATED', TO_DATE('2024-01-01 00:00:00', 'YYYY-MM-DD HH24:MI:SS')), - (103,'APP', 'FTML', 1, 1, 1,'IDIR\\TTESTER', TO_DATE('2024-01-01 00:00:00', 'YYYY-MM-DD HH24:MI:SS'), 'IDIR\\TTESTER', TO_DATE('2024-01-01 00:00:00', 'YYYY-MM-DD HH24:MI:SS')); + (101,'APP', 'FTML', 1, 1, 1,'idir-here', TO_DATE('2024-01-01 00:00:00', 'YYYY-MM-DD HH24:MI:SS'), 'idir-here', TO_DATE('2024-01-01 00:00:00', 'YYYY-MM-DD HH24:MI:SS'), 1), + (102,'APP', 'FTML', 1, 1, 1,'IDIR\\OTTOMATED', TO_DATE('2024-01-01 00:00:00', 'YYYY-MM-DD HH24:MI:SS'), 'IDIR\OTTOMATED', TO_DATE('2024-01-01 00:00:00', 'YYYY-MM-DD HH24:MI:SS'), 1), + (103,'APP', 'FTML', 1, 2, 1,'IDIR@TTESTER', TO_DATE('2024-01-01 00:00:00', 'YYYY-MM-DD HH24:MI:SS'), 'IDIR\TTESTER', TO_DATE('2024-01-01 00:00:00', 'YYYY-MM-DD HH24:MI:SS'), 2); INSERT INTO THE.CUT_BLOCK_OPEN_ADMIN ( CUT_BLOCK_OPEN_ADMIN_ID, @@ -45,3 +72,215 @@ INSERT INTO THE.CUT_BLOCK_OPEN_ADMIN ( (112, 'TFL48', '13T', '48/13S', '13-70', 13.9, TO_DATE('2024-01-22 00:00:00', 'YYYY-MM-DD HH24:MI:SS'), TO_DATE('2024-01-23 00:00:00', 'YYYY-MM-DD HH24:MI:SS'), 102,1,'TEST', TO_DATE('2024-01-01 00:00:00', 'YYYY-MM-DD HH24:MI:SS'), 'TEST', TO_DATE('2024-01-01 00:00:00', 'YYYY-MM-DD HH24:MI:SS')), (113, 'TFL49', '14T', '49/14S', '14-71', 14.9, TO_DATE('2024-01-24 00:00:00', 'YYYY-MM-DD HH24:MI:SS'), TO_DATE('2024-01-25 00:00:00', 'YYYY-MM-DD HH24:MI:SS'), 103,1,'TEST', TO_DATE('2024-01-01 00:00:00', 'YYYY-MM-DD HH24:MI:SS'), 'TEST', TO_DATE('2024-01-01 00:00:00', 'YYYY-MM-DD HH24:MI:SS')); +--TODO: Generate some random THE.OPENING_ATTACHMENT records + +INSERT INTO THE.RESULTS_ELECTRONIC_SUBMISSION +( + RESULTS_SUBMISSION_ID, + SUBMISSION_TIMESTAMP, + SUBMITTED_BY, + CLIENT_NUMBER, + CLIENT_LOCN_CODE, + ORG_UNIT_NO, + USER_FILENAME, + USER_REFERENCE, + ENTRY_USERID, + ENTRY_TIMESTAMP, + UPDATE_USERID, + UPDATE_TIMESTAMP, + REVISION_COUNT +) +VALUES(111, TO_DATE('2024-01-20 00:00:00', 'YYYY-MM-DD HH24:MI:SS'), 'IDIR\TTESTER', '00000001', '01', 1, 'my opening.xml', NULL, 'IDIR\TTESTER', TO_DATE('2024-01-20 00:00:00', 'YYYY-MM-DD HH24:MI:SS'), 'IDIR\TTESTER', TO_DATE('2024-01-20 00:00:00', 'YYYY-MM-DD HH24:MI:SS'), 1); + +INSERT INTO THE.SILV_ADMIN_ZONE +( + DIST_ADMIN_ZONE, + ORG_UNIT_NO, + ADMIN_ZONE_DESC, + REVISION_COUNT +) +VALUES('A', 1, 'TEST VALLEY', 1); + +INSERT INTO THE.OPENING_AMENDMENT_HISTORY +( + OPENING_ID, + OPENING_AMENDMENT_NUMBER, + AMENDMENT_USERID, + AMENDMENT_DATE, + SUBMITTED_BY_USERID, + SUBMITTED_DATE, + APP_ENT_BY_USERID, + APPROVE_DATE, + ENTRY_USERID, + ENTRY_TIMESTAMP, + UPDATE_USERID, + UPDATE_TIMESTAMP, + REVISION_COUNT +) +VALUES(101, 1, 'IDIR\TTESTER', TO_DATE('2024-01-20 00:00:00', 'YYYY-MM-DD HH24:MI:SS'), 'IDIR\TTESTER, IDIR\OTTOMATED', TO_DATE('2024-01-20 10:00:00', 'YYYY-MM-DD HH24:MI:SS'), 'IDIR\TTESTER', TO_DATE('2024-01-20 00:00:00', 'YYYY-MM-DD HH24:MI:SS'), 'RESULTS_CONV', TO_DATE('2024-01-20 10:00:00', 'YYYY-MM-DD HH24:MI:SS'), 'RESULTS_CONV', TO_DATE('2024-01-20 12:00:00', 'YYYY-MM-DD HH24:MI:SS'), 1); + +INSERT INTO THE.STOCKING_EVENT_HISTORY +( + STOCKING_EVENT_HISTORY_ID, + OPENING_ID, + OPENING_AMENDMENT_ID, + OPENING_AMENDMENT_NUMBER, + RESULTS_AUDIT_ACTION_CODE, + SUBMITTED_USERID, + RESULTS_SUBMISSION_ID, + AMEND_EVENT_TIMESTAMP, + ENTRY_USERID, + ENTRY_TIMESTAMP, + REVISION_COUNT +) +VALUES(111, 101, 101, 1, 'O', 'Results data conversion', 111, TO_DATE('2024-01-20 00:00:00', 'YYYY-MM-DD HH24:MI:SS'), 'Results data conversion', TO_DATE('2024-01-20 00:00:00', 'YYYY-MM-DD HH24:MI:SS'), 1); + +INSERT INTO THE.RESULTS_AUDIT_EVENT +( + RESULTS_AUDIT_EVENT_ID, + OPENING_ID, + STANDARDS_REGIME_ID, + SILVICULTURE_PROJECT_ID, + RESULTS_AUDIT_ACTION_CODE, + ACTION_DATE, + DESCRIPTION, + USER_ID, + EMAIL_SENT_IND, + XML_SUBMISSION_ID, + OPENING_AMENDMENT_NUMBER, + ENTRY_USERID, + ENTRY_TIMESTAMP +) +VALUES(1, 101, NULL, NULL, 'SUB', TO_DATE('2024-01-20 00:00:00', 'YYYY-MM-DD HH24:MI:SS'), 'Forest Cover 0000000', NULL, 'Y', 101, 101, 'TEST\OTTOMATED', TO_DATE('2024-01-20 00:00:00', 'YYYY-MM-DD HH24:MI:SS')); + +INSERT INTO THE.ACTIVITY_TREATMENT_UNIT +( + ACTIVITY_TREATMENT_UNIT_ID, + ACTIVITY_TU_SEQ_NO, + ORG_UNIT_NO, + OPENING_ID, + SILVICULTURE_PROJECT_ID, + PROJECT_UNIT_ID, + SILV_BASE_CODE, + SILV_TECHNIQUE_CODE, + SILV_METHOD_CODE, + SILV_OBJECTIVE_CODE_1, + SILV_OBJECTIVE_CODE_2, + SILV_OBJECTIVE_CODE_3, + SILV_FUND_SRCE_CODE, + SILV_ACTIVITY_MEASUREMENT_CODE, + ACTIVITY_LICENSEE_ID, + TREATMENT_AMOUNT, + ACTUAL_TREATMENT_COST, + ACT_PLANTED_NO, + PLAN_SILV_TECHNIQUE_CODE, + PLAN_SILV_METHOD_CODE, + PLAN_SILV_FUND_SRCE_CODE, + PLANNED_DATE, + PLANNED_TREATMENT_AMOUNT, + PLANNED_TREATMENT_COST, + PLAN_SILV_OBJECTIVE_CODE_1, + PLAN_SILV_OBJECTIVE_CODE_2, + PLAN_SILV_OBJECTIVE_CODE_3, + TARGET_PREPARED_SPOTS, + PRUNING_MIN_CROWN_PCT, + PRUNE_HEIGHT, + STEMS_TO_PRUNE, + MIN_ACCEPTABLE_DENSITY, + TOTAL_STEMS_PER_HA, + INTER_TREE_TARGET_DISTANCE, + INTER_TREE_VARIATION, + INTER_TREE_MIN_DISTANCE, + MAX_TREES_PER_PLOT, + MAX_TREES_PER_HA, + SURVEY_PLANNED_NUM_PLOTS, + SURVEY_ACTUAL_NUM_PLOTS, + SURVEY_MIN_PLOTS_PER_STRATUM, + SILV_TREE_SPECIES_CODE, + ATU_START_DATE, + ATU_COMPLETION_DATE, + RESULTS_IND, + UNIT_BID_PRICE, + FIA_PROJECT_ID, + RESULTS_SUBMISSION_ID, + DISTURBANCE_CODE, + SILV_SYSTEM_CODE, + SILV_SYSTEM_VARIANT_CODE, + SILV_CUT_PHASE_CODE, + CUT_BLOCK_OPEN_ADMIN_ID, + DISTURBANCE_COMPLETED_IND, + ENTRY_USERID, + ENTRY_TIMESTAMP, + UPDATE_USERID, + UPDATE_TIMESTAMP, + REVISION_COUNT +) +VALUES(101, 1, 1, 101, NULL, NULL, 'SU', 'RG', 'PLOT', 'RG', NULL, NULL, 'VOI', 'HA', NULL, 13.5, NULL, 0, 'RG', 'PLOT', 'VOI', TO_DATE('2024-01-20 00:00:00', 'YYYY-MM-DD HH24:MI:SS'), 13.5, NULL, 'RG', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, TO_DATE('2024-01-20 00:00:00', 'YYYY-MM-DD HH24:MI:SS'), 'Y', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'IDIR\TTESTER', TO_DATE('2024-01-20 00:00:00', 'YYYY-MM-DD HH24:MI:SS'), ' DATAFIX_ABP_2014', TO_DATE('2024-01-20 00:00:00', 'YYYY-MM-DD HH24:MI:SS'), 2); + +INSERT INTO THE.SILV_RELIEF_APPLICATION +( + SILV_RELIEF_APPLICATION_ID, + SILV_RELIEF_APPLICATION_NO, + ACTIVITY_TREATMENT_UNIT_ID, + SILV_RELIEF_APPL_STATUS_CODE, + PRE_EVENT_FOREST_COVER_DATE, + POST_EVENT_FOREST_COVER_DATE, + AMENDMENT_OPENING_ID, + OPENING_AMENDMENT_NUMBER, + OBLIGATION_RELIEF_IND, + OBLIGATION_MET_IND, + CAUSE_DAMAGE_IND, + OFFICIALLY_INDUCED_ERROR_IND, + DUE_DILIGENCE_IND, + AUTHORIZATION_CHECKED_IND, + SUBMITTED_DATE, + SUBMITTED_BY_USERID, + APPROVED_DATE, + APPROVED_BY_USERID, + REJECT_COMMENT, + ENTRY_USERID, + ENTRY_TIMESTAMP, + UPDATE_USERID, + UPDATE_TIMESTAMP, + REVISION_COUNT +) +VALUES(101, 1, 101, 'APP', TO_DATE('2024-01-20 00:00:00', 'YYYY-MM-DD HH24:MI:SS'), TO_DATE('2024-01-20 08:00:00', 'YYYY-MM-DD HH24:MI:SS'), 101, 1, 'N', 'Y', 'Y', 'N', 'N', 'Y', TO_DATE('2024-01-20 08:00:00', 'YYYY-MM-DD HH24:MI:SS'), 'IDIR\TTESTER', TO_DATE('2024-01-20 08:00:00', 'YYYY-MM-DD HH24:MI:SS'), 'IDIR\TTESTER', NULL, 'IDIR\TTESTER', TO_DATE('2024-01-20 00:00:00', 'YYYY-MM-DD HH24:MI:SS'), 'IDIR\TTESTER', TO_DATE('2024-01-20 00:00:00', 'YYYY-MM-DD HH24:MI:SS'), 4); + +INSERT INTO THE.STOCKING_STANDARD_UNIT +( + STOCKING_STANDARD_UNIT_ID, + OPENING_ID, + STANDARDS_UNIT_ID, + STANDARDS_REGIME_ID, + NET_AREA, + MAX_ALLOW_SOIL_DISTURBANCE_PCT, + VARIANCE_IND, + ENTRY_USERID, + ENTRY_TIMESTAMP, + UPDATE_USERID, + UPDATE_TIMESTAMP, + REVISION_COUNT +) +VALUES(101, 101, '1', NULL, 0, 0, NULL, 'RESULTS_CONV', TO_DATE('2024-01-20 00:00:00', 'YYYY-MM-DD HH24:MI:SS'), 'RESULTS_CONV', TO_DATE('2024-01-20 00:00:00', 'YYYY-MM-DD HH24:MI:SS'), 5); + +INSERT INTO THE.STOCKING_MILESTONE +( + STOCKING_STANDARD_UNIT_ID, + SILV_MILESTONE_TYPE_CODE, + RESULTS_SUBMISSION_ID, + DECLARED_DATE, + DECLARED_USERID, + DECLARE_IND, + DECLARATION_SUBMITTED_DATE, + EARLY_OFFSET_YEARS, + LATE_OFFSET_YEARS, + DUE_EARLY_DATE, + DUE_LATE_DATE, + ENTRY_USERID, + ENTRY_TIMESTAMP, + UPDATE_USERID, + UPDATE_TIMESTAMP, + REVISION_COUNT, + EXTENT_FEASIBLE_DECLARED_IND +) +VALUES(101, 'FG', NULL, NULL, NULL, 'N', NULL, 12, 15, NULL, NULL, 'RESULTS_CONV', TO_DATE('2024-01-20 00:00:00', 'YYYY-MM-DD HH24:MI:SS'), 'RESULTS_CONV', TO_DATE('2024-01-20 00:00:00', 'YYYY-MM-DD HH24:MI:SS'), 1, 'N'); From acca0f9f070577fecb84dfac24b078910363264c Mon Sep 17 00:00:00 2001 From: Paulo Gomes da Cruz Junior Date: Mon, 28 Oct 2024 06:07:55 -0700 Subject: [PATCH 06/10] ci: updating sonar and jacoco exclusions --- .github/workflows/analysis.yml | 2 +- backend/pom.xml | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/analysis.yml b/.github/workflows/analysis.yml index 31475a6c..7cba3636 100644 --- a/.github/workflows/analysis.yml +++ b/.github/workflows/analysis.yml @@ -25,7 +25,7 @@ jobs: java-distribution: temurin java-version: 21 sonar_args: > - -Dsonar.exclusions=**/config/**,**/converter/**,**/dto/**,**/entity/**,**/exception/**,**/job/**,**/response/**,**/*$*Builder*,**/RestExceptionEndpoint.*,**/ResultsApplication.* + -Dsonar.exclusions=**/configuration/**,**/dto/**,**/entity/**,**/exception/**,**/job/**,**/*$*Builder*,**/ResultsApplication.*,**/*Constants.*, -Dsonar.coverage.jacoco.xmlReportPaths=target/coverage-reports/merged-test-report/jacoco.xml -Dsonar.organization=bcgov-sonarcloud -Dsonar.project.monorepo.enabled=true diff --git a/backend/pom.xml b/backend/pom.xml index c6d3b09a..f0ba2680 100644 --- a/backend/pom.xml +++ b/backend/pom.xml @@ -162,6 +162,7 @@ com.oracle.database.jdbc ojdbc11 + runtime org.flywaydb @@ -179,6 +180,7 @@ org.postgresql postgresql + runtime org.testcontainers @@ -200,6 +202,7 @@ org.springframework.security spring-security-test + test org.testcontainers @@ -331,17 +334,14 @@ ${jacoco.skip} - **/config/** - **/converter/** + **/configuration/** **/dto/** **/entity/** **/exception/** **/job/** - **/response/** **/*$*Builder* - **/RestExceptionEndpoint.* - **/Controller.* **/ResultsApplication.* + **/*Constants.* From 22f11055b08ce445d5f0e059164478bb9d3ab07b Mon Sep 17 00:00:00 2001 From: Paulo Gomes da Cruz Junior Date: Mon, 28 Oct 2024 06:08:57 -0700 Subject: [PATCH 07/10] test: adding jwt mock --- .../results/extensions/WithMockJwt.java | 23 +++++++++ .../WithMockJwtSecurityContextFactory.java | 49 +++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 backend/src/test/java/ca/bc/gov/restapi/results/extensions/WithMockJwt.java create mode 100644 backend/src/test/java/ca/bc/gov/restapi/results/extensions/WithMockJwtSecurityContextFactory.java diff --git a/backend/src/test/java/ca/bc/gov/restapi/results/extensions/WithMockJwt.java b/backend/src/test/java/ca/bc/gov/restapi/results/extensions/WithMockJwt.java new file mode 100644 index 00000000..391f4eb1 --- /dev/null +++ b/backend/src/test/java/ca/bc/gov/restapi/results/extensions/WithMockJwt.java @@ -0,0 +1,23 @@ +package ca.bc.gov.restapi.results.extensions; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Inherited; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import org.springframework.security.test.context.support.WithSecurityContext; + +@Target({ElementType.METHOD, ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Inherited +@Documented +@WithSecurityContext(factory = WithMockJwtSecurityContextFactory.class) +public @interface WithMockJwt { + String value() default "test"; + String[] roles() default {"user_read"}; + String email() default "test@test.ca"; + String idp() default "idir"; + String displayName() default "Test, Automated WLRS:EX"; + +} diff --git a/backend/src/test/java/ca/bc/gov/restapi/results/extensions/WithMockJwtSecurityContextFactory.java b/backend/src/test/java/ca/bc/gov/restapi/results/extensions/WithMockJwtSecurityContextFactory.java new file mode 100644 index 00000000..281f0026 --- /dev/null +++ b/backend/src/test/java/ca/bc/gov/restapi/results/extensions/WithMockJwtSecurityContextFactory.java @@ -0,0 +1,49 @@ +package ca.bc.gov.restapi.results.extensions; + +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; +import org.springframework.security.core.GrantedAuthority; +import org.springframework.security.core.authority.AuthorityUtils; +import org.springframework.security.core.context.SecurityContext; +import org.springframework.security.core.context.SecurityContextHolder; +import org.springframework.security.oauth2.jwt.Jwt; +import org.springframework.security.oauth2.server.resource.authentication.JwtAuthenticationToken; +import org.springframework.security.test.context.support.WithSecurityContextFactory; + +public class WithMockJwtSecurityContextFactory implements WithSecurityContextFactory { + + @Override + public SecurityContext createSecurityContext(WithMockJwt annotation) { + Jwt jwt = Jwt + .withTokenValue("token") + .header("alg", "none") + .claim("sub", annotation.value()) + .claim("client_roles", listToString(annotation.roles())) + .claim("custom:idp_name", annotation.idp()) + .claim("custom:idp_username", annotation.value()) + .claim("custom:idp_display_name", annotation.displayName()) + .claim("email", annotation.email()) + .build(); + + List authorities = AuthorityUtils.createAuthorityList(annotation.roles()); + JwtAuthenticationToken token = new JwtAuthenticationToken(jwt, authorities); + + SecurityContext context = SecurityContextHolder.createEmptyContext(); + context.setAuthentication(token); + return context; + + } + + private String listToString(String[] list) { + return listToString(Arrays.asList(list)); + } + + private String listToString(List list) { + return + list + .stream() + .map(content -> String.format("\"%s\"", content)) + .collect(Collectors.joining(",", "[", "]")); + } +} From 7e9c1c8e9d5a9dcae364ab70b08577b69986cadd Mon Sep 17 00:00:00 2001 From: Paulo Gomes da Cruz Junior Date: Mon, 28 Oct 2024 06:09:25 -0700 Subject: [PATCH 08/10] chore: updating timestamp util and test --- .../results/common/util/TimestampUtil.java | 39 ++++- .../common/util/TimestampUtilTest.java | 135 ++++++++++++++---- 2 files changed, 139 insertions(+), 35 deletions(-) diff --git a/backend/src/main/java/ca/bc/gov/restapi/results/common/util/TimestampUtil.java b/backend/src/main/java/ca/bc/gov/restapi/results/common/util/TimestampUtil.java index a79a0528..bfde87a8 100644 --- a/backend/src/main/java/ca/bc/gov/restapi/results/common/util/TimestampUtil.java +++ b/backend/src/main/java/ca/bc/gov/restapi/results/common/util/TimestampUtil.java @@ -2,14 +2,20 @@ import java.time.LocalDate; import java.time.LocalDateTime; +import java.time.LocalTime; import java.time.Period; import java.time.format.DateTimeFormatter; import java.util.Objects; +import lombok.AccessLevel; +import lombok.NoArgsConstructor; +import org.apache.commons.lang3.StringUtils; -/** This class contains useful methods for parsing and handling timestamps. */ +/** + * This class contains useful methods for parsing and handling timestamps. + */ +@NoArgsConstructor(access = AccessLevel.PRIVATE) public class TimestampUtil { - private TimestampUtil() {} /** * Parses a date string to a {@link LocalDateTime} instance. Format: yyyy-MM-dd. @@ -18,13 +24,34 @@ private TimestampUtil() {} * @return LocalDateTime parsed or null if a null value is found. */ public static LocalDateTime parseDateString(String dateStr) { - if (Objects.isNull(dateStr)) { + if (StringUtils.isEmpty(dateStr)) { return null; } + return parseDateString(LocalDate.parse(dateStr, DateTimeFormatter.ofPattern("yyyy-MM-dd"))); + } + + /** + * Parses a LocalDate to a LocalDateTime instance with the time set to LocalTime.MIN. + * + * @param localDate The LocalDate to be parsed + * @return LocalDateTime parsed or null if a null value is found. + */ + public static LocalDateTime parseDateString(LocalDate localDate) { + return parseDateString(localDate, LocalTime.MIN); + } - LocalDate entryDateStartLd = - LocalDate.parse(dateStr, DateTimeFormatter.ofPattern("yyyy-MM-dd")); - return entryDateStartLd.atStartOfDay(); + /** + * Parses a LocalDate to a LocalDateTime instance with the specified time. + * + * @param localDate The LocalDate to be parsed + * @param time The LocalTime to be set + * @return LocalDateTime parsed or null if a null value is found. + */ + public static LocalDateTime parseDateString(LocalDate localDate, LocalTime time) { + if (Objects.isNull(localDate)) { + return null; + } + return localDate.atTime(time); } /** diff --git a/backend/src/test/java/ca/bc/gov/restapi/results/common/util/TimestampUtilTest.java b/backend/src/test/java/ca/bc/gov/restapi/results/common/util/TimestampUtilTest.java index c885e0b6..3415e966 100644 --- a/backend/src/test/java/ca/bc/gov/restapi/results/common/util/TimestampUtilTest.java +++ b/backend/src/test/java/ca/bc/gov/restapi/results/common/util/TimestampUtilTest.java @@ -1,45 +1,122 @@ package ca.bc.gov.restapi.results.common.util; +import java.time.LocalDate; import java.time.LocalDateTime; +import java.time.LocalTime; +import java.util.stream.Stream; import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; +import org.junit.jupiter.params.provider.NullAndEmptySource; +@DisplayName("Unit Test | Timestamp Util") class TimestampUtilTest { - @Test - void parseDateStringTest() { - LocalDateTime dateTimeParsed = TimestampUtil.parseDateString("2024-04-09"); - Assertions.assertNotNull(dateTimeParsed); - Assertions.assertEquals(2024, dateTimeParsed.getYear()); - Assertions.assertEquals(4, dateTimeParsed.getMonthValue()); - Assertions.assertEquals(9, dateTimeParsed.getDayOfMonth()); + @ParameterizedTest + @MethodSource("startEndOfDay") + @DisplayName("Date begin and end of day") + void shouldGetStartOrEndOfDay(LocalDate date, boolean start){ + + LocalDateTime dateTime = TimestampUtil.parseDateString(date, start ? LocalTime.MIN : LocalTime.MAX); + + Assertions.assertEquals(date, dateTime.toLocalDate()); + - LocalDateTime dateTimeNull = TimestampUtil.parseDateString(null); + if(start){ + Assertions.assertEquals(0, dateTime.getHour()); + Assertions.assertEquals(0, dateTime.getMinute()); + Assertions.assertEquals(0, dateTime.getSecond()); + Assertions.assertEquals(0, dateTime.getNano()); + } else { + Assertions.assertEquals(23, dateTime.getHour()); + Assertions.assertEquals(59, dateTime.getMinute()); + Assertions.assertEquals(59, dateTime.getSecond()); + Assertions.assertEquals(999999999, dateTime.getNano()); + } + + } + + @ParameterizedTest + @NullAndEmptySource + @DisplayName("Parse date string null or empty") + void parseDateStringTest(String value) { + LocalDateTime dateTimeNull = TimestampUtil.parseDateString(value); Assertions.assertNull(dateTimeNull); } - @Test - void getLocalDateTimeIndexTest() { + @ParameterizedTest(name = "Parse date string {0} to {1}") + @MethodSource("parseValuesString") + @DisplayName("Parse date string") + void parseDateStringTest( + String dateStr, int year, int month, int day + ) { + LocalDateTime dateTimeParsed = TimestampUtil.parseDateString(dateStr); + Assertions.assertNotNull(dateTimeParsed); + Assertions.assertEquals(year, dateTimeParsed.getYear()); + Assertions.assertEquals(month, dateTimeParsed.getMonthValue()); + Assertions.assertEquals(day, dateTimeParsed.getDayOfMonth()); + } + + @ParameterizedTest(name = "Get local date time index for {1} months ago as {0}") + @MethodSource("indexValues") + @DisplayName("Get local date time index") + void getLocalDateTimeIndexTest( + int expectedIndex, long monthsAgo + ) { LocalDateTime now = LocalDateTime.now(); + LocalDateTime dateTime = now.minusMonths(monthsAgo); + Assertions.assertEquals(expectedIndex, TimestampUtil.getLocalDateTimeIndex(dateTime)); + } + + private static Stream indexValues() { + return Stream.of( + Arguments.of(0, 1L), + Arguments.of(0, 2L), + Arguments.of(0, 3L), + Arguments.of(0, 4L), + Arguments.of(0, 5L), + Arguments.of(1, 6L), + Arguments.of(1, 7L), + Arguments.of(1, 8L), + Arguments.of(1, 9L), + Arguments.of(1, 10L), + Arguments.of(1, 11L), + Arguments.of(2, 12L), + Arguments.of(2, 13L), + Arguments.of(2, 14L), + Arguments.of(2, 15L), + Arguments.of(2, 16L), + Arguments.of(2, 17L), + Arguments.of(3, 18L), + Arguments.of(3, 36L) + ); + } + + private static Stream parseValuesString(){ + return Stream.of( + Arguments.of("2024-04-09", 2024, 4, 9), + Arguments.of("1987-01-01", 1987,1,1), + Arguments.of("2022-12-31", 2022,12,31), + Arguments.of("2023-02-28", 2023,2,28), + Arguments.of("2024-02-29", 2024,2,29) + ); + } - Assertions.assertEquals(0, TimestampUtil.getLocalDateTimeIndex(now.minusMonths(1L))); - Assertions.assertEquals(0, TimestampUtil.getLocalDateTimeIndex(now.minusMonths(2L))); - Assertions.assertEquals(0, TimestampUtil.getLocalDateTimeIndex(now.minusMonths(3L))); - Assertions.assertEquals(0, TimestampUtil.getLocalDateTimeIndex(now.minusMonths(4L))); - Assertions.assertEquals(0, TimestampUtil.getLocalDateTimeIndex(now.minusMonths(5L))); - Assertions.assertEquals(1, TimestampUtil.getLocalDateTimeIndex(now.minusMonths(6L))); - Assertions.assertEquals(1, TimestampUtil.getLocalDateTimeIndex(now.minusMonths(7L))); - Assertions.assertEquals(1, TimestampUtil.getLocalDateTimeIndex(now.minusMonths(8L))); - Assertions.assertEquals(1, TimestampUtil.getLocalDateTimeIndex(now.minusMonths(9L))); - Assertions.assertEquals(1, TimestampUtil.getLocalDateTimeIndex(now.minusMonths(10L))); - Assertions.assertEquals(1, TimestampUtil.getLocalDateTimeIndex(now.minusMonths(11L))); - Assertions.assertEquals(2, TimestampUtil.getLocalDateTimeIndex(now.minusMonths(12L))); - Assertions.assertEquals(2, TimestampUtil.getLocalDateTimeIndex(now.minusMonths(13L))); - Assertions.assertEquals(2, TimestampUtil.getLocalDateTimeIndex(now.minusMonths(14L))); - Assertions.assertEquals(2, TimestampUtil.getLocalDateTimeIndex(now.minusMonths(15L))); - Assertions.assertEquals(2, TimestampUtil.getLocalDateTimeIndex(now.minusMonths(16L))); - Assertions.assertEquals(2, TimestampUtil.getLocalDateTimeIndex(now.minusMonths(17L))); - Assertions.assertEquals(3, TimestampUtil.getLocalDateTimeIndex(now.minusMonths(18L))); - Assertions.assertEquals(3, TimestampUtil.getLocalDateTimeIndex(now.minusMonths(36L))); + private static Stream startEndOfDay(){ + return Stream.of( + Arguments.of(LocalDate.of(2024, 4, 9), true), + Arguments.of(LocalDate.of(1987, 1, 1), true), + Arguments.of(LocalDate.of(2022, 12, 31), true), + Arguments.of(LocalDate.of(2023, 2, 28), true), + Arguments.of(LocalDate.of(2024, 2, 29), true), + Arguments.of(LocalDate.of(2024, 4, 9), false), + Arguments.of(LocalDate.of(1987, 1, 1), false), + Arguments.of(LocalDate.of(2022, 12, 31), false), + Arguments.of(LocalDate.of(2023, 2, 28), false), + Arguments.of(LocalDate.of(2024, 2, 29), false) + ); } } From 3b93d133bfcd5bc7d6a33a86ffbfdb4fc63e8777 Mon Sep 17 00:00:00 2001 From: Paulo Gomes da Cruz Junior Date: Mon, 28 Oct 2024 06:10:17 -0700 Subject: [PATCH 09/10] chore: simplified code and updated tests --- .../endpoint/FeatureServiceEndpoint.java | 6 +-- .../service/DashboardExtractionService.java | 25 ++++----- .../common/service/ForestClientService.java | 17 +++--- ...{RestService.java => OpenMapsService.java} | 20 +++---- .../endpoint/FeatureServiceEndpointTest.java | 7 +-- .../DashboardExtractionServiceTest.java | 53 ++++++++++++++++--- .../service/ForestClientServiceTest.java | 19 +++++++ ...viceTest.java => OpenMapsServiceTest.java} | 41 +++++++------- 8 files changed, 117 insertions(+), 71 deletions(-) rename backend/src/main/java/ca/bc/gov/restapi/results/common/service/{RestService.java => OpenMapsService.java} (77%) rename backend/src/test/java/ca/bc/gov/restapi/results/common/service/{RestServiceTest.java => OpenMapsServiceTest.java} (75%) diff --git a/backend/src/main/java/ca/bc/gov/restapi/results/common/endpoint/FeatureServiceEndpoint.java b/backend/src/main/java/ca/bc/gov/restapi/results/common/endpoint/FeatureServiceEndpoint.java index 8ff8e91d..a5ae4079 100644 --- a/backend/src/main/java/ca/bc/gov/restapi/results/common/endpoint/FeatureServiceEndpoint.java +++ b/backend/src/main/java/ca/bc/gov/restapi/results/common/endpoint/FeatureServiceEndpoint.java @@ -1,6 +1,6 @@ package ca.bc.gov.restapi.results.common.endpoint; -import ca.bc.gov.restapi.results.common.service.RestService; +import ca.bc.gov.restapi.results.common.service.OpenMapsService; import lombok.AllArgsConstructor; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; @@ -15,7 +15,7 @@ @AllArgsConstructor public class FeatureServiceEndpoint { - private final RestService restService; + private final OpenMapsService openMapsService; /** * Fetch Opening data from WFS. @@ -27,6 +27,6 @@ public class FeatureServiceEndpoint { public Object getOpeningPolygonAndProperties( @PathVariable String openingId) { - return restService.getOpeningPolygonAndProperties(openingId); + return openMapsService.getOpeningPolygonAndProperties(openingId); } } diff --git a/backend/src/main/java/ca/bc/gov/restapi/results/common/service/DashboardExtractionService.java b/backend/src/main/java/ca/bc/gov/restapi/results/common/service/DashboardExtractionService.java index ce8a6938..af01199e 100644 --- a/backend/src/main/java/ca/bc/gov/restapi/results/common/service/DashboardExtractionService.java +++ b/backend/src/main/java/ca/bc/gov/restapi/results/common/service/DashboardExtractionService.java @@ -27,8 +27,8 @@ public class DashboardExtractionService { /** * Service for extracting data from oracle and adding into Postgres. * - * @param months Optional number of months. - * @param debug Optional debug mode enabled. + * @param months Optional number of months. + * @param debug Optional debug mode enabled. * @param manuallyTriggered Optional option. */ @Async @@ -47,18 +47,11 @@ public void extractDataForTheDashboard(Integer months, Boolean debug, Boolean ma dashboardInsertionService.loadDashboardData(extractionDto, startDateTime, params); } - private OracleExtractionParamsDto getParams( - Integer months, Boolean debug, Boolean manuallyTriggered) { - if (Objects.isNull(months)) { - months = 24; - } - if (Objects.isNull(debug)) { - debug = Boolean.FALSE; - } - if (Objects.isNull(manuallyTriggered)) { - manuallyTriggered = Boolean.FALSE; - } - - return new OracleExtractionParamsDto(months, debug, manuallyTriggered); - } + private OracleExtractionParamsDto getParams(Integer months, Boolean debug, Boolean manuallyTriggered) { + return new OracleExtractionParamsDto( + Objects.requireNonNullElse(months, 24), + Objects.requireNonNullElse(debug, Boolean.FALSE), + Objects.requireNonNullElse(manuallyTriggered, Boolean.FALSE) + ); +} } diff --git a/backend/src/main/java/ca/bc/gov/restapi/results/common/service/ForestClientService.java b/backend/src/main/java/ca/bc/gov/restapi/results/common/service/ForestClientService.java index 091829bd..c0f67bf2 100644 --- a/backend/src/main/java/ca/bc/gov/restapi/results/common/service/ForestClientService.java +++ b/backend/src/main/java/ca/bc/gov/restapi/results/common/service/ForestClientService.java @@ -2,14 +2,15 @@ import ca.bc.gov.restapi.results.common.dto.ForestClientDto; import ca.bc.gov.restapi.results.common.provider.ForestClientApiProvider; -import java.util.Objects; import java.util.Optional; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; -import org.springframework.web.client.HttpClientErrorException; -/** This service contains methods for interacting with Forest Client API. */ +/** + * This service contains methods for interacting with Forest Client API. + */ @Slf4j @Service @RequiredArgsConstructor @@ -30,17 +31,11 @@ public Optional getClientByNumber(String clientNumber) { if (!fixedNumber.equals(clientNumber)) { log.info("Fixed client number to fetch {}", fixedNumber); } - - try { - return forestClientApiProvider.fetchClientByNumber(fixedNumber); - } catch (HttpClientErrorException.NotFound e) { - log.info(String.format("Client %s not found", clientNumber), e); - return Optional.empty(); - } + return forestClientApiProvider.fetchClientByNumber(fixedNumber); } private String checkClientNumber(String clientNumber) { - if (Objects.isNull(clientNumber)) { + if (StringUtils.isEmpty(clientNumber)) { return "00000000"; } diff --git a/backend/src/main/java/ca/bc/gov/restapi/results/common/service/RestService.java b/backend/src/main/java/ca/bc/gov/restapi/results/common/service/OpenMapsService.java similarity index 77% rename from backend/src/main/java/ca/bc/gov/restapi/results/common/service/RestService.java rename to backend/src/main/java/ca/bc/gov/restapi/results/common/service/OpenMapsService.java index c085de0b..8e84c722 100644 --- a/backend/src/main/java/ca/bc/gov/restapi/results/common/service/RestService.java +++ b/backend/src/main/java/ca/bc/gov/restapi/results/common/service/OpenMapsService.java @@ -11,11 +11,11 @@ */ @Slf4j @Service -public class RestService { +public class OpenMapsService { private final RestClient restClient; - public RestService(@Qualifier("openMapsApi") RestClient openMapsApi) { + public OpenMapsService(@Qualifier("openMapsApi") RestClient openMapsApi) { this.restClient = openMapsApi; } @@ -40,14 +40,14 @@ public Object getOpeningPolygonAndProperties(String openingId) { .queryParam("SrsName", "EPSG:4326") .queryParam("PROPERTYNAME", "OPENING_ID," - + "GEOMETRY," - + "REGION_NAME," - + "REGION_CODE," - + "DISTRICT_NAME," - + "DISTRICT_CODE," - + "CLIENT_NAME," - + "CLIENT_NUMBER," - + "OPENING_WHEN_CREATED" + + "GEOMETRY," + + "REGION_NAME," + + "REGION_CODE," + + "DISTRICT_NAME," + + "DISTRICT_CODE," + + "CLIENT_NAME," + + "CLIENT_NUMBER," + + "OPENING_WHEN_CREATED" ) .queryParam("CQL_FILTER", "OPENING_ID=" + openingId) .build(Map.of()) diff --git a/backend/src/test/java/ca/bc/gov/restapi/results/common/endpoint/FeatureServiceEndpointTest.java b/backend/src/test/java/ca/bc/gov/restapi/results/common/endpoint/FeatureServiceEndpointTest.java index 25d147ec..cce26e10 100644 --- a/backend/src/test/java/ca/bc/gov/restapi/results/common/endpoint/FeatureServiceEndpointTest.java +++ b/backend/src/test/java/ca/bc/gov/restapi/results/common/endpoint/FeatureServiceEndpointTest.java @@ -6,7 +6,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; -import ca.bc.gov.restapi.results.common.service.RestService; +import ca.bc.gov.restapi.results.common.service.OpenMapsService; import java.util.Optional; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -24,7 +24,8 @@ class FeatureServiceEndpointTest { @Autowired private MockMvc mockMvc; - @MockBean RestService restService; + @MockBean + OpenMapsService openMapsService; @Test @DisplayName("Get opening polygon and properties happy path should succeed") @@ -67,7 +68,7 @@ void getOpeningPolygonAndProperties_happyPath_shouldSucceed() throws Exception { } """; - when(restService.getOpeningPolygonAndProperties(openingId)) + when(openMapsService.getOpeningPolygonAndProperties(openingId)) .thenReturn(ResponseEntity.of(Optional.of(response))); mockMvc diff --git a/backend/src/test/java/ca/bc/gov/restapi/results/common/service/DashboardExtractionServiceTest.java b/backend/src/test/java/ca/bc/gov/restapi/results/common/service/DashboardExtractionServiceTest.java index 4ce8a163..8b42dacc 100644 --- a/backend/src/test/java/ca/bc/gov/restapi/results/common/service/DashboardExtractionServiceTest.java +++ b/backend/src/test/java/ca/bc/gov/restapi/results/common/service/DashboardExtractionServiceTest.java @@ -9,20 +9,26 @@ import ca.bc.gov.restapi.results.oracle.service.OracleExtractionService; import ca.bc.gov.restapi.results.postgres.service.DashboardInsertionService; import java.util.ArrayList; +import java.util.stream.Stream; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; @ExtendWith(MockitoExtension.class) +@DisplayName("Unit Test | Dashboard Extraction Service") class DashboardExtractionServiceTest { - @Mock OracleExtractionService oracleExtractionService; + @Mock + OracleExtractionService oracleExtractionService; - @Mock DashboardInsertionService dashboardInsertionService; + @Mock + DashboardInsertionService dashboardInsertionService; private DashboardExtractionService dashboardExtractionService; @@ -32,19 +38,50 @@ void setup() { new DashboardExtractionService(oracleExtractionService, dashboardInsertionService); } - @Test + @ParameterizedTest + @MethodSource("basicValues") @DisplayName("extract data for the dashboard happy path should succeed") - void extractDataForTheDashboard_happyPath_shouldSucceed() { - OracleExtractionParamsDto params = new OracleExtractionParamsDto(24, false, false); + void extractDataForTheDashboard_happyPath_shouldSucceed( + Integer months, + Boolean debug, + Boolean manuallyTriggered + ) { + OracleExtractionParamsDto params = new OracleExtractionParamsDto( + 24, + false, + false + ); OracleExtractionDto extractionDto = - new OracleExtractionDto(null, null, null, null, null, null, new ArrayList<>()); + new OracleExtractionDto( + null, + null, + null, + null, + null, + null, + new ArrayList<>() + ); when(oracleExtractionService.getOpeningActivities(params)).thenReturn(extractionDto); doNothing().when(dashboardInsertionService).loadDashboardData(any(), any(), any()); - dashboardExtractionService.extractDataForTheDashboard(null, null, null); + dashboardExtractionService.extractDataForTheDashboard(months, debug, manuallyTriggered); Assertions.assertFalse(extractionDto.logMessages().isEmpty()); } + + private static Stream basicValues() { + return Stream.of( + Arguments.of(24, false, false), + Arguments.of(24, false, null), + Arguments.of(24, null, false), + Arguments.of(24, null, null), + Arguments.of(null, false, false), + Arguments.of(null, null, false), + Arguments.of(null, null, null), + Arguments.of(null, false, null) + ); + } + } diff --git a/backend/src/test/java/ca/bc/gov/restapi/results/common/service/ForestClientServiceTest.java b/backend/src/test/java/ca/bc/gov/restapi/results/common/service/ForestClientServiceTest.java index 67e20492..801a6a31 100644 --- a/backend/src/test/java/ca/bc/gov/restapi/results/common/service/ForestClientServiceTest.java +++ b/backend/src/test/java/ca/bc/gov/restapi/results/common/service/ForestClientServiceTest.java @@ -12,10 +12,14 @@ import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.NullAndEmptySource; +import org.junit.jupiter.params.provider.ValueSource; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; @ExtendWith(MockitoExtension.class) +@DisplayName("Unit Test | Forest Client Service") class ForestClientServiceTest { @Mock ForestClientApiProvider forestClientApiProvider; @@ -107,4 +111,19 @@ void getClientByNumber_notFound_shouldSucceed() { Assertions.assertTrue(clientDto.isEmpty()); } + + @ParameterizedTest + @ValueSource(strings = {"", " ", " ", " "}) + @NullAndEmptySource + @DisplayName("No client number should return empty") + void shouldGetEmptyWhenNoClientNumber(String clientNumber) { + + when(forestClientApiProvider.fetchClientByNumber("00000000")) + .thenReturn(Optional.empty()); + + Optional clientDtoOptional = + forestClientService.getClientByNumber(clientNumber); + + Assertions.assertTrue(clientDtoOptional.isEmpty()); + } } diff --git a/backend/src/test/java/ca/bc/gov/restapi/results/common/service/RestServiceTest.java b/backend/src/test/java/ca/bc/gov/restapi/results/common/service/OpenMapsServiceTest.java similarity index 75% rename from backend/src/test/java/ca/bc/gov/restapi/results/common/service/RestServiceTest.java rename to backend/src/test/java/ca/bc/gov/restapi/results/common/service/OpenMapsServiceTest.java index 1a1a41e8..01924c78 100644 --- a/backend/src/test/java/ca/bc/gov/restapi/results/common/service/RestServiceTest.java +++ b/backend/src/test/java/ca/bc/gov/restapi/results/common/service/OpenMapsServiceTest.java @@ -15,7 +15,8 @@ import org.junit.jupiter.api.extension.RegisterExtension; import org.springframework.web.client.RestClient; -class RestServiceTest { +@DisplayName("Integrated Test | OpenMapsService") +class OpenMapsServiceIntegrationTest { @RegisterExtension static WireMockExtension clientApiStub = WireMockExtension @@ -30,7 +31,7 @@ class RestServiceTest { .configureStaticDsl(true) .build(); - private final RestService restService = new RestService( + private final OpenMapsService openMapsService = new OpenMapsService( RestClient.builder().baseUrl("http://localhost:10001").build() ); @@ -49,20 +50,20 @@ void getOpeningPolygonAndProperties_happyPath_shouldSucceed() { .withQueryParam("SrsName", equalTo("EPSG:4326")) .withQueryParam("PROPERTYNAME", equalTo("OPENING_ID," - + "GEOMETRY," - + "REGION_NAME," - + "REGION_CODE," - + "DISTRICT_NAME," - + "DISTRICT_CODE," - + "CLIENT_NAME," - + "CLIENT_NUMBER," - + "OPENING_WHEN_CREATED" + + "GEOMETRY," + + "REGION_NAME," + + "REGION_CODE," + + "DISTRICT_NAME," + + "DISTRICT_CODE," + + "CLIENT_NAME," + + "CLIENT_NUMBER," + + "OPENING_WHEN_CREATED" )) .withQueryParam("CQL_FILTER", equalTo("OPENING_ID=" + openingId)) .willReturn(okJson("{}")) ); - Object response = restService.getOpeningPolygonAndProperties(openingId); + Object response = openMapsService.getOpeningPolygonAndProperties(openingId); Assertions.assertNotNull(response); } @@ -82,20 +83,20 @@ void getOpeningPolygonAndProperties_notFound_shouldFail() { .withQueryParam("SrsName", equalTo("EPSG:4326")) .withQueryParam("PROPERTYNAME", equalTo("OPENING_ID," - + "GEOMETRY," - + "REGION_NAME," - + "REGION_CODE," - + "DISTRICT_NAME," - + "DISTRICT_CODE," - + "CLIENT_NAME," - + "CLIENT_NUMBER," - + "OPENING_WHEN_CREATED" + + "GEOMETRY," + + "REGION_NAME," + + "REGION_CODE," + + "DISTRICT_NAME," + + "DISTRICT_CODE," + + "CLIENT_NAME," + + "CLIENT_NUMBER," + + "OPENING_WHEN_CREATED" )) .withQueryParam("CQL_FILTER", equalTo("OPENING_ID=" + openingId)) .willReturn(notFound()) ); - Object response = restService.getOpeningPolygonAndProperties(openingId); + Object response = openMapsService.getOpeningPolygonAndProperties(openingId); Assertions.assertNull(response); } From f2ffa55d97ee572be07c29a8225dcb04de28e5f9 Mon Sep 17 00:00:00 2001 From: Paulo Gomes da Cruz Junior Date: Mon, 28 Oct 2024 06:14:00 -0700 Subject: [PATCH 10/10] chore: renamed test and added display name --- .../{UserServiceTest.java => LoggedUserServiceTest.java} | 3 ++- .../restapi/results/security/UserAuthenticationHelperTest.java | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) rename backend/src/test/java/ca/bc/gov/restapi/results/security/{UserServiceTest.java => LoggedUserServiceTest.java} (98%) diff --git a/backend/src/test/java/ca/bc/gov/restapi/results/security/UserServiceTest.java b/backend/src/test/java/ca/bc/gov/restapi/results/security/LoggedUserServiceTest.java similarity index 98% rename from backend/src/test/java/ca/bc/gov/restapi/results/security/UserServiceTest.java rename to backend/src/test/java/ca/bc/gov/restapi/results/security/LoggedUserServiceTest.java index 0c8d4b39..d4daa6b3 100644 --- a/backend/src/test/java/ca/bc/gov/restapi/results/security/UserServiceTest.java +++ b/backend/src/test/java/ca/bc/gov/restapi/results/security/LoggedUserServiceTest.java @@ -18,7 +18,8 @@ import org.springframework.test.context.junit.jupiter.SpringExtension; @ExtendWith(SpringExtension.class) -class UserServiceTest { +@DisplayName("Unit Test | LoggedUserService") +class LoggedUserServiceTest { @Mock UserAuthenticationHelper userAuthenticationHelper; diff --git a/backend/src/test/java/ca/bc/gov/restapi/results/security/UserAuthenticationHelperTest.java b/backend/src/test/java/ca/bc/gov/restapi/results/security/UserAuthenticationHelperTest.java index 051f2966..97d8d54c 100644 --- a/backend/src/test/java/ca/bc/gov/restapi/results/security/UserAuthenticationHelperTest.java +++ b/backend/src/test/java/ca/bc/gov/restapi/results/security/UserAuthenticationHelperTest.java @@ -20,6 +20,7 @@ import org.springframework.test.context.junit.jupiter.SpringExtension; @ExtendWith(SpringExtension.class) +@DisplayName("Unit Test | UserAuthenticationHelper") class UserAuthenticationHelperTest { private UserAuthenticationHelper userAuthenticationHelper;