-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMissionNavActionEntity.kt
194 lines (184 loc) · 9.08 KB
/
MissionNavActionEntity.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
package fr.gouv.dgampa.rapportnav.domain.entities.mission.v2
import fr.gouv.dgampa.rapportnav.config.DependentFieldValue
import fr.gouv.dgampa.rapportnav.config.MandatoryForStats
import fr.gouv.dgampa.rapportnav.domain.entities.mission.env.MissionSourceEnum
import fr.gouv.dgampa.rapportnav.domain.entities.mission.env.envActions.VesselSizeEnum
import fr.gouv.dgampa.rapportnav.domain.entities.mission.env.envActions.VesselTypeEnum
import fr.gouv.dgampa.rapportnav.domain.entities.mission.nav.action.ActionType
import fr.gouv.dgampa.rapportnav.domain.entities.mission.nav.control.ControlMethod
import fr.gouv.dgampa.rapportnav.domain.entities.mission.nav.status.ActionStatusReason
import fr.gouv.dgampa.rapportnav.domain.entities.mission.nav.status.ActionStatusType
import fr.gouv.dgampa.rapportnav.domain.entities.mission.nav.status.DOCKED_STATUS_AS_STRING
import fr.gouv.dgampa.rapportnav.domain.entities.mission.nav.status.UNAVAILABLE_STATUS_AS_STRING
import fr.gouv.dgampa.rapportnav.domain.utils.EntityCompletenessValidator
import fr.gouv.dgampa.rapportnav.infrastructure.database.model.mission.action.v2.MissionActionModel
import java.time.Instant
import java.util.*
class MissionNavActionEntity(
@MandatoryForStats
override var id: UUID,
@MandatoryForStats
override var missionId: Int,
@MandatoryForStats
override var actionType: ActionType,
override var sourcesOfMissingDataForStats: List<MissionSourceEnum>? = null,
@MandatoryForStats
override var startDateTimeUtc: Instant? = null,
@MandatoryForStats(
enableIf = [DependentFieldValue(
field = "actionType",
value = ["ANTI_POLLUTION", "BAAEM_PERMANENCE", "CONTROL",
"VIGIMER", "REPRESENTATION", "PUBLIC_ORDER", "ILLEGAL_IMMIGRATION", "NAUTICAL_EVENT"]
)]
)
override var endDateTimeUtc: Instant? = null,
override var observations: String? = null,
@MandatoryForStats(enableIf = [DependentFieldValue(field = "actionType", value = ["CONTROL", "RESCUE"])])
override var latitude: Double? = null,
@MandatoryForStats(enableIf = [DependentFieldValue(field = "actionType", value = ["CONTROL", "RESCUE"])])
override var longitude: Double? = null,
override var detectedPollution: Boolean? = null,
override var pollutionObservedByAuthorizedAgent: Boolean? = null,
override var diversionCarriedOut: Boolean? = null,
override var isSimpleBrewingOperationDone: Boolean? = null,
override var isAntiPolDeviceDeployed: Boolean? = null,
@MandatoryForStats(enableIf = [DependentFieldValue(field = "actionType", value = ["CONTROL"])])
override var controlMethod: ControlMethod? = null,
@MandatoryForStats(enableIf = [DependentFieldValue(field = "actionType", value = ["CONTROL"])])
override var vesselIdentifier: String? = null,
@MandatoryForStats(enableIf = [DependentFieldValue(field = "actionType", value = ["CONTROL"])])
override var vesselType: VesselTypeEnum? = null,
@MandatoryForStats(enableIf = [DependentFieldValue(field = "actionType", value = ["CONTROL"])])
override var vesselSize: VesselSizeEnum? = null,
@MandatoryForStats(enableIf = [DependentFieldValue(field = "actionType", value = ["CONTROL"])])
override var identityControlledPerson: String? = null,
@MandatoryForStats(enableIf = [DependentFieldValue(field = "actionType", value = ["ILLEGAL_IMMIGRATION"])])
override var nbOfInterceptedVessels: Int? = null,
@MandatoryForStats(enableIf = [DependentFieldValue(field = "actionType", value = ["ILLEGAL_IMMIGRATION"])])
override var nbOfInterceptedMigrants: Int? = null,
@MandatoryForStats(enableIf = [DependentFieldValue(field = "actionType", value = ["ILLEGAL_IMMIGRATION"])])
override var nbOfSuspectedSmugglers: Int? = null,
override var isVesselRescue: Boolean? = false,
override var isPersonRescue: Boolean? = false,
override var isVesselNoticed: Boolean? = false,
override var isVesselTowed: Boolean? = false,
override var isInSRRorFollowedByCROSSMRCC: Boolean? = false,
@MandatoryForStats(
enableIf = [
DependentFieldValue(field = "actionType", value = ["RESCUE"]),
DependentFieldValue(
field = "isPersonRescue",
value = arrayOf("true")
),
]
)
override var numberPersonsRescued: Int? = null,
@MandatoryForStats(
enableIf = [
DependentFieldValue(field = "actionType", value = ["RESCUE"]),
DependentFieldValue(
field = "isPersonRescue",
value = arrayOf("true")
)
]
)
override var numberOfDeaths: Int? = null,
override var operationFollowsDEFREP: Boolean? = false,
override var locationDescription: String? = null,
override var isMigrationRescue: Boolean? = false,
@MandatoryForStats(
enableIf = [
DependentFieldValue(field = "actionType", value = ["RESCUE"]),
DependentFieldValue(
field = "isMigrationRescue",
value = arrayOf("true")
),
]
)
override var nbOfVesselsTrackedWithoutIntervention: Int? = null,
@MandatoryForStats(
enableIf = [
DependentFieldValue(field = "actionType", value = ["RESCUE"]),
DependentFieldValue(
field = "isMigrationRescue",
value = arrayOf("true")
),
]
)
override var nbAssistedVesselsReturningToShore: Int? = null,
@MandatoryForStats(
enableIf = [
DependentFieldValue(field = "actionType", value = ["STATUS"])
]
)
override var status: ActionStatusType? = null,
@MandatoryForStats(
enableIf = [
DependentFieldValue(field = "actionType", value = ["STATUS"]),
DependentFieldValue(
field = "status",
value = arrayOf(DOCKED_STATUS_AS_STRING, UNAVAILABLE_STATUS_AS_STRING)
),
]
)
override var reason: ActionStatusReason? = null,
) : MissionActionEntity(
status = status,
actionType = actionType,
missionId = missionId,
isCompleteForStats = false,
endDateTimeUtc = endDateTimeUtc,
startDateTimeUtc = startDateTimeUtc,
source = MissionSourceEnum.RAPPORTNAV
), BaseMissionNavAction {
override fun getActionId(): String {
return id.toString()
}
override fun computeCompleteness() {
this.isCompleteForStats = EntityCompletenessValidator.isCompleteForStats(this)
this.sourcesOfMissingDataForStats = listOf(MissionSourceEnum.RAPPORTNAV)
this.computeSummaryTags()
this.computeCompletenessForStats()
}
companion object {
fun fromMissionActionModel(model: MissionActionModel): MissionNavActionEntity {
return MissionNavActionEntity(
id = model.id,
missionId = model.missionId,
actionType = model.actionType, //model.actionType.let { ActionType.valueOf(it) },
startDateTimeUtc = model.startDateTimeUtc,
endDateTimeUtc = model.endDateTimeUtc,
observations = model.observations,
latitude = model.latitude,
longitude = model.longitude,
detectedPollution = model.detectedPollution,
pollutionObservedByAuthorizedAgent = model.pollutionObservedByAuthorizedAgent,
diversionCarriedOut = model.diversionCarriedOut,
isSimpleBrewingOperationDone = model.isSimpleBrewingOperationDone,
isAntiPolDeviceDeployed = model.isAntiPolDeviceDeployed,
controlMethod = model.controlMethod?.let { ControlMethod.valueOf(it) },
vesselIdentifier = model.vesselIdentifier,
vesselType = model.vesselType?.let { VesselTypeEnum.valueOf(it) },
vesselSize = model.vesselSize?.let { VesselSizeEnum.valueOf(it) },
identityControlledPerson = model.identityControlledPerson,
nbOfInterceptedVessels = model.nbOfInterceptedVessels,
nbOfInterceptedMigrants = model.nbOfInterceptedMigrants,
nbOfSuspectedSmugglers = model.nbOfSuspectedSmugglers,
isVesselRescue = model.isVesselRescue,
isPersonRescue = model.isPersonRescue,
isVesselNoticed = model.isVesselNoticed,
isVesselTowed = model.isVesselTowed,
isInSRRorFollowedByCROSSMRCC = model.isInSRRorFollowedByCROSSMRCC,
numberPersonsRescued = model.numberPersonsRescued,
numberOfDeaths = model.numberOfDeaths,
operationFollowsDEFREP = model.operationFollowsDEFREP,
locationDescription = model.locationDescription,
isMigrationRescue = model.isMigrationRescue,
nbOfVesselsTrackedWithoutIntervention = model.nbOfVesselsTrackedWithoutIntervention,
nbAssistedVesselsReturningToShore = model.nbAssistedVesselsReturningToShore,
status = model.status?.let { ActionStatusType.valueOf(it) },
reason = model.reason?.let { ActionStatusReason.valueOf(it) }
)
}
}
}