-
Notifications
You must be signed in to change notification settings - Fork 1
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
patch additional data #253
Changes from 12 commits
74e7ead
82c4b71
f19acff
2525b50
915d997
3636cd9
3e4c22f
bb82ce0
d7b127d
0994909
7bc0658
087bd14
3bfea09
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Copyright 2021 ABSA Group Limited | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package za.co.absa.atum.model.dto | ||
|
||
import io.circe.generic.semiauto.{deriveDecoder, deriveEncoder} | ||
import io.circe.{Decoder, Encoder} | ||
|
||
case class AdditionalDataPatchItemDTO( | ||
value: String, | ||
author: String | ||
) | ||
|
||
object AdditionalDataPatchItemDTO { | ||
implicit val encoderAdditionalDataPatchItem: Encoder[AdditionalDataPatchItemDTO] = deriveEncoder | ||
implicit val decoderAdditionalDataPatchItem: Decoder[AdditionalDataPatchItemDTO] = deriveDecoder | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,31 +17,42 @@ | |
package za.co.absa.atum.server.api.database.runs.functions | ||
|
||
import doobie.implicits.toSqlInterpolator | ||
import za.co.absa.atum.model.dto.AdditionalDataSubmitDTO | ||
import za.co.absa.atum.server.api.database.PostgresDatabaseProvider | ||
import za.co.absa.atum.server.api.database.runs.Runs | ||
import za.co.absa.atum.server.model.PartitioningForDB | ||
import za.co.absa.atum.server.model.AdditionalDataItemFromDB | ||
import za.co.absa.db.fadb.DBSchema | ||
import za.co.absa.db.fadb.doobie.DoobieFunction.DoobieSingleResultFunctionWithStatus | ||
import za.co.absa.db.fadb.doobie.DoobieFunction.DoobieMultipleResultFunctionWithAggStatus | ||
import za.co.absa.db.fadb.doobie.DoobieEngine | ||
import za.co.absa.db.fadb.status.handling.implementations.StandardStatusHandling | ||
import zio._ | ||
import io.circe.syntax._ | ||
|
||
import doobie.postgres.implicits._ | ||
import za.co.absa.db.fadb.doobie.postgres.circe.implicits.jsonbPut | ||
import za.co.absa.atum.model.dto.AdditionalDataPatchDTO | ||
import za.co.absa.atum.server.api.database.runs.functions.CreateOrUpdateAdditionalData.CreateOrUpdateAdditionalDataArgs | ||
import za.co.absa.db.fadb.status.aggregation.implementations.ByFirstRowStatusAggregator | ||
|
||
class CreateOrUpdateAdditionalData(implicit schema: DBSchema, dbEngine: DoobieEngine[Task]) | ||
extends DoobieSingleResultFunctionWithStatus[AdditionalDataSubmitDTO, Unit, Task](values => | ||
extends DoobieMultipleResultFunctionWithAggStatus[CreateOrUpdateAdditionalDataArgs, Option[ | ||
AdditionalDataItemFromDB | ||
], Task](args => | ||
Seq( | ||
fr"${PartitioningForDB.fromSeqPartitionDTO(values.partitioning).asJson}", | ||
fr"${values.additionalData.map { case (k, v) => (k, v.orNull) }}", | ||
fr"${values.author}" | ||
fr"${args.partitioningId}", | ||
fr"${args.additionalData.data}", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll take a deeper and proper look later, but why it's not allowed to have Option there? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't want to allow 'empty' values for PATCH operation. That's been discussed. Do you think we should reconsider the decision? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @lsulak There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay, thanks for the explanation |
||
fr"${args.additionalData.byUser}" | ||
) | ||
) | ||
with StandardStatusHandling | ||
with ByFirstRowStatusAggregator { | ||
|
||
override def fieldsToSelect: Seq[String] = super.fieldsToSelect ++ Seq("o_ad_name", "o_ad_value", "o_ad_author") | ||
} | ||
|
||
object CreateOrUpdateAdditionalData { | ||
case class CreateOrUpdateAdditionalDataArgs( | ||
partitioningId: Long, | ||
additionalData: AdditionalDataPatchDTO | ||
) | ||
|
||
val layer: URLayer[PostgresDatabaseProvider, CreateOrUpdateAdditionalData] = ZLayer { | ||
for { | ||
dbProvider <- ZIO.service[PostgresDatabaseProvider] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the whitespaces?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not recall adding this whitespace, probably automatic formatting was applied ... Commit below accepted.