Skip to content

Commit

Permalink
Fixes #120 - Merged master
Browse files Browse the repository at this point in the history
  • Loading branch information
TebaleloS committed Mar 20, 2024
1 parent 6d7145b commit 1896eba
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ class PartitioningControllerImpl(partitioningService: PartitioningService)
serviceCallWithStatus[Unit, AtumContextDTO](
partitioningService.createPartitioningIfNotExists(partitioning),
_ => {
val measures: Set[MeasureDTO] = Set(MeasureDTO("count", Seq("*")))
val additionalData: AdditionalDataDTO = Map.empty
val measures: Set[MeasureDTO] = Set(partitioningService.getPartitioningMeasures(partitioning))
val additionalData: AdditionalDataDTO = partitioningService.getPartioningAdditionalData(partitioning)
AtumContextDTO(partitioning.partitioning, measures, additionalData)
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,16 @@

package za.co.absa.atum.server.api.repository

import za.co.absa.atum.model.dto.{AdditionalDataSubmitDTO, PartitioningSubmitDTO}
import za.co.absa.atum.server.api.database.runs.functions.{CreateOrUpdateAdditionalData, CreatePartitioningIfNotExists}
import za.co.absa.atum.model.dto.{AdditionalDataDTO, AdditionalDataSubmitDTO, MeasureDTO, PartitioningSubmitDTO}
import za.co.absa.atum.server.api.database.runs.functions.{CreateOrUpdateAdditionalData, CreatePartitioningIfNotExists, GetPartitioningAdditionalData, GetPartitioningMeasures}
import za.co.absa.atum.server.api.exception.DatabaseError
import za.co.absa.fadb.exceptions.StatusException
import zio._

class PartitioningRepositoryImpl(
createPartitioningIfNotExistsFn: CreatePartitioningIfNotExists,
getPartitioningMeasuresFn: GetPartitioningMeasures,
getPartitioningAdditionalDataFn: GetPartitioningAdditionalData,
createOrUpdateAdditionalDataFn: CreateOrUpdateAdditionalData
) extends PartitioningRepository with BaseRepository {

Expand All @@ -39,13 +41,28 @@ class PartitioningRepositoryImpl(
dbCallWithStatus(createOrUpdateAdditionalDataFn(additionalData), "createOrUpdateAdditionalData")
}

override def getPartitioningMeasures(partitioning: PartitioningSubmitDTO):
IO[DatabaseError, Either[StatusException, Seq[MeasureDTO]]] = {
dbCallWithStatus(getPartitioningMeasuresFn(partitioning), "getPartitioningMeasures")
}

override def getPartitioningAdditionalData(partitioning: PartitioningSubmitDTO):
IO[DatabaseError, Either[StatusException, Seq[AdditionalDataDTO]]] = {
dbCallWithStatus(getPartitioningAdditionalDataFn(partitioning), "getPartitioningAdditionalData")
}
}

object PartitioningRepositoryImpl {
val layer: URLayer[CreatePartitioningIfNotExists with CreateOrUpdateAdditionalData, PartitioningRepository] = ZLayer {
val layer: URLayer[CreatePartitioningIfNotExists with GetPartitioningMeasures with GetPartitioningAdditionalData with CreateOrUpdateAdditionalData, PartitioningRepository] = ZLayer {
for {
createPartitioningIfNotExists <- ZIO.service[CreatePartitioningIfNotExists]
getPartitioningMeasures <- ZIO.service[GetPartitioningMeasures]
getPartitioningAdditionalData <- ZIO.service[GetPartitioningAdditionalData]
createOrUpdateAdditionalData <- ZIO.service[CreateOrUpdateAdditionalData]
} yield new PartitioningRepositoryImpl(createPartitioningIfNotExists, createOrUpdateAdditionalData)
} yield new PartitioningRepositoryImpl(
createPartitioningIfNotExists,
getPartitioningMeasures,
getPartitioningAdditionalData,
createOrUpdateAdditionalData)
}
}

0 comments on commit 1896eba

Please sign in to comment.