Skip to content

Commit

Permalink
Don't require a label for Entity updates
Browse files Browse the repository at this point in the history
  • Loading branch information
grzesiek2010 committed Nov 15, 2024
1 parent 1ff31bc commit 036cfb9
Showing 1 changed file with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,20 @@ object LocalEntityUseCases {
formEntities?.entities?.forEach { formEntity ->
val id = formEntity.id
val label = formEntity.label
if (id != null && !label.isNullOrEmpty()) {
if (id != null) {
when (formEntity.action) {
EntityAction.CREATE -> {
val entity = Entity.New(
id,
label,
1,
formEntity.properties,
branchId = UUID.randomUUID().toString()
)
if (!label.isNullOrEmpty()) {
val entity = Entity.New(
id,
label,
1,
formEntity.properties,
branchId = UUID.randomUUID().toString()
)

entitiesRepository.save(formEntity.dataset, entity)
entitiesRepository.save(formEntity.dataset, entity)
}
}

EntityAction.UPDATE -> {
Expand All @@ -41,7 +43,7 @@ object LocalEntityUseCases {
entitiesRepository.save(
formEntity.dataset,
existing.copy(
label = label,
label = if (label.isNullOrBlank()) existing.label else label,
properties = formEntity.properties,
version = existing.version + 1
)
Expand Down

0 comments on commit 036cfb9

Please sign in to comment.