From 8534a8cb8654a52eacb95a54c1177159c52c28de Mon Sep 17 00:00:00 2001 From: AB019TC Date: Mon, 23 Oct 2023 09:47:38 +0200 Subject: [PATCH] Closes #50 - Added some scala doc --- .../absa/atum/web/api/config/AtumConfig.scala | 8 ++++++++ .../absa/atum/web/api/config/BaseConfig.scala | 4 ++++ .../api/controller/CheckPointController.scala | 5 +++++ .../co/absa/atum/web/api/database/Runs.scala | 18 ++++++++++++++++++ .../atum/web/api/service/BaseApiService.scala | 7 ++++++- .../web/api/service/CheckPointService.scala | 4 ++++ .../api/service/PostgresAccessProvider.scala | 8 ++++++++ 7 files changed, 53 insertions(+), 1 deletion(-) diff --git a/server/src/main/scala/za/co/absa/atum/web/api/config/AtumConfig.scala b/server/src/main/scala/za/co/absa/atum/web/api/config/AtumConfig.scala index 4ba9f5213..3d820546a 100644 --- a/server/src/main/scala/za/co/absa/atum/web/api/config/AtumConfig.scala +++ b/server/src/main/scala/za/co/absa/atum/web/api/config/AtumConfig.scala @@ -20,12 +20,20 @@ import com.typesafe.config.{Config, ConfigFactory} trait AtumConfig { + /** + * + * @return + */ def dbConfig: Config } object AtumConfig extends AtumConfig { + /** + * + * @return + */ override def dbConfig: Config = { config.getConfig("postgres") } diff --git a/server/src/main/scala/za/co/absa/atum/web/api/config/BaseConfig.scala b/server/src/main/scala/za/co/absa/atum/web/api/config/BaseConfig.scala index 9828d3ef2..355feadba 100644 --- a/server/src/main/scala/za/co/absa/atum/web/api/config/BaseConfig.scala +++ b/server/src/main/scala/za/co/absa/atum/web/api/config/BaseConfig.scala @@ -18,6 +18,10 @@ package za.co.absa.atum.web.api.config import org.springframework.boot.context.properties.ConfigurationProperties +/** + * + * @param someKey + */ @ConfigurationProperties(prefix = "atum.web.api.config") class BaseConfig( val someKey: String diff --git a/server/src/main/scala/za/co/absa/atum/web/api/controller/CheckPointController.scala b/server/src/main/scala/za/co/absa/atum/web/api/controller/CheckPointController.scala index 6f1383ecb..9d1be5573 100644 --- a/server/src/main/scala/za/co/absa/atum/web/api/controller/CheckPointController.scala +++ b/server/src/main/scala/za/co/absa/atum/web/api/controller/CheckPointController.scala @@ -29,6 +29,11 @@ class CheckPointController { @Autowired() private val checkpointService: CheckPointService = null + /** + * + * @param checkpoint + * @return + */ @PostMapping(Array("/save-checkpoint")) def saveCheckpoint(@RequestBody checkpoint: CheckpointDTO): ResponseEntity[Unit] = { checkpointService.saveCheckpoint(checkpoint) diff --git a/server/src/main/scala/za/co/absa/atum/web/api/database/Runs.scala b/server/src/main/scala/za/co/absa/atum/web/api/database/Runs.scala index 0eb51b783..c8262f7d9 100644 --- a/server/src/main/scala/za/co/absa/atum/web/api/database/Runs.scala +++ b/server/src/main/scala/za/co/absa/atum/web/api/database/Runs.scala @@ -26,6 +26,10 @@ import za.co.absa.fadb.naming.implementations.SnakeCaseNaming.Implicits._ import za.co.absa.fadb.slick.{SlickFunctionWithStatusSupport, SlickPgEngine} import za.co.absa.fadb.status.handling.implementations.StandardStatusHandling +/** + * + * @param dBEngine + */ class Runs (implicit dBEngine: SlickPgEngine) extends DBSchema{ val writeCheckpoint = new WriteCheckpoint @@ -33,12 +37,22 @@ class Runs (implicit dBEngine: SlickPgEngine) extends DBSchema{ object Runs { + /** + * + * @param schema + * @param dbEngine + */ class WriteCheckpoint(implicit override val schema: DBSchema, override val dbEngine: SlickPgEngine) extends DBSingleResultFunction[CheckpointDTO, Unit, SlickPgEngine] with SlickFunctionWithStatusSupport[CheckpointDTO, Unit] with StandardStatusHandling { + /** + * + * @param values + * @return + */ override protected def sql(values: CheckpointDTO): SQLActionBuilder = { // ToDo serialize the partitioning and measurement columns into JSON object @@ -54,6 +68,10 @@ object Runs { ) #$alias;""" } + /** + * + * @return + */ override protected def slickConverter: GetResult[Unit] = GetResult { _ => } } } diff --git a/server/src/main/scala/za/co/absa/atum/web/api/service/BaseApiService.scala b/server/src/main/scala/za/co/absa/atum/web/api/service/BaseApiService.scala index 2e81fbe54..64daf5b09 100644 --- a/server/src/main/scala/za/co/absa/atum/web/api/service/BaseApiService.scala +++ b/server/src/main/scala/za/co/absa/atum/web/api/service/BaseApiService.scala @@ -39,8 +39,13 @@ abstract class BaseApiService[C <: BaseApiModel](dao: ApiModelDao[C]) { // default implementation that will work, but specific services may override it for optimization dao.getById(uuid).map(_.nonEmpty) } + /** - * Finds entity by `id` and applies method `fn`. Throws NotFoundException when not found + * Could not autowire. No beans of 'CheckPointService' type found. Throws NotFoundException when not found + * @param id + * @param fn + * @tparam S + * @return */ def withExistingEntity[S](id: UUID)(fn: C => S): Future[S] = { withExistingEntityF(id) { c => diff --git a/server/src/main/scala/za/co/absa/atum/web/api/service/CheckPointService.scala b/server/src/main/scala/za/co/absa/atum/web/api/service/CheckPointService.scala index ac0d50e9d..fe82dac14 100644 --- a/server/src/main/scala/za/co/absa/atum/web/api/service/CheckPointService.scala +++ b/server/src/main/scala/za/co/absa/atum/web/api/service/CheckPointService.scala @@ -28,6 +28,10 @@ class CheckPointService { @Autowired private val checkpointRepository: Runs = null + /** + * this service function saves the checkpoint into the database. + * @param checkpoint + */ def saveCheckpoint(checkpoint: CheckpointDTO): Unit = { this.checkpointRepository.writeCheckpoint(checkpoint) } diff --git a/server/src/main/scala/za/co/absa/atum/web/api/service/PostgresAccessProvider.scala b/server/src/main/scala/za/co/absa/atum/web/api/service/PostgresAccessProvider.scala index 3328b3c02..bf46ea952 100644 --- a/server/src/main/scala/za/co/absa/atum/web/api/service/PostgresAccessProvider.scala +++ b/server/src/main/scala/za/co/absa/atum/web/api/service/PostgresAccessProvider.scala @@ -24,11 +24,19 @@ import za.co.absa.atum.web.api.database.Runs import za.co.absa.atum.web.api.service.utils.ExecutorsProvider import za.co.absa.fadb.slick.SlickPgEngine +/** + * + * @param executors + */ @Component class PostgresAccessProvider@Autowired()( executors: ExecutorsProvider ) { private val config = ConfigFactory.load("application.properties") + /** + * + * @return + */ private def dbConfig: Config = { val conf = config.getConfig("postgres") print("Configs:", conf)