generated from bcgov/quickstart-openshift
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into fix/1704-seedlots-not-updating-bv-values-cor…
…rectly
- Loading branch information
Showing
8 changed files
with
149 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
spring: | ||
datasource: | ||
url: jdbc:oracle:thin:@tcp://localhost:1521/dbdock_01 | ||
username: THE | ||
password: default |
73 changes: 73 additions & 0 deletions
73
oracle-api/src/main/java/ca/bc/gov/oracleapi/endpoint/SeedlotEndpoint.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package ca.bc.gov.oracleapi.endpoint; | ||
|
||
import ca.bc.gov.oracleapi.config.SparLog; | ||
import ca.bc.gov.oracleapi.entity.Seedlot; | ||
import ca.bc.gov.oracleapi.repository.SeedlotRepository; | ||
import ca.bc.gov.oracleapi.security.RoleAccessConfig; | ||
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.responses.ApiResponses; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
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 exposes seedlot resources API. */ | ||
@RestController | ||
@RequestMapping("/api/seedlot") | ||
@Tag(name = "seedlot", description = "Resource to retrieve seedlot") | ||
public class SeedlotEndpoint { | ||
|
||
private SeedlotRepository seedlotRepository; | ||
|
||
SeedlotEndpoint(SeedlotRepository seedlotRepository) { | ||
this.seedlotRepository = seedlotRepository; | ||
} | ||
|
||
/** | ||
* Retrieve a seedlot by seedlot number. | ||
* | ||
* @return A record of {@link Seedlot}. | ||
*/ | ||
@GetMapping( | ||
path = "/{seedlotNumber}", | ||
produces = "application/json") | ||
@Operation( | ||
summary = "Retrieve a seedlot by seedlot number", | ||
description = "Retrieve a seedlot by seedlot number ") | ||
@ApiResponses( | ||
value = { | ||
@ApiResponse( | ||
responseCode = "200", | ||
description = "Returns a record of seedlot", | ||
content = | ||
@Content( | ||
mediaType = "application/json", | ||
schema = @Schema(implementation = Seedlot.class))), | ||
@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 Seedlot getSeedlotBySeedlotNumber( | ||
@PathVariable | ||
@Parameter( | ||
name = "seedlotNumber", | ||
in = ParameterIn.PATH, | ||
description = "Identifier of the seedlot.") | ||
String seedlotNumber | ||
) { | ||
SparLog.info("Fetch a seedlot by seedlot number"); | ||
SparLog.info(seedlotNumber); | ||
Seedlot seedlot = seedlotRepository.findSeedlotBySeedlotNumber(seedlotNumber); | ||
SparLog.info("{} valid seedlot found.", seedlot); | ||
|
||
return seedlot; | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
oracle-api/src/main/java/ca/bc/gov/oracleapi/entity/Seedlot.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package ca.bc.gov.oracleapi.entity; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.Table; | ||
import lombok.Getter; | ||
import lombok.Setter; | ||
|
||
/** This class presents a funding source to an agency seedlot owner. */ | ||
@Getter | ||
@Setter | ||
@Entity | ||
@Table(name = "SEEDLOT") | ||
@Schema(description = "Represents a partial seedlot object in the database") | ||
public class Seedlot { | ||
|
||
@Id | ||
@Column(name = "SEEDLOT_NUMBER") | ||
@Schema(description = "The number of a seedlot", example = "16258") | ||
private Long seedlotNumber; | ||
|
||
@Column(name = "ORIGINAL_SEED_QTY") | ||
@Schema( | ||
description = "The original quantity of seeds in the seedlot", | ||
example = "1") | ||
private Long originalSeedQty; | ||
} |
13 changes: 13 additions & 0 deletions
13
oracle-api/src/main/java/ca/bc/gov/oracleapi/repository/SeedlotRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package ca.bc.gov.oracleapi.repository; | ||
|
||
import ca.bc.gov.oracleapi.entity.Seedlot; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Query; | ||
import org.springframework.data.repository.query.Param; | ||
|
||
/** This interface enables the funding source entity to be retrieved from the database. */ | ||
public interface SeedlotRepository extends JpaRepository<Seedlot, String> { | ||
|
||
@Query("SELECT s FROM Seedlot s WHERE s.seedlotNumber = :seedlotNumber") | ||
Seedlot findSeedlotBySeedlotNumber(@Param("seedlotNumber") String seedlotNumber); | ||
} |