-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[feat] using Optional for patch function
- Loading branch information
1 parent
6aab2d4
commit 773e5d4
Showing
18 changed files
with
218 additions
and
283 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 0 additions & 7 deletions
7
backend/src/main/kotlin/fr/gouv/cacem/monitorenv/domain/entities/PatchableEntity.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
...in/fr/gouv/cacem/monitorenv/domain/entities/mission/envAction/PatchableEnvActionEntity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package fr.gouv.cacem.monitorenv.domain.entities.mission.envAction | ||
|
||
import java.time.ZonedDateTime | ||
import java.util.Optional | ||
|
||
data class PatchableEnvActionEntity( | ||
val actionStartDateTimeUtc: Optional<ZonedDateTime>?, | ||
val actionEndDateTimeUtc: Optional<ZonedDateTime>?, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 5 additions & 5 deletions
10
backend/src/main/kotlin/fr/gouv/cacem/monitorenv/domain/use_cases/actions/PatchEnvAction.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 0 additions & 9 deletions
9
...main/kotlin/fr/gouv/cacem/monitorenv/domain/use_cases/actions/interactors/IDataPatcher.kt
This file was deleted.
Oops, something went wrong.
40 changes: 40 additions & 0 deletions
40
...lin/fr/gouv/cacem/monitorenv/domain/use_cases/actions/interactors/MergeEnvActionEntity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package fr.gouv.cacem.monitorenv.domain.use_cases.actions.interactors | ||
|
||
import fr.gouv.cacem.monitorenv.config.UseCase | ||
import fr.gouv.cacem.monitorenv.domain.entities.mission.envAction.EnvActionEntity | ||
import fr.gouv.cacem.monitorenv.domain.entities.mission.envAction.PatchableEnvActionEntity | ||
import java.time.ZonedDateTime | ||
import java.util.Optional | ||
|
||
@UseCase | ||
class MergeEnvActionEntity { | ||
|
||
fun execute( | ||
envActionEntity: EnvActionEntity, | ||
patchableEnvActionEntity: PatchableEnvActionEntity, | ||
): EnvActionEntity { | ||
val patchedActionEndDateTime = | ||
getValueFromOptional( | ||
envActionEntity.actionEndDateTimeUtc, | ||
patchableEnvActionEntity.actionEndDateTimeUtc, | ||
) | ||
val patchedActionStartDateTime = getValueFromOptional( | ||
envActionEntity.actionStartDateTimeUtc, | ||
patchableEnvActionEntity.actionStartDateTimeUtc, | ||
) | ||
envActionEntity.actionEndDateTimeUtc = patchedActionEndDateTime | ||
envActionEntity.actionStartDateTimeUtc = patchedActionStartDateTime | ||
return envActionEntity | ||
} | ||
|
||
private fun getValueFromOptional( | ||
actionEndDateTimeUtc: ZonedDateTime?, | ||
oActionEndDateTimeUtc: Optional<ZonedDateTime>?, | ||
) = if (oActionEndDateTimeUtc == null) { | ||
actionEndDateTimeUtc | ||
} else if (oActionEndDateTimeUtc.isEmpty) { | ||
null | ||
} else { | ||
oActionEndDateTimeUtc.get() | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
.../monitorenv/infrastructure/api/adapters/bff/inputs/actions/PatchableEnvActionDataInput.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package fr.gouv.cacem.monitorenv.infrastructure.api.adapters.bff.inputs.actions | ||
|
||
import fr.gouv.cacem.monitorenv.domain.entities.mission.envAction.PatchableEnvActionEntity | ||
import java.time.ZonedDateTime | ||
import java.util.Optional | ||
|
||
data class PatchableEnvActionDataInput( | ||
val actionStartDateTimeUtc: Optional<ZonedDateTime>?, | ||
val actionEndDateTimeUtc: Optional<ZonedDateTime>?, | ||
) { | ||
fun toPatchableEnvActionEntity(): PatchableEnvActionEntity { | ||
return PatchableEnvActionEntity( | ||
actionStartDateTimeUtc = actionStartDateTimeUtc, | ||
actionEndDateTimeUtc = actionEndDateTimeUtc, | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 0 additions & 42 deletions
42
backend/src/main/kotlin/fr/gouv/cacem/monitorenv/infrastructure/mapper/PatchData.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.