Skip to content

Commit

Permalink
Replace flag state string by country code
Browse files Browse the repository at this point in the history
  • Loading branch information
louptheron committed Feb 1, 2024
1 parent 15e23a9 commit 3794f91
Show file tree
Hide file tree
Showing 25 changed files with 168 additions and 62 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package fr.gouv.cnsp.monitorfish.domain.entities.mission_actions

import com.neovisionaries.i18n.CountryCode
import fr.gouv.cnsp.monitorfish.domain.entities.mission.ControlUnit
import java.time.ZonedDateTime

Expand All @@ -11,7 +12,7 @@ data class MissionAction(
val internalReferenceNumber: String? = null,
val externalReferenceNumber: String? = null,
val ircs: String? = null,
val flagState: String? = null,
val flagState: CountryCode,
val districtCode: String? = null,
val faoAreas: List<String> = listOf(),
val actionType: MissionActionType,
Expand All @@ -35,7 +36,7 @@ data class MissionAction(
val unitWithoutOmegaGauge: Boolean? = null,
val controlQualityComments: String? = null,
val feedbackSheetRequired: Boolean? = null,
val userTrigram: String? = null,
val userTrigram: String,
val segments: List<FleetSegment> = listOf(),
val facade: String? = null,
val longitude: Double? = null,
Expand Down Expand Up @@ -87,17 +88,11 @@ data class MissionAction(
require(this.latitude != null) {
"A control must specify a position: the `latitude` must be given."
}
require(this.userTrigram != null) {
"A control must specify a user trigram: the `userTrigram` must be given."
}
}

private fun checkControlPort() {
require(this.portLocode != null) {
"A land control must specify a port: the `portLocode` must be given."
}
require(this.userTrigram != null) {
"A control must specify a user trigram: the `userTrigram` must be given."
}
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package fr.gouv.cnsp.monitorfish.infrastructure.api

import fr.gouv.cnsp.monitorfish.config.SentryConfig
import fr.gouv.cnsp.monitorfish.domain.exceptions.CouldNotUpdateControlObjectiveException
import fr.gouv.cnsp.monitorfish.domain.exceptions.CouldNotUpdateFleetSegmentException
import fr.gouv.cnsp.monitorfish.domain.exceptions.NAFMessageParsingException
import fr.gouv.cnsp.monitorfish.domain.exceptions.NoLogbookFishingTripFound
import fr.gouv.cnsp.monitorfish.domain.exceptions.*
import fr.gouv.cnsp.monitorfish.infrastructure.api.outputs.ApiError
import fr.gouv.cnsp.monitorfish.infrastructure.api.outputs.MissingParameterApiError
import io.sentry.Sentry
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package fr.gouv.cnsp.monitorfish.infrastructure.api.input

import com.neovisionaries.i18n.CountryCode
import fr.gouv.cnsp.monitorfish.domain.entities.mission_actions.*
import java.time.ZonedDateTime

Expand All @@ -10,7 +11,7 @@ data class AddMissionActionDataInput(
var internalReferenceNumber: String? = null,
var externalReferenceNumber: String? = null,
var ircs: String? = null,
var flagState: String? = null,
var flagState: CountryCode,
var districtCode: String? = null,
var faoAreas: List<String> = listOf(),
var flightGoals: List<FlightGoal> = listOf(),
Expand Down Expand Up @@ -42,7 +43,7 @@ data class AddMissionActionDataInput(
var seizureAndDiversionComments: String? = null,
var otherComments: String? = null,
var gearOnboard: List<GearControl> = listOf(),
var userTrigram: String? = null,
var userTrigram: String,
var speciesOnboard: List<SpeciesControl> = listOf(),
var vesselTargeted: ControlCheck? = null,
var hasSomeGearsSeized: Boolean = false,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package fr.gouv.cnsp.monitorfish.infrastructure.api.outputs

import com.neovisionaries.i18n.CountryCode
import fr.gouv.cnsp.monitorfish.domain.entities.mission.ControlUnit
import fr.gouv.cnsp.monitorfish.domain.entities.mission_actions.*
import java.time.ZonedDateTime
Expand All @@ -11,7 +12,7 @@ data class MissionActionDataOutput(
val internalReferenceNumber: String? = null,
val externalReferenceNumber: String? = null,
val ircs: String? = null,
val flagState: String? = null,
val flagState: CountryCode,
val districtCode: String? = null,
val faoAreas: List<String> = listOf(),
val flightGoals: List<FlightGoal> = listOf(),
Expand Down Expand Up @@ -47,7 +48,7 @@ data class MissionActionDataOutput(
val gearOnboard: List<GearControl> = listOf(),
val speciesOnboard: List<SpeciesControl> = listOf(),
val controlUnits: List<ControlUnit> = listOf(),
val userTrigram: String? = null,
val userTrigram: String,
val vesselTargeted: ControlCheck? = null,
val hasSomeGearsSeized: Boolean,
val hasSomeSpeciesSeized: Boolean,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package fr.gouv.cnsp.monitorfish.infrastructure.database.entities

import com.fasterxml.jackson.databind.ObjectMapper
import com.neovisionaries.i18n.CountryCode
import fr.gouv.cnsp.monitorfish.domain.entities.facade.Facade
import fr.gouv.cnsp.monitorfish.domain.entities.mission_actions.*
import io.hypersistence.utils.hibernate.type.array.ListArrayType
Expand Down Expand Up @@ -30,7 +31,8 @@ class MissionActionEntity(
@Column(name = "ircs")
val ircs: String? = null,
@Column(name = "flag_state")
val flagState: String? = null,
@Enumerated(EnumType.STRING)
val flagState: CountryCode,
@Column(name = "district_code")
val districtCode: String? = null,
@Type(ListArrayType::class)
Expand Down Expand Up @@ -94,7 +96,7 @@ class MissionActionEntity(
@Column(name = "is_from_poseidon")
val isFromPoseidon: Boolean,
@Column(name = "user_trigram")
val userTrigram: String? = null,
val userTrigram: String,
@Type(JsonBinaryType::class)
@Column(name = "segments", columnDefinition = "jsonb")
val segments: String? = null,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
ALTER TABLE mission_actions
ALTER COLUMN user_trigram SET NOT NULL;

UPDATE mission_actions
SET flag_state = 'UNDEFINED'
WHERE flag_state = 'UNKNOWN';

UPDATE mission_actions
SET flag_state = 'UNDEFINED'
WHERE flag_state = 'X';

UPDATE mission_actions
SET flag_state = 'UNDEFINED'
WHERE flag_state IS NULL;

UPDATE mission_actions
SET flag_state = upper(flag_state);

ALTER TABLE mission_actions
ALTER COLUMN flag_state SET NOT NULL;
Loading

0 comments on commit 3794f91

Please sign in to comment.