-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMissionEnvActionDataInput.kt
49 lines (43 loc) · 1.98 KB
/
MissionEnvActionDataInput.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package fr.gouv.dgampa.rapportnav.infrastructure.api.bff.adapters.v2
import fr.gouv.dgampa.rapportnav.domain.entities.mission.env.envActions.ActionTypeEnum
import fr.gouv.dgampa.rapportnav.domain.entities.mission.v2.MissionEnvActionEntity
import java.time.Instant
import java.util.*
class MissionEnvActionDataInput(
override val startDateTimeUtc: Instant,
override val endDateTimeUtc: Instant? = null,
override val observations: String? = null,
override val controlSecurity: ControlSecurityInput2? = null,
override val controlGensDeMer: ControlGensDeMerInput2? = null,
override val controlNavigation: ControlNavigationInput2? = null,
override val controlAdministrative: ControlAdministrativeInput2? = null,
val infractions: List<InfractionByTargetInput2>? = null
) : MissionActionDataInput(
startDateTimeUtc = startDateTimeUtc,
endDateTimeUtc = endDateTimeUtc,
controlSecurity = controlSecurity,
controlGensDeMer = controlGensDeMer,
controlNavigation = controlNavigation,
controlAdministrative = controlAdministrative
) {
fun getInfractions(missionId: Int, actionId: String): List<InfractionInput2>? {
val infractions = infractions?.flatMap { it.infractions }
//?.filter { it.controlId != null || it.controlType != null }
infractions?.forEach { it.setMissionIdAndActionId(missionId, actionId) }
return infractions
}
companion object {
fun toMissionEnvActionEntity(input: MissionActionInput): MissionEnvActionEntity {
val data = input.env
val action = MissionEnvActionEntity(
id = UUID.fromString(input.id),
missionId = input.missionId,
endDateTimeUtc = data?.endDateTimeUtc,
startDateTimeUtc = data?.startDateTimeUtc,
observationsByUnit = data?.observations,
envActionType = ActionTypeEnum.valueOf(input.actionType.toString())
)
return action
}
}
}