Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 1435 different parent tree gw values and date update #1491

Merged
merged 32 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
ca30cb8
fix: stash WIP
craigyu Jul 29, 2024
4012dca
fix: pt query
craigyu Jul 30, 2024
4c2306a
Merge commit '488f4a8331055e7067cdabc87724ffb3ea78462c' into feat/143…
craigyu Aug 2, 2024
9ebb9b3
feat: new parent tree endpoint
craigyu Aug 7, 2024
cf6f4d4
fix: frontend adjustment with new endpoint
craigyu Aug 7, 2024
904ebd1
fix: add spu to orchard dto
craigyu Aug 7, 2024
6fa88b8
fix: skeleton display while orchard fetching
craigyu Aug 7, 2024
544c110
fix: enforce UTC timestamp
craigyu Aug 7, 2024
ee1ab94
fix: frontend refactor
craigyu Aug 8, 2024
4c77b55
fix: parent tree from outside
craigyu Aug 8, 2024
cad0f22
feat: add red colour to estimated gw
craigyu Aug 8, 2024
4877192
fix: adds bracket
craigyu Aug 8, 2024
8380e48
Merge commit 'fbce61e477ca4734d8744237de14941263bf3e9c' into feat/143…
craigyu Aug 8, 2024
c307c04
fix: styles
craigyu Aug 8, 2024
285e018
fix: refactor for submit seedlot
craigyu Aug 9, 2024
21d1ec2
fix: set untested_ind
craigyu Aug 9, 2024
63a2a45
fix: tested ind reverse not possible
craigyu Aug 9, 2024
87f271f
fix: comment
craigyu Aug 9, 2024
c114bf7
fix: tests
craigyu Aug 9, 2024
25a3b23
fix: log
craigyu Aug 9, 2024
6e39131
fix: list name
craigyu Aug 12, 2024
9842dc8
fix: explanation
craigyu Aug 12, 2024
8e434e7
fix: import order
craigyu Aug 12, 2024
0ac710d
fix: remove content
craigyu Aug 12, 2024
44382a0
fix: entity def
craigyu Aug 12, 2024
6ae622c
fix: better japa dog
craigyu Aug 12, 2024
d8791d4
Merge branch 'main' into feat/1435-different-parent-tree-gw-values
craigyu Aug 12, 2024
ae4b565
fix: parent tree by veg code sql query
craigyu Aug 12, 2024
189e60a
Merge branch 'feat/1435-different-parent-tree-gw-values' of https://g…
craigyu Aug 12, 2024
b32f40b
Merge commit '5fe264246b80c2f1094010c55faeef1460ea875f' into feat/143…
craigyu Aug 12, 2024
8d9bfaf
fix: num of smp parent from outside and date format
craigyu Aug 12, 2024
93a6b78
fix: cypress
craigyu Aug 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package ca.bc.gov.backendstartapi.dto;

import io.swagger.v3.oas.annotations.media.Schema;
import java.math.BigDecimal;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

/** This class represents a response body when a genetic worth entity is requested. */
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class GeneticWorthDto extends CodeDescriptionDto {
@Schema(description = "The default breeding value", example = "0.0")
private BigDecimal defaultBv;

public GeneticWorthDto(String code, String description, BigDecimal defaultBv) {
super(code, description);
this.defaultBv = defaultBv;
}
}
Original file line number Diff line number Diff line change
@@ -1,49 +1,71 @@
package ca.bc.gov.backendstartapi.dto;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;

/**
* This record represents the OrchardLotTypeDescriptionDto object found in the oracle-api service.
*/
@Schema(description = "Represents an Orchard object received from oracle-api.")
public record OrchardDto(
@Schema(
description =
"""
@Schema(description = "Represents an Orchard object received from oracle-api except spuId.")
@Getter
@Setter
public class OrchardDto {
@Schema(
description =
"""
A unique identifier which is assigned to a location where cuttings or
A class seed is produced.
""",
example = "339")
String id,
@Schema(
description = "The name of a location where cuttings or A class seed is produced.",
example = "EAGLEROCK")
String name,
@Schema(description = "A code which represents a species of tree or brush.", example = "PLI")
String vegetationCode,
@Schema(
description =
"""
example = "339")
private String id;

@Schema(
description = "The name of a location where cuttings or A class seed is produced.",
example = "EAGLEROCK")
private String name;

@Schema(description = "A code which represents a species of tree or brush.", example = "PLI")
private String vegetationCode;

@Schema(
description =
"""
A code representing a type of orchard. The two values will be 'S' (Seed Lot) or
'C' (Cutting Lot).
""",
example = "S")
Character lotTypeCode,
@Schema(
description =
"""
example = "S")
private Character lotTypeCode;

@Schema(
description =
"""
A description of the Orchard Lot Type code. The two values will be 'Seed Lot'
or 'Cutting Lot'.
""",
example = "Seed Lot")
String lotTypeDescription,
@Schema(
description = "A code which represents the current stage or status of an orchard.",
example = "PRD")
String stageCode,
@Schema(description = "The bgc zone code", example = "SBS") String becZoneCode,
@Schema(description = "The description of a bgc zone code", example = "Sub-Boreal Spruce")
String becZoneDescription,
@Schema(description = "The bgc sub-zone code", example = "wk") String becSubzoneCode,
@Schema(description = "The variant.", example = "1") Character variant,
@Schema(description = "The bec version id.", example = "5") Integer becVersionId) {}
example = "Seed Lot")
private String lotTypeDescription;

@Schema(
description = "A code which represents the current stage or status of an orchard.",
example = "PRD")
private String stageCode;

@Schema(description = "The bgc zone code", example = "SBS")
private String becZoneCode;

@Schema(description = "The description of a bgc zone code", example = "Sub-Boreal Spruce")
private String becZoneDescription;

@Schema(description = "The bgc sub-zone code", example = "wk")
private String becSubzoneCode;

@Schema(description = "The variant.", example = "1")
private Character variant;

@Schema(description = "The bec version id.", example = "5")
private Integer becVersionId;

@Schema(description = "Seed Plan Unit id", example = "7")
private Integer spuId;
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,24 @@ public record ParentTreeGeneticQualityDto(
@Schema(
description =
"""
Describes the comparative measure of genetic value for a specific genetic trait of a
parent tree. Examples are BV (Breeding Value) and CV (Clonal Value).
""",
Describes the comparative measure of genetic value for a specific genetic trait of a
parent tree. Examples are BV (Breeding Value) and CV (Clonal Value).
""",
example = "BV")
String geneticTypeCode,
@Schema(description = "A code describing various Genetic Worths.", example = "GVO")
String geneticWorthCode,
@Schema(
description =
"""
The genetic quality value based on the test assessment for a Parent Tree from a test
no. and series.
""",
The genetic quality value based on the test assessment for a Parent Tree from a test
no. and series.
""",
example = "18")
BigDecimal geneticQualityValue) {}
BigDecimal geneticQualityValue,
@Schema(description = "Whether the parent tree is tested", example = "true")
Boolean isParentTreeTested,
@Schema(
description = "Whether the genetic quality value is using default value.",
example = "false")
Boolean isEstimated) {}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ public class SameSpeciesTreeDto {
@Schema(description = "The seed plan unit this tree belongs to.", example = "7")
private Long spu;

@Schema(description = "Whether the tree is tested.", example = "True")
private Boolean tested;

private List<ParentTreeGeneticQualityDto> parentTreeGeneticQualities;

public SameSpeciesTreeDto() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
package ca.bc.gov.backendstartapi.endpoint;

import ca.bc.gov.backendstartapi.dto.CodeDescriptionDto;
import ca.bc.gov.backendstartapi.dto.GeneticWorthDto;
import ca.bc.gov.backendstartapi.entity.GeneticWorthEntity;
import ca.bc.gov.backendstartapi.security.RoleAccessConfig;
import ca.bc.gov.backendstartapi.service.GeneticWorthService;
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.ArraySchema;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.media.SchemaProperty;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
Expand Down Expand Up @@ -47,34 +46,14 @@ public class GeneticWorthEndpoint {
value = {
@ApiResponse(
responseCode = "200",
description = "An array of objects containing code and description for each value.",
content =
@Content(
array = @ArraySchema(schema = @Schema(type = "object")),
mediaType = "application/json",
schemaProperties = {
@SchemaProperty(
name = "code",
schema =
@Schema(
type = "string",
description = "This object represents a genetic worth code",
example = "AD")),
@SchemaProperty(
name = "description",
schema =
@Schema(
type = "string",
description = "The description of a genetic worth",
example = "Animal browse resistance (deer)"))
})),
description = "An array of objects containing code and description for each value."),
@ApiResponse(
responseCode = "401",
description = "Access token is missing or invalid",
content = @Content(schema = @Schema(implementation = Void.class)))
})
@RoleAccessConfig({"SPAR_TSC_ADMIN", "SPAR_MINISTRY_ORCHARD", "SPAR_NONMINISTRY_ORCHARD"})
public List<CodeDescriptionDto> getAllGeneticWorth() {
public List<GeneticWorthDto> getAllGeneticWorth() {
return geneticWorthService.getAllGeneticWorth();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
package ca.bc.gov.backendstartapi.endpoint;

import ca.bc.gov.backendstartapi.dto.OrchardDto;
import ca.bc.gov.backendstartapi.dto.OrchardSpuDto;
import ca.bc.gov.backendstartapi.dto.ParentTreeDto;
import ca.bc.gov.backendstartapi.dto.SameSpeciesTreeDto;
import ca.bc.gov.backendstartapi.security.RoleAccessConfig;
import ca.bc.gov.backendstartapi.service.OrchardService;
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.ArraySchema;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
Expand Down Expand Up @@ -66,38 +64,31 @@ public OrchardSpuDto getParentTreeGeneticQualityData(
}

/**
* Get all parent trees under a species (VegCode).
* Get all Orchards under a species (VegCode).
*
* @return A list of {@link ParentTreeDto}
* @return A list of {@link OrchardDto}
*/
@GetMapping(path = "/parent-trees/vegetation-codes/{vegCode}", produces = "application/json")
@GetMapping("/vegetation-codes/{vegCode}")
@Operation(
summary = "Retrieves all parent trees under a species (VegCode)",
description = "Returns a list containing all parent trees under a species (VegCode).")
@ApiResponses(
value = {
@ApiResponse(
responseCode = "200",
description = "An array of parent tree dto.",
content =
@Content(
array =
@ArraySchema(schema = @Schema(implementation = SameSpeciesTreeDto.class)),
mediaType = "application/json")),
@ApiResponse(responseCode = "200", description = "An array of parent tree dto."),
@ApiResponse(
responseCode = "401",
description = "Access token is missing or invalid",
content = @Content(schema = @Schema(implementation = Void.class)))
})
@RoleAccessConfig({"SPAR_TSC_ADMIN", "SPAR_MINISTRY_ORCHARD", "SPAR_NONMINISTRY_ORCHARD"})
public List<SameSpeciesTreeDto> getAllParentTreeByVegCode(
public List<OrchardDto> getAllOrchards(
@PathVariable("vegCode")
@Pattern(regexp = "^[a-zA-Z]{1,8}$")
@Parameter(
name = "vegCode",
in = ParameterIn.PATH,
description = "Identifier of the Orchard.")
String vegCode) {
return orchardService.findParentTreesByVegCode(vegCode);
return orchardService.findAllOrchardsByVegCode(vegCode);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import jakarta.persistence.PrePersist;
import jakarta.persistence.PreUpdate;
import jakarta.persistence.Table;
import java.time.Clock;
import java.time.LocalDateTime;
import lombok.AllArgsConstructor;
import lombok.Getter;
Expand Down Expand Up @@ -58,12 +59,12 @@ public FavouriteActivityEntity() {

@PrePersist
private void prePersist() {
entryTimestamp = LocalDateTime.now();
entryTimestamp = LocalDateTime.now(Clock.systemUTC());
updateTimestamp = entryTimestamp;
}

@PreUpdate
private void preUpdate() {
updateTimestamp = LocalDateTime.now();
updateTimestamp = LocalDateTime.now(Clock.systemUTC());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import java.math.BigDecimal;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
Expand All @@ -20,9 +21,17 @@ public class GeneticWorthEntity extends CodeDescriptionEntity {
@Column(name = "genetic_worth_code", length = 3)
private String geneticWorthCode;

@Column(name = "default_bv", nullable = false, precision = 3, scale = 1)
private BigDecimal defaultBv;

/** Constructor. */
public GeneticWorthEntity(
String geneticWorthCode, String description, EffectiveDateRange effectiveDateRange) {
String geneticWorthCode,
String description,
EffectiveDateRange effectiveDateRange,
BigDecimal defaultBv) {
super(description, effectiveDateRange);
this.geneticWorthCode = geneticWorthCode;
this.defaultBv = defaultBv;
craigyu marked this conversation as resolved.
Show resolved Hide resolved
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import jakarta.persistence.PreUpdate;
import java.io.Serial;
import java.io.Serializable;
import java.time.Clock;
import java.time.LocalDateTime;
import lombok.Generated;
import lombok.Getter;
Expand Down Expand Up @@ -46,12 +47,12 @@ public AuditInformation(@NonNull String userId) {

@PrePersist
private void prePersist() {
entryTimestamp = LocalDateTime.now();
entryTimestamp = LocalDateTime.now(Clock.systemUTC());
updateTimestamp = entryTimestamp;
}

@PreUpdate
private void preUpdate() {
updateTimestamp = LocalDateTime.now();
updateTimestamp = LocalDateTime.now(Clock.systemUTC());
}
}
Loading
Loading