Skip to content

Commit

Permalink
Closes #50 - Added some scala doc
Browse files Browse the repository at this point in the history
  • Loading branch information
TebaleloS committed Oct 23, 2023
1 parent 0e84b16 commit 8534a8c
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
18 changes: 18 additions & 0 deletions server/src/main/scala/za/co/absa/atum/web/api/database/Runs.scala
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,33 @@ 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
}

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
Expand All @@ -54,6 +68,10 @@ object Runs {
) #$alias;"""
}

/**
*
* @return
*/
override protected def slickConverter: GetResult[Unit] = GetResult { _ => }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 8534a8c

Please sign in to comment.