From b59812636c02b80d43f99be918ea4349666bdc8a Mon Sep 17 00:00:00 2001 From: Loup Theron Date: Tue, 4 Feb 2025 15:32:07 +0100 Subject: [PATCH] Finalize not nullable types --- .../entities/last_position/LastPosition.kt | 16 +++-- .../domain/entities/logbook/LogbookMessage.kt | 2 +- .../logbook/LogbookTransmissionFormat.kt | 1 + .../entities/risk_factor/VesselRiskFactor.kt | 6 +- .../domain/entities/vessel/Vessel.kt | 2 +- .../monitorfish/domain/mappers/ERSMapper.kt | 2 +- .../CreateOrUpdateManualPriorNotification.kt | 2 +- .../reporting/GetVesselReportings.kt | 9 +-- .../use_cases/vessel/GetVesselRiskFactor.kt | 11 ++-- .../light/outputs/LastPositionDataOutput.kt | 4 +- .../light/outputs/LogbookMessageDataOutput.kt | 4 +- .../api/light/outputs/VesselDataOutput.kt | 2 +- .../api/outputs/LastPositionDataOutput.kt | 17 +++--- .../api/outputs/LogbookMessageDataOutput.kt | 4 +- .../api/outputs/RiskFactorDataOutput.kt | 4 +- .../api/outputs/VesselDataOutput.kt | 2 +- .../BaseLogbookMessageDataOutput.kt | 2 +- .../database/entities/LastPositionEntity.kt | 12 ++-- .../database/entities/LogbookReportEntity.kt | 29 +++------ .../entities/ManualPriorNotificationEntity.kt | 2 +- .../database/entities/MissionActionEntity.kt | 2 +- .../database/entities/RiskFactorsEntity.kt | 22 +++---- .../database/entities/VesselEntity.kt | 2 +- .../database/entities/converters/Utils.kt | 21 +++++++ .../V0.290__Update_last_positions_table.sql | 30 ++++++++++ .../testdata/V666.2__Insert_dummy_vessels.sql | 60 +++++++++---------- .../V666.3__Insert_dummy_last_positions.sql | 8 +-- .../json/V666.2__Insert_dummy_vessels.jsonc | 31 ++++++++++ .../monitorfish/fakers/LogbookMessageFaker.kt | 2 +- .../cnsp/monitorfish/fakers/VesselFaker.kt | 2 +- ...ManualPriorNotificationRepositoryITests.kt | 7 +-- .../vessel_sidebar/logbook.spec.ts | 2 +- .../alert_list/alerts_list.spec.ts | 4 +- frontend/src/features/Vessel/Vessel.types.ts | 2 +- .../schemas/VesselLastPositionSchema.ts | 13 ++-- 35 files changed, 206 insertions(+), 135 deletions(-) create mode 100644 backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/converters/Utils.kt create mode 100644 backend/src/main/resources/db/migration/internal/V0.290__Update_last_positions_table.sql diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/last_position/LastPosition.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/last_position/LastPosition.kt index e5ab6bb5c9..baa8de0969 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/last_position/LastPosition.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/last_position/LastPosition.kt @@ -2,6 +2,10 @@ package fr.gouv.cnsp.monitorfish.domain.entities.last_position import com.neovisionaries.i18n.CountryCode import fr.gouv.cnsp.monitorfish.domain.entities.position.PositionType +import fr.gouv.cnsp.monitorfish.domain.entities.risk_factor.defaultDetectabilityRiskFactor +import fr.gouv.cnsp.monitorfish.domain.entities.risk_factor.defaultImpactRiskFactor +import fr.gouv.cnsp.monitorfish.domain.entities.risk_factor.defaultProbabilityRiskFactor +import fr.gouv.cnsp.monitorfish.domain.entities.risk_factor.defaultRiskFactor import fr.gouv.cnsp.monitorfish.domain.entities.vessel.VesselIdentifier import java.time.Duration import java.time.ZonedDateTime @@ -41,17 +45,17 @@ data class LastPosition( val gearOnboard: List? = listOf(), val segments: List? = listOf(), val speciesOnboard: List? = listOf(), - val totalWeightOnboard: Double? = null, + val totalWeightOnboard: Double = 0.0, val lastControlDateTime: ZonedDateTime? = null, val lastControlInfraction: Boolean? = null, val postControlComment: String? = null, val vesselIdentifier: VesselIdentifier, - val impactRiskFactor: Double? = null, - val probabilityRiskFactor: Double? = null, - val detectabilityRiskFactor: Double? = null, - val riskFactor: Double? = null, + val impactRiskFactor: Double = defaultImpactRiskFactor, + val probabilityRiskFactor: Double = defaultProbabilityRiskFactor, + val detectabilityRiskFactor: Double = defaultDetectabilityRiskFactor, + val riskFactor: Double = defaultRiskFactor, val underCharter: Boolean? = null, - val isAtPort: Boolean? = null, + val isAtPort: Boolean = false, val alerts: List? = listOf(), val beaconMalfunctionId: Int? = null, val reportings: List = listOf(), diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/logbook/LogbookMessage.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/logbook/LogbookMessage.kt index edd08fedcb..2d4451df24 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/logbook/LogbookMessage.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/logbook/LogbookMessage.kt @@ -26,7 +26,7 @@ data class LogbookMessage( // Reception date of the report by the data center val integrationDateTime: ZonedDateTime, var rawMessage: String? = null, - val transmissionFormat: LogbookTransmissionFormat?, + val transmissionFormat: LogbookTransmissionFormat, val software: String? = null, var acknowledgment: Acknowledgment? = null, var isCorrectedByNewerMessage: Boolean = false, diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/logbook/LogbookTransmissionFormat.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/logbook/LogbookTransmissionFormat.kt index d30ec9a54c..930b9b5525 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/logbook/LogbookTransmissionFormat.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/logbook/LogbookTransmissionFormat.kt @@ -1,6 +1,7 @@ package fr.gouv.cnsp.monitorfish.domain.entities.logbook enum class LogbookTransmissionFormat { + MANUAL, ERS, FLUX, } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/risk_factor/VesselRiskFactor.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/risk_factor/VesselRiskFactor.kt index 8635a16fa9..7bb7de2400 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/risk_factor/VesselRiskFactor.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/risk_factor/VesselRiskFactor.kt @@ -34,9 +34,9 @@ data class VesselRiskFactor( /** CFR (Community Fleet Register Number). */ val internalReferenceNumber: String? = null, val vesselId: Int? = null, - val gearOnboard: List? = listOf(), - val speciesOnboard: List? = listOf(), - val totalWeightOnboard: Double? = null, + val gearOnboard: List = listOf(), + val speciesOnboard: List = listOf(), + val totalWeightOnboard: Double = 0.0, val segments: List = listOf(), val probableSegments: List? = listOf(), val segmentHighestImpact: String? = null, diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/vessel/Vessel.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/vessel/Vessel.kt index a319652208..b01b8f0923 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/vessel/Vessel.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/vessel/Vessel.kt @@ -32,7 +32,7 @@ data class Vessel( val vesselType: String? = null, val sailingCategory: String? = null, val sailingType: String? = null, - val declaredFishingGears: List? = null, + val declaredFishingGears: List = listOf(), val pinger: Boolean? = null, val navigationLicenceExpirationDate: Date? = null, val navigationLicenceExtensionDate: Date? = null, diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/mappers/ERSMapper.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/mappers/ERSMapper.kt index ae16174384..db87d1430c 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/mappers/ERSMapper.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/mappers/ERSMapper.kt @@ -10,7 +10,7 @@ import org.springframework.stereotype.Component @Component object ERSMapper { - private const val JSONB_NULL_STRING = "null" + const val JSONB_NULL_STRING = "null" fun getERSMessageValueFromJSON( mapper: ObjectMapper, diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/CreateOrUpdateManualPriorNotification.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/CreateOrUpdateManualPriorNotification.kt index 14ac649a9e..922efe7eec 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/CreateOrUpdateManualPriorNotification.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/CreateOrUpdateManualPriorNotification.kt @@ -122,7 +122,7 @@ class CreateOrUpdateManualPriorNotification( reportDateTime = sentAt, integrationDateTime = ZonedDateTime.now(), rawMessage = null, - transmissionFormat = null, + transmissionFormat = LogbookTransmissionFormat.MANUAL, software = null, acknowledgment = null, isCorrectedByNewerMessage = false, diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/reporting/GetVesselReportings.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/reporting/GetVesselReportings.kt index 53b1ae6458..abe1a34dd5 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/reporting/GetVesselReportings.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/reporting/GetVesselReportings.kt @@ -78,10 +78,11 @@ class GetVesselReportings( logger.info("TIME_RECORD - 'archivedYearsToReportings' took $archivedYearsToReportingsTimeTaken") val twelveMonthsAgo = ZonedDateTime.now().minusMonths(12) - val lastTwelveMonthsReportings = reportings.filter { reporting -> - reporting.validationDate?.isAfter(twelveMonthsAgo) - ?: reporting.creationDate.isAfter(twelveMonthsAgo) - } + val lastTwelveMonthsReportings = + reportings.filter { reporting -> + reporting.validationDate?.isAfter(twelveMonthsAgo) + ?: reporting.creationDate.isAfter(twelveMonthsAgo) + } val (infractionSuspicionsSummary, infractionSuspicionsSummaryTimeTaken) = measureTimedValue { diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/vessel/GetVesselRiskFactor.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/vessel/GetVesselRiskFactor.kt index d34c4218bb..32fa7e1661 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/vessel/GetVesselRiskFactor.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/vessel/GetVesselRiskFactor.kt @@ -15,11 +15,12 @@ class GetVesselRiskFactor( private val logger: Logger = LoggerFactory.getLogger(GetVesselRiskFactor::class.java) fun execute(internalReferenceNumber: String): VesselRiskFactor { - val riskFactor = riskFactorRepository.findByInternalReferenceNumber(internalReferenceNumber) - ?: throw BackendUsageException( - BackendUsageErrorCode.NOT_FOUND_BUT_OK, - message = "No risk factor found for vessel $internalReferenceNumber", - ) + val riskFactor = + riskFactorRepository.findByInternalReferenceNumber(internalReferenceNumber) + ?: throw BackendUsageException( + BackendUsageErrorCode.NOT_FOUND_BUT_OK, + message = "No risk factor found for vessel $internalReferenceNumber", + ) return riskFactor } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/light/outputs/LastPositionDataOutput.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/light/outputs/LastPositionDataOutput.kt index 61c93a272f..9426642105 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/light/outputs/LastPositionDataOutput.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/light/outputs/LastPositionDataOutput.kt @@ -37,12 +37,12 @@ data class LastPositionDataOutput( val gearOnboard: List? = null, val segments: List? = listOf(), val speciesOnboard: List? = null, - val totalWeightOnboard: Double? = null, + val totalWeightOnboard: Double, val lastControlDateTime: ZonedDateTime? = null, val lastControlInfraction: Boolean? = null, val vesselIdentifier: VesselIdentifier, val underCharter: Boolean? = null, - val isAtPort: Boolean? = null, + val isAtPort: Boolean, val beaconMalfunctionId: Int? = null, ) { companion object { diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/light/outputs/LogbookMessageDataOutput.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/light/outputs/LogbookMessageDataOutput.kt index d3f6f828d2..32a778e751 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/light/outputs/LogbookMessageDataOutput.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/light/outputs/LogbookMessageDataOutput.kt @@ -17,7 +17,7 @@ data class LogbookMessageDataOutput( override val operationDateTime: ZonedDateTime?, override val activityDateTime: ZonedDateTime?, override val reportDateTime: ZonedDateTime?, - override val integrationDateTime: ZonedDateTime?, + override val integrationDateTime: ZonedDateTime, override val internalReferenceNumber: String?, override val externalReferenceNumber: String?, override val ircs: String?, @@ -29,7 +29,7 @@ data class LogbookMessageDataOutput( override val isDeleted: Boolean, override val message: LogbookMessageValue?, override val isSentByFailoverSoftware: Boolean, -): BaseLogbookMessageDataOutput { +) : BaseLogbookMessageDataOutput { companion object { fun fromLogbookMessage(logbookMessage: LogbookMessage) = LogbookMessageDataOutput( diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/light/outputs/VesselDataOutput.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/light/outputs/VesselDataOutput.kt index b2e5f7aad3..d0deb7577f 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/light/outputs/VesselDataOutput.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/light/outputs/VesselDataOutput.kt @@ -25,7 +25,7 @@ data class VesselDataOutput( val vesselType: String? = null, val sailingCategory: String? = null, val sailingType: String? = null, - val declaredFishingGears: List? = null, + val declaredFishingGears: List, val pinger: Boolean? = null, val navigationLicenceExpirationDate: Date? = null, val navigationLicenceExtensionDate: Date? = null, diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/LastPositionDataOutput.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/LastPositionDataOutput.kt index 6210d24dc9..4a2b34b3e6 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/LastPositionDataOutput.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/LastPositionDataOutput.kt @@ -35,17 +35,17 @@ data class LastPositionDataOutput( val gearOnboard: List, val segments: List, val speciesOnboard: List, - val totalWeightOnboard: Double? = null, + val totalWeightOnboard: Double, val lastControlDateTime: ZonedDateTime? = null, val lastControlInfraction: Boolean? = null, val postControlComment: String? = null, val vesselIdentifier: VesselIdentifier, - val impactRiskFactor: Double? = null, - val probabilityRiskFactor: Double? = null, - val detectabilityRiskFactor: Double? = null, - val riskFactor: Double? = null, + val impactRiskFactor: Double, + val probabilityRiskFactor: Double, + val detectabilityRiskFactor: Double, + val riskFactor: Double, val underCharter: Boolean? = null, - val isAtPort: Boolean? = null, + val isAtPort: Boolean, val alerts: List, val beaconMalfunctionId: Int? = null, val reportings: List = listOf(), @@ -77,8 +77,9 @@ data class LastPositionDataOutput( registryPortName = position.registryPortName, district = position.district, districtCode = position.districtCode, - gearOnboard = position.gearOnboard?.map { GearLastPositionDataOutput.fromGearLastPosition(it) } - ?: listOf(), + gearOnboard = + position.gearOnboard?.map { GearLastPositionDataOutput.fromGearLastPosition(it) } + ?: listOf(), segments = position.segments ?: listOf(), speciesOnboard = position.speciesOnboard?.map { diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/LogbookMessageDataOutput.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/LogbookMessageDataOutput.kt index 80f4d39802..e862ed2995 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/LogbookMessageDataOutput.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/LogbookMessageDataOutput.kt @@ -15,7 +15,7 @@ data class LogbookMessageDataOutput( override val operationDateTime: ZonedDateTime?, override val activityDateTime: ZonedDateTime?, override val reportDateTime: ZonedDateTime?, - override val integrationDateTime: ZonedDateTime?, + override val integrationDateTime: ZonedDateTime, override val internalReferenceNumber: String?, override val externalReferenceNumber: String?, override val ircs: String?, @@ -32,7 +32,7 @@ data class LogbookMessageDataOutput( val rawMessage: String?, val tripGears: List?, val tripSegments: List?, -): BaseLogbookMessageDataOutput { +) : BaseLogbookMessageDataOutput { companion object { fun fromLogbookMessage(logbookMessage: LogbookMessage): LogbookMessageDataOutput { val tripGears = diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/RiskFactorDataOutput.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/RiskFactorDataOutput.kt index 70f04c29bd..332fafc211 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/RiskFactorDataOutput.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/RiskFactorDataOutput.kt @@ -26,7 +26,9 @@ data class RiskFactorDataOutput( companion object { fun fromVesselRiskFactor(vesselRiskFactor: VesselRiskFactor) = RiskFactorDataOutput( - gearOnboard = vesselRiskFactor.gearOnboard?.map { GearLastPositionDataOutput.fromGearLastPosition(it) } ?: listOf(), + gearOnboard = + vesselRiskFactor.gearOnboard?.map { GearLastPositionDataOutput.fromGearLastPosition(it) } + ?: listOf(), segments = vesselRiskFactor.segments, segmentHighestImpact = vesselRiskFactor.segmentHighestImpact, segmentHighestPriority = vesselRiskFactor.segmentHighestPriority, diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/VesselDataOutput.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/VesselDataOutput.kt index 74429aa0dd..56f0e5f3ce 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/VesselDataOutput.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/VesselDataOutput.kt @@ -26,7 +26,7 @@ data class VesselDataOutput( val vesselType: String? = null, val sailingCategory: String? = null, val sailingType: String? = null, - val declaredFishingGears: List? = null, + val declaredFishingGears: List, val pinger: Boolean? = null, val navigationLicenceExpirationDate: Date? = null, val navigationLicenceExtensionDate: Date? = null, diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/interfaces/BaseLogbookMessageDataOutput.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/interfaces/BaseLogbookMessageDataOutput.kt index c78337e811..f04268eb37 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/interfaces/BaseLogbookMessageDataOutput.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/interfaces/BaseLogbookMessageDataOutput.kt @@ -13,7 +13,7 @@ interface BaseLogbookMessageDataOutput { val operationDateTime: ZonedDateTime? val activityDateTime: ZonedDateTime? val reportDateTime: ZonedDateTime? - val integrationDateTime: ZonedDateTime? + val integrationDateTime: ZonedDateTime val internalReferenceNumber: String? val externalReferenceNumber: String? val ircs: String? diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/LastPositionEntity.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/LastPositionEntity.kt index 1a6afc664b..80e0baf6e1 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/LastPositionEntity.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/LastPositionEntity.kt @@ -82,7 +82,7 @@ data class LastPositionEntity( @Column(name = "species_onboard", columnDefinition = "jsonb") val speciesOnboard: String? = null, @Column(name = "total_weight_onboard") - val totalWeightOnboard: Double? = null, + val totalWeightOnboard: Double, @Column(name = "last_control_datetime_utc") val lastControlDateTime: ZonedDateTime? = null, @Column(name = "last_control_infraction") @@ -93,17 +93,17 @@ data class LastPositionEntity( @Enumerated(EnumType.STRING) val vesselIdentifier: VesselIdentifier, @Column(name = "impact_risk_factor") - val impactRiskFactor: Double? = null, + val impactRiskFactor: Double, @Column(name = "probability_risk_factor") - val probabilityRiskFactor: Double? = null, + val probabilityRiskFactor: Double, @Column(name = "detectability_risk_factor") - val detectabilityRiskFactor: Double? = null, + val detectabilityRiskFactor: Double, @Column(name = "risk_factor") - val riskFactor: Double? = null, + val riskFactor: Double, @Column(name = "under_charter") val underCharter: Boolean? = null, @Column(name = "is_at_port") - val isAtPort: Boolean? = null, + val isAtPort: Boolean, @Column(name = "alerts", columnDefinition = "varchar(200)[]") val alerts: List? = listOf(), @Column(name = "beacon_malfunction_id") diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/LogbookReportEntity.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/LogbookReportEntity.kt index fb4e80642d..6e8cb99ccd 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/LogbookReportEntity.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/LogbookReportEntity.kt @@ -2,7 +2,9 @@ package fr.gouv.cnsp.monitorfish.infrastructure.database.entities import com.fasterxml.jackson.databind.ObjectMapper import fr.gouv.cnsp.monitorfish.domain.entities.logbook.* +import fr.gouv.cnsp.monitorfish.domain.mappers.ERSMapper.JSONB_NULL_STRING import fr.gouv.cnsp.monitorfish.domain.mappers.ERSMapper.getERSMessageValueFromJSON +import fr.gouv.cnsp.monitorfish.infrastructure.database.entities.converters.deserializeJSONList import io.hypersistence.utils.hibernate.type.json.JsonBinaryType import jakarta.persistence.* import org.hibernate.annotations.JdbcType @@ -54,23 +56,23 @@ data class LogbookReportEntity( @Column(name = "log_type") val messageType: String?, @Type(JsonBinaryType::class) - @Column(name = "value", nullable = true, columnDefinition = "jsonb") + @Column(name = "value", columnDefinition = "jsonb") val message: String?, @Column(name = "integration_datetime_utc") val integrationDateTime: Instant, @JdbcType(PostgreSQLEnumJdbcType::class) @Column(name = "transmission_format", columnDefinition = "logbook_message_transmission_format") @Enumerated(EnumType.STRING) - val transmissionFormat: LogbookTransmissionFormat?, + val transmissionFormat: LogbookTransmissionFormat, @Column(name = "software") val software: String?, @Column(name = "enriched") - val isEnriched: Boolean = false, + val isEnriched: Boolean, @Type(JsonBinaryType::class) - @Column(name = "trip_gears", nullable = true, columnDefinition = "jsonb") + @Column(name = "trip_gears", columnDefinition = "jsonb") val tripGears: String?, @Type(JsonBinaryType::class) - @Column(name = "trip_segments", nullable = true, columnDefinition = "jsonb") + @Column(name = "trip_segments", columnDefinition = "jsonb") val tripSegments: String?, @Column(name = "is_test_message") val isTestMessage: Boolean = false, @@ -101,8 +103,8 @@ data class LogbookReportEntity( messageType = logbookMessage.messageType, operationCountry = null, operationType = logbookMessage.operationType, - tripGears = null, - tripSegments = null, + tripGears = JSONB_NULL_STRING, + tripSegments = JSONB_NULL_STRING, ) } @@ -137,17 +139,4 @@ data class LogbookReportEntity( tripSegments = tripSegments, ) } - - private fun deserializeJSONList( - mapper: ObjectMapper, - json: String?, - clazz: Class, - ): List = - json?.let { - mapper.readValue( - json, - mapper.typeFactory - .constructCollectionType(MutableList::class.java, clazz), - ) - } ?: listOf() } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/ManualPriorNotificationEntity.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/ManualPriorNotificationEntity.kt index b2c91a2dcd..63c0e335fb 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/ManualPriorNotificationEntity.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/ManualPriorNotificationEntity.kt @@ -103,7 +103,7 @@ data class ManualPriorNotificationEntity( operationNumber = null, operationType = LogbookOperationType.DAT, reportDateTime = sentAt, - transmissionFormat = null, + transmissionFormat = LogbookTransmissionFormat.MANUAL, tripGears = tripGears, tripSegments = tripSegments, vesselName = vesselName, diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/MissionActionEntity.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/MissionActionEntity.kt index 2be143f331..16222d8cb2 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/MissionActionEntity.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/MissionActionEntity.kt @@ -232,7 +232,7 @@ class MissionActionEntity( } ?: listOf(), actionType = actionType, actionDatetimeUtc = actionDatetimeUtc.atZone(ZoneOffset.UTC), - actionEndDatetimeUtc = actionEndDatetimeUtc?.let { it.atZone(ZoneOffset.UTC) }, + actionEndDatetimeUtc = actionEndDatetimeUtc?.atZone(ZoneOffset.UTC), emitsVms = emitsVms, emitsAis = emitsAis, logbookMatchesActivity = logbookMatchesActivity, diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/RiskFactorsEntity.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/RiskFactorsEntity.kt index 5eadb689e4..5e594d947a 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/RiskFactorsEntity.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/RiskFactorsEntity.kt @@ -4,6 +4,7 @@ import com.fasterxml.jackson.databind.ObjectMapper import fr.gouv.cnsp.monitorfish.domain.entities.last_position.Gear import fr.gouv.cnsp.monitorfish.domain.entities.last_position.Species import fr.gouv.cnsp.monitorfish.domain.entities.risk_factor.VesselRiskFactor +import fr.gouv.cnsp.monitorfish.infrastructure.database.entities.converters.deserializeJSONList import io.hypersistence.utils.hibernate.type.json.JsonBinaryType import jakarta.persistence.Column import jakarta.persistence.Entity @@ -29,10 +30,10 @@ data class RiskFactorsEntity( val riskFactor: Double, @Type(JsonBinaryType::class) @Column(name = "gear_onboard", columnDefinition = "jsonb") - val gearOnboard: String?, + val gearOnboard: String, @Type(JsonBinaryType::class) @Column(name = "species_onboard", columnDefinition = "jsonb") - val speciesOnboard: String?, + val speciesOnboard: String, @Column(name = "segments", columnDefinition = "varchar(50)[]") val segments: List, @Column(name = "segment_highest_impact") @@ -45,6 +46,8 @@ data class RiskFactorsEntity( val lastControlDatetime: ZonedDateTime? = null, @Column(name = "control_rate_risk_factor") val controlRateRiskFactor: Double, + @Column(name = "total_weight_onboard") + val totalWeightOnboard: Double, @Column(name = "infraction_score") val infractionScore: Double? = null, @Column(name = "number_controls_last_5_years") @@ -69,22 +72,13 @@ data class RiskFactorsEntity( detectabilityRiskFactor = detectabilityRiskFactor, riskFactor = riskFactor, internalReferenceNumber = cfr, - gearOnboard = - mapper.readValue( - gearOnboard, - mapper.typeFactory - .constructCollectionType(MutableList::class.java, Gear::class.java), - ), - speciesOnboard = - mapper.readValue( - speciesOnboard, - mapper.typeFactory - .constructCollectionType(MutableList::class.java, Species::class.java), - ), + gearOnboard = deserializeJSONList(mapper, gearOnboard, Gear::class.java), + speciesOnboard = deserializeJSONList(mapper, speciesOnboard, Species::class.java), segments = segments, controlPriorityLevel = controlPriorityLevel, segmentHighestImpact = segmentHighestImpact, segmentHighestPriority = segmentHighestPriority, + totalWeightOnboard = totalWeightOnboard, lastControlDatetime = lastControlDatetime, controlRateRiskFactor = controlRateRiskFactor, numberControlsLastFiveYears = numberControlsLastFiveYears, diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/VesselEntity.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/VesselEntity.kt index 58846e8e0c..6a78746d89 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/VesselEntity.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/VesselEntity.kt @@ -59,7 +59,7 @@ data class VesselEntity( @Column(name = "sailing_type") val sailingType: String? = null, @Column(name = "declared_fishing_gears", columnDefinition = "varchar(100)[]") - val declaredFishingGears: List? = null, + val declaredFishingGears: List, @Column(name = "nav_licence_expiration_date", columnDefinition = "date") val navigationLicenceExpirationDate: Date? = null, @Column(name = "nav_licence_extension_date", columnDefinition = "date") diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/converters/Utils.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/converters/Utils.kt new file mode 100644 index 0000000000..8161a71bc4 --- /dev/null +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/converters/Utils.kt @@ -0,0 +1,21 @@ +package fr.gouv.cnsp.monitorfish.infrastructure.database.entities.converters + +import com.fasterxml.jackson.databind.ObjectMapper +import fr.gouv.cnsp.monitorfish.domain.mappers.ERSMapper.JSONB_NULL_STRING + +fun deserializeJSONList( + mapper: ObjectMapper, + json: String?, + clazz: Class, +): List = + json?.let { + if (it == JSONB_NULL_STRING) { + return listOf() + } + + mapper.readValue( + it, + mapper.typeFactory + .constructCollectionType(MutableList::class.java, clazz), + ) + } ?: listOf() diff --git a/backend/src/main/resources/db/migration/internal/V0.290__Update_last_positions_table.sql b/backend/src/main/resources/db/migration/internal/V0.290__Update_last_positions_table.sql new file mode 100644 index 0000000000..99c8cb6e95 --- /dev/null +++ b/backend/src/main/resources/db/migration/internal/V0.290__Update_last_positions_table.sql @@ -0,0 +1,30 @@ +ALTER TABLE public.last_positions + ALTER COLUMN longitude SET NOT NULL; +ALTER TABLE public.last_positions + ALTER COLUMN latitude SET NOT NULL; +ALTER TABLE public.last_positions + ALTER COLUMN total_weight_onboard SET NOT NULL; +ALTER TABLE public.last_positions + ALTER COLUMN impact_risk_factor SET NOT NULL; +ALTER TABLE public.last_positions + ALTER COLUMN probability_risk_factor SET NOT NULL; +ALTER TABLE public.last_positions + ALTER COLUMN risk_factor SET NOT NULL; + +ALTER TABLE public.risk_factors + ALTER COLUMN gear_onboard SET NOT NULL; +ALTER TABLE public.risk_factors + ALTER COLUMN species_onboard SET NOT NULL; + +ALTER TABLE public.vessels + ALTER COLUMN declared_fishing_gears SET NOT NULL; + +ALTER TABLE public.logbook_reports + ALTER COLUMN operation_type SET NOT NULL; +ALTER TABLE public.logbook_reports + ALTER COLUMN integration_datetime_utc SET NOT NULL; + +ALTER TYPE public.logbook_message_transmission_format ADD VALUE 'MANUAL' AFTER 'FLUX'; + +ALTER TABLE public.logbook_reports + ALTER COLUMN transmission_format SET NOT NULL; diff --git a/backend/src/main/resources/db/testdata/V666.2__Insert_dummy_vessels.sql b/backend/src/main/resources/db/testdata/V666.2__Insert_dummy_vessels.sql index ae840ea744..c7ac6480de 100644 --- a/backend/src/main/resources/db/testdata/V666.2__Insert_dummy_vessels.sql +++ b/backend/src/main/resources/db/testdata/V666.2__Insert_dummy_vessels.sql @@ -27,62 +27,62 @@ INSERT INTO vessels (id, cfr, mmsi, ircs, external_immatriculation, vessel_name, INSERT INTO vessels (id, cfr, mmsi, ircs, external_immatriculation, vessel_name, flag_state, width, length, district, district_code, gauge, registry_port, power, vessel_type, sailing_category, sailing_type, declared_fishing_gears, nav_licence_expiration_date, operator_name, operator_phones, operator_email, proprietor_name, proprietor_phones, proprietor_emails, vessel_emails, vessel_phones, under_charter, has_esacapt, logbook_equipment_status) VALUES (13, 'FR263454484', '', 'FE4864', '8FR6541', 'NO NAME', 'FR', 15.5, 7.6, 'Auray', 'AY', 123, 'LORIENT', 108, 'Pêche côtière', '3', 'Pêche', '{"PTM", "OTM"}', CURRENT_DATE + INTERVAL '5 days', 'DUPOND', '{"+33 6 84 56 32 14"}', 'dupond@gmail.com', 'DURAND', '{"+33 6 45 25 14"}', '{"durand@gmail.com"}', '{"escogriffe@dgse.spy", "henri.duflot@dgse.spy"}', '{"0918273645", "+33 6 00 00 00 00"}', true, false, 'Equipé'); -INSERT INTO vessels (id, cfr, ircs, external_immatriculation, vessel_name) VALUES (-1, 'UNKNOWN', 'UNKNOWN', 'UNKNOWN', 'UNKNOWN'); +INSERT INTO vessels (id, cfr, ircs, declared_fishing_gears, external_immatriculation, vessel_name) VALUES (-1, 'UNKNOWN', 'UNKNOWN', '{}', 'UNKNOWN', 'UNKNOWN'); -INSERT INTO vessels (id, cfr, mmsi, ircs, external_immatriculation, vessel_name, flag_state, length, under_charter) VALUES (101, 'CFR101', 'MMSI101', 'IRCS101', 'EXTIMM101', 'VIVA ESPANA', 'ES', 15, true); +INSERT INTO vessels (id, cfr, mmsi, ircs, declared_fishing_gears, external_immatriculation, vessel_name, flag_state, length, under_charter) VALUES (101, 'CFR101', 'MMSI101', 'IRCS101', '{}', 'EXTIMM101', 'VIVA ESPANA', 'ES', 15, true); -INSERT INTO vessels (id, cfr, mmsi, ircs, external_immatriculation, vessel_name, flag_state, length, under_charter) VALUES (102, 'CFR102', 'MMSI102', 'IRCS102', 'EXTIMM102', 'LEVE NEDERLAND', 'NL', 20, true); +INSERT INTO vessels (id, cfr, mmsi, ircs, declared_fishing_gears, external_immatriculation, vessel_name, flag_state, length, under_charter) VALUES (102, 'CFR102', 'MMSI102', 'IRCS102', '{}', 'EXTIMM102', 'LEVE NEDERLAND', 'NL', 20, true); -INSERT INTO vessels (id, cfr, mmsi, ircs, external_immatriculation, vessel_name, flag_state, length, under_charter) VALUES (103, 'CFR103', 'MMSI103', 'IRCS103', 'EXTIMM103', 'L''OM DU POISSON', 'FR', 11.99, true); +INSERT INTO vessels (id, cfr, mmsi, ircs, declared_fishing_gears, external_immatriculation, vessel_name, flag_state, length, under_charter) VALUES (103, 'CFR103', 'MMSI103', 'IRCS103', '{}', 'EXTIMM103', 'L''OM DU POISSON', 'FR', 11.99, true); -INSERT INTO vessels (id, cfr, mmsi, ircs, external_immatriculation, vessel_name, flag_state, length, under_charter) VALUES (104, 'CFR104', 'MMSI104', 'IRCS104', 'EXTIMM104', 'DES BARS', NULL, 15, false); +INSERT INTO vessels (id, cfr, mmsi, ircs, declared_fishing_gears, external_immatriculation, vessel_name, flag_state, length, under_charter) VALUES (104, 'CFR104', 'MMSI104', 'IRCS104', '{}', 'EXTIMM104', 'DES BARS', NULL, 15, false); -INSERT INTO vessels (id, cfr, mmsi, ircs, external_immatriculation, vessel_name, flag_state, length, under_charter) VALUES (105, 'CFR105', 'MMSI105', 'IRCS105', 'EXTIMM105', 'CALAMARO', 'FR', 16, false); +INSERT INTO vessels (id, cfr, mmsi, ircs, declared_fishing_gears, external_immatriculation, vessel_name, flag_state, length, under_charter) VALUES (105, 'CFR105', 'MMSI105', 'IRCS105', '{}', 'EXTIMM105', 'CALAMARO', 'FR', 16, false); -INSERT INTO vessels (id, cfr, mmsi, ircs, external_immatriculation, vessel_name, flag_state, length, under_charter) VALUES (106, 'CFR106', 'MMSI106', 'IRCS106', 'EXTIMM106', 'L''ANCRE SÈCHE', 'FR', 7.5, false); +INSERT INTO vessels (id, cfr, mmsi, ircs, declared_fishing_gears, external_immatriculation, vessel_name, flag_state, length, under_charter) VALUES (106, 'CFR106', 'MMSI106', 'IRCS106', '{}', 'EXTIMM106', 'L''ANCRE SÈCHE', 'FR', 7.5, false); -INSERT INTO vessels (id, cfr, mmsi, ircs, external_immatriculation, vessel_name, flag_state, length, under_charter) VALUES (107, 'CFR107', 'MMSI107', 'IRCS107', 'EXTIMM107', 'MERLU L''ENCHANTEUR', 'FR', 18, false); +INSERT INTO vessels (id, cfr, mmsi, ircs, declared_fishing_gears, external_immatriculation, vessel_name, flag_state, length, under_charter) VALUES (107, 'CFR107', 'MMSI107', 'IRCS107', '{}', 'EXTIMM107', 'MERLU L''ENCHANTEUR', 'FR', 18, false); -INSERT INTO vessels (id, cfr, mmsi, ircs, external_immatriculation, vessel_name, flag_state, length, under_charter) VALUES (108, 'CFR108', 'MMSI108', 'IRCS108', 'EXTIMM108', 'LE POISSON AMBULANT', 'FR', 9, false); +INSERT INTO vessels (id, cfr, mmsi, ircs, declared_fishing_gears, external_immatriculation, vessel_name, flag_state, length, under_charter) VALUES (108, 'CFR108', 'MMSI108', 'IRCS108', '{}', 'EXTIMM108', 'LE POISSON AMBULANT', 'FR', 9, false); -INSERT INTO vessels (id, cfr, mmsi, ircs, external_immatriculation, vessel_name, flag_state, length, under_charter) VALUES (109, 'CFR109', 'MMSI109', 'IRCS109', 'EXTIMM109', 'LE POISSON D''AVRIL', 'FR', 25, false); +INSERT INTO vessels (id, cfr, mmsi, ircs, declared_fishing_gears, external_immatriculation, vessel_name, flag_state, length, under_charter) VALUES (109, 'CFR109', 'MMSI109', 'IRCS109', '{}', 'EXTIMM109', 'LE POISSON D''AVRIL', 'FR', 25, false); -INSERT INTO vessels (id, cfr, mmsi, ircs, external_immatriculation, vessel_name, flag_state, length, under_charter) VALUES (110, 'CFR110', 'MMSI110', 'IRCS110', 'EXTIMM110', 'LA MER À BOIRE', 'FR', 12.5, false); +INSERT INTO vessels (id, cfr, mmsi, ircs, declared_fishing_gears, external_immatriculation, vessel_name, flag_state, length, under_charter) VALUES (110, 'CFR110', 'MMSI110', 'IRCS110', '{}', 'EXTIMM110', 'LA MER À BOIRE', 'FR', 12.5, false); -INSERT INTO vessels (id, cfr, mmsi, ircs, external_immatriculation, vessel_name, flag_state, length, under_charter) VALUES (111, 'CFR111', 'MMSI111', 'IRCS111', 'EXTIMM111', 'LE MARIN D''EAU DOUCE', 'FR', 9.5, false); +INSERT INTO vessels (id, cfr, mmsi, ircs, declared_fishing_gears, external_immatriculation, vessel_name, flag_state, length, under_charter) VALUES (111, 'CFR111', 'MMSI111', 'IRCS111', '{}', 'EXTIMM111', 'LE MARIN D''EAU DOUCE', 'FR', 9.5, false); -INSERT INTO vessels (id, cfr, mmsi, ircs, external_immatriculation, vessel_name, flag_state, length, under_charter) VALUES (112, 'CFR112', 'MMSI112', 'IRCS112', 'EXTIMM112', 'POISSON PAS NET', 'FR', 7.3, false); +INSERT INTO vessels (id, cfr, mmsi, ircs, declared_fishing_gears, external_immatriculation, vessel_name, flag_state, length, under_charter) VALUES (112, 'CFR112', 'MMSI112', 'IRCS112', '{}', 'EXTIMM112', 'POISSON PAS NET', 'FR', 7.3, false); -INSERT INTO vessels (id, cfr, mmsi, ircs, external_immatriculation, vessel_name, flag_state, length, under_charter) VALUES (113, 'CFR113', 'MMSI113', 'IRCS113', 'EXTIMM113', 'IN-ARÊTE-ABLE', 'FR', 8.5, false); +INSERT INTO vessels (id, cfr, mmsi, ircs, declared_fishing_gears, external_immatriculation, vessel_name, flag_state, length, under_charter) VALUES (113, 'CFR113', 'MMSI113', 'IRCS113', '{}', 'EXTIMM113', 'IN-ARÊTE-ABLE', 'FR', 8.5, false); -INSERT INTO vessels (id, cfr, mmsi, ircs, external_immatriculation, vessel_name, flag_state, length, under_charter) VALUES (115, 'CFR115', 'MMSI115', 'IRCS115', 'EXTIMM115', 'DOS FIN', 'BE', 9.2, true); +INSERT INTO vessels (id, cfr, mmsi, ircs, declared_fishing_gears, external_immatriculation, vessel_name, flag_state, length, under_charter) VALUES (115, 'CFR115', 'MMSI115', 'IRCS115', '{}', 'EXTIMM115', 'DOS FIN', 'BE', 9.2, true); -INSERT INTO vessels (id, cfr, mmsi, ircs, external_immatriculation, vessel_name, flag_state, length, under_charter) VALUES (116, 'CFR116', 'MMSI116', 'IRCS116', 'EXTIMM116', 'NAVIRE RENOMMÉ (NOUVEAU NOM)', 'FR', 11, false); +INSERT INTO vessels (id, cfr, mmsi, ircs, declared_fishing_gears, external_immatriculation, vessel_name, flag_state, length, under_charter) VALUES (116, 'CFR116', 'MMSI116', 'IRCS116', '{}', 'EXTIMM116', 'NAVIRE RENOMMÉ (NOUVEAU NOM)', 'FR', 11, false); -INSERT INTO vessels (id, cfr, mmsi, ircs, external_immatriculation, vessel_name, flag_state, length, under_charter) VALUES (117, 'CFR117', 'MMSI117', 'IRCS117', 'EXTIMM117', 'QUEUE DE POISSON', 'FR', 10.9, false); +INSERT INTO vessels (id, cfr, mmsi, ircs, declared_fishing_gears, external_immatriculation, vessel_name, flag_state, length, under_charter) VALUES (117, 'CFR117', 'MMSI117', 'IRCS117', '{}', 'EXTIMM117', 'QUEUE DE POISSON', 'FR', 10.9, false); -INSERT INTO vessels (id, cfr, mmsi, ircs, external_immatriculation, vessel_name, flag_state, length, under_charter) VALUES (118, 'CFR118', 'MMSI118', 'IRCS118', 'EXTIMM118', 'GOUJON BOUGON', 'FR', 11.2, false); +INSERT INTO vessels (id, cfr, mmsi, ircs, declared_fishing_gears, external_immatriculation, vessel_name, flag_state, length, under_charter) VALUES (118, 'CFR118', 'MMSI118', 'IRCS118', '{}', 'EXTIMM118', 'GOUJON BOUGON', 'FR', 11.2, false); -INSERT INTO vessels (id, cfr, mmsi, ircs, external_immatriculation, vessel_name, flag_state, length, under_charter) VALUES (119, 'CFR119', 'MMSI119', 'IRCS119', 'EXTIMM119', 'PAGEOT JO', 'FR', 11.1, false); +INSERT INTO vessels (id, cfr, mmsi, ircs, declared_fishing_gears, external_immatriculation, vessel_name, flag_state, length, under_charter) VALUES (119, 'CFR119', 'MMSI119', 'IRCS119', '{}', 'EXTIMM119', 'PAGEOT JO', 'FR', 11.1, false); -INSERT INTO vessels (id, cfr, mmsi, ircs, external_immatriculation, vessel_name, flag_state, length, under_charter) VALUES (120, 'CFR120', 'MMSI120', 'IRCS120', 'EXTIMM120', 'VIVA L''ITALIA', 'IT', 11.1, false); +INSERT INTO vessels (id, cfr, mmsi, ircs, declared_fishing_gears, external_immatriculation, vessel_name, flag_state, length, under_charter) VALUES (120, 'CFR120', 'MMSI120', 'IRCS120', '{}', 'EXTIMM120', 'VIVA L''ITALIA', 'IT', 11.1, false); -INSERT INTO vessels (id, cfr, mmsi, ircs, external_immatriculation, vessel_name, flag_state, length, under_charter) VALUES (121, 'CFR121', 'MMSI121', 'IRCS121', 'EXTIMM121', 'MARE ET BASS', 'FR', 7.7, false); +INSERT INTO vessels (id, cfr, mmsi, ircs, declared_fishing_gears, external_immatriculation, vessel_name, flag_state, length, under_charter) VALUES (121, 'CFR121', 'MMSI121', 'IRCS121', '{}', 'EXTIMM121', 'MARE ET BASS', 'FR', 7.7, false); -INSERT INTO vessels (id, cfr, mmsi, ircs, external_immatriculation, vessel_name, flag_state, length, under_charter) VALUES (122, 'CFR122', 'MMSI122', 'IRCS122', 'EXTIMM122', 'FILET DOUX', 'FR', 7.8, false); +INSERT INTO vessels (id, cfr, mmsi, ircs, declared_fishing_gears, external_immatriculation, vessel_name, flag_state, length, under_charter) VALUES (122, 'CFR122', 'MMSI122', 'IRCS122', '{}', 'EXTIMM122', 'FILET DOUX', 'FR', 7.8, false); -INSERT INTO vessels (id, cfr, mmsi, ircs, external_immatriculation, vessel_name, flag_state, length, under_charter) VALUES (123, 'CFR123', 'MMSI123', 'IRCS123', 'EXTIMM123', 'DÉVOILÉ', 'FR', 7.9, false); +INSERT INTO vessels (id, cfr, mmsi, ircs, declared_fishing_gears, external_immatriculation, vessel_name, flag_state, length, under_charter) VALUES (123, 'CFR123', 'MMSI123', 'IRCS123', '{}', 'EXTIMM123', 'DÉVOILÉ', 'FR', 7.9, false); -INSERT INTO vessels (id, cfr, mmsi, ircs, external_immatriculation, vessel_name, flag_state, length, under_charter) VALUES (124, 'CFR124', 'MMSI124', 'IRCS124', 'EXTIMM124', 'MAT QUILLE', 'FR', 8.1, false); +INSERT INTO vessels (id, cfr, mmsi, ircs, declared_fishing_gears, external_immatriculation, vessel_name, flag_state, length, under_charter) VALUES (124, 'CFR124', 'MMSI124', 'IRCS124', '{}', 'EXTIMM124', 'MAT QUILLE', 'FR', 8.1, false); -INSERT INTO vessels (id, cfr, mmsi, ircs, external_immatriculation, vessel_name, flag_state, length, under_charter) VALUES (125, 'CFR125', 'MMSI125', 'IRCS125', 'EXTIMM125', 'BEAU SÉANT', 'FR', 8.2, false); +INSERT INTO vessels (id, cfr, mmsi, ircs, declared_fishing_gears, external_immatriculation, vessel_name, flag_state, length, under_charter) VALUES (125, 'CFR125', 'MMSI125', 'IRCS125', '{}', 'EXTIMM125', 'BEAU SÉANT', 'FR', 8.2, false); -INSERT INTO vessels (id, cfr, mmsi, ircs, external_immatriculation, vessel_name, flag_state, length, under_charter) VALUES (126, 'CFR126', 'MMSI126', 'IRCS126', 'EXTIMM126', 'THON BEAU', 'FR', 17.8, false); +INSERT INTO vessels (id, cfr, mmsi, ircs, declared_fishing_gears, external_immatriculation, vessel_name, flag_state, length, under_charter) VALUES (126, 'CFR126', 'MMSI126', 'IRCS126', '{}', 'EXTIMM126', 'THON BEAU', 'FR', 17.8, false); -INSERT INTO vessels (id, cfr, mmsi, ircs, external_immatriculation, vessel_name, flag_state, length, under_charter) VALUES (127, 'CFR127', 'MMSI127', 'IRCS127', 'EXTIMM127', 'MILLE SABORDS', 'FR', 16.9, false); +INSERT INTO vessels (id, cfr, mmsi, ircs, declared_fishing_gears, external_immatriculation, vessel_name, flag_state, length, under_charter) VALUES (127, 'CFR127', 'MMSI127', 'IRCS127', '{}', 'EXTIMM127', 'MILLE SABORDS', 'FR', 16.9, false); -INSERT INTO vessels (id, cfr, mmsi, ircs, external_immatriculation, vessel_name, flag_state, length, under_charter) VALUES (128, 'CFR128', 'MMSI128', 'IRCS128', 'EXTIMM128', 'THE FLOATING KANGAROO', 'AU', 31, false); +INSERT INTO vessels (id, cfr, mmsi, ircs, declared_fishing_gears, external_immatriculation, vessel_name, flag_state, length, under_charter) VALUES (128, 'CFR128', 'MMSI128', 'IRCS128', '{}', 'EXTIMM128', 'THE FLOATING KANGAROO', 'AU', 31, false); -INSERT INTO vessels (id, cfr, mmsi, ircs, external_immatriculation, vessel_name, flag_state, length, under_charter) VALUES (129, 'CFR129', 'MMSI129', 'IRCS129', 'EXTIMM129', 'BON VENT', 'FR', 34.5, false); +INSERT INTO vessels (id, cfr, mmsi, ircs, declared_fishing_gears, external_immatriculation, vessel_name, flag_state, length, under_charter) VALUES (129, 'CFR129', 'MMSI129', 'IRCS129', '{}', 'EXTIMM129', 'BON VENT', 'FR', 34.5, false); -INSERT INTO vessels (id, cfr, mmsi, ircs, external_immatriculation, vessel_name, flag_state, length, under_charter) VALUES (130, 'CFR130', 'MMSI130', 'IRCS130', 'EXTIMM130', 'L''HIPPO CAMPE', 'FR', 19.2, false); +INSERT INTO vessels (id, cfr, mmsi, ircs, declared_fishing_gears, external_immatriculation, vessel_name, flag_state, length, under_charter) VALUES (130, 'CFR130', 'MMSI130', 'IRCS130', '{}', 'EXTIMM130', 'L''HIPPO CAMPE', 'FR', 19.2, false); diff --git a/backend/src/main/resources/db/testdata/V666.3__Insert_dummy_last_positions.sql b/backend/src/main/resources/db/testdata/V666.3__Insert_dummy_last_positions.sql index c27e178390..082175db00 100644 --- a/backend/src/main/resources/db/testdata/V666.3__Insert_dummy_last_positions.sql +++ b/backend/src/main/resources/db/testdata/V666.3__Insert_dummy_last_positions.sql @@ -1023,16 +1023,16 @@ set last_control_datetime_utc = last_control_datetime_utc + (now() - '2021-01-01 -- Add fake data used in automated testing COPY public.last_positions (id, cfr, external_immatriculation, mmsi, ircs, vessel_name, flag_state, trip_number, - latitude, longitude, speed, course, last_position_datetime_utc, emission_period, + latitude, longitude, speed, total_weight_onboard, course, last_position_datetime_utc, emission_period, last_logbook_message_datetime_utc, length, width, segments, gear_onboard, species_onboard, district, district_code, last_control_datetime_utc, last_control_infraction, post_control_comments, vessel_identifier, estimated_current_latitude, estimated_current_longitude, impact_risk_factor, probability_risk_factor, detectability_risk_factor, risk_factor, under_charter, is_at_port, alerts, beacon_malfunction_id, reportings) FROM stdin; -10000 FAK000999999 DONTSINK \N CALLME PHENOMENE GB \N 47.921999999999997 -8.0129999999999999 8.40000000000000036 14 2021-01-15 07:32:00 00:40:00 2020-12-21 15:01:00 14.3 5.2 {"W10", "PEL03"} [{"gear": "OTB", "mesh": 70.0, "dimensions": 45.0}] [{ "gear": "OTB","faoZone": "27.8.b","species": "BLI","weight": 13.46 },{ "gear": "OTB","faoZone": "27.8.c","species": "HKE","weight": 235.6 }] CAEN CN 2020-12-22 08:59:00 true Pas de com INTERNAL_REFERENCE_NUMBER 47.7123 -8.8123 2.1 2 3 2.473 t f {THREE_MILES_TRAWLING_ALERT} 1 \N -10001 SOCR4T3 LePhiloFilou \N SCRT SOCRATE FR \N 48.921999999999997 -8.0129999999999999 8.40000000000000036 14 2021-01-15 07:32:00 00:40:00 2020-12-21 15:01:00 14.3 5.2 {"W10", "PEL03"} [{"gear": "OTB", "mesh": 70.0, "dimensions": 45.0}] [{ "gear": "OTB","faoZone": "27.8.b","species": "BLI","weight": 13.46 },{ "gear": "OTB","faoZone": "27.8.c","species": "HKE","weight": 235.6 }] ATHENES AT 2020-12-22 08:59:00 true No comment INTERNAL_REFERENCE_NUMBER 49.003 -7.9523 2.1 2 3 2.473 f f \N \N \N -10002 U_W0NTFINDME ABC123456 \N TALK2ME MALOTRU FR \N 48.221999999999997 -8.5129999999999999 8.40000000000000036 14 2021-01-15 07:32:00 00:40:00 2020-12-21 15:01:00 14.3 5.2 {"W10", "PEL03"} [{"gear": "OTB", "mesh": 70.0, "dimensions": 45.0}] [{ "gear": "OTB","faoZone": "27.8.b","species": "BLI","weight": 13.46 },{ "gear": "OTB","faoZone": "27.8.c","species": "HKE","weight": 235.6 }] ATHENES AT 2020-12-22 08:59:00 true No comment INTERNAL_REFERENCE_NUMBER 49.003 -7.9523 2.1 2 3 2.473 f f \N \N \N +10000 FAK000999999 DONTSINK \N CALLME PHENOMENE GB \N 47.921999999999997 -8.0129999999999999 8.40000000000000036 0.0 14 2021-01-15 07:32:00 00:40:00 2020-12-21 15:01:00 14.3 5.2 {"W10", "PEL03"} [{"gear": "OTB", "mesh": 70.0, "dimensions": 45.0}] [{ "gear": "OTB","faoZone": "27.8.b","species": "BLI","weight": 13.46 },{ "gear": "OTB","faoZone": "27.8.c","species": "HKE","weight": 235.6 }] CAEN CN 2020-12-22 08:59:00 true Pas de com INTERNAL_REFERENCE_NUMBER 47.7123 -8.8123 2.1 2 3 2.473 t f {THREE_MILES_TRAWLING_ALERT} 1 \N +10001 SOCR4T3 LePhiloFilou \N SCRT SOCRATE FR \N 48.921999999999997 -8.0129999999999999 8.40000000000000036 0.0 14 2021-01-15 07:32:00 00:40:00 2020-12-21 15:01:00 14.3 5.2 {"W10", "PEL03"} [{"gear": "OTB", "mesh": 70.0, "dimensions": 45.0}] [{ "gear": "OTB","faoZone": "27.8.b","species": "BLI","weight": 13.46 },{ "gear": "OTB","faoZone": "27.8.c","species": "HKE","weight": 235.6 }] ATHENES AT 2020-12-22 08:59:00 true No comment INTERNAL_REFERENCE_NUMBER 49.003 -7.9523 2.1 2 3 2.473 f f \N \N \N +10002 U_W0NTFINDME ABC123456 \N TALK2ME MALOTRU FR \N 48.221999999999997 -8.5129999999999999 8.40000000000000036 0.0 14 2021-01-15 07:32:00 00:40:00 2020-12-21 15:01:00 14.3 5.2 {"W10", "PEL03"} [{"gear": "OTB", "mesh": 70.0, "dimensions": 45.0}] [{ "gear": "OTB","faoZone": "27.8.b","species": "BLI","weight": 13.46 },{ "gear": "OTB","faoZone": "27.8.c","species": "HKE","weight": 235.6 }] ATHENES AT 2020-12-22 08:59:00 true No comment INTERNAL_REFERENCE_NUMBER 49.003 -7.9523 2.1 2 3 2.473 f f \N \N \N \. update last_positions diff --git a/backend/src/main/resources/db/testdata/json/V666.2__Insert_dummy_vessels.jsonc b/backend/src/main/resources/db/testdata/json/V666.2__Insert_dummy_vessels.jsonc index 84d5ed49c8..865b496c46 100644 --- a/backend/src/main/resources/db/testdata/json/V666.2__Insert_dummy_vessels.jsonc +++ b/backend/src/main/resources/db/testdata/json/V666.2__Insert_dummy_vessels.jsonc @@ -437,6 +437,7 @@ "id": -1, "cfr": "UNKNOWN", "ircs": "UNKNOWN", + "declared_fishing_gears": [], "external_immatriculation": "UNKNOWN", "vessel_name": "UNKNOWN" }, @@ -449,6 +450,7 @@ "cfr": "CFR101", "mmsi": "MMSI101", "ircs": "IRCS101", + "declared_fishing_gears": [], "external_immatriculation": "EXTIMM101", "vessel_name": "VIVA ESPANA", "flag_state": "ES", @@ -464,6 +466,7 @@ "cfr": "CFR102", "mmsi": "MMSI102", "ircs": "IRCS102", + "declared_fishing_gears": [], "external_immatriculation": "EXTIMM102", "vessel_name": "LEVE NEDERLAND", "flag_state": "NL", @@ -478,6 +481,7 @@ "cfr": "CFR103", "mmsi": "MMSI103", "ircs": "IRCS103", + "declared_fishing_gears": [], "external_immatriculation": "EXTIMM103", "vessel_name": "L'OM DU POISSON", "flag_state": "FR", @@ -492,6 +496,7 @@ "cfr": "CFR104", "mmsi": "MMSI104", "ircs": "IRCS104", + "declared_fishing_gears": [], "external_immatriculation": "EXTIMM104", "vessel_name": "DES BARS", "flag_state": null, @@ -505,6 +510,7 @@ "cfr": "CFR105", "mmsi": "MMSI105", "ircs": "IRCS105", + "declared_fishing_gears": [], "external_immatriculation": "EXTIMM105", "vessel_name": "CALAMARO", "flag_state": "FR", @@ -518,6 +524,7 @@ "cfr": "CFR106", "mmsi": "MMSI106", "ircs": "IRCS106", + "declared_fishing_gears": [], "external_immatriculation": "EXTIMM106", "vessel_name": "L'ANCRE SÈCHE", "flag_state": "FR", @@ -531,6 +538,7 @@ "cfr": "CFR107", "mmsi": "MMSI107", "ircs": "IRCS107", + "declared_fishing_gears": [], "external_immatriculation": "EXTIMM107", "vessel_name": "MERLU L'ENCHANTEUR", "flag_state": "FR", @@ -544,6 +552,7 @@ "cfr": "CFR108", "mmsi": "MMSI108", "ircs": "IRCS108", + "declared_fishing_gears": [], "external_immatriculation": "EXTIMM108", "vessel_name": "LE POISSON AMBULANT", "flag_state": "FR", @@ -558,6 +567,7 @@ "cfr": "CFR109", "mmsi": "MMSI109", "ircs": "IRCS109", + "declared_fishing_gears": [], "external_immatriculation": "EXTIMM109", "vessel_name": "LE POISSON D'AVRIL", "flag_state": "FR", @@ -570,6 +580,7 @@ // "cfr": "CFR109", // "mmsi": "MMSI109_DUPLICATE", // "ircs": "IRCS109_DUPLICATE", + // "declared_fishing_gears": [], // "external_immatriculation": "EXTIMM109_DUPLICATE", // "vessel_name": "LE POISSON D'AVRIL DUPLIQUÉ", // "flag_state": "FR", @@ -583,6 +594,7 @@ "cfr": "CFR110", "mmsi": "MMSI110", "ircs": "IRCS110", + "declared_fishing_gears": [], "external_immatriculation": "EXTIMM110", "vessel_name": "LA MER À BOIRE", "flag_state": "FR", @@ -596,6 +608,7 @@ "cfr": "CFR111", "mmsi": "MMSI111", "ircs": "IRCS111", + "declared_fishing_gears": [], "external_immatriculation": "EXTIMM111", "vessel_name": "LE MARIN D'EAU DOUCE", "flag_state": "FR", @@ -609,6 +622,7 @@ "cfr": "CFR112", "mmsi": "MMSI112", "ircs": "IRCS112", + "declared_fishing_gears": [], "external_immatriculation": "EXTIMM112", "vessel_name": "POISSON PAS NET", "flag_state": "FR", @@ -622,6 +636,7 @@ "cfr": "CFR113", "mmsi": "MMSI113", "ircs": "IRCS113", + "declared_fishing_gears": [], "external_immatriculation": "EXTIMM113", "vessel_name": "IN-ARÊTE-ABLE", "flag_state": "FR", @@ -637,6 +652,7 @@ "cfr": "CFR115", "mmsi": "MMSI115", "ircs": "IRCS115", + "declared_fishing_gears": [], "external_immatriculation": "EXTIMM115", "vessel_name": "DOS FIN", "flag_state": "BE", @@ -651,6 +667,7 @@ "cfr": "CFR116", "mmsi": "MMSI116", "ircs": "IRCS116", + "declared_fishing_gears": [], "external_immatriculation": "EXTIMM116", "vessel_name": "NAVIRE RENOMMÉ (NOUVEAU NOM)", "flag_state": "FR", @@ -664,6 +681,7 @@ "cfr": "CFR117", "mmsi": "MMSI117", "ircs": "IRCS117", + "declared_fishing_gears": [], "external_immatriculation": "EXTIMM117", "vessel_name": "QUEUE DE POISSON", "flag_state": "FR", @@ -677,6 +695,7 @@ "cfr": "CFR118", "mmsi": "MMSI118", "ircs": "IRCS118", + "declared_fishing_gears": [], "external_immatriculation": "EXTIMM118", "vessel_name": "GOUJON BOUGON", "flag_state": "FR", @@ -690,6 +709,7 @@ "cfr": "CFR119", "mmsi": "MMSI119", "ircs": "IRCS119", + "declared_fishing_gears": [], "external_immatriculation": "EXTIMM119", "vessel_name": "PAGEOT JO", "flag_state": "FR", @@ -704,6 +724,7 @@ "cfr": "CFR120", "mmsi": "MMSI120", "ircs": "IRCS120", + "declared_fishing_gears": [], "external_immatriculation": "EXTIMM120", "vessel_name": "VIVA L'ITALIA", "flag_state": "IT", @@ -717,6 +738,7 @@ "cfr": "CFR121", "mmsi": "MMSI121", "ircs": "IRCS121", + "declared_fishing_gears": [], "external_immatriculation": "EXTIMM121", "vessel_name": "MARE ET BASS", "flag_state": "FR", @@ -730,6 +752,7 @@ "cfr": "CFR122", "mmsi": "MMSI122", "ircs": "IRCS122", + "declared_fishing_gears": [], "external_immatriculation": "EXTIMM122", "vessel_name": "FILET DOUX", "flag_state": "FR", @@ -743,6 +766,7 @@ "cfr": "CFR123", "mmsi": "MMSI123", "ircs": "IRCS123", + "declared_fishing_gears": [], "external_immatriculation": "EXTIMM123", "vessel_name": "DÉVOILÉ", "flag_state": "FR", @@ -756,6 +780,7 @@ "cfr": "CFR124", "mmsi": "MMSI124", "ircs": "IRCS124", + "declared_fishing_gears": [], "external_immatriculation": "EXTIMM124", "vessel_name": "MAT QUILLE", "flag_state": "FR", @@ -769,6 +794,7 @@ "cfr": "CFR125", "mmsi": "MMSI125", "ircs": "IRCS125", + "declared_fishing_gears": [], "external_immatriculation": "EXTIMM125", "vessel_name": "BEAU SÉANT", "flag_state": "FR", @@ -782,6 +808,7 @@ "cfr": "CFR126", "mmsi": "MMSI126", "ircs": "IRCS126", + "declared_fishing_gears": [], "external_immatriculation": "EXTIMM126", "vessel_name": "THON BEAU", "flag_state": "FR", @@ -795,6 +822,7 @@ "cfr": "CFR127", "mmsi": "MMSI127", "ircs": "IRCS127", + "declared_fishing_gears": [], "external_immatriculation": "EXTIMM127", "vessel_name": "MILLE SABORDS", "flag_state": "FR", @@ -809,6 +837,7 @@ "cfr": "CFR128", "mmsi": "MMSI128", "ircs": "IRCS128", + "declared_fishing_gears": [], "external_immatriculation": "EXTIMM128", "vessel_name": "THE FLOATING KANGAROO", "flag_state": "AU", @@ -822,6 +851,7 @@ "cfr": "CFR129", "mmsi": "MMSI129", "ircs": "IRCS129", + "declared_fishing_gears": [], "external_immatriculation": "EXTIMM129", "vessel_name": "BON VENT", "flag_state": "FR", @@ -835,6 +865,7 @@ "cfr": "CFR130", "mmsi": "MMSI130", "ircs": "IRCS130", + "declared_fishing_gears": [], "external_immatriculation": "EXTIMM130", "vessel_name": "L'HIPPO CAMPE", "flag_state": "FR", diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/fakers/LogbookMessageFaker.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/fakers/LogbookMessageFaker.kt index f9f99d1a64..6a0555cabb 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/fakers/LogbookMessageFaker.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/fakers/LogbookMessageFaker.kt @@ -48,7 +48,7 @@ class LogbookMessageFaker { rawMessage: String? = null, reportDateTime: ZonedDateTime? = null, software: String? = null, - transmissionFormat: LogbookTransmissionFormat? = null, + transmissionFormat: LogbookTransmissionFormat = LogbookTransmissionFormat.ERS, tripGears: List? = emptyList(), tripNumber: String? = null, tripSegments: List? = emptyList(), diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/fakers/VesselFaker.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/fakers/VesselFaker.kt index cc5ef9c0ee..1214310637 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/fakers/VesselFaker.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/fakers/VesselFaker.kt @@ -25,7 +25,7 @@ class VesselFaker { vesselType: String? = null, sailingCategory: String? = null, sailingType: String? = null, - declaredFishingGears: List? = null, + declaredFishingGears: List = listOf(), pinger: Boolean? = null, navigationLicenceExpirationDate: Date? = null, operatorName: String? = null, diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaManualPriorNotificationRepositoryITests.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaManualPriorNotificationRepositoryITests.kt index c4a89a95e9..74e261e763 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaManualPriorNotificationRepositoryITests.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaManualPriorNotificationRepositoryITests.kt @@ -1,10 +1,7 @@ package fr.gouv.cnsp.monitorfish.infrastructure.database.repositories import com.neovisionaries.i18n.CountryCode -import fr.gouv.cnsp.monitorfish.domain.entities.logbook.LogbookMessage -import fr.gouv.cnsp.monitorfish.domain.entities.logbook.LogbookMessageAndValue -import fr.gouv.cnsp.monitorfish.domain.entities.logbook.LogbookMessagePurpose -import fr.gouv.cnsp.monitorfish.domain.entities.logbook.LogbookOperationType +import fr.gouv.cnsp.monitorfish.domain.entities.logbook.* import fr.gouv.cnsp.monitorfish.domain.entities.logbook.messages.PNO import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotification import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.filters.PriorNotificationsFilter @@ -526,7 +523,7 @@ class JpaManualPriorNotificationRepositoryITests : AbstractDBTests() { operationType = LogbookOperationType.DAT, // Replaced by the generated `sentAt` during the save operation. reportDateTime = ZonedDateTime.now(), - transmissionFormat = null, + transmissionFormat = LogbookTransmissionFormat.FLUX, vesselName = "Vessel Name", vesselId = 123, ), diff --git a/frontend/cypress/e2e/main_window/vessel_sidebar/logbook.spec.ts b/frontend/cypress/e2e/main_window/vessel_sidebar/logbook.spec.ts index b5ce681a2e..abd07682f5 100644 --- a/frontend/cypress/e2e/main_window/vessel_sidebar/logbook.spec.ts +++ b/frontend/cypress/e2e/main_window/vessel_sidebar/logbook.spec.ts @@ -171,7 +171,7 @@ context('Vessel sidebar logbook tab', () => { .its('response.url') .should( 'have.string', - '/bff/v1/vessels/positions?&afterDateTime=&beforeDateTime=' + + '/bff/v1/vessels/positions?afterDateTime=&beforeDateTime=' + '&externalReferenceNumber=DONTSINK&internalReferenceNumber=FAK000999999' + '&IRCS=CALLME&trackDepth=TWELVE_HOURS&vesselIdentifier=INTERNAL_REFERENCE_NUMBER' ) diff --git a/frontend/cypress/e2e/side_window/alert_list/alerts_list.spec.ts b/frontend/cypress/e2e/side_window/alert_list/alerts_list.spec.ts index 3e10aa4fb8..6cb6462326 100644 --- a/frontend/cypress/e2e/side_window/alert_list/alerts_list.spec.ts +++ b/frontend/cypress/e2e/side_window/alert_list/alerts_list.spec.ts @@ -62,8 +62,8 @@ context('Side Window > Alert List', () => { // Show vessel on map cy.intercept( 'GET', - 'bff/v1/vessels/find?vesselId=&internalReferenceNumber=FAK000999999&externalReferenceNumber=DONTSINK' + - '&IRCS=CALLME&vesselIdentifier=INTERNAL_REFERENCE_NUMBER&trackDepth=TWELVE_HOURS&afterDateTime=&beforeDateTime=' + 'bff/v1/vessels/find?afterDateTime=&beforeDateTime=&externalReferenceNumber=DONTSINK' + + '&internalReferenceNumber=FAK000999999&IRCS=CALLME&trackDepth=TWELVE_HOURS&vesselId=&vesselIdentifier=INTERNAL_REFERENCE_NUMBER' ).as('showVesselPositionsOnMap') cy.get('*[data-cy="side-window-alerts-show-vessel"]').first().forceClick() cy.wait('@showVesselPositionsOnMap').then(({ response }) => expect(response && response.statusCode).equal(200)) diff --git a/frontend/src/features/Vessel/Vessel.types.ts b/frontend/src/features/Vessel/Vessel.types.ts index 561f2dd739..c89123a9b6 100644 --- a/frontend/src/features/Vessel/Vessel.types.ts +++ b/frontend/src/features/Vessel/Vessel.types.ts @@ -18,7 +18,7 @@ export namespace Vessel { } export interface Vessel { - declaredFishingGears: string[] | undefined + declaredFishingGears: string[] district: string | undefined districtCode: string | undefined externalReferenceNumber: string | undefined diff --git a/frontend/src/features/Vessel/schemas/VesselLastPositionSchema.ts b/frontend/src/features/Vessel/schemas/VesselLastPositionSchema.ts index 2670bad7d1..53ae1cdc6e 100644 --- a/frontend/src/features/Vessel/schemas/VesselLastPositionSchema.ts +++ b/frontend/src/features/Vessel/schemas/VesselLastPositionSchema.ts @@ -9,7 +9,6 @@ import DeclaredLogbookSpeciesSchema = Vessel.DeclaredLogbookSpeciesSchema import DeclaredLogbookGearSchema = Vessel.DeclaredLogbookGearSchema import VesselIdentifier = Vessel.VesselIdentifier -// TODO Check which of these schemas are nullable or not export const VesselLastPositionSchema = z.strictObject({ alerts: z.array(z.union([z.nativeEnum(PendingAlertValueType), z.literal('PNO_LAN_WEIGHT_TOLERANCE_ALERT')])), beaconMalfunctionId: numberOrUndefined, @@ -18,7 +17,7 @@ export const VesselLastPositionSchema = z.strictObject({ dateTime: z.string(), departureDateTime: stringOrUndefined, destination: stringOrUndefined, - detectabilityRiskFactor: numberOrUndefined, + detectabilityRiskFactor: z.number(), district: stringOrUndefined, districtCode: stringOrUndefined, emissionPeriod: numberOrUndefined, @@ -28,10 +27,10 @@ export const VesselLastPositionSchema = z.strictObject({ flagState: z.string(), from: stringOrUndefined, gearOnboard: z.array(DeclaredLogbookGearSchema), - impactRiskFactor: numberOrUndefined, + impactRiskFactor: z.number(), internalReferenceNumber: stringOrUndefined, ircs: stringOrUndefined, - isAtPort: booleanOrUndefined, + isAtPort: z.boolean(), lastControlDateTime: stringOrUndefined, lastControlInfraction: booleanOrUndefined, lastLogbookMessageDateTime: stringOrUndefined, @@ -41,15 +40,15 @@ export const VesselLastPositionSchema = z.strictObject({ mmsi: stringOrUndefined, positionType: z.string(), postControlComment: stringOrUndefined, - probabilityRiskFactor: numberOrUndefined, + probabilityRiskFactor: z.number(), registryPortLocode: stringOrUndefined, registryPortName: stringOrUndefined, reportings: z.array(z.nativeEnum(ReportingType)), - riskFactor: numberOrUndefined, + riskFactor: z.number(), segments: z.array(z.string()), speciesOnboard: z.array(DeclaredLogbookSpeciesSchema), speed: numberOrUndefined, - totalWeightOnboard: numberOrUndefined, + totalWeightOnboard: z.number(), tripNumber: stringOrUndefined, underCharter: booleanOrUndefined, vesselId: numberOrUndefined,