diff --git a/backend/pom.xml b/backend/pom.xml index 230215a0..ce3b2ef8 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..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 @@ -3,26 +3,18 @@ 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 +27,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(@PathVariable 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(); }