From 443d14610f9e5aac0108d8a661eda91a4fb7eff5 Mon Sep 17 00:00:00 2001 From: Ivan Gabriele Date: Tue, 22 Oct 2024 15:10:53 +0200 Subject: [PATCH 01/59] Align backoffice menu style with MonitorEnv one --- .../features/BackOffice/components/BackofficeMenu/index.tsx | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/frontend/src/features/BackOffice/components/BackofficeMenu/index.tsx b/frontend/src/features/BackOffice/components/BackofficeMenu/index.tsx index 1d5e427152..d558b3cf0a 100644 --- a/frontend/src/features/BackOffice/components/BackofficeMenu/index.tsx +++ b/frontend/src/features/BackOffice/components/BackofficeMenu/index.tsx @@ -31,18 +31,16 @@ const Wrapper = styled.div` flex-direction: column; letter-spacing: 0.5px; line-height: 1; - min-width: 130px; padding: 16px 24px; + width: 200px; ` const StyledNavLink = styled(NavLink)` align-items: center; color: ${p => p.theme.color.gainsboro}; display: flex; - height: 55px; + height: 45px; text-align: left; - line-height: 17px; - width: 140px; && { color: ${p => p.theme.color.gainsboro}; From 3a7912b0c016e0b0aa1dcdfef75816bbde2f8a43 Mon Sep 17 00:00:00 2001 From: Ivan Gabriele Date: Wed, 23 Oct 2024 09:21:54 +0200 Subject: [PATCH 02/59] Rename APIControlUnitRepository to APILegacyControlUnitRepository --- ...nitRepository.kt => LegacyControlUnitRepository.kt} | 2 +- .../use_cases/control_units/GetAllControlUnits.kt | 10 +++------- ...Repository.kt => APILegacyControlUnitRepository.kt} | 8 ++++---- ...ests.kt => APILegacyControlUnitRepositoryITests.kt} | 4 ++-- 4 files changed, 10 insertions(+), 14 deletions(-) rename backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/repositories/{ControlUnitRepository.kt => LegacyControlUnitRepository.kt} (80%) rename backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/{APIControlUnitRepository.kt => APILegacyControlUnitRepository.kt} (80%) rename backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/{APIControlUnitRepositoryITests.kt => APILegacyControlUnitRepositoryITests.kt} (94%) diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/repositories/ControlUnitRepository.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/repositories/LegacyControlUnitRepository.kt similarity index 80% rename from backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/repositories/ControlUnitRepository.kt rename to backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/repositories/LegacyControlUnitRepository.kt index 5bcb3a917a..2c38a03e2f 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/repositories/ControlUnitRepository.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/repositories/LegacyControlUnitRepository.kt @@ -2,6 +2,6 @@ package fr.gouv.cnsp.monitorfish.domain.repositories import fr.gouv.cnsp.monitorfish.domain.entities.mission.ControlUnit -interface ControlUnitRepository { +interface LegacyControlUnitRepository { fun findAll(): List } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/control_units/GetAllControlUnits.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/control_units/GetAllControlUnits.kt index c36e849066..4186e17636 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/control_units/GetAllControlUnits.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/control_units/GetAllControlUnits.kt @@ -2,17 +2,13 @@ package fr.gouv.cnsp.monitorfish.domain.use_cases.control_units import fr.gouv.cnsp.monitorfish.config.UseCase import fr.gouv.cnsp.monitorfish.domain.entities.mission.ControlUnit -import fr.gouv.cnsp.monitorfish.domain.repositories.ControlUnitRepository -import org.slf4j.Logger -import org.slf4j.LoggerFactory +import fr.gouv.cnsp.monitorfish.domain.repositories.LegacyControlUnitRepository @UseCase class GetAllControlUnits( - private val controlUnitsRepository: ControlUnitRepository, + private val legacyControlUnitsRepository: LegacyControlUnitRepository, ) { - private val logger: Logger = LoggerFactory.getLogger(GetAllControlUnits::class.java) - fun execute(): List { - return controlUnitsRepository.findAll() + return legacyControlUnitsRepository.findAll() } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/APIControlUnitRepository.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/APILegacyControlUnitRepository.kt similarity index 80% rename from backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/APIControlUnitRepository.kt rename to backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/APILegacyControlUnitRepository.kt index 764de431ce..efe12a033c 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/APIControlUnitRepository.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/APILegacyControlUnitRepository.kt @@ -3,7 +3,7 @@ package fr.gouv.cnsp.monitorfish.infrastructure.monitorenv import fr.gouv.cnsp.monitorfish.config.ApiClient import fr.gouv.cnsp.monitorfish.config.MonitorenvProperties import fr.gouv.cnsp.monitorfish.domain.entities.mission.ControlUnit -import fr.gouv.cnsp.monitorfish.domain.repositories.ControlUnitRepository +import fr.gouv.cnsp.monitorfish.domain.repositories.LegacyControlUnitRepository import io.ktor.client.call.* import io.ktor.client.request.* import kotlinx.coroutines.runBlocking @@ -13,11 +13,11 @@ import org.springframework.cache.annotation.Cacheable import org.springframework.stereotype.Repository @Repository -class APIControlUnitRepository( +class APILegacyControlUnitRepository( val monitorenvProperties: MonitorenvProperties, val apiClient: ApiClient, -) : ControlUnitRepository { - private val logger: Logger = LoggerFactory.getLogger(APIControlUnitRepository::class.java) +) : LegacyControlUnitRepository { + private val logger: Logger = LoggerFactory.getLogger(APILegacyControlUnitRepository::class.java) @Cacheable(value = ["control_units"]) override fun findAll(): List = diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/APIControlUnitRepositoryITests.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/APILegacyControlUnitRepositoryITests.kt similarity index 94% rename from backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/APIControlUnitRepositoryITests.kt rename to backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/APILegacyControlUnitRepositoryITests.kt index 2daeaa1e74..11a22c83e1 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/APIControlUnitRepositoryITests.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/APILegacyControlUnitRepositoryITests.kt @@ -8,7 +8,7 @@ import io.ktor.utils.io.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class APIControlUnitRepositoryITests { +class APILegacyControlUnitRepositoryITests { @Test fun `findAll Should return control units`() { // Given @@ -54,7 +54,7 @@ class APIControlUnitRepositoryITests { // When val controlUnits = - APIControlUnitRepository(monitorenvProperties, apiClient) + APILegacyControlUnitRepository(monitorenvProperties, apiClient) .findAll() assertThat(controlUnits).hasSize(3) From fa919b6ad0b70eb915e05524723342fc10283067 Mon Sep 17 00:00:00 2001 From: Ivan Gabriele Date: Wed, 23 Oct 2024 09:26:34 +0200 Subject: [PATCH 03/59] Rename GetAllControlUnits to GetAllLegacyControlUnits --- ...olUnits.kt => GetAllLegacyControlUnits.kt} | 2 +- .../use_cases/reporting/AddReporting.kt | 6 +- .../reporting/GetAllCurrentReportings.kt | 6 +- .../reporting/GetVesselReportings.kt | 6 +- .../use_cases/reporting/UpdateReporting.kt | 8 +- .../domain/use_cases/AddReportingUTests.kt | 40 +++--- .../GetAllCurrentReportingsUTests.kt | 32 ++--- .../domain/use_cases/UpdateReportingUTests.kt | 122 ++++++++++-------- .../reporting/GetVesselReportingsUTests.kt | 16 +-- 9 files changed, 134 insertions(+), 104 deletions(-) rename backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/control_units/{GetAllControlUnits.kt => GetAllLegacyControlUnits.kt} (93%) diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/control_units/GetAllControlUnits.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/control_units/GetAllLegacyControlUnits.kt similarity index 93% rename from backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/control_units/GetAllControlUnits.kt rename to backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/control_units/GetAllLegacyControlUnits.kt index 4186e17636..64248e457e 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/control_units/GetAllControlUnits.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/control_units/GetAllLegacyControlUnits.kt @@ -5,7 +5,7 @@ import fr.gouv.cnsp.monitorfish.domain.entities.mission.ControlUnit import fr.gouv.cnsp.monitorfish.domain.repositories.LegacyControlUnitRepository @UseCase -class GetAllControlUnits( +class GetAllLegacyControlUnits( private val legacyControlUnitsRepository: LegacyControlUnitRepository, ) { fun execute(): List { diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/reporting/AddReporting.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/reporting/AddReporting.kt index 0c3a84d12a..52af3ed3f1 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/reporting/AddReporting.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/reporting/AddReporting.kt @@ -7,7 +7,7 @@ import fr.gouv.cnsp.monitorfish.domain.entities.reporting.InfractionSuspicionOrO import fr.gouv.cnsp.monitorfish.domain.entities.reporting.Reporting import fr.gouv.cnsp.monitorfish.domain.entities.reporting.ReportingType import fr.gouv.cnsp.monitorfish.domain.repositories.ReportingRepository -import fr.gouv.cnsp.monitorfish.domain.use_cases.control_units.GetAllControlUnits +import fr.gouv.cnsp.monitorfish.domain.use_cases.control_units.GetAllLegacyControlUnits import org.slf4j.Logger import org.slf4j.LoggerFactory @@ -15,7 +15,7 @@ import org.slf4j.LoggerFactory class AddReporting( private val reportingRepository: ReportingRepository, private val getInfractionSuspicionWithDMLAndSeaFront: GetInfractionSuspicionWithDMLAndSeaFront, - private val getAllControlUnits: GetAllControlUnits, + private val getAllLegacyControlUnits: GetAllLegacyControlUnits, ) { private val logger: Logger = LoggerFactory.getLogger(AddReporting::class.java) @@ -28,7 +28,7 @@ class AddReporting( "The reporting type must be OBSERVATION or INFRACTION_SUSPICION" } - val controlUnits = getAllControlUnits.execute() + val controlUnits = getAllLegacyControlUnits.execute() newReporting.value as InfractionSuspicionOrObservationType newReporting.value.checkReportingActorAndFieldsRequirements() diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/reporting/GetAllCurrentReportings.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/reporting/GetAllCurrentReportings.kt index 83b43b6a53..92e1c0df5d 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/reporting/GetAllCurrentReportings.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/reporting/GetAllCurrentReportings.kt @@ -9,7 +9,7 @@ import fr.gouv.cnsp.monitorfish.domain.entities.reporting.filters.ReportingFilte import fr.gouv.cnsp.monitorfish.domain.entities.vessel.VesselIdentifier import fr.gouv.cnsp.monitorfish.domain.repositories.ReportingRepository import fr.gouv.cnsp.monitorfish.domain.repositories.VesselRepository -import fr.gouv.cnsp.monitorfish.domain.use_cases.control_units.GetAllControlUnits +import fr.gouv.cnsp.monitorfish.domain.use_cases.control_units.GetAllLegacyControlUnits import org.slf4j.Logger import org.slf4j.LoggerFactory @@ -17,7 +17,7 @@ import org.slf4j.LoggerFactory class GetAllCurrentReportings( private val reportingRepository: ReportingRepository, private val vesselRepository: VesselRepository, - private val getAllControlUnits: GetAllControlUnits, + private val getAllLegacyControlUnits: GetAllLegacyControlUnits, ) { private val logger: Logger = LoggerFactory.getLogger(GetAllCurrentReportings::class.java) @@ -30,7 +30,7 @@ class GetAllCurrentReportings( ) val currentReportings = reportingRepository.findAll(filter) - val controlUnits = getAllControlUnits.execute() + val controlUnits = getAllLegacyControlUnits.execute() val currentReportingsWithCharterInfo = currentReportings.map { reporting -> 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 ff767fb1d0..29b7a1df69 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 @@ -9,7 +9,7 @@ import fr.gouv.cnsp.monitorfish.domain.entities.vessel.VesselIdentifier import fr.gouv.cnsp.monitorfish.domain.exceptions.NatinfCodeNotFoundException import fr.gouv.cnsp.monitorfish.domain.repositories.InfractionRepository import fr.gouv.cnsp.monitorfish.domain.repositories.ReportingRepository -import fr.gouv.cnsp.monitorfish.domain.use_cases.control_units.GetAllControlUnits +import fr.gouv.cnsp.monitorfish.domain.use_cases.control_units.GetAllLegacyControlUnits import org.slf4j.LoggerFactory import java.time.ZonedDateTime import kotlin.time.measureTimedValue @@ -18,7 +18,7 @@ import kotlin.time.measureTimedValue class GetVesselReportings( private val reportingRepository: ReportingRepository, private val infractionRepository: InfractionRepository, - private val getAllControlUnits: GetAllControlUnits, + private val getAllLegacyControlUnits: GetAllLegacyControlUnits, ) { private val logger = LoggerFactory.getLogger(GetVesselReportings::class.java) @@ -30,7 +30,7 @@ class GetVesselReportings( vesselIdentifier: VesselIdentifier?, fromDate: ZonedDateTime, ): VesselReportings { - val (controlUnits, controlUnitsTimeTaken) = measureTimedValue { getAllControlUnits.execute() } + val (controlUnits, controlUnitsTimeTaken) = measureTimedValue { getAllLegacyControlUnits.execute() } logger.info("TIME_RECORD - 'getAllControlUnits' took $controlUnitsTimeTaken") val (reportings, reportingsTimeTaken) = diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/reporting/UpdateReporting.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/reporting/UpdateReporting.kt index 4e01be94da..3a43bda492 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/reporting/UpdateReporting.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/reporting/UpdateReporting.kt @@ -4,7 +4,7 @@ import fr.gouv.cnsp.monitorfish.config.UseCase import fr.gouv.cnsp.monitorfish.domain.entities.mission.ControlUnit import fr.gouv.cnsp.monitorfish.domain.entities.reporting.* import fr.gouv.cnsp.monitorfish.domain.repositories.ReportingRepository -import fr.gouv.cnsp.monitorfish.domain.use_cases.control_units.GetAllControlUnits +import fr.gouv.cnsp.monitorfish.domain.use_cases.control_units.GetAllLegacyControlUnits import org.slf4j.Logger import org.slf4j.LoggerFactory @@ -12,7 +12,7 @@ import org.slf4j.LoggerFactory class UpdateReporting( private val reportingRepository: ReportingRepository, private val getInfractionSuspicionWithDMLAndSeaFront: GetInfractionSuspicionWithDMLAndSeaFront, - private val getAllControlUnits: GetAllControlUnits, + private val getAllLegacyControlUnits: GetAllLegacyControlUnits, ) { private val logger: Logger = LoggerFactory.getLogger(UpdateReporting::class.java) @@ -21,7 +21,7 @@ class UpdateReporting( updatedInfractionSuspicionOrObservation: UpdatedInfractionSuspicionOrObservation, ): Pair { val currentReporting = reportingRepository.findById(reportingId) - val controlUnits = getAllControlUnits.execute() + val controlUnits = getAllLegacyControlUnits.execute() logger.info("Updating reporting id $reportingId for vessel id ${currentReporting.vesselId}") require(currentReporting.type != ReportingType.ALERT) { @@ -43,6 +43,7 @@ class UpdateReporting( Pair(updatedReporting, controlUnit) } + ReportingType.INFRACTION_SUSPICION -> { currentReporting.value as InfractionSuspicionOrObservationType @@ -59,6 +60,7 @@ class UpdateReporting( Pair(updatedReporting, controlUnit) } + else -> throw IllegalArgumentException( "The new reporting type must be an INFRACTION_SUSPICION or an OBSERVATION", ) diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/AddReportingUTests.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/AddReportingUTests.kt index 14767267d9..32d90b1925 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/AddReportingUTests.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/AddReportingUTests.kt @@ -6,7 +6,7 @@ import fr.gouv.cnsp.monitorfish.domain.entities.alerts.type.ThreeMilesTrawlingAl import fr.gouv.cnsp.monitorfish.domain.entities.reporting.* import fr.gouv.cnsp.monitorfish.domain.entities.vessel.VesselIdentifier import fr.gouv.cnsp.monitorfish.domain.repositories.ReportingRepository -import fr.gouv.cnsp.monitorfish.domain.use_cases.control_units.GetAllControlUnits +import fr.gouv.cnsp.monitorfish.domain.use_cases.control_units.GetAllLegacyControlUnits import fr.gouv.cnsp.monitorfish.domain.use_cases.reporting.AddReporting import fr.gouv.cnsp.monitorfish.domain.use_cases.reporting.GetInfractionSuspicionWithDMLAndSeaFront import org.assertj.core.api.Assertions.assertThat @@ -29,7 +29,7 @@ class AddReportingUTests { private lateinit var getInfractionSuspicionWithDMLAndSeaFront: GetInfractionSuspicionWithDMLAndSeaFront @Mock - private lateinit var getAllControlUnits: GetAllControlUnits + private lateinit var getAllLegacyControlUnits: GetAllLegacyControlUnits @Test fun `execute Should throw an exception When the reporting is an alert`() { @@ -54,7 +54,11 @@ class AddReportingUTests { // When val throwable = catchThrowable { - AddReporting(reportingRepository, getInfractionSuspicionWithDMLAndSeaFront, getAllControlUnits).execute( + AddReporting( + reportingRepository, + getInfractionSuspicionWithDMLAndSeaFront, + getAllLegacyControlUnits, + ).execute( reportingToAdd, ) } @@ -82,11 +86,11 @@ class AddReportingUTests { creationDate = ZonedDateTime.now(), validationDate = ZonedDateTime.now(), value = - Observation( - reportingActor = reportingActor, - authorTrigram = "LTH", - title = "A title", - ), + Observation( + reportingActor = reportingActor, + authorTrigram = "LTH", + title = "A title", + ), isArchived = false, isDeleted = false, ) @@ -95,7 +99,11 @@ class AddReportingUTests { // When val throwable = catchThrowable { - AddReporting(reportingRepository, getInfractionSuspicionWithDMLAndSeaFront, getAllControlUnits).execute( + AddReporting( + reportingRepository, + getInfractionSuspicionWithDMLAndSeaFront, + getAllLegacyControlUnits, + ).execute( reportingToAdd, ) } @@ -137,19 +145,19 @@ class AddReportingUTests { creationDate = ZonedDateTime.now(), validationDate = ZonedDateTime.now(), value = - InfractionSuspicion( - reportingActor = ReportingActor.OPS, - natinfCode = 1235, - authorTrigram = "LTH", - title = "Chalut en boeuf illégal", - ), + InfractionSuspicion( + reportingActor = ReportingActor.OPS, + natinfCode = 1235, + authorTrigram = "LTH", + title = "Chalut en boeuf illégal", + ), isArchived = false, isDeleted = false, ) given(reportingRepository.save(any())).willReturn(reportingToAdd) // When - AddReporting(reportingRepository, getInfractionSuspicionWithDMLAndSeaFront, getAllControlUnits).execute( + AddReporting(reportingRepository, getInfractionSuspicionWithDMLAndSeaFront, getAllLegacyControlUnits).execute( reportingToAdd, ) diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/GetAllCurrentReportingsUTests.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/GetAllCurrentReportingsUTests.kt index 1e94d43200..b02c86a2ba 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/GetAllCurrentReportingsUTests.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/GetAllCurrentReportingsUTests.kt @@ -11,7 +11,7 @@ import fr.gouv.cnsp.monitorfish.domain.entities.reporting.ReportingType import fr.gouv.cnsp.monitorfish.domain.entities.vessel.VesselIdentifier import fr.gouv.cnsp.monitorfish.domain.repositories.ReportingRepository import fr.gouv.cnsp.monitorfish.domain.repositories.VesselRepository -import fr.gouv.cnsp.monitorfish.domain.use_cases.control_units.GetAllControlUnits +import fr.gouv.cnsp.monitorfish.domain.use_cases.control_units.GetAllLegacyControlUnits import fr.gouv.cnsp.monitorfish.domain.use_cases.reporting.GetAllCurrentReportings import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.Assertions.catchThrowable @@ -30,7 +30,7 @@ class GetAllCurrentReportingsUTests { private lateinit var vesselRepository: VesselRepository @MockBean - private lateinit var getAllControlUnits: GetAllControlUnits + private lateinit var getAllLegacyControlUnits: GetAllLegacyControlUnits @Test fun `execute Should get all reportings with the underCharter field`() { @@ -44,12 +44,12 @@ class GetAllCurrentReportingsUTests { flagState = CountryCode.FR, creationDate = ZonedDateTime.now(), value = - InfractionSuspicion( - ReportingActor.OPS, - natinfCode = 123456, - authorTrigram = "LTH", - title = "A title", - ), + InfractionSuspicion( + ReportingActor.OPS, + natinfCode = 123456, + authorTrigram = "LTH", + title = "A title", + ), type = ReportingType.INFRACTION_SUSPICION, isDeleted = false, isArchived = false, @@ -68,7 +68,7 @@ class GetAllCurrentReportingsUTests { GetAllCurrentReportings( reportingRepository, vesselRepository, - getAllControlUnits, + getAllLegacyControlUnits, ).execute() // Then @@ -90,12 +90,12 @@ class GetAllCurrentReportingsUTests { flagState = CountryCode.FR, creationDate = ZonedDateTime.now(), value = - InfractionSuspicion( - ReportingActor.OPS, - natinfCode = 123456, - authorTrigram = "LTH", - title = "A title", - ), + InfractionSuspicion( + ReportingActor.OPS, + natinfCode = 123456, + authorTrigram = "LTH", + title = "A title", + ), type = ReportingType.INFRACTION_SUSPICION, isDeleted = false, isArchived = false, @@ -105,7 +105,7 @@ class GetAllCurrentReportingsUTests { // When val throwable = catchThrowable { - GetAllCurrentReportings(reportingRepository, vesselRepository, getAllControlUnits).execute() + GetAllCurrentReportings(reportingRepository, vesselRepository, getAllLegacyControlUnits).execute() } // Then diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/UpdateReportingUTests.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/UpdateReportingUTests.kt index b40d46220b..19ab709264 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/UpdateReportingUTests.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/UpdateReportingUTests.kt @@ -6,7 +6,7 @@ import fr.gouv.cnsp.monitorfish.domain.entities.alerts.type.ThreeMilesTrawlingAl import fr.gouv.cnsp.monitorfish.domain.entities.reporting.* import fr.gouv.cnsp.monitorfish.domain.entities.vessel.VesselIdentifier import fr.gouv.cnsp.monitorfish.domain.repositories.ReportingRepository -import fr.gouv.cnsp.monitorfish.domain.use_cases.control_units.GetAllControlUnits +import fr.gouv.cnsp.monitorfish.domain.use_cases.control_units.GetAllLegacyControlUnits import fr.gouv.cnsp.monitorfish.domain.use_cases.reporting.GetInfractionSuspicionWithDMLAndSeaFront import fr.gouv.cnsp.monitorfish.domain.use_cases.reporting.UpdateReporting import fr.gouv.cnsp.monitorfish.domain.use_cases.reporting.UpdatedInfractionSuspicionOrObservation @@ -29,7 +29,7 @@ class UpdateReportingUTests { private lateinit var getInfractionSuspicionWithDMLAndSeaFront: GetInfractionSuspicionWithDMLAndSeaFront @MockBean - private lateinit var getAllControlUnits: GetAllControlUnits + private lateinit var getAllLegacyControlUnits: GetAllLegacyControlUnits @Test fun `execute Should throw an exception When the reporting is an alert`() { @@ -55,7 +55,7 @@ class UpdateReportingUTests { // When val throwable = catchThrowable { - UpdateReporting(reportingRepository, getInfractionSuspicionWithDMLAndSeaFront, getAllControlUnits) + UpdateReporting(reportingRepository, getInfractionSuspicionWithDMLAndSeaFront, getAllLegacyControlUnits) .execute( 1, UpdatedInfractionSuspicionOrObservation( @@ -87,12 +87,12 @@ class UpdateReportingUTests { creationDate = ZonedDateTime.now(), validationDate = ZonedDateTime.now(), value = - InfractionSuspicion( - reportingActor = ReportingActor.UNIT, - authorTrigram = "LTH", - title = "Test", - natinfCode = 1234, - ) as ReportingValue, + InfractionSuspicion( + reportingActor = ReportingActor.UNIT, + authorTrigram = "LTH", + title = "Test", + natinfCode = 1234, + ) as ReportingValue, isArchived = false, isDeleted = false, ), @@ -101,7 +101,7 @@ class UpdateReportingUTests { // When val throwable = catchThrowable { - UpdateReporting(reportingRepository, getInfractionSuspicionWithDMLAndSeaFront, getAllControlUnits) + UpdateReporting(reportingRepository, getInfractionSuspicionWithDMLAndSeaFront, getAllLegacyControlUnits) .execute( 1, UpdatedInfractionSuspicionOrObservation( @@ -138,12 +138,12 @@ class UpdateReportingUTests { creationDate = ZonedDateTime.now(), validationDate = ZonedDateTime.now(), value = - InfractionSuspicion( - reportingActor = ReportingActor.UNIT, - authorTrigram = "LTH", - title = "Test", - natinfCode = 1234, - ) as ReportingValue, + InfractionSuspicion( + reportingActor = ReportingActor.UNIT, + authorTrigram = "LTH", + title = "Test", + natinfCode = 1234, + ) as ReportingValue, isArchived = false, isDeleted = false, ) @@ -161,7 +161,7 @@ class UpdateReportingUTests { // When val throwable = catchThrowable { - UpdateReporting(reportingRepository, getInfractionSuspicionWithDMLAndSeaFront, getAllControlUnits) + UpdateReporting(reportingRepository, getInfractionSuspicionWithDMLAndSeaFront, getAllLegacyControlUnits) .execute( 1, UpdatedInfractionSuspicionOrObservation( @@ -201,12 +201,12 @@ class UpdateReportingUTests { creationDate = ZonedDateTime.now(), validationDate = ZonedDateTime.now(), value = - InfractionSuspicion( - reportingActor = ReportingActor.UNIT, - authorTrigram = "LTH", - title = "Test", - natinfCode = 1234, - ) as ReportingValue, + InfractionSuspicion( + reportingActor = ReportingActor.UNIT, + authorTrigram = "LTH", + title = "Test", + natinfCode = 1234, + ) as ReportingValue, isArchived = false, isDeleted = false, ), @@ -218,7 +218,7 @@ class UpdateReportingUTests { UpdateReporting( reportingRepository, getInfractionSuspicionWithDMLAndSeaFront, - getAllControlUnits, + getAllLegacyControlUnits, ).execute( 1, UpdatedInfractionSuspicionOrObservation( @@ -265,7 +265,11 @@ class UpdateReportingUTests { given(reportingRepository.update(any(), isA())).willReturn(reporting) // When - UpdateReporting(reportingRepository, getInfractionSuspicionWithDMLAndSeaFront, getAllControlUnits).execute( + UpdateReporting( + reportingRepository, + getInfractionSuspicionWithDMLAndSeaFront, + getAllLegacyControlUnits, + ).execute( 1, UpdatedInfractionSuspicionOrObservation( reportingActor = ReportingActor.UNIT, @@ -302,12 +306,12 @@ class UpdateReportingUTests { creationDate = ZonedDateTime.now(), validationDate = ZonedDateTime.now(), value = - InfractionSuspicion( - reportingActor = ReportingActor.UNIT, - authorTrigram = "LTH", - title = "Test", - natinfCode = 1234, - ) as ReportingValue, + InfractionSuspicion( + reportingActor = ReportingActor.UNIT, + authorTrigram = "LTH", + title = "Test", + natinfCode = 1234, + ) as ReportingValue, isArchived = false, isDeleted = false, ) @@ -315,7 +319,11 @@ class UpdateReportingUTests { given(reportingRepository.update(any(), isA())).willReturn(reporting) // When - UpdateReporting(reportingRepository, getInfractionSuspicionWithDMLAndSeaFront, getAllControlUnits).execute( + UpdateReporting( + reportingRepository, + getInfractionSuspicionWithDMLAndSeaFront, + getAllLegacyControlUnits, + ).execute( 1, UpdatedInfractionSuspicionOrObservation( reportingActor = ReportingActor.UNIT, @@ -354,12 +362,12 @@ class UpdateReportingUTests { creationDate = ZonedDateTime.now(), validationDate = ZonedDateTime.now(), value = - InfractionSuspicion( - reportingActor = ReportingActor.UNIT, - title = "Test", - natinfCode = 1234, - authorTrigram = "LTH", - ) as ReportingValue, + InfractionSuspicion( + reportingActor = ReportingActor.UNIT, + title = "Test", + natinfCode = 1234, + authorTrigram = "LTH", + ) as ReportingValue, isArchived = false, isDeleted = false, ) @@ -378,7 +386,11 @@ class UpdateReportingUTests { ) // When - UpdateReporting(reportingRepository, getInfractionSuspicionWithDMLAndSeaFront, getAllControlUnits).execute( + UpdateReporting( + reportingRepository, + getInfractionSuspicionWithDMLAndSeaFront, + getAllLegacyControlUnits, + ).execute( 1, UpdatedInfractionSuspicionOrObservation( reportingActor = ReportingActor.UNIT, @@ -415,11 +427,11 @@ class UpdateReportingUTests { creationDate = ZonedDateTime.now(), validationDate = ZonedDateTime.now(), value = - Observation( - reportingActor = ReportingActor.UNIT, - title = "Test", - authorTrigram = "LTH", - ) as ReportingValue, + Observation( + reportingActor = ReportingActor.UNIT, + title = "Test", + authorTrigram = "LTH", + ) as ReportingValue, isArchived = false, isDeleted = false, ) @@ -427,7 +439,11 @@ class UpdateReportingUTests { given(reportingRepository.update(any(), isA())).willReturn(reporting) // When - UpdateReporting(reportingRepository, getInfractionSuspicionWithDMLAndSeaFront, getAllControlUnits).execute( + UpdateReporting( + reportingRepository, + getInfractionSuspicionWithDMLAndSeaFront, + getAllLegacyControlUnits, + ).execute( 1, UpdatedInfractionSuspicionOrObservation( reportingActor = ReportingActor.UNIT, @@ -461,11 +477,11 @@ class UpdateReportingUTests { creationDate = ZonedDateTime.now(), validationDate = ZonedDateTime.now(), value = - Observation( - reportingActor = ReportingActor.UNIT, - title = "Test", - authorTrigram = "LTH", - ) as ReportingValue, + Observation( + reportingActor = ReportingActor.UNIT, + title = "Test", + authorTrigram = "LTH", + ) as ReportingValue, isArchived = false, isDeleted = false, ) @@ -483,7 +499,11 @@ class UpdateReportingUTests { ) // When - UpdateReporting(reportingRepository, getInfractionSuspicionWithDMLAndSeaFront, getAllControlUnits).execute( + UpdateReporting( + reportingRepository, + getInfractionSuspicionWithDMLAndSeaFront, + getAllLegacyControlUnits, + ).execute( 1, UpdatedInfractionSuspicionOrObservation( reportingActor = ReportingActor.UNIT, diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/reporting/GetVesselReportingsUTests.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/reporting/GetVesselReportingsUTests.kt index 4397403bb6..4b63f4f8ca 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/reporting/GetVesselReportingsUTests.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/reporting/GetVesselReportingsUTests.kt @@ -12,7 +12,7 @@ import fr.gouv.cnsp.monitorfish.domain.repositories.InfractionRepository import fr.gouv.cnsp.monitorfish.domain.repositories.ReportingRepository import fr.gouv.cnsp.monitorfish.domain.use_cases.TestUtils import fr.gouv.cnsp.monitorfish.domain.use_cases.TestUtils.createCurrentReporting -import fr.gouv.cnsp.monitorfish.domain.use_cases.control_units.GetAllControlUnits +import fr.gouv.cnsp.monitorfish.domain.use_cases.control_units.GetAllLegacyControlUnits import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -30,7 +30,7 @@ class GetVesselReportingsUTests { private lateinit var infractionRepository: InfractionRepository @MockBean - private lateinit var getAllControlUnits: GetAllControlUnits + private lateinit var getAllLegacyControlUnits: GetAllLegacyControlUnits @Test fun `execute Should return a map of years for archived`() { @@ -45,7 +45,7 @@ class GetVesselReportingsUTests { GetVesselReportings( reportingRepository, infractionRepository, - getAllControlUnits, + getAllLegacyControlUnits, ).execute( null, "FR224226850", @@ -80,7 +80,7 @@ class GetVesselReportingsUTests { GetVesselReportings( reportingRepository, infractionRepository, - getAllControlUnits, + getAllLegacyControlUnits, ).execute( null, "FR224226850", @@ -125,7 +125,7 @@ class GetVesselReportingsUTests { GetVesselReportings( reportingRepository, infractionRepository, - getAllControlUnits, + getAllLegacyControlUnits, ).execute( 123456, "FR224226850", @@ -188,7 +188,7 @@ class GetVesselReportingsUTests { GetVesselReportings( reportingRepository, infractionRepository, - getAllControlUnits, + getAllLegacyControlUnits, ).execute( null, "FR224226850", @@ -271,7 +271,7 @@ class GetVesselReportingsUTests { GetVesselReportings( reportingRepository, infractionRepository, - getAllControlUnits, + getAllLegacyControlUnits, ).execute( null, "FR55667788", @@ -396,7 +396,7 @@ class GetVesselReportingsUTests { GetVesselReportings( reportingRepository, infractionRepository, - getAllControlUnits, + getAllLegacyControlUnits, ).execute( null, "FR55667788", From 2cf70d27478c29b58bb9e14205edd5a88478829b Mon Sep 17 00:00:00 2001 From: Ivan Gabriele Date: Wed, 23 Oct 2024 09:30:02 +0200 Subject: [PATCH 04/59] Rename ControlUnit to LegacyControlUnit in Backend --- .../{ControlUnit.kt => LegacyControlUnit.kt} | 2 +- .../domain/entities/mission/Mission.kt | 2 +- .../mission/mission_actions/MissionAction.kt | 4 +- .../reporting/ReportingAndOccurrences.kt | 4 +- .../LegacyControlUnitRepository.kt | 4 +- .../domain/repositories/MissionRepository.kt | 4 +- .../control_units/GetAllLegacyControlUnits.kt | 4 +- .../mission_actions/GetActivityReports.kt | 11 +-- .../mission_actions/GetVesselControls.kt | 2 +- .../mission_actions/dtos/ActivityReport.kt | 4 +- .../use_cases/reporting/AddReporting.kt | 4 +- .../reporting/GetAllCurrentReportings.kt | 4 +- .../reporting/GetVesselReportings.kt | 12 +-- .../use_cases/reporting/UpdateReporting.kt | 10 +-- .../api/outputs/ActivityReportDataOutput.kt | 6 +- .../outputs/InfractionSuspicionDataOutput.kt | 8 +- .../api/outputs/MissionActionDataOutput.kt | 6 +- .../outputs/MissionWithActionsDataOutput.kt | 4 +- .../api/outputs/ObservationDataOutput.kt | 8 +- .../ReportingAndOccurrencesDataOutput.kt | 4 +- .../api/outputs/ReportingDataOutput.kt | 8 +- .../APILegacyControlUnitRepository.kt | 4 +- .../monitorenv/APIMissionRepository.kt | 32 +++++--- .../monitorenv/input/MissionDataResponse.kt | 8 +- .../domain/use_cases/AddReportingUTests.kt | 22 ++--- .../GetAllCurrentReportingsUTests.kt | 24 +++--- .../domain/use_cases/UpdateReportingUTests.kt | 80 +++++++++---------- .../use_cases/mission/GetMissionUTests.kt | 2 +- .../domain/use_cases/mission/TestUtils.kt | 2 +- .../GetActivityReportsUTests.kt | 6 +- .../api/bff/MissionActionsControllerITests.kt | 4 +- .../api/bff/ReportingControllerITests.kt | 4 +- .../api/bff/VesselControllerITests.kt | 6 +- .../JpaMissionActionRepositoryITests.kt | 4 +- 34 files changed, 158 insertions(+), 155 deletions(-) rename backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/mission/{ControlUnit.kt => LegacyControlUnit.kt} (90%) diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/mission/ControlUnit.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/mission/LegacyControlUnit.kt similarity index 90% rename from backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/mission/ControlUnit.kt rename to backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/mission/LegacyControlUnit.kt index 7890a7ad8c..6b46c19840 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/mission/ControlUnit.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/mission/LegacyControlUnit.kt @@ -3,7 +3,7 @@ package fr.gouv.cnsp.monitorfish.domain.entities.mission import kotlinx.serialization.Serializable @Serializable -data class ControlUnit( +data class LegacyControlUnit( val id: Int, val administration: String, val isArchived: Boolean, diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/mission/Mission.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/mission/Mission.kt index 0c6166fa35..ee31077b92 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/mission/Mission.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/mission/Mission.kt @@ -25,5 +25,5 @@ data class Mission( val missionSource: MissionSource, val hasMissionOrder: Boolean? = false, val isUnderJdp: Boolean? = false, - val controlUnits: List = listOf(), + val legacyControlUnits: List = listOf(), ) diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/mission/mission_actions/MissionAction.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/mission/mission_actions/MissionAction.kt index ff47d870f1..e6f22bfbd1 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/mission/mission_actions/MissionAction.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/mission/mission_actions/MissionAction.kt @@ -2,7 +2,7 @@ package fr.gouv.cnsp.monitorfish.domain.entities.mission.mission_actions import com.neovisionaries.i18n.CountryCode import fr.gouv.cnsp.monitorfish.config.Patchable -import fr.gouv.cnsp.monitorfish.domain.entities.mission.ControlUnit +import fr.gouv.cnsp.monitorfish.domain.entities.mission.LegacyControlUnit import java.time.ZonedDateTime data class MissionAction( @@ -58,7 +58,7 @@ data class MissionAction( * This field is only used by the `GetVesselControls` use-case. * /!\ Do not use it to get `controlUnits` as the field will be empty be default. */ - var controlUnits: List = listOf(), + var legacyControlUnits: List = listOf(), val isDeleted: Boolean, val hasSomeGearsSeized: Boolean, val hasSomeSpeciesSeized: Boolean, diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/reporting/ReportingAndOccurrences.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/reporting/ReportingAndOccurrences.kt index 45e5e39862..7189843694 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/reporting/ReportingAndOccurrences.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/reporting/ReportingAndOccurrences.kt @@ -1,9 +1,9 @@ package fr.gouv.cnsp.monitorfish.domain.entities.reporting -import fr.gouv.cnsp.monitorfish.domain.entities.mission.ControlUnit +import fr.gouv.cnsp.monitorfish.domain.entities.mission.LegacyControlUnit data class ReportingAndOccurrences( val otherOccurrencesOfSameAlert: List, val reporting: Reporting, - val controlUnit: ControlUnit?, + val legacyControlUnit: LegacyControlUnit?, ) diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/repositories/LegacyControlUnitRepository.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/repositories/LegacyControlUnitRepository.kt index 2c38a03e2f..e826b704ef 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/repositories/LegacyControlUnitRepository.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/repositories/LegacyControlUnitRepository.kt @@ -1,7 +1,7 @@ package fr.gouv.cnsp.monitorfish.domain.repositories -import fr.gouv.cnsp.monitorfish.domain.entities.mission.ControlUnit +import fr.gouv.cnsp.monitorfish.domain.entities.mission.LegacyControlUnit interface LegacyControlUnitRepository { - fun findAll(): List + fun findAll(): List } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/repositories/MissionRepository.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/repositories/MissionRepository.kt index 2091a88d64..e14e99b6e2 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/repositories/MissionRepository.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/repositories/MissionRepository.kt @@ -1,6 +1,6 @@ package fr.gouv.cnsp.monitorfish.domain.repositories -import fr.gouv.cnsp.monitorfish.domain.entities.mission.ControlUnit +import fr.gouv.cnsp.monitorfish.domain.entities.mission.LegacyControlUnit import fr.gouv.cnsp.monitorfish.domain.entities.mission.Mission import fr.gouv.cnsp.monitorfish.domain.exceptions.CouldNotFindException import kotlinx.coroutines.CoroutineScope @@ -11,7 +11,7 @@ interface MissionRepository { fun findControlUnitsOfMission( scope: CoroutineScope, missionId: Int, - ): Deferred> + ): Deferred> fun findAllMissions( pageNumber: Int?, diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/control_units/GetAllLegacyControlUnits.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/control_units/GetAllLegacyControlUnits.kt index 64248e457e..6563869638 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/control_units/GetAllLegacyControlUnits.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/control_units/GetAllLegacyControlUnits.kt @@ -1,14 +1,14 @@ package fr.gouv.cnsp.monitorfish.domain.use_cases.control_units import fr.gouv.cnsp.monitorfish.config.UseCase -import fr.gouv.cnsp.monitorfish.domain.entities.mission.ControlUnit +import fr.gouv.cnsp.monitorfish.domain.entities.mission.LegacyControlUnit import fr.gouv.cnsp.monitorfish.domain.repositories.LegacyControlUnitRepository @UseCase class GetAllLegacyControlUnits( private val legacyControlUnitsRepository: LegacyControlUnitRepository, ) { - fun execute(): List { + fun execute(): List { return legacyControlUnitsRepository.findAll() } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/mission_actions/GetActivityReports.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/mission_actions/GetActivityReports.kt index d35548647c..2a228c06c0 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/mission_actions/GetActivityReports.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/mission_actions/GetActivityReports.kt @@ -75,12 +75,9 @@ class GetActivityReports( val controlMission = missions.firstOrNull { mission -> mission.id == control.missionId } // All AECP reports are excluded from the response // see: https://github.com/MTES-MCT/monitorfish/issues/3194 - return@filter !( - controlMission?.controlUnits?.any { - controlUnit -> - controlUnit.administration == "AECP" - } ?: false - ) + return@filter controlMission?.legacyControlUnits?.any { controlUnit -> + controlUnit.administration == "AECP" + } != true } logger.info("Found ${filteredControls.size} controls to report.") @@ -125,7 +122,7 @@ class GetActivityReports( ActivityReport( action = control, activityCode = activityCode, - controlUnits = controlMission.controlUnits, + legacyControlUnits = controlMission.legacyControlUnits, faoArea = faoArea?.faoCode, /** * The fleet segment is set as null, as we need to integrate the EFCA segments referential diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/mission_actions/GetVesselControls.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/mission_actions/GetVesselControls.kt index 3668760adf..167d4dc506 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/mission_actions/GetVesselControls.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/mission_actions/GetVesselControls.kt @@ -45,7 +45,7 @@ class GetVesselControls( Pair(action, controlUnits) }.map { (control, controlUnits) -> - control.controlUnits = controlUnits.await() + control.legacyControlUnits = controlUnits.await() control.portLocode?.let { port -> try { diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/mission_actions/dtos/ActivityReport.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/mission_actions/dtos/ActivityReport.kt index 53df863986..d2aec0cd67 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/mission_actions/dtos/ActivityReport.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/mission_actions/dtos/ActivityReport.kt @@ -1,6 +1,6 @@ package fr.gouv.cnsp.monitorfish.domain.use_cases.mission.mission_actions.dtos -import fr.gouv.cnsp.monitorfish.domain.entities.mission.ControlUnit +import fr.gouv.cnsp.monitorfish.domain.entities.mission.LegacyControlUnit import fr.gouv.cnsp.monitorfish.domain.entities.mission.mission_actions.MissionAction import fr.gouv.cnsp.monitorfish.domain.entities.mission.mission_actions.actrep.ActivityCode import fr.gouv.cnsp.monitorfish.domain.entities.vessel.Vessel @@ -12,6 +12,6 @@ data class ActivityReport( val activityCode: ActivityCode, // The `districtCode` and `internalReferenceNumber` concatenation val vesselNationalIdentifier: String, - val controlUnits: List, + val legacyControlUnits: List, val vessel: Vessel, ) diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/reporting/AddReporting.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/reporting/AddReporting.kt index 52af3ed3f1..b98daf7d0f 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/reporting/AddReporting.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/reporting/AddReporting.kt @@ -1,7 +1,7 @@ package fr.gouv.cnsp.monitorfish.domain.use_cases.reporting import fr.gouv.cnsp.monitorfish.config.UseCase -import fr.gouv.cnsp.monitorfish.domain.entities.mission.ControlUnit +import fr.gouv.cnsp.monitorfish.domain.entities.mission.LegacyControlUnit import fr.gouv.cnsp.monitorfish.domain.entities.reporting.InfractionSuspicion import fr.gouv.cnsp.monitorfish.domain.entities.reporting.InfractionSuspicionOrObservationType import fr.gouv.cnsp.monitorfish.domain.entities.reporting.Reporting @@ -19,7 +19,7 @@ class AddReporting( ) { private val logger: Logger = LoggerFactory.getLogger(AddReporting::class.java) - fun execute(newReporting: Reporting): Pair { + fun execute(newReporting: Reporting): Pair { logger.info( "Adding reporting for vessel ${newReporting.internalReferenceNumber}/${newReporting.ircs}/${newReporting.externalReferenceNumber}", ) diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/reporting/GetAllCurrentReportings.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/reporting/GetAllCurrentReportings.kt index 92e1c0df5d..471b6efd02 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/reporting/GetAllCurrentReportings.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/reporting/GetAllCurrentReportings.kt @@ -1,7 +1,7 @@ package fr.gouv.cnsp.monitorfish.domain.use_cases.reporting import fr.gouv.cnsp.monitorfish.config.UseCase -import fr.gouv.cnsp.monitorfish.domain.entities.mission.ControlUnit +import fr.gouv.cnsp.monitorfish.domain.entities.mission.LegacyControlUnit import fr.gouv.cnsp.monitorfish.domain.entities.reporting.InfractionSuspicionOrObservationType import fr.gouv.cnsp.monitorfish.domain.entities.reporting.Reporting import fr.gouv.cnsp.monitorfish.domain.entities.reporting.ReportingType @@ -21,7 +21,7 @@ class GetAllCurrentReportings( ) { private val logger: Logger = LoggerFactory.getLogger(GetAllCurrentReportings::class.java) - fun execute(): List> { + fun execute(): List> { val filter = ReportingFilter( isArchived = 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 29b7a1df69..bfbb7f70bd 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 @@ -3,7 +3,7 @@ package fr.gouv.cnsp.monitorfish.domain.use_cases.reporting import fr.gouv.cnsp.monitorfish.config.UseCase import fr.gouv.cnsp.monitorfish.domain.entities.alerts.type.AlertType import fr.gouv.cnsp.monitorfish.domain.entities.alerts.type.AlertTypeMapping -import fr.gouv.cnsp.monitorfish.domain.entities.mission.ControlUnit +import fr.gouv.cnsp.monitorfish.domain.entities.mission.LegacyControlUnit import fr.gouv.cnsp.monitorfish.domain.entities.reporting.* import fr.gouv.cnsp.monitorfish.domain.entities.vessel.VesselIdentifier import fr.gouv.cnsp.monitorfish.domain.exceptions.NatinfCodeNotFoundException @@ -152,7 +152,7 @@ class GetVesselReportings( private fun enrichWithInfractionAndControlUnit( reportingAndOccurrences: ReportingAndOccurrences, - controlUnits: List, + legacyControlUnits: List, ): ReportingAndOccurrences { val updatedInfraction = reportingAndOccurrences.reporting.value.natinfCode?.let { natinfCode -> @@ -178,9 +178,9 @@ class GetVesselReportings( } val controlUnitId = (updatedReporting.value as? InfractionSuspicionOrObservationType)?.controlUnitId - val foundControlUnit = controlUnits.find { it.id == controlUnitId } + val foundControlUnit = legacyControlUnits.find { it.id == controlUnitId } - return updatedReportingAndOccurrences.copy(controlUnit = foundControlUnit) + return updatedReportingAndOccurrences.copy(legacyControlUnit = foundControlUnit) } private fun getReportingsAndOccurrences(reportings: List): List { @@ -191,7 +191,7 @@ class GetVesselReportings( ReportingAndOccurrences( otherOccurrencesOfSameAlert = emptyList(), reporting = reporting, - controlUnit = null, + legacyControlUnit = null, ) } @@ -226,7 +226,7 @@ class GetVesselReportings( ReportingAndOccurrences( otherOccurrencesOfSameAlert = otherOccurrencesOfSameAlert, reporting = lastAlert, - controlUnit = null, + legacyControlUnit = null, ), ) } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/reporting/UpdateReporting.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/reporting/UpdateReporting.kt index 3a43bda492..056a9ffbae 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/reporting/UpdateReporting.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/reporting/UpdateReporting.kt @@ -1,7 +1,7 @@ package fr.gouv.cnsp.monitorfish.domain.use_cases.reporting import fr.gouv.cnsp.monitorfish.config.UseCase -import fr.gouv.cnsp.monitorfish.domain.entities.mission.ControlUnit +import fr.gouv.cnsp.monitorfish.domain.entities.mission.LegacyControlUnit import fr.gouv.cnsp.monitorfish.domain.entities.reporting.* import fr.gouv.cnsp.monitorfish.domain.repositories.ReportingRepository import fr.gouv.cnsp.monitorfish.domain.use_cases.control_units.GetAllLegacyControlUnits @@ -19,7 +19,7 @@ class UpdateReporting( fun execute( reportingId: Int, updatedInfractionSuspicionOrObservation: UpdatedInfractionSuspicionOrObservation, - ): Pair { + ): Pair { val currentReporting = reportingRepository.findById(reportingId) val controlUnits = getAllLegacyControlUnits.execute() logger.info("Updating reporting id $reportingId for vessel id ${currentReporting.vesselId}") @@ -69,9 +69,9 @@ class UpdateReporting( fun getControlUnit( reporting: Reporting, - controlUnits: List, - ): ControlUnit? { + legacyControlUnits: List, + ): LegacyControlUnit? { val controlUnitId = (reporting.value as InfractionSuspicionOrObservationType).controlUnitId - return controlUnits.find { it.id == controlUnitId } + return legacyControlUnits.find { it.id == controlUnitId } } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/ActivityReportDataOutput.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/ActivityReportDataOutput.kt index 64c9e3c369..17046e5f0a 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/ActivityReportDataOutput.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/ActivityReportDataOutput.kt @@ -1,6 +1,6 @@ package fr.gouv.cnsp.monitorfish.infrastructure.api.outputs -import fr.gouv.cnsp.monitorfish.domain.entities.mission.ControlUnit +import fr.gouv.cnsp.monitorfish.domain.entities.mission.LegacyControlUnit import fr.gouv.cnsp.monitorfish.domain.entities.mission.mission_actions.actrep.ActivityCode import fr.gouv.cnsp.monitorfish.domain.use_cases.mission.mission_actions.dtos.ActivityReport @@ -10,7 +10,7 @@ data class ActivityReportDataOutput( val faoArea: String?, val segment: String?, val vesselNationalIdentifier: String, - val controlUnits: List, + val legacyControlUnits: List, val vessel: VesselDataOutput, ) { companion object { @@ -21,7 +21,7 @@ data class ActivityReportDataOutput( faoArea = activityReport.faoArea, segment = activityReport.segment, vesselNationalIdentifier = activityReport.vesselNationalIdentifier, - controlUnits = activityReport.controlUnits, + legacyControlUnits = activityReport.legacyControlUnits, vessel = VesselDataOutput.fromVessel(activityReport.vessel), ) } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/InfractionSuspicionDataOutput.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/InfractionSuspicionDataOutput.kt index 10eff5720d..e532659eaa 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/InfractionSuspicionDataOutput.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/InfractionSuspicionDataOutput.kt @@ -1,13 +1,13 @@ package fr.gouv.cnsp.monitorfish.infrastructure.api.outputs -import fr.gouv.cnsp.monitorfish.domain.entities.mission.ControlUnit +import fr.gouv.cnsp.monitorfish.domain.entities.mission.LegacyControlUnit import fr.gouv.cnsp.monitorfish.domain.entities.reporting.InfractionSuspicion import fr.gouv.cnsp.monitorfish.domain.entities.reporting.ReportingActor data class InfractionSuspicionDataOutput( val reportingActor: ReportingActor, val controlUnitId: Int? = null, - val controlUnit: ControlUnit? = null, + val legacyControlUnit: LegacyControlUnit? = null, val authorTrigram: String, val authorContact: String? = null, val title: String, @@ -19,12 +19,12 @@ data class InfractionSuspicionDataOutput( companion object { fun fromInfractionSuspicion( infractionSuspicion: InfractionSuspicion, - controlUnit: ControlUnit? = null, + legacyControlUnit: LegacyControlUnit? = null, ): InfractionSuspicionDataOutput { return InfractionSuspicionDataOutput( reportingActor = infractionSuspicion.reportingActor, controlUnitId = infractionSuspicion.controlUnitId, - controlUnit = controlUnit, + legacyControlUnit = legacyControlUnit, authorTrigram = infractionSuspicion.authorTrigram, authorContact = infractionSuspicion.authorContact, title = infractionSuspicion.title, diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/MissionActionDataOutput.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/MissionActionDataOutput.kt index b99a16dfa9..3de0ace72c 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/MissionActionDataOutput.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/MissionActionDataOutput.kt @@ -1,7 +1,7 @@ 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.LegacyControlUnit import fr.gouv.cnsp.monitorfish.domain.entities.mission.mission_actions.* import fr.gouv.cnsp.monitorfish.domain.entities.mission.mission_actions.Completion import java.time.ZonedDateTime @@ -49,7 +49,7 @@ data class MissionActionDataOutput( val otherComments: String? = null, val gearOnboard: List = listOf(), val speciesOnboard: List = listOf(), - val controlUnits: List = listOf(), + val legacyControlUnits: List = listOf(), val userTrigram: String, val vesselTargeted: ControlCheck? = null, val hasSomeGearsSeized: Boolean, @@ -109,7 +109,7 @@ data class MissionActionDataOutput( otherComments = missionAction.otherComments, gearOnboard = missionAction.gearOnboard, speciesOnboard = missionAction.speciesOnboard, - controlUnits = missionAction.controlUnits, + legacyControlUnits = missionAction.legacyControlUnits, userTrigram = missionAction.userTrigram, vesselTargeted = missionAction.vesselTargeted, hasSomeGearsSeized = missionAction.hasSomeGearsSeized, diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/MissionWithActionsDataOutput.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/MissionWithActionsDataOutput.kt index d80a020641..fc4b4cfa5a 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/MissionWithActionsDataOutput.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/MissionWithActionsDataOutput.kt @@ -25,7 +25,7 @@ data class MissionWithActionsDataOutput( val missionSource: MissionSource, val hasMissionOrder: Boolean? = false, val isUnderJdp: Boolean? = false, - val controlUnits: List = listOf(), + val legacyControlUnits: List = listOf(), val actions: List, ) { companion object { @@ -50,7 +50,7 @@ data class MissionWithActionsDataOutput( missionSource = missionAndActions.mission.missionSource, hasMissionOrder = missionAndActions.mission.hasMissionOrder, isUnderJdp = missionAndActions.mission.isUnderJdp, - controlUnits = missionAndActions.mission.controlUnits, + legacyControlUnits = missionAndActions.mission.legacyControlUnits, actions = missionAndActions.actions.map { MissionActionDataOutput.fromMissionAction(it) }, ) } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/ObservationDataOutput.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/ObservationDataOutput.kt index e8e6049fb7..242f4de3aa 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/ObservationDataOutput.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/ObservationDataOutput.kt @@ -1,13 +1,13 @@ package fr.gouv.cnsp.monitorfish.infrastructure.api.outputs -import fr.gouv.cnsp.monitorfish.domain.entities.mission.ControlUnit +import fr.gouv.cnsp.monitorfish.domain.entities.mission.LegacyControlUnit import fr.gouv.cnsp.monitorfish.domain.entities.reporting.Observation import fr.gouv.cnsp.monitorfish.domain.entities.reporting.ReportingActor class ObservationDataOutput( val reportingActor: ReportingActor, val controlUnitId: Int? = null, - val controlUnit: ControlUnit? = null, + val legacyControlUnit: LegacyControlUnit? = null, val authorTrigram: String, val authorContact: String? = null, val title: String, @@ -16,12 +16,12 @@ class ObservationDataOutput( companion object { fun fromObservation( observation: Observation, - controlUnit: ControlUnit? = null, + legacyControlUnit: LegacyControlUnit? = null, ): ObservationDataOutput { return ObservationDataOutput( reportingActor = observation.reportingActor, controlUnitId = observation.controlUnitId, - controlUnit = controlUnit, + legacyControlUnit = legacyControlUnit, authorTrigram = observation.authorTrigram, authorContact = observation.authorContact, title = observation.title, diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/ReportingAndOccurrencesDataOutput.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/ReportingAndOccurrencesDataOutput.kt index 2f4723de9c..d1657ae9a2 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/ReportingAndOccurrencesDataOutput.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/ReportingAndOccurrencesDataOutput.kt @@ -13,12 +13,12 @@ data class ReportingAndOccurrencesDataOutput( return ReportingAndOccurrencesDataOutput( otherOccurrencesOfSameAlert = reportingAndOccurrences.otherOccurrencesOfSameAlert.map { reporting -> - ReportingDataOutput.fromReporting(reporting, reportingAndOccurrences.controlUnit) + ReportingDataOutput.fromReporting(reporting, reportingAndOccurrences.legacyControlUnit) }, reporting = ReportingDataOutput.fromReporting( reportingAndOccurrences.reporting, - reportingAndOccurrences.controlUnit, + reportingAndOccurrences.legacyControlUnit, ), ) } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/ReportingDataOutput.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/ReportingDataOutput.kt index 61563581e3..b58a422272 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/ReportingDataOutput.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/ReportingDataOutput.kt @@ -2,7 +2,7 @@ package fr.gouv.cnsp.monitorfish.infrastructure.api.outputs import com.neovisionaries.i18n.CountryCode import fr.gouv.cnsp.monitorfish.domain.entities.alerts.type.AlertType -import fr.gouv.cnsp.monitorfish.domain.entities.mission.ControlUnit +import fr.gouv.cnsp.monitorfish.domain.entities.mission.LegacyControlUnit import fr.gouv.cnsp.monitorfish.domain.entities.reporting.InfractionSuspicion import fr.gouv.cnsp.monitorfish.domain.entities.reporting.Observation import fr.gouv.cnsp.monitorfish.domain.entities.reporting.Reporting @@ -31,17 +31,17 @@ class ReportingDataOutput( companion object { fun fromReporting( reporting: Reporting, - controlUnit: ControlUnit?, + legacyControlUnit: LegacyControlUnit?, ): ReportingDataOutput { val value = when (reporting.value) { is InfractionSuspicion -> InfractionSuspicionDataOutput.fromInfractionSuspicion( reporting.value, - controlUnit, + legacyControlUnit, ) - is Observation -> ObservationDataOutput.fromObservation(reporting.value, controlUnit) + is Observation -> ObservationDataOutput.fromObservation(reporting.value, legacyControlUnit) is AlertType -> AlertDataOutput.fromAlertType(reporting.value) else -> throw IllegalArgumentException("Should not happen.") } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/APILegacyControlUnitRepository.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/APILegacyControlUnitRepository.kt index efe12a033c..c8e66cf4a7 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/APILegacyControlUnitRepository.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/APILegacyControlUnitRepository.kt @@ -2,7 +2,7 @@ package fr.gouv.cnsp.monitorfish.infrastructure.monitorenv import fr.gouv.cnsp.monitorfish.config.ApiClient import fr.gouv.cnsp.monitorfish.config.MonitorenvProperties -import fr.gouv.cnsp.monitorfish.domain.entities.mission.ControlUnit +import fr.gouv.cnsp.monitorfish.domain.entities.mission.LegacyControlUnit import fr.gouv.cnsp.monitorfish.domain.repositories.LegacyControlUnitRepository import io.ktor.client.call.* import io.ktor.client.request.* @@ -20,7 +20,7 @@ class APILegacyControlUnitRepository( private val logger: Logger = LoggerFactory.getLogger(APILegacyControlUnitRepository::class.java) @Cacheable(value = ["control_units"]) - override fun findAll(): List = + override fun findAll(): List = runBlocking { val missionsUrl = "${monitorenvProperties.url}/api/v1/control_units" diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/APIMissionRepository.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/APIMissionRepository.kt index 76c23b6e90..260d063b55 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/APIMissionRepository.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/APIMissionRepository.kt @@ -3,7 +3,7 @@ package fr.gouv.cnsp.monitorfish.infrastructure.monitorenv import com.github.benmanes.caffeine.cache.Caffeine import fr.gouv.cnsp.monitorfish.config.ApiClient import fr.gouv.cnsp.monitorfish.config.MonitorenvProperties -import fr.gouv.cnsp.monitorfish.domain.entities.mission.ControlUnit +import fr.gouv.cnsp.monitorfish.domain.entities.mission.LegacyControlUnit import fr.gouv.cnsp.monitorfish.domain.entities.mission.Mission import fr.gouv.cnsp.monitorfish.domain.exceptions.CouldNotFindException import fr.gouv.cnsp.monitorfish.domain.repositories.MissionRepository @@ -33,12 +33,12 @@ class APIMissionRepository( Caffeine.newBuilder() .maximumSize(500) .expireAfterWrite(1, TimeUnit.DAYS) - .build>() + .build>() override fun findControlUnitsOfMission( scope: CoroutineScope, missionId: Int, - ): Deferred> { + ): Deferred> { val cacheKey = "control_units_$missionId" val cachedControlUnits = cache.getIfPresent(cacheKey) @@ -48,7 +48,7 @@ class APIMissionRepository( val missionsUrl = "${monitorenvProperties.url}/api/v1/missions/$missionId" try { - val controlUnits = apiClient.httpClient.get(missionsUrl).body().controlUnits + val controlUnits = apiClient.httpClient.get(missionsUrl).body().legacyControlUnits cache.put(cacheKey, controlUnits) @@ -74,26 +74,32 @@ class APIMissionRepository( // For these parameters, if the list is null or empty, we don't send the param to the server to avoid filtering results val missionTypesParameter = if (!missionTypes.isNullOrEmpty()) { - "missionTypes=${missionTypes.joinToString( - ",", - )}&" + "missionTypes=${ + missionTypes.joinToString( + ",", + ) + }&" } else { "" } val missionStatusesParameter = if (!missionStatuses.isNullOrEmpty()) { - "missionStatus=${missionStatuses.joinToString( - ",", - )}&" + "missionStatus=${ + missionStatuses.joinToString( + ",", + ) + }&" } else { "" } val seaFrontsParameter = if (!seaFronts.isNullOrEmpty()) "seaFronts=${seaFronts.joinToString(",")}&" else "" val missionSourcesParameter = if (!missionSources.isNullOrEmpty()) { - "missionSource=${missionSources.joinToString( - ",", - )}&" + "missionSource=${ + missionSources.joinToString( + ",", + ) + }&" } else { "" } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/input/MissionDataResponse.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/input/MissionDataResponse.kt index 5a2baca1a7..1dcd3209a5 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/input/MissionDataResponse.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/input/MissionDataResponse.kt @@ -5,13 +5,13 @@ import kotlinx.serialization.Serializable import java.time.ZonedDateTime /** - @see monitorenv/backend/src/main/kotlin/fr/gouv/cacem/monitorenv/domain/entities/missions/MissionEntity.kt - for the full entity structure +@see monitorenv/backend/src/main/kotlin/fr/gouv/cacem/monitorenv/domain/entities/missions/MissionEntity.kt +for the full entity structure */ @Serializable data class MissionDataResponse( val id: Int, - val controlUnits: List = listOf(), + val legacyControlUnits: List = listOf(), val missionTypes: List, val openBy: String? = null, val completedBy: String? = null, @@ -32,7 +32,7 @@ data class MissionDataResponse( fun toMission() = Mission( id = id, - controlUnits = controlUnits, + legacyControlUnits = legacyControlUnits, missionTypes = missionTypes, openBy = openBy, completedBy = completedBy, diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/AddReportingUTests.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/AddReportingUTests.kt index 32d90b1925..3a8e9f5994 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/AddReportingUTests.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/AddReportingUTests.kt @@ -86,11 +86,11 @@ class AddReportingUTests { creationDate = ZonedDateTime.now(), validationDate = ZonedDateTime.now(), value = - Observation( - reportingActor = reportingActor, - authorTrigram = "LTH", - title = "A title", - ), + Observation( + reportingActor = reportingActor, + authorTrigram = "LTH", + title = "A title", + ), isArchived = false, isDeleted = false, ) @@ -145,12 +145,12 @@ class AddReportingUTests { creationDate = ZonedDateTime.now(), validationDate = ZonedDateTime.now(), value = - InfractionSuspicion( - reportingActor = ReportingActor.OPS, - natinfCode = 1235, - authorTrigram = "LTH", - title = "Chalut en boeuf illégal", - ), + InfractionSuspicion( + reportingActor = ReportingActor.OPS, + natinfCode = 1235, + authorTrigram = "LTH", + title = "Chalut en boeuf illégal", + ), isArchived = false, isDeleted = false, ) diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/GetAllCurrentReportingsUTests.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/GetAllCurrentReportingsUTests.kt index b02c86a2ba..3c1ce94a73 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/GetAllCurrentReportingsUTests.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/GetAllCurrentReportingsUTests.kt @@ -44,12 +44,12 @@ class GetAllCurrentReportingsUTests { flagState = CountryCode.FR, creationDate = ZonedDateTime.now(), value = - InfractionSuspicion( - ReportingActor.OPS, - natinfCode = 123456, - authorTrigram = "LTH", - title = "A title", - ), + InfractionSuspicion( + ReportingActor.OPS, + natinfCode = 123456, + authorTrigram = "LTH", + title = "A title", + ), type = ReportingType.INFRACTION_SUSPICION, isDeleted = false, isArchived = false, @@ -90,12 +90,12 @@ class GetAllCurrentReportingsUTests { flagState = CountryCode.FR, creationDate = ZonedDateTime.now(), value = - InfractionSuspicion( - ReportingActor.OPS, - natinfCode = 123456, - authorTrigram = "LTH", - title = "A title", - ), + InfractionSuspicion( + ReportingActor.OPS, + natinfCode = 123456, + authorTrigram = "LTH", + title = "A title", + ), type = ReportingType.INFRACTION_SUSPICION, isDeleted = false, isArchived = false, diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/UpdateReportingUTests.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/UpdateReportingUTests.kt index 19ab709264..660f732408 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/UpdateReportingUTests.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/UpdateReportingUTests.kt @@ -87,12 +87,12 @@ class UpdateReportingUTests { creationDate = ZonedDateTime.now(), validationDate = ZonedDateTime.now(), value = - InfractionSuspicion( - reportingActor = ReportingActor.UNIT, - authorTrigram = "LTH", - title = "Test", - natinfCode = 1234, - ) as ReportingValue, + InfractionSuspicion( + reportingActor = ReportingActor.UNIT, + authorTrigram = "LTH", + title = "Test", + natinfCode = 1234, + ) as ReportingValue, isArchived = false, isDeleted = false, ), @@ -138,12 +138,12 @@ class UpdateReportingUTests { creationDate = ZonedDateTime.now(), validationDate = ZonedDateTime.now(), value = - InfractionSuspicion( - reportingActor = ReportingActor.UNIT, - authorTrigram = "LTH", - title = "Test", - natinfCode = 1234, - ) as ReportingValue, + InfractionSuspicion( + reportingActor = ReportingActor.UNIT, + authorTrigram = "LTH", + title = "Test", + natinfCode = 1234, + ) as ReportingValue, isArchived = false, isDeleted = false, ) @@ -201,12 +201,12 @@ class UpdateReportingUTests { creationDate = ZonedDateTime.now(), validationDate = ZonedDateTime.now(), value = - InfractionSuspicion( - reportingActor = ReportingActor.UNIT, - authorTrigram = "LTH", - title = "Test", - natinfCode = 1234, - ) as ReportingValue, + InfractionSuspicion( + reportingActor = ReportingActor.UNIT, + authorTrigram = "LTH", + title = "Test", + natinfCode = 1234, + ) as ReportingValue, isArchived = false, isDeleted = false, ), @@ -306,12 +306,12 @@ class UpdateReportingUTests { creationDate = ZonedDateTime.now(), validationDate = ZonedDateTime.now(), value = - InfractionSuspicion( - reportingActor = ReportingActor.UNIT, - authorTrigram = "LTH", - title = "Test", - natinfCode = 1234, - ) as ReportingValue, + InfractionSuspicion( + reportingActor = ReportingActor.UNIT, + authorTrigram = "LTH", + title = "Test", + natinfCode = 1234, + ) as ReportingValue, isArchived = false, isDeleted = false, ) @@ -362,12 +362,12 @@ class UpdateReportingUTests { creationDate = ZonedDateTime.now(), validationDate = ZonedDateTime.now(), value = - InfractionSuspicion( - reportingActor = ReportingActor.UNIT, - title = "Test", - natinfCode = 1234, - authorTrigram = "LTH", - ) as ReportingValue, + InfractionSuspicion( + reportingActor = ReportingActor.UNIT, + title = "Test", + natinfCode = 1234, + authorTrigram = "LTH", + ) as ReportingValue, isArchived = false, isDeleted = false, ) @@ -427,11 +427,11 @@ class UpdateReportingUTests { creationDate = ZonedDateTime.now(), validationDate = ZonedDateTime.now(), value = - Observation( - reportingActor = ReportingActor.UNIT, - title = "Test", - authorTrigram = "LTH", - ) as ReportingValue, + Observation( + reportingActor = ReportingActor.UNIT, + title = "Test", + authorTrigram = "LTH", + ) as ReportingValue, isArchived = false, isDeleted = false, ) @@ -477,11 +477,11 @@ class UpdateReportingUTests { creationDate = ZonedDateTime.now(), validationDate = ZonedDateTime.now(), value = - Observation( - reportingActor = ReportingActor.UNIT, - title = "Test", - authorTrigram = "LTH", - ) as ReportingValue, + Observation( + reportingActor = ReportingActor.UNIT, + title = "Test", + authorTrigram = "LTH", + ) as ReportingValue, isArchived = false, isDeleted = false, ) diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/GetMissionUTests.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/GetMissionUTests.kt index e31f371eac..7337cf2bd8 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/GetMissionUTests.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/GetMissionUTests.kt @@ -35,7 +35,7 @@ class GetMissionUTests { given(missionRepository.findById(any())).willReturn( Mission( id = 123, - controlUnits = listOf(), + legacyControlUnits = listOf(), missionTypes = listOf(MissionType.SEA), startDateTimeUtc = ZonedDateTime.now(), isGeometryComputedFromControls = false, diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/TestUtils.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/TestUtils.kt index b66cce8974..4c18fea53b 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/TestUtils.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/TestUtils.kt @@ -16,7 +16,7 @@ object TestUtils { return ids.map { return@map Mission( id = it, - controlUnits = listOf(), + legacyControlUnits = listOf(), missionTypes = listOf(MissionType.SEA), startDateTimeUtc = ZonedDateTime.now(), isGeometryComputedFromControls = false, diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/mission_actions/GetActivityReportsUTests.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/mission_actions/GetActivityReportsUTests.kt index d66f12c97e..8d965ade99 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/mission_actions/GetActivityReportsUTests.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/mission_actions/GetActivityReportsUTests.kt @@ -4,7 +4,7 @@ import com.neovisionaries.i18n.CountryCode import com.nhaarman.mockitokotlin2.any import com.nhaarman.mockitokotlin2.eq import com.nhaarman.mockitokotlin2.given -import fr.gouv.cnsp.monitorfish.domain.entities.mission.ControlUnit +import fr.gouv.cnsp.monitorfish.domain.entities.mission.LegacyControlUnit import fr.gouv.cnsp.monitorfish.domain.entities.mission.Mission import fr.gouv.cnsp.monitorfish.domain.entities.mission.MissionSource import fr.gouv.cnsp.monitorfish.domain.entities.mission.MissionType @@ -904,7 +904,7 @@ class GetActivityReportsUTests { faoAreas = listOf("27.4.b", "27.4.c"), actionType = MissionActionType.SEA_CONTROL, gearOnboard = listOf(), - controlUnits = listOf(), + legacyControlUnits = listOf(), speciesOnboard = listOf(), seizureAndDiversion = true, isDeleted = false, @@ -940,7 +940,7 @@ class GetActivityReportsUTests { missionTypes = listOf(MissionType.SEA), missionSource = MissionSource.MONITORFISH, isUnderJdp = true, - controlUnits = listOf(ControlUnit(123, "AECP", false, "Unit AECP", listOf())), + legacyControlUnits = listOf(LegacyControlUnit(123, "AECP", false, "Unit AECP", listOf())), isGeometryComputedFromControls = false, startDateTimeUtc = ZonedDateTime.of(2020, 5, 5, 3, 4, 5, 3, ZoneOffset.UTC), ), diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/MissionActionsControllerITests.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/MissionActionsControllerITests.kt index a7399e48fe..07f050185c 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/MissionActionsControllerITests.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/MissionActionsControllerITests.kt @@ -4,7 +4,7 @@ import com.fasterxml.jackson.databind.ObjectMapper import com.neovisionaries.i18n.CountryCode import com.nhaarman.mockitokotlin2.* import fr.gouv.cnsp.monitorfish.config.SentryConfig -import fr.gouv.cnsp.monitorfish.domain.entities.mission.ControlUnit +import fr.gouv.cnsp.monitorfish.domain.entities.mission.LegacyControlUnit import fr.gouv.cnsp.monitorfish.domain.entities.mission.mission_actions.* import fr.gouv.cnsp.monitorfish.domain.entities.mission.mission_actions.actrep.ActivityCode import fr.gouv.cnsp.monitorfish.domain.entities.mission.mission_actions.actrep.JointDeploymentPlan @@ -374,7 +374,7 @@ class MissionActionsControllerITests { ), activityCode = ActivityCode.FIS, vesselNationalIdentifier = "AYFR000654", - controlUnits = listOf(ControlUnit(1234, "DIRM", false, "Cross Etel", listOf())), + legacyControlUnits = listOf(LegacyControlUnit(1234, "DIRM", false, "Cross Etel", listOf())), faoArea = "27.7.c", segment = "NS01/03", vessel = diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/ReportingControllerITests.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/ReportingControllerITests.kt index 6a6e181b1b..bffbda4979 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/ReportingControllerITests.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/ReportingControllerITests.kt @@ -7,7 +7,7 @@ import com.nhaarman.mockitokotlin2.eq import com.nhaarman.mockitokotlin2.given import fr.gouv.cnsp.monitorfish.config.MapperConfiguration import fr.gouv.cnsp.monitorfish.config.SentryConfig -import fr.gouv.cnsp.monitorfish.domain.entities.mission.ControlUnit +import fr.gouv.cnsp.monitorfish.domain.entities.mission.LegacyControlUnit import fr.gouv.cnsp.monitorfish.domain.entities.reporting.InfractionSuspicion import fr.gouv.cnsp.monitorfish.domain.entities.reporting.Reporting import fr.gouv.cnsp.monitorfish.domain.entities.reporting.ReportingActor @@ -193,7 +193,7 @@ class ReportingControllerITests { isArchived = false, ) given(addReporting.execute(any())).willReturn( - Pair(reporting, ControlUnit(1234, "DIRM", false, "Cross Etel", listOf())), + Pair(reporting, LegacyControlUnit(1234, "DIRM", false, "Cross Etel", listOf())), ) // When diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/VesselControllerITests.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/VesselControllerITests.kt index a90e6813ab..a4fb177cc1 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/VesselControllerITests.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/VesselControllerITests.kt @@ -759,12 +759,12 @@ class VesselControllerITests { ReportingAndOccurrences( otherOccurrencesOfSameAlert = listOf(), reporting = currentReporting, - controlUnit = null, + legacyControlUnit = null, ), ReportingAndOccurrences( otherOccurrencesOfSameAlert = listOf(), reporting = currentReporting, - controlUnit = null, + legacyControlUnit = null, ), ), archived = @@ -774,7 +774,7 @@ class VesselControllerITests { ReportingAndOccurrences( otherOccurrencesOfSameAlert = listOf(), reporting = archivedReporting, - controlUnit = null, + legacyControlUnit = null, ), ), 2023 to emptyList(), diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaMissionActionRepositoryITests.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaMissionActionRepositoryITests.kt index a41ec3622e..54e94a3dfd 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaMissionActionRepositoryITests.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaMissionActionRepositoryITests.kt @@ -126,7 +126,7 @@ class JpaMissionActionRepositoryITests : AbstractDBTests() { assertThat(firstControl.speciesOnboard.first().controlledWeight).isEqualTo(450.0) assertThat(firstControl.speciesOnboard.first().nbFish).isNull() assertThat(firstControl.speciesOnboard.first().underSized).isTrue - assertThat(firstControl.controlUnits).hasSize(0) + assertThat(firstControl.legacyControlUnits).hasSize(0) assertThat(firstControl.actionType).isEqualTo(MissionActionType.SEA_CONTROL) } @@ -211,7 +211,7 @@ class JpaMissionActionRepositoryITests : AbstractDBTests() { actionDatetimeUtc = ZonedDateTime.now(), actionType = MissionActionType.SEA_CONTROL, controlQualityComments = null, - controlUnits = listOf(), + legacyControlUnits = listOf(), districtCode = null, emitsAis = null, emitsVms = ControlCheck.NOT_APPLICABLE, From 43725230ef94dff61aef93dfe47170e9182a63b4 Mon Sep 17 00:00:00 2001 From: Ivan Gabriele Date: Wed, 23 Oct 2024 09:39:17 +0200 Subject: [PATCH 05/59] Move LegacyControlUnit entity to control_unit domain in Backend --- .../entities/{mission => control_unit}/LegacyControlUnit.kt | 3 ++- .../gouv/cnsp/monitorfish/domain/entities/mission/Mission.kt | 1 + .../domain/entities/mission/mission_actions/MissionAction.kt | 2 +- .../domain/entities/reporting/ReportingAndOccurrences.kt | 2 +- .../domain/repositories/LegacyControlUnitRepository.kt | 2 +- .../cnsp/monitorfish/domain/repositories/MissionRepository.kt | 2 +- .../domain/use_cases/control_units/GetAllLegacyControlUnits.kt | 2 +- .../use_cases/mission/mission_actions/dtos/ActivityReport.kt | 2 +- .../monitorfish/domain/use_cases/reporting/AddReporting.kt | 2 +- .../domain/use_cases/reporting/GetAllCurrentReportings.kt | 2 +- .../domain/use_cases/reporting/GetVesselReportings.kt | 2 +- .../monitorfish/domain/use_cases/reporting/UpdateReporting.kt | 2 +- .../infrastructure/api/outputs/ActivityReportDataOutput.kt | 2 +- .../api/outputs/InfractionSuspicionDataOutput.kt | 2 +- .../infrastructure/api/outputs/MissionActionDataOutput.kt | 2 +- .../infrastructure/api/outputs/MissionWithActionsDataOutput.kt | 1 + .../infrastructure/api/outputs/ObservationDataOutput.kt | 2 +- .../infrastructure/api/outputs/ReportingDataOutput.kt | 2 +- .../monitorenv/APILegacyControlUnitRepository.kt | 2 +- .../infrastructure/monitorenv/APIMissionRepository.kt | 2 +- .../infrastructure/monitorenv/input/MissionDataResponse.kt | 1 + .../mission/mission_actions/GetActivityReportsUTests.kt | 2 +- .../infrastructure/api/bff/MissionActionsControllerITests.kt | 2 +- .../infrastructure/api/bff/ReportingControllerITests.kt | 2 +- 24 files changed, 25 insertions(+), 21 deletions(-) rename backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/{mission => control_unit}/LegacyControlUnit.kt (66%) diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/mission/LegacyControlUnit.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/control_unit/LegacyControlUnit.kt similarity index 66% rename from backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/mission/LegacyControlUnit.kt rename to backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/control_unit/LegacyControlUnit.kt index 6b46c19840..c8098be22c 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/mission/LegacyControlUnit.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/control_unit/LegacyControlUnit.kt @@ -1,5 +1,6 @@ -package fr.gouv.cnsp.monitorfish.domain.entities.mission +package fr.gouv.cnsp.monitorfish.domain.entities.control_units +import fr.gouv.cnsp.monitorfish.domain.entities.mission.ControlResource import kotlinx.serialization.Serializable @Serializable diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/mission/Mission.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/mission/Mission.kt index ee31077b92..ea3e6e1d4b 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/mission/Mission.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/mission/Mission.kt @@ -1,5 +1,6 @@ package fr.gouv.cnsp.monitorfish.domain.entities.mission +import fr.gouv.cnsp.monitorfish.domain.entities.control_units.LegacyControlUnit import fr.gouv.cnsp.monitorfish.domain.entities.mission.env_mission_action.EnvMissionAction import java.time.ZonedDateTime diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/mission/mission_actions/MissionAction.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/mission/mission_actions/MissionAction.kt index e6f22bfbd1..1d333a22dc 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/mission/mission_actions/MissionAction.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/mission/mission_actions/MissionAction.kt @@ -2,7 +2,7 @@ package fr.gouv.cnsp.monitorfish.domain.entities.mission.mission_actions import com.neovisionaries.i18n.CountryCode import fr.gouv.cnsp.monitorfish.config.Patchable -import fr.gouv.cnsp.monitorfish.domain.entities.mission.LegacyControlUnit +import fr.gouv.cnsp.monitorfish.domain.entities.control_units.LegacyControlUnit import java.time.ZonedDateTime data class MissionAction( diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/reporting/ReportingAndOccurrences.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/reporting/ReportingAndOccurrences.kt index 7189843694..3a52401285 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/reporting/ReportingAndOccurrences.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/reporting/ReportingAndOccurrences.kt @@ -1,6 +1,6 @@ package fr.gouv.cnsp.monitorfish.domain.entities.reporting -import fr.gouv.cnsp.monitorfish.domain.entities.mission.LegacyControlUnit +import fr.gouv.cnsp.monitorfish.domain.entities.control_units.LegacyControlUnit data class ReportingAndOccurrences( val otherOccurrencesOfSameAlert: List, diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/repositories/LegacyControlUnitRepository.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/repositories/LegacyControlUnitRepository.kt index e826b704ef..7dd6c8f13c 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/repositories/LegacyControlUnitRepository.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/repositories/LegacyControlUnitRepository.kt @@ -1,6 +1,6 @@ package fr.gouv.cnsp.monitorfish.domain.repositories -import fr.gouv.cnsp.monitorfish.domain.entities.mission.LegacyControlUnit +import fr.gouv.cnsp.monitorfish.domain.entities.control_units.LegacyControlUnit interface LegacyControlUnitRepository { fun findAll(): List diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/repositories/MissionRepository.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/repositories/MissionRepository.kt index e14e99b6e2..06ae213bc3 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/repositories/MissionRepository.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/repositories/MissionRepository.kt @@ -1,6 +1,6 @@ package fr.gouv.cnsp.monitorfish.domain.repositories -import fr.gouv.cnsp.monitorfish.domain.entities.mission.LegacyControlUnit +import fr.gouv.cnsp.monitorfish.domain.entities.control_units.LegacyControlUnit import fr.gouv.cnsp.monitorfish.domain.entities.mission.Mission import fr.gouv.cnsp.monitorfish.domain.exceptions.CouldNotFindException import kotlinx.coroutines.CoroutineScope diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/control_units/GetAllLegacyControlUnits.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/control_units/GetAllLegacyControlUnits.kt index 6563869638..067dbd9773 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/control_units/GetAllLegacyControlUnits.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/control_units/GetAllLegacyControlUnits.kt @@ -1,7 +1,7 @@ package fr.gouv.cnsp.monitorfish.domain.use_cases.control_units import fr.gouv.cnsp.monitorfish.config.UseCase -import fr.gouv.cnsp.monitorfish.domain.entities.mission.LegacyControlUnit +import fr.gouv.cnsp.monitorfish.domain.entities.control_units.LegacyControlUnit import fr.gouv.cnsp.monitorfish.domain.repositories.LegacyControlUnitRepository @UseCase diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/mission_actions/dtos/ActivityReport.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/mission_actions/dtos/ActivityReport.kt index d2aec0cd67..1595733ef1 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/mission_actions/dtos/ActivityReport.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/mission_actions/dtos/ActivityReport.kt @@ -1,6 +1,6 @@ package fr.gouv.cnsp.monitorfish.domain.use_cases.mission.mission_actions.dtos -import fr.gouv.cnsp.monitorfish.domain.entities.mission.LegacyControlUnit +import fr.gouv.cnsp.monitorfish.domain.entities.control_units.LegacyControlUnit import fr.gouv.cnsp.monitorfish.domain.entities.mission.mission_actions.MissionAction import fr.gouv.cnsp.monitorfish.domain.entities.mission.mission_actions.actrep.ActivityCode import fr.gouv.cnsp.monitorfish.domain.entities.vessel.Vessel diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/reporting/AddReporting.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/reporting/AddReporting.kt index b98daf7d0f..ae35758512 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/reporting/AddReporting.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/reporting/AddReporting.kt @@ -1,7 +1,7 @@ package fr.gouv.cnsp.monitorfish.domain.use_cases.reporting import fr.gouv.cnsp.monitorfish.config.UseCase -import fr.gouv.cnsp.monitorfish.domain.entities.mission.LegacyControlUnit +import fr.gouv.cnsp.monitorfish.domain.entities.control_units.LegacyControlUnit import fr.gouv.cnsp.monitorfish.domain.entities.reporting.InfractionSuspicion import fr.gouv.cnsp.monitorfish.domain.entities.reporting.InfractionSuspicionOrObservationType import fr.gouv.cnsp.monitorfish.domain.entities.reporting.Reporting diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/reporting/GetAllCurrentReportings.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/reporting/GetAllCurrentReportings.kt index 471b6efd02..0dd0dce89d 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/reporting/GetAllCurrentReportings.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/reporting/GetAllCurrentReportings.kt @@ -1,7 +1,7 @@ package fr.gouv.cnsp.monitorfish.domain.use_cases.reporting import fr.gouv.cnsp.monitorfish.config.UseCase -import fr.gouv.cnsp.monitorfish.domain.entities.mission.LegacyControlUnit +import fr.gouv.cnsp.monitorfish.domain.entities.control_units.LegacyControlUnit import fr.gouv.cnsp.monitorfish.domain.entities.reporting.InfractionSuspicionOrObservationType import fr.gouv.cnsp.monitorfish.domain.entities.reporting.Reporting import fr.gouv.cnsp.monitorfish.domain.entities.reporting.ReportingType 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 bfbb7f70bd..243372b752 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 @@ -3,7 +3,7 @@ package fr.gouv.cnsp.monitorfish.domain.use_cases.reporting import fr.gouv.cnsp.monitorfish.config.UseCase import fr.gouv.cnsp.monitorfish.domain.entities.alerts.type.AlertType import fr.gouv.cnsp.monitorfish.domain.entities.alerts.type.AlertTypeMapping -import fr.gouv.cnsp.monitorfish.domain.entities.mission.LegacyControlUnit +import fr.gouv.cnsp.monitorfish.domain.entities.control_units.LegacyControlUnit import fr.gouv.cnsp.monitorfish.domain.entities.reporting.* import fr.gouv.cnsp.monitorfish.domain.entities.vessel.VesselIdentifier import fr.gouv.cnsp.monitorfish.domain.exceptions.NatinfCodeNotFoundException diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/reporting/UpdateReporting.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/reporting/UpdateReporting.kt index 056a9ffbae..24835b6db7 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/reporting/UpdateReporting.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/reporting/UpdateReporting.kt @@ -1,7 +1,7 @@ package fr.gouv.cnsp.monitorfish.domain.use_cases.reporting import fr.gouv.cnsp.monitorfish.config.UseCase -import fr.gouv.cnsp.monitorfish.domain.entities.mission.LegacyControlUnit +import fr.gouv.cnsp.monitorfish.domain.entities.control_units.LegacyControlUnit import fr.gouv.cnsp.monitorfish.domain.entities.reporting.* import fr.gouv.cnsp.monitorfish.domain.repositories.ReportingRepository import fr.gouv.cnsp.monitorfish.domain.use_cases.control_units.GetAllLegacyControlUnits diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/ActivityReportDataOutput.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/ActivityReportDataOutput.kt index 17046e5f0a..e9e32646a7 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/ActivityReportDataOutput.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/ActivityReportDataOutput.kt @@ -1,6 +1,6 @@ package fr.gouv.cnsp.monitorfish.infrastructure.api.outputs -import fr.gouv.cnsp.monitorfish.domain.entities.mission.LegacyControlUnit +import fr.gouv.cnsp.monitorfish.domain.entities.control_units.LegacyControlUnit import fr.gouv.cnsp.monitorfish.domain.entities.mission.mission_actions.actrep.ActivityCode import fr.gouv.cnsp.monitorfish.domain.use_cases.mission.mission_actions.dtos.ActivityReport diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/InfractionSuspicionDataOutput.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/InfractionSuspicionDataOutput.kt index e532659eaa..b0f0c1f2a4 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/InfractionSuspicionDataOutput.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/InfractionSuspicionDataOutput.kt @@ -1,6 +1,6 @@ package fr.gouv.cnsp.monitorfish.infrastructure.api.outputs -import fr.gouv.cnsp.monitorfish.domain.entities.mission.LegacyControlUnit +import fr.gouv.cnsp.monitorfish.domain.entities.control_units.LegacyControlUnit import fr.gouv.cnsp.monitorfish.domain.entities.reporting.InfractionSuspicion import fr.gouv.cnsp.monitorfish.domain.entities.reporting.ReportingActor diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/MissionActionDataOutput.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/MissionActionDataOutput.kt index 3de0ace72c..832339c5f9 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/MissionActionDataOutput.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/MissionActionDataOutput.kt @@ -1,7 +1,7 @@ package fr.gouv.cnsp.monitorfish.infrastructure.api.outputs import com.neovisionaries.i18n.CountryCode -import fr.gouv.cnsp.monitorfish.domain.entities.mission.LegacyControlUnit +import fr.gouv.cnsp.monitorfish.domain.entities.control_units.LegacyControlUnit import fr.gouv.cnsp.monitorfish.domain.entities.mission.mission_actions.* import fr.gouv.cnsp.monitorfish.domain.entities.mission.mission_actions.Completion import java.time.ZonedDateTime diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/MissionWithActionsDataOutput.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/MissionWithActionsDataOutput.kt index fc4b4cfa5a..8d783acd58 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/MissionWithActionsDataOutput.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/MissionWithActionsDataOutput.kt @@ -1,5 +1,6 @@ package fr.gouv.cnsp.monitorfish.infrastructure.api.outputs +import fr.gouv.cnsp.monitorfish.domain.entities.control_units.LegacyControlUnit import fr.gouv.cnsp.monitorfish.domain.entities.mission.* import java.time.ZonedDateTime diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/ObservationDataOutput.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/ObservationDataOutput.kt index 242f4de3aa..8471cb273f 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/ObservationDataOutput.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/ObservationDataOutput.kt @@ -1,6 +1,6 @@ package fr.gouv.cnsp.monitorfish.infrastructure.api.outputs -import fr.gouv.cnsp.monitorfish.domain.entities.mission.LegacyControlUnit +import fr.gouv.cnsp.monitorfish.domain.entities.control_units.LegacyControlUnit import fr.gouv.cnsp.monitorfish.domain.entities.reporting.Observation import fr.gouv.cnsp.monitorfish.domain.entities.reporting.ReportingActor diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/ReportingDataOutput.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/ReportingDataOutput.kt index b58a422272..156ed9ec48 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/ReportingDataOutput.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/ReportingDataOutput.kt @@ -2,7 +2,7 @@ package fr.gouv.cnsp.monitorfish.infrastructure.api.outputs import com.neovisionaries.i18n.CountryCode import fr.gouv.cnsp.monitorfish.domain.entities.alerts.type.AlertType -import fr.gouv.cnsp.monitorfish.domain.entities.mission.LegacyControlUnit +import fr.gouv.cnsp.monitorfish.domain.entities.control_units.LegacyControlUnit import fr.gouv.cnsp.monitorfish.domain.entities.reporting.InfractionSuspicion import fr.gouv.cnsp.monitorfish.domain.entities.reporting.Observation import fr.gouv.cnsp.monitorfish.domain.entities.reporting.Reporting diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/APILegacyControlUnitRepository.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/APILegacyControlUnitRepository.kt index c8e66cf4a7..6a9c48cfbc 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/APILegacyControlUnitRepository.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/APILegacyControlUnitRepository.kt @@ -2,7 +2,7 @@ package fr.gouv.cnsp.monitorfish.infrastructure.monitorenv import fr.gouv.cnsp.monitorfish.config.ApiClient import fr.gouv.cnsp.monitorfish.config.MonitorenvProperties -import fr.gouv.cnsp.monitorfish.domain.entities.mission.LegacyControlUnit +import fr.gouv.cnsp.monitorfish.domain.entities.control_units.LegacyControlUnit import fr.gouv.cnsp.monitorfish.domain.repositories.LegacyControlUnitRepository import io.ktor.client.call.* import io.ktor.client.request.* diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/APIMissionRepository.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/APIMissionRepository.kt index 260d063b55..2f516e9666 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/APIMissionRepository.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/APIMissionRepository.kt @@ -3,7 +3,7 @@ package fr.gouv.cnsp.monitorfish.infrastructure.monitorenv import com.github.benmanes.caffeine.cache.Caffeine import fr.gouv.cnsp.monitorfish.config.ApiClient import fr.gouv.cnsp.monitorfish.config.MonitorenvProperties -import fr.gouv.cnsp.monitorfish.domain.entities.mission.LegacyControlUnit +import fr.gouv.cnsp.monitorfish.domain.entities.control_units.LegacyControlUnit import fr.gouv.cnsp.monitorfish.domain.entities.mission.Mission import fr.gouv.cnsp.monitorfish.domain.exceptions.CouldNotFindException import fr.gouv.cnsp.monitorfish.domain.repositories.MissionRepository diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/input/MissionDataResponse.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/input/MissionDataResponse.kt index 1dcd3209a5..4e6363e9c1 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/input/MissionDataResponse.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/input/MissionDataResponse.kt @@ -1,5 +1,6 @@ package fr.gouv.cnsp.monitorfish.infrastructure.monitorenv.input +import fr.gouv.cnsp.monitorfish.domain.entities.control_units.LegacyControlUnit import fr.gouv.cnsp.monitorfish.domain.entities.mission.* import kotlinx.serialization.Serializable import java.time.ZonedDateTime diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/mission_actions/GetActivityReportsUTests.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/mission_actions/GetActivityReportsUTests.kt index 8d965ade99..52193f5422 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/mission_actions/GetActivityReportsUTests.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/mission_actions/GetActivityReportsUTests.kt @@ -4,7 +4,7 @@ import com.neovisionaries.i18n.CountryCode import com.nhaarman.mockitokotlin2.any import com.nhaarman.mockitokotlin2.eq import com.nhaarman.mockitokotlin2.given -import fr.gouv.cnsp.monitorfish.domain.entities.mission.LegacyControlUnit +import fr.gouv.cnsp.monitorfish.domain.entities.control_units.LegacyControlUnit import fr.gouv.cnsp.monitorfish.domain.entities.mission.Mission import fr.gouv.cnsp.monitorfish.domain.entities.mission.MissionSource import fr.gouv.cnsp.monitorfish.domain.entities.mission.MissionType diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/MissionActionsControllerITests.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/MissionActionsControllerITests.kt index 07f050185c..888c154767 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/MissionActionsControllerITests.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/MissionActionsControllerITests.kt @@ -4,7 +4,7 @@ import com.fasterxml.jackson.databind.ObjectMapper import com.neovisionaries.i18n.CountryCode import com.nhaarman.mockitokotlin2.* import fr.gouv.cnsp.monitorfish.config.SentryConfig -import fr.gouv.cnsp.monitorfish.domain.entities.mission.LegacyControlUnit +import fr.gouv.cnsp.monitorfish.domain.entities.control_units.LegacyControlUnit import fr.gouv.cnsp.monitorfish.domain.entities.mission.mission_actions.* import fr.gouv.cnsp.monitorfish.domain.entities.mission.mission_actions.actrep.ActivityCode import fr.gouv.cnsp.monitorfish.domain.entities.mission.mission_actions.actrep.JointDeploymentPlan diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/ReportingControllerITests.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/ReportingControllerITests.kt index bffbda4979..3d68a1d99c 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/ReportingControllerITests.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/ReportingControllerITests.kt @@ -7,7 +7,7 @@ import com.nhaarman.mockitokotlin2.eq import com.nhaarman.mockitokotlin2.given import fr.gouv.cnsp.monitorfish.config.MapperConfiguration import fr.gouv.cnsp.monitorfish.config.SentryConfig -import fr.gouv.cnsp.monitorfish.domain.entities.mission.LegacyControlUnit +import fr.gouv.cnsp.monitorfish.domain.entities.control_units.LegacyControlUnit import fr.gouv.cnsp.monitorfish.domain.entities.reporting.InfractionSuspicion import fr.gouv.cnsp.monitorfish.domain.entities.reporting.Reporting import fr.gouv.cnsp.monitorfish.domain.entities.reporting.ReportingActor From 63934473ee4038008747fe44a73db471fa0ce194 Mon Sep 17 00:00:00 2001 From: Ivan Gabriele Date: Wed, 23 Oct 2024 09:40:58 +0200 Subject: [PATCH 06/59] Add GetPriorNotificationSubscriber use case in Backend --- .../PriorNotificationPortSubscription.kt | 7 ++++ .../PriorNotificationSegmentSubscription.kt | 6 ++++ .../PriorNotificationVesselSubscription.kt | 6 ++++ .../PnoPortSubscriptionRepository.kt | 4 +++ .../PnoSegmentSubscriptionRepository.kt | 4 +++ .../PnoVesselSubscriptionRepository.kt | 4 +++ .../GetPriorNotificationSubscriber.kt | 33 +++++++++++++++++++ .../dtos/PriorNotificationSubscriber.kt | 13 ++++++++ .../entities/PnoPortSubscriptionEntity.kt | 11 ++++++- .../entities/PnoSegmentSubscriptionEntity.kt | 10 +++++- .../entities/PnoVesselSubscriptionEntity.kt | 10 +++++- .../JpaPnoPortSubscriptionRepository.kt | 6 ++++ .../JpaPnoSegmentSubscriptionRepository.kt | 6 ++++ .../JpaPnoVesselSubscriptionRepository.kt | 6 ++++ .../DBPnoPortsSubscriptionsRepository.kt | 10 ++++++ .../DBPnoSegmentsSubscriptionsRepository.kt | 10 ++++++ .../DBPnoVesselsSubscriptionsRepository.kt | 10 ++++++ 17 files changed, 153 insertions(+), 3 deletions(-) create mode 100644 backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/prior_notification/PriorNotificationPortSubscription.kt create mode 100644 backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/prior_notification/PriorNotificationSegmentSubscription.kt create mode 100644 backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/prior_notification/PriorNotificationVesselSubscription.kt create mode 100644 backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationSubscriber.kt create mode 100644 backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/dtos/PriorNotificationSubscriber.kt diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/prior_notification/PriorNotificationPortSubscription.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/prior_notification/PriorNotificationPortSubscription.kt new file mode 100644 index 0000000000..ae5c9694db --- /dev/null +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/prior_notification/PriorNotificationPortSubscription.kt @@ -0,0 +1,7 @@ +package fr.gouv.cnsp.monitorfish.domain.entities.prior_notification + +data class PriorNotificationPortSubscription( + val controlUnitId: Int, + val portLocode: String, + val hasSubscribedToAllPriorNotifications: Boolean, +) diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/prior_notification/PriorNotificationSegmentSubscription.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/prior_notification/PriorNotificationSegmentSubscription.kt new file mode 100644 index 0000000000..465157cd9d --- /dev/null +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/prior_notification/PriorNotificationSegmentSubscription.kt @@ -0,0 +1,6 @@ +package fr.gouv.cnsp.monitorfish.domain.entities.prior_notification + +data class PriorNotificationSegmentSubscription( + val controlUnitId: Int, + val segmentCode: String, +) diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/prior_notification/PriorNotificationVesselSubscription.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/prior_notification/PriorNotificationVesselSubscription.kt new file mode 100644 index 0000000000..8c84901c1c --- /dev/null +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/prior_notification/PriorNotificationVesselSubscription.kt @@ -0,0 +1,6 @@ +package fr.gouv.cnsp.monitorfish.domain.entities.prior_notification + +data class PriorNotificationVesselSubscription( + val controlUnitId: Int, + val vesselId: Int, +) diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/repositories/PnoPortSubscriptionRepository.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/repositories/PnoPortSubscriptionRepository.kt index 17d8f0f9a6..665a4ad6ad 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/repositories/PnoPortSubscriptionRepository.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/repositories/PnoPortSubscriptionRepository.kt @@ -1,5 +1,9 @@ package fr.gouv.cnsp.monitorfish.domain.repositories +import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotificationPortSubscription + interface PnoPortSubscriptionRepository { + fun findByControlUnitId(controlUnitId: Int): List + fun has(portLocode: String): Boolean } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/repositories/PnoSegmentSubscriptionRepository.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/repositories/PnoSegmentSubscriptionRepository.kt index 32b0f522d6..76e5e8b2f9 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/repositories/PnoSegmentSubscriptionRepository.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/repositories/PnoSegmentSubscriptionRepository.kt @@ -1,6 +1,10 @@ package fr.gouv.cnsp.monitorfish.domain.repositories +import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotificationSegmentSubscription + interface PnoSegmentSubscriptionRepository { + fun findByControlUnitId(controlUnitId: Int): List + fun has( portLocode: String, segmentCodes: List, diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/repositories/PnoVesselSubscriptionRepository.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/repositories/PnoVesselSubscriptionRepository.kt index 7e07a00130..72a7ab5a0b 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/repositories/PnoVesselSubscriptionRepository.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/repositories/PnoVesselSubscriptionRepository.kt @@ -1,5 +1,9 @@ package fr.gouv.cnsp.monitorfish.domain.repositories +import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotificationVesselSubscription + interface PnoVesselSubscriptionRepository { + fun findByControlUnitId(controlUnitId: Int): List + fun has(vesselId: Int): Boolean } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationSubscriber.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationSubscriber.kt new file mode 100644 index 0000000000..34c1bcbf1c --- /dev/null +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationSubscriber.kt @@ -0,0 +1,33 @@ +package fr.gouv.cnsp.monitorfish.domain.use_cases.prior_notification + +import fr.gouv.cnsp.monitorfish.config.UseCase +import fr.gouv.cnsp.monitorfish.domain.exceptions.BackendUsageErrorCode +import fr.gouv.cnsp.monitorfish.domain.exceptions.BackendUsageException +import fr.gouv.cnsp.monitorfish.domain.repositories.* +import fr.gouv.cnsp.monitorfish.domain.use_cases.prior_notification.dtos.PriorNotificationSubscriber + +@UseCase +class GetPriorNotificationSubscriber( + private val legacyControlUnitRepository: LegacyControlUnitRepository, + private val pnoPortSubscriptionRepository: PnoPortSubscriptionRepository, + private val pnoSegmentSubscriptionRepository: PnoSegmentSubscriptionRepository, + private val pnoVesselSubscriptionRepository: PnoVesselSubscriptionRepository, +) { + fun execute(id: Int): PriorNotificationSubscriber { + val controlUnit = legacyControlUnitRepository.findAll().find { it.id == id } + if (controlUnit == null) { + throw BackendUsageException(BackendUsageErrorCode.NOT_FOUND) + } + + val portSubscriptions = pnoPortSubscriptionRepository.findByControlUnitId(id) + val segmentSubscriptions = pnoSegmentSubscriptionRepository.findByControlUnitId(id) + val vesselSubscriptions = pnoVesselSubscriptionRepository.findByControlUnitId(id) + + return PriorNotificationSubscriber( + legacyControlUnit = controlUnit, + portSubscriptions = portSubscriptions, + segmentSubscriptions = segmentSubscriptions, + vesselSubscriptions = vesselSubscriptions, + ) + } +} diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/dtos/PriorNotificationSubscriber.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/dtos/PriorNotificationSubscriber.kt new file mode 100644 index 0000000000..6864bb0339 --- /dev/null +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/dtos/PriorNotificationSubscriber.kt @@ -0,0 +1,13 @@ +package fr.gouv.cnsp.monitorfish.domain.use_cases.prior_notification.dtos + +import fr.gouv.cnsp.monitorfish.domain.entities.control_units.LegacyControlUnit +import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotificationPortSubscription +import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotificationSegmentSubscription +import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotificationVesselSubscription + +data class PriorNotificationSubscriber( + val legacyControlUnit: LegacyControlUnit, + val portSubscriptions: List, + val segmentSubscriptions: List, + val vesselSubscriptions: List, +) diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/PnoPortSubscriptionEntity.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/PnoPortSubscriptionEntity.kt index 6e33716127..e4cadbe50e 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/PnoPortSubscriptionEntity.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/PnoPortSubscriptionEntity.kt @@ -1,5 +1,6 @@ package fr.gouv.cnsp.monitorfish.infrastructure.database.entities +import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotificationPortSubscription import jakarta.persistence.* import java.io.Serializable @@ -13,4 +14,12 @@ data class PnoPortSubscriptionEntity( val id: PnoPortSubscriptionId, @Column(name = "receive_all_pnos", updatable = false) val receiveAllPnos: Boolean, -) +) { + fun toPriorNotificationPortSubscription(): PriorNotificationPortSubscription { + return PriorNotificationPortSubscription( + controlUnitId = id.controlUnitId, + portLocode = id.portLocode, + hasSubscribedToAllPriorNotifications = receiveAllPnos, + ) + } +} diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/PnoSegmentSubscriptionEntity.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/PnoSegmentSubscriptionEntity.kt index 2b2ba260b1..279c25f1e4 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/PnoSegmentSubscriptionEntity.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/PnoSegmentSubscriptionEntity.kt @@ -1,5 +1,6 @@ package fr.gouv.cnsp.monitorfish.infrastructure.database.entities +import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotificationSegmentSubscription import jakarta.persistence.* import java.io.Serializable @@ -15,4 +16,11 @@ class PnoSegmentSubscriptionId( data class PnoSegmentSubscriptionEntity( @EmbeddedId val id: PnoSegmentSubscriptionId, -) +) { + fun toPriorNotificationSegmentSubscription(): PriorNotificationSegmentSubscription { + return PriorNotificationSegmentSubscription( + controlUnitId = id.controlUnitId, + segmentCode = id.segmentCode, + ) + } +} diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/PnoVesselSubscriptionEntity.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/PnoVesselSubscriptionEntity.kt index c6df870d19..0fee785093 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/PnoVesselSubscriptionEntity.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/PnoVesselSubscriptionEntity.kt @@ -1,5 +1,6 @@ package fr.gouv.cnsp.monitorfish.infrastructure.database.entities +import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotificationVesselSubscription import jakarta.persistence.Embeddable import jakarta.persistence.EmbeddedId import jakarta.persistence.Entity @@ -14,4 +15,11 @@ class PnoVesselSubscriptionId(val controlUnitId: Int, val vesselId: Int) : Seria data class PnoVesselSubscriptionEntity( @EmbeddedId val id: PnoVesselSubscriptionId, -) +) { + fun toPriorNotificationVesselSubscription(): PriorNotificationVesselSubscription { + return PriorNotificationVesselSubscription( + controlUnitId = id.controlUnitId, + vesselId = id.vesselId, + ) + } +} diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPnoPortSubscriptionRepository.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPnoPortSubscriptionRepository.kt index bdf5fd6da1..6f3986c077 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPnoPortSubscriptionRepository.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPnoPortSubscriptionRepository.kt @@ -1,5 +1,6 @@ package fr.gouv.cnsp.monitorfish.infrastructure.database.repositories +import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotificationPortSubscription import fr.gouv.cnsp.monitorfish.domain.repositories.PnoPortSubscriptionRepository import fr.gouv.cnsp.monitorfish.infrastructure.database.repositories.interfaces.DBPnoPortsSubscriptionsRepository import org.springframework.stereotype.Repository @@ -8,6 +9,11 @@ import org.springframework.stereotype.Repository class JpaPnoPortSubscriptionRepository( private val dbPnoPortsSubscriptionsRepository: DBPnoPortsSubscriptionsRepository, ) : PnoPortSubscriptionRepository { + override fun findByControlUnitId(controlUnitId: Int): List { + return dbPnoPortsSubscriptionsRepository.findByControlUnitId(controlUnitId) + .map { it.toPriorNotificationPortSubscription() } + } + override fun has(portLocode: String): Boolean { return dbPnoPortsSubscriptionsRepository.countByPortLocode(portLocode) > 0 } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPnoSegmentSubscriptionRepository.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPnoSegmentSubscriptionRepository.kt index 5e92c76e6c..6b67fd18ca 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPnoSegmentSubscriptionRepository.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPnoSegmentSubscriptionRepository.kt @@ -1,5 +1,6 @@ package fr.gouv.cnsp.monitorfish.infrastructure.database.repositories +import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotificationSegmentSubscription import fr.gouv.cnsp.monitorfish.domain.repositories.PnoSegmentSubscriptionRepository import fr.gouv.cnsp.monitorfish.infrastructure.database.repositories.interfaces.DBPnoSegmentsSubscriptionsRepository import org.springframework.stereotype.Repository @@ -8,6 +9,11 @@ import org.springframework.stereotype.Repository class JpaPnoSegmentSubscriptionRepository( private val dbPnoSegmentsSubscriptionsRepository: DBPnoSegmentsSubscriptionsRepository, ) : PnoSegmentSubscriptionRepository { + override fun findByControlUnitId(controlUnitId: Int): List { + return dbPnoSegmentsSubscriptionsRepository.findByControlUnitId(controlUnitId) + .map { it.toPriorNotificationSegmentSubscription() } + } + override fun has( portLocode: String, segmentCodes: List, diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPnoVesselSubscriptionRepository.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPnoVesselSubscriptionRepository.kt index ac322b90dd..48a870b0bd 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPnoVesselSubscriptionRepository.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPnoVesselSubscriptionRepository.kt @@ -1,5 +1,6 @@ package fr.gouv.cnsp.monitorfish.infrastructure.database.repositories +import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotificationVesselSubscription import fr.gouv.cnsp.monitorfish.domain.repositories.PnoVesselSubscriptionRepository import fr.gouv.cnsp.monitorfish.infrastructure.database.repositories.interfaces.DBPnoVesselsSubscriptionsRepository import org.springframework.stereotype.Repository @@ -8,6 +9,11 @@ import org.springframework.stereotype.Repository class JpaPnoVesselSubscriptionRepository( private val dbPnoVesselsSubscriptionsRepository: DBPnoVesselsSubscriptionsRepository, ) : PnoVesselSubscriptionRepository { + override fun findByControlUnitId(controlUnitId: Int): List { + return dbPnoVesselsSubscriptionsRepository.findByControlUnitId(controlUnitId) + .map { it.toPriorNotificationVesselSubscription() } + } + override fun has(vesselId: Int): Boolean { return dbPnoVesselsSubscriptionsRepository.countByVesselId(vesselId) > 0 } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/interfaces/DBPnoPortsSubscriptionsRepository.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/interfaces/DBPnoPortsSubscriptionsRepository.kt index f0a0b006f4..0498f0d1ee 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/interfaces/DBPnoPortsSubscriptionsRepository.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/interfaces/DBPnoPortsSubscriptionsRepository.kt @@ -11,4 +11,14 @@ interface DBPnoPortsSubscriptionsRepository : JpaRepository } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/interfaces/DBPnoSegmentsSubscriptionsRepository.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/interfaces/DBPnoSegmentsSubscriptionsRepository.kt index b5b6bf369f..a4d6dd4904 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/interfaces/DBPnoSegmentsSubscriptionsRepository.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/interfaces/DBPnoSegmentsSubscriptionsRepository.kt @@ -19,4 +19,14 @@ interface DBPnoSegmentsSubscriptionsRepository : JpaRepository, ): Long + + @Query( + """ + SELECT * + FROM pno_segments_subscriptions + WHERE control_unit_id = :controlUnitId + """, + nativeQuery = true, + ) + fun findByControlUnitId(controlUnitId: Int): List } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/interfaces/DBPnoVesselsSubscriptionsRepository.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/interfaces/DBPnoVesselsSubscriptionsRepository.kt index 10550d4af9..7d164dde4f 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/interfaces/DBPnoVesselsSubscriptionsRepository.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/interfaces/DBPnoVesselsSubscriptionsRepository.kt @@ -8,4 +8,14 @@ import org.springframework.data.jpa.repository.Query interface DBPnoVesselsSubscriptionsRepository : JpaRepository { @Query("SELECT COUNT(*) FROM pno_vessels_subscriptions WHERE vessel_id = :vesselId", nativeQuery = true) fun countByVesselId(vesselId: Int): Long + + @Query( + """ + SELECT * + FROM pno_vessels_subscriptions + WHERE control_unit_id = :controlUnitId + """, + nativeQuery = true, + ) + fun findByControlUnitId(controlUnitId: Int): List } From 2ab08bc7c79b0725e6e2eaab6fd5d777ed710fb3 Mon Sep 17 00:00:00 2001 From: Ivan Gabriele Date: Wed, 23 Oct 2024 09:48:34 +0200 Subject: [PATCH 07/59] Rollback wrong controlUnit prop renaming in Backend entities --- .../domain/entities/mission/Mission.kt | 2 +- .../mission/mission_actions/MissionAction.kt | 2 +- .../reporting/ReportingAndOccurrences.kt | 2 +- .../mission_actions/GetActivityReports.kt | 4 +- .../mission_actions/GetVesselControls.kt | 2 +- .../mission_actions/dtos/ActivityReport.kt | 2 +- .../reporting/GetVesselReportings.kt | 6 +- .../api/outputs/ActivityReportDataOutput.kt | 2 +- .../api/outputs/MissionActionDataOutput.kt | 2 +- .../outputs/MissionWithActionsDataOutput.kt | 6 +- .../ReportingAndOccurrencesDataOutput.kt | 14 +- .../monitorenv/input/MissionDataResponse.kt | 2 +- .../use_cases/mission/GetMissionUTests.kt | 14 +- .../domain/use_cases/mission/TestUtils.kt | 2 +- .../GetActivityReportsUTests.kt | 64 ++-- .../api/bff/MissionActionsControllerITests.kt | 134 +++---- .../api/bff/VesselControllerITests.kt | 338 +++++++++--------- .../JpaMissionActionRepositoryITests.kt | 4 +- 18 files changed, 301 insertions(+), 301 deletions(-) diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/mission/Mission.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/mission/Mission.kt index ea3e6e1d4b..1c529b1cbe 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/mission/Mission.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/mission/Mission.kt @@ -26,5 +26,5 @@ data class Mission( val missionSource: MissionSource, val hasMissionOrder: Boolean? = false, val isUnderJdp: Boolean? = false, - val legacyControlUnits: List = listOf(), + val controlUnits: List = listOf(), ) diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/mission/mission_actions/MissionAction.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/mission/mission_actions/MissionAction.kt index 1d333a22dc..d9cc55dd06 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/mission/mission_actions/MissionAction.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/mission/mission_actions/MissionAction.kt @@ -58,7 +58,7 @@ data class MissionAction( * This field is only used by the `GetVesselControls` use-case. * /!\ Do not use it to get `controlUnits` as the field will be empty be default. */ - var legacyControlUnits: List = listOf(), + var controlUnits: List = listOf(), val isDeleted: Boolean, val hasSomeGearsSeized: Boolean, val hasSomeSpeciesSeized: Boolean, diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/reporting/ReportingAndOccurrences.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/reporting/ReportingAndOccurrences.kt index 3a52401285..71a7eb3a8c 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/reporting/ReportingAndOccurrences.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/reporting/ReportingAndOccurrences.kt @@ -5,5 +5,5 @@ import fr.gouv.cnsp.monitorfish.domain.entities.control_units.LegacyControlUnit data class ReportingAndOccurrences( val otherOccurrencesOfSameAlert: List, val reporting: Reporting, - val legacyControlUnit: LegacyControlUnit?, + val controlUnit: LegacyControlUnit?, ) diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/mission_actions/GetActivityReports.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/mission_actions/GetActivityReports.kt index 2a228c06c0..aa941e6740 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/mission_actions/GetActivityReports.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/mission_actions/GetActivityReports.kt @@ -75,7 +75,7 @@ class GetActivityReports( val controlMission = missions.firstOrNull { mission -> mission.id == control.missionId } // All AECP reports are excluded from the response // see: https://github.com/MTES-MCT/monitorfish/issues/3194 - return@filter controlMission?.legacyControlUnits?.any { controlUnit -> + return@filter controlMission?.controlUnits?.any { controlUnit -> controlUnit.administration == "AECP" } != true } @@ -122,7 +122,7 @@ class GetActivityReports( ActivityReport( action = control, activityCode = activityCode, - legacyControlUnits = controlMission.legacyControlUnits, + controlUnits = controlMission.controlUnits, faoArea = faoArea?.faoCode, /** * The fleet segment is set as null, as we need to integrate the EFCA segments referential diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/mission_actions/GetVesselControls.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/mission_actions/GetVesselControls.kt index 167d4dc506..3668760adf 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/mission_actions/GetVesselControls.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/mission_actions/GetVesselControls.kt @@ -45,7 +45,7 @@ class GetVesselControls( Pair(action, controlUnits) }.map { (control, controlUnits) -> - control.legacyControlUnits = controlUnits.await() + control.controlUnits = controlUnits.await() control.portLocode?.let { port -> try { diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/mission_actions/dtos/ActivityReport.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/mission_actions/dtos/ActivityReport.kt index 1595733ef1..6af99732e7 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/mission_actions/dtos/ActivityReport.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/mission_actions/dtos/ActivityReport.kt @@ -12,6 +12,6 @@ data class ActivityReport( val activityCode: ActivityCode, // The `districtCode` and `internalReferenceNumber` concatenation val vesselNationalIdentifier: String, - val legacyControlUnits: List, + val controlUnits: List, val vessel: Vessel, ) 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 243372b752..9e95c501c9 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 @@ -180,7 +180,7 @@ class GetVesselReportings( val controlUnitId = (updatedReporting.value as? InfractionSuspicionOrObservationType)?.controlUnitId val foundControlUnit = legacyControlUnits.find { it.id == controlUnitId } - return updatedReportingAndOccurrences.copy(legacyControlUnit = foundControlUnit) + return updatedReportingAndOccurrences.copy(controlUnit = foundControlUnit) } private fun getReportingsAndOccurrences(reportings: List): List { @@ -191,7 +191,7 @@ class GetVesselReportings( ReportingAndOccurrences( otherOccurrencesOfSameAlert = emptyList(), reporting = reporting, - legacyControlUnit = null, + controlUnit = null, ) } @@ -226,7 +226,7 @@ class GetVesselReportings( ReportingAndOccurrences( otherOccurrencesOfSameAlert = otherOccurrencesOfSameAlert, reporting = lastAlert, - legacyControlUnit = null, + controlUnit = null, ), ) } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/ActivityReportDataOutput.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/ActivityReportDataOutput.kt index e9e32646a7..6225dd842c 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/ActivityReportDataOutput.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/ActivityReportDataOutput.kt @@ -21,7 +21,7 @@ data class ActivityReportDataOutput( faoArea = activityReport.faoArea, segment = activityReport.segment, vesselNationalIdentifier = activityReport.vesselNationalIdentifier, - legacyControlUnits = activityReport.legacyControlUnits, + legacyControlUnits = activityReport.controlUnits, vessel = VesselDataOutput.fromVessel(activityReport.vessel), ) } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/MissionActionDataOutput.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/MissionActionDataOutput.kt index 832339c5f9..5c35053f7b 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/MissionActionDataOutput.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/MissionActionDataOutput.kt @@ -109,7 +109,7 @@ data class MissionActionDataOutput( otherComments = missionAction.otherComments, gearOnboard = missionAction.gearOnboard, speciesOnboard = missionAction.speciesOnboard, - legacyControlUnits = missionAction.legacyControlUnits, + legacyControlUnits = missionAction.controlUnits, userTrigram = missionAction.userTrigram, vesselTargeted = missionAction.vesselTargeted, hasSomeGearsSeized = missionAction.hasSomeGearsSeized, diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/MissionWithActionsDataOutput.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/MissionWithActionsDataOutput.kt index 8d783acd58..41bc1a84f3 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/MissionWithActionsDataOutput.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/MissionWithActionsDataOutput.kt @@ -43,15 +43,15 @@ data class MissionWithActionsDataOutput( createdAtUtc = missionAndActions.mission.createdAtUtc, updatedAtUtc = missionAndActions.mission.updatedAtUtc, envActions = - missionAndActions.mission.envActions - ?.map { EnvMissionActionDataOutput.fromEnvMissionAction(it) } ?: listOf(), + missionAndActions.mission.envActions + ?.map { EnvMissionActionDataOutput.fromEnvMissionAction(it) } ?: listOf(), startDateTimeUtc = missionAndActions.mission.startDateTimeUtc, endDateTimeUtc = missionAndActions.mission.endDateTimeUtc, isGeometryComputedFromControls = missionAndActions.mission.isGeometryComputedFromControls, missionSource = missionAndActions.mission.missionSource, hasMissionOrder = missionAndActions.mission.hasMissionOrder, isUnderJdp = missionAndActions.mission.isUnderJdp, - legacyControlUnits = missionAndActions.mission.legacyControlUnits, + legacyControlUnits = missionAndActions.mission.controlUnits, actions = missionAndActions.actions.map { MissionActionDataOutput.fromMissionAction(it) }, ) } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/ReportingAndOccurrencesDataOutput.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/ReportingAndOccurrencesDataOutput.kt index d1657ae9a2..9315bc00f9 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/ReportingAndOccurrencesDataOutput.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/ReportingAndOccurrencesDataOutput.kt @@ -12,14 +12,14 @@ data class ReportingAndOccurrencesDataOutput( ): ReportingAndOccurrencesDataOutput { return ReportingAndOccurrencesDataOutput( otherOccurrencesOfSameAlert = - reportingAndOccurrences.otherOccurrencesOfSameAlert.map { reporting -> - ReportingDataOutput.fromReporting(reporting, reportingAndOccurrences.legacyControlUnit) - }, + reportingAndOccurrences.otherOccurrencesOfSameAlert.map { reporting -> + ReportingDataOutput.fromReporting(reporting, reportingAndOccurrences.controlUnit) + }, reporting = - ReportingDataOutput.fromReporting( - reportingAndOccurrences.reporting, - reportingAndOccurrences.legacyControlUnit, - ), + ReportingDataOutput.fromReporting( + reportingAndOccurrences.reporting, + reportingAndOccurrences.controlUnit, + ), ) } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/input/MissionDataResponse.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/input/MissionDataResponse.kt index 4e6363e9c1..e1a5bae2de 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/input/MissionDataResponse.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/input/MissionDataResponse.kt @@ -33,7 +33,7 @@ data class MissionDataResponse( fun toMission() = Mission( id = id, - legacyControlUnits = legacyControlUnits, + controlUnits = legacyControlUnits, missionTypes = missionTypes, openBy = openBy, completedBy = completedBy, diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/GetMissionUTests.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/GetMissionUTests.kt index 7337cf2bd8..4408a08000 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/GetMissionUTests.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/GetMissionUTests.kt @@ -35,19 +35,19 @@ class GetMissionUTests { given(missionRepository.findById(any())).willReturn( Mission( id = 123, - legacyControlUnits = listOf(), + controlUnits = listOf(), missionTypes = listOf(MissionType.SEA), startDateTimeUtc = ZonedDateTime.now(), isGeometryComputedFromControls = false, missionSource = MissionSource.MONITORFISH, envActions = - listOf( - EnvMissionAction( - id = UUID.randomUUID(), - actionStartDateTimeUtc = ZonedDateTime.now(), - actionType = EnvMissionActionType.CONTROL, - ), + listOf( + EnvMissionAction( + id = UUID.randomUUID(), + actionStartDateTimeUtc = ZonedDateTime.now(), + actionType = EnvMissionActionType.CONTROL, ), + ), ), ) given(getMissionActions.execute(any())).willReturn(getDummyMissionActions(listOf(1, 2))) diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/TestUtils.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/TestUtils.kt index 4c18fea53b..b66cce8974 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/TestUtils.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/TestUtils.kt @@ -16,7 +16,7 @@ object TestUtils { return ids.map { return@map Mission( id = it, - legacyControlUnits = listOf(), + controlUnits = listOf(), missionTypes = listOf(MissionType.SEA), startDateTimeUtc = ZonedDateTime.now(), isGeometryComputedFromControls = false, diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/mission_actions/GetActivityReportsUTests.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/mission_actions/GetActivityReportsUTests.kt index 52193f5422..38dc76786d 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/mission_actions/GetActivityReportsUTests.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/mission_actions/GetActivityReportsUTests.kt @@ -61,10 +61,10 @@ class GetActivityReportsUTests { portLocode = "AEFAT", faoAreas = listOf("27.7.b", "27.4.c"), segments = - listOf( - FleetSegment("NWW01/02", "Trawl"), - FleetSegment("NS01/03", "North sea"), - ), + listOf( + FleetSegment("NWW01/02", "Trawl"), + FleetSegment("NS01/03", "North sea"), + ), actionType = MissionActionType.LAND_CONTROL, gearOnboard = listOf(), speciesOnboard = listOf(species), @@ -212,10 +212,10 @@ class GetActivityReportsUTests { portLocode = "AEFAT", faoAreas = listOf("27.7.b", "27.4.c"), segments = - listOf( - FleetSegment("NWW01/02", "Trawl"), - FleetSegment("NS01/03", "North sea"), - ), + listOf( + FleetSegment("NWW01/02", "Trawl"), + FleetSegment("NS01/03", "North sea"), + ), actionType = MissionActionType.LAND_CONTROL, gearOnboard = listOf(), speciesOnboard = listOf(species), @@ -368,25 +368,25 @@ class GetActivityReportsUTests { "NS01/03", "Otter trawls/Seines", gears = - listOf( - "OTB", - "OTT", - "TBN", - "PTB", - "SDN", - "SSC", - "SPR", - "OT", - "TBS", - "OTM", - "PTM", - "TMS", - "TM", - "TX", - "TB", - "SX", - "SV", - ), + listOf( + "OTB", + "OTT", + "TBN", + "PTB", + "SDN", + "SSC", + "SPR", + "OT", + "TBS", + "OTM", + "PTM", + "TMS", + "TM", + "TX", + "TB", + "SX", + "SV", + ), targetSpecies = listOf("COD", "HAD", "WHG", "POK", "SOL", "PLE", "NEP", "HKE"), faoAreas = listOf("27.2.a", "27.4.a", "27.4.b", "27.4.c"), year = ZonedDateTime.now().year, @@ -405,9 +405,9 @@ class GetActivityReportsUTests { portLocode = "AEFAT", faoAreas = listOf("27.4.a"), segments = - listOf( - FleetSegment("NS01/03", "North Sea"), - ), + listOf( + FleetSegment("NS01/03", "North Sea"), + ), actionType = MissionActionType.LAND_CONTROL, gearOnboard = listOf(), speciesOnboard = listOf(species), @@ -904,7 +904,7 @@ class GetActivityReportsUTests { faoAreas = listOf("27.4.b", "27.4.c"), actionType = MissionActionType.SEA_CONTROL, gearOnboard = listOf(), - legacyControlUnits = listOf(), + controlUnits = listOf(), speciesOnboard = listOf(), seizureAndDiversion = true, isDeleted = false, @@ -940,7 +940,7 @@ class GetActivityReportsUTests { missionTypes = listOf(MissionType.SEA), missionSource = MissionSource.MONITORFISH, isUnderJdp = true, - legacyControlUnits = listOf(LegacyControlUnit(123, "AECP", false, "Unit AECP", listOf())), + controlUnits = listOf(LegacyControlUnit(123, "AECP", false, "Unit AECP", listOf())), isGeometryComputedFromControls = false, startDateTimeUtc = ZonedDateTime.of(2020, 5, 5, 3, 4, 5, 3, ZoneOffset.UTC), ), diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/MissionActionsControllerITests.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/MissionActionsControllerITests.kt index 888c154767..0c37c7c6f4 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/MissionActionsControllerITests.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/MissionActionsControllerITests.kt @@ -158,29 +158,29 @@ class MissionActionsControllerITests { vesselId = 2, actionType = MissionActionType.SEA_CONTROL, logbookInfractions = - listOf( - LogbookInfraction( - InfractionType.WITH_RECORD, - 27689, - "Poids à bord MNZ supérieur de 50% au poids déclaré", - ), + listOf( + LogbookInfraction( + InfractionType.WITH_RECORD, + 27689, + "Poids à bord MNZ supérieur de 50% au poids déclaré", ), + ), faoAreas = listOf("25.6.9", "25.7.9"), segments = - listOf( - FleetSegment( - segment = "WWSS10", - segmentName = "World Wide Segment", - ), + listOf( + FleetSegment( + segment = "WWSS10", + segmentName = "World Wide Segment", ), + ), gearInfractions = - listOf( - GearInfraction( - InfractionType.WITH_RECORD, - 27689, - "Maille trop petite", - ), + listOf( + GearInfraction( + InfractionType.WITH_RECORD, + 27689, + "Maille trop petite", ), + ), hasSomeGearsSeized = false, hasSomeSpeciesSeized = false, isAdministrativeControl = true, @@ -242,29 +242,29 @@ class MissionActionsControllerITests { vesselId = 2, actionType = MissionActionType.SEA_CONTROL, logbookInfractions = - listOf( - LogbookInfraction( - InfractionType.WITH_RECORD, - 27689, - "Poids à bord MNZ supérieur de 50% au poids déclaré", - ), + listOf( + LogbookInfraction( + InfractionType.WITH_RECORD, + 27689, + "Poids à bord MNZ supérieur de 50% au poids déclaré", ), + ), faoAreas = listOf("25.6.9", "25.7.9"), segments = - listOf( - FleetSegment( - segment = "WWSS10", - segmentName = "World Wide Segment", - ), + listOf( + FleetSegment( + segment = "WWSS10", + segmentName = "World Wide Segment", ), + ), gearInfractions = - listOf( - GearInfraction( - InfractionType.WITH_RECORD, - 27689, - "Maille trop petite", - ), + listOf( + GearInfraction( + InfractionType.WITH_RECORD, + 27689, + "Maille trop petite", ), + ), gearOnboard = listOf(gearControl), hasSomeGearsSeized = false, hasSomeSpeciesSeized = false, @@ -355,41 +355,41 @@ class MissionActionsControllerITests { given(getActivityReports.execute(any(), any(), any())).willReturn( ActivityReports( activityReports = - listOf( - ActivityReport( - action = - MissionAction( - 1, - 1, - 1, - actionType = MissionActionType.SEA_CONTROL, - actionDatetimeUtc = ZonedDateTime.now(), - isDeleted = false, - hasSomeGearsSeized = false, - hasSomeSpeciesSeized = false, - isFromPoseidon = true, - flagState = CountryCode.FR, - userTrigram = "LTH", - completion = Completion.TO_COMPLETE, - ), - activityCode = ActivityCode.FIS, - vesselNationalIdentifier = "AYFR000654", - legacyControlUnits = listOf(LegacyControlUnit(1234, "DIRM", false, "Cross Etel", listOf())), - faoArea = "27.7.c", - segment = "NS01/03", - vessel = - Vessel( - id = 1, - internalReferenceNumber = "FR00022680", - vesselName = "MY AWESOME VESSEL", - flagState = CountryCode.FR, - declaredFishingGears = listOf("Trémails"), - vesselType = "Fishing", - districtCode = "AY", - hasLogbookEsacapt = false, - ), + listOf( + ActivityReport( + action = + MissionAction( + 1, + 1, + 1, + actionType = MissionActionType.SEA_CONTROL, + actionDatetimeUtc = ZonedDateTime.now(), + isDeleted = false, + hasSomeGearsSeized = false, + hasSomeSpeciesSeized = false, + isFromPoseidon = true, + flagState = CountryCode.FR, + userTrigram = "LTH", + completion = Completion.TO_COMPLETE, + ), + activityCode = ActivityCode.FIS, + vesselNationalIdentifier = "AYFR000654", + controlUnits = listOf(LegacyControlUnit(1234, "DIRM", false, "Cross Etel", listOf())), + faoArea = "27.7.c", + segment = "NS01/03", + vessel = + Vessel( + id = 1, + internalReferenceNumber = "FR00022680", + vesselName = "MY AWESOME VESSEL", + flagState = CountryCode.FR, + declaredFishingGears = listOf("Trémails"), + vesselType = "Fishing", + districtCode = "AY", + hasLogbookEsacapt = false, ), ), + ), jdpSpecies = listOf("BSS", "MAK", "LTH"), ), ) diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/VesselControllerITests.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/VesselControllerITests.kt index a4fb177cc1..80c34f0966 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/VesselControllerITests.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/VesselControllerITests.kt @@ -111,9 +111,9 @@ class VesselControllerITests { course = 180.0, dateTime = farPastFixedDateTime, vesselIdentifier = VesselIdentifier.INTERNAL_REFERENCE_NUMBER, gearOnboard = - listOf( - gear, - ), + listOf( + gear, + ), ) given(this.getLastPositions.execute()).willReturn(listOf(position)) @@ -167,9 +167,9 @@ class VesselControllerITests { speed = 1.8, course = 180.0, dateTime = - now.minusHours( - 4, - ), + now.minusHours( + 4, + ), ) val secondPosition = Position( @@ -188,9 +188,9 @@ class VesselControllerITests { speed = 1.8, course = 180.0, dateTime = - now.minusHours( - 3, - ), + now.minusHours( + 3, + ), ) val thirdPosition = Position( @@ -209,9 +209,9 @@ class VesselControllerITests { speed = 1.8, course = 180.0, dateTime = - now.minusHours( - 2, - ), + now.minusHours( + 2, + ), ) givenSuspended { getVessel.execute(eq(123), any(), any(), any(), any(), any(), eq(null), eq(null)) @@ -220,16 +220,16 @@ class VesselControllerITests { false, VesselInformation( vessel = - Vessel( - id = 123, - internalReferenceNumber = "FR224226850", - vesselName = "MY AWESOME VESSEL", - flagState = CountryCode.FR, - declaredFishingGears = listOf("Trémails"), - vesselType = "Fishing", - underCharter = true, - hasLogbookEsacapt = false, - ), + Vessel( + id = 123, + internalReferenceNumber = "FR224226850", + vesselName = "MY AWESOME VESSEL", + flagState = CountryCode.FR, + declaredFishingGears = listOf("Trémails"), + vesselType = "Fishing", + underCharter = true, + hasLogbookEsacapt = false, + ), beacon = null, positions = listOf(firstPosition, secondPosition, thirdPosition), vesselRiskFactor = VesselRiskFactor(2.3, 2.0, 1.9, 3.2), @@ -356,9 +356,9 @@ class VesselControllerITests { speed = 1.8, course = 180.0, dateTime = - now.minusHours( - 4, - ), + now.minusHours( + 4, + ), ) val secondPosition = Position( @@ -377,9 +377,9 @@ class VesselControllerITests { speed = 1.8, course = 180.0, dateTime = - now.minusHours( - 3, - ), + now.minusHours( + 3, + ), ) val thirdPosition = Position( @@ -398,9 +398,9 @@ class VesselControllerITests { speed = 1.8, course = 180.0, dateTime = - now.minusHours( - 2, - ), + now.minusHours( + 2, + ), ) givenSuspended { getVesselPositions.execute(any(), any(), any(), any(), any(), eq(null), eq(null)) @@ -438,28 +438,28 @@ class VesselControllerITests { listOf( VesselAndBeacon( vessel = - Vessel( - id = 1, - internalReferenceNumber = "FR224226850", - vesselName = "MY AWESOME VESSEL", - flagState = CountryCode.FR, - declaredFishingGears = listOf("Trémails"), - vesselType = "Fishing", - hasLogbookEsacapt = false, - ), + Vessel( + id = 1, + internalReferenceNumber = "FR224226850", + vesselName = "MY AWESOME VESSEL", + flagState = CountryCode.FR, + declaredFishingGears = listOf("Trémails"), + vesselType = "Fishing", + hasLogbookEsacapt = false, + ), beacon = Beacon(beaconNumber = "123456", vesselId = 1), ), VesselAndBeacon( vessel = - Vessel( - id = 2, - internalReferenceNumber = "GBR21555445", - vesselName = "ANOTHER VESSEL", - flagState = CountryCode.GB, - declaredFishingGears = listOf("Trémails"), - vesselType = "Fishing", - hasLogbookEsacapt = false, - ), + Vessel( + id = 2, + internalReferenceNumber = "GBR21555445", + vesselName = "ANOTHER VESSEL", + flagState = CountryCode.GB, + declaredFishingGears = listOf("Trémails"), + vesselType = "Fishing", + hasLogbookEsacapt = false, + ), beacon = null, ), ), @@ -569,88 +569,88 @@ class VesselControllerITests { VesselBeaconMalfunctionsResumeAndHistory( resume = VesselBeaconMalfunctionsResume(1, 2, null, null), history = - listOf( - BeaconMalfunctionWithDetails( - beaconMalfunction = - BeaconMalfunction( - id = 1, - internalReferenceNumber = "FR224226850", - externalReferenceNumber = "1236514", - ircs = "IRCS", - flagState = "fr", - vesselIdentifier = VesselIdentifier.INTERNAL_REFERENCE_NUMBER, - vesselName = "BIDUBULE", - vesselStatus = VesselStatus.AT_SEA, - stage = Stage.ARCHIVED, - malfunctionStartDateTime = ZonedDateTime.now(), - malfunctionEndDateTime = null, - vesselStatusLastModificationDateTime = ZonedDateTime.now(), - endOfBeaconMalfunctionReason = EndOfBeaconMalfunctionReason.RESUMED_TRANSMISSION, - beaconNumber = "123465", - beaconStatusAtMalfunctionCreation = BeaconStatus.ACTIVATED, - vesselId = 123, - ), - comments = - listOf( - BeaconMalfunctionComment( - beaconMalfunctionId = 1, - comment = "A comment", - userType = BeaconMalfunctionCommentUserType.SIP, - dateTime = now, - ), - ), - actions = - listOf( - BeaconMalfunctionAction( - beaconMalfunctionId = 1, - propertyName = BeaconMalfunctionActionPropertyName.VESSEL_STATUS, - nextValue = "A VALUE", - previousValue = "A VALUE", - dateTime = now, - ), - ), - ), - ), - current = + listOf( BeaconMalfunctionWithDetails( beaconMalfunction = - BeaconMalfunction( - id = 2, - internalReferenceNumber = "FR224226850", - externalReferenceNumber = "1236514", - ircs = "IRCS", - flagState = "fr", - vesselIdentifier = VesselIdentifier.INTERNAL_REFERENCE_NUMBER, - vesselName = "BIDUBULE", - vesselStatus = VesselStatus.AT_SEA, - stage = Stage.INITIAL_ENCOUNTER, - malfunctionStartDateTime = ZonedDateTime.now(), - malfunctionEndDateTime = null, - vesselStatusLastModificationDateTime = ZonedDateTime.now(), - beaconNumber = "123465", - beaconStatusAtMalfunctionCreation = BeaconStatus.ACTIVATED, - vesselId = 123, - ), + BeaconMalfunction( + id = 1, + internalReferenceNumber = "FR224226850", + externalReferenceNumber = "1236514", + ircs = "IRCS", + flagState = "fr", + vesselIdentifier = VesselIdentifier.INTERNAL_REFERENCE_NUMBER, + vesselName = "BIDUBULE", + vesselStatus = VesselStatus.AT_SEA, + stage = Stage.ARCHIVED, + malfunctionStartDateTime = ZonedDateTime.now(), + malfunctionEndDateTime = null, + vesselStatusLastModificationDateTime = ZonedDateTime.now(), + endOfBeaconMalfunctionReason = EndOfBeaconMalfunctionReason.RESUMED_TRANSMISSION, + beaconNumber = "123465", + beaconStatusAtMalfunctionCreation = BeaconStatus.ACTIVATED, + vesselId = 123, + ), comments = - listOf( - BeaconMalfunctionComment( - beaconMalfunctionId = 1, - comment = "A comment", - userType = BeaconMalfunctionCommentUserType.SIP, - dateTime = now, - ), + listOf( + BeaconMalfunctionComment( + beaconMalfunctionId = 1, + comment = "A comment", + userType = BeaconMalfunctionCommentUserType.SIP, + dateTime = now, ), + ), actions = - listOf( - BeaconMalfunctionAction( - beaconMalfunctionId = 1, - propertyName = BeaconMalfunctionActionPropertyName.VESSEL_STATUS, - nextValue = "A VALUE", - previousValue = "A VALUE", - dateTime = now, - ), + listOf( + BeaconMalfunctionAction( + beaconMalfunctionId = 1, + propertyName = BeaconMalfunctionActionPropertyName.VESSEL_STATUS, + nextValue = "A VALUE", + previousValue = "A VALUE", + dateTime = now, ), + ), + ), + ), + current = + BeaconMalfunctionWithDetails( + beaconMalfunction = + BeaconMalfunction( + id = 2, + internalReferenceNumber = "FR224226850", + externalReferenceNumber = "1236514", + ircs = "IRCS", + flagState = "fr", + vesselIdentifier = VesselIdentifier.INTERNAL_REFERENCE_NUMBER, + vesselName = "BIDUBULE", + vesselStatus = VesselStatus.AT_SEA, + stage = Stage.INITIAL_ENCOUNTER, + malfunctionStartDateTime = ZonedDateTime.now(), + malfunctionEndDateTime = null, + vesselStatusLastModificationDateTime = ZonedDateTime.now(), + beaconNumber = "123465", + beaconStatusAtMalfunctionCreation = BeaconStatus.ACTIVATED, + vesselId = 123, ), + comments = + listOf( + BeaconMalfunctionComment( + beaconMalfunctionId = 1, + comment = "A comment", + userType = BeaconMalfunctionCommentUserType.SIP, + dateTime = now, + ), + ), + actions = + listOf( + BeaconMalfunctionAction( + beaconMalfunctionId = 1, + propertyName = BeaconMalfunctionActionPropertyName.VESSEL_STATUS, + nextValue = "A VALUE", + previousValue = "A VALUE", + dateTime = now, + ), + ), + ), ), ) @@ -703,10 +703,10 @@ class VesselControllerITests { isArchived = false, isDeleted = false, infraction = - Infraction( - natinfCode = 7059, - infractionCategory = InfractionCategory.FISHING, - ), + Infraction( + natinfCode = 7059, + infractionCategory = InfractionCategory.FISHING, + ), ) val archivedReporting = @@ -739,48 +739,48 @@ class VesselControllerITests { .willReturn( VesselReportings( summary = - ReportingSummary( - infractionSuspicionsSummary = - listOf( - ReportingTitleAndNumberOfOccurrences( - title = "A title", - numberOfOccurrences = 2, - ), - ReportingTitleAndNumberOfOccurrences( - title = "A title", - numberOfOccurrences = 2, - ), - ), - numberOfInfractionSuspicions = 4, - numberOfObservations = 5, - ), - current = + ReportingSummary( + infractionSuspicionsSummary = listOf( - ReportingAndOccurrences( - otherOccurrencesOfSameAlert = listOf(), - reporting = currentReporting, - legacyControlUnit = null, + ReportingTitleAndNumberOfOccurrences( + title = "A title", + numberOfOccurrences = 2, ), - ReportingAndOccurrences( - otherOccurrencesOfSameAlert = listOf(), - reporting = currentReporting, - legacyControlUnit = null, + ReportingTitleAndNumberOfOccurrences( + title = "A title", + numberOfOccurrences = 2, ), ), + numberOfInfractionSuspicions = 4, + numberOfObservations = 5, + ), + current = + listOf( + ReportingAndOccurrences( + otherOccurrencesOfSameAlert = listOf(), + reporting = currentReporting, + controlUnit = null, + ), + ReportingAndOccurrences( + otherOccurrencesOfSameAlert = listOf(), + reporting = currentReporting, + controlUnit = null, + ), + ), archived = - mapOf( - 2024 to - listOf( - ReportingAndOccurrences( - otherOccurrencesOfSameAlert = listOf(), - reporting = archivedReporting, - legacyControlUnit = null, - ), + mapOf( + 2024 to + listOf( + ReportingAndOccurrences( + otherOccurrencesOfSameAlert = listOf(), + reporting = archivedReporting, + controlUnit = null, ), - 2023 to emptyList(), - 2022 to emptyList(), - 2021 to emptyList(), - ), + ), + 2023 to emptyList(), + 2022 to emptyList(), + 2021 to emptyList(), + ), ), ) @@ -830,11 +830,11 @@ class VesselControllerITests { .willReturn( VesselReportings( summary = - ReportingSummary( - infractionSuspicionsSummary = listOf(), - numberOfInfractionSuspicions = 0, - numberOfObservations = 0, - ), + ReportingSummary( + infractionSuspicionsSummary = listOf(), + numberOfInfractionSuspicions = 0, + numberOfObservations = 0, + ), current = listOf(), archived = mapOf(), ), diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaMissionActionRepositoryITests.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaMissionActionRepositoryITests.kt index 54e94a3dfd..a41ec3622e 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaMissionActionRepositoryITests.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaMissionActionRepositoryITests.kt @@ -126,7 +126,7 @@ class JpaMissionActionRepositoryITests : AbstractDBTests() { assertThat(firstControl.speciesOnboard.first().controlledWeight).isEqualTo(450.0) assertThat(firstControl.speciesOnboard.first().nbFish).isNull() assertThat(firstControl.speciesOnboard.first().underSized).isTrue - assertThat(firstControl.legacyControlUnits).hasSize(0) + assertThat(firstControl.controlUnits).hasSize(0) assertThat(firstControl.actionType).isEqualTo(MissionActionType.SEA_CONTROL) } @@ -211,7 +211,7 @@ class JpaMissionActionRepositoryITests : AbstractDBTests() { actionDatetimeUtc = ZonedDateTime.now(), actionType = MissionActionType.SEA_CONTROL, controlQualityComments = null, - legacyControlUnits = listOf(), + controlUnits = listOf(), districtCode = null, emitsAis = null, emitsVms = ControlCheck.NOT_APPLICABLE, From 5d3cce0096c07f6014e8f516f09d6bde3d624f81 Mon Sep 17 00:00:00 2001 From: Ivan Gabriele Date: Wed, 23 Oct 2024 09:55:14 +0200 Subject: [PATCH 08/59] Rollback controlUnit props renaming in Backend --- .../control_units/GetAllLegacyControlUnits.kt | 4 +- .../GetPriorNotificationSubscriber.kt | 6 +- .../dtos/PriorNotificationSubscriber.kt | 2 +- .../reporting/GetVesselReportings.kt | 4 +- .../use_cases/reporting/UpdateReporting.kt | 4 +- .../api/outputs/ActivityReportDataOutput.kt | 4 +- .../outputs/InfractionSuspicionDataOutput.kt | 6 +- .../api/outputs/MissionActionDataOutput.kt | 4 +- .../outputs/MissionWithActionsDataOutput.kt | 8 +- .../api/outputs/ObservationDataOutput.kt | 6 +- .../ReportingAndOccurrencesDataOutput.kt | 14 +- .../api/outputs/ReportingDataOutput.kt | 6 +- .../monitorenv/APIMissionRepository.kt | 2 +- .../monitorenv/input/MissionDataResponse.kt | 4 +- .../use_cases/mission/GetMissionUTests.kt | 12 +- .../GetActivityReportsUTests.kt | 60 ++-- .../api/bff/MissionActionsControllerITests.kt | 134 +++---- .../api/bff/VesselControllerITests.kt | 338 +++++++++--------- 18 files changed, 309 insertions(+), 309 deletions(-) diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/control_units/GetAllLegacyControlUnits.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/control_units/GetAllLegacyControlUnits.kt index 067dbd9773..ac0fe49089 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/control_units/GetAllLegacyControlUnits.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/control_units/GetAllLegacyControlUnits.kt @@ -6,9 +6,9 @@ import fr.gouv.cnsp.monitorfish.domain.repositories.LegacyControlUnitRepository @UseCase class GetAllLegacyControlUnits( - private val legacyControlUnitsRepository: LegacyControlUnitRepository, + private val controlUnitsRepository: LegacyControlUnitRepository, ) { fun execute(): List { - return legacyControlUnitsRepository.findAll() + return controlUnitsRepository.findAll() } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationSubscriber.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationSubscriber.kt index 34c1bcbf1c..2b13221b17 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationSubscriber.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationSubscriber.kt @@ -8,13 +8,13 @@ import fr.gouv.cnsp.monitorfish.domain.use_cases.prior_notification.dtos.PriorNo @UseCase class GetPriorNotificationSubscriber( - private val legacyControlUnitRepository: LegacyControlUnitRepository, + private val controlUnitRepository: LegacyControlUnitRepository, private val pnoPortSubscriptionRepository: PnoPortSubscriptionRepository, private val pnoSegmentSubscriptionRepository: PnoSegmentSubscriptionRepository, private val pnoVesselSubscriptionRepository: PnoVesselSubscriptionRepository, ) { fun execute(id: Int): PriorNotificationSubscriber { - val controlUnit = legacyControlUnitRepository.findAll().find { it.id == id } + val controlUnit = controlUnitRepository.findAll().find { it.id == id } if (controlUnit == null) { throw BackendUsageException(BackendUsageErrorCode.NOT_FOUND) } @@ -24,7 +24,7 @@ class GetPriorNotificationSubscriber( val vesselSubscriptions = pnoVesselSubscriptionRepository.findByControlUnitId(id) return PriorNotificationSubscriber( - legacyControlUnit = controlUnit, + controlUnit = controlUnit, portSubscriptions = portSubscriptions, segmentSubscriptions = segmentSubscriptions, vesselSubscriptions = vesselSubscriptions, diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/dtos/PriorNotificationSubscriber.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/dtos/PriorNotificationSubscriber.kt index 6864bb0339..839af3bd68 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/dtos/PriorNotificationSubscriber.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/dtos/PriorNotificationSubscriber.kt @@ -6,7 +6,7 @@ import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotifica import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotificationVesselSubscription data class PriorNotificationSubscriber( - val legacyControlUnit: LegacyControlUnit, + val controlUnit: LegacyControlUnit, val portSubscriptions: List, val segmentSubscriptions: List, val vesselSubscriptions: List, 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 9e95c501c9..7f61b0670f 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 @@ -152,7 +152,7 @@ class GetVesselReportings( private fun enrichWithInfractionAndControlUnit( reportingAndOccurrences: ReportingAndOccurrences, - legacyControlUnits: List, + controlUnits: List, ): ReportingAndOccurrences { val updatedInfraction = reportingAndOccurrences.reporting.value.natinfCode?.let { natinfCode -> @@ -178,7 +178,7 @@ class GetVesselReportings( } val controlUnitId = (updatedReporting.value as? InfractionSuspicionOrObservationType)?.controlUnitId - val foundControlUnit = legacyControlUnits.find { it.id == controlUnitId } + val foundControlUnit = controlUnits.find { it.id == controlUnitId } return updatedReportingAndOccurrences.copy(controlUnit = foundControlUnit) } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/reporting/UpdateReporting.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/reporting/UpdateReporting.kt index 24835b6db7..d15cadf8c7 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/reporting/UpdateReporting.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/reporting/UpdateReporting.kt @@ -69,9 +69,9 @@ class UpdateReporting( fun getControlUnit( reporting: Reporting, - legacyControlUnits: List, + controlUnits: List, ): LegacyControlUnit? { val controlUnitId = (reporting.value as InfractionSuspicionOrObservationType).controlUnitId - return legacyControlUnits.find { it.id == controlUnitId } + return controlUnits.find { it.id == controlUnitId } } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/ActivityReportDataOutput.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/ActivityReportDataOutput.kt index 6225dd842c..5f421a273c 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/ActivityReportDataOutput.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/ActivityReportDataOutput.kt @@ -10,7 +10,7 @@ data class ActivityReportDataOutput( val faoArea: String?, val segment: String?, val vesselNationalIdentifier: String, - val legacyControlUnits: List, + val controlUnits: List, val vessel: VesselDataOutput, ) { companion object { @@ -21,7 +21,7 @@ data class ActivityReportDataOutput( faoArea = activityReport.faoArea, segment = activityReport.segment, vesselNationalIdentifier = activityReport.vesselNationalIdentifier, - legacyControlUnits = activityReport.controlUnits, + controlUnits = activityReport.controlUnits, vessel = VesselDataOutput.fromVessel(activityReport.vessel), ) } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/InfractionSuspicionDataOutput.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/InfractionSuspicionDataOutput.kt index b0f0c1f2a4..7636e24965 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/InfractionSuspicionDataOutput.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/InfractionSuspicionDataOutput.kt @@ -7,7 +7,7 @@ import fr.gouv.cnsp.monitorfish.domain.entities.reporting.ReportingActor data class InfractionSuspicionDataOutput( val reportingActor: ReportingActor, val controlUnitId: Int? = null, - val legacyControlUnit: LegacyControlUnit? = null, + val controlUnit: LegacyControlUnit? = null, val authorTrigram: String, val authorContact: String? = null, val title: String, @@ -19,12 +19,12 @@ data class InfractionSuspicionDataOutput( companion object { fun fromInfractionSuspicion( infractionSuspicion: InfractionSuspicion, - legacyControlUnit: LegacyControlUnit? = null, + controlUnit: LegacyControlUnit? = null, ): InfractionSuspicionDataOutput { return InfractionSuspicionDataOutput( reportingActor = infractionSuspicion.reportingActor, controlUnitId = infractionSuspicion.controlUnitId, - legacyControlUnit = legacyControlUnit, + controlUnit = controlUnit, authorTrigram = infractionSuspicion.authorTrigram, authorContact = infractionSuspicion.authorContact, title = infractionSuspicion.title, diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/MissionActionDataOutput.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/MissionActionDataOutput.kt index 5c35053f7b..e96a835acb 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/MissionActionDataOutput.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/MissionActionDataOutput.kt @@ -49,7 +49,7 @@ data class MissionActionDataOutput( val otherComments: String? = null, val gearOnboard: List = listOf(), val speciesOnboard: List = listOf(), - val legacyControlUnits: List = listOf(), + val controlUnits: List = listOf(), val userTrigram: String, val vesselTargeted: ControlCheck? = null, val hasSomeGearsSeized: Boolean, @@ -109,7 +109,7 @@ data class MissionActionDataOutput( otherComments = missionAction.otherComments, gearOnboard = missionAction.gearOnboard, speciesOnboard = missionAction.speciesOnboard, - legacyControlUnits = missionAction.controlUnits, + controlUnits = missionAction.controlUnits, userTrigram = missionAction.userTrigram, vesselTargeted = missionAction.vesselTargeted, hasSomeGearsSeized = missionAction.hasSomeGearsSeized, diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/MissionWithActionsDataOutput.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/MissionWithActionsDataOutput.kt index 41bc1a84f3..1058fbb58d 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/MissionWithActionsDataOutput.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/MissionWithActionsDataOutput.kt @@ -26,7 +26,7 @@ data class MissionWithActionsDataOutput( val missionSource: MissionSource, val hasMissionOrder: Boolean? = false, val isUnderJdp: Boolean? = false, - val legacyControlUnits: List = listOf(), + val controlUnits: List = listOf(), val actions: List, ) { companion object { @@ -43,15 +43,15 @@ data class MissionWithActionsDataOutput( createdAtUtc = missionAndActions.mission.createdAtUtc, updatedAtUtc = missionAndActions.mission.updatedAtUtc, envActions = - missionAndActions.mission.envActions - ?.map { EnvMissionActionDataOutput.fromEnvMissionAction(it) } ?: listOf(), + missionAndActions.mission.envActions + ?.map { EnvMissionActionDataOutput.fromEnvMissionAction(it) } ?: listOf(), startDateTimeUtc = missionAndActions.mission.startDateTimeUtc, endDateTimeUtc = missionAndActions.mission.endDateTimeUtc, isGeometryComputedFromControls = missionAndActions.mission.isGeometryComputedFromControls, missionSource = missionAndActions.mission.missionSource, hasMissionOrder = missionAndActions.mission.hasMissionOrder, isUnderJdp = missionAndActions.mission.isUnderJdp, - legacyControlUnits = missionAndActions.mission.controlUnits, + controlUnits = missionAndActions.mission.controlUnits, actions = missionAndActions.actions.map { MissionActionDataOutput.fromMissionAction(it) }, ) } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/ObservationDataOutput.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/ObservationDataOutput.kt index 8471cb273f..d5f2b2d30f 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/ObservationDataOutput.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/ObservationDataOutput.kt @@ -7,7 +7,7 @@ import fr.gouv.cnsp.monitorfish.domain.entities.reporting.ReportingActor class ObservationDataOutput( val reportingActor: ReportingActor, val controlUnitId: Int? = null, - val legacyControlUnit: LegacyControlUnit? = null, + val controlUnit: LegacyControlUnit? = null, val authorTrigram: String, val authorContact: String? = null, val title: String, @@ -16,12 +16,12 @@ class ObservationDataOutput( companion object { fun fromObservation( observation: Observation, - legacyControlUnit: LegacyControlUnit? = null, + controlUnit: LegacyControlUnit? = null, ): ObservationDataOutput { return ObservationDataOutput( reportingActor = observation.reportingActor, controlUnitId = observation.controlUnitId, - legacyControlUnit = legacyControlUnit, + controlUnit = controlUnit, authorTrigram = observation.authorTrigram, authorContact = observation.authorContact, title = observation.title, diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/ReportingAndOccurrencesDataOutput.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/ReportingAndOccurrencesDataOutput.kt index 9315bc00f9..2f4723de9c 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/ReportingAndOccurrencesDataOutput.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/ReportingAndOccurrencesDataOutput.kt @@ -12,14 +12,14 @@ data class ReportingAndOccurrencesDataOutput( ): ReportingAndOccurrencesDataOutput { return ReportingAndOccurrencesDataOutput( otherOccurrencesOfSameAlert = - reportingAndOccurrences.otherOccurrencesOfSameAlert.map { reporting -> - ReportingDataOutput.fromReporting(reporting, reportingAndOccurrences.controlUnit) - }, + reportingAndOccurrences.otherOccurrencesOfSameAlert.map { reporting -> + ReportingDataOutput.fromReporting(reporting, reportingAndOccurrences.controlUnit) + }, reporting = - ReportingDataOutput.fromReporting( - reportingAndOccurrences.reporting, - reportingAndOccurrences.controlUnit, - ), + ReportingDataOutput.fromReporting( + reportingAndOccurrences.reporting, + reportingAndOccurrences.controlUnit, + ), ) } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/ReportingDataOutput.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/ReportingDataOutput.kt index 156ed9ec48..6f15faf0ef 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/ReportingDataOutput.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/ReportingDataOutput.kt @@ -31,17 +31,17 @@ class ReportingDataOutput( companion object { fun fromReporting( reporting: Reporting, - legacyControlUnit: LegacyControlUnit?, + controlUnit: LegacyControlUnit?, ): ReportingDataOutput { val value = when (reporting.value) { is InfractionSuspicion -> InfractionSuspicionDataOutput.fromInfractionSuspicion( reporting.value, - legacyControlUnit, + controlUnit, ) - is Observation -> ObservationDataOutput.fromObservation(reporting.value, legacyControlUnit) + is Observation -> ObservationDataOutput.fromObservation(reporting.value, controlUnit) is AlertType -> AlertDataOutput.fromAlertType(reporting.value) else -> throw IllegalArgumentException("Should not happen.") } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/APIMissionRepository.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/APIMissionRepository.kt index 2f516e9666..13b2af94c8 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/APIMissionRepository.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/APIMissionRepository.kt @@ -48,7 +48,7 @@ class APIMissionRepository( val missionsUrl = "${monitorenvProperties.url}/api/v1/missions/$missionId" try { - val controlUnits = apiClient.httpClient.get(missionsUrl).body().legacyControlUnits + val controlUnits = apiClient.httpClient.get(missionsUrl).body().controlUnits cache.put(cacheKey, controlUnits) diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/input/MissionDataResponse.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/input/MissionDataResponse.kt index e1a5bae2de..086b223b76 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/input/MissionDataResponse.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/input/MissionDataResponse.kt @@ -12,7 +12,7 @@ for the full entity structure @Serializable data class MissionDataResponse( val id: Int, - val legacyControlUnits: List = listOf(), + val controlUnits: List = listOf(), val missionTypes: List, val openBy: String? = null, val completedBy: String? = null, @@ -33,7 +33,7 @@ data class MissionDataResponse( fun toMission() = Mission( id = id, - controlUnits = legacyControlUnits, + controlUnits = controlUnits, missionTypes = missionTypes, openBy = openBy, completedBy = completedBy, diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/GetMissionUTests.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/GetMissionUTests.kt index 4408a08000..e31f371eac 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/GetMissionUTests.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/GetMissionUTests.kt @@ -41,13 +41,13 @@ class GetMissionUTests { isGeometryComputedFromControls = false, missionSource = MissionSource.MONITORFISH, envActions = - listOf( - EnvMissionAction( - id = UUID.randomUUID(), - actionStartDateTimeUtc = ZonedDateTime.now(), - actionType = EnvMissionActionType.CONTROL, + listOf( + EnvMissionAction( + id = UUID.randomUUID(), + actionStartDateTimeUtc = ZonedDateTime.now(), + actionType = EnvMissionActionType.CONTROL, + ), ), - ), ), ) given(getMissionActions.execute(any())).willReturn(getDummyMissionActions(listOf(1, 2))) diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/mission_actions/GetActivityReportsUTests.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/mission_actions/GetActivityReportsUTests.kt index 38dc76786d..4a185b9932 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/mission_actions/GetActivityReportsUTests.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/mission_actions/GetActivityReportsUTests.kt @@ -61,10 +61,10 @@ class GetActivityReportsUTests { portLocode = "AEFAT", faoAreas = listOf("27.7.b", "27.4.c"), segments = - listOf( - FleetSegment("NWW01/02", "Trawl"), - FleetSegment("NS01/03", "North sea"), - ), + listOf( + FleetSegment("NWW01/02", "Trawl"), + FleetSegment("NS01/03", "North sea"), + ), actionType = MissionActionType.LAND_CONTROL, gearOnboard = listOf(), speciesOnboard = listOf(species), @@ -212,10 +212,10 @@ class GetActivityReportsUTests { portLocode = "AEFAT", faoAreas = listOf("27.7.b", "27.4.c"), segments = - listOf( - FleetSegment("NWW01/02", "Trawl"), - FleetSegment("NS01/03", "North sea"), - ), + listOf( + FleetSegment("NWW01/02", "Trawl"), + FleetSegment("NS01/03", "North sea"), + ), actionType = MissionActionType.LAND_CONTROL, gearOnboard = listOf(), speciesOnboard = listOf(species), @@ -368,25 +368,25 @@ class GetActivityReportsUTests { "NS01/03", "Otter trawls/Seines", gears = - listOf( - "OTB", - "OTT", - "TBN", - "PTB", - "SDN", - "SSC", - "SPR", - "OT", - "TBS", - "OTM", - "PTM", - "TMS", - "TM", - "TX", - "TB", - "SX", - "SV", - ), + listOf( + "OTB", + "OTT", + "TBN", + "PTB", + "SDN", + "SSC", + "SPR", + "OT", + "TBS", + "OTM", + "PTM", + "TMS", + "TM", + "TX", + "TB", + "SX", + "SV", + ), targetSpecies = listOf("COD", "HAD", "WHG", "POK", "SOL", "PLE", "NEP", "HKE"), faoAreas = listOf("27.2.a", "27.4.a", "27.4.b", "27.4.c"), year = ZonedDateTime.now().year, @@ -405,9 +405,9 @@ class GetActivityReportsUTests { portLocode = "AEFAT", faoAreas = listOf("27.4.a"), segments = - listOf( - FleetSegment("NS01/03", "North Sea"), - ), + listOf( + FleetSegment("NS01/03", "North Sea"), + ), actionType = MissionActionType.LAND_CONTROL, gearOnboard = listOf(), speciesOnboard = listOf(species), diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/MissionActionsControllerITests.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/MissionActionsControllerITests.kt index 0c37c7c6f4..e64de4493a 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/MissionActionsControllerITests.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/MissionActionsControllerITests.kt @@ -158,29 +158,29 @@ class MissionActionsControllerITests { vesselId = 2, actionType = MissionActionType.SEA_CONTROL, logbookInfractions = - listOf( - LogbookInfraction( - InfractionType.WITH_RECORD, - 27689, - "Poids à bord MNZ supérieur de 50% au poids déclaré", + listOf( + LogbookInfraction( + InfractionType.WITH_RECORD, + 27689, + "Poids à bord MNZ supérieur de 50% au poids déclaré", + ), ), - ), faoAreas = listOf("25.6.9", "25.7.9"), segments = - listOf( - FleetSegment( - segment = "WWSS10", - segmentName = "World Wide Segment", + listOf( + FleetSegment( + segment = "WWSS10", + segmentName = "World Wide Segment", + ), ), - ), gearInfractions = - listOf( - GearInfraction( - InfractionType.WITH_RECORD, - 27689, - "Maille trop petite", + listOf( + GearInfraction( + InfractionType.WITH_RECORD, + 27689, + "Maille trop petite", + ), ), - ), hasSomeGearsSeized = false, hasSomeSpeciesSeized = false, isAdministrativeControl = true, @@ -242,29 +242,29 @@ class MissionActionsControllerITests { vesselId = 2, actionType = MissionActionType.SEA_CONTROL, logbookInfractions = - listOf( - LogbookInfraction( - InfractionType.WITH_RECORD, - 27689, - "Poids à bord MNZ supérieur de 50% au poids déclaré", + listOf( + LogbookInfraction( + InfractionType.WITH_RECORD, + 27689, + "Poids à bord MNZ supérieur de 50% au poids déclaré", + ), ), - ), faoAreas = listOf("25.6.9", "25.7.9"), segments = - listOf( - FleetSegment( - segment = "WWSS10", - segmentName = "World Wide Segment", + listOf( + FleetSegment( + segment = "WWSS10", + segmentName = "World Wide Segment", + ), ), - ), gearInfractions = - listOf( - GearInfraction( - InfractionType.WITH_RECORD, - 27689, - "Maille trop petite", + listOf( + GearInfraction( + InfractionType.WITH_RECORD, + 27689, + "Maille trop petite", + ), ), - ), gearOnboard = listOf(gearControl), hasSomeGearsSeized = false, hasSomeSpeciesSeized = false, @@ -355,41 +355,41 @@ class MissionActionsControllerITests { given(getActivityReports.execute(any(), any(), any())).willReturn( ActivityReports( activityReports = - listOf( - ActivityReport( - action = - MissionAction( - 1, - 1, - 1, - actionType = MissionActionType.SEA_CONTROL, - actionDatetimeUtc = ZonedDateTime.now(), - isDeleted = false, - hasSomeGearsSeized = false, - hasSomeSpeciesSeized = false, - isFromPoseidon = true, - flagState = CountryCode.FR, - userTrigram = "LTH", - completion = Completion.TO_COMPLETE, - ), - activityCode = ActivityCode.FIS, - vesselNationalIdentifier = "AYFR000654", - controlUnits = listOf(LegacyControlUnit(1234, "DIRM", false, "Cross Etel", listOf())), - faoArea = "27.7.c", - segment = "NS01/03", - vessel = - Vessel( - id = 1, - internalReferenceNumber = "FR00022680", - vesselName = "MY AWESOME VESSEL", - flagState = CountryCode.FR, - declaredFishingGears = listOf("Trémails"), - vesselType = "Fishing", - districtCode = "AY", - hasLogbookEsacapt = false, + listOf( + ActivityReport( + action = + MissionAction( + 1, + 1, + 1, + actionType = MissionActionType.SEA_CONTROL, + actionDatetimeUtc = ZonedDateTime.now(), + isDeleted = false, + hasSomeGearsSeized = false, + hasSomeSpeciesSeized = false, + isFromPoseidon = true, + flagState = CountryCode.FR, + userTrigram = "LTH", + completion = Completion.TO_COMPLETE, + ), + activityCode = ActivityCode.FIS, + vesselNationalIdentifier = "AYFR000654", + controlUnits = listOf(LegacyControlUnit(1234, "DIRM", false, "Cross Etel", listOf())), + faoArea = "27.7.c", + segment = "NS01/03", + vessel = + Vessel( + id = 1, + internalReferenceNumber = "FR00022680", + vesselName = "MY AWESOME VESSEL", + flagState = CountryCode.FR, + declaredFishingGears = listOf("Trémails"), + vesselType = "Fishing", + districtCode = "AY", + hasLogbookEsacapt = false, + ), ), ), - ), jdpSpecies = listOf("BSS", "MAK", "LTH"), ), ) diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/VesselControllerITests.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/VesselControllerITests.kt index 80c34f0966..a90e6813ab 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/VesselControllerITests.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/VesselControllerITests.kt @@ -111,9 +111,9 @@ class VesselControllerITests { course = 180.0, dateTime = farPastFixedDateTime, vesselIdentifier = VesselIdentifier.INTERNAL_REFERENCE_NUMBER, gearOnboard = - listOf( - gear, - ), + listOf( + gear, + ), ) given(this.getLastPositions.execute()).willReturn(listOf(position)) @@ -167,9 +167,9 @@ class VesselControllerITests { speed = 1.8, course = 180.0, dateTime = - now.minusHours( - 4, - ), + now.minusHours( + 4, + ), ) val secondPosition = Position( @@ -188,9 +188,9 @@ class VesselControllerITests { speed = 1.8, course = 180.0, dateTime = - now.minusHours( - 3, - ), + now.minusHours( + 3, + ), ) val thirdPosition = Position( @@ -209,9 +209,9 @@ class VesselControllerITests { speed = 1.8, course = 180.0, dateTime = - now.minusHours( - 2, - ), + now.minusHours( + 2, + ), ) givenSuspended { getVessel.execute(eq(123), any(), any(), any(), any(), any(), eq(null), eq(null)) @@ -220,16 +220,16 @@ class VesselControllerITests { false, VesselInformation( vessel = - Vessel( - id = 123, - internalReferenceNumber = "FR224226850", - vesselName = "MY AWESOME VESSEL", - flagState = CountryCode.FR, - declaredFishingGears = listOf("Trémails"), - vesselType = "Fishing", - underCharter = true, - hasLogbookEsacapt = false, - ), + Vessel( + id = 123, + internalReferenceNumber = "FR224226850", + vesselName = "MY AWESOME VESSEL", + flagState = CountryCode.FR, + declaredFishingGears = listOf("Trémails"), + vesselType = "Fishing", + underCharter = true, + hasLogbookEsacapt = false, + ), beacon = null, positions = listOf(firstPosition, secondPosition, thirdPosition), vesselRiskFactor = VesselRiskFactor(2.3, 2.0, 1.9, 3.2), @@ -356,9 +356,9 @@ class VesselControllerITests { speed = 1.8, course = 180.0, dateTime = - now.minusHours( - 4, - ), + now.minusHours( + 4, + ), ) val secondPosition = Position( @@ -377,9 +377,9 @@ class VesselControllerITests { speed = 1.8, course = 180.0, dateTime = - now.minusHours( - 3, - ), + now.minusHours( + 3, + ), ) val thirdPosition = Position( @@ -398,9 +398,9 @@ class VesselControllerITests { speed = 1.8, course = 180.0, dateTime = - now.minusHours( - 2, - ), + now.minusHours( + 2, + ), ) givenSuspended { getVesselPositions.execute(any(), any(), any(), any(), any(), eq(null), eq(null)) @@ -438,28 +438,28 @@ class VesselControllerITests { listOf( VesselAndBeacon( vessel = - Vessel( - id = 1, - internalReferenceNumber = "FR224226850", - vesselName = "MY AWESOME VESSEL", - flagState = CountryCode.FR, - declaredFishingGears = listOf("Trémails"), - vesselType = "Fishing", - hasLogbookEsacapt = false, - ), + Vessel( + id = 1, + internalReferenceNumber = "FR224226850", + vesselName = "MY AWESOME VESSEL", + flagState = CountryCode.FR, + declaredFishingGears = listOf("Trémails"), + vesselType = "Fishing", + hasLogbookEsacapt = false, + ), beacon = Beacon(beaconNumber = "123456", vesselId = 1), ), VesselAndBeacon( vessel = - Vessel( - id = 2, - internalReferenceNumber = "GBR21555445", - vesselName = "ANOTHER VESSEL", - flagState = CountryCode.GB, - declaredFishingGears = listOf("Trémails"), - vesselType = "Fishing", - hasLogbookEsacapt = false, - ), + Vessel( + id = 2, + internalReferenceNumber = "GBR21555445", + vesselName = "ANOTHER VESSEL", + flagState = CountryCode.GB, + declaredFishingGears = listOf("Trémails"), + vesselType = "Fishing", + hasLogbookEsacapt = false, + ), beacon = null, ), ), @@ -569,88 +569,88 @@ class VesselControllerITests { VesselBeaconMalfunctionsResumeAndHistory( resume = VesselBeaconMalfunctionsResume(1, 2, null, null), history = - listOf( + listOf( + BeaconMalfunctionWithDetails( + beaconMalfunction = + BeaconMalfunction( + id = 1, + internalReferenceNumber = "FR224226850", + externalReferenceNumber = "1236514", + ircs = "IRCS", + flagState = "fr", + vesselIdentifier = VesselIdentifier.INTERNAL_REFERENCE_NUMBER, + vesselName = "BIDUBULE", + vesselStatus = VesselStatus.AT_SEA, + stage = Stage.ARCHIVED, + malfunctionStartDateTime = ZonedDateTime.now(), + malfunctionEndDateTime = null, + vesselStatusLastModificationDateTime = ZonedDateTime.now(), + endOfBeaconMalfunctionReason = EndOfBeaconMalfunctionReason.RESUMED_TRANSMISSION, + beaconNumber = "123465", + beaconStatusAtMalfunctionCreation = BeaconStatus.ACTIVATED, + vesselId = 123, + ), + comments = + listOf( + BeaconMalfunctionComment( + beaconMalfunctionId = 1, + comment = "A comment", + userType = BeaconMalfunctionCommentUserType.SIP, + dateTime = now, + ), + ), + actions = + listOf( + BeaconMalfunctionAction( + beaconMalfunctionId = 1, + propertyName = BeaconMalfunctionActionPropertyName.VESSEL_STATUS, + nextValue = "A VALUE", + previousValue = "A VALUE", + dateTime = now, + ), + ), + ), + ), + current = BeaconMalfunctionWithDetails( beaconMalfunction = - BeaconMalfunction( - id = 1, - internalReferenceNumber = "FR224226850", - externalReferenceNumber = "1236514", - ircs = "IRCS", - flagState = "fr", - vesselIdentifier = VesselIdentifier.INTERNAL_REFERENCE_NUMBER, - vesselName = "BIDUBULE", - vesselStatus = VesselStatus.AT_SEA, - stage = Stage.ARCHIVED, - malfunctionStartDateTime = ZonedDateTime.now(), - malfunctionEndDateTime = null, - vesselStatusLastModificationDateTime = ZonedDateTime.now(), - endOfBeaconMalfunctionReason = EndOfBeaconMalfunctionReason.RESUMED_TRANSMISSION, - beaconNumber = "123465", - beaconStatusAtMalfunctionCreation = BeaconStatus.ACTIVATED, - vesselId = 123, - ), + BeaconMalfunction( + id = 2, + internalReferenceNumber = "FR224226850", + externalReferenceNumber = "1236514", + ircs = "IRCS", + flagState = "fr", + vesselIdentifier = VesselIdentifier.INTERNAL_REFERENCE_NUMBER, + vesselName = "BIDUBULE", + vesselStatus = VesselStatus.AT_SEA, + stage = Stage.INITIAL_ENCOUNTER, + malfunctionStartDateTime = ZonedDateTime.now(), + malfunctionEndDateTime = null, + vesselStatusLastModificationDateTime = ZonedDateTime.now(), + beaconNumber = "123465", + beaconStatusAtMalfunctionCreation = BeaconStatus.ACTIVATED, + vesselId = 123, + ), comments = - listOf( - BeaconMalfunctionComment( - beaconMalfunctionId = 1, - comment = "A comment", - userType = BeaconMalfunctionCommentUserType.SIP, - dateTime = now, + listOf( + BeaconMalfunctionComment( + beaconMalfunctionId = 1, + comment = "A comment", + userType = BeaconMalfunctionCommentUserType.SIP, + dateTime = now, + ), ), - ), actions = - listOf( - BeaconMalfunctionAction( - beaconMalfunctionId = 1, - propertyName = BeaconMalfunctionActionPropertyName.VESSEL_STATUS, - nextValue = "A VALUE", - previousValue = "A VALUE", - dateTime = now, + listOf( + BeaconMalfunctionAction( + beaconMalfunctionId = 1, + propertyName = BeaconMalfunctionActionPropertyName.VESSEL_STATUS, + nextValue = "A VALUE", + previousValue = "A VALUE", + dateTime = now, + ), ), - ), - ), - ), - current = - BeaconMalfunctionWithDetails( - beaconMalfunction = - BeaconMalfunction( - id = 2, - internalReferenceNumber = "FR224226850", - externalReferenceNumber = "1236514", - ircs = "IRCS", - flagState = "fr", - vesselIdentifier = VesselIdentifier.INTERNAL_REFERENCE_NUMBER, - vesselName = "BIDUBULE", - vesselStatus = VesselStatus.AT_SEA, - stage = Stage.INITIAL_ENCOUNTER, - malfunctionStartDateTime = ZonedDateTime.now(), - malfunctionEndDateTime = null, - vesselStatusLastModificationDateTime = ZonedDateTime.now(), - beaconNumber = "123465", - beaconStatusAtMalfunctionCreation = BeaconStatus.ACTIVATED, - vesselId = 123, ), - comments = - listOf( - BeaconMalfunctionComment( - beaconMalfunctionId = 1, - comment = "A comment", - userType = BeaconMalfunctionCommentUserType.SIP, - dateTime = now, - ), - ), - actions = - listOf( - BeaconMalfunctionAction( - beaconMalfunctionId = 1, - propertyName = BeaconMalfunctionActionPropertyName.VESSEL_STATUS, - nextValue = "A VALUE", - previousValue = "A VALUE", - dateTime = now, - ), - ), - ), ), ) @@ -703,10 +703,10 @@ class VesselControllerITests { isArchived = false, isDeleted = false, infraction = - Infraction( - natinfCode = 7059, - infractionCategory = InfractionCategory.FISHING, - ), + Infraction( + natinfCode = 7059, + infractionCategory = InfractionCategory.FISHING, + ), ) val archivedReporting = @@ -739,48 +739,48 @@ class VesselControllerITests { .willReturn( VesselReportings( summary = - ReportingSummary( - infractionSuspicionsSummary = + ReportingSummary( + infractionSuspicionsSummary = + listOf( + ReportingTitleAndNumberOfOccurrences( + title = "A title", + numberOfOccurrences = 2, + ), + ReportingTitleAndNumberOfOccurrences( + title = "A title", + numberOfOccurrences = 2, + ), + ), + numberOfInfractionSuspicions = 4, + numberOfObservations = 5, + ), + current = listOf( - ReportingTitleAndNumberOfOccurrences( - title = "A title", - numberOfOccurrences = 2, + ReportingAndOccurrences( + otherOccurrencesOfSameAlert = listOf(), + reporting = currentReporting, + controlUnit = null, ), - ReportingTitleAndNumberOfOccurrences( - title = "A title", - numberOfOccurrences = 2, + ReportingAndOccurrences( + otherOccurrencesOfSameAlert = listOf(), + reporting = currentReporting, + controlUnit = null, ), ), - numberOfInfractionSuspicions = 4, - numberOfObservations = 5, - ), - current = - listOf( - ReportingAndOccurrences( - otherOccurrencesOfSameAlert = listOf(), - reporting = currentReporting, - controlUnit = null, - ), - ReportingAndOccurrences( - otherOccurrencesOfSameAlert = listOf(), - reporting = currentReporting, - controlUnit = null, - ), - ), archived = - mapOf( - 2024 to - listOf( - ReportingAndOccurrences( - otherOccurrencesOfSameAlert = listOf(), - reporting = archivedReporting, - controlUnit = null, + mapOf( + 2024 to + listOf( + ReportingAndOccurrences( + otherOccurrencesOfSameAlert = listOf(), + reporting = archivedReporting, + controlUnit = null, + ), ), - ), - 2023 to emptyList(), - 2022 to emptyList(), - 2021 to emptyList(), - ), + 2023 to emptyList(), + 2022 to emptyList(), + 2021 to emptyList(), + ), ), ) @@ -830,11 +830,11 @@ class VesselControllerITests { .willReturn( VesselReportings( summary = - ReportingSummary( - infractionSuspicionsSummary = listOf(), - numberOfInfractionSuspicions = 0, - numberOfObservations = 0, - ), + ReportingSummary( + infractionSuspicionsSummary = listOf(), + numberOfInfractionSuspicions = 0, + numberOfObservations = 0, + ), current = listOf(), archived = mapOf(), ), From cc3e93b9e565efc526bb847e00b389ec2c4e72a2 Mon Sep 17 00:00:00 2001 From: Ivan Gabriele Date: Wed, 23 Oct 2024 09:58:42 +0200 Subject: [PATCH 09/59] Upgrade MonitorEnv local docker image from v1.37.0 to v1.45.1 --- infra/docker/.env.local.defaults | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/infra/docker/.env.local.defaults b/infra/docker/.env.local.defaults index 80f9274ae6..6349a28080 100644 --- a/infra/docker/.env.local.defaults +++ b/infra/docker/.env.local.defaults @@ -17,7 +17,7 @@ MONITORFISH_VERSION=0.0.0 #===================================================================== # VERSION -MONITORENV_VERSION=v1.37.0 +MONITORENV_VERSION=v1.45.1 #===================================================================== # BACKEND & INFRA From 296bbb2b7cb0e1c2f27eb3fa8c7c27eaba07fb35 Mon Sep 17 00:00:00 2001 From: Ivan Gabriele Date: Wed, 23 Oct 2024 10:40:48 +0200 Subject: [PATCH 10/59] Add new GetAllControlUnits use case in Backend --- .../entities/control_unit/ControlUnit.kt | 11 ++++++ .../control_unit/ControlUnitAdministration.kt | 7 ++++ .../control_unit/ControlUnitContact.kt | 11 ++++++ .../control_unit/ControlUnitDepartmentArea.kt | 7 ++++ .../control_unit/ControlUnitResourceType.kt | 29 +++++++++++++++ .../control_unit/ControlUnitStation.kt | 8 +++++ .../control_unit/FullControlUnitResource.kt | 14 ++++++++ .../control_unit/LegacyControlUnit.kt | 2 +- .../domain/entities/mission/Mission.kt | 2 +- .../mission/mission_actions/MissionAction.kt | 2 +- .../reporting/ReportingAndOccurrences.kt | 2 +- .../repositories/ControlUnitRepository.kt | 7 ++++ .../LegacyControlUnitRepository.kt | 2 +- .../domain/repositories/MissionRepository.kt | 2 +- .../control_units/GetAllControlUnits.kt | 14 ++++++++ .../control_units/GetAllLegacyControlUnits.kt | 6 ++-- .../control_units/dtos/FullControlUnit.kt | 22 ++++++++++++ .../mission_actions/dtos/ActivityReport.kt | 2 +- .../dtos/PriorNotificationSubscriber.kt | 2 +- .../use_cases/reporting/AddReporting.kt | 2 +- .../reporting/GetAllCurrentReportings.kt | 2 +- .../reporting/GetVesselReportings.kt | 2 +- .../use_cases/reporting/UpdateReporting.kt | 2 +- .../api/outputs/ActivityReportDataOutput.kt | 2 +- .../outputs/InfractionSuspicionDataOutput.kt | 2 +- .../api/outputs/MissionActionDataOutput.kt | 2 +- .../outputs/MissionWithActionsDataOutput.kt | 2 +- .../api/outputs/ObservationDataOutput.kt | 2 +- .../api/outputs/ReportingDataOutput.kt | 2 +- .../cache/CaffeineConfiguration.kt | 3 ++ .../monitorenv/APIControlUnitRepository.kt | 35 +++++++++++++++++++ .../APILegacyControlUnitRepository.kt | 4 +-- .../monitorenv/APIMissionRepository.kt | 2 +- .../monitorenv/input/MissionDataResponse.kt | 2 +- .../GetActivityReportsUTests.kt | 2 +- .../api/bff/MissionActionsControllerITests.kt | 2 +- .../api/bff/ReportingControllerITests.kt | 2 +- infra/docker/.env.local.defaults | 8 ++++- .../docker/docker-compose.monitorenv.dev.yml | 2 ++ 39 files changed, 205 insertions(+), 29 deletions(-) create mode 100644 backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/control_unit/ControlUnit.kt create mode 100644 backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/control_unit/ControlUnitAdministration.kt create mode 100644 backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/control_unit/ControlUnitContact.kt create mode 100644 backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/control_unit/ControlUnitDepartmentArea.kt create mode 100644 backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/control_unit/ControlUnitResourceType.kt create mode 100644 backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/control_unit/ControlUnitStation.kt create mode 100644 backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/control_unit/FullControlUnitResource.kt create mode 100644 backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/repositories/ControlUnitRepository.kt create mode 100644 backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/control_units/GetAllControlUnits.kt create mode 100644 backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/control_units/dtos/FullControlUnit.kt create mode 100644 backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/APIControlUnitRepository.kt diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/control_unit/ControlUnit.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/control_unit/ControlUnit.kt new file mode 100644 index 0000000000..34c502fc73 --- /dev/null +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/control_unit/ControlUnit.kt @@ -0,0 +1,11 @@ +package fr.gouv.cnsp.monitorfish.domain.entities.control_unit + +data class ControlUnit( + val id: Int, + val areaNote: String?, + val administrationId: Int, + val departmentAreaInseeCode: String?, + val isArchived: Boolean, + val name: String, + val termsNote: String?, +) diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/control_unit/ControlUnitAdministration.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/control_unit/ControlUnitAdministration.kt new file mode 100644 index 0000000000..5817d0e5d0 --- /dev/null +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/control_unit/ControlUnitAdministration.kt @@ -0,0 +1,7 @@ +package fr.gouv.cnsp.monitorfish.domain.entities.control_unit + +data class ControlUnitAdministration( + val id: Int, + val isArchived: Boolean, + val name: String, +) diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/control_unit/ControlUnitContact.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/control_unit/ControlUnitContact.kt new file mode 100644 index 0000000000..a4190d1ee7 --- /dev/null +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/control_unit/ControlUnitContact.kt @@ -0,0 +1,11 @@ +package fr.gouv.cnsp.monitorfish.domain.entities.control_unit + +data class ControlUnitContact( + val id: Int, + val controlUnitId: Int, + val email: String?, + val isEmailSubscriptionContact: Boolean, + val isSmsSubscriptionContact: Boolean, + val name: String, + val phone: String?, +) diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/control_unit/ControlUnitDepartmentArea.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/control_unit/ControlUnitDepartmentArea.kt new file mode 100644 index 0000000000..0df0524f51 --- /dev/null +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/control_unit/ControlUnitDepartmentArea.kt @@ -0,0 +1,7 @@ +package fr.gouv.cnsp.monitorfish.domain.entities.control_unit + +data class ControlUnitDepartmentArea( + /** `inseeCode` is the ID. */ + val inseeCode: String, + val name: String, +) diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/control_unit/ControlUnitResourceType.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/control_unit/ControlUnitResourceType.kt new file mode 100644 index 0000000000..e7e1d6b31e --- /dev/null +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/control_unit/ControlUnitResourceType.kt @@ -0,0 +1,29 @@ +package fr.gouv.cnsp.monitorfish.domain.entities.control_unit + +enum class ControlUnitResourceType(val label: String) { + AIRPLANE("Avion"), + BARGE("Barge"), + CAR("Voiture"), + DRONE("Drône"), + EQUESTRIAN("Équestre"), + FAST_BOAT("Vedette"), + FRIGATE("Frégate"), + HELICOPTER("Hélicoptère"), + HYDROGRAPHIC_SHIP("Bâtiment hydrographique"), + KAYAK("Kayak"), + LIGHT_FAST_BOAT("Vedette légère"), + MINE_DIVER("Plongeur démineur"), + MOTORCYCLE("Moto"), + NET_LIFTER("Remonte-filets"), + NO_RESOURCE("Aucun moyen"), + OTHER("Autre"), + PATROL_BOAT("Patrouilleur"), + PEDESTRIAN("Piéton"), + PIROGUE("Pirogue"), + RIGID_HULL("Coque rigide"), + SEA_SCOOTER("Scooter de mer"), + SEMI_RIGID("Semi-rigide"), + SUPPORT_SHIP("Bâtiment de soutien"), + TRAINING_SHIP("Bâtiment-école"), + TUGBOAT("Remorqueur"), +} diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/control_unit/ControlUnitStation.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/control_unit/ControlUnitStation.kt new file mode 100644 index 0000000000..5e38d514ad --- /dev/null +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/control_unit/ControlUnitStation.kt @@ -0,0 +1,8 @@ +package fr.gouv.cnsp.monitorfish.domain.entities.control_unit + +data class ControlUnitStation( + val id: Int, + val latitude: Double, + val longitude: Double, + val name: String, +) diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/control_unit/FullControlUnitResource.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/control_unit/FullControlUnitResource.kt new file mode 100644 index 0000000000..58c43ef3b8 --- /dev/null +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/control_unit/FullControlUnitResource.kt @@ -0,0 +1,14 @@ +package fr.gouv.cnsp.monitorfish.domain.entities.control_unit + +data class FullControlUnitResource( + val id: Int, + val controlUnit: ControlUnit, + val controlUnitId: Int, + val isArchived: Boolean, + val name: String, + val note: String?, + val photo: ByteArray?, + val station: ControlUnitStation, + val stationId: Int, + val type: ControlUnitResourceType, +) diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/control_unit/LegacyControlUnit.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/control_unit/LegacyControlUnit.kt index c8098be22c..69ba76542e 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/control_unit/LegacyControlUnit.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/control_unit/LegacyControlUnit.kt @@ -1,4 +1,4 @@ -package fr.gouv.cnsp.monitorfish.domain.entities.control_units +package fr.gouv.cnsp.monitorfish.domain.entities.control_unit import fr.gouv.cnsp.monitorfish.domain.entities.mission.ControlResource import kotlinx.serialization.Serializable diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/mission/Mission.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/mission/Mission.kt index 1c529b1cbe..462e7d7674 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/mission/Mission.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/mission/Mission.kt @@ -1,6 +1,6 @@ package fr.gouv.cnsp.monitorfish.domain.entities.mission -import fr.gouv.cnsp.monitorfish.domain.entities.control_units.LegacyControlUnit +import fr.gouv.cnsp.monitorfish.domain.entities.control_unit.LegacyControlUnit import fr.gouv.cnsp.monitorfish.domain.entities.mission.env_mission_action.EnvMissionAction import java.time.ZonedDateTime diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/mission/mission_actions/MissionAction.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/mission/mission_actions/MissionAction.kt index d9cc55dd06..7bb16cfe51 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/mission/mission_actions/MissionAction.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/mission/mission_actions/MissionAction.kt @@ -2,7 +2,7 @@ package fr.gouv.cnsp.monitorfish.domain.entities.mission.mission_actions import com.neovisionaries.i18n.CountryCode import fr.gouv.cnsp.monitorfish.config.Patchable -import fr.gouv.cnsp.monitorfish.domain.entities.control_units.LegacyControlUnit +import fr.gouv.cnsp.monitorfish.domain.entities.control_unit.LegacyControlUnit import java.time.ZonedDateTime data class MissionAction( diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/reporting/ReportingAndOccurrences.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/reporting/ReportingAndOccurrences.kt index 71a7eb3a8c..390031d32b 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/reporting/ReportingAndOccurrences.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/reporting/ReportingAndOccurrences.kt @@ -1,6 +1,6 @@ package fr.gouv.cnsp.monitorfish.domain.entities.reporting -import fr.gouv.cnsp.monitorfish.domain.entities.control_units.LegacyControlUnit +import fr.gouv.cnsp.monitorfish.domain.entities.control_unit.LegacyControlUnit data class ReportingAndOccurrences( val otherOccurrencesOfSameAlert: List, diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/repositories/ControlUnitRepository.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/repositories/ControlUnitRepository.kt new file mode 100644 index 0000000000..cc18b5b2fa --- /dev/null +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/repositories/ControlUnitRepository.kt @@ -0,0 +1,7 @@ +package fr.gouv.cnsp.monitorfish.domain.repositories + +import fr.gouv.cnsp.monitorfish.domain.use_cases.control_units.dtos.FullControlUnit + +interface ControlUnitRepository { + fun findAll(): List +} diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/repositories/LegacyControlUnitRepository.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/repositories/LegacyControlUnitRepository.kt index 7dd6c8f13c..f4287e3f53 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/repositories/LegacyControlUnitRepository.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/repositories/LegacyControlUnitRepository.kt @@ -1,6 +1,6 @@ package fr.gouv.cnsp.monitorfish.domain.repositories -import fr.gouv.cnsp.monitorfish.domain.entities.control_units.LegacyControlUnit +import fr.gouv.cnsp.monitorfish.domain.entities.control_unit.LegacyControlUnit interface LegacyControlUnitRepository { fun findAll(): List diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/repositories/MissionRepository.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/repositories/MissionRepository.kt index 06ae213bc3..c73ef8bdd0 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/repositories/MissionRepository.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/repositories/MissionRepository.kt @@ -1,6 +1,6 @@ package fr.gouv.cnsp.monitorfish.domain.repositories -import fr.gouv.cnsp.monitorfish.domain.entities.control_units.LegacyControlUnit +import fr.gouv.cnsp.monitorfish.domain.entities.control_unit.LegacyControlUnit import fr.gouv.cnsp.monitorfish.domain.entities.mission.Mission import fr.gouv.cnsp.monitorfish.domain.exceptions.CouldNotFindException import kotlinx.coroutines.CoroutineScope diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/control_units/GetAllControlUnits.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/control_units/GetAllControlUnits.kt new file mode 100644 index 0000000000..2ab16c62da --- /dev/null +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/control_units/GetAllControlUnits.kt @@ -0,0 +1,14 @@ +package fr.gouv.cnsp.monitorfish.domain.use_cases.control_units + +import fr.gouv.cnsp.monitorfish.config.UseCase +import fr.gouv.cnsp.monitorfish.domain.repositories.ControlUnitRepository +import fr.gouv.cnsp.monitorfish.domain.use_cases.control_units.dtos.FullControlUnit + +@UseCase +class GetAllControlUnits( + private val controlUnitsRepository: ControlUnitRepository, +) { + fun execute(): List { + return controlUnitsRepository.findAll() + } +} diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/control_units/GetAllLegacyControlUnits.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/control_units/GetAllLegacyControlUnits.kt index ac0fe49089..d65ee9cc32 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/control_units/GetAllLegacyControlUnits.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/control_units/GetAllLegacyControlUnits.kt @@ -1,14 +1,14 @@ package fr.gouv.cnsp.monitorfish.domain.use_cases.control_units import fr.gouv.cnsp.monitorfish.config.UseCase -import fr.gouv.cnsp.monitorfish.domain.entities.control_units.LegacyControlUnit +import fr.gouv.cnsp.monitorfish.domain.entities.control_unit.LegacyControlUnit import fr.gouv.cnsp.monitorfish.domain.repositories.LegacyControlUnitRepository @UseCase class GetAllLegacyControlUnits( - private val controlUnitsRepository: LegacyControlUnitRepository, + private val legacyControlUnitsRepository: LegacyControlUnitRepository, ) { fun execute(): List { - return controlUnitsRepository.findAll() + return legacyControlUnitsRepository.findAll() } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/control_units/dtos/FullControlUnit.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/control_units/dtos/FullControlUnit.kt new file mode 100644 index 0000000000..32c07bb67f --- /dev/null +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/control_units/dtos/FullControlUnit.kt @@ -0,0 +1,22 @@ +package fr.gouv.cnsp.monitorfish.domain.use_cases.control_units.dtos + +import fr.gouv.cnsp.monitorfish.domain.entities.control_unit.ControlUnitAdministration +import fr.gouv.cnsp.monitorfish.domain.entities.control_unit.ControlUnitContact +import fr.gouv.cnsp.monitorfish.domain.entities.control_unit.ControlUnitDepartmentArea +import fr.gouv.cnsp.monitorfish.domain.entities.control_unit.FullControlUnitResource + +data class FullControlUnit( + val id: Int, + val areaNote: String?, + val administration: ControlUnitAdministration, + val administrationId: Int, + val controlUnitContactIds: List, + val controlUnitContacts: List, + val controlUnitResourceIds: List, + val controlUnitResources: List, + val departmentArea: ControlUnitDepartmentArea?, + val departmentAreaInseeCode: String?, + val isArchived: Boolean, + val name: String, + val termsNote: String?, +) diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/mission_actions/dtos/ActivityReport.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/mission_actions/dtos/ActivityReport.kt index 6af99732e7..4cd8dec0bc 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/mission_actions/dtos/ActivityReport.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/mission_actions/dtos/ActivityReport.kt @@ -1,6 +1,6 @@ package fr.gouv.cnsp.monitorfish.domain.use_cases.mission.mission_actions.dtos -import fr.gouv.cnsp.monitorfish.domain.entities.control_units.LegacyControlUnit +import fr.gouv.cnsp.monitorfish.domain.entities.control_unit.LegacyControlUnit import fr.gouv.cnsp.monitorfish.domain.entities.mission.mission_actions.MissionAction import fr.gouv.cnsp.monitorfish.domain.entities.mission.mission_actions.actrep.ActivityCode import fr.gouv.cnsp.monitorfish.domain.entities.vessel.Vessel diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/dtos/PriorNotificationSubscriber.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/dtos/PriorNotificationSubscriber.kt index 839af3bd68..2067a8a699 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/dtos/PriorNotificationSubscriber.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/dtos/PriorNotificationSubscriber.kt @@ -1,6 +1,6 @@ package fr.gouv.cnsp.monitorfish.domain.use_cases.prior_notification.dtos -import fr.gouv.cnsp.monitorfish.domain.entities.control_units.LegacyControlUnit +import fr.gouv.cnsp.monitorfish.domain.entities.control_unit.LegacyControlUnit import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotificationPortSubscription import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotificationSegmentSubscription import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotificationVesselSubscription diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/reporting/AddReporting.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/reporting/AddReporting.kt index ae35758512..28f6088556 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/reporting/AddReporting.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/reporting/AddReporting.kt @@ -1,7 +1,7 @@ package fr.gouv.cnsp.monitorfish.domain.use_cases.reporting import fr.gouv.cnsp.monitorfish.config.UseCase -import fr.gouv.cnsp.monitorfish.domain.entities.control_units.LegacyControlUnit +import fr.gouv.cnsp.monitorfish.domain.entities.control_unit.LegacyControlUnit import fr.gouv.cnsp.monitorfish.domain.entities.reporting.InfractionSuspicion import fr.gouv.cnsp.monitorfish.domain.entities.reporting.InfractionSuspicionOrObservationType import fr.gouv.cnsp.monitorfish.domain.entities.reporting.Reporting diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/reporting/GetAllCurrentReportings.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/reporting/GetAllCurrentReportings.kt index 0dd0dce89d..a56b8c68f2 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/reporting/GetAllCurrentReportings.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/reporting/GetAllCurrentReportings.kt @@ -1,7 +1,7 @@ package fr.gouv.cnsp.monitorfish.domain.use_cases.reporting import fr.gouv.cnsp.monitorfish.config.UseCase -import fr.gouv.cnsp.monitorfish.domain.entities.control_units.LegacyControlUnit +import fr.gouv.cnsp.monitorfish.domain.entities.control_unit.LegacyControlUnit import fr.gouv.cnsp.monitorfish.domain.entities.reporting.InfractionSuspicionOrObservationType import fr.gouv.cnsp.monitorfish.domain.entities.reporting.Reporting import fr.gouv.cnsp.monitorfish.domain.entities.reporting.ReportingType 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 7f61b0670f..2604fad88a 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 @@ -3,7 +3,7 @@ package fr.gouv.cnsp.monitorfish.domain.use_cases.reporting import fr.gouv.cnsp.monitorfish.config.UseCase import fr.gouv.cnsp.monitorfish.domain.entities.alerts.type.AlertType import fr.gouv.cnsp.monitorfish.domain.entities.alerts.type.AlertTypeMapping -import fr.gouv.cnsp.monitorfish.domain.entities.control_units.LegacyControlUnit +import fr.gouv.cnsp.monitorfish.domain.entities.control_unit.LegacyControlUnit import fr.gouv.cnsp.monitorfish.domain.entities.reporting.* import fr.gouv.cnsp.monitorfish.domain.entities.vessel.VesselIdentifier import fr.gouv.cnsp.monitorfish.domain.exceptions.NatinfCodeNotFoundException diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/reporting/UpdateReporting.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/reporting/UpdateReporting.kt index d15cadf8c7..97775748d2 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/reporting/UpdateReporting.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/reporting/UpdateReporting.kt @@ -1,7 +1,7 @@ package fr.gouv.cnsp.monitorfish.domain.use_cases.reporting import fr.gouv.cnsp.monitorfish.config.UseCase -import fr.gouv.cnsp.monitorfish.domain.entities.control_units.LegacyControlUnit +import fr.gouv.cnsp.monitorfish.domain.entities.control_unit.LegacyControlUnit import fr.gouv.cnsp.monitorfish.domain.entities.reporting.* import fr.gouv.cnsp.monitorfish.domain.repositories.ReportingRepository import fr.gouv.cnsp.monitorfish.domain.use_cases.control_units.GetAllLegacyControlUnits diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/ActivityReportDataOutput.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/ActivityReportDataOutput.kt index 5f421a273c..4910e09be8 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/ActivityReportDataOutput.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/ActivityReportDataOutput.kt @@ -1,6 +1,6 @@ package fr.gouv.cnsp.monitorfish.infrastructure.api.outputs -import fr.gouv.cnsp.monitorfish.domain.entities.control_units.LegacyControlUnit +import fr.gouv.cnsp.monitorfish.domain.entities.control_unit.LegacyControlUnit import fr.gouv.cnsp.monitorfish.domain.entities.mission.mission_actions.actrep.ActivityCode import fr.gouv.cnsp.monitorfish.domain.use_cases.mission.mission_actions.dtos.ActivityReport diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/InfractionSuspicionDataOutput.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/InfractionSuspicionDataOutput.kt index 7636e24965..4c691c8b30 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/InfractionSuspicionDataOutput.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/InfractionSuspicionDataOutput.kt @@ -1,6 +1,6 @@ package fr.gouv.cnsp.monitorfish.infrastructure.api.outputs -import fr.gouv.cnsp.monitorfish.domain.entities.control_units.LegacyControlUnit +import fr.gouv.cnsp.monitorfish.domain.entities.control_unit.LegacyControlUnit import fr.gouv.cnsp.monitorfish.domain.entities.reporting.InfractionSuspicion import fr.gouv.cnsp.monitorfish.domain.entities.reporting.ReportingActor diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/MissionActionDataOutput.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/MissionActionDataOutput.kt index e96a835acb..5cc5d21f9f 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/MissionActionDataOutput.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/MissionActionDataOutput.kt @@ -1,7 +1,7 @@ package fr.gouv.cnsp.monitorfish.infrastructure.api.outputs import com.neovisionaries.i18n.CountryCode -import fr.gouv.cnsp.monitorfish.domain.entities.control_units.LegacyControlUnit +import fr.gouv.cnsp.monitorfish.domain.entities.control_unit.LegacyControlUnit import fr.gouv.cnsp.monitorfish.domain.entities.mission.mission_actions.* import fr.gouv.cnsp.monitorfish.domain.entities.mission.mission_actions.Completion import java.time.ZonedDateTime diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/MissionWithActionsDataOutput.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/MissionWithActionsDataOutput.kt index 1058fbb58d..8d9432a496 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/MissionWithActionsDataOutput.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/MissionWithActionsDataOutput.kt @@ -1,6 +1,6 @@ package fr.gouv.cnsp.monitorfish.infrastructure.api.outputs -import fr.gouv.cnsp.monitorfish.domain.entities.control_units.LegacyControlUnit +import fr.gouv.cnsp.monitorfish.domain.entities.control_unit.LegacyControlUnit import fr.gouv.cnsp.monitorfish.domain.entities.mission.* import java.time.ZonedDateTime diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/ObservationDataOutput.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/ObservationDataOutput.kt index d5f2b2d30f..6b12dc5db3 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/ObservationDataOutput.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/ObservationDataOutput.kt @@ -1,6 +1,6 @@ package fr.gouv.cnsp.monitorfish.infrastructure.api.outputs -import fr.gouv.cnsp.monitorfish.domain.entities.control_units.LegacyControlUnit +import fr.gouv.cnsp.monitorfish.domain.entities.control_unit.LegacyControlUnit import fr.gouv.cnsp.monitorfish.domain.entities.reporting.Observation import fr.gouv.cnsp.monitorfish.domain.entities.reporting.ReportingActor diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/ReportingDataOutput.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/ReportingDataOutput.kt index 6f15faf0ef..c2f1abd6f3 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/ReportingDataOutput.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/ReportingDataOutput.kt @@ -2,7 +2,7 @@ package fr.gouv.cnsp.monitorfish.infrastructure.api.outputs import com.neovisionaries.i18n.CountryCode import fr.gouv.cnsp.monitorfish.domain.entities.alerts.type.AlertType -import fr.gouv.cnsp.monitorfish.domain.entities.control_units.LegacyControlUnit +import fr.gouv.cnsp.monitorfish.domain.entities.control_unit.LegacyControlUnit import fr.gouv.cnsp.monitorfish.domain.entities.reporting.InfractionSuspicion import fr.gouv.cnsp.monitorfish.domain.entities.reporting.Observation import fr.gouv.cnsp.monitorfish.domain.entities.reporting.Reporting diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/cache/CaffeineConfiguration.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/cache/CaffeineConfiguration.kt index 7543a3c463..f2ba7e253c 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/cache/CaffeineConfiguration.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/cache/CaffeineConfiguration.kt @@ -19,6 +19,7 @@ class CaffeineConfiguration { // Control Units val controlUnits = "control_units" + val legacyControlUnits = "legacy_control_units" // FAO Areas val faoAreas = "fao_areas" @@ -95,6 +96,7 @@ class CaffeineConfiguration { // Control Units val controlUnitsCache = buildMinutesCache(controlUnits, ticker, oneDay) + val legacyControlUnitsCache = buildMinutesCache(legacyControlUnits, ticker, oneDay) // FAO Areas val faoAreasCache = buildMinutesCache(faoAreas, ticker, oneWeek) @@ -188,6 +190,7 @@ class CaffeineConfiguration { gearsCache, infractionCache, infractionsCache, + legacyControlUnitsCache, logbookCache, logbookRawMessageCache, missionControlUnitsCache, diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/APIControlUnitRepository.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/APIControlUnitRepository.kt new file mode 100644 index 0000000000..4a21fdc37e --- /dev/null +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/APIControlUnitRepository.kt @@ -0,0 +1,35 @@ +package fr.gouv.cnsp.monitorfish.infrastructure.monitorenv + +import fr.gouv.cnsp.monitorfish.config.ApiClient +import fr.gouv.cnsp.monitorfish.config.MonitorenvProperties +import fr.gouv.cnsp.monitorfish.domain.repositories.ControlUnitRepository +import fr.gouv.cnsp.monitorfish.domain.use_cases.control_units.dtos.FullControlUnit +import io.ktor.client.call.* +import io.ktor.client.request.* +import kotlinx.coroutines.runBlocking +import org.slf4j.Logger +import org.slf4j.LoggerFactory +import org.springframework.cache.annotation.Cacheable +import org.springframework.stereotype.Repository + +@Repository +class APIControlUnitRepository( + val monitorenvProperties: MonitorenvProperties, + val apiClient: ApiClient, +) : ControlUnitRepository { + private val logger: Logger = LoggerFactory.getLogger(APIControlUnitRepository::class.java) + + @Cacheable(value = ["control_units"]) + override fun findAll(): List = + runBlocking { + val missionsUrl = "${monitorenvProperties.url}/api/v2/control_units" + + try { + apiClient.httpClient.get(missionsUrl).body() + } catch (e: Exception) { + logger.error("Could not fetch control units at $missionsUrl", e) + + listOf() + } + } +} diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/APILegacyControlUnitRepository.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/APILegacyControlUnitRepository.kt index 6a9c48cfbc..30f20186e1 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/APILegacyControlUnitRepository.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/APILegacyControlUnitRepository.kt @@ -2,7 +2,7 @@ package fr.gouv.cnsp.monitorfish.infrastructure.monitorenv import fr.gouv.cnsp.monitorfish.config.ApiClient import fr.gouv.cnsp.monitorfish.config.MonitorenvProperties -import fr.gouv.cnsp.monitorfish.domain.entities.control_units.LegacyControlUnit +import fr.gouv.cnsp.monitorfish.domain.entities.control_unit.LegacyControlUnit import fr.gouv.cnsp.monitorfish.domain.repositories.LegacyControlUnitRepository import io.ktor.client.call.* import io.ktor.client.request.* @@ -19,7 +19,7 @@ class APILegacyControlUnitRepository( ) : LegacyControlUnitRepository { private val logger: Logger = LoggerFactory.getLogger(APILegacyControlUnitRepository::class.java) - @Cacheable(value = ["control_units"]) + @Cacheable(value = ["legacy_control_units"]) override fun findAll(): List = runBlocking { val missionsUrl = "${monitorenvProperties.url}/api/v1/control_units" diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/APIMissionRepository.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/APIMissionRepository.kt index 13b2af94c8..c269bf54fc 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/APIMissionRepository.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/APIMissionRepository.kt @@ -3,7 +3,7 @@ package fr.gouv.cnsp.monitorfish.infrastructure.monitorenv import com.github.benmanes.caffeine.cache.Caffeine import fr.gouv.cnsp.monitorfish.config.ApiClient import fr.gouv.cnsp.monitorfish.config.MonitorenvProperties -import fr.gouv.cnsp.monitorfish.domain.entities.control_units.LegacyControlUnit +import fr.gouv.cnsp.monitorfish.domain.entities.control_unit.LegacyControlUnit import fr.gouv.cnsp.monitorfish.domain.entities.mission.Mission import fr.gouv.cnsp.monitorfish.domain.exceptions.CouldNotFindException import fr.gouv.cnsp.monitorfish.domain.repositories.MissionRepository diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/input/MissionDataResponse.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/input/MissionDataResponse.kt index 086b223b76..e77459df9a 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/input/MissionDataResponse.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/input/MissionDataResponse.kt @@ -1,6 +1,6 @@ package fr.gouv.cnsp.monitorfish.infrastructure.monitorenv.input -import fr.gouv.cnsp.monitorfish.domain.entities.control_units.LegacyControlUnit +import fr.gouv.cnsp.monitorfish.domain.entities.control_unit.LegacyControlUnit import fr.gouv.cnsp.monitorfish.domain.entities.mission.* import kotlinx.serialization.Serializable import java.time.ZonedDateTime diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/mission_actions/GetActivityReportsUTests.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/mission_actions/GetActivityReportsUTests.kt index 4a185b9932..0dd1ee3137 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/mission_actions/GetActivityReportsUTests.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/mission/mission_actions/GetActivityReportsUTests.kt @@ -4,7 +4,7 @@ import com.neovisionaries.i18n.CountryCode import com.nhaarman.mockitokotlin2.any import com.nhaarman.mockitokotlin2.eq import com.nhaarman.mockitokotlin2.given -import fr.gouv.cnsp.monitorfish.domain.entities.control_units.LegacyControlUnit +import fr.gouv.cnsp.monitorfish.domain.entities.control_unit.LegacyControlUnit import fr.gouv.cnsp.monitorfish.domain.entities.mission.Mission import fr.gouv.cnsp.monitorfish.domain.entities.mission.MissionSource import fr.gouv.cnsp.monitorfish.domain.entities.mission.MissionType diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/MissionActionsControllerITests.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/MissionActionsControllerITests.kt index e64de4493a..edecd1c1ca 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/MissionActionsControllerITests.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/MissionActionsControllerITests.kt @@ -4,7 +4,7 @@ import com.fasterxml.jackson.databind.ObjectMapper import com.neovisionaries.i18n.CountryCode import com.nhaarman.mockitokotlin2.* import fr.gouv.cnsp.monitorfish.config.SentryConfig -import fr.gouv.cnsp.monitorfish.domain.entities.control_units.LegacyControlUnit +import fr.gouv.cnsp.monitorfish.domain.entities.control_unit.LegacyControlUnit import fr.gouv.cnsp.monitorfish.domain.entities.mission.mission_actions.* import fr.gouv.cnsp.monitorfish.domain.entities.mission.mission_actions.actrep.ActivityCode import fr.gouv.cnsp.monitorfish.domain.entities.mission.mission_actions.actrep.JointDeploymentPlan diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/ReportingControllerITests.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/ReportingControllerITests.kt index 3d68a1d99c..26f12a75a7 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/ReportingControllerITests.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/ReportingControllerITests.kt @@ -7,7 +7,7 @@ import com.nhaarman.mockitokotlin2.eq import com.nhaarman.mockitokotlin2.given import fr.gouv.cnsp.monitorfish.config.MapperConfiguration import fr.gouv.cnsp.monitorfish.config.SentryConfig -import fr.gouv.cnsp.monitorfish.domain.entities.control_units.LegacyControlUnit +import fr.gouv.cnsp.monitorfish.domain.entities.control_unit.LegacyControlUnit import fr.gouv.cnsp.monitorfish.domain.entities.reporting.InfractionSuspicion import fr.gouv.cnsp.monitorfish.domain.entities.reporting.Reporting import fr.gouv.cnsp.monitorfish.domain.entities.reporting.ReportingActor diff --git a/infra/docker/.env.local.defaults b/infra/docker/.env.local.defaults index 6349a28080..2096bc5ce7 100644 --- a/infra/docker/.env.local.defaults +++ b/infra/docker/.env.local.defaults @@ -50,11 +50,12 @@ MONITORENV_POSTGRES_PASSWORD=postgres #----------------------------------------------------------- # Feature flags +MONITORENV_FRONTEND_DASHBOARD_ENABLED=true MONITORENV_FRONTEND_MISSION_FORM_AUTO_UPDATE=true MONITORENV_FRONTEND_MISSION_FORM_AUTO_SAVE_ENABLED=true -MONITORENV_FRONTEND_VIGILANCE_AREA_ENABLED=true MONITORENV_FRONTEND_REPORTING_FORM_AUTO_SAVE_ENABLED=true MONITORENV_FRONTEND_REPORTING_FORM_AUTO_UPDATE=true +MONITORENV_FRONTEND_VIGILANCE_AREA_ENABLED=true #----------------------------------------------------------- # GeoServer @@ -72,6 +73,11 @@ MONITORENV_FRONTEND_GOOGLEMAPS_API_KEY= MONITORENV_FRONTEND_MAPBOX_KEY= +#----------------------------------------------------------- +# Metabase + +MONITORENV_FRONTEND_METABASE_URL=https://metabase.din.developpement-durable.gouv.fr + #----------------------------------------------------------- # Sentry diff --git a/infra/docker/docker-compose.monitorenv.dev.yml b/infra/docker/docker-compose.monitorenv.dev.yml index ec4c88e2e1..f76941b8dc 100644 --- a/infra/docker/docker-compose.monitorenv.dev.yml +++ b/infra/docker/docker-compose.monitorenv.dev.yml @@ -18,6 +18,8 @@ services: - HOST_IP=127.0.0.1 - MONITORFISH_API_KEY=${MONITORENV_MONITORFISH_API_KEY} - SPRING_PROFILES_ACTIVE=test + - FRONTEND_DASHBOARD_ENABLED=${MONITORENV_FRONTEND_DASHBOARD_ENABLED} + - FRONTEND_METABASE_URL=${MONITORENV_FRONTEND_METABASE_URL} - FRONTEND_REPORTING_FORM_AUTO_SAVE_ENABLED=${MONITORENV_FRONTEND_REPORTING_FORM_AUTO_SAVE_ENABLED} - FRONTEND_REPORTING_FORM_AUTO_UPDATE=${MONITORENV_FRONTEND_REPORTING_FORM_AUTO_UPDATE} - FRONTEND_VIGILANCE_AREA_ENABLED=${MONITORENV_FRONTEND_VIGILANCE_AREA_ENABLED} From abdb57a3e03685b2f7b0293cdd7fdc92a292057e Mon Sep 17 00:00:00 2001 From: Ivan Gabriele Date: Wed, 23 Oct 2024 15:01:42 +0200 Subject: [PATCH 11/59] Rename ControlUnitAdministration to Administration in Backend --- .../domain/entities/administration/Administration.kt | 7 +++++++ .../entities/control_unit/ControlUnitAdministration.kt | 7 ------- .../entities/control_unit/ControlUnitDepartmentArea.kt | 1 + .../domain/use_cases/control_units/dtos/FullControlUnit.kt | 5 ++--- .../control_units/dtos}/FullControlUnitResource.kt | 6 +++++- 5 files changed, 15 insertions(+), 11 deletions(-) create mode 100644 backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/administration/Administration.kt delete mode 100644 backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/control_unit/ControlUnitAdministration.kt rename backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/{entities/control_unit => use_cases/control_units/dtos}/FullControlUnitResource.kt (50%) diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/administration/Administration.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/administration/Administration.kt new file mode 100644 index 0000000000..4cbad4e388 --- /dev/null +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/administration/Administration.kt @@ -0,0 +1,7 @@ +package fr.gouv.cnsp.monitorfish.domain.entities.administration + +data class Administration( + val id: Int, + val isArchived: Boolean, + val name: String, +) diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/control_unit/ControlUnitAdministration.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/control_unit/ControlUnitAdministration.kt deleted file mode 100644 index 5817d0e5d0..0000000000 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/control_unit/ControlUnitAdministration.kt +++ /dev/null @@ -1,7 +0,0 @@ -package fr.gouv.cnsp.monitorfish.domain.entities.control_unit - -data class ControlUnitAdministration( - val id: Int, - val isArchived: Boolean, - val name: String, -) diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/control_unit/ControlUnitDepartmentArea.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/control_unit/ControlUnitDepartmentArea.kt index 0df0524f51..a8752279fc 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/control_unit/ControlUnitDepartmentArea.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/control_unit/ControlUnitDepartmentArea.kt @@ -1,5 +1,6 @@ package fr.gouv.cnsp.monitorfish.domain.entities.control_unit +// TODO Maybe merge `districts` from MonitorFish into MonitorEnv `departmentAreas`? data class ControlUnitDepartmentArea( /** `inseeCode` is the ID. */ val inseeCode: String, diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/control_units/dtos/FullControlUnit.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/control_units/dtos/FullControlUnit.kt index 32c07bb67f..68c4d1864c 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/control_units/dtos/FullControlUnit.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/control_units/dtos/FullControlUnit.kt @@ -1,14 +1,13 @@ package fr.gouv.cnsp.monitorfish.domain.use_cases.control_units.dtos -import fr.gouv.cnsp.monitorfish.domain.entities.control_unit.ControlUnitAdministration +import fr.gouv.cnsp.monitorfish.domain.entities.administration.Administration import fr.gouv.cnsp.monitorfish.domain.entities.control_unit.ControlUnitContact import fr.gouv.cnsp.monitorfish.domain.entities.control_unit.ControlUnitDepartmentArea -import fr.gouv.cnsp.monitorfish.domain.entities.control_unit.FullControlUnitResource data class FullControlUnit( val id: Int, val areaNote: String?, - val administration: ControlUnitAdministration, + val administration: Administration, val administrationId: Int, val controlUnitContactIds: List, val controlUnitContacts: List, diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/control_unit/FullControlUnitResource.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/control_units/dtos/FullControlUnitResource.kt similarity index 50% rename from backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/control_unit/FullControlUnitResource.kt rename to backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/control_units/dtos/FullControlUnitResource.kt index 58c43ef3b8..e549a0a1ac 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/control_unit/FullControlUnitResource.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/control_units/dtos/FullControlUnitResource.kt @@ -1,4 +1,8 @@ -package fr.gouv.cnsp.monitorfish.domain.entities.control_unit +package fr.gouv.cnsp.monitorfish.domain.use_cases.control_units.dtos + +import fr.gouv.cnsp.monitorfish.domain.entities.control_unit.ControlUnit +import fr.gouv.cnsp.monitorfish.domain.entities.control_unit.ControlUnitResourceType +import fr.gouv.cnsp.monitorfish.domain.entities.control_unit.ControlUnitStation data class FullControlUnitResource( val id: Int, From 6a3a2fe013dcad841e7ad590574290b172a19d53 Mon Sep 17 00:00:00 2001 From: Ivan Gabriele Date: Wed, 23 Oct 2024 15:30:09 +0200 Subject: [PATCH 12/59] Add GetPriorNotificationSubscribers use case in Backend --- .../PriorNotificationSubscribersFilter.kt | 7 ++ .../PriorNotificationSubscribersSortColumn.kt | 5 ++ .../GetPriorNotificationSubscribers.kt | 90 +++++++++++++++++++ .../dtos/PriorNotificationSubscriber.kt | 4 +- 4 files changed, 104 insertions(+), 2 deletions(-) create mode 100644 backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/prior_notification/filters/PriorNotificationSubscribersFilter.kt create mode 100644 backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/prior_notification/sorters/PriorNotificationSubscribersSortColumn.kt create mode 100644 backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationSubscribers.kt diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/prior_notification/filters/PriorNotificationSubscribersFilter.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/prior_notification/filters/PriorNotificationSubscribersFilter.kt new file mode 100644 index 0000000000..5ea5fdb1c1 --- /dev/null +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/prior_notification/filters/PriorNotificationSubscribersFilter.kt @@ -0,0 +1,7 @@ +package fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.filters + +data class PriorNotificationSubscribersFilter( + val administrationId: Int? = null, + val portLocode: String? = null, + val searchQuery: String? = null, +) diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/prior_notification/sorters/PriorNotificationSubscribersSortColumn.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/prior_notification/sorters/PriorNotificationSubscribersSortColumn.kt new file mode 100644 index 0000000000..0f81e8b233 --- /dev/null +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/prior_notification/sorters/PriorNotificationSubscribersSortColumn.kt @@ -0,0 +1,5 @@ +package fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.sorters + +enum class PriorNotificationSubscribersSortColumn { + NAME, +} diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationSubscribers.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationSubscribers.kt new file mode 100644 index 0000000000..c000827e9f --- /dev/null +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationSubscribers.kt @@ -0,0 +1,90 @@ +package fr.gouv.cnsp.monitorfish.domain.use_cases.prior_notification + +import fr.gouv.cnsp.monitorfish.config.UseCase +import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.filters.PriorNotificationSubscribersFilter +import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.sorters.PriorNotificationSubscribersSortColumn +import fr.gouv.cnsp.monitorfish.domain.repositories.* +import fr.gouv.cnsp.monitorfish.domain.use_cases.prior_notification.dtos.PriorNotificationSubscriber +import org.springframework.data.domain.Sort + +@UseCase +class GetPriorNotificationSubscribers( + private val controlUnitRepository: ControlUnitRepository, + private val pnoPortSubscriptionRepository: PnoPortSubscriptionRepository, + private val pnoSegmentSubscriptionRepository: PnoSegmentSubscriptionRepository, + private val pnoVesselSubscriptionRepository: PnoVesselSubscriptionRepository, +) { + fun execute( + filter: PriorNotificationSubscribersFilter, + sortColumn: PriorNotificationSubscribersSortColumn, + sortDirection: Sort.Direction, + ): List { + val priorNotificationSubscribers = getPriorNotificationSubscribers() + val filteredPriorNotificationSubscribers = + filterPriorNotificationSubscribers( + subscribers = priorNotificationSubscribers, + filter = filter, + ) + + return sortPriorNotificationSubscribers( + subscribers = filteredPriorNotificationSubscribers, + sortColumn = sortColumn, + sortDirection = sortDirection, + ) + } + + private fun getPriorNotificationSubscribers(): List { + return controlUnitRepository.findAll().map { controlUnit -> + val portSubscriptions = pnoPortSubscriptionRepository.findByControlUnitId(controlUnit.id) + val segmentSubscriptions = pnoSegmentSubscriptionRepository.findByControlUnitId(controlUnit.id) + val vesselSubscriptions = pnoVesselSubscriptionRepository.findByControlUnitId(controlUnit.id) + + PriorNotificationSubscriber( + controlUnit = controlUnit, + portSubscriptions = portSubscriptions, + segmentSubscriptions = segmentSubscriptions, + vesselSubscriptions = vesselSubscriptions, + ) + } + } + + private fun filterPriorNotificationSubscribers( + subscribers: List, + filter: PriorNotificationSubscribersFilter, + ): List { + return subscribers.filter { subscriber -> + val administrationIdMatches = + filter.administrationId?.let { + subscriber.controlUnit.administration.id == it + } != false + + val portLocodeMatches = + filter.portLocode?.let { + subscriber.portSubscriptions.any { portSubscription -> portSubscription.portLocode == it } + } != false + + val searchQueryMatches = + filter.searchQuery?.let { + subscriber.controlUnit.name.contains(it, ignoreCase = true) + } != false + + administrationIdMatches && portLocodeMatches && searchQueryMatches + } + } + + private fun sortPriorNotificationSubscribers( + subscribers: List, + sortColumn: PriorNotificationSubscribersSortColumn, + sortDirection: Sort.Direction, + ): List { + val comparator = + when (sortColumn) { + PriorNotificationSubscribersSortColumn.NAME -> + compareBy { it.controlUnit.name } + } + + return subscribers.sortedWith( + if (sortDirection == Sort.Direction.ASC) comparator else comparator.reversed(), + ) + } +} diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/dtos/PriorNotificationSubscriber.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/dtos/PriorNotificationSubscriber.kt index 2067a8a699..d8be8b78cf 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/dtos/PriorNotificationSubscriber.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/dtos/PriorNotificationSubscriber.kt @@ -1,12 +1,12 @@ package fr.gouv.cnsp.monitorfish.domain.use_cases.prior_notification.dtos -import fr.gouv.cnsp.monitorfish.domain.entities.control_unit.LegacyControlUnit import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotificationPortSubscription import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotificationSegmentSubscription import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotificationVesselSubscription +import fr.gouv.cnsp.monitorfish.domain.use_cases.control_units.dtos.FullControlUnit data class PriorNotificationSubscriber( - val controlUnit: LegacyControlUnit, + val controlUnit: FullControlUnit, val portSubscriptions: List, val segmentSubscriptions: List, val vesselSubscriptions: List, From 3de69244d6bd464ef17557edb51c329e8413305f Mon Sep 17 00:00:00 2001 From: Ivan Gabriele Date: Wed, 23 Oct 2024 15:43:40 +0200 Subject: [PATCH 13/59] Optimize etPriorNotificationSubscribers use case in Backend --- .../PnoPortSubscriptionRepository.kt | 2 ++ .../PnoSegmentSubscriptionRepository.kt | 2 ++ .../PnoVesselSubscriptionRepository.kt | 2 ++ .../GetPriorNotificationSubscriber.kt | 2 +- .../GetPriorNotificationSubscribers.kt | 27 +++++++++++++------ .../JpaPnoPortSubscriptionRepository.kt | 5 ++++ .../JpaPnoSegmentSubscriptionRepository.kt | 5 ++++ .../JpaPnoVesselSubscriptionRepository.kt | 5 ++++ 8 files changed, 41 insertions(+), 9 deletions(-) diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/repositories/PnoPortSubscriptionRepository.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/repositories/PnoPortSubscriptionRepository.kt index 665a4ad6ad..1f4e1adce8 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/repositories/PnoPortSubscriptionRepository.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/repositories/PnoPortSubscriptionRepository.kt @@ -3,6 +3,8 @@ package fr.gouv.cnsp.monitorfish.domain.repositories import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotificationPortSubscription interface PnoPortSubscriptionRepository { + fun findAll(): List + fun findByControlUnitId(controlUnitId: Int): List fun has(portLocode: String): Boolean diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/repositories/PnoSegmentSubscriptionRepository.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/repositories/PnoSegmentSubscriptionRepository.kt index 76e5e8b2f9..e087e848cc 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/repositories/PnoSegmentSubscriptionRepository.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/repositories/PnoSegmentSubscriptionRepository.kt @@ -3,6 +3,8 @@ package fr.gouv.cnsp.monitorfish.domain.repositories import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotificationSegmentSubscription interface PnoSegmentSubscriptionRepository { + fun findAll(): List + fun findByControlUnitId(controlUnitId: Int): List fun has( diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/repositories/PnoVesselSubscriptionRepository.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/repositories/PnoVesselSubscriptionRepository.kt index 72a7ab5a0b..165af3dade 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/repositories/PnoVesselSubscriptionRepository.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/repositories/PnoVesselSubscriptionRepository.kt @@ -3,6 +3,8 @@ package fr.gouv.cnsp.monitorfish.domain.repositories import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotificationVesselSubscription interface PnoVesselSubscriptionRepository { + fun findAll(): List + fun findByControlUnitId(controlUnitId: Int): List fun has(vesselId: Int): Boolean diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationSubscriber.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationSubscriber.kt index 2b13221b17..6f49320ff1 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationSubscriber.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationSubscriber.kt @@ -8,7 +8,7 @@ import fr.gouv.cnsp.monitorfish.domain.use_cases.prior_notification.dtos.PriorNo @UseCase class GetPriorNotificationSubscriber( - private val controlUnitRepository: LegacyControlUnitRepository, + private val controlUnitRepository: ControlUnitRepository, private val pnoPortSubscriptionRepository: PnoPortSubscriptionRepository, private val pnoSegmentSubscriptionRepository: PnoSegmentSubscriptionRepository, private val pnoVesselSubscriptionRepository: PnoVesselSubscriptionRepository, diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationSubscribers.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationSubscribers.kt index c000827e9f..4775d180f1 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationSubscribers.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationSubscribers.kt @@ -21,10 +21,7 @@ class GetPriorNotificationSubscribers( ): List { val priorNotificationSubscribers = getPriorNotificationSubscribers() val filteredPriorNotificationSubscribers = - filterPriorNotificationSubscribers( - subscribers = priorNotificationSubscribers, - filter = filter, - ) + filterPriorNotificationSubscribers(subscribers = priorNotificationSubscribers, filter = filter) return sortPriorNotificationSubscribers( subscribers = filteredPriorNotificationSubscribers, @@ -34,10 +31,24 @@ class GetPriorNotificationSubscribers( } private fun getPriorNotificationSubscribers(): List { - return controlUnitRepository.findAll().map { controlUnit -> - val portSubscriptions = pnoPortSubscriptionRepository.findByControlUnitId(controlUnit.id) - val segmentSubscriptions = pnoSegmentSubscriptionRepository.findByControlUnitId(controlUnit.id) - val vesselSubscriptions = pnoVesselSubscriptionRepository.findByControlUnitId(controlUnit.id) + val allControlUnits = controlUnitRepository.findAll() + val allPortSubscriptions = pnoPortSubscriptionRepository.findAll() + val allSegmentSubscriptions = pnoSegmentSubscriptionRepository.findAll() + val allVesselSubscriptions = pnoVesselSubscriptionRepository.findAll() + + return allControlUnits.map { controlUnit -> + val portSubscriptions = + allPortSubscriptions.filter { portSubscription -> + portSubscription.controlUnitId == controlUnit.id + } + val segmentSubscriptions = + allSegmentSubscriptions.filter { segmentSubscription -> + segmentSubscription.controlUnitId == controlUnit.id + } + val vesselSubscriptions = + allVesselSubscriptions.filter { vesselSubscription -> + vesselSubscription.controlUnitId == controlUnit.id + } PriorNotificationSubscriber( controlUnit = controlUnit, diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPnoPortSubscriptionRepository.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPnoPortSubscriptionRepository.kt index 6f3986c077..8fa68e4c87 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPnoPortSubscriptionRepository.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPnoPortSubscriptionRepository.kt @@ -9,6 +9,11 @@ import org.springframework.stereotype.Repository class JpaPnoPortSubscriptionRepository( private val dbPnoPortsSubscriptionsRepository: DBPnoPortsSubscriptionsRepository, ) : PnoPortSubscriptionRepository { + override fun findAll(): List { + return dbPnoPortsSubscriptionsRepository.findAll() + .map { it.toPriorNotificationPortSubscription() } + } + override fun findByControlUnitId(controlUnitId: Int): List { return dbPnoPortsSubscriptionsRepository.findByControlUnitId(controlUnitId) .map { it.toPriorNotificationPortSubscription() } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPnoSegmentSubscriptionRepository.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPnoSegmentSubscriptionRepository.kt index 6b67fd18ca..cf732f5329 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPnoSegmentSubscriptionRepository.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPnoSegmentSubscriptionRepository.kt @@ -9,6 +9,11 @@ import org.springframework.stereotype.Repository class JpaPnoSegmentSubscriptionRepository( private val dbPnoSegmentsSubscriptionsRepository: DBPnoSegmentsSubscriptionsRepository, ) : PnoSegmentSubscriptionRepository { + override fun findAll(): List { + return dbPnoSegmentsSubscriptionsRepository.findAll() + .map { it.toPriorNotificationSegmentSubscription() } + } + override fun findByControlUnitId(controlUnitId: Int): List { return dbPnoSegmentsSubscriptionsRepository.findByControlUnitId(controlUnitId) .map { it.toPriorNotificationSegmentSubscription() } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPnoVesselSubscriptionRepository.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPnoVesselSubscriptionRepository.kt index 48a870b0bd..3367fa7a18 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPnoVesselSubscriptionRepository.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPnoVesselSubscriptionRepository.kt @@ -9,6 +9,11 @@ import org.springframework.stereotype.Repository class JpaPnoVesselSubscriptionRepository( private val dbPnoVesselsSubscriptionsRepository: DBPnoVesselsSubscriptionsRepository, ) : PnoVesselSubscriptionRepository { + override fun findAll(): List { + return dbPnoVesselsSubscriptionsRepository.findAll() + .map { it.toPriorNotificationVesselSubscription() } + } + override fun findByControlUnitId(controlUnitId: Int): List { return dbPnoVesselsSubscriptionsRepository.findByControlUnitId(controlUnitId) .map { it.toPriorNotificationVesselSubscription() } From 0aab3445c18dc49b36faab18c29656556f9250fa Mon Sep 17 00:00:00 2001 From: Ivan Gabriele Date: Wed, 23 Oct 2024 17:16:14 +0200 Subject: [PATCH 14/59] Enrich prior notification subscriptions with related names in Backend --- .../PriorNotificationPortSubscription.kt | 1 + .../PriorNotificationSegmentSubscription.kt | 1 + .../PriorNotificationVesselSubscription.kt | 1 + .../GetPriorNotificationSubscriber.kt | 67 +++++++++++++++++-- .../GetPriorNotificationSubscribers.kt | 20 ++++-- .../entities/PnoPortSubscriptionEntity.kt | 1 + .../entities/PnoSegmentSubscriptionEntity.kt | 1 + .../entities/PnoVesselSubscriptionEntity.kt | 1 + 8 files changed, 83 insertions(+), 10 deletions(-) diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/prior_notification/PriorNotificationPortSubscription.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/prior_notification/PriorNotificationPortSubscription.kt index ae5c9694db..b7a505c239 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/prior_notification/PriorNotificationPortSubscription.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/prior_notification/PriorNotificationPortSubscription.kt @@ -3,5 +3,6 @@ package fr.gouv.cnsp.monitorfish.domain.entities.prior_notification data class PriorNotificationPortSubscription( val controlUnitId: Int, val portLocode: String, + val portName: String?, val hasSubscribedToAllPriorNotifications: Boolean, ) diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/prior_notification/PriorNotificationSegmentSubscription.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/prior_notification/PriorNotificationSegmentSubscription.kt index 465157cd9d..fb0ca8c554 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/prior_notification/PriorNotificationSegmentSubscription.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/prior_notification/PriorNotificationSegmentSubscription.kt @@ -3,4 +3,5 @@ package fr.gouv.cnsp.monitorfish.domain.entities.prior_notification data class PriorNotificationSegmentSubscription( val controlUnitId: Int, val segmentCode: String, + val segmentName: String?, ) diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/prior_notification/PriorNotificationVesselSubscription.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/prior_notification/PriorNotificationVesselSubscription.kt index 8c84901c1c..da9d8954ad 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/prior_notification/PriorNotificationVesselSubscription.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/prior_notification/PriorNotificationVesselSubscription.kt @@ -3,4 +3,5 @@ package fr.gouv.cnsp.monitorfish.domain.entities.prior_notification data class PriorNotificationVesselSubscription( val controlUnitId: Int, val vesselId: Int, + val vesselName: String?, ) diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationSubscriber.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationSubscriber.kt index 6f49320ff1..cde0f0986e 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationSubscriber.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationSubscriber.kt @@ -1,19 +1,33 @@ package fr.gouv.cnsp.monitorfish.domain.use_cases.prior_notification import fr.gouv.cnsp.monitorfish.config.UseCase +import fr.gouv.cnsp.monitorfish.domain.entities.fleet_segment.FleetSegment +import fr.gouv.cnsp.monitorfish.domain.entities.port.Port +import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotificationPortSubscription +import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotificationSegmentSubscription +import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotificationVesselSubscription +import fr.gouv.cnsp.monitorfish.domain.entities.vessel.Vessel import fr.gouv.cnsp.monitorfish.domain.exceptions.BackendUsageErrorCode import fr.gouv.cnsp.monitorfish.domain.exceptions.BackendUsageException import fr.gouv.cnsp.monitorfish.domain.repositories.* +import fr.gouv.cnsp.monitorfish.domain.use_cases.control_units.dtos.FullControlUnit import fr.gouv.cnsp.monitorfish.domain.use_cases.prior_notification.dtos.PriorNotificationSubscriber @UseCase class GetPriorNotificationSubscriber( private val controlUnitRepository: ControlUnitRepository, + private val fleetSegmentRepository: FleetSegmentRepository, private val pnoPortSubscriptionRepository: PnoPortSubscriptionRepository, private val pnoSegmentSubscriptionRepository: PnoSegmentSubscriptionRepository, private val pnoVesselSubscriptionRepository: PnoVesselSubscriptionRepository, + private val portRepository: PortRepository, + private val vesselRepository: VesselRepository, ) { fun execute(id: Int): PriorNotificationSubscriber { + val allFleetSegments = fleetSegmentRepository.findAll() + val allPorts = portRepository.findAll() + val allVessels = vesselRepository.findAll() + val controlUnit = controlUnitRepository.findAll().find { it.id == id } if (controlUnit == null) { throw BackendUsageException(BackendUsageErrorCode.NOT_FOUND) @@ -23,11 +37,54 @@ class GetPriorNotificationSubscriber( val segmentSubscriptions = pnoSegmentSubscriptionRepository.findByControlUnitId(id) val vesselSubscriptions = pnoVesselSubscriptionRepository.findByControlUnitId(id) - return PriorNotificationSubscriber( - controlUnit = controlUnit, - portSubscriptions = portSubscriptions, - segmentSubscriptions = segmentSubscriptions, - vesselSubscriptions = vesselSubscriptions, + return enrich( + controlUnit, + portSubscriptions, + segmentSubscriptions, + vesselSubscriptions, + allFleetSegments, + allPorts, + allVessels, ) } + + companion object { + fun enrich( + controlUnit: FullControlUnit, + portSubscriptions: List, + segmentSubscriptions: List, + vesselSubscriptions: List, + allFleetSegments: List, + allPorts: List, + allVessels: List, + ): PriorNotificationSubscriber { + portSubscriptions.any { portSubscription -> portSubscription.hasSubscribedToAllPriorNotifications } + + val namedPortSubscriptions = + portSubscriptions.map { portSubscription -> + val port = allPorts.find { it.locode == portSubscription.portLocode } + + return@map portSubscription.copy(portName = port?.name) + } + val namedSegmentSubscriptions = + segmentSubscriptions.map { fleetSegmentSubscription -> + val fleetSegment = allFleetSegments.find { it.segment == fleetSegmentSubscription.segmentCode } + + return@map fleetSegmentSubscription.copy(segmentName = fleetSegment?.segmentName) + } + val namedVesselSubscriptions = + vesselSubscriptions.map { vesselSubscription -> + val vessel = allVessels.find { it.id == vesselSubscription.vesselId } + + return@map vesselSubscription.copy(vesselName = vessel?.vesselName) + } + + return PriorNotificationSubscriber( + controlUnit, + portSubscriptions = namedPortSubscriptions, + segmentSubscriptions = namedSegmentSubscriptions, + vesselSubscriptions = namedVesselSubscriptions, + ) + } + } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationSubscribers.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationSubscribers.kt index 4775d180f1..486d53b8b0 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationSubscribers.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationSubscribers.kt @@ -10,9 +10,12 @@ import org.springframework.data.domain.Sort @UseCase class GetPriorNotificationSubscribers( private val controlUnitRepository: ControlUnitRepository, + private val fleetSegmentRepository: FleetSegmentRepository, private val pnoPortSubscriptionRepository: PnoPortSubscriptionRepository, private val pnoSegmentSubscriptionRepository: PnoSegmentSubscriptionRepository, private val pnoVesselSubscriptionRepository: PnoVesselSubscriptionRepository, + private val portRepository: PortRepository, + private val vesselRepository: VesselRepository, ) { fun execute( filter: PriorNotificationSubscribersFilter, @@ -31,6 +34,10 @@ class GetPriorNotificationSubscribers( } private fun getPriorNotificationSubscribers(): List { + val allFleetSegments = fleetSegmentRepository.findAll() + val allPorts = portRepository.findAll() + val allVessels = vesselRepository.findAll() + val allControlUnits = controlUnitRepository.findAll() val allPortSubscriptions = pnoPortSubscriptionRepository.findAll() val allSegmentSubscriptions = pnoSegmentSubscriptionRepository.findAll() @@ -50,11 +57,14 @@ class GetPriorNotificationSubscribers( vesselSubscription.controlUnitId == controlUnit.id } - PriorNotificationSubscriber( - controlUnit = controlUnit, - portSubscriptions = portSubscriptions, - segmentSubscriptions = segmentSubscriptions, - vesselSubscriptions = vesselSubscriptions, + return@map GetPriorNotificationSubscriber.enrich( + controlUnit, + portSubscriptions, + segmentSubscriptions, + vesselSubscriptions, + allFleetSegments, + allPorts, + allVessels, ) } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/PnoPortSubscriptionEntity.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/PnoPortSubscriptionEntity.kt index e4cadbe50e..fcd275cbac 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/PnoPortSubscriptionEntity.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/PnoPortSubscriptionEntity.kt @@ -19,6 +19,7 @@ data class PnoPortSubscriptionEntity( return PriorNotificationPortSubscription( controlUnitId = id.controlUnitId, portLocode = id.portLocode, + portName = null, hasSubscribedToAllPriorNotifications = receiveAllPnos, ) } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/PnoSegmentSubscriptionEntity.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/PnoSegmentSubscriptionEntity.kt index 279c25f1e4..5e96009abf 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/PnoSegmentSubscriptionEntity.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/PnoSegmentSubscriptionEntity.kt @@ -21,6 +21,7 @@ data class PnoSegmentSubscriptionEntity( return PriorNotificationSegmentSubscription( controlUnitId = id.controlUnitId, segmentCode = id.segmentCode, + segmentName = null, ) } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/PnoVesselSubscriptionEntity.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/PnoVesselSubscriptionEntity.kt index 0fee785093..34270a56e9 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/PnoVesselSubscriptionEntity.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/PnoVesselSubscriptionEntity.kt @@ -20,6 +20,7 @@ data class PnoVesselSubscriptionEntity( return PriorNotificationVesselSubscription( controlUnitId = id.controlUnitId, vesselId = id.vesselId, + vesselName = null, ) } } From 27f8611a958410dc880a2d4adb1a117fb4ac1c5b Mon Sep 17 00:00:00 2001 From: Ivan Gabriele Date: Thu, 24 Oct 2024 09:16:53 +0200 Subject: [PATCH 15/59] Move ResponseBodyStatus into BackendApi namespace in Frontend --- frontend/src/api/BackendApi.types.ts | 9 +++++++++ .../components/shared/DownloadButton/index.tsx | 11 ++++++----- .../PriorNotification/priorNotificationApi.ts | 11 +---------- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/frontend/src/api/BackendApi.types.ts b/frontend/src/api/BackendApi.types.ts index ada6add61f..6ceed24200 100644 --- a/frontend/src/api/BackendApi.types.ts +++ b/frontend/src/api/BackendApi.types.ts @@ -60,6 +60,15 @@ export namespace BackendApi { /** Thrown when attempting to archive an entity linked to non-archived children. */ UNARCHIVED_CHILD = 'UNARCHIVED_CHILD' } + + export enum ResponseBodyStatusEnum { + FOUND = 'FOUND', + NO_CONTENT = 'NO_CONTENT' + } + + export type ResponseBodyStatus = { + status: ResponseBodyStatusEnum + } } export interface Meta { diff --git a/frontend/src/features/PriorNotification/components/shared/DownloadButton/index.tsx b/frontend/src/features/PriorNotification/components/shared/DownloadButton/index.tsx index f3f95becb0..b17a69877d 100644 --- a/frontend/src/features/PriorNotification/components/shared/DownloadButton/index.tsx +++ b/frontend/src/features/PriorNotification/components/shared/DownloadButton/index.tsx @@ -1,11 +1,9 @@ import { monitorfishApiKy } from '@api/api' +import { BackendApi } from '@api/BackendApi.types' import { RTK_ONE_MINUTE_POLLING_QUERY_OPTIONS } from '@api/constants' import { useGetGearsQuery } from '@api/gear' import { getAlpha2CodeFromAlpha2or3Code } from '@components/CountryFlag/utils' -import { - StatusBodyEnum, - useGetPriorNotificationPdfExistenceQuery -} from '@features/PriorNotification/priorNotificationApi' +import { useGetPriorNotificationPdfExistenceQuery } from '@features/PriorNotification/priorNotificationApi' import { customSentry, CustomSentryMeasurementName } from '@libs/customSentry' import { Accent, Button, customDayjs, Dropdown, Icon } from '@mtes-mct/monitor-ui' import { downloadFile } from '@utils/downloadFile' @@ -34,7 +32,10 @@ export function DownloadButton({ const getGearsApiQuery = useGetGearsQuery() const { data } = useGetPriorNotificationPdfExistenceQuery(reportId, RTK_ONE_MINUTE_POLLING_QUERY_OPTIONS) - const isPriorNotificationDocumentAvailable = useMemo(() => data?.status === StatusBodyEnum.FOUND, [data]) + const isPriorNotificationDocumentAvailable = useMemo( + () => data?.status === BackendApi.ResponseBodyStatusEnum.FOUND, + [data] + ) const hasAuthorizedLandingDownload = isSuperUser && diff --git a/frontend/src/features/PriorNotification/priorNotificationApi.ts b/frontend/src/features/PriorNotification/priorNotificationApi.ts index f32d9e4a93..a811b2755f 100644 --- a/frontend/src/features/PriorNotification/priorNotificationApi.ts +++ b/frontend/src/features/PriorNotification/priorNotificationApi.ts @@ -26,15 +26,6 @@ const GET_PRIOR_NOTIFICATION_PDF_ERROR_MESSAGE = "Nous n'avons pas pu récupére const VERIFY_AND_SEND_PRIOR_NOTIFICATION_ERROR_MESSAGE = "Nous n'avons pas pu vérifier et envoyer le préavis." const INVALIDATE_PRIOR_NOTIFICATION_ERROR_MESSAGE = "Nous n'avons pas pu invalider et envoyer le préavis." -export enum StatusBodyEnum { - FOUND = 'FOUND', - NO_CONTENT = 'NO_CONTENT' -} - -type StatusBody = { - status: StatusBodyEnum -} - export const priorNotificationApi = monitorfishApi.injectEndpoints({ endpoints: builder => ({ computeManualPriorNotification: builder.mutation< @@ -91,7 +82,7 @@ export const priorNotificationApi = monitorfishApi.injectEndpoints({ transformErrorResponse: response => new FrontendApiError(GET_PRIOR_NOTIFICATION_DETAIL_ERROR_MESSAGE, response) }), - getPriorNotificationPdfExistence: builder.query({ + getPriorNotificationPdfExistence: builder.query({ extraOptions: { maxRetries: 0 }, forceRefetch: () => true, query: reportId => ({ From 422c5aecc56a43e5ad80487278875de37600b1f2 Mon Sep 17 00:00:00 2001 From: Ivan Gabriele Date: Thu, 24 Oct 2024 10:01:27 +0200 Subject: [PATCH 16/59] Add run-back-with-monitorenv-for-cypress command to Makefile --- Makefile | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index f5cb9e971d..2704573875 100644 --- a/Makefile +++ b/Makefile @@ -41,7 +41,7 @@ docker-env: # Local Development .PHONY: check-clean-archi ##LOCAL Check clean architecture imports -check-clean-archi: +check-clean-archi: cd backend/tools && ./check-clean-architecture.sh .PHONY: clean ##LOCAL Clean all backend assets and stop docker containers @@ -148,6 +148,11 @@ test-back: check-clean-archi test-back-watch: ./backend/scripts/test-watch.sh +.PHONY: run-back-with-monitorenv-for-cypress ##TEST ▶️ Run backend API when using Cypress connected to a local MonitorEnv app 📝 +run-back-with-monitorenv-for-cypress: run-monitorenv run-stubbed-apis + docker compose up -d --quiet-pull --wait db keycloak + cd backend && MONITORENV_URL=http://localhost:9880 MONITORFISH_OIDC_ENABLED=false MONITORFISH_SCHEDULING_ENABLED=false ./gradlew bootRun --args='--spring.profiles.active=local --spring.config.additional-location=$(INFRA_FOLDER)' + .PHONY: run-back-for-puppeteer ##TEST ▶️ Run backend API when using Puppeteer 📝 run-back-for-puppeteer: docker-env run-stubbed-apis docker compose up -d --quiet-pull --wait db @@ -168,7 +173,7 @@ run-front-for-puppeteer: restart-remote-app: cd infra/remote && docker compose pull && docker compose up -d --build app --force-recreate -.PHONY: register-pipeline-flows-prod ##RUN ▶️ Register pipeline flows in PROD +.PHONY: register-pipeline-flows-prod ##RUN ▶️ Register pipeline flows in PROD register-pipeline-flows-prod: docker pull docker.pkg.github.com/mtes-mct/monitorfish/monitorfish-pipeline:$(MONITORFISH_VERSION) && \ infra/remote/data-pipeline/register-flows-prod.sh From d6ee593405f2a0ea75a01494789729d60544a85b Mon Sep 17 00:00:00 2001 From: Ivan Gabriele Date: Thu, 24 Oct 2024 10:39:22 +0200 Subject: [PATCH 17/59] Add /bff/v1/prior_notification_subscribers route in Backend --- .../entities/administration/Administration.kt | 3 + .../entities/control_unit/ControlUnit.kt | 3 + .../control_unit/ControlUnitContact.kt | 3 + .../control_unit/ControlUnitDepartmentArea.kt | 3 + .../control_unit/ControlUnitResourceType.kt | 3 + .../control_unit/ControlUnitStation.kt | 3 + .../PriorNotificationSubscribersSortColumn.kt | 2 +- .../control_units/dtos/FullControlUnit.kt | 2 + .../dtos/FullControlUnitResource.kt | 2 + .../GetPriorNotificationSubscribers.kt | 2 +- .../PriorNotificationSubscriberController.kt | 80 +++++++++++++++++++ .../api/outputs/AdministrationDataOutput.kt | 17 ++++ .../api/outputs/ControlUnitDataOutput.kt | 21 +++++ .../api/outputs/PortDataOutput.kt | 4 +- ...rNotificationPortSubscriptionDataOutput.kt | 23 ++++++ ...tificationSegmentSubscriptionDataOutput.kt | 21 +++++ .../PriorNotificationSubscriberDataOutput.kt | 40 ++++++++++ ...otificationVesselSubscriptionDataOutput.kt | 21 +++++ 18 files changed, 249 insertions(+), 4 deletions(-) create mode 100644 backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/PriorNotificationSubscriberController.kt create mode 100644 backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/AdministrationDataOutput.kt create mode 100644 backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/ControlUnitDataOutput.kt create mode 100644 backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/PriorNotificationPortSubscriptionDataOutput.kt create mode 100644 backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/PriorNotificationSegmentSubscriptionDataOutput.kt create mode 100644 backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/PriorNotificationSubscriberDataOutput.kt create mode 100644 backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/PriorNotificationVesselSubscriptionDataOutput.kt diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/administration/Administration.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/administration/Administration.kt index 4cbad4e388..04e66bba79 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/administration/Administration.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/administration/Administration.kt @@ -1,5 +1,8 @@ package fr.gouv.cnsp.monitorfish.domain.entities.administration +import kotlinx.serialization.Serializable + +@Serializable data class Administration( val id: Int, val isArchived: Boolean, diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/control_unit/ControlUnit.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/control_unit/ControlUnit.kt index 34c502fc73..f86ef6ed85 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/control_unit/ControlUnit.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/control_unit/ControlUnit.kt @@ -1,5 +1,8 @@ package fr.gouv.cnsp.monitorfish.domain.entities.control_unit +import kotlinx.serialization.Serializable + +@Serializable data class ControlUnit( val id: Int, val areaNote: String?, diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/control_unit/ControlUnitContact.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/control_unit/ControlUnitContact.kt index a4190d1ee7..98c3c21de3 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/control_unit/ControlUnitContact.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/control_unit/ControlUnitContact.kt @@ -1,5 +1,8 @@ package fr.gouv.cnsp.monitorfish.domain.entities.control_unit +import kotlinx.serialization.Serializable + +@Serializable data class ControlUnitContact( val id: Int, val controlUnitId: Int, diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/control_unit/ControlUnitDepartmentArea.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/control_unit/ControlUnitDepartmentArea.kt index a8752279fc..86bf509e93 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/control_unit/ControlUnitDepartmentArea.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/control_unit/ControlUnitDepartmentArea.kt @@ -1,6 +1,9 @@ package fr.gouv.cnsp.monitorfish.domain.entities.control_unit +import kotlinx.serialization.Serializable + // TODO Maybe merge `districts` from MonitorFish into MonitorEnv `departmentAreas`? +@Serializable data class ControlUnitDepartmentArea( /** `inseeCode` is the ID. */ val inseeCode: String, diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/control_unit/ControlUnitResourceType.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/control_unit/ControlUnitResourceType.kt index e7e1d6b31e..98f2cf1a83 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/control_unit/ControlUnitResourceType.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/control_unit/ControlUnitResourceType.kt @@ -1,5 +1,8 @@ package fr.gouv.cnsp.monitorfish.domain.entities.control_unit +import kotlinx.serialization.Serializable + +@Serializable enum class ControlUnitResourceType(val label: String) { AIRPLANE("Avion"), BARGE("Barge"), diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/control_unit/ControlUnitStation.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/control_unit/ControlUnitStation.kt index 5e38d514ad..c437f884f0 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/control_unit/ControlUnitStation.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/control_unit/ControlUnitStation.kt @@ -1,5 +1,8 @@ package fr.gouv.cnsp.monitorfish.domain.entities.control_unit +import kotlinx.serialization.Serializable + +@Serializable data class ControlUnitStation( val id: Int, val latitude: Double, diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/prior_notification/sorters/PriorNotificationSubscribersSortColumn.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/prior_notification/sorters/PriorNotificationSubscribersSortColumn.kt index 0f81e8b233..0a5811d4d6 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/prior_notification/sorters/PriorNotificationSubscribersSortColumn.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/prior_notification/sorters/PriorNotificationSubscribersSortColumn.kt @@ -1,5 +1,5 @@ package fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.sorters enum class PriorNotificationSubscribersSortColumn { - NAME, + CONTROL_UNIT_NAME, } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/control_units/dtos/FullControlUnit.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/control_units/dtos/FullControlUnit.kt index 68c4d1864c..828c6c2ae3 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/control_units/dtos/FullControlUnit.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/control_units/dtos/FullControlUnit.kt @@ -3,7 +3,9 @@ package fr.gouv.cnsp.monitorfish.domain.use_cases.control_units.dtos import fr.gouv.cnsp.monitorfish.domain.entities.administration.Administration import fr.gouv.cnsp.monitorfish.domain.entities.control_unit.ControlUnitContact import fr.gouv.cnsp.monitorfish.domain.entities.control_unit.ControlUnitDepartmentArea +import kotlinx.serialization.Serializable +@Serializable data class FullControlUnit( val id: Int, val areaNote: String?, diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/control_units/dtos/FullControlUnitResource.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/control_units/dtos/FullControlUnitResource.kt index e549a0a1ac..0692f8fdc3 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/control_units/dtos/FullControlUnitResource.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/control_units/dtos/FullControlUnitResource.kt @@ -3,7 +3,9 @@ package fr.gouv.cnsp.monitorfish.domain.use_cases.control_units.dtos import fr.gouv.cnsp.monitorfish.domain.entities.control_unit.ControlUnit import fr.gouv.cnsp.monitorfish.domain.entities.control_unit.ControlUnitResourceType import fr.gouv.cnsp.monitorfish.domain.entities.control_unit.ControlUnitStation +import kotlinx.serialization.Serializable +@Serializable data class FullControlUnitResource( val id: Int, val controlUnit: ControlUnit, diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationSubscribers.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationSubscribers.kt index 486d53b8b0..c766f5068d 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationSubscribers.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationSubscribers.kt @@ -100,7 +100,7 @@ class GetPriorNotificationSubscribers( ): List { val comparator = when (sortColumn) { - PriorNotificationSubscribersSortColumn.NAME -> + PriorNotificationSubscribersSortColumn.CONTROL_UNIT_NAME -> compareBy { it.controlUnit.name } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/PriorNotificationSubscriberController.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/PriorNotificationSubscriberController.kt new file mode 100644 index 0000000000..0e7c604f54 --- /dev/null +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/PriorNotificationSubscriberController.kt @@ -0,0 +1,80 @@ +package fr.gouv.cnsp.monitorfish.infrastructure.api.bff + +import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.filters.PriorNotificationSubscribersFilter +import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.sorters.PriorNotificationSubscribersSortColumn +import fr.gouv.cnsp.monitorfish.domain.use_cases.prior_notification.* +import fr.gouv.cnsp.monitorfish.infrastructure.api.input.LogbookPriorNotificationFormDataInput +import fr.gouv.cnsp.monitorfish.infrastructure.api.outputs.* +import io.swagger.v3.oas.annotations.Operation +import io.swagger.v3.oas.annotations.Parameter +import io.swagger.v3.oas.annotations.tags.Tag +import jakarta.websocket.server.PathParam +import org.springframework.data.domain.Sort +import org.springframework.web.bind.annotation.* + +@RestController +@RequestMapping("/bff/v1/prior_notification_subscribers") +@Tag(name = "Prior notifications endpoints") +class PriorNotificationSubscriberController( + private val getPriorNotificationSubscriber: GetPriorNotificationSubscriber, + private val getPriorNotificationSubscribers: GetPriorNotificationSubscribers, +) { + @GetMapping("") + @Operation(summary = "Get all prior notification subscribers") + fun getAll( + @Parameter(description = "Administration ID.") + @RequestParam(name = "administrationId") + administrationId: Int? = null, + @Parameter(description = "Port locode.") + @RequestParam(name = "portLocode") + portLocode: String? = null, + @Parameter(description = "Search query (vessel name).") + @RequestParam(name = "searchQuery") + searchQuery: String? = null, + @Parameter(description = "Sort column.") + @RequestParam(name = "sortColumn") + sortColumn: PriorNotificationSubscribersSortColumn, + @Parameter(description = "Sort order.") + @RequestParam(name = "sortDirection") + sortDirection: Sort.Direction, + ): List { + val filter = + PriorNotificationSubscribersFilter( + administrationId = administrationId, + portLocode = portLocode, + searchQuery = searchQuery, + ) + + val priorNotificationSubscribers = getPriorNotificationSubscribers.execute(filter, sortColumn, sortDirection) + + return priorNotificationSubscribers.map { + PriorNotificationSubscriberDataOutput.fromPriorNotificationSubscriber(it) + } + } + + @GetMapping("/{controlUnitId}") + @Operation(summary = "Get a prior notification subscriber by its `controlUnitId`") + fun getOne( + @PathParam("Control unit ID") + @PathVariable(name = "controlUnitId") + controlUnitId: Int, + ): PriorNotificationSubscriberDataOutput { + val priorNotificationsSubscriber = getPriorNotificationSubscriber.execute(controlUnitId) + + return PriorNotificationSubscriberDataOutput.fromPriorNotificationSubscriber( + priorNotificationsSubscriber, + ) + } + + @PutMapping("/{controlUnitId}") + @Operation(summary = "Update a prior notification subscriber by its `controlUnitId`") + fun updateOne( + @PathParam("Control unit ID") + @PathVariable(name = "controlUnitId") + controlUnitId: String, + @RequestBody + logbookPriorNotificationFormDataInput: LogbookPriorNotificationFormDataInput, + ) { + return + } +} diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/AdministrationDataOutput.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/AdministrationDataOutput.kt new file mode 100644 index 0000000000..30d4685d40 --- /dev/null +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/AdministrationDataOutput.kt @@ -0,0 +1,17 @@ +package fr.gouv.cnsp.monitorfish.infrastructure.api.outputs + +import fr.gouv.cnsp.monitorfish.domain.entities.administration.Administration + +data class AdministrationDataOutput( + val id: Int, + val name: String, +) { + companion object { + fun fromAdministration(administration: Administration): AdministrationDataOutput { + return AdministrationDataOutput( + id = administration.id, + name = administration.name, + ) + } + } +} diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/ControlUnitDataOutput.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/ControlUnitDataOutput.kt new file mode 100644 index 0000000000..e7094f6d4f --- /dev/null +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/ControlUnitDataOutput.kt @@ -0,0 +1,21 @@ +package fr.gouv.cnsp.monitorfish.infrastructure.api.outputs + +import fr.gouv.cnsp.monitorfish.domain.use_cases.control_units.dtos.FullControlUnit + +data class ControlUnitDataOutput( + val id: Int, + val administration: AdministrationDataOutput, + val name: String, +) { + companion object { + fun fromFullControlUnit(fullControlUnit: FullControlUnit): ControlUnitDataOutput { + val administration = AdministrationDataOutput.fromAdministration(fullControlUnit.administration) + + return ControlUnitDataOutput( + id = fullControlUnit.id, + administration, + name = fullControlUnit.name, + ) + } + } +} diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/PortDataOutput.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/PortDataOutput.kt index 1c543cd9c6..bca6957e74 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/PortDataOutput.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/PortDataOutput.kt @@ -3,8 +3,8 @@ package fr.gouv.cnsp.monitorfish.infrastructure.api.outputs import fr.gouv.cnsp.monitorfish.domain.entities.port.Port data class PortDataOutput( - val locode: String?, - val name: String?, + val locode: String, + val name: String, val latitude: Double?, val longitude: Double?, val region: String?, diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/PriorNotificationPortSubscriptionDataOutput.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/PriorNotificationPortSubscriptionDataOutput.kt new file mode 100644 index 0000000000..ec0050f226 --- /dev/null +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/PriorNotificationPortSubscriptionDataOutput.kt @@ -0,0 +1,23 @@ +package fr.gouv.cnsp.monitorfish.infrastructure.api.outputs + +import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotificationPortSubscription + +data class PriorNotificationPortSubscriptionDataOutput( + val controlUnitId: Int, + val hasSubscribedToAllPriorNotifications: Boolean, + val portLocode: String, + val portName: String?, +) { + companion object { + fun fromPriorNotificationPortSubscription( + priorNotificationPortSubscription: PriorNotificationPortSubscription, + ): PriorNotificationPortSubscriptionDataOutput { + return PriorNotificationPortSubscriptionDataOutput( + controlUnitId = priorNotificationPortSubscription.controlUnitId, + hasSubscribedToAllPriorNotifications = priorNotificationPortSubscription.hasSubscribedToAllPriorNotifications, + portLocode = priorNotificationPortSubscription.portLocode, + portName = priorNotificationPortSubscription.portName, + ) + } + } +} diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/PriorNotificationSegmentSubscriptionDataOutput.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/PriorNotificationSegmentSubscriptionDataOutput.kt new file mode 100644 index 0000000000..31ef312a6c --- /dev/null +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/PriorNotificationSegmentSubscriptionDataOutput.kt @@ -0,0 +1,21 @@ +package fr.gouv.cnsp.monitorfish.infrastructure.api.outputs + +import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotificationSegmentSubscription + +data class PriorNotificationSegmentSubscriptionDataOutput( + val controlUnitId: Int, + val segmentCode: String, + val segmentName: String?, +) { + companion object { + fun fromPriorNotificationSegmentSubscription( + priorNotificationFleetSegmentSubscription: PriorNotificationSegmentSubscription, + ): PriorNotificationSegmentSubscriptionDataOutput { + return PriorNotificationSegmentSubscriptionDataOutput( + controlUnitId = priorNotificationFleetSegmentSubscription.controlUnitId, + segmentCode = priorNotificationFleetSegmentSubscription.segmentCode, + segmentName = priorNotificationFleetSegmentSubscription.segmentName, + ) + } + } +} diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/PriorNotificationSubscriberDataOutput.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/PriorNotificationSubscriberDataOutput.kt new file mode 100644 index 0000000000..2f997bb68e --- /dev/null +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/PriorNotificationSubscriberDataOutput.kt @@ -0,0 +1,40 @@ +package fr.gouv.cnsp.monitorfish.infrastructure.api.outputs + +import fr.gouv.cnsp.monitorfish.domain.use_cases.prior_notification.dtos.PriorNotificationSubscriber + +data class PriorNotificationSubscriberDataOutput( + /** Control unit ID. */ + val id: Int, + val controlUnit: ControlUnitDataOutput, + val portSubscriptions: List, + val segmentSubscriptions: List, + val vesselSubscriptions: List, +) { + companion object { + fun fromPriorNotificationSubscriber( + priorNotificationSubscriber: PriorNotificationSubscriber, + ): PriorNotificationSubscriberDataOutput { + val controlUnit = ControlUnitDataOutput.fromFullControlUnit(priorNotificationSubscriber.controlUnit) + val portSubscriptions = + priorNotificationSubscriber.portSubscriptions.map { + PriorNotificationPortSubscriptionDataOutput.fromPriorNotificationPortSubscription(it) + } + val segmentSubscriptions = + priorNotificationSubscriber.segmentSubscriptions.map { + PriorNotificationSegmentSubscriptionDataOutput.fromPriorNotificationSegmentSubscription(it) + } + val vesselSubscriptions = + priorNotificationSubscriber.vesselSubscriptions.map { + PriorNotificationVesselSubscriptionDataOutput.fromPriorNotificationVesselSubscription(it) + } + + return PriorNotificationSubscriberDataOutput( + id = controlUnit.id, + controlUnit, + portSubscriptions, + segmentSubscriptions, + vesselSubscriptions, + ) + } + } +} diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/PriorNotificationVesselSubscriptionDataOutput.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/PriorNotificationVesselSubscriptionDataOutput.kt new file mode 100644 index 0000000000..d8247c142e --- /dev/null +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/PriorNotificationVesselSubscriptionDataOutput.kt @@ -0,0 +1,21 @@ +package fr.gouv.cnsp.monitorfish.infrastructure.api.outputs + +import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotificationVesselSubscription + +data class PriorNotificationVesselSubscriptionDataOutput( + val controlUnitId: Int, + val vesselId: Int, + val vesselName: String?, +) { + companion object { + fun fromPriorNotificationVesselSubscription( + priorNotificationFleetVesselSubscription: PriorNotificationVesselSubscription, + ): PriorNotificationVesselSubscriptionDataOutput { + return PriorNotificationVesselSubscriptionDataOutput( + controlUnitId = priorNotificationFleetVesselSubscription.controlUnitId, + vesselId = priorNotificationFleetVesselSubscription.vesselId, + vesselName = priorNotificationFleetVesselSubscription.vesselName, + ) + } + } +} From 6c22b4d68f39a8b0d393da926267ede788e7d697 Mon Sep 17 00:00:00 2001 From: Ivan Gabriele Date: Thu, 24 Oct 2024 10:40:08 +0200 Subject: [PATCH 18/59] Add pno subscriber list to BackOffice --- .../components/BackOfficeIconLink.tsx | 17 ++++ .../BackOffice/components/BackofficeBody.tsx | 15 ++++ .../components/BackofficeMenu/constants.ts | 3 + .../components/BackofficeMenu/index.tsx | 4 + .../PriorNotificationSubscriber.types.ts | 47 ++++++++++ .../PriorNotification/backoffice.slice.ts | 28 ++++++ .../FilterBar.tsx | 87 +++++++++++++++++++ .../constants.tsx | 62 +++++++++++++ .../index.tsx | 45 ++++++++++ .../PriorNotificationSubscriberTable/types.ts | 5 ++ .../utils.tsx | 37 ++++++++ .../priorNotificationSubscriberApi.ts | 28 ++++++ .../hooks/useGetAdministrationsAsOptions.ts | 35 ++++++++ .../src/hooks/useGetControlUnitsAsOptions.ts | 35 ++++++++ frontend/src/pages/BackofficePage.tsx | 17 ++-- frontend/src/paths.ts | 2 + frontend/src/router.tsx | 9 ++ frontend/src/store/index.ts | 2 +- frontend/src/store/reducers.ts | 6 +- 19 files changed, 468 insertions(+), 16 deletions(-) create mode 100644 frontend/src/features/BackOffice/components/BackOfficeIconLink.tsx create mode 100644 frontend/src/features/BackOffice/components/BackofficeBody.tsx create mode 100644 frontend/src/features/PriorNotification/PriorNotificationSubscriber.types.ts create mode 100644 frontend/src/features/PriorNotification/backoffice.slice.ts create mode 100644 frontend/src/features/PriorNotification/components/PriorNotificationSubscriberTable/FilterBar.tsx create mode 100644 frontend/src/features/PriorNotification/components/PriorNotificationSubscriberTable/constants.tsx create mode 100644 frontend/src/features/PriorNotification/components/PriorNotificationSubscriberTable/index.tsx create mode 100644 frontend/src/features/PriorNotification/components/PriorNotificationSubscriberTable/types.ts create mode 100644 frontend/src/features/PriorNotification/components/PriorNotificationSubscriberTable/utils.tsx create mode 100644 frontend/src/features/PriorNotification/priorNotificationSubscriberApi.ts create mode 100644 frontend/src/hooks/useGetAdministrationsAsOptions.ts create mode 100644 frontend/src/hooks/useGetControlUnitsAsOptions.ts diff --git a/frontend/src/features/BackOffice/components/BackOfficeIconLink.tsx b/frontend/src/features/BackOffice/components/BackOfficeIconLink.tsx new file mode 100644 index 0000000000..4d8c9a6f45 --- /dev/null +++ b/frontend/src/features/BackOffice/components/BackOfficeIconLink.tsx @@ -0,0 +1,17 @@ +import { IconButton, type IconButtonProps } from '@mtes-mct/monitor-ui' +import { useCallback } from 'react' +import { useNavigate } from 'react-router-dom' + +export type BackOfficeIconLinkProps = Omit & { + to: string +} +export function BackOfficeIconLink({ to, ...originalProps }: BackOfficeIconLinkProps) { + const navigate = useNavigate() + + const handleClick = useCallback(() => { + navigate(to) + }, [navigate, to]) + + // eslint-disable-next-line react/jsx-props-no-spreading + return +} diff --git a/frontend/src/features/BackOffice/components/BackofficeBody.tsx b/frontend/src/features/BackOffice/components/BackofficeBody.tsx new file mode 100644 index 0000000000..2df1bc1a84 --- /dev/null +++ b/frontend/src/features/BackOffice/components/BackofficeBody.tsx @@ -0,0 +1,15 @@ +import styled from 'styled-components' + +export const BackOfficeBody = styled.div` + box-sizing: border-box; + display: flex; + flex-direction: column; + flex-grow: 1; + height: 100%; + padding: 24px; + overflow-y: auto; + + * { + box-sizing: border-box; + } +` diff --git a/frontend/src/features/BackOffice/components/BackofficeMenu/constants.ts b/frontend/src/features/BackOffice/components/BackofficeMenu/constants.ts index 5008366d98..3daa5efc71 100644 --- a/frontend/src/features/BackOffice/components/BackofficeMenu/constants.ts +++ b/frontend/src/features/BackOffice/components/BackofficeMenu/constants.ts @@ -1,17 +1,20 @@ export enum BackOfficeMenuKey { CONTROL_OBJECTIVE_LIST = 'CONTROL_OBJECTIVE_LIST', FLEET_SEGMENT_LIST = 'CONTROL_UNIT_LIST', + PRIOR_NOTIFICATION_SUBSCRIBER_LIST = 'PRIOR_NOTIFICATION_SUBSCRIBER_LIST', REGULATORY_ZONE_LIST = 'REGULATORY_ZONE_LIST' } export const BACK_OFFICE_MENU_LABEL: Record = { [BackOfficeMenuKey.CONTROL_OBJECTIVE_LIST]: 'Objectifs de contrôle', [BackOfficeMenuKey.FLEET_SEGMENT_LIST]: 'Segments de flotte', + [BackOfficeMenuKey.PRIOR_NOTIFICATION_SUBSCRIBER_LIST]: 'Diffusion des préavis', [BackOfficeMenuKey.REGULATORY_ZONE_LIST]: 'Zones réglementaires' } export const BACK_OFFICE_MENU_PATH: Record = { [BackOfficeMenuKey.CONTROL_OBJECTIVE_LIST]: '/control_objectives', [BackOfficeMenuKey.FLEET_SEGMENT_LIST]: '/fleet_segments', + [BackOfficeMenuKey.PRIOR_NOTIFICATION_SUBSCRIBER_LIST]: '/prior_notification_subscribers', [BackOfficeMenuKey.REGULATORY_ZONE_LIST]: '/regulation' } diff --git a/frontend/src/features/BackOffice/components/BackofficeMenu/index.tsx b/frontend/src/features/BackOffice/components/BackofficeMenu/index.tsx index d558b3cf0a..f8a2dd4d1a 100644 --- a/frontend/src/features/BackOffice/components/BackofficeMenu/index.tsx +++ b/frontend/src/features/BackOffice/components/BackofficeMenu/index.tsx @@ -19,6 +19,10 @@ export function BackOfficeMenu() { {BACK_OFFICE_MENU_LABEL[BackOfficeMenuKey.FLEET_SEGMENT_LIST]} + + + {BACK_OFFICE_MENU_LABEL[BackOfficeMenuKey.PRIOR_NOTIFICATION_SUBSCRIBER_LIST]} + ) } diff --git a/frontend/src/features/PriorNotification/PriorNotificationSubscriber.types.ts b/frontend/src/features/PriorNotification/PriorNotificationSubscriber.types.ts new file mode 100644 index 0000000000..3285236278 --- /dev/null +++ b/frontend/src/features/PriorNotification/PriorNotificationSubscriber.types.ts @@ -0,0 +1,47 @@ +export namespace PriorNotificationSubscriber { + export interface Subscriber { + controlUnit: ControlUnit + /** Control unit ID. */ + id: number + portSubscriptions: PortSubscription[] + segmentSubscriptions: SegmentSubscription[] + vesselSubscriptions: VesselSubscription[] + } + + /** @internal Only used within this namespace. */ + type Administration = { + id: number + name: String + } + + /** @internal Only used within this namespace. */ + type ControlUnit = { + administration: Administration + id: number + name: String + } + + export type PortSubscription = { + controlUnitId: number + hasSubscribedToAllPriorNotifications: boolean + portLocode: string + portName: string | undefined + } + + export type SegmentSubscription = { + controlUnitId: number + hasSubscribedToAllPriorNotifications: boolean + segmentCode: string + segmentName: string | undefined + } + + export type VesselSubscription = { + controlUnitId: number + vesselId: number + vesselName: string | undefined + } + + export enum ApiSortColumn { + CONTROL_UNIT_NAME = 'CONTROL_UNIT_NAME' + } +} diff --git a/frontend/src/features/PriorNotification/backoffice.slice.ts b/frontend/src/features/PriorNotification/backoffice.slice.ts new file mode 100644 index 0000000000..657ba338b1 --- /dev/null +++ b/frontend/src/features/PriorNotification/backoffice.slice.ts @@ -0,0 +1,28 @@ +import { createSlice, type PayloadAction } from '@reduxjs/toolkit' + +import { DEFAULT_TABLE_FILTER_VALUES } from './components/PriorNotificationSubscriberTable/constants' + +import type { TableFilter } from './components/PriorNotificationSubscriberTable/types' + +export interface BackofficePriorNotificationState { + tableFilterValues: TableFilter +} +const INITIAL_STATE: BackofficePriorNotificationState = { + tableFilterValues: DEFAULT_TABLE_FILTER_VALUES +} + +const backofficePriorNotificationSlice = createSlice({ + initialState: INITIAL_STATE, + name: 'priorNotification', + reducers: { + setTableFilterValues(state, action: PayloadAction>) { + state.tableFilterValues = { + ...state.tableFilterValues, + ...action.payload + } + } + } +}) + +export const backofficePriorNotificationActions = backofficePriorNotificationSlice.actions +export const backofficePriorNotificationReducer = backofficePriorNotificationSlice.reducer diff --git a/frontend/src/features/PriorNotification/components/PriorNotificationSubscriberTable/FilterBar.tsx b/frontend/src/features/PriorNotification/components/PriorNotificationSubscriberTable/FilterBar.tsx new file mode 100644 index 0000000000..8e6b581f03 --- /dev/null +++ b/frontend/src/features/PriorNotification/components/PriorNotificationSubscriberTable/FilterBar.tsx @@ -0,0 +1,87 @@ +import { backofficePriorNotificationActions } from '@features/PriorNotification/backoffice.slice' +import { useBackofficeAppDispatch } from '@hooks/useBackofficeAppDispatch' +import { useBackofficeAppSelector } from '@hooks/useBackofficeAppSelector' +import { useGetAdministrationsAsOptions } from '@hooks/useGetAdministrationsAsOptions' +import { useGetPortsAsOptions } from '@hooks/useGetPortsAsOptions' +import { Icon, Select, TextInput } from '@mtes-mct/monitor-ui' +import { useCallback } from 'react' +import styled from 'styled-components' + +export function FilterBar() { + const dispatch = useBackofficeAppDispatch() + const tableFilterValues = useBackofficeAppSelector(store => store.priorNotification.tableFilterValues) + + const { administrationsAsOptions } = useGetAdministrationsAsOptions() + const { portsAsOptions } = useGetPortsAsOptions() + + const updateAdministrationId = useCallback( + (nextValue: number | undefined) => { + dispatch(backofficePriorNotificationActions.setTableFilterValues({ administrationId: nextValue })) + }, + [dispatch] + ) + + const updatePortLocode = useCallback( + (nextValue: string | undefined) => { + dispatch(backofficePriorNotificationActions.setTableFilterValues({ portLocode: nextValue })) + }, + [dispatch] + ) + + const updateSearchQuery = useCallback( + (nextValue: string | undefined) => { + dispatch(backofficePriorNotificationActions.setTableFilterValues({ searchQuery: nextValue })) + }, + [dispatch] + ) + + return ( + + + + {administrationsAsOptions && ( + + )} + + ) +} + +const Wrapper = styled.div` + display: flex; + margin-bottom: 24px; + + > .Element-Field:not(:first-child) { + margin-left: 24px; + width: 240px; + } +` diff --git a/frontend/src/features/PriorNotification/components/PriorNotificationSubscriberTable/constants.tsx b/frontend/src/features/PriorNotification/components/PriorNotificationSubscriberTable/constants.tsx new file mode 100644 index 0000000000..59e2ba58c4 --- /dev/null +++ b/frontend/src/features/PriorNotification/components/PriorNotificationSubscriberTable/constants.tsx @@ -0,0 +1,62 @@ +import { BackOfficeIconLink } from '@features/BackOffice/components/BackOfficeIconLink' +import { BACK_OFFICE_MENU_PATH, BackOfficeMenuKey } from '@features/BackOffice/components/BackofficeMenu/constants' +import { Icon, Size } from '@mtes-mct/monitor-ui' + +import { getSubscriberPortNames, getSubscriberPortNamesWithAllNotifications } from './utils' + +import type { TableFilter } from './types' +import type { PriorNotificationSubscriber } from '@features/PriorNotification/PriorNotificationSubscriber.types' +import type { ColumnDef } from '@tanstack/react-table' + +export const DEFAULT_TABLE_FILTER_VALUES: TableFilter = { + administrationId: undefined, + portLocode: undefined, + searchQuery: undefined +} + +export const TABLE_COLUMNS: Array> = [ + { + accessorFn: row => row.id, + enableSorting: false, + header: () => 'ID', + id: 'id', + size: 64 + }, + { + accessorFn: row => `${row.controlUnit.name} (${row.controlUnit.administration.name})`, + enableSorting: true, + header: () => 'Unité (administration)', + id: 'name' + }, + { + accessorFn: row => row.portSubscriptions, + cell: getSubscriberPortNames, + enableSorting: false, + header: () => 'Ports de diffusion', + id: 'ports', + size: 400 + }, + { + accessorFn: row => row.portSubscriptions, + cell: getSubscriberPortNamesWithAllNotifications, + enableSorting: false, + header: () => 'Ports de diffusion avec préavis supplémentaires', + id: 'portsWithAllNotifications', + size: 400 + }, + { + accessorFn: row => row.controlUnit.id, + cell: info => ( + ()}`} + /> + ), + enableSorting: false, + header: () => '', + id: 'edit', + size: 44 + } +] diff --git a/frontend/src/features/PriorNotification/components/PriorNotificationSubscriberTable/index.tsx b/frontend/src/features/PriorNotification/components/PriorNotificationSubscriberTable/index.tsx new file mode 100644 index 0000000000..657dfdcb84 --- /dev/null +++ b/frontend/src/features/PriorNotification/components/PriorNotificationSubscriberTable/index.tsx @@ -0,0 +1,45 @@ +import { BackendApi } from '@api/BackendApi.types' +import { RTK_FIVE_MINUTES_POLLING_QUERY_OPTIONS } from '@api/constants' +import { BackOfficeBody } from '@features/BackOffice/components/BackofficeBody' +import { PriorNotificationSubscriber } from '@features/PriorNotification/PriorNotificationSubscriber.types' +import { useGetPriorNotificationSubscribersQuery } from '@features/PriorNotification/priorNotificationSubscriberApi' +import { useBackofficeAppSelector } from '@hooks/useBackofficeAppSelector' +import { DataTable } from '@mtes-mct/monitor-ui' +import styled from 'styled-components' + +import { TABLE_COLUMNS } from './constants' +import { FilterBar } from './FilterBar' + +export function PriorNotificationSubscriberTable() { + const tableFilterValues = useBackofficeAppSelector(store => store.priorNotification.tableFilterValues) + + const apiSortingParams: BackendApi.RequestSortingParams = { + sortColumn: PriorNotificationSubscriber.ApiSortColumn.CONTROL_UNIT_NAME, + sortDirection: BackendApi.SortDirection.ASC + } + + const rtkQueryParams = { + ...apiSortingParams, + ...tableFilterValues + } + const { data: subscribers } = useGetPriorNotificationSubscribersQuery( + rtkQueryParams, + RTK_FIVE_MINUTES_POLLING_QUERY_OPTIONS + ) + + return ( + + Diffusion des préavis auprès des unités de contrôle + + + + + + ) +} + +const Title = styled.h1` + line-height: 1; + font-size: 24px; + margin: 0 0 24px; +` diff --git a/frontend/src/features/PriorNotification/components/PriorNotificationSubscriberTable/types.ts b/frontend/src/features/PriorNotification/components/PriorNotificationSubscriberTable/types.ts new file mode 100644 index 0000000000..68b8f3afee --- /dev/null +++ b/frontend/src/features/PriorNotification/components/PriorNotificationSubscriberTable/types.ts @@ -0,0 +1,5 @@ +export type TableFilter = { + administrationId: number | undefined + portLocode: string | undefined + searchQuery: string | undefined +} diff --git a/frontend/src/features/PriorNotification/components/PriorNotificationSubscriberTable/utils.tsx b/frontend/src/features/PriorNotification/components/PriorNotificationSubscriberTable/utils.tsx new file mode 100644 index 0000000000..f7666140e0 --- /dev/null +++ b/frontend/src/features/PriorNotification/components/PriorNotificationSubscriberTable/utils.tsx @@ -0,0 +1,37 @@ +import { isNotNullish } from '@utils/isNotNullish' + +import type { PriorNotificationSubscriber } from '@features/PriorNotification/PriorNotificationSubscriber.types' +import type { CellContext } from '@tanstack/react-table' + +export function getSubscriberPortNames( + cell: CellContext +) { + const portNames = cell + .getValue() + .map(portSubscription => portSubscription.portName) + .filter(isNotNullish) + .sort() + + if (!portNames.length) { + return Aucun + } + + return portNames.join(', ') +} + +export function getSubscriberPortNamesWithAllNotifications( + cell: CellContext +) { + const portNames = cell + .getValue() + .filter(portSubscription => portSubscription.hasSubscribedToAllPriorNotifications) + .map(portSubscription => portSubscription.portName) + .filter(isNotNullish) + .sort() + + if (!portNames.length) { + return Aucun + } + + return portNames.join(', ') +} diff --git a/frontend/src/features/PriorNotification/priorNotificationSubscriberApi.ts b/frontend/src/features/PriorNotification/priorNotificationSubscriberApi.ts new file mode 100644 index 0000000000..f9d517324f --- /dev/null +++ b/frontend/src/features/PriorNotification/priorNotificationSubscriberApi.ts @@ -0,0 +1,28 @@ +import { monitorfishApi } from '@api/api' +import { BackendApi } from '@api/BackendApi.types' +import { RtkCacheTagType } from '@api/constants' +import { FrontendApiError } from '@libs/FrontendApiError' +import { getUrlOrPathWithQueryParams } from '@utils/getUrlOrPathWithQueryParams' + +import type { TableFilter } from './components/PriorNotificationSubscriberTable/types' +import type { PriorNotificationSubscriber } from './PriorNotificationSubscriber.types' + +const GET_PRIOR_NOTIFICATION_SUBSCRIBERS_ERROR_MESSAGE = + "Nous n'avons pas pu récupérer la liste des inscrits aux préavis." + +export const priorNotificationSubscriberApi = monitorfishApi.injectEndpoints({ + endpoints: builder => ({ + getPriorNotificationSubscribers: builder.query< + PriorNotificationSubscriber.Subscriber[], + BackendApi.RequestSortingParams & TableFilter + >({ + providesTags: () => [{ type: RtkCacheTagType.PriorNotifications }], + query: (queryParams: BackendApi.RequestSortingParams & TableFilter) => + getUrlOrPathWithQueryParams(`/prior_notification_subscribers`, queryParams), + transformErrorResponse: response => + new FrontendApiError(GET_PRIOR_NOTIFICATION_SUBSCRIBERS_ERROR_MESSAGE, response) + }) + }) +}) + +export const { useGetPriorNotificationSubscribersQuery } = priorNotificationSubscriberApi diff --git a/frontend/src/hooks/useGetAdministrationsAsOptions.ts b/frontend/src/hooks/useGetAdministrationsAsOptions.ts new file mode 100644 index 0000000000..3fe0792f19 --- /dev/null +++ b/frontend/src/hooks/useGetAdministrationsAsOptions.ts @@ -0,0 +1,35 @@ +import { RTK_FIVE_MINUTES_POLLING_QUERY_OPTIONS } from '@api/constants' +import { useGetAdministrationsQuery } from '@features/ControlUnit/administrationApi' +import { useMemo } from 'react' + +import type { Option } from '@mtes-mct/monitor-ui' + +/** + * Fetches administrations and returns them as options with their `id` property as option value. + */ +export function useGetAdministrationsAsOptions() { + const { + data: administrations, + error, + isLoading + } = useGetAdministrationsQuery(undefined, RTK_FIVE_MINUTES_POLLING_QUERY_OPTIONS) + + const administrationsAsOptions: Option[] | undefined = useMemo(() => { + if (!administrations) { + return undefined + } + + return administrations + .map(administration => ({ + label: administration.name, + value: administration.id + })) + .sort((a, b) => a.label.localeCompare(b.label)) + }, [administrations]) + + return { + administrationsAsOptions, + error, + isLoading + } +} diff --git a/frontend/src/hooks/useGetControlUnitsAsOptions.ts b/frontend/src/hooks/useGetControlUnitsAsOptions.ts new file mode 100644 index 0000000000..aa532a372c --- /dev/null +++ b/frontend/src/hooks/useGetControlUnitsAsOptions.ts @@ -0,0 +1,35 @@ +import { RTK_FIVE_MINUTES_POLLING_QUERY_OPTIONS } from '@api/constants' +import { useGetControlUnitsQuery } from '@features/ControlUnit/controlUnitApi' +import { useMemo } from 'react' + +import type { Option } from '@mtes-mct/monitor-ui' + +/** + * Fetches control units and returns them as options with their `id` property as option value. + */ +export function useGetControlUnitsAsOptions() { + const { + data: controlUnits, + error, + isLoading + } = useGetControlUnitsQuery(undefined, RTK_FIVE_MINUTES_POLLING_QUERY_OPTIONS) + + const administrationsAsOptions: Option[] | undefined = useMemo(() => { + if (!controlUnits) { + return undefined + } + + return controlUnits + .map(controlUnit => ({ + label: controlUnit.name, + value: controlUnit.id + })) + .sort((a, b) => a.label.localeCompare(b.label)) + }, [controlUnits]) + + return { + administrationsAsOptions, + error, + isLoading + } +} diff --git a/frontend/src/pages/BackofficePage.tsx b/frontend/src/pages/BackofficePage.tsx index f5eec0804b..2462f7ac1d 100644 --- a/frontend/src/pages/BackofficePage.tsx +++ b/frontend/src/pages/BackofficePage.tsx @@ -5,7 +5,6 @@ import { Provider } from 'react-redux' import { Outlet } from 'react-router-dom' import { PersistGate } from 'redux-persist/integration/react' import styled from 'styled-components' -import { LegacyRsuiteComponentsWrapper } from 'ui/LegacyRsuiteComponentsWrapper' import { NamespaceContext } from '../context/NamespaceContext' import { LayerSliceNamespace } from '../domain/entities/layers/types' @@ -23,13 +22,11 @@ export function BackofficePage() { - - - + + - - - + + @@ -38,11 +35,7 @@ export function BackofficePage() { ) } -const BackofficeWrapper = styled.div` - box-sizing: border-box; +const Wrapper = styled.div` display: flex; - font-size: 13px; height: 100%; - overflow: hidden; - width: 100%; ` diff --git a/frontend/src/paths.ts b/frontend/src/paths.ts index 0541365a25..21410b551c 100644 --- a/frontend/src/paths.ts +++ b/frontend/src/paths.ts @@ -2,6 +2,8 @@ export const paths = { backendForFrontend: '/bff', backoffice: '/backoffice', controlObjectives: 'control_objectives', + controlUnitSubscribers: 'control_unit_subscribers', + editControlUnitSubscriber: 'control_unit_subscribers/:controlUnitId', editRegulation: 'regulation/edit', ext: '/ext', fleetSegments: 'fleet_segments', diff --git a/frontend/src/router.tsx b/frontend/src/router.tsx index 3fabea9342..c824c8c15a 100644 --- a/frontend/src/router.tsx +++ b/frontend/src/router.tsx @@ -3,6 +3,7 @@ import { EditRegulation } from '@features/BackOffice/edit_regulation/EditRegulat import { ControlObjectiveTable } from '@features/ControlObjective/components/ControlObjectiveTable' import { FleetSegmentsBackoffice } from '@features/FleetSegment/components/FleetSegmentsBackoffice' import { MainWindow } from '@features/MainWindow' +import { PriorNotificationSubscriberTable } from '@features/PriorNotification/components/PriorNotificationSubscriberTable' import { SideWindow } from '@features/SideWindow' import { BackofficePage } from '@pages/BackofficePage' import { HomePage } from '@pages/HomePage' @@ -115,6 +116,14 @@ export const routes = [ ) + }, + { + path: paths.controlUnitSubscribers, + element: ( + + + + ) } ] }, diff --git a/frontend/src/store/index.ts b/frontend/src/store/index.ts index 16c721e4dc..f22fcf2081 100644 --- a/frontend/src/store/index.ts +++ b/frontend/src/store/index.ts @@ -98,7 +98,7 @@ export const backofficeStore = configureStore({ // TODO Replace all Redux state Dates by strings & Error by a strict-typed POJO. serializableCheck: false } - }).concat(monitorfishApi.middleware), + }).concat(monitorenvApi.middleware, monitorfishApi.middleware), reducer: persistedBackofficeReducer }) diff --git a/frontend/src/store/reducers.ts b/frontend/src/store/reducers.ts index 30effc0270..15333495a7 100644 --- a/frontend/src/store/reducers.ts +++ b/frontend/src/store/reducers.ts @@ -10,6 +10,7 @@ import { mainWindowReducer } from '@features/MainWindow/slice' import { measurementReducer, type MeasurementState } from '@features/Measurement/slice' import { missionFormReducer } from '@features/Mission/components/MissionForm/slice' import { missionListReducer, type MissionListState } from '@features/Mission/components/MissionList/slice' +import { backofficePriorNotificationReducer } from '@features/PriorNotification/backoffice.slice' import { priorNotificationReducer, type PriorNotificationState } from '@features/PriorNotification/slice' import { regulatoryLayerSearchReducer } from '@features/Regulation/components/RegulationSearch/slice' import { regulatoryReducer } from '@features/Regulation/slice' @@ -52,6 +53,7 @@ const getCommonPersistReducerConfig = (key: string, whitelist?: Array Date: Thu, 24 Oct 2024 10:45:36 +0200 Subject: [PATCH 19/59] Improve search in backoffice pno subscriber list --- .../GetPriorNotificationSubscribers.kt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationSubscribers.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationSubscribers.kt index c766f5068d..1ee4e416c3 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationSubscribers.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationSubscribers.kt @@ -86,7 +86,14 @@ class GetPriorNotificationSubscribers( val searchQueryMatches = filter.searchQuery?.let { - subscriber.controlUnit.name.contains(it, ignoreCase = true) + subscriber.controlUnit.name.contains(it, ignoreCase = true) || + subscriber.controlUnit.administration.name.contains(it, ignoreCase = true) || + subscriber.portSubscriptions.any { portSubscription -> + portSubscription.portName?.contains( + it, + ignoreCase = true, + ) == true + } } != false administrationIdMatches && portLocodeMatches && searchQueryMatches From 1e1d867ea27926adde9fc82f89f82745e6643b78 Mon Sep 17 00:00:00 2001 From: Ivan Gabriele Date: Thu, 24 Oct 2024 12:28:18 +0200 Subject: [PATCH 20/59] Add UpdatePriorNotificationSubscriber use case in Backend --- .../PnoPortSubscriptionRepository.kt | 6 ++ .../PnoSegmentSubscriptionRepository.kt | 6 ++ .../PnoVesselSubscriptionRepository.kt | 6 ++ .../GetPriorNotificationSubscriber.kt | 49 +-------------- .../GetPriorNotificationSubscribers.kt | 2 +- .../UpdatePriorNotificationSubscriber.kt | 60 +++++++++++++++++++ .../dtos/PriorNotificationSubscriber.kt | 45 +++++++++++++- .../entities/PnoPortSubscriptionEntity.kt | 15 +++++ .../entities/PnoSegmentSubscriptionEntity.kt | 14 +++++ .../entities/PnoVesselSubscriptionEntity.kt | 14 +++++ .../JpaPnoPortSubscriptionRepository.kt | 18 ++++++ .../JpaPnoSegmentSubscriptionRepository.kt | 18 ++++++ .../JpaPnoVesselSubscriptionRepository.kt | 18 ++++++ .../DBPnoPortsSubscriptionsRepository.kt | 12 ++-- .../DBPnoSegmentsSubscriptionsRepository.kt | 12 ++-- .../DBPnoVesselsSubscriptionsRepository.kt | 12 ++-- 16 files changed, 233 insertions(+), 74 deletions(-) create mode 100644 backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/UpdatePriorNotificationSubscriber.kt diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/repositories/PnoPortSubscriptionRepository.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/repositories/PnoPortSubscriptionRepository.kt index 1f4e1adce8..70465e432d 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/repositories/PnoPortSubscriptionRepository.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/repositories/PnoPortSubscriptionRepository.kt @@ -3,9 +3,15 @@ package fr.gouv.cnsp.monitorfish.domain.repositories import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotificationPortSubscription interface PnoPortSubscriptionRepository { + fun deleteByControlUnitId(controlUnitId: Int) + fun findAll(): List fun findByControlUnitId(controlUnitId: Int): List fun has(portLocode: String): Boolean + + fun saveAll( + priorNotificationPortSubscriptions: List, + ): List } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/repositories/PnoSegmentSubscriptionRepository.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/repositories/PnoSegmentSubscriptionRepository.kt index e087e848cc..db9e7a7cb0 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/repositories/PnoSegmentSubscriptionRepository.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/repositories/PnoSegmentSubscriptionRepository.kt @@ -3,6 +3,8 @@ package fr.gouv.cnsp.monitorfish.domain.repositories import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotificationSegmentSubscription interface PnoSegmentSubscriptionRepository { + fun deleteByControlUnitId(controlUnitId: Int) + fun findAll(): List fun findByControlUnitId(controlUnitId: Int): List @@ -11,4 +13,8 @@ interface PnoSegmentSubscriptionRepository { portLocode: String, segmentCodes: List, ): Boolean + + fun saveAll( + priorNotificationSegmentSubscriptions: List, + ): List } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/repositories/PnoVesselSubscriptionRepository.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/repositories/PnoVesselSubscriptionRepository.kt index 165af3dade..6a2c84f09f 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/repositories/PnoVesselSubscriptionRepository.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/repositories/PnoVesselSubscriptionRepository.kt @@ -3,9 +3,15 @@ package fr.gouv.cnsp.monitorfish.domain.repositories import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotificationVesselSubscription interface PnoVesselSubscriptionRepository { + fun deleteByControlUnitId(controlUnitId: Int) + fun findAll(): List fun findByControlUnitId(controlUnitId: Int): List fun has(vesselId: Int): Boolean + + fun saveAll( + priorNotificationVesselSubscriptions: List, + ): List } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationSubscriber.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationSubscriber.kt index cde0f0986e..c9231be58f 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationSubscriber.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationSubscriber.kt @@ -1,16 +1,9 @@ package fr.gouv.cnsp.monitorfish.domain.use_cases.prior_notification import fr.gouv.cnsp.monitorfish.config.UseCase -import fr.gouv.cnsp.monitorfish.domain.entities.fleet_segment.FleetSegment -import fr.gouv.cnsp.monitorfish.domain.entities.port.Port -import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotificationPortSubscription -import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotificationSegmentSubscription -import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotificationVesselSubscription -import fr.gouv.cnsp.monitorfish.domain.entities.vessel.Vessel import fr.gouv.cnsp.monitorfish.domain.exceptions.BackendUsageErrorCode import fr.gouv.cnsp.monitorfish.domain.exceptions.BackendUsageException import fr.gouv.cnsp.monitorfish.domain.repositories.* -import fr.gouv.cnsp.monitorfish.domain.use_cases.control_units.dtos.FullControlUnit import fr.gouv.cnsp.monitorfish.domain.use_cases.prior_notification.dtos.PriorNotificationSubscriber @UseCase @@ -37,7 +30,7 @@ class GetPriorNotificationSubscriber( val segmentSubscriptions = pnoSegmentSubscriptionRepository.findByControlUnitId(id) val vesselSubscriptions = pnoVesselSubscriptionRepository.findByControlUnitId(id) - return enrich( + return PriorNotificationSubscriber.create( controlUnit, portSubscriptions, segmentSubscriptions, @@ -47,44 +40,4 @@ class GetPriorNotificationSubscriber( allVessels, ) } - - companion object { - fun enrich( - controlUnit: FullControlUnit, - portSubscriptions: List, - segmentSubscriptions: List, - vesselSubscriptions: List, - allFleetSegments: List, - allPorts: List, - allVessels: List, - ): PriorNotificationSubscriber { - portSubscriptions.any { portSubscription -> portSubscription.hasSubscribedToAllPriorNotifications } - - val namedPortSubscriptions = - portSubscriptions.map { portSubscription -> - val port = allPorts.find { it.locode == portSubscription.portLocode } - - return@map portSubscription.copy(portName = port?.name) - } - val namedSegmentSubscriptions = - segmentSubscriptions.map { fleetSegmentSubscription -> - val fleetSegment = allFleetSegments.find { it.segment == fleetSegmentSubscription.segmentCode } - - return@map fleetSegmentSubscription.copy(segmentName = fleetSegment?.segmentName) - } - val namedVesselSubscriptions = - vesselSubscriptions.map { vesselSubscription -> - val vessel = allVessels.find { it.id == vesselSubscription.vesselId } - - return@map vesselSubscription.copy(vesselName = vessel?.vesselName) - } - - return PriorNotificationSubscriber( - controlUnit, - portSubscriptions = namedPortSubscriptions, - segmentSubscriptions = namedSegmentSubscriptions, - vesselSubscriptions = namedVesselSubscriptions, - ) - } - } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationSubscribers.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationSubscribers.kt index 1ee4e416c3..dfa520088a 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationSubscribers.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationSubscribers.kt @@ -57,7 +57,7 @@ class GetPriorNotificationSubscribers( vesselSubscription.controlUnitId == controlUnit.id } - return@map GetPriorNotificationSubscriber.enrich( + return@map PriorNotificationSubscriber.create( controlUnit, portSubscriptions, segmentSubscriptions, diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/UpdatePriorNotificationSubscriber.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/UpdatePriorNotificationSubscriber.kt new file mode 100644 index 0000000000..0f95d532fd --- /dev/null +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/UpdatePriorNotificationSubscriber.kt @@ -0,0 +1,60 @@ +package fr.gouv.cnsp.monitorfish.domain.use_cases.prior_notification + +import fr.gouv.cnsp.monitorfish.config.UseCase +import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotificationPortSubscription +import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotificationSegmentSubscription +import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotificationVesselSubscription +import fr.gouv.cnsp.monitorfish.domain.exceptions.BackendUsageErrorCode +import fr.gouv.cnsp.monitorfish.domain.exceptions.BackendUsageException +import fr.gouv.cnsp.monitorfish.domain.repositories.ControlUnitRepository +import fr.gouv.cnsp.monitorfish.domain.repositories.FleetSegmentRepository +import fr.gouv.cnsp.monitorfish.domain.repositories.PnoPortSubscriptionRepository +import fr.gouv.cnsp.monitorfish.domain.repositories.PnoSegmentSubscriptionRepository +import fr.gouv.cnsp.monitorfish.domain.repositories.PnoVesselSubscriptionRepository +import fr.gouv.cnsp.monitorfish.domain.repositories.PortRepository +import fr.gouv.cnsp.monitorfish.domain.repositories.VesselRepository +import fr.gouv.cnsp.monitorfish.domain.use_cases.prior_notification.dtos.PriorNotificationSubscriber + +@UseCase +class UpdatePriorNotificationSubscriber( + private val controlUnitRepository: ControlUnitRepository, + private val fleetSegmentRepository: FleetSegmentRepository, + private val pnoPortSubscriptionRepository: PnoPortSubscriptionRepository, + private val pnoSegmentSubscriptionRepository: PnoSegmentSubscriptionRepository, + private val pnoVesselSubscriptionRepository: PnoVesselSubscriptionRepository, + private val portRepository: PortRepository, + private val vesselRepository: VesselRepository, +) { + fun execute( + controlUnitId: Int, + portSubscriptions: List, + segmentSubscriptions: List, + vesselSubscriptions: List, + ): PriorNotificationSubscriber { + val allFleetSegments = fleetSegmentRepository.findAll() + val allPorts = portRepository.findAll() + val allVessels = vesselRepository.findAll() + + val controlUnit = controlUnitRepository.findAll().find { it.id == controlUnitId } + if (controlUnit == null) { + throw BackendUsageException(BackendUsageErrorCode.NOT_FOUND) + } + + pnoPortSubscriptionRepository.deleteByControlUnitId(controlUnitId) + pnoSegmentSubscriptionRepository.deleteByControlUnitId(controlUnitId) + pnoVesselSubscriptionRepository.deleteByControlUnitId(controlUnitId) + pnoPortSubscriptionRepository.saveAll(portSubscriptions) + pnoSegmentSubscriptionRepository.saveAll(segmentSubscriptions) + pnoVesselSubscriptionRepository.saveAll(vesselSubscriptions) + + return PriorNotificationSubscriber.create( + controlUnit, + portSubscriptions, + segmentSubscriptions, + vesselSubscriptions, + allFleetSegments, + allPorts, + allVessels, + ) + } +} diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/dtos/PriorNotificationSubscriber.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/dtos/PriorNotificationSubscriber.kt index d8be8b78cf..6d8d85e10d 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/dtos/PriorNotificationSubscriber.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/dtos/PriorNotificationSubscriber.kt @@ -1,8 +1,11 @@ package fr.gouv.cnsp.monitorfish.domain.use_cases.prior_notification.dtos +import fr.gouv.cnsp.monitorfish.domain.entities.fleet_segment.FleetSegment +import fr.gouv.cnsp.monitorfish.domain.entities.port.Port import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotificationPortSubscription import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotificationSegmentSubscription import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotificationVesselSubscription +import fr.gouv.cnsp.monitorfish.domain.entities.vessel.Vessel import fr.gouv.cnsp.monitorfish.domain.use_cases.control_units.dtos.FullControlUnit data class PriorNotificationSubscriber( @@ -10,4 +13,44 @@ data class PriorNotificationSubscriber( val portSubscriptions: List, val segmentSubscriptions: List, val vesselSubscriptions: List, -) +) { + companion object { + fun create( + controlUnit: FullControlUnit, + portSubscriptions: List, + segmentSubscriptions: List, + vesselSubscriptions: List, + allFleetSegments: List, + allPorts: List, + allVessels: List, + ): PriorNotificationSubscriber { + portSubscriptions.any { portSubscription -> portSubscription.hasSubscribedToAllPriorNotifications } + + val namedPortSubscriptions = + portSubscriptions.map { portSubscription -> + val port = allPorts.find { it.locode == portSubscription.portLocode } + + return@map portSubscription.copy(portName = port?.name) + } + val namedSegmentSubscriptions = + segmentSubscriptions.map { fleetSegmentSubscription -> + val fleetSegment = allFleetSegments.find { it.segment == fleetSegmentSubscription.segmentCode } + + return@map fleetSegmentSubscription.copy(segmentName = fleetSegment?.segmentName) + } + val namedVesselSubscriptions = + vesselSubscriptions.map { vesselSubscription -> + val vessel = allVessels.find { it.id == vesselSubscription.vesselId } + + return@map vesselSubscription.copy(vesselName = vessel?.vesselName) + } + + return PriorNotificationSubscriber( + controlUnit, + portSubscriptions = namedPortSubscriptions, + segmentSubscriptions = namedSegmentSubscriptions, + vesselSubscriptions = namedVesselSubscriptions, + ) + } + } +} diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/PnoPortSubscriptionEntity.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/PnoPortSubscriptionEntity.kt index fcd275cbac..c26c940195 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/PnoPortSubscriptionEntity.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/PnoPortSubscriptionEntity.kt @@ -23,4 +23,19 @@ data class PnoPortSubscriptionEntity( hasSubscribedToAllPriorNotifications = receiveAllPnos, ) } + + companion object { + fun fromPriorNotificationPortSubscription( + priorNotificationPortSubscription: PriorNotificationPortSubscription, + ): PnoPortSubscriptionEntity { + return PnoPortSubscriptionEntity( + id = + PnoPortSubscriptionId( + controlUnitId = priorNotificationPortSubscription.controlUnitId, + portLocode = priorNotificationPortSubscription.portLocode, + ), + receiveAllPnos = priorNotificationPortSubscription.hasSubscribedToAllPriorNotifications, + ) + } + } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/PnoSegmentSubscriptionEntity.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/PnoSegmentSubscriptionEntity.kt index 5e96009abf..d251dba448 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/PnoSegmentSubscriptionEntity.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/PnoSegmentSubscriptionEntity.kt @@ -24,4 +24,18 @@ data class PnoSegmentSubscriptionEntity( segmentName = null, ) } + + companion object { + fun fromPriorNotificationSegmentSubscription( + priorNotificationSegmentSubscription: PriorNotificationSegmentSubscription, + ): PnoSegmentSubscriptionEntity { + return PnoSegmentSubscriptionEntity( + id = + PnoSegmentSubscriptionId( + controlUnitId = priorNotificationSegmentSubscription.controlUnitId, + segmentCode = priorNotificationSegmentSubscription.segmentCode, + ), + ) + } + } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/PnoVesselSubscriptionEntity.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/PnoVesselSubscriptionEntity.kt index 34270a56e9..1ccd02c6f4 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/PnoVesselSubscriptionEntity.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/PnoVesselSubscriptionEntity.kt @@ -23,4 +23,18 @@ data class PnoVesselSubscriptionEntity( vesselName = null, ) } + + companion object { + fun fromPriorNotificationVesselSubscription( + priorNotificationVesselSubscription: PriorNotificationVesselSubscription, + ): PnoVesselSubscriptionEntity { + return PnoVesselSubscriptionEntity( + id = + PnoVesselSubscriptionId( + controlUnitId = priorNotificationVesselSubscription.controlUnitId, + vesselId = priorNotificationVesselSubscription.vesselId, + ), + ) + } + } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPnoPortSubscriptionRepository.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPnoPortSubscriptionRepository.kt index 8fa68e4c87..c758b5858b 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPnoPortSubscriptionRepository.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPnoPortSubscriptionRepository.kt @@ -2,6 +2,7 @@ package fr.gouv.cnsp.monitorfish.infrastructure.database.repositories import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotificationPortSubscription import fr.gouv.cnsp.monitorfish.domain.repositories.PnoPortSubscriptionRepository +import fr.gouv.cnsp.monitorfish.infrastructure.database.entities.PnoPortSubscriptionEntity import fr.gouv.cnsp.monitorfish.infrastructure.database.repositories.interfaces.DBPnoPortsSubscriptionsRepository import org.springframework.stereotype.Repository @@ -9,6 +10,10 @@ import org.springframework.stereotype.Repository class JpaPnoPortSubscriptionRepository( private val dbPnoPortsSubscriptionsRepository: DBPnoPortsSubscriptionsRepository, ) : PnoPortSubscriptionRepository { + override fun deleteByControlUnitId(controlUnitId: Int) { + dbPnoPortsSubscriptionsRepository.deleteByControlUnitId(controlUnitId) + } + override fun findAll(): List { return dbPnoPortsSubscriptionsRepository.findAll() .map { it.toPriorNotificationPortSubscription() } @@ -22,4 +27,17 @@ class JpaPnoPortSubscriptionRepository( override fun has(portLocode: String): Boolean { return dbPnoPortsSubscriptionsRepository.countByPortLocode(portLocode) > 0 } + + override fun saveAll( + priorNotificationPortSubscriptions: List, + ): List { + return dbPnoPortsSubscriptionsRepository.saveAll( + priorNotificationPortSubscriptions.map { + PnoPortSubscriptionEntity.fromPriorNotificationPortSubscription( + it, + ) + }, + ) + .map { it.toPriorNotificationPortSubscription() } + } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPnoSegmentSubscriptionRepository.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPnoSegmentSubscriptionRepository.kt index cf732f5329..f9f91c04b8 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPnoSegmentSubscriptionRepository.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPnoSegmentSubscriptionRepository.kt @@ -2,6 +2,7 @@ package fr.gouv.cnsp.monitorfish.infrastructure.database.repositories import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotificationSegmentSubscription import fr.gouv.cnsp.monitorfish.domain.repositories.PnoSegmentSubscriptionRepository +import fr.gouv.cnsp.monitorfish.infrastructure.database.entities.PnoSegmentSubscriptionEntity import fr.gouv.cnsp.monitorfish.infrastructure.database.repositories.interfaces.DBPnoSegmentsSubscriptionsRepository import org.springframework.stereotype.Repository @@ -9,6 +10,10 @@ import org.springframework.stereotype.Repository class JpaPnoSegmentSubscriptionRepository( private val dbPnoSegmentsSubscriptionsRepository: DBPnoSegmentsSubscriptionsRepository, ) : PnoSegmentSubscriptionRepository { + override fun deleteByControlUnitId(controlUnitId: Int) { + dbPnoSegmentsSubscriptionsRepository.deleteByControlUnitId(controlUnitId) + } + override fun findAll(): List { return dbPnoSegmentsSubscriptionsRepository.findAll() .map { it.toPriorNotificationSegmentSubscription() } @@ -25,4 +30,17 @@ class JpaPnoSegmentSubscriptionRepository( ): Boolean { return dbPnoSegmentsSubscriptionsRepository.countByPortLocodeAndSegmentCodes(portLocode, segmentCodes) > 0 } + + override fun saveAll( + priorNotificationSegmentSubscriptions: List, + ): List { + return dbPnoSegmentsSubscriptionsRepository.saveAll( + priorNotificationSegmentSubscriptions.map { + PnoSegmentSubscriptionEntity.fromPriorNotificationSegmentSubscription( + it, + ) + }, + ) + .map { it.toPriorNotificationSegmentSubscription() } + } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPnoVesselSubscriptionRepository.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPnoVesselSubscriptionRepository.kt index 3367fa7a18..bbf39e9e8d 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPnoVesselSubscriptionRepository.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPnoVesselSubscriptionRepository.kt @@ -2,6 +2,7 @@ package fr.gouv.cnsp.monitorfish.infrastructure.database.repositories import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotificationVesselSubscription import fr.gouv.cnsp.monitorfish.domain.repositories.PnoVesselSubscriptionRepository +import fr.gouv.cnsp.monitorfish.infrastructure.database.entities.PnoVesselSubscriptionEntity import fr.gouv.cnsp.monitorfish.infrastructure.database.repositories.interfaces.DBPnoVesselsSubscriptionsRepository import org.springframework.stereotype.Repository @@ -9,6 +10,10 @@ import org.springframework.stereotype.Repository class JpaPnoVesselSubscriptionRepository( private val dbPnoVesselsSubscriptionsRepository: DBPnoVesselsSubscriptionsRepository, ) : PnoVesselSubscriptionRepository { + override fun deleteByControlUnitId(controlUnitId: Int) { + dbPnoVesselsSubscriptionsRepository.deleteByControlUnitId(controlUnitId) + } + override fun findAll(): List { return dbPnoVesselsSubscriptionsRepository.findAll() .map { it.toPriorNotificationVesselSubscription() } @@ -22,4 +27,17 @@ class JpaPnoVesselSubscriptionRepository( override fun has(vesselId: Int): Boolean { return dbPnoVesselsSubscriptionsRepository.countByVesselId(vesselId) > 0 } + + override fun saveAll( + priorNotificationVesselSubscriptions: List, + ): List { + return dbPnoVesselsSubscriptionsRepository.saveAll( + priorNotificationVesselSubscriptions.map { + PnoVesselSubscriptionEntity.fromPriorNotificationVesselSubscription( + it, + ) + }, + ) + .map { it.toPriorNotificationVesselSubscription() } + } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/interfaces/DBPnoPortsSubscriptionsRepository.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/interfaces/DBPnoPortsSubscriptionsRepository.kt index 0498f0d1ee..e50a57c85e 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/interfaces/DBPnoPortsSubscriptionsRepository.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/interfaces/DBPnoPortsSubscriptionsRepository.kt @@ -12,13 +12,9 @@ interface DBPnoPortsSubscriptionsRepository : JpaRepository } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/interfaces/DBPnoSegmentsSubscriptionsRepository.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/interfaces/DBPnoSegmentsSubscriptionsRepository.kt index a4d6dd4904..ca620ab965 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/interfaces/DBPnoSegmentsSubscriptionsRepository.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/interfaces/DBPnoSegmentsSubscriptionsRepository.kt @@ -20,13 +20,9 @@ interface DBPnoSegmentsSubscriptionsRepository : JpaRepository, ): Long - @Query( - """ - SELECT * - FROM pno_segments_subscriptions - WHERE control_unit_id = :controlUnitId - """, - nativeQuery = true, - ) + @Query("DELETE FROM pno_segments_subscriptions WHERE control_unit_id = :controlUnitId", nativeQuery = true) + fun deleteByControlUnitId(controlUnitId: Int) + + @Query("SELECT * FROM pno_segments_subscriptions WHERE control_unit_id = :controlUnitId", nativeQuery = true) fun findByControlUnitId(controlUnitId: Int): List } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/interfaces/DBPnoVesselsSubscriptionsRepository.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/interfaces/DBPnoVesselsSubscriptionsRepository.kt index 7d164dde4f..9aad133f4b 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/interfaces/DBPnoVesselsSubscriptionsRepository.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/interfaces/DBPnoVesselsSubscriptionsRepository.kt @@ -9,13 +9,9 @@ interface DBPnoVesselsSubscriptionsRepository : JpaRepository } From 44da31a79e1cf4673353bb652d3ef5eddb0bd617 Mon Sep 17 00:00:00 2001 From: Ivan Gabriele Date: Fri, 25 Oct 2024 04:29:16 +0200 Subject: [PATCH 21/59] Add PUT /prior_notification_subscribers/{controlUnitId} route in Backend --- .../PriorNotificationSubscriberController.kt | 25 ++++++++++--- .../PriorNotificationSubscriberDataInput.kt | 36 +++++++++++++++++++ .../JpaPnoPortSubscriptionRepository.kt | 3 ++ .../JpaPnoSegmentSubscriptionRepository.kt | 3 ++ .../JpaPnoVesselSubscriptionRepository.kt | 3 ++ .../DBPnoPortsSubscriptionsRepository.kt | 2 ++ .../DBPnoSegmentsSubscriptionsRepository.kt | 2 ++ .../DBPnoVesselsSubscriptionsRepository.kt | 2 ++ 8 files changed, 71 insertions(+), 5 deletions(-) create mode 100644 backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/input/PriorNotificationSubscriberDataInput.kt diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/PriorNotificationSubscriberController.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/PriorNotificationSubscriberController.kt index 0e7c604f54..78437dcc42 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/PriorNotificationSubscriberController.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/PriorNotificationSubscriberController.kt @@ -3,7 +3,7 @@ package fr.gouv.cnsp.monitorfish.infrastructure.api.bff import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.filters.PriorNotificationSubscribersFilter import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.sorters.PriorNotificationSubscribersSortColumn import fr.gouv.cnsp.monitorfish.domain.use_cases.prior_notification.* -import fr.gouv.cnsp.monitorfish.infrastructure.api.input.LogbookPriorNotificationFormDataInput +import fr.gouv.cnsp.monitorfish.infrastructure.api.input.PriorNotificationSubscriberDataInput import fr.gouv.cnsp.monitorfish.infrastructure.api.outputs.* import io.swagger.v3.oas.annotations.Operation import io.swagger.v3.oas.annotations.Parameter @@ -18,6 +18,7 @@ import org.springframework.web.bind.annotation.* class PriorNotificationSubscriberController( private val getPriorNotificationSubscriber: GetPriorNotificationSubscriber, private val getPriorNotificationSubscribers: GetPriorNotificationSubscribers, + private val updatePriorNotificationSubscriber: UpdatePriorNotificationSubscriber, ) { @GetMapping("") @Operation(summary = "Get all prior notification subscribers") @@ -71,10 +72,24 @@ class PriorNotificationSubscriberController( fun updateOne( @PathParam("Control unit ID") @PathVariable(name = "controlUnitId") - controlUnitId: String, + controlUnitId: Int, @RequestBody - logbookPriorNotificationFormDataInput: LogbookPriorNotificationFormDataInput, - ) { - return + priorNotificationSubscriberDataInput: PriorNotificationSubscriberDataInput, + ): PriorNotificationSubscriberDataOutput { + val (portSubscriptions, segmentSubscriptions, vesselSubscriptions) = + priorNotificationSubscriberDataInput.toSubscriptions() + + println("controlUnitId: $controlUnitId") + val updatedPriorNotificationSubscriber = + updatePriorNotificationSubscriber.execute( + controlUnitId, + portSubscriptions, + segmentSubscriptions, + vesselSubscriptions, + ) + + return PriorNotificationSubscriberDataOutput.fromPriorNotificationSubscriber( + updatedPriorNotificationSubscriber, + ) } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/input/PriorNotificationSubscriberDataInput.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/input/PriorNotificationSubscriberDataInput.kt new file mode 100644 index 0000000000..3996b42c3c --- /dev/null +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/input/PriorNotificationSubscriberDataInput.kt @@ -0,0 +1,36 @@ +package fr.gouv.cnsp.monitorfish.infrastructure.api.input + +import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotificationPortSubscription +import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotificationSegmentSubscription +import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotificationVesselSubscription + +data class PriorNotificationSubscriberDataInput( + val controlUnitId: Int, + val portLocodes: List, + val portLocodesWithAllNotifications: List, + val segmentCodes: List, + val vesselIds: List, +) { + fun toSubscriptions(): Triple, List, List> { + val portSubscriptions = + portLocodes.map { portLocode -> + val hasSubscribedToAllPriorNotifications = portLocodesWithAllNotifications.contains(portLocode) + + PriorNotificationPortSubscription(controlUnitId, portLocode, null, hasSubscribedToAllPriorNotifications) + } + val segmentSubscriptions = + segmentCodes.map { segmentCode -> + PriorNotificationSegmentSubscription(controlUnitId, segmentCode, null) + } + val vesselSubscriptions = + vesselIds.map { vesselId -> + PriorNotificationVesselSubscription(controlUnitId, vesselId, null) + } + + return Triple( + portSubscriptions, + segmentSubscriptions, + vesselSubscriptions, + ) + } +} diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPnoPortSubscriptionRepository.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPnoPortSubscriptionRepository.kt index c758b5858b..c6daf99ed3 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPnoPortSubscriptionRepository.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPnoPortSubscriptionRepository.kt @@ -4,12 +4,14 @@ import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotifica import fr.gouv.cnsp.monitorfish.domain.repositories.PnoPortSubscriptionRepository import fr.gouv.cnsp.monitorfish.infrastructure.database.entities.PnoPortSubscriptionEntity import fr.gouv.cnsp.monitorfish.infrastructure.database.repositories.interfaces.DBPnoPortsSubscriptionsRepository +import jakarta.transaction.Transactional import org.springframework.stereotype.Repository @Repository class JpaPnoPortSubscriptionRepository( private val dbPnoPortsSubscriptionsRepository: DBPnoPortsSubscriptionsRepository, ) : PnoPortSubscriptionRepository { + @Transactional override fun deleteByControlUnitId(controlUnitId: Int) { dbPnoPortsSubscriptionsRepository.deleteByControlUnitId(controlUnitId) } @@ -28,6 +30,7 @@ class JpaPnoPortSubscriptionRepository( return dbPnoPortsSubscriptionsRepository.countByPortLocode(portLocode) > 0 } + @Transactional override fun saveAll( priorNotificationPortSubscriptions: List, ): List { diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPnoSegmentSubscriptionRepository.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPnoSegmentSubscriptionRepository.kt index f9f91c04b8..9f027eaf00 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPnoSegmentSubscriptionRepository.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPnoSegmentSubscriptionRepository.kt @@ -4,12 +4,14 @@ import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotifica import fr.gouv.cnsp.monitorfish.domain.repositories.PnoSegmentSubscriptionRepository import fr.gouv.cnsp.monitorfish.infrastructure.database.entities.PnoSegmentSubscriptionEntity import fr.gouv.cnsp.monitorfish.infrastructure.database.repositories.interfaces.DBPnoSegmentsSubscriptionsRepository +import jakarta.transaction.Transactional import org.springframework.stereotype.Repository @Repository class JpaPnoSegmentSubscriptionRepository( private val dbPnoSegmentsSubscriptionsRepository: DBPnoSegmentsSubscriptionsRepository, ) : PnoSegmentSubscriptionRepository { + @Transactional override fun deleteByControlUnitId(controlUnitId: Int) { dbPnoSegmentsSubscriptionsRepository.deleteByControlUnitId(controlUnitId) } @@ -31,6 +33,7 @@ class JpaPnoSegmentSubscriptionRepository( return dbPnoSegmentsSubscriptionsRepository.countByPortLocodeAndSegmentCodes(portLocode, segmentCodes) > 0 } + @Transactional override fun saveAll( priorNotificationSegmentSubscriptions: List, ): List { diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPnoVesselSubscriptionRepository.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPnoVesselSubscriptionRepository.kt index bbf39e9e8d..cff5ee3b1d 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPnoVesselSubscriptionRepository.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPnoVesselSubscriptionRepository.kt @@ -4,12 +4,14 @@ import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotifica import fr.gouv.cnsp.monitorfish.domain.repositories.PnoVesselSubscriptionRepository import fr.gouv.cnsp.monitorfish.infrastructure.database.entities.PnoVesselSubscriptionEntity import fr.gouv.cnsp.monitorfish.infrastructure.database.repositories.interfaces.DBPnoVesselsSubscriptionsRepository +import jakarta.transaction.Transactional import org.springframework.stereotype.Repository @Repository class JpaPnoVesselSubscriptionRepository( private val dbPnoVesselsSubscriptionsRepository: DBPnoVesselsSubscriptionsRepository, ) : PnoVesselSubscriptionRepository { + @Transactional override fun deleteByControlUnitId(controlUnitId: Int) { dbPnoVesselsSubscriptionsRepository.deleteByControlUnitId(controlUnitId) } @@ -28,6 +30,7 @@ class JpaPnoVesselSubscriptionRepository( return dbPnoVesselsSubscriptionsRepository.countByVesselId(vesselId) > 0 } + @Transactional override fun saveAll( priorNotificationVesselSubscriptions: List, ): List { diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/interfaces/DBPnoPortsSubscriptionsRepository.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/interfaces/DBPnoPortsSubscriptionsRepository.kt index e50a57c85e..91af5992af 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/interfaces/DBPnoPortsSubscriptionsRepository.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/interfaces/DBPnoPortsSubscriptionsRepository.kt @@ -3,6 +3,7 @@ package fr.gouv.cnsp.monitorfish.infrastructure.database.repositories.interfaces import fr.gouv.cnsp.monitorfish.infrastructure.database.entities.PnoPortSubscriptionEntity import fr.gouv.cnsp.monitorfish.infrastructure.database.entities.PnoPortSubscriptionId import org.springframework.data.jpa.repository.JpaRepository +import org.springframework.data.jpa.repository.Modifying import org.springframework.data.jpa.repository.Query interface DBPnoPortsSubscriptionsRepository : JpaRepository { @@ -12,6 +13,7 @@ interface DBPnoPortsSubscriptionsRepository : JpaRepository { @@ -20,6 +21,7 @@ interface DBPnoSegmentsSubscriptionsRepository : JpaRepository, ): Long + @Modifying @Query("DELETE FROM pno_segments_subscriptions WHERE control_unit_id = :controlUnitId", nativeQuery = true) fun deleteByControlUnitId(controlUnitId: Int) diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/interfaces/DBPnoVesselsSubscriptionsRepository.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/interfaces/DBPnoVesselsSubscriptionsRepository.kt index 9aad133f4b..3a32130249 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/interfaces/DBPnoVesselsSubscriptionsRepository.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/interfaces/DBPnoVesselsSubscriptionsRepository.kt @@ -3,12 +3,14 @@ package fr.gouv.cnsp.monitorfish.infrastructure.database.repositories.interfaces import fr.gouv.cnsp.monitorfish.infrastructure.database.entities.PnoVesselSubscriptionEntity import fr.gouv.cnsp.monitorfish.infrastructure.database.entities.PnoVesselSubscriptionId import org.springframework.data.jpa.repository.JpaRepository +import org.springframework.data.jpa.repository.Modifying import org.springframework.data.jpa.repository.Query interface DBPnoVesselsSubscriptionsRepository : JpaRepository { @Query("SELECT COUNT(*) FROM pno_vessels_subscriptions WHERE vessel_id = :vesselId", nativeQuery = true) fun countByVesselId(vesselId: Int): Long + @Modifying @Query("DELETE FROM pno_vessels_subscriptions WHERE control_unit_id = :controlUnitId", nativeQuery = true) fun deleteByControlUnitId(controlUnitId: Int) From 6d9cc19f0a7a3d7b8f61dce391fed0aab03f31b2 Mon Sep 17 00:00:00 2001 From: Ivan Gabriele Date: Fri, 25 Oct 2024 04:30:43 +0200 Subject: [PATCH 22/59] Add pno subscriber edition to BackOffice --- frontend/package-lock.json | 26 +- frontend/package.json | 2 +- .../components/BackOfficeSubtitle.tsx | 10 + .../BackOffice/components/BackOfficeTitle.tsx | 13 +- .../components/BackofficeMenu/index.tsx | 1 + .../PriorNotificationSubscriber.types.ts | 8 + .../FullPortSubscriptionsField.tsx | 68 +++++ .../LimitedPortSubscriptionsField.tsx | 69 +++++ .../SegmentSubscriptionsField.tsx | 69 +++++ .../VesselSubscriptionsField.tsx | 73 +++++ .../columns.tsx | 92 ++++++ .../constants.tsx | 28 ++ .../PriorNotificationSubscriberForm/index.tsx | 159 ++++++++++ .../shared/Info.tsx | 8 + .../PriorNotificationSubscriberForm/utils.ts | 15 + .../index.tsx | 10 +- .../priorNotificationSubscriberApi.ts | 35 ++- .../VesselSearch/VesselSearchResult.tsx | 76 +++++ .../VesselSearch/VesselSearchResultItem.tsx | 143 +++++++++ .../components/VesselSearch/constants.ts | 8 + .../Vessel/components/VesselSearch/index.tsx | 282 ++++++++++++++++++ .../Vessel/components/VesselSearch/utils.ts | 50 ++++ frontend/src/features/VesselSearch/index.tsx | 1 + frontend/src/paths.ts | 4 +- frontend/src/router.tsx | 11 +- 25 files changed, 1226 insertions(+), 35 deletions(-) create mode 100644 frontend/src/features/BackOffice/components/BackOfficeSubtitle.tsx create mode 100644 frontend/src/features/PriorNotification/components/PriorNotificationSubscriberForm/FullPortSubscriptionsField.tsx create mode 100644 frontend/src/features/PriorNotification/components/PriorNotificationSubscriberForm/LimitedPortSubscriptionsField.tsx create mode 100644 frontend/src/features/PriorNotification/components/PriorNotificationSubscriberForm/SegmentSubscriptionsField.tsx create mode 100644 frontend/src/features/PriorNotification/components/PriorNotificationSubscriberForm/VesselSubscriptionsField.tsx create mode 100644 frontend/src/features/PriorNotification/components/PriorNotificationSubscriberForm/columns.tsx create mode 100644 frontend/src/features/PriorNotification/components/PriorNotificationSubscriberForm/constants.tsx create mode 100644 frontend/src/features/PriorNotification/components/PriorNotificationSubscriberForm/index.tsx create mode 100644 frontend/src/features/PriorNotification/components/PriorNotificationSubscriberForm/shared/Info.tsx create mode 100644 frontend/src/features/PriorNotification/components/PriorNotificationSubscriberForm/utils.ts create mode 100644 frontend/src/features/Vessel/components/VesselSearch/VesselSearchResult.tsx create mode 100644 frontend/src/features/Vessel/components/VesselSearch/VesselSearchResultItem.tsx create mode 100644 frontend/src/features/Vessel/components/VesselSearch/constants.ts create mode 100644 frontend/src/features/Vessel/components/VesselSearch/index.tsx create mode 100644 frontend/src/features/Vessel/components/VesselSearch/utils.ts diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 382ebb5f4c..a6a006e705 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -11,7 +11,7 @@ "dependencies": { "@dnd-kit/core": "6.1.0", "@dnd-kit/modifiers": "6.0.1", - "@mtes-mct/monitor-ui": "24.2.1", + "@mtes-mct/monitor-ui": "24.3.1", "@reduxjs/toolkit": "2.2.7", "@sentry/react": "8.35.0", "@tanstack/react-table": "8.20.5", @@ -2484,15 +2484,16 @@ "license": "BSD-2-Clause" }, "node_modules/@mtes-mct/monitor-ui": { - "version": "24.2.1", - "resolved": "https://registry.npmjs.org/@mtes-mct/monitor-ui/-/monitor-ui-24.2.1.tgz", - "integrity": "sha512-d2/dkGUWOLXQ+BWEdqhA+ixNeeGMjU1FX7r1+KFIGjUzgq3qcJKzoSyv91OqR+W1TcvNPONQJVLa12Fs0uYRzA==", + "version": "24.3.1", + "resolved": "https://registry.npmjs.org/@mtes-mct/monitor-ui/-/monitor-ui-24.3.1.tgz", + "integrity": "sha512-pMpqe721TFFP1f8PNC/2/Vsy/1RzfW9dtFsx4FEGZgdm8fFOMY5bhs5dohZU+6BuPQUiWRt24z1nZC8zrADvxw==", + "license": "AGPL-3.0", "dependencies": { "@babel/runtime": "7.25.7", "@tanstack/react-table": "8.20.5", "@tanstack/react-virtual": "beta", "prop-types": "15.8.1", - "tslib": "2.7.0" + "tslib": "2.8.0" }, "engines": { "node": ">=20" @@ -2736,6 +2737,7 @@ "version": "8.35.0", "resolved": "https://registry.npmjs.org/@sentry-internal/browser-utils/-/browser-utils-8.35.0.tgz", "integrity": "sha512-uj9nwERm7HIS13f/Q52hF/NUS5Al8Ma6jkgpfYGeppYvU0uSjPkwMogtqoJQNbOoZg973tV8qUScbcWY616wNA==", + "license": "MIT", "dependencies": { "@sentry/core": "8.35.0", "@sentry/types": "8.35.0", @@ -2749,6 +2751,7 @@ "version": "8.35.0", "resolved": "https://registry.npmjs.org/@sentry-internal/feedback/-/feedback-8.35.0.tgz", "integrity": "sha512-7bjSaUhL0bDArozre6EiIhhdWdT/1AWNWBC1Wc5w1IxEi5xF7nvF/FfvjQYrONQzZAI3HRxc45J2qhLUzHBmoQ==", + "license": "MIT", "dependencies": { "@sentry/core": "8.35.0", "@sentry/types": "8.35.0", @@ -2762,6 +2765,7 @@ "version": "8.35.0", "resolved": "https://registry.npmjs.org/@sentry-internal/replay/-/replay-8.35.0.tgz", "integrity": "sha512-3wkW03vXYMyWtTLxl9yrtkV+qxbnKFgfASdoGWhXzfLjycgT6o4/04eb3Gn71q9aXqRwH17ISVQbVswnRqMcmA==", + "license": "MIT", "dependencies": { "@sentry-internal/browser-utils": "8.35.0", "@sentry/core": "8.35.0", @@ -2776,6 +2780,7 @@ "version": "8.35.0", "resolved": "https://registry.npmjs.org/@sentry-internal/replay-canvas/-/replay-canvas-8.35.0.tgz", "integrity": "sha512-TUrH6Piv19kvHIiRyIuapLdnuwxk/Un/l1WDCQfq7mK9p1Pac0FkQ7Uufjp6zY3lyhDDZQ8qvCS4ioCMibCwQg==", + "license": "MIT", "dependencies": { "@sentry-internal/replay": "8.35.0", "@sentry/core": "8.35.0", @@ -2790,6 +2795,7 @@ "version": "8.35.0", "resolved": "https://registry.npmjs.org/@sentry/browser/-/browser-8.35.0.tgz", "integrity": "sha512-WHfI+NoZzpCsmIvtr6ChOe7yWPLQyMchPnVhY3Z4UeC70bkYNdKcoj/4XZbX3m0D8+71JAsm0mJ9s9OC3Ue6MQ==", + "license": "MIT", "dependencies": { "@sentry-internal/browser-utils": "8.35.0", "@sentry-internal/feedback": "8.35.0", @@ -2807,6 +2813,7 @@ "version": "8.35.0", "resolved": "https://registry.npmjs.org/@sentry/core/-/core-8.35.0.tgz", "integrity": "sha512-Ci0Nmtw5ETWLqQJGY4dyF+iWh7PWKy6k303fCEoEmqj2czDrKJCp7yHBNV0XYbo00prj2ZTbCr6I7albYiyONA==", + "license": "MIT", "dependencies": { "@sentry/types": "8.35.0", "@sentry/utils": "8.35.0" @@ -2819,6 +2826,7 @@ "version": "8.35.0", "resolved": "https://registry.npmjs.org/@sentry/react/-/react-8.35.0.tgz", "integrity": "sha512-8Y+s4pE9hvT2TwSo5JS/Enw2cNFlwiLcJDNGCj/Hho+FePFYA59hbN06ouTHWARnO+swANHKZQj24Wp57p1/tg==", + "license": "MIT", "dependencies": { "@sentry/browser": "8.35.0", "@sentry/core": "8.35.0", @@ -2837,6 +2845,7 @@ "version": "8.35.0", "resolved": "https://registry.npmjs.org/@sentry/types/-/types-8.35.0.tgz", "integrity": "sha512-AVEZjb16MlYPifiDDvJ19dPQyDn0jlrtC1PHs6ZKO+Rzyz+2EX2BRdszvanqArldexPoU1p5Bn2w81XZNXThBA==", + "license": "MIT", "engines": { "node": ">=14.18" } @@ -2845,6 +2854,7 @@ "version": "8.35.0", "resolved": "https://registry.npmjs.org/@sentry/utils/-/utils-8.35.0.tgz", "integrity": "sha512-MdMb6+uXjqND7qIPWhulubpSeHzia6HtxeJa8jYI09OCvIcmNGPydv/Gx/LZBwosfMHrLdTWcFH7Y7aCxrq7cg==", + "license": "MIT", "dependencies": { "@sentry/types": "8.35.0" }, @@ -17028,9 +17038,9 @@ } }, "node_modules/tslib": { - "version": "2.7.0", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.7.0.tgz", - "integrity": "sha512-gLXCKdN1/j47AiHiOkJN69hJmcbGTHI0ImLmbYLHykhgeN0jVGola9yVjFgzCUklsZQMW55o+dW7IXv3RCXDzA==", + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.0.tgz", + "integrity": "sha512-jWVzBLplnCmoaTr13V9dYbiQ99wvZRd0vNWaDRg+aVYRcjDF3nDksxFDE/+fkXnKhpnUUkmx5pK/v8mCtLVqZA==", "license": "0BSD" }, "node_modules/tsutils": { diff --git a/frontend/package.json b/frontend/package.json index 0d5d0c9296..ab3a66c170 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -36,7 +36,7 @@ "dependencies": { "@dnd-kit/core": "6.1.0", "@dnd-kit/modifiers": "6.0.1", - "@mtes-mct/monitor-ui": "24.2.1", + "@mtes-mct/monitor-ui": "24.3.1", "@reduxjs/toolkit": "2.2.7", "@sentry/react": "8.35.0", "@tanstack/react-table": "8.20.5", diff --git a/frontend/src/features/BackOffice/components/BackOfficeSubtitle.tsx b/frontend/src/features/BackOffice/components/BackOfficeSubtitle.tsx new file mode 100644 index 0000000000..b9258c3a75 --- /dev/null +++ b/frontend/src/features/BackOffice/components/BackOfficeSubtitle.tsx @@ -0,0 +1,10 @@ +import styled from 'styled-components' + +export const BackOfficeSubtitle = styled.h2<{ + $isFirst?: boolean + $withSmallBottomMargin?: boolean +}>` + font-size: 18px; + line-height: 1; + margin: ${p => (p.$isFirst ? 0 : 24)}px 0 ${p => (p.$withSmallBottomMargin ? 8 : 24)}px; +` diff --git a/frontend/src/features/BackOffice/components/BackOfficeTitle.tsx b/frontend/src/features/BackOffice/components/BackOfficeTitle.tsx index eb4340b1f9..d30ca192e4 100644 --- a/frontend/src/features/BackOffice/components/BackOfficeTitle.tsx +++ b/frontend/src/features/BackOffice/components/BackOfficeTitle.tsx @@ -1,14 +1,7 @@ import styled from 'styled-components' -export const BackOfficeTitle = styled.h2` - border-bottom: 2px solid ${p => p.theme.color.lightGray}; - color: #282f3e; - font-size: 16px; - font-weight: 700; +export const BackOfficeTitle = styled.h1` + font-size: 24px; line-height: 1; - margin-bottom: 12px; - padding-bottom: 5px; - text-align: left; - text-transform: uppercase; - width: fit-content; + margin: 0 0 24px; ` diff --git a/frontend/src/features/BackOffice/components/BackofficeMenu/index.tsx b/frontend/src/features/BackOffice/components/BackofficeMenu/index.tsx index f8a2dd4d1a..18f6b53097 100644 --- a/frontend/src/features/BackOffice/components/BackofficeMenu/index.tsx +++ b/frontend/src/features/BackOffice/components/BackofficeMenu/index.tsx @@ -35,6 +35,7 @@ const Wrapper = styled.div` flex-direction: column; letter-spacing: 0.5px; line-height: 1; + min-width: 200px; padding: 16px 24px; width: 200px; ` diff --git a/frontend/src/features/PriorNotification/PriorNotificationSubscriber.types.ts b/frontend/src/features/PriorNotification/PriorNotificationSubscriber.types.ts index 3285236278..42f61bedf7 100644 --- a/frontend/src/features/PriorNotification/PriorNotificationSubscriber.types.ts +++ b/frontend/src/features/PriorNotification/PriorNotificationSubscriber.types.ts @@ -41,6 +41,14 @@ export namespace PriorNotificationSubscriber { vesselName: string | undefined } + export type FormData = { + controlUnitId: number + portLocodes: string[] + portLocodesWithAllNotifications: string[] + segmentCodes: string[] + vesselIds: number[] + } + export enum ApiSortColumn { CONTROL_UNIT_NAME = 'CONTROL_UNIT_NAME' } diff --git a/frontend/src/features/PriorNotification/components/PriorNotificationSubscriberForm/FullPortSubscriptionsField.tsx b/frontend/src/features/PriorNotification/components/PriorNotificationSubscriberForm/FullPortSubscriptionsField.tsx new file mode 100644 index 0000000000..544144b8cc --- /dev/null +++ b/frontend/src/features/PriorNotification/components/PriorNotificationSubscriberForm/FullPortSubscriptionsField.tsx @@ -0,0 +1,68 @@ +import { BackOfficeSubtitle } from '@features/BackOffice/components/BackOfficeSubtitle' +import { useGetPortsAsOptions } from '@hooks/useGetPortsAsOptions' +import { DataTable, Select } from '@mtes-mct/monitor-ui' + +import { getPortSubscriptionTableColumns } from './columns' +import { Info } from './shared/Info' + +import type { PriorNotificationSubscriber } from '@features/PriorNotification/PriorNotificationSubscriber.types' +import type { Promisable } from 'type-fest' + +type FullPortSubscriptionsFieldProps = Readonly<{ + isDisabled: boolean + onAdd: (newPortLocode: string, isAllNotificationSubscription: boolean) => Promisable + onRemove: (portLocodeToRemove: string, isAllNotificationSubscription: boolean) => Promisable + portSubscriptions: PriorNotificationSubscriber.PortSubscription[] +}> +export function FullPortSubscriptionsField({ + isDisabled, + onAdd, + onRemove, + portSubscriptions +}: FullPortSubscriptionsFieldProps) { + const { portsAsOptions } = useGetPortsAsOptions() + + const add = (newPortLocode: string | undefined) => { + if (!newPortLocode) { + return + } + + onAdd(newPortLocode, true) + } + + const remove = (portLocodeToRemove: string) => { + onRemove(portLocodeToRemove, true) + } + + const columns = getPortSubscriptionTableColumns(remove, isDisabled) + + return ( + <> + + Ajouter tous les préavis d’un port à la diffusion + + + Tous les préavis de ces ports seront diffusés, sans faire partie du périmètre de vérification du CNSP. + + + `${originalRow.controlUnitId}-${originalRow.portLocode}` + }} + withoutHead + /> + + + + ) +} diff --git a/frontend/src/features/PriorNotification/components/PriorNotificationSubscriberForm/SegmentSubscriptionsField.tsx b/frontend/src/features/PriorNotification/components/PriorNotificationSubscriberForm/SegmentSubscriptionsField.tsx new file mode 100644 index 0000000000..7ed748470b --- /dev/null +++ b/frontend/src/features/PriorNotification/components/PriorNotificationSubscriberForm/SegmentSubscriptionsField.tsx @@ -0,0 +1,69 @@ +import { BackOfficeSubtitle } from '@features/BackOffice/components/BackOfficeSubtitle' +import { useGetFleetSegmentsAsOptions } from '@features/FleetSegment/hooks/useGetFleetSegmentsAsOptions' +import { DataTable, Select } from '@mtes-mct/monitor-ui' + +import { getSegmentSubscriptionTableColumns } from './columns' +import { Info } from './shared/Info' + +import type { PriorNotificationSubscriber } from '@features/PriorNotification/PriorNotificationSubscriber.types' +import type { Promisable } from 'type-fest' + +type SegmentSubscriptionsFieldProps = Readonly<{ + isDisabled: boolean + onAdd: (newSegmentCode: string) => Promisable + onRemove: (segmentCodeToRemove: string) => Promisable + segmentSubscriptions: PriorNotificationSubscriber.SegmentSubscription[] +}> +export function SegmentSubscriptionsField({ + isDisabled, + onAdd, + onRemove, + segmentSubscriptions +}: SegmentSubscriptionsFieldProps) { + const { fleetSegmentsAsOptions } = useGetFleetSegmentsAsOptions() + + const add = (newSegmentCode: string | undefined) => { + if (!newSegmentCode) { + return + } + + onAdd(newSegmentCode) + } + + const remove = (segmentCodeToRemove: string) => { + onRemove(segmentCodeToRemove) + } + + const columns = getSegmentSubscriptionTableColumns(remove, isDisabled) + + return ( + <> + + Ajouter tous les préavis d’un segment à la diffusion + + + Tous les préavis des navires appartenant à ces segments seront diffusés, sans faire partie du périmètre de + vérification du CNSP. + + + `${originalRow.controlUnitId}-${originalRow.segmentCode}` + }} + withoutHead + /> + + + {vesselName && isLinkToVesselSidebarDisplayed && ( + <> + {/* eslint-disable-next-line jsx-a11y/anchor-is-valid */} + + Voir la fiche + + + )} + {vesselName && ( + + )} + + + + ) +} + +const Wrapper = styled.div<{ + $extendedWidth: number | undefined + $isExtended: boolean +}>` + box-sizing: border-box; + width: ${p => (p.$isExtended && p.$extendedWidth !== undefined ? p.$extendedWidth : 320)}px; + transition: all 0.7s; + + * { + box-sizing: border-box; + } +` + +const Input = styled.input<{ + $baseUrl: string + $flagState: string | undefined + $hasError: boolean | undefined +}>` + margin: 0; + border: ${p => (p.$hasError ? '1px solid red' : 'none')}; + border-radius: 0; + border-radius: 2px; + color: ${p => p.theme.color.gunMetal}; + font-size: 13px; + font-weight: 500; + height: 40px; + width: 100%; + padding: 0 5px 0 10px; + flex: 3; + transition: all 0.7s; + background: ${p => + p.$flagState ? `url(${p.$baseUrl}/flags/${p.$flagState.toLowerCase()}.svg) no-repeat scroll, white` : 'white'}; + background-size: 20px; + background-position-y: center; + background-position-x: 16px; + padding-left: ${p => (p.$flagState ? 45 : 16)}px; + + &:disabled { + background-color: var(--rs-input-disabled-bg); + } + + &:hover, + &:focus { + border: none; + } +` + +const InputWrapper = styled.div` + position: relative; + + /* Clear icon button */ + > button { + position: absolute; + right: 7.5px; + top: 7.5px; + } + + /* Open vessel sidebar link */ + > a { + position: absolute; + right: 42px; + top: 11px; + cursor: pointer; + } +` diff --git a/frontend/src/features/Vessel/components/VesselSearch/utils.ts b/frontend/src/features/Vessel/components/VesselSearch/utils.ts new file mode 100644 index 0000000000..da6d271468 --- /dev/null +++ b/frontend/src/features/Vessel/components/VesselSearch/utils.ts @@ -0,0 +1,50 @@ +import { VesselIdentifier } from '../../../../domain/entities/vessel/types' + +import type { VesselIdentity } from '../../../../domain/entities/vessel/types' +import type { Vessel } from '@features/Vessel/Vessel.types' + +/** + * Remove duplicated vessels : keep vessels from APIs when a duplicate is found on either + * - internalReferenceNumber (CFR) or + * - vesselId (Vessel internal identifier) + */ +export function removeDuplicatedFoundVessels( + foundVesselsFromAPI: VesselIdentity[], + foundVesselsOnMap: VesselIdentity[] +): VesselIdentity[] { + const filteredVesselsFromMap = foundVesselsOnMap.filter(vesselFromMap => { + if (!vesselFromMap.internalReferenceNumber) { + return true + } + + return !foundVesselsFromAPI.some( + vesselFromApi => + vesselFromApi.internalReferenceNumber === vesselFromMap.internalReferenceNumber || + (vesselFromApi.vesselId && vesselFromApi.vesselId === vesselFromMap.vesselId) + ) + }) + + return foundVesselsFromAPI.concat(filteredVesselsFromMap).slice(0, 50) +} + +export function enrichWithVesselIdentifierIfNotFound( + identity: Vessel.VesselEnhancedObject | VesselIdentity +): VesselIdentity { + if (identity.vesselIdentifier) { + return identity + } + + if (identity.internalReferenceNumber) { + return { ...identity, vesselIdentifier: VesselIdentifier.INTERNAL_REFERENCE_NUMBER } + } + + if (identity.ircs) { + return { ...identity, vesselIdentifier: VesselIdentifier.IRCS } + } + + if (identity.externalReferenceNumber) { + return { ...identity, vesselIdentifier: VesselIdentifier.EXTERNAL_REFERENCE_NUMBER } + } + + return identity +} diff --git a/frontend/src/features/VesselSearch/index.tsx b/frontend/src/features/VesselSearch/index.tsx index 6641698359..19c228bf94 100644 --- a/frontend/src/features/VesselSearch/index.tsx +++ b/frontend/src/features/VesselSearch/index.tsx @@ -33,6 +33,7 @@ type VesselSearchProps = Omit, 'defaultVal onClickOutsideOrEscape?: () => Promisable onInputClick?: () => Promisable } +/** @deprecated Use `@features/Vessel/components/VesselSearch` instead. */ export function VesselSearch({ baseRef, className, diff --git a/frontend/src/paths.ts b/frontend/src/paths.ts index 21410b551c..4a4b7eb376 100644 --- a/frontend/src/paths.ts +++ b/frontend/src/paths.ts @@ -2,8 +2,7 @@ export const paths = { backendForFrontend: '/bff', backoffice: '/backoffice', controlObjectives: 'control_objectives', - controlUnitSubscribers: 'control_unit_subscribers', - editControlUnitSubscriber: 'control_unit_subscribers/:controlUnitId', + editPriorNotificationSubscriber: 'prior_notification_subscribers/:controlUnitId', editRegulation: 'regulation/edit', ext: '/ext', fleetSegments: 'fleet_segments', @@ -12,6 +11,7 @@ export const paths = { loadLight: '/load_light', login: '/login', newRegulation: 'regulation/new', + priorNotificationSubscribers: 'prior_notification_subscribers', register: '/register', regulation: 'regulation', sideWindow: '/side_window' diff --git a/frontend/src/router.tsx b/frontend/src/router.tsx index c824c8c15a..67efa90912 100644 --- a/frontend/src/router.tsx +++ b/frontend/src/router.tsx @@ -3,6 +3,7 @@ import { EditRegulation } from '@features/BackOffice/edit_regulation/EditRegulat import { ControlObjectiveTable } from '@features/ControlObjective/components/ControlObjectiveTable' import { FleetSegmentsBackoffice } from '@features/FleetSegment/components/FleetSegmentsBackoffice' import { MainWindow } from '@features/MainWindow' +import { PriorNotificationSubscriberForm } from '@features/PriorNotification/components/PriorNotificationSubscriberForm' import { PriorNotificationSubscriberTable } from '@features/PriorNotification/components/PriorNotificationSubscriberTable' import { SideWindow } from '@features/SideWindow' import { BackofficePage } from '@pages/BackofficePage' @@ -118,12 +119,20 @@ export const routes = [ ) }, { - path: paths.controlUnitSubscribers, + path: paths.priorNotificationSubscribers, element: ( ) + }, + { + path: paths.editPriorNotificationSubscriber, + element: ( + + + + ) } ] }, From 2528ef7e0dff28fd18f6bb86648ee115411ab0e3 Mon Sep 17 00:00:00 2001 From: Ivan Gabriele Date: Fri, 25 Oct 2024 05:44:26 +0200 Subject: [PATCH 23/59] Clean pno fleet segment naming --- ...orNotificationFleetSegmentSubscription.kt} | 2 +- .../PnoFleetSegmentSubscriptionRepository.kt | 20 ++++++++ .../PnoSegmentSubscriptionRepository.kt | 20 -------- .../ComputeManualPriorNotification.kt | 6 +-- .../CreateOrUpdateManualPriorNotification.kt | 4 +- .../GetPriorNotificationSubscriber.kt | 6 +-- .../GetPriorNotificationSubscribers.kt | 14 +++--- .../UpdatePriorNotificationSubscriber.kt | 14 +++--- .../dtos/PriorNotificationSubscriber.kt | 20 ++++---- .../PriorNotificationSubscriberController.kt | 4 +- .../PriorNotificationSubscriberDataInput.kt | 20 ++++---- ...tionFleetSegmentSubscriptionDataOutput.kt} | 10 ++-- .../PriorNotificationSubscriberDataOutput.kt | 15 +++--- .../PnoFleetSegmentSubscriptionEntity.kt | 41 ++++++++++++++++ .../entities/PnoSegmentSubscriptionEntity.kt | 41 ---------------- ...paPnoFleetSegmentSubscriptionRepository.kt | 49 +++++++++++++++++++ .../JpaPnoSegmentSubscriptionRepository.kt | 49 ------------------- ...noFleetSegmentsSubscriptionsRepository.kt} | 9 ++-- ...teOrUpdateManualPriorNotificationITests.kt | 2 +- ...teOrUpdateManualPriorNotificationUTests.kt | 6 +-- .../PriorNotificationSubscriber.types.ts | 20 ++++---- .../SegmentSubscriptionsField.tsx | 4 +- .../columns.tsx | 4 +- .../PriorNotificationSubscriberForm/index.tsx | 24 ++++----- .../PriorNotificationSubscriberForm/utils.ts | 8 +-- .../constants.tsx | 7 --- 26 files changed, 204 insertions(+), 215 deletions(-) rename backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/prior_notification/{PriorNotificationSegmentSubscription.kt => PriorNotificationFleetSegmentSubscription.kt} (74%) create mode 100644 backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/repositories/PnoFleetSegmentSubscriptionRepository.kt delete mode 100644 backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/repositories/PnoSegmentSubscriptionRepository.kt rename backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/{PriorNotificationSegmentSubscriptionDataOutput.kt => PriorNotificationFleetSegmentSubscriptionDataOutput.kt} (69%) create mode 100644 backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/PnoFleetSegmentSubscriptionEntity.kt delete mode 100644 backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/PnoSegmentSubscriptionEntity.kt create mode 100644 backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPnoFleetSegmentSubscriptionRepository.kt delete mode 100644 backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPnoSegmentSubscriptionRepository.kt rename backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/interfaces/{DBPnoSegmentsSubscriptionsRepository.kt => DBPnoFleetSegmentsSubscriptionsRepository.kt} (78%) diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/prior_notification/PriorNotificationSegmentSubscription.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/prior_notification/PriorNotificationFleetSegmentSubscription.kt similarity index 74% rename from backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/prior_notification/PriorNotificationSegmentSubscription.kt rename to backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/prior_notification/PriorNotificationFleetSegmentSubscription.kt index fb0ca8c554..41cb256fb5 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/prior_notification/PriorNotificationSegmentSubscription.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/prior_notification/PriorNotificationFleetSegmentSubscription.kt @@ -1,6 +1,6 @@ package fr.gouv.cnsp.monitorfish.domain.entities.prior_notification -data class PriorNotificationSegmentSubscription( +data class PriorNotificationFleetSegmentSubscription( val controlUnitId: Int, val segmentCode: String, val segmentName: String?, diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/repositories/PnoFleetSegmentSubscriptionRepository.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/repositories/PnoFleetSegmentSubscriptionRepository.kt new file mode 100644 index 0000000000..b8b74cedbc --- /dev/null +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/repositories/PnoFleetSegmentSubscriptionRepository.kt @@ -0,0 +1,20 @@ +package fr.gouv.cnsp.monitorfish.domain.repositories + +import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotificationFleetSegmentSubscription + +interface PnoFleetSegmentSubscriptionRepository { + fun deleteByControlUnitId(controlUnitId: Int) + + fun findAll(): List + + fun findByControlUnitId(controlUnitId: Int): List + + fun has( + portLocode: String, + segmentCodes: List, + ): Boolean + + fun saveAll( + priorNotificationFleetSegmentSubscriptions: List, + ): List +} diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/repositories/PnoSegmentSubscriptionRepository.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/repositories/PnoSegmentSubscriptionRepository.kt deleted file mode 100644 index db9e7a7cb0..0000000000 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/repositories/PnoSegmentSubscriptionRepository.kt +++ /dev/null @@ -1,20 +0,0 @@ -package fr.gouv.cnsp.monitorfish.domain.repositories - -import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotificationSegmentSubscription - -interface PnoSegmentSubscriptionRepository { - fun deleteByControlUnitId(controlUnitId: Int) - - fun findAll(): List - - fun findByControlUnitId(controlUnitId: Int): List - - fun has( - portLocode: String, - segmentCodes: List, - ): Boolean - - fun saveAll( - priorNotificationSegmentSubscriptions: List, - ): List -} diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/ComputeManualPriorNotification.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/ComputeManualPriorNotification.kt index a8dfa2a208..6cb8b4c850 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/ComputeManualPriorNotification.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/ComputeManualPriorNotification.kt @@ -4,8 +4,8 @@ import fr.gouv.cnsp.monitorfish.config.UseCase import fr.gouv.cnsp.monitorfish.domain.entities.logbook.LogbookFishingCatch import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.ManualPriorNotificationComputedValues import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotification +import fr.gouv.cnsp.monitorfish.domain.repositories.PnoFleetSegmentSubscriptionRepository import fr.gouv.cnsp.monitorfish.domain.repositories.PnoPortSubscriptionRepository -import fr.gouv.cnsp.monitorfish.domain.repositories.PnoSegmentSubscriptionRepository import fr.gouv.cnsp.monitorfish.domain.repositories.PnoVesselSubscriptionRepository import fr.gouv.cnsp.monitorfish.domain.repositories.VesselRepository import fr.gouv.cnsp.monitorfish.domain.use_cases.fleet_segment.ComputeFleetSegments @@ -13,7 +13,7 @@ import fr.gouv.cnsp.monitorfish.domain.use_cases.fleet_segment.ComputeFleetSegme @UseCase class ComputeManualPriorNotification( private val pnoPortSubscriptionRepository: PnoPortSubscriptionRepository, - private val pnoSegmentSubscriptionRepository: PnoSegmentSubscriptionRepository, + private val pnoFleetSegmentSubscriptionRepository: PnoFleetSegmentSubscriptionRepository, private val pnoVesselSubscriptionRepository: PnoVesselSubscriptionRepository, private val vesselRepository: VesselRepository, private val computeFleetSegments: ComputeFleetSegments, @@ -48,7 +48,7 @@ class ComputeManualPriorNotification( val isPartOfControlUnitSubscriptions = pnoPortSubscriptionRepository.has(portLocode) || pnoVesselSubscriptionRepository.has(vesselId) || - pnoSegmentSubscriptionRepository.has(portLocode, tripSegments.map { it.segment }) + pnoFleetSegmentSubscriptionRepository.has(portLocode, tripSegments.map { it.segment }) val nextState = PriorNotification.getNextState(isInVerificationScope, isPartOfControlUnitSubscriptions) return ManualPriorNotificationComputedValues( 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 5877037e45..db0c41ca6f 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 @@ -16,8 +16,8 @@ import java.time.ZonedDateTime class CreateOrUpdateManualPriorNotification( private val gearRepository: GearRepository, private val manualPriorNotificationRepository: ManualPriorNotificationRepository, + private val pnoFleetSegmentSubscriptionRepository: PnoFleetSegmentSubscriptionRepository, private val pnoPortSubscriptionRepository: PnoPortSubscriptionRepository, - private val pnoSegmentSubscriptionRepository: PnoSegmentSubscriptionRepository, private val pnoVesselSubscriptionRepository: PnoVesselSubscriptionRepository, private val portRepository: PortRepository, private val priorNotificationPdfDocumentRepository: PriorNotificationPdfDocumentRepository, @@ -69,7 +69,7 @@ class CreateOrUpdateManualPriorNotification( val isPartOfControlUnitSubscriptions = pnoPortSubscriptionRepository.has(portLocode) || pnoVesselSubscriptionRepository.has(vesselId) || - pnoSegmentSubscriptionRepository.has(portLocode, computedValues.tripSegments.map { it.segment }) + pnoFleetSegmentSubscriptionRepository.has(portLocode, computedValues.tripSegments.map { it.segment }) val fishingCatchesWithFaoArea = globalFaoArea?.let { fishingCatches.map { it.copy(faoZone = globalFaoArea) } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationSubscriber.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationSubscriber.kt index c9231be58f..d5c8ed7b1e 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationSubscriber.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationSubscriber.kt @@ -11,7 +11,7 @@ class GetPriorNotificationSubscriber( private val controlUnitRepository: ControlUnitRepository, private val fleetSegmentRepository: FleetSegmentRepository, private val pnoPortSubscriptionRepository: PnoPortSubscriptionRepository, - private val pnoSegmentSubscriptionRepository: PnoSegmentSubscriptionRepository, + private val pnoFleetSegmentSubscriptionRepository: PnoFleetSegmentSubscriptionRepository, private val pnoVesselSubscriptionRepository: PnoVesselSubscriptionRepository, private val portRepository: PortRepository, private val vesselRepository: VesselRepository, @@ -26,14 +26,14 @@ class GetPriorNotificationSubscriber( throw BackendUsageException(BackendUsageErrorCode.NOT_FOUND) } + val fleetSegmentSubscriptions = pnoFleetSegmentSubscriptionRepository.findByControlUnitId(id) val portSubscriptions = pnoPortSubscriptionRepository.findByControlUnitId(id) - val segmentSubscriptions = pnoSegmentSubscriptionRepository.findByControlUnitId(id) val vesselSubscriptions = pnoVesselSubscriptionRepository.findByControlUnitId(id) return PriorNotificationSubscriber.create( controlUnit, + fleetSegmentSubscriptions, portSubscriptions, - segmentSubscriptions, vesselSubscriptions, allFleetSegments, allPorts, diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationSubscribers.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationSubscribers.kt index dfa520088a..b3a2e79851 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationSubscribers.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationSubscribers.kt @@ -12,7 +12,7 @@ class GetPriorNotificationSubscribers( private val controlUnitRepository: ControlUnitRepository, private val fleetSegmentRepository: FleetSegmentRepository, private val pnoPortSubscriptionRepository: PnoPortSubscriptionRepository, - private val pnoSegmentSubscriptionRepository: PnoSegmentSubscriptionRepository, + private val pnoFleetSegmentSubscriptionRepository: PnoFleetSegmentSubscriptionRepository, private val pnoVesselSubscriptionRepository: PnoVesselSubscriptionRepository, private val portRepository: PortRepository, private val vesselRepository: VesselRepository, @@ -39,19 +39,19 @@ class GetPriorNotificationSubscribers( val allVessels = vesselRepository.findAll() val allControlUnits = controlUnitRepository.findAll() + val allFleetSegmentSubscriptions = pnoFleetSegmentSubscriptionRepository.findAll() val allPortSubscriptions = pnoPortSubscriptionRepository.findAll() - val allSegmentSubscriptions = pnoSegmentSubscriptionRepository.findAll() val allVesselSubscriptions = pnoVesselSubscriptionRepository.findAll() return allControlUnits.map { controlUnit -> + val fleetSegmentSubscriptions = + allFleetSegmentSubscriptions.filter { segmentSubscription -> + segmentSubscription.controlUnitId == controlUnit.id + } val portSubscriptions = allPortSubscriptions.filter { portSubscription -> portSubscription.controlUnitId == controlUnit.id } - val segmentSubscriptions = - allSegmentSubscriptions.filter { segmentSubscription -> - segmentSubscription.controlUnitId == controlUnit.id - } val vesselSubscriptions = allVesselSubscriptions.filter { vesselSubscription -> vesselSubscription.controlUnitId == controlUnit.id @@ -59,8 +59,8 @@ class GetPriorNotificationSubscribers( return@map PriorNotificationSubscriber.create( controlUnit, + fleetSegmentSubscriptions, portSubscriptions, - segmentSubscriptions, vesselSubscriptions, allFleetSegments, allPorts, diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/UpdatePriorNotificationSubscriber.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/UpdatePriorNotificationSubscriber.kt index 0f95d532fd..d64114b73a 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/UpdatePriorNotificationSubscriber.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/UpdatePriorNotificationSubscriber.kt @@ -1,15 +1,15 @@ package fr.gouv.cnsp.monitorfish.domain.use_cases.prior_notification import fr.gouv.cnsp.monitorfish.config.UseCase +import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotificationFleetSegmentSubscription import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotificationPortSubscription -import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotificationSegmentSubscription import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotificationVesselSubscription import fr.gouv.cnsp.monitorfish.domain.exceptions.BackendUsageErrorCode import fr.gouv.cnsp.monitorfish.domain.exceptions.BackendUsageException import fr.gouv.cnsp.monitorfish.domain.repositories.ControlUnitRepository import fr.gouv.cnsp.monitorfish.domain.repositories.FleetSegmentRepository +import fr.gouv.cnsp.monitorfish.domain.repositories.PnoFleetSegmentSubscriptionRepository import fr.gouv.cnsp.monitorfish.domain.repositories.PnoPortSubscriptionRepository -import fr.gouv.cnsp.monitorfish.domain.repositories.PnoSegmentSubscriptionRepository import fr.gouv.cnsp.monitorfish.domain.repositories.PnoVesselSubscriptionRepository import fr.gouv.cnsp.monitorfish.domain.repositories.PortRepository import fr.gouv.cnsp.monitorfish.domain.repositories.VesselRepository @@ -20,15 +20,15 @@ class UpdatePriorNotificationSubscriber( private val controlUnitRepository: ControlUnitRepository, private val fleetSegmentRepository: FleetSegmentRepository, private val pnoPortSubscriptionRepository: PnoPortSubscriptionRepository, - private val pnoSegmentSubscriptionRepository: PnoSegmentSubscriptionRepository, + private val pnoFleetSegmentSubscriptionRepository: PnoFleetSegmentSubscriptionRepository, private val pnoVesselSubscriptionRepository: PnoVesselSubscriptionRepository, private val portRepository: PortRepository, private val vesselRepository: VesselRepository, ) { fun execute( controlUnitId: Int, + fleetSegmentSubscriptions: List, portSubscriptions: List, - segmentSubscriptions: List, vesselSubscriptions: List, ): PriorNotificationSubscriber { val allFleetSegments = fleetSegmentRepository.findAll() @@ -41,16 +41,16 @@ class UpdatePriorNotificationSubscriber( } pnoPortSubscriptionRepository.deleteByControlUnitId(controlUnitId) - pnoSegmentSubscriptionRepository.deleteByControlUnitId(controlUnitId) + pnoFleetSegmentSubscriptionRepository.deleteByControlUnitId(controlUnitId) pnoVesselSubscriptionRepository.deleteByControlUnitId(controlUnitId) + pnoFleetSegmentSubscriptionRepository.saveAll(fleetSegmentSubscriptions) pnoPortSubscriptionRepository.saveAll(portSubscriptions) - pnoSegmentSubscriptionRepository.saveAll(segmentSubscriptions) pnoVesselSubscriptionRepository.saveAll(vesselSubscriptions) return PriorNotificationSubscriber.create( controlUnit, + fleetSegmentSubscriptions, portSubscriptions, - segmentSubscriptions, vesselSubscriptions, allFleetSegments, allPorts, diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/dtos/PriorNotificationSubscriber.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/dtos/PriorNotificationSubscriber.kt index 6d8d85e10d..d0486fd89d 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/dtos/PriorNotificationSubscriber.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/dtos/PriorNotificationSubscriber.kt @@ -2,23 +2,23 @@ package fr.gouv.cnsp.monitorfish.domain.use_cases.prior_notification.dtos import fr.gouv.cnsp.monitorfish.domain.entities.fleet_segment.FleetSegment import fr.gouv.cnsp.monitorfish.domain.entities.port.Port +import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotificationFleetSegmentSubscription import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotificationPortSubscription -import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotificationSegmentSubscription import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotificationVesselSubscription import fr.gouv.cnsp.monitorfish.domain.entities.vessel.Vessel import fr.gouv.cnsp.monitorfish.domain.use_cases.control_units.dtos.FullControlUnit data class PriorNotificationSubscriber( val controlUnit: FullControlUnit, + val fleetSegmentSubscriptions: List, val portSubscriptions: List, - val segmentSubscriptions: List, val vesselSubscriptions: List, ) { companion object { fun create( controlUnit: FullControlUnit, + fleetSegmentSubscriptions: List, portSubscriptions: List, - segmentSubscriptions: List, vesselSubscriptions: List, allFleetSegments: List, allPorts: List, @@ -26,18 +26,18 @@ data class PriorNotificationSubscriber( ): PriorNotificationSubscriber { portSubscriptions.any { portSubscription -> portSubscription.hasSubscribedToAllPriorNotifications } + val namedFleetSegmentSubscriptions = + fleetSegmentSubscriptions.map { fleetSegmentSubscription -> + val fleetSegment = allFleetSegments.find { it.segment == fleetSegmentSubscription.segmentCode } + + return@map fleetSegmentSubscription.copy(segmentName = fleetSegment?.segmentName) + } val namedPortSubscriptions = portSubscriptions.map { portSubscription -> val port = allPorts.find { it.locode == portSubscription.portLocode } return@map portSubscription.copy(portName = port?.name) } - val namedSegmentSubscriptions = - segmentSubscriptions.map { fleetSegmentSubscription -> - val fleetSegment = allFleetSegments.find { it.segment == fleetSegmentSubscription.segmentCode } - - return@map fleetSegmentSubscription.copy(segmentName = fleetSegment?.segmentName) - } val namedVesselSubscriptions = vesselSubscriptions.map { vesselSubscription -> val vessel = allVessels.find { it.id == vesselSubscription.vesselId } @@ -47,8 +47,8 @@ data class PriorNotificationSubscriber( return PriorNotificationSubscriber( controlUnit, + fleetSegmentSubscriptions = namedFleetSegmentSubscriptions, portSubscriptions = namedPortSubscriptions, - segmentSubscriptions = namedSegmentSubscriptions, vesselSubscriptions = namedVesselSubscriptions, ) } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/PriorNotificationSubscriberController.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/PriorNotificationSubscriberController.kt index 78437dcc42..bfaa8747d3 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/PriorNotificationSubscriberController.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/PriorNotificationSubscriberController.kt @@ -76,15 +76,15 @@ class PriorNotificationSubscriberController( @RequestBody priorNotificationSubscriberDataInput: PriorNotificationSubscriberDataInput, ): PriorNotificationSubscriberDataOutput { - val (portSubscriptions, segmentSubscriptions, vesselSubscriptions) = + val (fleetSegmentSubscriptions, portSubscriptions, vesselSubscriptions) = priorNotificationSubscriberDataInput.toSubscriptions() println("controlUnitId: $controlUnitId") val updatedPriorNotificationSubscriber = updatePriorNotificationSubscriber.execute( controlUnitId, + fleetSegmentSubscriptions, portSubscriptions, - segmentSubscriptions, vesselSubscriptions, ) diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/input/PriorNotificationSubscriberDataInput.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/input/PriorNotificationSubscriberDataInput.kt index 3996b42c3c..e13c4cbde1 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/input/PriorNotificationSubscriberDataInput.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/input/PriorNotificationSubscriberDataInput.kt @@ -1,35 +1,35 @@ package fr.gouv.cnsp.monitorfish.infrastructure.api.input +import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotificationFleetSegmentSubscription import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotificationPortSubscription -import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotificationSegmentSubscription import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotificationVesselSubscription data class PriorNotificationSubscriberDataInput( val controlUnitId: Int, + val fleetSegmentCodes: List, val portLocodes: List, - val portLocodesWithAllNotifications: List, - val segmentCodes: List, + val portLocodesWithFullSubscription: List, val vesselIds: List, ) { - fun toSubscriptions(): Triple, List, List> { + fun toSubscriptions(): Triple, List, List> { + val fleetSegmentSubscriptions = + fleetSegmentCodes.map { segmentCode -> + PriorNotificationFleetSegmentSubscription(controlUnitId, segmentCode, null) + } val portSubscriptions = portLocodes.map { portLocode -> - val hasSubscribedToAllPriorNotifications = portLocodesWithAllNotifications.contains(portLocode) + val hasSubscribedToAllPriorNotifications = portLocodesWithFullSubscription.contains(portLocode) PriorNotificationPortSubscription(controlUnitId, portLocode, null, hasSubscribedToAllPriorNotifications) } - val segmentSubscriptions = - segmentCodes.map { segmentCode -> - PriorNotificationSegmentSubscription(controlUnitId, segmentCode, null) - } val vesselSubscriptions = vesselIds.map { vesselId -> PriorNotificationVesselSubscription(controlUnitId, vesselId, null) } return Triple( + fleetSegmentSubscriptions, portSubscriptions, - segmentSubscriptions, vesselSubscriptions, ) } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/PriorNotificationSegmentSubscriptionDataOutput.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/PriorNotificationFleetSegmentSubscriptionDataOutput.kt similarity index 69% rename from backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/PriorNotificationSegmentSubscriptionDataOutput.kt rename to backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/PriorNotificationFleetSegmentSubscriptionDataOutput.kt index 31ef312a6c..8405741707 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/PriorNotificationSegmentSubscriptionDataOutput.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/PriorNotificationFleetSegmentSubscriptionDataOutput.kt @@ -1,17 +1,17 @@ package fr.gouv.cnsp.monitorfish.infrastructure.api.outputs -import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotificationSegmentSubscription +import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotificationFleetSegmentSubscription -data class PriorNotificationSegmentSubscriptionDataOutput( +data class PriorNotificationFleetSegmentSubscriptionDataOutput( val controlUnitId: Int, val segmentCode: String, val segmentName: String?, ) { companion object { fun fromPriorNotificationSegmentSubscription( - priorNotificationFleetSegmentSubscription: PriorNotificationSegmentSubscription, - ): PriorNotificationSegmentSubscriptionDataOutput { - return PriorNotificationSegmentSubscriptionDataOutput( + priorNotificationFleetSegmentSubscription: PriorNotificationFleetSegmentSubscription, + ): PriorNotificationFleetSegmentSubscriptionDataOutput { + return PriorNotificationFleetSegmentSubscriptionDataOutput( controlUnitId = priorNotificationFleetSegmentSubscription.controlUnitId, segmentCode = priorNotificationFleetSegmentSubscription.segmentCode, segmentName = priorNotificationFleetSegmentSubscription.segmentName, diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/PriorNotificationSubscriberDataOutput.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/PriorNotificationSubscriberDataOutput.kt index 2f997bb68e..3475a888b3 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/PriorNotificationSubscriberDataOutput.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/PriorNotificationSubscriberDataOutput.kt @@ -3,11 +3,9 @@ package fr.gouv.cnsp.monitorfish.infrastructure.api.outputs import fr.gouv.cnsp.monitorfish.domain.use_cases.prior_notification.dtos.PriorNotificationSubscriber data class PriorNotificationSubscriberDataOutput( - /** Control unit ID. */ - val id: Int, val controlUnit: ControlUnitDataOutput, + val fleetSegmentSubscriptions: List, val portSubscriptions: List, - val segmentSubscriptions: List, val vesselSubscriptions: List, ) { companion object { @@ -15,24 +13,23 @@ data class PriorNotificationSubscriberDataOutput( priorNotificationSubscriber: PriorNotificationSubscriber, ): PriorNotificationSubscriberDataOutput { val controlUnit = ControlUnitDataOutput.fromFullControlUnit(priorNotificationSubscriber.controlUnit) + val fleetSegmentSubscriptions = + priorNotificationSubscriber.fleetSegmentSubscriptions.map { + PriorNotificationFleetSegmentSubscriptionDataOutput.fromPriorNotificationSegmentSubscription(it) + } val portSubscriptions = priorNotificationSubscriber.portSubscriptions.map { PriorNotificationPortSubscriptionDataOutput.fromPriorNotificationPortSubscription(it) } - val segmentSubscriptions = - priorNotificationSubscriber.segmentSubscriptions.map { - PriorNotificationSegmentSubscriptionDataOutput.fromPriorNotificationSegmentSubscription(it) - } val vesselSubscriptions = priorNotificationSubscriber.vesselSubscriptions.map { PriorNotificationVesselSubscriptionDataOutput.fromPriorNotificationVesselSubscription(it) } return PriorNotificationSubscriberDataOutput( - id = controlUnit.id, controlUnit, + fleetSegmentSubscriptions, portSubscriptions, - segmentSubscriptions, vesselSubscriptions, ) } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/PnoFleetSegmentSubscriptionEntity.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/PnoFleetSegmentSubscriptionEntity.kt new file mode 100644 index 0000000000..fbc59dc199 --- /dev/null +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/PnoFleetSegmentSubscriptionEntity.kt @@ -0,0 +1,41 @@ +package fr.gouv.cnsp.monitorfish.infrastructure.database.entities + +import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotificationFleetSegmentSubscription +import jakarta.persistence.* +import java.io.Serializable + +@Embeddable +class PnoFleetSegmentSubscriptionId( + val controlUnitId: Int, + @Column(name = "segment", updatable = false) + val segmentCode: String, +) : Serializable + +@Entity +@Table(name = "pno_segments_subscriptions") +data class PnoFleetSegmentSubscriptionEntity( + @EmbeddedId + val id: PnoFleetSegmentSubscriptionId, +) { + fun toPriorNotificationFleetSegmentSubscription(): PriorNotificationFleetSegmentSubscription { + return PriorNotificationFleetSegmentSubscription( + controlUnitId = id.controlUnitId, + segmentCode = id.segmentCode, + segmentName = null, + ) + } + + companion object { + fun fromPriorNotificationFleetSegmentSubscription( + priorNotificationFleetSegmentSubscription: PriorNotificationFleetSegmentSubscription, + ): PnoFleetSegmentSubscriptionEntity { + return PnoFleetSegmentSubscriptionEntity( + id = + PnoFleetSegmentSubscriptionId( + controlUnitId = priorNotificationFleetSegmentSubscription.controlUnitId, + segmentCode = priorNotificationFleetSegmentSubscription.segmentCode, + ), + ) + } + } +} diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/PnoSegmentSubscriptionEntity.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/PnoSegmentSubscriptionEntity.kt deleted file mode 100644 index d251dba448..0000000000 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/PnoSegmentSubscriptionEntity.kt +++ /dev/null @@ -1,41 +0,0 @@ -package fr.gouv.cnsp.monitorfish.infrastructure.database.entities - -import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotificationSegmentSubscription -import jakarta.persistence.* -import java.io.Serializable - -@Embeddable -class PnoSegmentSubscriptionId( - val controlUnitId: Int, - @Column(name = "segment", updatable = false) - val segmentCode: String, -) : Serializable - -@Entity -@Table(name = "pno_segments_subscriptions") -data class PnoSegmentSubscriptionEntity( - @EmbeddedId - val id: PnoSegmentSubscriptionId, -) { - fun toPriorNotificationSegmentSubscription(): PriorNotificationSegmentSubscription { - return PriorNotificationSegmentSubscription( - controlUnitId = id.controlUnitId, - segmentCode = id.segmentCode, - segmentName = null, - ) - } - - companion object { - fun fromPriorNotificationSegmentSubscription( - priorNotificationSegmentSubscription: PriorNotificationSegmentSubscription, - ): PnoSegmentSubscriptionEntity { - return PnoSegmentSubscriptionEntity( - id = - PnoSegmentSubscriptionId( - controlUnitId = priorNotificationSegmentSubscription.controlUnitId, - segmentCode = priorNotificationSegmentSubscription.segmentCode, - ), - ) - } - } -} diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPnoFleetSegmentSubscriptionRepository.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPnoFleetSegmentSubscriptionRepository.kt new file mode 100644 index 0000000000..3fb6c31429 --- /dev/null +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPnoFleetSegmentSubscriptionRepository.kt @@ -0,0 +1,49 @@ +package fr.gouv.cnsp.monitorfish.infrastructure.database.repositories + +import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotificationFleetSegmentSubscription +import fr.gouv.cnsp.monitorfish.domain.repositories.PnoFleetSegmentSubscriptionRepository +import fr.gouv.cnsp.monitorfish.infrastructure.database.entities.PnoFleetSegmentSubscriptionEntity +import fr.gouv.cnsp.monitorfish.infrastructure.database.repositories.interfaces.DBPnoFleetSegmentsSubscriptionsRepository +import jakarta.transaction.Transactional +import org.springframework.stereotype.Repository + +@Repository +class JpaPnoFleetSegmentSubscriptionRepository( + private val dbPnoFleetSegmentsSubscriptionsRepository: DBPnoFleetSegmentsSubscriptionsRepository, +) : PnoFleetSegmentSubscriptionRepository { + @Transactional + override fun deleteByControlUnitId(controlUnitId: Int) { + dbPnoFleetSegmentsSubscriptionsRepository.deleteByControlUnitId(controlUnitId) + } + + override fun findAll(): List { + return dbPnoFleetSegmentsSubscriptionsRepository.findAll() + .map { it.toPriorNotificationFleetSegmentSubscription() } + } + + override fun findByControlUnitId(controlUnitId: Int): List { + return dbPnoFleetSegmentsSubscriptionsRepository.findByControlUnitId(controlUnitId) + .map { it.toPriorNotificationFleetSegmentSubscription() } + } + + override fun has( + portLocode: String, + segmentCodes: List, + ): Boolean { + return dbPnoFleetSegmentsSubscriptionsRepository.countByPortLocodeAndSegmentCodes(portLocode, segmentCodes) > 0 + } + + @Transactional + override fun saveAll( + priorNotificationFleetSegmentSubscriptions: List, + ): List { + return dbPnoFleetSegmentsSubscriptionsRepository.saveAll( + priorNotificationFleetSegmentSubscriptions.map { + PnoFleetSegmentSubscriptionEntity.fromPriorNotificationFleetSegmentSubscription( + it, + ) + }, + ) + .map { it.toPriorNotificationFleetSegmentSubscription() } + } +} diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPnoSegmentSubscriptionRepository.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPnoSegmentSubscriptionRepository.kt deleted file mode 100644 index 9f027eaf00..0000000000 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/JpaPnoSegmentSubscriptionRepository.kt +++ /dev/null @@ -1,49 +0,0 @@ -package fr.gouv.cnsp.monitorfish.infrastructure.database.repositories - -import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotificationSegmentSubscription -import fr.gouv.cnsp.monitorfish.domain.repositories.PnoSegmentSubscriptionRepository -import fr.gouv.cnsp.monitorfish.infrastructure.database.entities.PnoSegmentSubscriptionEntity -import fr.gouv.cnsp.monitorfish.infrastructure.database.repositories.interfaces.DBPnoSegmentsSubscriptionsRepository -import jakarta.transaction.Transactional -import org.springframework.stereotype.Repository - -@Repository -class JpaPnoSegmentSubscriptionRepository( - private val dbPnoSegmentsSubscriptionsRepository: DBPnoSegmentsSubscriptionsRepository, -) : PnoSegmentSubscriptionRepository { - @Transactional - override fun deleteByControlUnitId(controlUnitId: Int) { - dbPnoSegmentsSubscriptionsRepository.deleteByControlUnitId(controlUnitId) - } - - override fun findAll(): List { - return dbPnoSegmentsSubscriptionsRepository.findAll() - .map { it.toPriorNotificationSegmentSubscription() } - } - - override fun findByControlUnitId(controlUnitId: Int): List { - return dbPnoSegmentsSubscriptionsRepository.findByControlUnitId(controlUnitId) - .map { it.toPriorNotificationSegmentSubscription() } - } - - override fun has( - portLocode: String, - segmentCodes: List, - ): Boolean { - return dbPnoSegmentsSubscriptionsRepository.countByPortLocodeAndSegmentCodes(portLocode, segmentCodes) > 0 - } - - @Transactional - override fun saveAll( - priorNotificationSegmentSubscriptions: List, - ): List { - return dbPnoSegmentsSubscriptionsRepository.saveAll( - priorNotificationSegmentSubscriptions.map { - PnoSegmentSubscriptionEntity.fromPriorNotificationSegmentSubscription( - it, - ) - }, - ) - .map { it.toPriorNotificationSegmentSubscription() } - } -} diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/interfaces/DBPnoSegmentsSubscriptionsRepository.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/interfaces/DBPnoFleetSegmentsSubscriptionsRepository.kt similarity index 78% rename from backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/interfaces/DBPnoSegmentsSubscriptionsRepository.kt rename to backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/interfaces/DBPnoFleetSegmentsSubscriptionsRepository.kt index 6362e35260..456199cda4 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/interfaces/DBPnoSegmentsSubscriptionsRepository.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/interfaces/DBPnoFleetSegmentsSubscriptionsRepository.kt @@ -1,12 +1,13 @@ package fr.gouv.cnsp.monitorfish.infrastructure.database.repositories.interfaces -import fr.gouv.cnsp.monitorfish.infrastructure.database.entities.PnoSegmentSubscriptionEntity -import fr.gouv.cnsp.monitorfish.infrastructure.database.entities.PnoSegmentSubscriptionId +import fr.gouv.cnsp.monitorfish.infrastructure.database.entities.PnoFleetSegmentSubscriptionEntity +import fr.gouv.cnsp.monitorfish.infrastructure.database.entities.PnoFleetSegmentSubscriptionId import org.springframework.data.jpa.repository.JpaRepository import org.springframework.data.jpa.repository.Modifying import org.springframework.data.jpa.repository.Query -interface DBPnoSegmentsSubscriptionsRepository : JpaRepository { +interface DBPnoFleetSegmentsSubscriptionsRepository : + JpaRepository { @Query( """ SELECT COUNT(*) @@ -26,5 +27,5 @@ interface DBPnoSegmentsSubscriptionsRepository : JpaRepository + fun findByControlUnitId(controlUnitId: Int): List } diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/CreateOrUpdateManualPriorNotificationITests.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/CreateOrUpdateManualPriorNotificationITests.kt index b9d7761d01..dd959fa80e 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/CreateOrUpdateManualPriorNotificationITests.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/CreateOrUpdateManualPriorNotificationITests.kt @@ -38,7 +38,7 @@ class CreateOrUpdateManualPriorNotificationITests : AbstractDBTests() { private lateinit var pnoPortSubscriptionRepository: PnoPortSubscriptionRepository @Autowired - private lateinit var pnoSegmentSubscriptionRepository: PnoSegmentSubscriptionRepository + private lateinit var pnoFleetSegmentSubscriptionRepository: PnoFleetSegmentSubscriptionRepository @Autowired private lateinit var pnoVesselSubscriptionRepository: PnoVesselSubscriptionRepository diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/CreateOrUpdateManualPriorNotificationUTests.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/CreateOrUpdateManualPriorNotificationUTests.kt index b656cf82ac..1606e4b034 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/CreateOrUpdateManualPriorNotificationUTests.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/CreateOrUpdateManualPriorNotificationUTests.kt @@ -27,7 +27,7 @@ class CreateOrUpdateManualPriorNotificationUTests { private lateinit var pnoPortSubscriptionRepository: PnoPortSubscriptionRepository @MockBean - private lateinit var pnoSegmentSubscriptionRepository: PnoSegmentSubscriptionRepository + private lateinit var pnoFleetSegmentSubscriptionRepository: PnoFleetSegmentSubscriptionRepository @MockBean private lateinit var pnoVesselSubscriptionRepository: PnoVesselSubscriptionRepository @@ -76,8 +76,8 @@ class CreateOrUpdateManualPriorNotificationUTests { CreateOrUpdateManualPriorNotification( gearRepository, manualPriorNotificationRepository, + pnoFleetSegmentSubscriptionRepository, pnoPortSubscriptionRepository, - pnoSegmentSubscriptionRepository, pnoVesselSubscriptionRepository, portRepository, priorNotificationPdfDocumentRepository, @@ -139,8 +139,8 @@ class CreateOrUpdateManualPriorNotificationUTests { CreateOrUpdateManualPriorNotification( gearRepository, manualPriorNotificationRepository, + pnoFleetSegmentSubscriptionRepository, pnoPortSubscriptionRepository, - pnoSegmentSubscriptionRepository, pnoVesselSubscriptionRepository, portRepository, priorNotificationPdfDocumentRepository, diff --git a/frontend/src/features/PriorNotification/PriorNotificationSubscriber.types.ts b/frontend/src/features/PriorNotification/PriorNotificationSubscriber.types.ts index 42f61bedf7..f77ecab762 100644 --- a/frontend/src/features/PriorNotification/PriorNotificationSubscriber.types.ts +++ b/frontend/src/features/PriorNotification/PriorNotificationSubscriber.types.ts @@ -1,10 +1,8 @@ export namespace PriorNotificationSubscriber { export interface Subscriber { controlUnit: ControlUnit - /** Control unit ID. */ - id: number + fleetSegmentSubscriptions: FleetSegmentSubscription[] portSubscriptions: PortSubscription[] - segmentSubscriptions: SegmentSubscription[] vesselSubscriptions: VesselSubscription[] } @@ -21,18 +19,18 @@ export namespace PriorNotificationSubscriber { name: String } - export type PortSubscription = { + export type FleetSegmentSubscription = { controlUnitId: number hasSubscribedToAllPriorNotifications: boolean - portLocode: string - portName: string | undefined + segmentCode: string + segmentName: string | undefined } - export type SegmentSubscription = { + export type PortSubscription = { controlUnitId: number hasSubscribedToAllPriorNotifications: boolean - segmentCode: string - segmentName: string | undefined + portLocode: string + portName: string | undefined } export type VesselSubscription = { @@ -43,9 +41,9 @@ export namespace PriorNotificationSubscriber { export type FormData = { controlUnitId: number + fleetSegmentCodes: string[] portLocodes: string[] - portLocodesWithAllNotifications: string[] - segmentCodes: string[] + portLocodesWithFullSubscription: string[] vesselIds: number[] } diff --git a/frontend/src/features/PriorNotification/components/PriorNotificationSubscriberForm/SegmentSubscriptionsField.tsx b/frontend/src/features/PriorNotification/components/PriorNotificationSubscriberForm/SegmentSubscriptionsField.tsx index 7ed748470b..031d935060 100644 --- a/frontend/src/features/PriorNotification/components/PriorNotificationSubscriberForm/SegmentSubscriptionsField.tsx +++ b/frontend/src/features/PriorNotification/components/PriorNotificationSubscriberForm/SegmentSubscriptionsField.tsx @@ -12,7 +12,7 @@ type SegmentSubscriptionsFieldProps = Readonly<{ isDisabled: boolean onAdd: (newSegmentCode: string) => Promisable onRemove: (segmentCodeToRemove: string) => Promisable - segmentSubscriptions: PriorNotificationSubscriber.SegmentSubscription[] + segmentSubscriptions: PriorNotificationSubscriber.FleetSegmentSubscription[] }> export function SegmentSubscriptionsField({ isDisabled, @@ -49,7 +49,7 @@ export function SegmentSubscriptionsField({ `${originalRow.controlUnitId}-${originalRow.segmentCode}` }} diff --git a/frontend/src/features/PriorNotification/components/PriorNotificationSubscriberForm/columns.tsx b/frontend/src/features/PriorNotification/components/PriorNotificationSubscriberForm/columns.tsx index 316597fb7b..0584589604 100644 --- a/frontend/src/features/PriorNotification/components/PriorNotificationSubscriberForm/columns.tsx +++ b/frontend/src/features/PriorNotification/components/PriorNotificationSubscriberForm/columns.tsx @@ -36,7 +36,7 @@ export function getPortSubscriptionTableColumns( export function getSegmentSubscriptionTableColumns( onRemove: (segmentCodeToRemove: string) => Promisable, isDisabled: boolean -): Array> { +): Array> { return [ { accessorFn: row => `${row.segmentCode} (${row.segmentName})`, @@ -45,7 +45,7 @@ export function getSegmentSubscriptionTableColumns( }, { accessorFn: row => row.segmentCode, - cell: (context: CellContext) => ( + cell: (context: CellContext) => ( } - const formData = getSubscriberFormDataFromSubscriber(subscriber) + const formData = getFormDataFromSubscriber(subscriber) const limitedPortSubscriptions = subscriber.portSubscriptions const fullPortSubscriptions = subscriber.portSubscriptions.filter( portSubscription => portSubscription.hasSubscribedToAllPriorNotifications @@ -42,22 +42,22 @@ export function PriorNotificationSubscriberForm() { const addPortSubscription = (newPortLocode: string, isAllNotificationSubscription: boolean) => { const nextPortLocodes = [...formData.portLocodes, newPortLocode] const nextPortLocodesWithAllNotifications = isAllNotificationSubscription - ? [...formData.portLocodesWithAllNotifications, newPortLocode] - : formData.portLocodesWithAllNotifications + ? [...formData.portLocodesWithFullSubscription, newPortLocode] + : formData.portLocodesWithFullSubscription update({ ...formData, portLocodes: nextPortLocodes, - portLocodesWithAllNotifications: nextPortLocodesWithAllNotifications + portLocodesWithFullSubscription: nextPortLocodesWithAllNotifications }) } const addSegmentSubscription = (newSegmentCode: string) => { - const nextSegmentCodes = [...formData.segmentCodes, newSegmentCode] + const nextSegmentCodes = [...formData.fleetSegmentCodes, newSegmentCode] update({ ...formData, - segmentCodes: nextSegmentCodes + fleetSegmentCodes: nextSegmentCodes }) } @@ -74,23 +74,23 @@ export function PriorNotificationSubscriberForm() { const nextPortLocodes = isAllNotificationSubscription ? formData.portLocodes : formData.portLocodes.filter(portLocode => portLocode !== portLocodeToRemove) - const nextPortLocodesWithAllNotifications = formData.portLocodesWithAllNotifications.filter( + const nextPortLocodesWithAllNotifications = formData.portLocodesWithFullSubscription.filter( portLocode => portLocode !== portLocodeToRemove ) update({ ...formData, portLocodes: nextPortLocodes, - portLocodesWithAllNotifications: nextPortLocodesWithAllNotifications + portLocodesWithFullSubscription: nextPortLocodesWithAllNotifications }) } const removeSegementSubscription = (segmentCodeToRemove: string) => { - const nextSegmentCodes = formData.segmentCodes.filter(segmentCode => segmentCode !== segmentCodeToRemove) + const nextSegmentCodes = formData.fleetSegmentCodes.filter(segmentCode => segmentCode !== segmentCodeToRemove) update({ ...formData, - segmentCodes: nextSegmentCodes + fleetSegmentCodes: nextSegmentCodes }) } @@ -126,7 +126,7 @@ export function PriorNotificationSubscriberForm() { isDisabled={isFetching} onAdd={addSegmentSubscription} onRemove={removeSegementSubscription} - segmentSubscriptions={subscriber.segmentSubscriptions} + segmentSubscriptions={subscriber.fleetSegmentSubscriptions} /> subscription.segmentCode), portLocodes: subscriber.portSubscriptions.map(subscription => subscription.portLocode), - portLocodesWithAllNotifications: subscriber.portSubscriptions + portLocodesWithFullSubscription: subscriber.portSubscriptions .filter(subscription => subscription.hasSubscribedToAllPriorNotifications) .map(subscription => subscription.portLocode), - segmentCodes: subscriber.segmentSubscriptions.map(subscription => subscription.segmentCode), vesselIds: subscriber.vesselSubscriptions.map(subscription => subscription.vesselId) } } diff --git a/frontend/src/features/PriorNotification/components/PriorNotificationSubscriberTable/constants.tsx b/frontend/src/features/PriorNotification/components/PriorNotificationSubscriberTable/constants.tsx index 59e2ba58c4..629bfb81bb 100644 --- a/frontend/src/features/PriorNotification/components/PriorNotificationSubscriberTable/constants.tsx +++ b/frontend/src/features/PriorNotification/components/PriorNotificationSubscriberTable/constants.tsx @@ -15,13 +15,6 @@ export const DEFAULT_TABLE_FILTER_VALUES: TableFilter = { } export const TABLE_COLUMNS: Array> = [ - { - accessorFn: row => row.id, - enableSorting: false, - header: () => 'ID', - id: 'id', - size: 64 - }, { accessorFn: row => `${row.controlUnit.name} (${row.controlUnit.administration.name})`, enableSorting: true, From 256735992e08fbc5b94efb8131c51bd0cf468f97 Mon Sep 17 00:00:00 2001 From: Ivan Gabriele Date: Fri, 25 Oct 2024 06:22:50 +0200 Subject: [PATCH 24/59] Add unit tests for GetPriorNotificationSubscriber use case in Backend --- .../entities/fleet_segment/FleetSegment.kt | 2 + .../domain/entities/vessel/Vessel.kt | 2 + .../GetPriorNotificationSubscriberUTests.kt | 152 ++++++++++++++++++ .../monitorfish/fakers/FleetSegmentFaker.kt | 31 ++++ .../fakers/FullControlUnitFaker.kt | 144 +++++++++++++++++ 5 files changed, 331 insertions(+) create mode 100644 backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationSubscriberUTests.kt create mode 100644 backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/fakers/FleetSegmentFaker.kt create mode 100644 backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/fakers/FullControlUnitFaker.kt diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/fleet_segment/FleetSegment.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/fleet_segment/FleetSegment.kt index 8dc725bf6c..4eb8481e69 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/fleet_segment/FleetSegment.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/fleet_segment/FleetSegment.kt @@ -3,7 +3,9 @@ package fr.gouv.cnsp.monitorfish.domain.entities.fleet_segment import fr.gouv.cnsp.monitorfish.domain.entities.logbook.LogbookTripSegment data class FleetSegment( + // TODO Rename that to `code`. val segment: String, + // TODO Rename that to `name`. val segmentName: String, val dirm: List = listOf(), val gears: List, 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 19afb2e90e..0fbc7ad81a 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 @@ -4,6 +4,7 @@ import com.neovisionaries.i18n.CountryCode import fr.gouv.cnsp.monitorfish.domain.FRENCH_COUNTRY_CODES import java.util.* +// TODO Remove all default values. data class Vessel( val id: Int, /** CFR (Community Fleet Register Number). */ @@ -15,6 +16,7 @@ data class Vessel( /** IRCS (International Radio Call Sign). */ val ircs: String? = null, val externalReferenceNumber: String? = null, + // TODO Rename to `name`. val vesselName: String? = null, val flagState: CountryCode, val width: Double? = null, diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationSubscriberUTests.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationSubscriberUTests.kt new file mode 100644 index 0000000000..8d4cf0e456 --- /dev/null +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationSubscriberUTests.kt @@ -0,0 +1,152 @@ +package fr.gouv.cnsp.monitorfish.domain.use_cases.prior_notification + +import com.nhaarman.mockitokotlin2.given +import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotificationFleetSegmentSubscription +import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotificationPortSubscription +import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotificationVesselSubscription +import fr.gouv.cnsp.monitorfish.domain.exceptions.BackendUsageErrorCode +import fr.gouv.cnsp.monitorfish.domain.exceptions.BackendUsageException +import fr.gouv.cnsp.monitorfish.domain.repositories.* +import fr.gouv.cnsp.monitorfish.fakers.FleetSegmentFaker +import fr.gouv.cnsp.monitorfish.fakers.FullControlUnitFaker +import fr.gouv.cnsp.monitorfish.fakers.PortFaker +import fr.gouv.cnsp.monitorfish.fakers.VesselFaker +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertThrows +import org.junit.jupiter.api.extension.ExtendWith +import org.springframework.boot.test.mock.mockito.MockBean +import org.springframework.test.context.junit.jupiter.SpringExtension + +@ExtendWith(SpringExtension::class) +class GetPriorNotificationSubscriberUTests { + @MockBean + private lateinit var controlUnitRepository: ControlUnitRepository + + @MockBean + private lateinit var fleetSegmentRepository: FleetSegmentRepository + + @MockBean + private lateinit var pnoPortSubscriptionRepository: PnoPortSubscriptionRepository + + @MockBean + private lateinit var pnoFleetSegmentSubscriptionRepository: PnoFleetSegmentSubscriptionRepository + + @MockBean + private lateinit var pnoVesselSubscriptionRepository: PnoVesselSubscriptionRepository + + @MockBean + private lateinit var portRepository: PortRepository + + @MockBean + private lateinit var vesselRepository: VesselRepository + + @Test + fun `execute should return a PriorNotificationSubscriber when control unit exists`() { + // Given + val fakeControlUnitId = 10023 + val fakeControlUnit = FullControlUnitFaker.fakeFullControlUnit(id = fakeControlUnitId) + given(controlUnitRepository.findAll()).willReturn(listOf(fakeControlUnit)) + + val allFakeFleetSegments = + listOf( + FleetSegmentFaker.fakeFleetSegment(segment = "SEG001", segmentName = "Segment 1"), + FleetSegmentFaker.fakeFleetSegment(segment = "SEG002", segmentName = "Segment 2"), + ) + given(fleetSegmentRepository.findAll()).willReturn(allFakeFleetSegments) + + val allFakePorts = + listOf( + PortFaker.fakePort(locode = "FRABC", name = "Port 1"), + PortFaker.fakePort(locode = "ESXYZ", name = "Port 2"), + ) + given(portRepository.findAll()).willReturn(allFakePorts) + + val allFakeVessels = + listOf( + VesselFaker.fakeVessel(id = 1, vesselName = "Vessel 1"), + VesselFaker.fakeVessel(id = 2, vesselName = "Vessel 2"), + ) + given(vesselRepository.findAll()).willReturn(allFakeVessels) + + val fakeFleetSegmentSubscriptions = + listOf( + PriorNotificationFleetSegmentSubscription( + controlUnitId = fakeControlUnitId, + segmentCode = "SEG001", + segmentName = null, // Expecting the use case to populate this + ), + ) + given(pnoFleetSegmentSubscriptionRepository.findByControlUnitId(fakeControlUnitId)) + .willReturn(fakeFleetSegmentSubscriptions) + + val portSubscriptions = + listOf( + PriorNotificationPortSubscription( + controlUnitId = fakeControlUnitId, + portLocode = "FRABC", + portName = null, // Expecting the use case to populate this + hasSubscribedToAllPriorNotifications = false, + ), + ) + given(pnoPortSubscriptionRepository.findByControlUnitId(fakeControlUnitId)) + .willReturn(portSubscriptions) + + val vesselSubscriptions = + listOf( + PriorNotificationVesselSubscription( + controlUnitId = fakeControlUnitId, + vesselId = 1, + vesselName = null, // Expecting the use case to populate this + ), + ) + given(pnoVesselSubscriptionRepository.findByControlUnitId(fakeControlUnitId)) + .willReturn(vesselSubscriptions) + + // When + val result = + GetPriorNotificationSubscriber( + controlUnitRepository, + fleetSegmentRepository, + pnoPortSubscriptionRepository, + pnoFleetSegmentSubscriptionRepository, + pnoVesselSubscriptionRepository, + portRepository, + vesselRepository, + ).execute(fakeControlUnitId) + + // Then + assertThat(result.controlUnit).isEqualTo(fakeControlUnit) + + val expectedFleetSegmentSubscription = fakeFleetSegmentSubscriptions[0].copy(segmentName = "Segment 1") + assertThat(result.fleetSegmentSubscriptions).containsExactly(expectedFleetSegmentSubscription) + + val expectedPortSubscription = portSubscriptions[0].copy(portName = "Port 1") + assertThat(result.portSubscriptions).containsExactly(expectedPortSubscription) + + val expectedVesselSubscription = vesselSubscriptions[0].copy(vesselName = "Vessel 1") + assertThat(result.vesselSubscriptions).containsExactly(expectedVesselSubscription) + } + + @Test + fun `execute Should throw BackendUsageException when control unit does not exist`() { + // Given + val controlUnitId = 99999 + given(controlUnitRepository.findAll()).willReturn(emptyList()) + + // When / Then + val exception = + assertThrows { + GetPriorNotificationSubscriber( + controlUnitRepository, + fleetSegmentRepository, + pnoPortSubscriptionRepository, + pnoFleetSegmentSubscriptionRepository, + pnoVesselSubscriptionRepository, + portRepository, + vesselRepository, + ).execute(controlUnitId) + } + assertThat(exception.code).isEqualTo(BackendUsageErrorCode.NOT_FOUND) + } +} diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/fakers/FleetSegmentFaker.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/fakers/FleetSegmentFaker.kt new file mode 100644 index 0000000000..3af892973b --- /dev/null +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/fakers/FleetSegmentFaker.kt @@ -0,0 +1,31 @@ +package fr.gouv.cnsp.monitorfish.fakers + +import fr.gouv.cnsp.monitorfish.domain.entities.fleet_segment.FleetSegment + +class FleetSegmentFaker { + companion object { + fun fakeFleetSegment( + segment: String = "SEG001", + segmentName: String = "Fake Segment Name", + dirm: List = listOf(), + gears: List = listOf("GEAR1", "GEAR2"), + faoAreas: List = listOf("FAO_AREA1", "FAO_AREA2"), + targetSpecies: List = listOf("SPECIES1", "SPECIES2"), + bycatchSpecies: List = listOf(), + impactRiskFactor: Double = 1.0, + year: Int = 2023, + ): FleetSegment { + return FleetSegment( + segment = segment, + segmentName = segmentName, + dirm = dirm, + gears = gears, + faoAreas = faoAreas, + targetSpecies = targetSpecies, + bycatchSpecies = bycatchSpecies, + impactRiskFactor = impactRiskFactor, + year = year, + ) + } + } +} diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/fakers/FullControlUnitFaker.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/fakers/FullControlUnitFaker.kt new file mode 100644 index 0000000000..f10a7dd3ec --- /dev/null +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/fakers/FullControlUnitFaker.kt @@ -0,0 +1,144 @@ +package fr.gouv.cnsp.monitorfish.fakers + +import fr.gouv.cnsp.monitorfish.domain.entities.administration.Administration +import fr.gouv.cnsp.monitorfish.domain.entities.control_unit.* +import fr.gouv.cnsp.monitorfish.domain.use_cases.control_units.dtos.FullControlUnit +import fr.gouv.cnsp.monitorfish.domain.use_cases.control_units.dtos.FullControlUnitResource + +class FullControlUnitFaker { + companion object { + fun fakeFullControlUnit( + id: Int = 1, + areaNote: String? = "Default Area Note", + administration: Administration = fakeAdministration(), + administrationId: Int = administration.id, + controlUnitContactIds: List = listOf(1), + controlUnitContacts: List = listOf(fakeControlUnitContact()), + controlUnitResourceIds: List = listOf(1), + controlUnitResources: List = listOf(fakeFullControlUnitResource()), + departmentArea: ControlUnitDepartmentArea? = fakeControlUnitDepartmentArea(), + departmentAreaInseeCode: String? = departmentArea?.inseeCode, + isArchived: Boolean = false, + name: String = "Fake Control Unit Name", + termsNote: String? = "Default Terms Note", + ): FullControlUnit { + return FullControlUnit( + id = id, + areaNote = areaNote, + administration = administration, + administrationId = administrationId, + controlUnitContactIds = controlUnitContactIds, + controlUnitContacts = controlUnitContacts, + controlUnitResourceIds = controlUnitResourceIds, + controlUnitResources = controlUnitResources, + departmentArea = departmentArea, + departmentAreaInseeCode = departmentAreaInseeCode, + isArchived = isArchived, + name = name, + termsNote = termsNote, + ) + } + + private fun fakeAdministration( + id: Int = 1, + isArchived: Boolean = false, + name: String = "Fake Administration Name", + ): Administration { + return Administration( + id = id, + isArchived = isArchived, + name = name, + ) + } + + private fun fakeControlUnitContact( + id: Int = 1, + controlUnitId: Int = 1, + email: String? = "contact@example.com", + isEmailSubscriptionContact: Boolean = true, + isSmsSubscriptionContact: Boolean = false, + name: String = "Fake Contact Name", + phone: String? = "+1234567890", + ): ControlUnitContact { + return ControlUnitContact( + id = id, + controlUnitId = controlUnitId, + email = email, + isEmailSubscriptionContact = isEmailSubscriptionContact, + isSmsSubscriptionContact = isSmsSubscriptionContact, + name = name, + phone = phone, + ) + } + + private fun fakeFullControlUnitResource( + id: Int = 1, + controlUnit: ControlUnit = fakeControlUnit(), + controlUnitId: Int = controlUnit.id, + isArchived: Boolean = false, + name: String = "Fake Resource Name", + note: String? = "Default Resource Note", + photo: ByteArray? = null, + station: ControlUnitStation = fakeControlUnitStation(), + stationId: Int = station.id, + type: ControlUnitResourceType = ControlUnitResourceType.FRIGATE, + ): FullControlUnitResource { + return FullControlUnitResource( + id = id, + controlUnit = controlUnit, + controlUnitId = controlUnitId, + isArchived = isArchived, + name = name, + note = note, + photo = photo, + station = station, + stationId = stationId, + type = type, + ) + } + + private fun fakeControlUnit( + id: Int = 1, + areaNote: String? = "Default Area Note", + administrationId: Int = 1, + departmentAreaInseeCode: String? = "00000", + isArchived: Boolean = false, + name: String = "Fake Control Unit Name", + termsNote: String? = "Default Terms Note", + ): ControlUnit { + return ControlUnit( + id = id, + areaNote = areaNote, + administrationId = administrationId, + departmentAreaInseeCode = departmentAreaInseeCode, + isArchived = isArchived, + name = name, + termsNote = termsNote, + ) + } + + private fun fakeControlUnitDepartmentArea( + inseeCode: String = "00000", + name: String = "Fake Department Area Name", + ): ControlUnitDepartmentArea { + return ControlUnitDepartmentArea( + inseeCode = inseeCode, + name = name, + ) + } + + private fun fakeControlUnitStation( + id: Int = 1, + latitude: Double = 48.8566, + longitude: Double = 2.3522, + name: String = "Fake Station Name", + ): ControlUnitStation { + return ControlUnitStation( + id = id, + latitude = latitude, + longitude = longitude, + name = name, + ) + } + } +} From d191d8b0a587fb8f735ef785d5684495718b4f46 Mon Sep 17 00:00:00 2001 From: Ivan Gabriele Date: Fri, 25 Oct 2024 06:38:16 +0200 Subject: [PATCH 25/59] Add unit tests for GetPriorNotificationSubscribers use case in Backend --- .../GetPriorNotificationSubscriberUTests.kt | 14 +- .../GetPriorNotificationSubscribersUTests.kt | 154 ++++++++++++++++++ 2 files changed, 159 insertions(+), 9 deletions(-) create mode 100644 backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationSubscribersUTests.kt diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationSubscriberUTests.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationSubscriberUTests.kt index 8d4cf0e456..0cec6c2e27 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationSubscriberUTests.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationSubscriberUTests.kt @@ -117,15 +117,11 @@ class GetPriorNotificationSubscriberUTests { // Then assertThat(result.controlUnit).isEqualTo(fakeControlUnit) - - val expectedFleetSegmentSubscription = fakeFleetSegmentSubscriptions[0].copy(segmentName = "Segment 1") - assertThat(result.fleetSegmentSubscriptions).containsExactly(expectedFleetSegmentSubscription) - - val expectedPortSubscription = portSubscriptions[0].copy(portName = "Port 1") - assertThat(result.portSubscriptions).containsExactly(expectedPortSubscription) - - val expectedVesselSubscription = vesselSubscriptions[0].copy(vesselName = "Vessel 1") - assertThat(result.vesselSubscriptions).containsExactly(expectedVesselSubscription) + assertThat(result.fleetSegmentSubscriptions).containsExactly( + fakeFleetSegmentSubscriptions[0].copy(segmentName = "Segment 1"), + ) + assertThat(result.portSubscriptions).containsExactly(portSubscriptions[0].copy(portName = "Port 1")) + assertThat(result.vesselSubscriptions).containsExactly(vesselSubscriptions[0].copy(vesselName = "Vessel 1")) } @Test diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationSubscribersUTests.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationSubscribersUTests.kt new file mode 100644 index 0000000000..9d3e2d6a5e --- /dev/null +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationSubscribersUTests.kt @@ -0,0 +1,154 @@ +package fr.gouv.cnsp.monitorfish.domain.use_cases.prior_notification + +import com.nhaarman.mockitokotlin2.given +import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotificationFleetSegmentSubscription +import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotificationPortSubscription +import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotificationVesselSubscription +import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.filters.PriorNotificationSubscribersFilter +import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.sorters.PriorNotificationSubscribersSortColumn +import fr.gouv.cnsp.monitorfish.domain.repositories.* +import fr.gouv.cnsp.monitorfish.fakers.* +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith +import org.mockito.Mock +import org.mockito.junit.jupiter.MockitoExtension +import org.springframework.data.domain.Sort + +@ExtendWith(MockitoExtension::class) +class GetPriorNotificationSubscribersUTests { + @Mock + private lateinit var controlUnitRepository: ControlUnitRepository + + @Mock + private lateinit var fleetSegmentRepository: FleetSegmentRepository + + @Mock + private lateinit var pnoPortSubscriptionRepository: PnoPortSubscriptionRepository + + @Mock + private lateinit var pnoFleetSegmentSubscriptionRepository: PnoFleetSegmentSubscriptionRepository + + @Mock + private lateinit var pnoVesselSubscriptionRepository: PnoVesselSubscriptionRepository + + @Mock + private lateinit var portRepository: PortRepository + + @Mock + private lateinit var vesselRepository: VesselRepository + + @Test + fun `execute should return all prior notification subscribers when no filter is applied`() { + // Given + val fakeFullControlUnit1 = FullControlUnitFaker.fakeFullControlUnit(id = 1, name = "Control Unit 1") + val fakeFullControlUnit2 = FullControlUnitFaker.fakeFullControlUnit(id = 2, name = "Control Unit 2") + given(controlUnitRepository.findAll()).willReturn(listOf(fakeFullControlUnit1, fakeFullControlUnit2)) + + val fakeFleetSegment1 = FleetSegmentFaker.fakeFleetSegment(segment = "SEG001", segmentName = "Segment 1") + val fakeFleetSegment2 = FleetSegmentFaker.fakeFleetSegment(segment = "SEG002", segmentName = "Segment 2") + given(fleetSegmentRepository.findAll()).willReturn(listOf(fakeFleetSegment1, fakeFleetSegment2)) + + val fakePort1 = PortFaker.fakePort(locode = "FRABC", name = "Port ABC") + val fakePort2 = PortFaker.fakePort(locode = "ESXYZ", name = "Port XYZ") + given(portRepository.findAll()).willReturn(listOf(fakePort1, fakePort2)) + + val fakeVessel1 = VesselFaker.fakeVessel(id = 1, vesselName = "Vessel 1") + val fakeVessel2 = VesselFaker.fakeVessel(id = 2, vesselName = "Vessel 2") + given(vesselRepository.findAll()).willReturn(listOf(fakeVessel1, fakeVessel2)) + + val fakeFleetSegmentSubscriptions = + listOf( + PriorNotificationFleetSegmentSubscription( + controlUnitId = 1, + segmentCode = "SEG001", + segmentName = null, + ), + PriorNotificationFleetSegmentSubscription( + controlUnitId = 2, + segmentCode = "SEG002", + segmentName = null, + ), + ) + + given(pnoFleetSegmentSubscriptionRepository.findAll()).willReturn(fakeFleetSegmentSubscriptions) + + val fakePortSubscriptions = + listOf( + PriorNotificationPortSubscription( + controlUnitId = 1, + portLocode = "FRABC", + portName = null, + hasSubscribedToAllPriorNotifications = false, + ), + PriorNotificationPortSubscription( + controlUnitId = 2, + portLocode = "ESXYZ", + portName = null, + hasSubscribedToAllPriorNotifications = false, + ), + ) + + given(pnoPortSubscriptionRepository.findAll()).willReturn(fakePortSubscriptions) + + val fakeVesselSubscriptions = + listOf( + PriorNotificationVesselSubscription( + controlUnitId = 1, + vesselId = 1, + vesselName = null, + ), + PriorNotificationVesselSubscription( + controlUnitId = 2, + vesselId = 2, + vesselName = null, + ), + ) + + given(pnoVesselSubscriptionRepository.findAll()).willReturn(fakeVesselSubscriptions) + + // When + val useCase = + GetPriorNotificationSubscribers( + controlUnitRepository, + fleetSegmentRepository, + pnoPortSubscriptionRepository, + pnoFleetSegmentSubscriptionRepository, + pnoVesselSubscriptionRepository, + portRepository, + vesselRepository, + ) + + val result = + useCase.execute( + filter = PriorNotificationSubscribersFilter(), + sortColumn = PriorNotificationSubscribersSortColumn.CONTROL_UNIT_NAME, + sortDirection = Sort.Direction.ASC, + ) + + // Then + assertThat(result).hasSize(2) + + assertThat(result[0].controlUnit).isEqualTo(fakeFullControlUnit1) + assertThat(result[0].fleetSegmentSubscriptions).isEqualTo( + listOf(fakeFleetSegmentSubscriptions[0].copy(segmentName = "Segment 1")), + ) + assertThat(result[0].portSubscriptions).isEqualTo( + listOf(fakePortSubscriptions[0].copy(portName = "Port ABC")), + ) + assertThat(result[0].vesselSubscriptions).isEqualTo( + listOf(fakeVesselSubscriptions[0].copy(vesselName = "Vessel 1")), + ) + + assertThat(result[1].controlUnit).isEqualTo(fakeFullControlUnit2) + assertThat(result[1].fleetSegmentSubscriptions).isEqualTo( + listOf(fakeFleetSegmentSubscriptions[1].copy(segmentName = "Segment 2")), + ) + assertThat(result[1].portSubscriptions).isEqualTo( + listOf(fakePortSubscriptions[1].copy(portName = "Port XYZ")), + ) + assertThat(result[1].vesselSubscriptions).isEqualTo( + listOf(fakeVesselSubscriptions[1].copy(vesselName = "Vessel 2")), + ) + } +} From 23c7568c42f0297457fdbe1956cf9bde16b9ad39 Mon Sep 17 00:00:00 2001 From: Ivan Gabriele Date: Fri, 25 Oct 2024 06:59:06 +0200 Subject: [PATCH 26/59] Handle diacritics in pno subscriber table search --- .../GetPriorNotificationSubscribers.kt | 28 ++++++++++++++----- .../cnsp/monitorfish/utils/StringUtils.kt | 11 ++++++++ 2 files changed, 32 insertions(+), 7 deletions(-) create mode 100644 backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/utils/StringUtils.kt diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationSubscribers.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationSubscribers.kt index b3a2e79851..0f8ab09b2c 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationSubscribers.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationSubscribers.kt @@ -5,6 +5,7 @@ import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.filters.Prior import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.sorters.PriorNotificationSubscribersSortColumn import fr.gouv.cnsp.monitorfish.domain.repositories.* import fr.gouv.cnsp.monitorfish.domain.use_cases.prior_notification.dtos.PriorNotificationSubscriber +import fr.gouv.cnsp.monitorfish.utils.StringUtils import org.springframework.data.domain.Sort @UseCase @@ -85,15 +86,28 @@ class GetPriorNotificationSubscribers( } != false val searchQueryMatches = - filter.searchQuery?.let { - subscriber.controlUnit.name.contains(it, ignoreCase = true) || - subscriber.controlUnit.administration.name.contains(it, ignoreCase = true) || + filter.searchQuery?.let { query -> + val normalizedQuery = StringUtils.removeAccents(query).lowercase() + + val controlUnitNameMatches = + StringUtils.removeAccents(subscriber.controlUnit.name) + .lowercase() + .contains(normalizedQuery) + + val administrationNameMatches = + StringUtils.removeAccents(subscriber.controlUnit.administration.name) + .lowercase() + .contains(normalizedQuery) + + val portNameMatches = subscriber.portSubscriptions.any { portSubscription -> - portSubscription.portName?.contains( - it, - ignoreCase = true, - ) == true + portSubscription.portName + ?.let(StringUtils::removeAccents) + ?.lowercase() + ?.contains(normalizedQuery) == true } + + controlUnitNameMatches || administrationNameMatches || portNameMatches } != false administrationIdMatches && portLocodeMatches && searchQueryMatches diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/utils/StringUtils.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/utils/StringUtils.kt new file mode 100644 index 0000000000..345bf9f8e0 --- /dev/null +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/utils/StringUtils.kt @@ -0,0 +1,11 @@ +package fr.gouv.cnsp.monitorfish.utils + +import java.text.Normalizer + +object StringUtils { + fun removeAccents(input: String): String { + val normalizedInput = Normalizer.normalize(input, Normalizer.Form.NFD) + + return normalizedInput.replace("\\p{InCombiningDiacriticalMarks}+".toRegex(), "") + } +} From 5bc3ee9227c58e9de9a679b6309d0764a7ab90dc Mon Sep 17 00:00:00 2001 From: Ivan Gabriele Date: Fri, 25 Oct 2024 07:39:07 +0200 Subject: [PATCH 27/59] Add unit tests for GetPriorNotificationSubscribers use case filtering --- .../GetPriorNotificationSubscribersUTests.kt | 157 +++++++++++++++++- 1 file changed, 156 insertions(+), 1 deletion(-) diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationSubscribersUTests.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationSubscribersUTests.kt index 9d3e2d6a5e..fa1301dd75 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationSubscribersUTests.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationSubscribersUTests.kt @@ -1,17 +1,21 @@ package fr.gouv.cnsp.monitorfish.domain.use_cases.prior_notification import com.nhaarman.mockitokotlin2.given +import fr.gouv.cnsp.monitorfish.domain.entities.administration.Administration import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotificationFleetSegmentSubscription import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotificationPortSubscription import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotificationVesselSubscription import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.filters.PriorNotificationSubscribersFilter import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.sorters.PriorNotificationSubscribersSortColumn import fr.gouv.cnsp.monitorfish.domain.repositories.* +import fr.gouv.cnsp.monitorfish.domain.use_cases.control_units.dtos.FullControlUnit import fr.gouv.cnsp.monitorfish.fakers.* +import junit.framework.TestCase.assertEquals import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith import org.mockito.Mock +import org.mockito.Mockito.`when` import org.mockito.junit.jupiter.MockitoExtension import org.springframework.data.domain.Sort @@ -39,7 +43,7 @@ class GetPriorNotificationSubscribersUTests { private lateinit var vesselRepository: VesselRepository @Test - fun `execute should return all prior notification subscribers when no filter is applied`() { + fun `execute Should return all prior notification subscribers when no filter is applied`() { // Given val fakeFullControlUnit1 = FullControlUnitFaker.fakeFullControlUnit(id = 1, name = "Control Unit 1") val fakeFullControlUnit2 = FullControlUnitFaker.fakeFullControlUnit(id = 2, name = "Control Unit 2") @@ -151,4 +155,155 @@ class GetPriorNotificationSubscribersUTests { listOf(fakeVesselSubscriptions[1].copy(vesselName = "Vessel 2")), ) } + + @Test + fun `execute Should filter prior notification subscribers as expected`() { + // Given + val fakeAdministration1 = Administration(id = 1, name = "Administration A", isArchived = false) + val fakeAdministration2 = Administration(id = 2, name = "Administration B", isArchived = false) + val fakeFullControlUnit1 = + FullControlUnitFaker.fakeFullControlUnit( + id = 100, + name = "Unite1 Sans Accent", + administration = fakeAdministration1, + ) + val fakeFullControlUnit2 = + FullControlUnitFaker.fakeFullControlUnit( + id = 101, + name = "Unité2 Avec Accent", + administration = fakeAdministration2, + ) + val fakeFullControlUnit3 = + FullControlUnitFaker.fakeFullControlUnit( + id = 102, + name = "La Dernière Unité3", + administration = fakeAdministration1, + ) + + val fakePort1 = PortFaker.fakePort(locode = "ESXYZ", name = "Le Pôrt1 Très Äccentué") + val fakePort2 = PortFaker.fakePort(locode = "FRABC", name = "Le Port2 Sans Accent") + + val fakeVessel1 = VesselFaker.fakeVessel(id = 1000, vesselName = "Navire Un") + val fakeVessel2 = VesselFaker.fakeVessel(id = 1001, vesselName = "Navire Deux") + + val fakePortSubscription1 = + PriorNotificationPortSubscription( + controlUnitId = 100, + portLocode = "ESXYZ", + portName = null, + hasSubscribedToAllPriorNotifications = false, + ) + val fakePortSubscription2 = + PriorNotificationPortSubscription( + controlUnitId = 101, + portLocode = "FRABC", + portName = null, + hasSubscribedToAllPriorNotifications = false, + ) + val fakePortSubscription3 = + PriorNotificationPortSubscription( + controlUnitId = 102, + portLocode = "ESXYZ", + portName = null, + hasSubscribedToAllPriorNotifications = false, + ) + + // Mock repository methods + `when`(controlUnitRepository.findAll()).thenReturn( + listOf( + fakeFullControlUnit1, + fakeFullControlUnit2, + fakeFullControlUnit3, + ), + ) + `when`(fleetSegmentRepository.findAll()).thenReturn(emptyList()) + `when`(pnoPortSubscriptionRepository.findAll()).thenReturn( + listOf( + fakePortSubscription1, + fakePortSubscription2, + fakePortSubscription3, + ), + ) + `when`(pnoFleetSegmentSubscriptionRepository.findAll()).thenReturn(emptyList()) + `when`(pnoVesselSubscriptionRepository.findAll()).thenReturn(emptyList()) + `when`(portRepository.findAll()).thenReturn(listOf(fakePort1, fakePort2)) + `when`(vesselRepository.findAll()).thenReturn(listOf(fakeVessel1, fakeVessel2)) + + var testCases: List, String>> = emptyList() + + // Case 1: Search query matches control unit name + testCases = testCases + + Triple( + PriorNotificationSubscribersFilter(searchQuery = "unitÉ1"), + listOf(fakeFullControlUnit1), + "Search query matches control unit name", + ) + + // Case 2: Search query matches administration name + testCases = testCases + + Triple( + PriorNotificationSubscribersFilter(searchQuery = "adminÎstratÏon b"), + listOf(fakeFullControlUnit2), + "Search query matches administration name", + ) + + // Case 3: Search query matches port name in port subscriptions + testCases = testCases + + Triple( + PriorNotificationSubscribersFilter(searchQuery = "tres accentue"), + listOf(fakeFullControlUnit1, fakeFullControlUnit3), + "Search query matches port name in port subscriptions", + ) + + // Case 4: Search query matches none + testCases = testCases + + Triple( + PriorNotificationSubscribersFilter(searchQuery = "inexistant"), + emptyList(), + "Search query matches none", + ) + + // Case 5: Combination of filters - administrationId and searchQuery + testCases = testCases + + Triple( + PriorNotificationSubscribersFilter(administrationId = 1, searchQuery = "derniere"), + listOf(fakeFullControlUnit3), + "Combination of administrationId and searchQuery filters", + ) + + // Case 6: Filter by portLocode + testCases = testCases + + Triple( + PriorNotificationSubscribersFilter(portLocode = "FRABC"), + listOf(fakeFullControlUnit2), + "Filter by portLocode", + ) + + val useCase = + GetPriorNotificationSubscribers( + controlUnitRepository, + fleetSegmentRepository, + pnoPortSubscriptionRepository, + pnoFleetSegmentSubscriptionRepository, + pnoVesselSubscriptionRepository, + portRepository, + vesselRepository, + ) + + for ((filter, expectedControlUnits, description) in testCases) { + // When + val result = + useCase.execute( + filter = filter, + sortColumn = PriorNotificationSubscribersSortColumn.CONTROL_UNIT_NAME, + sortDirection = Sort.Direction.ASC, + ) + + // Then + val expectedControlUnitIds = expectedControlUnits.map { it.id }.sorted() + val resultControlUnitIds = result.map { it.controlUnit.id }.sorted() + + assertEquals("Failed test case: $description", expectedControlUnitIds, resultControlUnitIds) + } + } } From 6954198d2c17985cfff4879bb4599738322d8cab Mon Sep 17 00:00:00 2001 From: Ivan Gabriele Date: Fri, 25 Oct 2024 07:48:14 +0200 Subject: [PATCH 28/59] Add unit tests for PriorNotificationSubscriberController --- ...rNotificationSubscriberControllerUTests.kt | 155 ++++++++++++++++++ 1 file changed, 155 insertions(+) create mode 100644 backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/PriorNotificationSubscriberControllerUTests.kt diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/PriorNotificationSubscriberControllerUTests.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/PriorNotificationSubscriberControllerUTests.kt new file mode 100644 index 0000000000..a1c5b76f5a --- /dev/null +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/bff/PriorNotificationSubscriberControllerUTests.kt @@ -0,0 +1,155 @@ +package fr.gouv.cnsp.monitorfish.infrastructure.api.bff + +import com.fasterxml.jackson.databind.ObjectMapper +import com.nhaarman.mockitokotlin2.any +import fr.gouv.cnsp.monitorfish.config.SentryConfig +import fr.gouv.cnsp.monitorfish.domain.use_cases.prior_notification.* +import fr.gouv.cnsp.monitorfish.domain.use_cases.prior_notification.dtos.PriorNotificationSubscriber +import fr.gouv.cnsp.monitorfish.fakers.FullControlUnitFaker +import fr.gouv.cnsp.monitorfish.infrastructure.api.input.PriorNotificationSubscriberDataInput +import org.hamcrest.Matchers.equalTo +import org.junit.jupiter.api.Test +import org.mockito.BDDMockito.given +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc +import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest +import org.springframework.boot.test.mock.mockito.MockBean +import org.springframework.context.annotation.Import +import org.springframework.http.MediaType +import org.springframework.test.web.servlet.MockMvc +import org.springframework.test.web.servlet.request.MockMvcRequestBuilders.* +import org.springframework.test.web.servlet.result.MockMvcResultMatchers.* + +@Import(SentryConfig::class) +@AutoConfigureMockMvc(addFilters = false) +@WebMvcTest(value = [(PriorNotificationSubscriberController::class)]) +class PriorNotificationSubscriberControllerUTests { + @Autowired + private lateinit var api: MockMvc + + @Autowired + private lateinit var objectMapper: ObjectMapper + + @MockBean + private lateinit var getPriorNotificationSubscriber: GetPriorNotificationSubscriber + + @MockBean + private lateinit var getPriorNotificationSubscribers: GetPriorNotificationSubscribers + + @MockBean + private lateinit var updatePriorNotificationSubscriber: UpdatePriorNotificationSubscriber + + @Test + fun `getAll Should get a list of prior notification subscribers`() { + // Given + val fakeControlUnit1 = FullControlUnitFaker.fakeFullControlUnit(id = 100, name = "Control Unit 1") + val fakeControlUnit2 = FullControlUnitFaker.fakeFullControlUnit(id = 101, name = "Control Unit 2") + + val fakeSubscriber1 = + PriorNotificationSubscriber( + controlUnit = fakeControlUnit1, + fleetSegmentSubscriptions = emptyList(), + portSubscriptions = emptyList(), + vesselSubscriptions = emptyList(), + ) + val fakeSubscriber2 = + PriorNotificationSubscriber( + controlUnit = fakeControlUnit2, + fleetSegmentSubscriptions = emptyList(), + portSubscriptions = emptyList(), + vesselSubscriptions = emptyList(), + ) + + given( + getPriorNotificationSubscribers.execute( + any(), + any(), + any(), + ), + ).willReturn( + listOf(fakeSubscriber1, fakeSubscriber2), + ) + + // When + api.perform( + get("/bff/v1/prior_notification_subscribers?sortColumn=CONTROL_UNIT_NAME&sortDirection=ASC"), + ) + // Then + .andExpect(status().isOk) + .andExpect(jsonPath("$.length()", equalTo(2))) + .andExpect(jsonPath("$[0].controlUnit.id", equalTo(fakeSubscriber1.controlUnit.id))) + .andExpect(jsonPath("$[1].controlUnit.id", equalTo(fakeSubscriber2.controlUnit.id))) + } + + @Test + fun `getOne Should get a prior notification subscriber by its controlUnitId`() { + // Given + val fakeControlUnitId = 100 + val fakeControlUnit = FullControlUnitFaker.fakeFullControlUnit(id = fakeControlUnitId, name = "Control Unit 1") + + val fakeSubscriber = + PriorNotificationSubscriber( + controlUnit = fakeControlUnit, + fleetSegmentSubscriptions = emptyList(), + portSubscriptions = emptyList(), + vesselSubscriptions = emptyList(), + ) + + given( + getPriorNotificationSubscriber.execute(fakeControlUnitId), + ).willReturn(fakeSubscriber) + + // When + api.perform( + get("/bff/v1/prior_notification_subscribers/$fakeControlUnitId"), + ) + // Then + .andExpect(status().isOk) + .andExpect(jsonPath("$.controlUnit.id", equalTo(fakeControlUnitId))) + } + + @Test + fun `updateOne Should update a prior notification subscriber by its controlUnitId`() { + // Given + val fakeControlUnitId = 100 + val fakeControlUnit = FullControlUnitFaker.fakeFullControlUnit(id = fakeControlUnitId, name = "Control Unit 1") + + val fakeSubscriber = + PriorNotificationSubscriber( + controlUnit = fakeControlUnit, + fleetSegmentSubscriptions = emptyList(), + portSubscriptions = emptyList(), + vesselSubscriptions = emptyList(), + ) + + val fakeDataInput = + PriorNotificationSubscriberDataInput( + controlUnitId = fakeControlUnitId, + portLocodes = listOf("FRABC", "ESXYZ"), + portLocodesWithFullSubscription = listOf("ESXYZ"), + fleetSegmentCodes = listOf("SEG001", "SEG002"), + vesselIds = listOf(1001, 1002), + ) + + given( + updatePriorNotificationSubscriber.execute( + controlUnitId = any(), + fleetSegmentSubscriptions = any(), + portSubscriptions = any(), + vesselSubscriptions = any(), + ), + ).willReturn(fakeSubscriber) + + val requestBody = objectMapper.writeValueAsString(fakeDataInput) + + // When + api.perform( + put("/bff/v1/prior_notification_subscribers/$fakeControlUnitId") + .contentType(MediaType.APPLICATION_JSON) + .content(requestBody), + ) + // Then + .andExpect(status().isOk) + .andExpect(jsonPath("$.controlUnit.id", equalTo(fakeControlUnitId))) + } +} From a7ebe9f4618d2a4789f145fafe72ddaf5ad2374a Mon Sep 17 00:00:00 2001 From: Ivan Gabriele Date: Fri, 25 Oct 2024 07:55:15 +0200 Subject: [PATCH 29/59] Move control_unit/ControlUnitStation entity to station/Station in Backend --- .../Station.kt} | 4 ++-- .../dtos/FullControlUnitResource.kt | 4 ++-- .../fakers/FullControlUnitFaker.kt | 17 ++------------- .../cnsp/monitorfish/fakers/StationFaker.kt | 21 +++++++++++++++++++ 4 files changed, 27 insertions(+), 19 deletions(-) rename backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/{control_unit/ControlUnitStation.kt => station/Station.kt} (62%) create mode 100644 backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/fakers/StationFaker.kt diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/control_unit/ControlUnitStation.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/station/Station.kt similarity index 62% rename from backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/control_unit/ControlUnitStation.kt rename to backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/station/Station.kt index c437f884f0..68b6ca3a37 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/control_unit/ControlUnitStation.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/station/Station.kt @@ -1,9 +1,9 @@ -package fr.gouv.cnsp.monitorfish.domain.entities.control_unit +package fr.gouv.cnsp.monitorfish.domain.entities.station import kotlinx.serialization.Serializable @Serializable -data class ControlUnitStation( +data class Station( val id: Int, val latitude: Double, val longitude: Double, diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/control_units/dtos/FullControlUnitResource.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/control_units/dtos/FullControlUnitResource.kt index 0692f8fdc3..b6946e0755 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/control_units/dtos/FullControlUnitResource.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/control_units/dtos/FullControlUnitResource.kt @@ -2,7 +2,7 @@ package fr.gouv.cnsp.monitorfish.domain.use_cases.control_units.dtos import fr.gouv.cnsp.monitorfish.domain.entities.control_unit.ControlUnit import fr.gouv.cnsp.monitorfish.domain.entities.control_unit.ControlUnitResourceType -import fr.gouv.cnsp.monitorfish.domain.entities.control_unit.ControlUnitStation +import fr.gouv.cnsp.monitorfish.domain.entities.station.Station import kotlinx.serialization.Serializable @Serializable @@ -14,7 +14,7 @@ data class FullControlUnitResource( val name: String, val note: String?, val photo: ByteArray?, - val station: ControlUnitStation, + val station: Station, val stationId: Int, val type: ControlUnitResourceType, ) diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/fakers/FullControlUnitFaker.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/fakers/FullControlUnitFaker.kt index f10a7dd3ec..336add85b1 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/fakers/FullControlUnitFaker.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/fakers/FullControlUnitFaker.kt @@ -2,6 +2,7 @@ package fr.gouv.cnsp.monitorfish.fakers import fr.gouv.cnsp.monitorfish.domain.entities.administration.Administration import fr.gouv.cnsp.monitorfish.domain.entities.control_unit.* +import fr.gouv.cnsp.monitorfish.domain.entities.station.Station import fr.gouv.cnsp.monitorfish.domain.use_cases.control_units.dtos.FullControlUnit import fr.gouv.cnsp.monitorfish.domain.use_cases.control_units.dtos.FullControlUnitResource @@ -79,7 +80,7 @@ class FullControlUnitFaker { name: String = "Fake Resource Name", note: String? = "Default Resource Note", photo: ByteArray? = null, - station: ControlUnitStation = fakeControlUnitStation(), + station: Station = StationFaker.fakeStation(), stationId: Int = station.id, type: ControlUnitResourceType = ControlUnitResourceType.FRIGATE, ): FullControlUnitResource { @@ -126,19 +127,5 @@ class FullControlUnitFaker { name = name, ) } - - private fun fakeControlUnitStation( - id: Int = 1, - latitude: Double = 48.8566, - longitude: Double = 2.3522, - name: String = "Fake Station Name", - ): ControlUnitStation { - return ControlUnitStation( - id = id, - latitude = latitude, - longitude = longitude, - name = name, - ) - } } } diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/fakers/StationFaker.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/fakers/StationFaker.kt new file mode 100644 index 0000000000..4d1d7cb21a --- /dev/null +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/fakers/StationFaker.kt @@ -0,0 +1,21 @@ +package fr.gouv.cnsp.monitorfish.fakers + +import fr.gouv.cnsp.monitorfish.domain.entities.station.Station + +class StationFaker { + companion object { + fun fakeStation( + id: Int = 1, + latitude: Double = 48.8566, + longitude: Double = 2.3522, + name: String = "Fake Station Name", + ): Station { + return Station( + id = id, + latitude = latitude, + longitude = longitude, + name = name, + ) + } + } +} From e58b0491bf5111cb199e2934f8f412b2396bd5a0 Mon Sep 17 00:00:00 2001 From: Ivan Gabriele Date: Fri, 25 Oct 2024 08:50:18 +0200 Subject: [PATCH 30/59] Add vessels identity info in pno subscriber edition form --- .../PriorNotificationVesselSubscription.kt | 4 ++ .../domain/entities/vessel/Vessel.kt | 5 +- .../dtos/PriorNotificationSubscriber.kt | 20 ++++--- .../PriorNotificationSubscriberDataInput.kt | 10 +++- ...otificationVesselSubscriptionDataOutput.kt | 8 +++ .../entities/PnoVesselSubscriptionEntity.kt | 4 ++ .../GetPriorNotificationSubscriberUTests.kt | 7 ++- .../GetPriorNotificationSubscribersUTests.kt | 8 +++ .../PriorNotificationSubscriber.types.ts | 4 ++ ...ield.tsx => AllPortSubscriptionsField.tsx} | 12 ++-- .../FullPortSubscriptionsField.tsx | 6 +- .../SegmentSubscriptionsField.tsx | 2 +- .../VesselSubscriptionsField.tsx | 29 +++++---- .../constants.tsx | 28 --------- .../PriorNotificationSubscriberForm/index.tsx | 12 ++-- .../PriorNotificationSubscriberForm/utils.ts | 15 ----- .../{columns.tsx => utils.tsx} | 60 ++++++++++++++++++- 17 files changed, 154 insertions(+), 80 deletions(-) rename frontend/src/features/PriorNotification/components/PriorNotificationSubscriberForm/{LimitedPortSubscriptionsField.tsx => AllPortSubscriptionsField.tsx} (82%) delete mode 100644 frontend/src/features/PriorNotification/components/PriorNotificationSubscriberForm/constants.tsx delete mode 100644 frontend/src/features/PriorNotification/components/PriorNotificationSubscriberForm/utils.ts rename frontend/src/features/PriorNotification/components/PriorNotificationSubscriberForm/{columns.tsx => utils.tsx} (56%) diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/prior_notification/PriorNotificationVesselSubscription.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/prior_notification/PriorNotificationVesselSubscription.kt index da9d8954ad..eeb678f2ec 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/prior_notification/PriorNotificationVesselSubscription.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/entities/prior_notification/PriorNotificationVesselSubscription.kt @@ -3,5 +3,9 @@ package fr.gouv.cnsp.monitorfish.domain.entities.prior_notification data class PriorNotificationVesselSubscription( val controlUnitId: Int, val vesselId: Int, + val vesselCallSign: String?, + val vesselCfr: String?, + val vesselExternalMarking: String?, + val vesselMmsi: String?, val vesselName: String?, ) 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 0fbc7ad81a..f3523e5a27 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 @@ -7,14 +7,17 @@ import java.util.* // TODO Remove all default values. data class Vessel( val id: Int, - /** CFR (Community Fleet Register Number). */ + // TODO Rename to either `cfr` (domain naming) or `commonFleetRegisterNumber` (ex: https://eur-lex.europa.eu/legal-content/EN/TXT/HTML/?uri=CELEX%3A32017R0218). + /** CFR (Common Fleet Register Number). */ val internalReferenceNumber: String? = null, /** IMO (International Maritime Organization). IMO is one of multiple UVI (Unique Vessel Identifier) types. */ val imo: String? = null, /** MMSI (Maritime Mobile Service Identity). */ val mmsi: String? = null, + // TODO Rename to either `callSign` (domain naming) or `internationRadioCallSign`. /** IRCS (International Radio Call Sign). */ val ircs: String? = null, + // TODO Rename to `externalMarking` (domaim naming + correct translation, ex: https://mer.gouv.fr/sites/default/files/2022-10/EU_Vessel_List_for_Jersey_Waters_Access_sept_22.pdf). val externalReferenceNumber: String? = null, // TODO Rename to `name`. val vesselName: String? = null, diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/dtos/PriorNotificationSubscriber.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/dtos/PriorNotificationSubscriber.kt index d0486fd89d..9b959fb125 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/dtos/PriorNotificationSubscriber.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/dtos/PriorNotificationSubscriber.kt @@ -26,30 +26,36 @@ data class PriorNotificationSubscriber( ): PriorNotificationSubscriber { portSubscriptions.any { portSubscription -> portSubscription.hasSubscribedToAllPriorNotifications } - val namedFleetSegmentSubscriptions = + val enrichedFleetSegmentSubscriptions = fleetSegmentSubscriptions.map { fleetSegmentSubscription -> val fleetSegment = allFleetSegments.find { it.segment == fleetSegmentSubscription.segmentCode } return@map fleetSegmentSubscription.copy(segmentName = fleetSegment?.segmentName) } - val namedPortSubscriptions = + val enrichedPortSubscriptions = portSubscriptions.map { portSubscription -> val port = allPorts.find { it.locode == portSubscription.portLocode } return@map portSubscription.copy(portName = port?.name) } - val namedVesselSubscriptions = + val enrichedVesselSubscriptions = vesselSubscriptions.map { vesselSubscription -> val vessel = allVessels.find { it.id == vesselSubscription.vesselId } - return@map vesselSubscription.copy(vesselName = vessel?.vesselName) + return@map vesselSubscription.copy( + vesselCallSign = vessel?.ircs, + vesselCfr = vessel?.internalReferenceNumber, + vesselExternalMarking = vessel?.externalReferenceNumber, + vesselMmsi = vessel?.mmsi, + vesselName = vessel?.vesselName, + ) } return PriorNotificationSubscriber( controlUnit, - fleetSegmentSubscriptions = namedFleetSegmentSubscriptions, - portSubscriptions = namedPortSubscriptions, - vesselSubscriptions = namedVesselSubscriptions, + fleetSegmentSubscriptions = enrichedFleetSegmentSubscriptions, + portSubscriptions = enrichedPortSubscriptions, + vesselSubscriptions = enrichedVesselSubscriptions, ) } } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/input/PriorNotificationSubscriberDataInput.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/input/PriorNotificationSubscriberDataInput.kt index e13c4cbde1..44d415e79a 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/input/PriorNotificationSubscriberDataInput.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/input/PriorNotificationSubscriberDataInput.kt @@ -24,7 +24,15 @@ data class PriorNotificationSubscriberDataInput( } val vesselSubscriptions = vesselIds.map { vesselId -> - PriorNotificationVesselSubscription(controlUnitId, vesselId, null) + PriorNotificationVesselSubscription( + controlUnitId, + vesselId, + vesselCallSign = null, + vesselCfr = null, + vesselExternalMarking = null, + vesselMmsi = null, + vesselName = null, + ) } return Triple( diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/PriorNotificationVesselSubscriptionDataOutput.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/PriorNotificationVesselSubscriptionDataOutput.kt index d8247c142e..25bbc9b14f 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/PriorNotificationVesselSubscriptionDataOutput.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/PriorNotificationVesselSubscriptionDataOutput.kt @@ -5,6 +5,10 @@ import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotifica data class PriorNotificationVesselSubscriptionDataOutput( val controlUnitId: Int, val vesselId: Int, + val vesselCallSign: String?, + val vesselCfr: String?, + val vesselExternalMarking: String?, + val vesselMmsi: String?, val vesselName: String?, ) { companion object { @@ -14,6 +18,10 @@ data class PriorNotificationVesselSubscriptionDataOutput( return PriorNotificationVesselSubscriptionDataOutput( controlUnitId = priorNotificationFleetVesselSubscription.controlUnitId, vesselId = priorNotificationFleetVesselSubscription.vesselId, + vesselCallSign = priorNotificationFleetVesselSubscription.vesselCallSign, + vesselCfr = priorNotificationFleetVesselSubscription.vesselCfr, + vesselExternalMarking = priorNotificationFleetVesselSubscription.vesselExternalMarking, + vesselMmsi = priorNotificationFleetVesselSubscription.vesselMmsi, vesselName = priorNotificationFleetVesselSubscription.vesselName, ) } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/PnoVesselSubscriptionEntity.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/PnoVesselSubscriptionEntity.kt index 1ccd02c6f4..09d64783e4 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/PnoVesselSubscriptionEntity.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/entities/PnoVesselSubscriptionEntity.kt @@ -20,6 +20,10 @@ data class PnoVesselSubscriptionEntity( return PriorNotificationVesselSubscription( controlUnitId = id.controlUnitId, vesselId = id.vesselId, + vesselCallSign = null, + vesselCfr = null, + vesselExternalMarking = null, + vesselMmsi = null, vesselName = null, ) } diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationSubscriberUTests.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationSubscriberUTests.kt index 0cec6c2e27..8f23671355 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationSubscriberUTests.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationSubscriberUTests.kt @@ -97,7 +97,12 @@ class GetPriorNotificationSubscriberUTests { PriorNotificationVesselSubscription( controlUnitId = fakeControlUnitId, vesselId = 1, - vesselName = null, // Expecting the use case to populate this + // Expecting the use case to populate these + vesselCallSign = null, + vesselCfr = null, + vesselExternalMarking = null, + vesselMmsi = null, + vesselName = null, ), ) given(pnoVesselSubscriptionRepository.findByControlUnitId(fakeControlUnitId)) diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationSubscribersUTests.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationSubscribersUTests.kt index fa1301dd75..008ebaee07 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationSubscribersUTests.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationSubscribersUTests.kt @@ -100,11 +100,19 @@ class GetPriorNotificationSubscribersUTests { PriorNotificationVesselSubscription( controlUnitId = 1, vesselId = 1, + vesselCallSign = null, + vesselCfr = null, + vesselExternalMarking = null, + vesselMmsi = null, vesselName = null, ), PriorNotificationVesselSubscription( controlUnitId = 2, vesselId = 2, + vesselCallSign = null, + vesselCfr = null, + vesselExternalMarking = null, + vesselMmsi = null, vesselName = null, ), ) diff --git a/frontend/src/features/PriorNotification/PriorNotificationSubscriber.types.ts b/frontend/src/features/PriorNotification/PriorNotificationSubscriber.types.ts index f77ecab762..32460711ed 100644 --- a/frontend/src/features/PriorNotification/PriorNotificationSubscriber.types.ts +++ b/frontend/src/features/PriorNotification/PriorNotificationSubscriber.types.ts @@ -35,7 +35,11 @@ export namespace PriorNotificationSubscriber { export type VesselSubscription = { controlUnitId: number + vesselCallSign: string | undefined + vesselCfr: string | undefined + vesselExternalMarking: string | undefined vesselId: number + vesselMmsi: string | undefined vesselName: string | undefined } diff --git a/frontend/src/features/PriorNotification/components/PriorNotificationSubscriberForm/LimitedPortSubscriptionsField.tsx b/frontend/src/features/PriorNotification/components/PriorNotificationSubscriberForm/AllPortSubscriptionsField.tsx similarity index 82% rename from frontend/src/features/PriorNotification/components/PriorNotificationSubscriberForm/LimitedPortSubscriptionsField.tsx rename to frontend/src/features/PriorNotification/components/PriorNotificationSubscriberForm/AllPortSubscriptionsField.tsx index fef9b36da2..498d07aa29 100644 --- a/frontend/src/features/PriorNotification/components/PriorNotificationSubscriberForm/LimitedPortSubscriptionsField.tsx +++ b/frontend/src/features/PriorNotification/components/PriorNotificationSubscriberForm/AllPortSubscriptionsField.tsx @@ -2,24 +2,24 @@ import { BackOfficeSubtitle } from '@features/BackOffice/components/BackOfficeSu import { useGetPortsAsOptions } from '@hooks/useGetPortsAsOptions' import { DataTable, Select } from '@mtes-mct/monitor-ui' -import { getPortSubscriptionTableColumns } from './columns' import { Info } from './shared/Info' +import { getPortSubscriptionTableColumns } from './utils' import type { PriorNotificationSubscriber } from '@features/PriorNotification/PriorNotificationSubscriber.types' import type { Promisable } from 'type-fest' -type LimitedPortSubscriptionsFieldProps = Readonly<{ +type AllPortSubscriptionsFieldProps = Readonly<{ isDisabled: boolean - onAdd: (newPortLocode: string, isAllNotificationSubscription: boolean) => Promisable - onRemove: (portLocodeToRemove: string, isAllNotificationSubscription: boolean) => Promisable + onAdd: (newPortLocode: string, isFullPortSubscription: boolean) => Promisable + onRemove: (portLocodeToRemove: string, isFullPortSubscription: boolean) => Promisable portSubscriptions: PriorNotificationSubscriber.PortSubscription[] }> -export function LimitedPortSubscriptionsField({ +export function AllPortSubscriptionsField({ isDisabled, onAdd, onRemove, portSubscriptions -}: LimitedPortSubscriptionsFieldProps) { +}: AllPortSubscriptionsFieldProps) { const { portsAsOptions } = useGetPortsAsOptions() const add = (newPortLocode: string | undefined) => { diff --git a/frontend/src/features/PriorNotification/components/PriorNotificationSubscriberForm/FullPortSubscriptionsField.tsx b/frontend/src/features/PriorNotification/components/PriorNotificationSubscriberForm/FullPortSubscriptionsField.tsx index 544144b8cc..608f3431fe 100644 --- a/frontend/src/features/PriorNotification/components/PriorNotificationSubscriberForm/FullPortSubscriptionsField.tsx +++ b/frontend/src/features/PriorNotification/components/PriorNotificationSubscriberForm/FullPortSubscriptionsField.tsx @@ -2,16 +2,16 @@ import { BackOfficeSubtitle } from '@features/BackOffice/components/BackOfficeSu import { useGetPortsAsOptions } from '@hooks/useGetPortsAsOptions' import { DataTable, Select } from '@mtes-mct/monitor-ui' -import { getPortSubscriptionTableColumns } from './columns' import { Info } from './shared/Info' +import { getPortSubscriptionTableColumns } from './utils' import type { PriorNotificationSubscriber } from '@features/PriorNotification/PriorNotificationSubscriber.types' import type { Promisable } from 'type-fest' type FullPortSubscriptionsFieldProps = Readonly<{ isDisabled: boolean - onAdd: (newPortLocode: string, isAllNotificationSubscription: boolean) => Promisable - onRemove: (portLocodeToRemove: string, isAllNotificationSubscription: boolean) => Promisable + onAdd: (newPortLocode: string, isFullPortSubscription: boolean) => Promisable + onRemove: (portLocodeToRemove: string, isFullPortSubscription: boolean) => Promisable portSubscriptions: PriorNotificationSubscriber.PortSubscription[] }> export function FullPortSubscriptionsField({ diff --git a/frontend/src/features/PriorNotification/components/PriorNotificationSubscriberForm/SegmentSubscriptionsField.tsx b/frontend/src/features/PriorNotification/components/PriorNotificationSubscriberForm/SegmentSubscriptionsField.tsx index 031d935060..8906338eda 100644 --- a/frontend/src/features/PriorNotification/components/PriorNotificationSubscriberForm/SegmentSubscriptionsField.tsx +++ b/frontend/src/features/PriorNotification/components/PriorNotificationSubscriberForm/SegmentSubscriptionsField.tsx @@ -2,8 +2,8 @@ import { BackOfficeSubtitle } from '@features/BackOffice/components/BackOfficeSu import { useGetFleetSegmentsAsOptions } from '@features/FleetSegment/hooks/useGetFleetSegmentsAsOptions' import { DataTable, Select } from '@mtes-mct/monitor-ui' -import { getSegmentSubscriptionTableColumns } from './columns' import { Info } from './shared/Info' +import { getSegmentSubscriptionTableColumns } from './utils' import type { PriorNotificationSubscriber } from '@features/PriorNotification/PriorNotificationSubscriber.types' import type { Promisable } from 'type-fest' diff --git a/frontend/src/features/PriorNotification/components/PriorNotificationSubscriberForm/VesselSubscriptionsField.tsx b/frontend/src/features/PriorNotification/components/PriorNotificationSubscriberForm/VesselSubscriptionsField.tsx index fd74b13791..2de90edc5e 100644 --- a/frontend/src/features/PriorNotification/components/PriorNotificationSubscriberForm/VesselSubscriptionsField.tsx +++ b/frontend/src/features/PriorNotification/components/PriorNotificationSubscriberForm/VesselSubscriptionsField.tsx @@ -3,8 +3,8 @@ import { VesselSearch } from '@features/Vessel/components/VesselSearch' import { DataTable, useKey } from '@mtes-mct/monitor-ui' import styled from 'styled-components' -import { getVesselSubscriptionTableColumns } from './columns' import { Info } from './shared/Info' +import { getVesselSubscriptionTableColumns } from './utils' import type { PriorNotificationSubscriber } from '@features/PriorNotification/PriorNotificationSubscriber.types' import type { VesselIdentity } from 'domain/entities/vessel/types' @@ -47,21 +47,30 @@ export function VesselSubscriptionsField({ Tous les préavis de ces navires seront diffusés, sans faire partie du périmètre de vérification du CNSP. - `${originalRow.controlUnitId}-${originalRow.vesselId}` - }} - withoutHead - /> + + `${originalRow.controlUnitId}-${originalRow.vesselId}` + }} + withoutHead + /> + ) } +const DataTableWrapper = styled.div` + > .Table-SimpleTable { + margin-bottom: 16px; + width: 1000px; + } +` + const StyledVesselSearch = styled(VesselSearch)` border: solid 1px ${p => p.theme.color.lightGray}; width: 400px; diff --git a/frontend/src/features/PriorNotification/components/PriorNotificationSubscriberForm/constants.tsx b/frontend/src/features/PriorNotification/components/PriorNotificationSubscriberForm/constants.tsx deleted file mode 100644 index 0c3175e821..0000000000 --- a/frontend/src/features/PriorNotification/components/PriorNotificationSubscriberForm/constants.tsx +++ /dev/null @@ -1,28 +0,0 @@ -import { Icon, IconButton, Size } from '@mtes-mct/monitor-ui' - -import type { PriorNotificationSubscriber } from '@features/PriorNotification/PriorNotificationSubscriber.types' -import type { ColumnDef } from '@tanstack/react-table' - -export const PORT_SUBSCRIPTION_TABLE_COLUMNS: Array> = [ - { - accessorFn: row => `${row.controlUnitId}-${row.portLocode}`, - enableSorting: false, - header: () => 'ID', - id: 'id', - size: 64 - }, - { - accessorFn: row => row.portName, - header: () => 'Port', - id: 'portName', - size: 240 - }, - { - accessorFn: row => row.portLocode, - cell: () => , - enableSorting: false, - header: () => '', - id: 'unsubscribe', - size: 44 - } -] diff --git a/frontend/src/features/PriorNotification/components/PriorNotificationSubscriberForm/index.tsx b/frontend/src/features/PriorNotification/components/PriorNotificationSubscriberForm/index.tsx index ab914cc155..afb0fd8750 100644 --- a/frontend/src/features/PriorNotification/components/PriorNotificationSubscriberForm/index.tsx +++ b/frontend/src/features/PriorNotification/components/PriorNotificationSubscriberForm/index.tsx @@ -10,8 +10,8 @@ import { useParams } from 'react-router-dom' import styled from 'styled-components' import { LoadingSpinnerWall } from 'ui/LoadingSpinnerWall' +import { AllPortSubscriptionsField } from './AllPortSubscriptionsField' import { FullPortSubscriptionsField } from './FullPortSubscriptionsField' -import { LimitedPortSubscriptionsField } from './LimitedPortSubscriptionsField' import { SegmentSubscriptionsField } from './SegmentSubscriptionsField' import { getFormDataFromSubscriber } from './utils' import { VesselSubscriptionsField } from './VesselSubscriptionsField' @@ -39,9 +39,9 @@ export function PriorNotificationSubscriberForm() { dispatch(priorNotificationSubscriberApi.endpoints.updatePriorNotificationSubscriber.initiate(nextFormData)).unwrap() } - const addPortSubscription = (newPortLocode: string, isAllNotificationSubscription: boolean) => { + const addPortSubscription = (newPortLocode: string, isFullPortSubscription: boolean) => { const nextPortLocodes = [...formData.portLocodes, newPortLocode] - const nextPortLocodesWithAllNotifications = isAllNotificationSubscription + const nextPortLocodesWithAllNotifications = isFullPortSubscription ? [...formData.portLocodesWithFullSubscription, newPortLocode] : formData.portLocodesWithFullSubscription @@ -70,8 +70,8 @@ export function PriorNotificationSubscriberForm() { }) } - const removePortSubscription = (portLocodeToRemove: string, isAllNotificationSubscription: boolean) => { - const nextPortLocodes = isAllNotificationSubscription + const removePortSubscription = (portLocodeToRemove: string, isFullPortSubscription: boolean) => { + const nextPortLocodes = isFullPortSubscription ? formData.portLocodes : formData.portLocodes.filter(portLocode => portLocode !== portLocodeToRemove) const nextPortLocodesWithAllNotifications = formData.portLocodesWithFullSubscription.filter( @@ -107,7 +107,7 @@ export function PriorNotificationSubscriberForm() { {`${subscriber.controlUnit.name} (${subscriber.controlUnit.administration.name}) – Paramétrage de la diffusion des préavis`} - subscription.segmentCode), - portLocodes: subscriber.portSubscriptions.map(subscription => subscription.portLocode), - portLocodesWithFullSubscription: subscriber.portSubscriptions - .filter(subscription => subscription.hasSubscribedToAllPriorNotifications) - .map(subscription => subscription.portLocode), - vesselIds: subscriber.vesselSubscriptions.map(subscription => subscription.vesselId) - } -} diff --git a/frontend/src/features/PriorNotification/components/PriorNotificationSubscriberForm/columns.tsx b/frontend/src/features/PriorNotification/components/PriorNotificationSubscriberForm/utils.tsx similarity index 56% rename from frontend/src/features/PriorNotification/components/PriorNotificationSubscriberForm/columns.tsx rename to frontend/src/features/PriorNotification/components/PriorNotificationSubscriberForm/utils.tsx index 0584589604..b46e1c4406 100644 --- a/frontend/src/features/PriorNotification/components/PriorNotificationSubscriberForm/columns.tsx +++ b/frontend/src/features/PriorNotification/components/PriorNotificationSubscriberForm/utils.tsx @@ -1,9 +1,24 @@ import { Icon, IconButton, Size } from '@mtes-mct/monitor-ui' +import styled from 'styled-components' import type { PriorNotificationSubscriber } from '@features/PriorNotification/PriorNotificationSubscriber.types' import type { CellContext, ColumnDef } from '@tanstack/react-table' import type { Promisable } from 'type-fest' +export function getFormDataFromSubscriber( + subscriber: PriorNotificationSubscriber.Subscriber +): PriorNotificationSubscriber.FormData { + return { + controlUnitId: subscriber.controlUnit.id, + fleetSegmentCodes: subscriber.fleetSegmentSubscriptions.map(subscription => subscription.segmentCode), + portLocodes: subscriber.portSubscriptions.map(subscription => subscription.portLocode), + portLocodesWithFullSubscription: subscriber.portSubscriptions + .filter(subscription => subscription.hasSubscribedToAllPriorNotifications) + .map(subscription => subscription.portLocode), + vesselIds: subscriber.vesselSubscriptions.map(subscription => subscription.vesselId) + } +} + export function getPortSubscriptionTableColumns( onRemove: (portLocodeToRemove: string) => Promisable, isDisabled: boolean @@ -70,7 +85,46 @@ export function getVesselSubscriptionTableColumns( { accessorFn: row => row.vesselName, header: () => 'Navire', - id: 'vesselName' + id: 'vesselName', + size: 320 + }, + { + accessorFn: row => row, + cell: ( + context: CellContext< + PriorNotificationSubscriber.VesselSubscription, + PriorNotificationSubscriber.VesselSubscription + > + ) => { + const vesselSubscription = context.getValue() + + return ( + + {vesselSubscription.vesselCfr && ( + <> + {vesselSubscription.vesselCfr} (CFR) - + + )} + {vesselSubscription.vesselMmsi && ( + <> + {vesselSubscription.vesselMmsi} (MMSI) - + + )} + {vesselSubscription.vesselExternalMarking && ( + <> + {vesselSubscription.vesselExternalMarking} (Marq. ext.) - + + )} + {vesselSubscription.vesselCallSign && ( + <> + {vesselSubscription.vesselCallSign} (Call Sign) + + )} + + ) + }, + header: () => 'Immatriculations', + id: 'vesselIdentity' }, { accessorFn: row => row.vesselId, @@ -90,3 +144,7 @@ export function getVesselSubscriptionTableColumns( } ] } + +const VesselIdentifierLabel = styled.span` + color: ${p => p.theme.color.slateGray}; +` From 166bf49a7e208b5ea80d066b0eb612c03751c1ed Mon Sep 17 00:00:00 2001 From: Ivan Gabriele Date: Fri, 25 Oct 2024 08:57:45 +0200 Subject: [PATCH 31/59] Add back button in pno subscriber edition form --- .../PriorNotificationSubscriberForm/index.tsx | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/frontend/src/features/PriorNotification/components/PriorNotificationSubscriberForm/index.tsx b/frontend/src/features/PriorNotification/components/PriorNotificationSubscriberForm/index.tsx index afb0fd8750..1bc6cb5ffe 100644 --- a/frontend/src/features/PriorNotification/components/PriorNotificationSubscriberForm/index.tsx +++ b/frontend/src/features/PriorNotification/components/PriorNotificationSubscriberForm/index.tsx @@ -1,12 +1,14 @@ import { BackOfficeBody } from '@features/BackOffice/components/BackofficeBody' +import { BACK_OFFICE_MENU_PATH, BackOfficeMenuKey } from '@features/BackOffice/components/BackofficeMenu/constants' import { BackOfficeTitle } from '@features/BackOffice/components/BackOfficeTitle' import { priorNotificationSubscriberApi, useGetPriorNotificationSubscriberQuery } from '@features/PriorNotification/priorNotificationSubscriberApi' import { useBackofficeAppDispatch } from '@hooks/useBackofficeAppDispatch' +import { Accent, Button } from '@mtes-mct/monitor-ui' import { assertNotNullish } from '@utils/assertNotNullish' -import { useParams } from 'react-router-dom' +import { useNavigate, useParams } from 'react-router-dom' import styled from 'styled-components' import { LoadingSpinnerWall } from 'ui/LoadingSpinnerWall' @@ -19,10 +21,12 @@ import { VesselSubscriptionsField } from './VesselSubscriptionsField' import type { PriorNotificationSubscriber } from '@features/PriorNotification/PriorNotificationSubscriber.types' export function PriorNotificationSubscriberForm() { - const dispatch = useBackofficeAppDispatch() const { controlUnitId } = useParams() assertNotNullish(controlUnitId) + const dispatch = useBackofficeAppDispatch() + const navigate = useNavigate() + const { data: subscriber, isFetching } = useGetPriorNotificationSubscriberQuery(Number(controlUnitId)) if (!subscriber) { @@ -35,6 +39,10 @@ export function PriorNotificationSubscriberForm() { portSubscription => portSubscription.hasSubscribedToAllPriorNotifications ) + const goBackToList = () => { + navigate(`/backoffice${BACK_OFFICE_MENU_PATH[BackOfficeMenuKey.PRIOR_NOTIFICATION_SUBSCRIBER_LIST]}`) + } + const update = (nextFormData: PriorNotificationSubscriber.FormData) => { dispatch(priorNotificationSubscriberApi.endpoints.updatePriorNotificationSubscriber.initiate(nextFormData)).unwrap() } @@ -134,6 +142,14 @@ export function PriorNotificationSubscriberForm() { onRemove={removeVesselSubscription} vesselSubscriptions={subscriber.vesselSubscriptions} /> + +
+ +
+ +
) } From cb8036e50b005c4f7e7fd8a87562f5e261151964 Mon Sep 17 00:00:00 2001 From: Ivan Gabriele Date: Fri, 25 Oct 2024 09:22:08 +0200 Subject: [PATCH 32/59] Add full port unsubscription confirmation in pno subscriber edition form --- frontend/src/components/ConfirmationModal.tsx | 22 ++++++++-- .../AllPortSubscriptionsField.tsx | 2 +- .../FullPortSubscriptionsField.tsx | 44 +++++++++++++++++-- .../PriorNotificationSubscriberForm/utils.tsx | 11 +++-- 4 files changed, 69 insertions(+), 10 deletions(-) diff --git a/frontend/src/components/ConfirmationModal.tsx b/frontend/src/components/ConfirmationModal.tsx index 157d9a8adf..7aa83487c8 100644 --- a/frontend/src/components/ConfirmationModal.tsx +++ b/frontend/src/components/ConfirmationModal.tsx @@ -33,7 +33,7 @@ export function ConfirmationModal({ )} - {message} + {typeof message === 'string' ? {message} : message} @@ -48,9 +48,25 @@ export function ConfirmationModal({ // TODO Allow direct `width` prop control in MUI. // This is a mess. I wonder if we should add inner classes in MUI. const StyledDialog = styled(Dialog)` + ${Dialog.Title} { + font-size: 23px; + } + + ${Dialog.Body} { + b, + p { + font-size: 16px; + line-height: 22px; + } + + > p:not(:first-child) { + margin-top: 24px; + } + } + > div:last-child { - max-width: 440px; - min-width: 440px; + max-width: 600px; + min-width: 600px; /* Dialog.Body */ > div:nth-child(2) { diff --git a/frontend/src/features/PriorNotification/components/PriorNotificationSubscriberForm/AllPortSubscriptionsField.tsx b/frontend/src/features/PriorNotification/components/PriorNotificationSubscriberForm/AllPortSubscriptionsField.tsx index 498d07aa29..3f1825a12e 100644 --- a/frontend/src/features/PriorNotification/components/PriorNotificationSubscriberForm/AllPortSubscriptionsField.tsx +++ b/frontend/src/features/PriorNotification/components/PriorNotificationSubscriberForm/AllPortSubscriptionsField.tsx @@ -34,7 +34,7 @@ export function AllPortSubscriptionsField({ onRemove(portLocodeToRemove, false) } - const columns = getPortSubscriptionTableColumns(remove, isDisabled) + const columns = getPortSubscriptionTableColumns(remove, false, isDisabled) return ( <> diff --git a/frontend/src/features/PriorNotification/components/PriorNotificationSubscriberForm/FullPortSubscriptionsField.tsx b/frontend/src/features/PriorNotification/components/PriorNotificationSubscriberForm/FullPortSubscriptionsField.tsx index 608f3431fe..cb3f572c3a 100644 --- a/frontend/src/features/PriorNotification/components/PriorNotificationSubscriberForm/FullPortSubscriptionsField.tsx +++ b/frontend/src/features/PriorNotification/components/PriorNotificationSubscriberForm/FullPortSubscriptionsField.tsx @@ -1,6 +1,8 @@ +import { ConfirmationModal } from '@components/ConfirmationModal' import { BackOfficeSubtitle } from '@features/BackOffice/components/BackOfficeSubtitle' import { useGetPortsAsOptions } from '@hooks/useGetPortsAsOptions' import { DataTable, Select } from '@mtes-mct/monitor-ui' +import { useState } from 'react' import { Info } from './shared/Info' import { getPortSubscriptionTableColumns } from './utils' @@ -22,6 +24,10 @@ export function FullPortSubscriptionsField({ }: FullPortSubscriptionsFieldProps) { const { portsAsOptions } = useGetPortsAsOptions() + const [unsubscriptionConfirmationModalPortLocode, setUnsubscriptionConfirmationModalPortLocode] = useState< + string | undefined + >(undefined) + const add = (newPortLocode: string | undefined) => { if (!newPortLocode) { return @@ -30,11 +36,23 @@ export function FullPortSubscriptionsField({ onAdd(newPortLocode, true) } - const remove = (portLocodeToRemove: string) => { - onRemove(portLocodeToRemove, true) + const askForRemovalConfirmation = (portLocodeToRemove: string) => { + setUnsubscriptionConfirmationModalPortLocode(portLocodeToRemove) + } + + const closeRemovalConfirmationModal = () => { + setUnsubscriptionConfirmationModalPortLocode(undefined) } - const columns = getPortSubscriptionTableColumns(remove, isDisabled) + const remove = () => { + if (!unsubscriptionConfirmationModalPortLocode) { + return + } + + onRemove(unsubscriptionConfirmationModalPortLocode, true) + } + + const columns = getPortSubscriptionTableColumns(askForRemovalConfirmation, true, isDisabled) return ( <> @@ -63,6 +81,26 @@ export function FullPortSubscriptionsField({ onChange={add} options={portsAsOptions ?? []} /> + + {unsubscriptionConfirmationModalPortLocode && ( + +

+ Êtes-vous sûr de vouloir supprimer ce port de diffusion ? +

+

+ L’unité ne recevra plus les préavis des navires ayant une note de risque supérieure à 2,3 lorsqu’ils + débarquent dans ce port. +

+ + } + onCancel={closeRemovalConfirmationModal} + onConfirm={remove} + title="Supprimer un port de diffusion" + /> + )} ) } diff --git a/frontend/src/features/PriorNotification/components/PriorNotificationSubscriberForm/utils.tsx b/frontend/src/features/PriorNotification/components/PriorNotificationSubscriberForm/utils.tsx index b46e1c4406..5023c0afb5 100644 --- a/frontend/src/features/PriorNotification/components/PriorNotificationSubscriberForm/utils.tsx +++ b/frontend/src/features/PriorNotification/components/PriorNotificationSubscriberForm/utils.tsx @@ -21,6 +21,7 @@ export function getFormDataFromSubscriber( export function getPortSubscriptionTableColumns( onRemove: (portLocodeToRemove: string) => Promisable, + isFullPortSubscription: boolean, isDisabled: boolean ): Array> { return [ @@ -37,7 +38,11 @@ export function getPortSubscriptionTableColumns( Icon={Icon.Delete} onClick={() => onRemove(context.getValue())} size={Size.SMALL} - title="Désinsrire l'unité des préavis liés à ce port" + title={ + isFullPortSubscription + ? "Désinscrire l'unité des préavis liés à ce port pour les navires dont la note de risque est supérieure à 2,3" + : "Désinscrire l'unité de tous les préavis liés à ce port" + } /> ), enableSorting: false, @@ -66,7 +71,7 @@ export function getSegmentSubscriptionTableColumns( Icon={Icon.Delete} onClick={() => onRemove(context.getValue())} size={Size.SMALL} - title="Désinsrire l'unité des préavis liés à ce segment de flotte" + title="Désinscrire l'unité de tous les préavis liés à ce segment de flotte" /> ), enableSorting: false, @@ -134,7 +139,7 @@ export function getVesselSubscriptionTableColumns( Icon={Icon.Delete} onClick={() => onRemove(context.getValue())} size={Size.SMALL} - title="Désinsrire l'unité des préavis liés à ce navire" + title="Désinscrire l'unité de tous les préavis liés à ce navire" /> ), enableSorting: false, From f27bfd5cc83b71227449d034f3e98258def194e6 Mon Sep 17 00:00:00 2001 From: Ivan Gabriele Date: Fri, 25 Oct 2024 09:49:10 +0200 Subject: [PATCH 33/59] Fix pno subscribers getter use cases unit tests in Backend --- .../GetPriorNotificationSubscriberUTests.kt | 28 +++++++++++-- .../GetPriorNotificationSubscribersUTests.kt | 40 +++++++++++++++++-- 2 files changed, 61 insertions(+), 7 deletions(-) diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationSubscriberUTests.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationSubscriberUTests.kt index 8f23671355..46aa99c502 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationSubscriberUTests.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationSubscriberUTests.kt @@ -64,8 +64,22 @@ class GetPriorNotificationSubscriberUTests { val allFakeVessels = listOf( - VesselFaker.fakeVessel(id = 1, vesselName = "Vessel 1"), - VesselFaker.fakeVessel(id = 2, vesselName = "Vessel 2"), + VesselFaker.fakeVessel( + id = 1, + vesselName = "Vessel 1", + internalReferenceNumber = "CFR001", + externalReferenceNumber = "EXT001", + ircs = "CALLSIGN01", + mmsi = "MMSI01", + ), + VesselFaker.fakeVessel( + id = 2, + vesselName = "Vessel 2", + internalReferenceNumber = "CFR002", + externalReferenceNumber = "EXT002", + ircs = "CALLSIGN02", + mmsi = "MMSI02", + ), ) given(vesselRepository.findAll()).willReturn(allFakeVessels) @@ -126,7 +140,15 @@ class GetPriorNotificationSubscriberUTests { fakeFleetSegmentSubscriptions[0].copy(segmentName = "Segment 1"), ) assertThat(result.portSubscriptions).containsExactly(portSubscriptions[0].copy(portName = "Port 1")) - assertThat(result.vesselSubscriptions).containsExactly(vesselSubscriptions[0].copy(vesselName = "Vessel 1")) + assertThat(result.vesselSubscriptions).containsExactly( + vesselSubscriptions[0].copy( + vesselCallSign = "CALLSIGN01", + vesselCfr = "CFR001", + vesselExternalMarking = "EXT001", + vesselMmsi = "MMSI01", + vesselName = "Vessel 1", + ), + ) } @Test diff --git a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationSubscribersUTests.kt b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationSubscribersUTests.kt index 008ebaee07..2a061231ed 100644 --- a/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationSubscribersUTests.kt +++ b/backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/GetPriorNotificationSubscribersUTests.kt @@ -57,8 +57,24 @@ class GetPriorNotificationSubscribersUTests { val fakePort2 = PortFaker.fakePort(locode = "ESXYZ", name = "Port XYZ") given(portRepository.findAll()).willReturn(listOf(fakePort1, fakePort2)) - val fakeVessel1 = VesselFaker.fakeVessel(id = 1, vesselName = "Vessel 1") - val fakeVessel2 = VesselFaker.fakeVessel(id = 2, vesselName = "Vessel 2") + val fakeVessel1 = + VesselFaker.fakeVessel( + id = 1, + internalReferenceNumber = "CFR001", + ircs = "CALLSIGN01", + externalReferenceNumber = "EXT001", + mmsi = "MMSI01", + vesselName = "Vessel 1", + ) + val fakeVessel2 = + VesselFaker.fakeVessel( + id = 2, + internalReferenceNumber = "CFR002", + ircs = "CALLSIGN02", + externalReferenceNumber = "EXT002", + mmsi = "MMSI02", + vesselName = "Vessel 2", + ) given(vesselRepository.findAll()).willReturn(listOf(fakeVessel1, fakeVessel2)) val fakeFleetSegmentSubscriptions = @@ -149,7 +165,15 @@ class GetPriorNotificationSubscribersUTests { listOf(fakePortSubscriptions[0].copy(portName = "Port ABC")), ) assertThat(result[0].vesselSubscriptions).isEqualTo( - listOf(fakeVesselSubscriptions[0].copy(vesselName = "Vessel 1")), + listOf( + fakeVesselSubscriptions[0].copy( + vesselCallSign = "CALLSIGN01", + vesselCfr = "CFR001", + vesselExternalMarking = "EXT001", + vesselMmsi = "MMSI01", + vesselName = "Vessel 1", + ), + ), ) assertThat(result[1].controlUnit).isEqualTo(fakeFullControlUnit2) @@ -160,7 +184,15 @@ class GetPriorNotificationSubscribersUTests { listOf(fakePortSubscriptions[1].copy(portName = "Port XYZ")), ) assertThat(result[1].vesselSubscriptions).isEqualTo( - listOf(fakeVesselSubscriptions[1].copy(vesselName = "Vessel 2")), + listOf( + fakeVesselSubscriptions[1].copy( + vesselCallSign = "CALLSIGN02", + vesselCfr = "CFR002", + vesselExternalMarking = "EXT002", + vesselMmsi = "MMSI02", + vesselName = "Vessel 2", + ), + ), ) } From 632db39a50e55d1cd9a95a53a5df9be71688684c Mon Sep 17 00:00:00 2001 From: Ivan Gabriele Date: Fri, 25 Oct 2024 15:46:04 +0200 Subject: [PATCH 34/59] Fix BackOffice regulation edition e2e tests through small simplifications --- frontend/cypress/e2e/backoffice/new_regulation.spec.ts | 7 +++---- frontend/cypress/e2e/backoffice/update_regulation.spec.ts | 6 ++++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/frontend/cypress/e2e/backoffice/new_regulation.spec.ts b/frontend/cypress/e2e/backoffice/new_regulation.spec.ts index 936f0c1fb9..76884dc531 100644 --- a/frontend/cypress/e2e/backoffice/new_regulation.spec.ts +++ b/frontend/cypress/e2e/backoffice/new_regulation.spec.ts @@ -49,15 +49,14 @@ context('New Regulation', () => { it('Region list should be enabled or disabled depending on the law type', () => { // Select a French law type cy.fill('Choisir un ensemble', 'Reg. MED') - cy.get('[id="Choisir une région"]').click() + cy.get('[id="Choisir une région"]').parent().click() // Region list length should be equal to 18 cy.get('[id="Choisir une région-listbox"] > div').should('have.length', 18) // Select a EU law type cy.fill('Choisir un ensemble', '2019') - cy.get('[data-key="R(UE) 2019/1241"]').eq(0).click({ force: true }) // Region select picker should be disabled - cy.get('[id="Choisir une région"]').click().should('have.attr', 'aria-disabled', 'true') + cy.get('[id="Choisir une région"]').forceClick().should('have.attr', 'aria-disabled', 'true') }) it('Select "Grand Est" and "Auvergne-Rhône-Alpes" region and remove it', () => { @@ -191,7 +190,7 @@ context('New Regulation', () => { cy.get('[data-cy="regulatory-gears-section"]').scrollIntoView().click() cy.get('[data-cy="authorized-all-towed-gears-option"] > div > label').click() cy.get('*[data-cy^="open-regulated-species"]').scrollIntoView().click({ force: true }).scrollIntoView() - cy.get('.rs-picker-toggle-placeholder').filter(':contains("catégories d\'espèces")').eq(0).click({ timeout: 10000 }) + cy.get('.rs-picker-toggle-placeholder').filter(':contains("catégories d\'espèces")').eq(0).parent().click() cy.wait(200) cy.get('.rs-search-box-input').type('Espèce{enter}', { force: true }) cy.get('.rs-picker-toggle-placeholder').filter(':contains("des espèces")').eq(0).click({ timeout: 10000 }) diff --git a/frontend/cypress/e2e/backoffice/update_regulation.spec.ts b/frontend/cypress/e2e/backoffice/update_regulation.spec.ts index e825abad7a..e549b1519d 100644 --- a/frontend/cypress/e2e/backoffice/update_regulation.spec.ts +++ b/frontend/cypress/e2e/backoffice/update_regulation.spec.ts @@ -108,8 +108,9 @@ context('Update Regulation', () => { cy.get('.rs-picker-toggle-placeholder') .filter(':contains("catégories d\'espèces")') .eq(0) + .parent() .scrollIntoView() - .click({ timeout: 10000 }) + .click() cy.get('.rs-search-box-input').type('Espèce{enter}') cy.get('[data-cy="authorized-species-selector"]').filter(':contains("des espèces")').click({ timeout: 10000 }) cy.wait(200) @@ -120,8 +121,9 @@ context('Update Regulation', () => { cy.get('.rs-picker-toggle-placeholder') .filter(':contains("catégories d\'espèces")') .eq(1) + .parent() .scrollIntoView() - .click({ timeout: 10000 }) + .click() cy.get('.rs-search-box-input').should('have.length', 1) cy.get('.rs-search-box-input').type('Bival{enter}') cy.get('[data-cy="unauthorized-species-selector"]').filter(':contains("des espèces")').click({ timeout: 10000 }) From 653de1c3e3b028b844dd025ac40e30cf360fcf70 Mon Sep 17 00:00:00 2001 From: Ivan Gabriele Date: Fri, 25 Oct 2024 16:20:08 +0200 Subject: [PATCH 35/59] Lint code following SonarCloud suggestions --- .../repositories/interfaces/DBVesselRepository.kt | 12 ++++++------ .../PriorNotificationSubscriber.types.ts | 4 ++-- .../VesselSubscriptionsField.tsx | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/interfaces/DBVesselRepository.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/interfaces/DBVesselRepository.kt index 7b69dbbc5e..f4b008f4fb 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/interfaces/DBVesselRepository.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/interfaces/DBVesselRepository.kt @@ -8,11 +8,11 @@ import org.springframework.data.repository.query.Param interface DBVesselRepository : CrudRepository { @Query( value = - "SELECT * FROM vessels WHERE cfr LIKE %:searched% " + - "OR mmsi LIKE %:searched% " + - "OR vessel_name LIKE %:searched% " + - "OR external_immatriculation LIKE %:searched% " + - "OR ircs LIKE %:searched% limit 50", + "SELECT * FROM vessels WHERE cfr LIKE %:searched% " + + "OR mmsi LIKE %:searched% " + + "OR vessel_name LIKE %:searched% " + + "OR external_immatriculation LIKE %:searched% " + + "OR ircs LIKE %:searched% limit 50", nativeQuery = true, ) fun searchBy( @@ -36,7 +36,7 @@ interface DBVesselRepository : CrudRepository { @Query(value = "SELECT * FROM vessels WHERE cfr in (:cfr)", nativeQuery = true) fun findAllByInternalReferenceNumbers(cfr: List): List - + @Query( value = """ SELECT under_charter diff --git a/frontend/src/features/PriorNotification/PriorNotificationSubscriber.types.ts b/frontend/src/features/PriorNotification/PriorNotificationSubscriber.types.ts index 32460711ed..d7cf1adeb5 100644 --- a/frontend/src/features/PriorNotification/PriorNotificationSubscriber.types.ts +++ b/frontend/src/features/PriorNotification/PriorNotificationSubscriber.types.ts @@ -9,14 +9,14 @@ export namespace PriorNotificationSubscriber { /** @internal Only used within this namespace. */ type Administration = { id: number - name: String + name: string } /** @internal Only used within this namespace. */ type ControlUnit = { administration: Administration id: number - name: String + name: string } export type FleetSegmentSubscription = { diff --git a/frontend/src/features/PriorNotification/components/PriorNotificationSubscriberForm/VesselSubscriptionsField.tsx b/frontend/src/features/PriorNotification/components/PriorNotificationSubscriberForm/VesselSubscriptionsField.tsx index 2de90edc5e..829aac4aa4 100644 --- a/frontend/src/features/PriorNotification/components/PriorNotificationSubscriberForm/VesselSubscriptionsField.tsx +++ b/frontend/src/features/PriorNotification/components/PriorNotificationSubscriberForm/VesselSubscriptionsField.tsx @@ -25,7 +25,7 @@ export function VesselSubscriptionsField({ const key = useKey([vesselSubscriptions]) const add = (newVesselIdentity: VesselIdentity | undefined) => { - if (!newVesselIdentity || !newVesselIdentity.vesselId) { + if (!newVesselIdentity?.vesselId) { return } From 26de246875baf6c2f20117f3715ad65b844aa75c Mon Sep 17 00:00:00 2001 From: Ivan Gabriele Date: Fri, 25 Oct 2024 17:00:03 +0200 Subject: [PATCH 36/59] Re-organize BackOffice e2e test files --- .../interfaces/DBVesselRepository.kt | 12 ++--- .../actions.spec.ts} | 51 +----------------- .../control_objective_tables/behavior.spec.ts | 28 ++++++++++ .../control_objective_tables/table.spec.ts | 45 ++++++++++++++++ ...ts.spec.ts => fleet_segment_table.spec.ts} | 2 +- ... The geometry Should be displayed #0.png} | Bin ... The geometry Should be displayed #1.png} | Bin .../creation.spec.ts} | 2 +- .../edition.spec.ts} | 4 +- .../regulation_table/behavior.spec.ts | 37 +++++++++++++ .../table.spec.ts} | 31 +---------- 11 files changed, 122 insertions(+), 90 deletions(-) rename frontend/cypress/e2e/backoffice/{control_objectives.spec.ts => control_objective_tables/actions.spec.ts} (67%) create mode 100644 frontend/cypress/e2e/backoffice/control_objective_tables/behavior.spec.ts create mode 100644 frontend/cypress/e2e/backoffice/control_objective_tables/table.spec.ts rename frontend/cypress/e2e/backoffice/{fleet_segments.spec.ts => fleet_segment_table.spec.ts} (99%) rename frontend/cypress/e2e/backoffice/{__image_snapshots__/Update Regulation The geometry Should be displayed #0.png => regulation_form/__image_snapshots__/BackOffice Regulation Form Edition The geometry Should be displayed #0.png} (100%) rename frontend/cypress/e2e/backoffice/{__image_snapshots__/Update Regulation The geometry Should be displayed #1.png => regulation_form/__image_snapshots__/BackOffice Regulation Form Edition The geometry Should be displayed #1.png} (100%) rename frontend/cypress/e2e/backoffice/{new_regulation.spec.ts => regulation_form/creation.spec.ts} (99%) rename frontend/cypress/e2e/backoffice/{update_regulation.spec.ts => regulation_form/edition.spec.ts} (99%) create mode 100644 frontend/cypress/e2e/backoffice/regulation_table/behavior.spec.ts rename frontend/cypress/e2e/backoffice/{regulatory_zone_list.spec.ts => regulation_table/table.spec.ts} (56%) diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/interfaces/DBVesselRepository.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/interfaces/DBVesselRepository.kt index f4b008f4fb..7b69dbbc5e 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/interfaces/DBVesselRepository.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/database/repositories/interfaces/DBVesselRepository.kt @@ -8,11 +8,11 @@ import org.springframework.data.repository.query.Param interface DBVesselRepository : CrudRepository { @Query( value = - "SELECT * FROM vessels WHERE cfr LIKE %:searched% " + - "OR mmsi LIKE %:searched% " + - "OR vessel_name LIKE %:searched% " + - "OR external_immatriculation LIKE %:searched% " + - "OR ircs LIKE %:searched% limit 50", + "SELECT * FROM vessels WHERE cfr LIKE %:searched% " + + "OR mmsi LIKE %:searched% " + + "OR vessel_name LIKE %:searched% " + + "OR external_immatriculation LIKE %:searched% " + + "OR ircs LIKE %:searched% limit 50", nativeQuery = true, ) fun searchBy( @@ -36,7 +36,7 @@ interface DBVesselRepository : CrudRepository { @Query(value = "SELECT * FROM vessels WHERE cfr in (:cfr)", nativeQuery = true) fun findAllByInternalReferenceNumbers(cfr: List): List - + @Query( value = """ SELECT under_charter diff --git a/frontend/cypress/e2e/backoffice/control_objectives.spec.ts b/frontend/cypress/e2e/backoffice/control_objective_tables/actions.spec.ts similarity index 67% rename from frontend/cypress/e2e/backoffice/control_objectives.spec.ts rename to frontend/cypress/e2e/backoffice/control_objective_tables/actions.spec.ts index c461be4af4..ba33966f4c 100644 --- a/frontend/cypress/e2e/backoffice/control_objectives.spec.ts +++ b/frontend/cypress/e2e/backoffice/control_objective_tables/actions.spec.ts @@ -1,6 +1,6 @@ /* eslint-disable no-undef */ -context('Control objectives', () => { +context('BackOffice > Control Objective Tables > Actions', () => { beforeEach(() => { cy.login('superuser') const currentYear = new Date().getFullYear() @@ -11,39 +11,6 @@ context('Control objectives', () => { cy.wait('@controlObjectives') }) - it('Should render the objectives and navigate between years', () => { - // Then - cy.get('.rs-table-row').should('have.length', 67) - cy.get('[data-cy="control-objective-facade-title"]').should('have.length', 5) - cy.get('[data-cy="control-objective-facade-title"]').eq(0).contains('NORD ATLANTIQUE - MANCHE OUEST (NAMO)') - cy.get('[data-cy="control-objective-facade-title"]').eq(1).contains('MANCHE EST – MER DU NORD (MEMN)') - cy.get('[data-cy="control-objective-facade-title"]').eq(2).contains('SUD-ATLANTIQUE (SA)') - cy.get('[data-cy="control-objective-facade-title"]').eq(3).contains('Méditerranée (MED)') - cy.get('[data-cy="control-objective-facade-title"]').eq(4).contains('Corse (CORSE)') - - cy.get('.rs-table-cell-content').eq(9).contains('ATL01') - // We check the next line as the ATL01 segment was deleted from the segment table and has no segment name associated - cy.get('.rs-table-cell-content').eq(18).contains('Eel sea fisheries') - cy.get('.rs-table-cell-content').eq(11).children().should('have.value', '0') - cy.get('.rs-table-cell-content').eq(12).children().should('have.value', '20') - // We check the next line as the ATL01 segment was deleted from the segment table and has no impact risk factor associated - cy.get('.rs-table-cell-content').eq(21).children().contains('3.8') - cy.get('.rs-table-cell-content').eq(14).children().children().children().contains('1') - - const currentYear = new Date().getFullYear() - cy.get('*[data-cy^="control-objectives-year"]').contains(currentYear) - - cy.log('Check the FR_SCE control objectives of MEMN') - cy.get('[data-cy="row-68-targetNumberOfControlsAtPort"]').should('exist') - cy.get('[data-cy="row-68-targetNumberOfControlsAtSea"]').should('exist') - - cy.log('Navigate to previous year') - cy.get('*[data-cy^="control-objectives-year"]').click() - cy.get(`[data-key="${currentYear - 1}"] > .rs-picker-select-menu-item`).click() - cy.get('[data-cy="row-15-targetNumberOfControlsAtPort"]').should('exist') - cy.get('[data-cy="row-15-targetNumberOfControlsAtSea"]').should('exist') - }) - it('Should update the targetNumberOfControlsAtPort field on an objective', () => { // When cy.intercept('PUT', '/bff/v1/admin/control_objectives/78').as('updateObjective') @@ -163,22 +130,6 @@ context('Control objectives', () => { cy.get('.rs-table-row').should('have.length', 67) }) - it('Should permit to add a control objective year When the current year is not yet added', () => { - // Given - const currentYear = new Date().getFullYear() - const nextYear = currentYear + 1 - const now = new Date(nextYear, 3, 14).getTime() - - cy.clock(now) - cy.get('.rs-table-row').should('have.length', 67) - cy.get('*[data-cy^="control-objectives-year"]').contains(currentYear) - cy.get('*[data-cy^="control-objectives-year"]').click() - cy.get('.rs-picker-select-menu-item').should('have.length', 2) - - // Then - cy.get('*[data-cy="control-objectives-add-year"]').contains(nextYear) - }) - it('Should add the next control objective year', () => { // Given cy.get('.rs-table-row').should('have.length', 67) diff --git a/frontend/cypress/e2e/backoffice/control_objective_tables/behavior.spec.ts b/frontend/cypress/e2e/backoffice/control_objective_tables/behavior.spec.ts new file mode 100644 index 0000000000..ce32b05023 --- /dev/null +++ b/frontend/cypress/e2e/backoffice/control_objective_tables/behavior.spec.ts @@ -0,0 +1,28 @@ +/* eslint-disable no-undef */ + +context('BackOffice > Control Objective Tables > Behavior', () => { + beforeEach(() => { + const currentYear = new Date().getFullYear() + cy.intercept('GET', `/bff/v1/fleet_segments/${currentYear}`).as('fleetSegments') + cy.intercept('GET', `/bff/v1/admin/control_objectives/${currentYear}`).as('controlObjectives') + cy.visit('/backoffice/control_objectives') + cy.wait('@fleetSegments') + cy.wait('@controlObjectives') + }) + + it('Should permit to add a control objective year When the current year is not yet added', () => { + // Given + const currentYear = new Date().getFullYear() + const nextYear = currentYear + 1 + const now = new Date(nextYear, 3, 14).getTime() + + cy.clock(now) + cy.get('.rs-table-row').should('have.length', 67) + cy.get('*[data-cy^="control-objectives-year"]').contains(currentYear) + cy.get('*[data-cy^="control-objectives-year"]').click() + cy.get('.rs-picker-select-menu-item').should('have.length', 2) + + // Then + cy.get('*[data-cy="control-objectives-add-year"]').contains(nextYear) + }) +}) diff --git a/frontend/cypress/e2e/backoffice/control_objective_tables/table.spec.ts b/frontend/cypress/e2e/backoffice/control_objective_tables/table.spec.ts new file mode 100644 index 0000000000..77d69a4989 --- /dev/null +++ b/frontend/cypress/e2e/backoffice/control_objective_tables/table.spec.ts @@ -0,0 +1,45 @@ +/* eslint-disable no-undef */ + +context('BackOffice > Control Objective Tables > Table', () => { + beforeEach(() => { + const currentYear = new Date().getFullYear() + cy.intercept('GET', `/bff/v1/fleet_segments/${currentYear}`).as('fleetSegments') + cy.intercept('GET', `/bff/v1/admin/control_objectives/${currentYear}`).as('controlObjectives') + cy.visit('/backoffice/control_objectives') + cy.wait('@fleetSegments') + cy.wait('@controlObjectives') + }) + + it('Should render the objectives and navigate between years', () => { + // Then + cy.get('.rs-table-row').should('have.length', 67) + cy.get('[data-cy="control-objective-facade-title"]').should('have.length', 5) + cy.get('[data-cy="control-objective-facade-title"]').eq(0).contains('NORD ATLANTIQUE - MANCHE OUEST (NAMO)') + cy.get('[data-cy="control-objective-facade-title"]').eq(1).contains('MANCHE EST – MER DU NORD (MEMN)') + cy.get('[data-cy="control-objective-facade-title"]').eq(2).contains('SUD-ATLANTIQUE (SA)') + cy.get('[data-cy="control-objective-facade-title"]').eq(3).contains('Méditerranée (MED)') + cy.get('[data-cy="control-objective-facade-title"]').eq(4).contains('Corse (CORSE)') + + cy.get('.rs-table-cell-content').eq(9).contains('ATL01') + // We check the next line as the ATL01 segment was deleted from the segment table and has no segment name associated + cy.get('.rs-table-cell-content').eq(18).contains('Eel sea fisheries') + cy.get('.rs-table-cell-content').eq(11).children().should('have.value', '0') + cy.get('.rs-table-cell-content').eq(12).children().should('have.value', '20') + // We check the next line as the ATL01 segment was deleted from the segment table and has no impact risk factor associated + cy.get('.rs-table-cell-content').eq(21).children().contains('3.8') + cy.get('.rs-table-cell-content').eq(14).children().children().children().contains('1') + + const currentYear = new Date().getFullYear() + cy.get('*[data-cy^="control-objectives-year"]').contains(currentYear) + + cy.log('Check the FR_SCE control objectives of MEMN') + cy.get('[data-cy="row-68-targetNumberOfControlsAtPort"]').should('exist') + cy.get('[data-cy="row-68-targetNumberOfControlsAtSea"]').should('exist') + + cy.log('Navigate to previous year') + cy.get('*[data-cy^="control-objectives-year"]').click() + cy.get(`[data-key="${currentYear - 1}"] > .rs-picker-select-menu-item`).click() + cy.get('[data-cy="row-15-targetNumberOfControlsAtPort"]').should('exist') + cy.get('[data-cy="row-15-targetNumberOfControlsAtSea"]').should('exist') + }) +}) diff --git a/frontend/cypress/e2e/backoffice/fleet_segments.spec.ts b/frontend/cypress/e2e/backoffice/fleet_segment_table.spec.ts similarity index 99% rename from frontend/cypress/e2e/backoffice/fleet_segments.spec.ts rename to frontend/cypress/e2e/backoffice/fleet_segment_table.spec.ts index 0cfea7d0a3..dc9875327a 100644 --- a/frontend/cypress/e2e/backoffice/fleet_segments.spec.ts +++ b/frontend/cypress/e2e/backoffice/fleet_segment_table.spec.ts @@ -6,7 +6,7 @@ import utc from 'dayjs/plugin/utc' dayjs.extend(utc) const currentYear = dayjs().utc().year() -context('Fleet segments', () => { +context('BackOffice > Fleet Segments Table', () => { beforeEach(() => { cy.login('superuser') cy.intercept('GET', `/bff/v1/fleet_segments/${currentYear}`).as('fleetSegments') diff --git a/frontend/cypress/e2e/backoffice/__image_snapshots__/Update Regulation The geometry Should be displayed #0.png b/frontend/cypress/e2e/backoffice/regulation_form/__image_snapshots__/BackOffice Regulation Form Edition The geometry Should be displayed #0.png similarity index 100% rename from frontend/cypress/e2e/backoffice/__image_snapshots__/Update Regulation The geometry Should be displayed #0.png rename to frontend/cypress/e2e/backoffice/regulation_form/__image_snapshots__/BackOffice Regulation Form Edition The geometry Should be displayed #0.png diff --git a/frontend/cypress/e2e/backoffice/__image_snapshots__/Update Regulation The geometry Should be displayed #1.png b/frontend/cypress/e2e/backoffice/regulation_form/__image_snapshots__/BackOffice Regulation Form Edition The geometry Should be displayed #1.png similarity index 100% rename from frontend/cypress/e2e/backoffice/__image_snapshots__/Update Regulation The geometry Should be displayed #1.png rename to frontend/cypress/e2e/backoffice/regulation_form/__image_snapshots__/BackOffice Regulation Form Edition The geometry Should be displayed #1.png diff --git a/frontend/cypress/e2e/backoffice/new_regulation.spec.ts b/frontend/cypress/e2e/backoffice/regulation_form/creation.spec.ts similarity index 99% rename from frontend/cypress/e2e/backoffice/new_regulation.spec.ts rename to frontend/cypress/e2e/backoffice/regulation_form/creation.spec.ts index 76884dc531..a5b309e2ed 100644 --- a/frontend/cypress/e2e/backoffice/new_regulation.spec.ts +++ b/frontend/cypress/e2e/backoffice/regulation_form/creation.spec.ts @@ -1,6 +1,6 @@ /* eslint-disable no-undef */ -context('New Regulation', () => { +context('BackOffice > Regulation Form > Creation', () => { beforeEach(() => { cy.login('superuser') cy.visit('/backoffice/regulation/new') diff --git a/frontend/cypress/e2e/backoffice/update_regulation.spec.ts b/frontend/cypress/e2e/backoffice/regulation_form/edition.spec.ts similarity index 99% rename from frontend/cypress/e2e/backoffice/update_regulation.spec.ts rename to frontend/cypress/e2e/backoffice/regulation_form/edition.spec.ts index e549b1519d..431369d3f6 100644 --- a/frontend/cypress/e2e/backoffice/update_regulation.spec.ts +++ b/frontend/cypress/e2e/backoffice/regulation_form/edition.spec.ts @@ -1,7 +1,7 @@ /* eslint-disable no-undef */ -import { customDayjs } from '../utils/customDayjs' +import { customDayjs } from '../../utils/customDayjs' -context('Update Regulation', () => { +context('BackOffice > Regulation Form > Edition', () => { beforeEach(() => { cy.login('superuser') cy.visit('/backoffice/regulation') diff --git a/frontend/cypress/e2e/backoffice/regulation_table/behavior.spec.ts b/frontend/cypress/e2e/backoffice/regulation_table/behavior.spec.ts new file mode 100644 index 0000000000..31420240df --- /dev/null +++ b/frontend/cypress/e2e/backoffice/regulation_table/behavior.spec.ts @@ -0,0 +1,37 @@ +/* eslint-disable no-undef */ + +context('BackOffice > Regulation Table > Behavior', () => { + beforeEach(() => { + cy.visit('/backoffice/regulation') + cy.wait(200) + }) + + it('on mouse over layer name edit button appears', () => { + // Given + // listen Post request to /geoserver/wfs + cy.intercept('POST', '/geoserver/wfs', { hostname: 'localhost' }).as('postRegulation') + + cy.get('[data-cy="Reg. MEMN"]').eq(0).click() + cy.get('[title="Ouest Cotentin Bivalves"]').trigger('mouseover', { force: true }) + cy.get('[data-cy="regulatory-topic-edit"]').should('be.visible') + cy.get('[data-cy="regulatory-topic-edit"]').click({ force: true }) + cy.get('[data-cy="regulatory-topic-edit-input"]').should('exist') + cy.get('[data-cy="regulatory-topic-edit-input"]').should('not.be.disabled') + cy.get('[data-cy="regulatory-topic-edit-input"]').type(' - changed{enter}', { force: true }) + + // When + cy.get('[data-cy="regulatory-topic-edit-input"]').should('not.exist') + + cy.wait('@postRegulation').then(({ request, response }) => { + expect(request.body).contain('typeName="monitorfish:regulations_write"') + expect(request.body).contain('Ouest Cotentin Bivalves - changed') + expect(response && response.statusCode).equal(200) + }) + + // Then + cy.get('[data-cy="regulatory-layers-my-zones-topic"]').then(elements => { + expect(elements.eq(0)).contain('Ouest Cotentin Bivalves - changed') + expect(elements.eq(0).parent()).contain('1/1') + }) + }) +}) diff --git a/frontend/cypress/e2e/backoffice/regulatory_zone_list.spec.ts b/frontend/cypress/e2e/backoffice/regulation_table/table.spec.ts similarity index 56% rename from frontend/cypress/e2e/backoffice/regulatory_zone_list.spec.ts rename to frontend/cypress/e2e/backoffice/regulation_table/table.spec.ts index 6a19e5cb02..3ae4915da3 100644 --- a/frontend/cypress/e2e/backoffice/regulatory_zone_list.spec.ts +++ b/frontend/cypress/e2e/backoffice/regulation_table/table.spec.ts @@ -1,6 +1,6 @@ /* eslint-disable no-undef */ -context('Backoffice', () => { +context('BackOffice > Regulation Table > Table', () => { beforeEach(() => { cy.login('superuser') cy.visit('/backoffice/regulation') @@ -34,33 +34,4 @@ context('Backoffice', () => { cy.get('[data-cy="regulatory-layer-topic-row"]').eq(0).click({ force: true }) cy.get('[title="Poulpes Mayotte"]').should('exist') }) - - it('on mouse over layer name edit button appears', () => { - // Given - // listen Post request to /geoserver/wfs - cy.intercept('POST', '/geoserver/wfs', { hostname: 'localhost' }).as('postRegulation') - - cy.get('[data-cy="Reg. MEMN"]').eq(0).click() - cy.get('[title="Ouest Cotentin Bivalves"]').trigger('mouseover', { force: true }) - cy.get('[data-cy="regulatory-topic-edit"]').should('be.visible') - cy.get('[data-cy="regulatory-topic-edit"]').click({ force: true }) - cy.get('[data-cy="regulatory-topic-edit-input"]').should('exist') - cy.get('[data-cy="regulatory-topic-edit-input"]').should('not.be.disabled') - cy.get('[data-cy="regulatory-topic-edit-input"]').type(' - changed{enter}', { force: true }) - - // When - cy.get('[data-cy="regulatory-topic-edit-input"]').should('not.exist') - - cy.wait('@postRegulation').then(({ request, response }) => { - expect(request.body).contain('typeName="monitorfish:regulations_write"') - expect(request.body).contain('Ouest Cotentin Bivalves - changed') - expect(response && response.statusCode).equal(200) - }) - - // Then - cy.get('[data-cy="regulatory-layers-my-zones-topic"]').then(elements => { - expect(elements.eq(0)).contain('Ouest Cotentin Bivalves - changed') - expect(elements.eq(0).parent()).contain('1/1') - }) - }) }) From 18da5340bc33b62ead6356751d45f5aebae4ef7d Mon Sep 17 00:00:00 2001 From: Ivan Gabriele Date: Fri, 25 Oct 2024 17:18:06 +0200 Subject: [PATCH 37/59] Remove nonexistent prop from FleetSegmentSubscription type --- .../PriorNotification/PriorNotificationSubscriber.types.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/frontend/src/features/PriorNotification/PriorNotificationSubscriber.types.ts b/frontend/src/features/PriorNotification/PriorNotificationSubscriber.types.ts index d7cf1adeb5..f2cfacb720 100644 --- a/frontend/src/features/PriorNotification/PriorNotificationSubscriber.types.ts +++ b/frontend/src/features/PriorNotification/PriorNotificationSubscriber.types.ts @@ -21,7 +21,6 @@ export namespace PriorNotificationSubscriber { export type FleetSegmentSubscription = { controlUnitId: number - hasSubscribedToAllPriorNotifications: boolean segmentCode: string segmentName: string | undefined } From 76f3c06dcec73766a3427bd1c5fdf6b12acd9f7b Mon Sep 17 00:00:00 2001 From: Ivan Gabriele Date: Mon, 28 Oct 2024 10:14:57 +0100 Subject: [PATCH 38/59] Disable pno subscriber list filters during options fetching --- .../FilterBar.tsx | 46 +++++++++---------- 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/frontend/src/features/PriorNotification/components/PriorNotificationSubscriberTable/FilterBar.tsx b/frontend/src/features/PriorNotification/components/PriorNotificationSubscriberTable/FilterBar.tsx index 8e6b581f03..bf38f5ed06 100644 --- a/frontend/src/features/PriorNotification/components/PriorNotificationSubscriberTable/FilterBar.tsx +++ b/frontend/src/features/PriorNotification/components/PriorNotificationSubscriberTable/FilterBar.tsx @@ -47,31 +47,29 @@ export function FilterBar() { value={tableFilterValues.searchQuery} /> - {administrationsAsOptions && ( - - {portsAsOptions && ( - ) } From 5dc0322e1d5a2214dbb81ee95371dd8dfd70a9e5 Mon Sep 17 00:00:00 2001 From: Ivan Gabriele Date: Mon, 28 Oct 2024 10:15:26 +0100 Subject: [PATCH 39/59] Add e2e tests for pno subscriber list filters --- .../constants.ts | 100 + .../filter_bar.spec.ts | 42 + .../utils.ts | 13 + frontend/cypress/e2e/constants.ts | 36 + .../mappings/get-administrations.v1.json | 5940 ----------------- 5 files changed, 191 insertions(+), 5940 deletions(-) create mode 100644 frontend/cypress/e2e/backoffice/prior_notification_subscriber_table/constants.ts create mode 100644 frontend/cypress/e2e/backoffice/prior_notification_subscriber_table/filter_bar.spec.ts create mode 100644 frontend/cypress/e2e/backoffice/prior_notification_subscriber_table/utils.ts delete mode 100644 frontend/cypress/mappings/get-administrations.v1.json diff --git a/frontend/cypress/e2e/backoffice/prior_notification_subscriber_table/constants.ts b/frontend/cypress/e2e/backoffice/prior_notification_subscriber_table/constants.ts new file mode 100644 index 0000000000..3b82a30a36 --- /dev/null +++ b/frontend/cypress/e2e/backoffice/prior_notification_subscriber_table/constants.ts @@ -0,0 +1,100 @@ +import type { PriorNotificationSubscriber } from '@features/PriorNotification/PriorNotificationSubscriber.types' + +export const FAKE_PRIOR_NOTIFICATION_SUBSCRIBERS: PriorNotificationSubscriber.Subscriber[] = [ + { + controlUnit: { + administration: { + id: 101, + name: 'Administration 1' + }, + id: 1, + name: 'Unité 1' + }, + fleetSegmentSubscriptions: [ + { + controlUnitId: 1, + segmentCode: 'SEG001', + segmentName: 'Segment 1' + }, + { + controlUnitId: 1, + segmentCode: 'SEG002', + segmentName: 'Segment 2' + }, + { + controlUnitId: 1, + segmentCode: 'SEG003', + segmentName: 'Segment 3' + }, + { + controlUnitId: 1, + segmentCode: 'SEG004', + segmentName: undefined + } + ], + portSubscriptions: [ + { + controlUnitId: 1, + hasSubscribedToAllPriorNotifications: false, + portLocode: 'FRABC', + portName: 'Port Français' + }, + { + controlUnitId: 1, + hasSubscribedToAllPriorNotifications: true, + portLocode: 'GBDEF', + portName: 'Port Anglais' + }, + { + controlUnitId: 1, + hasSubscribedToAllPriorNotifications: false, + portLocode: 'ESGHI', + portName: 'Port Espagnol' + }, + { + controlUnitId: 1, + hasSubscribedToAllPriorNotifications: false, + portLocode: 'ZZJKL', + portName: undefined + } + ], + vesselSubscriptions: [ + { + controlUnitId: 1, + vesselCallSign: 'CALLSIGN001', + vesselCfr: 'CFR001', + vesselExternalMarking: 'EXT001', + vesselId: 100001, + vesselMmsi: 'MMSI001', + vesselName: 'Navire 1' + }, + { + controlUnitId: 1, + vesselCallSign: 'CALLSIGN002', + vesselCfr: 'CFR002', + vesselExternalMarking: 'EXT002', + vesselId: 100002, + vesselMmsi: 'MMSI002', + vesselName: 'Navire 2' + }, + { + controlUnitId: 1, + vesselCallSign: 'CALLSIGN003', + vesselCfr: 'CFR003', + vesselExternalMarking: 'EXT003', + vesselId: 100003, + vesselMmsi: 'MMSI003', + vesselName: 'Navire 3' + }, + { + controlUnitId: 1, + vesselCallSign: undefined, + vesselCfr: undefined, + vesselExternalMarking: undefined, + vesselId: 100004, + vesselMmsi: undefined, + vesselName: undefined + } + ] + } +] diff --git a/frontend/cypress/e2e/backoffice/prior_notification_subscriber_table/filter_bar.spec.ts b/frontend/cypress/e2e/backoffice/prior_notification_subscriber_table/filter_bar.spec.ts new file mode 100644 index 0000000000..eda030b9b6 --- /dev/null +++ b/frontend/cypress/e2e/backoffice/prior_notification_subscriber_table/filter_bar.spec.ts @@ -0,0 +1,42 @@ +import { openBackOfficePriorNotificationSubscriberList } from './utils' + +context('BackOffice > Prior Notification Table > Filter Bar', () => { + beforeEach(() => { + openBackOfficePriorNotificationSubscriberList() + + cy.get('[name="administrationId').should('not.be.disabled') + cy.get('[name="portLocode').should('not.be.disabled') + + cy.wait(1000) + }) + + it('Should filter subscribers by search query', () => { + cy.intercept('GET', '/bff/v1/prior_notification_subscribers?*searchQuery=abc*').as( + 'getPriorNotificationSubscribers' + ) + + cy.fill('Rechercher...', 'abc') + + cy.wait('@getPriorNotificationSubscribers') + }) + + it('Should filter subscribers by administration', () => { + cy.intercept('GET', '/bff/v1/prior_notification_subscribers?*administrationId=1*').as( + 'getPriorNotificationSubscribers' + ) + + cy.fill('Administration', 'Administration 1') + + cy.wait('@getPriorNotificationSubscribers') + }) + + it('Should filter subscribers by port', () => { + cy.intercept('GET', '/bff/v1/prior_notification_subscribers?*portLocode=FRNCE*').as( + 'getPriorNotificationSubscribers' + ) + + cy.fill('Port de diffusion', 'Nice') + + cy.wait('@getPriorNotificationSubscribers') + }) +}) diff --git a/frontend/cypress/e2e/backoffice/prior_notification_subscriber_table/utils.ts b/frontend/cypress/e2e/backoffice/prior_notification_subscriber_table/utils.ts new file mode 100644 index 0000000000..9d066d345c --- /dev/null +++ b/frontend/cypress/e2e/backoffice/prior_notification_subscriber_table/utils.ts @@ -0,0 +1,13 @@ +import { FAKE_PRIOR_NOTIFICATION_SUBSCRIBERS } from './constants' +import { FAKE_ADMINISTRATIONS } from '../../constants' + +export const openBackOfficePriorNotificationSubscriberList = () => { + cy.intercept( + '/bff/v1/prior_notification_subscribers?sortColumn=CONTROL_UNIT_NAME&sortDirection=ASC', + FAKE_PRIOR_NOTIFICATION_SUBSCRIBERS + ).as('getPriorNotificationSubscribers') + cy.intercept('http://localhost:9880/api/v1/administrations', FAKE_ADMINISTRATIONS).as('getAdministrations') + + cy.visit('/backoffice/prior_notification_subscribers') + cy.wait('@getPriorNotificationSubscribers') +} diff --git a/frontend/cypress/e2e/constants.ts b/frontend/cypress/e2e/constants.ts index 01b7feb777..4229582bbe 100644 --- a/frontend/cypress/e2e/constants.ts +++ b/frontend/cypress/e2e/constants.ts @@ -1,3 +1,5 @@ +import { type Administration } from '@mtes-mct/monitor-ui' + export const FAKE_API_POST_RESPONSE = { body: {}, statusCode: 201 @@ -17,3 +19,37 @@ export const FAKE_MISSION_WITHOUT_EXTERNAL_ACTIONS = { body: { canDelete: true, sources: [] }, statusCode: 200 } + +export const FAKE_ADMINISTRATIONS: Administration.Administration[] = [ + { + controlUnitIds: [1], + controlUnits: [ + { + administrationId: 101, + areaNote: undefined, + departmentAreaInseeCode: undefined, + id: 1, + isArchived: false, + name: 'Unité 1', + termsNote: undefined + } + ], + id: 101, + isArchived: false, + name: 'Administration 1' + }, + { + controlUnitIds: [], + controlUnits: [], + id: 102, + isArchived: false, + name: 'Administration 2' + }, + { + controlUnitIds: [], + controlUnits: [], + id: 103, + isArchived: false, + name: 'Administration 3' + } +] diff --git a/frontend/cypress/mappings/get-administrations.v1.json b/frontend/cypress/mappings/get-administrations.v1.json deleted file mode 100644 index ee492b0014..0000000000 --- a/frontend/cypress/mappings/get-administrations.v1.json +++ /dev/null @@ -1,5940 +0,0 @@ -{ - "request": { - "method": "GET", - "url": "/api/v1/administrations" - }, - "response": { - "status": 200, - "headers": { - "Content-Type": "application/json", - "Access-Control-Allow-Origin": "*", - "Access-Control-Allow-Methods": "*" - }, - "jsonBody": [ - { - "id": 1002, - "controlUnitIds": [ - 1178, - 1209, - 1240, - 1253, - 1317, - 1179, - 1231, - 1245, - 1378, - 1177, - 1319 - ], - "controlUnits": [ - { - "id": 1178, - "areaNote": null, - "administrationId": 1002, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Ofb - 134 Ideal (historique)", - "termsNote": null - }, - { - "id": 1209, - "areaNote": null, - "administrationId": 1002, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Ofb 128 - Sotalie (historique)", - "termsNote": null - }, - { - "id": 1240, - "areaNote": null, - "administrationId": 1002, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Afb Sd 29 (historique)", - "termsNote": null - }, - { - "id": 1253, - "areaNote": null, - "administrationId": 1002, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Ofb La Desiradienne (historique)", - "termsNote": null - }, - { - "id": 1317, - "areaNote": null, - "administrationId": 1002, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Afb Sd 50 (historique)", - "termsNote": null - }, - { - "id": 1179, - "areaNote": null, - "administrationId": 1002, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Afb Guyane (historique)", - "termsNote": null - }, - { - "id": 1231, - "areaNote": null, - "administrationId": 1002, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Ofb - 114 - Kereon Ii (historique)", - "termsNote": null - }, - { - "id": 1245, - "areaNote": null, - "administrationId": 1002, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Afb Sd 56 (historique)", - "termsNote": null - }, - { - "id": 1378, - "areaNote": null, - "administrationId": 1002, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Afb Sd 35 (historique)", - "termsNote": null - }, - { - "id": 1177, - "areaNote": null, - "administrationId": 1002, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Ofb - 135 Clarissa (historique)", - "termsNote": null - }, - { - "id": 1319, - "areaNote": null, - "administrationId": 1002, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Afb Sd 44 (historique)", - "termsNote": null - } - ], - "isArchived": true, - "name": "AFB" - }, - { - "id": 1005, - "controlUnitIds": [ - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 1000, - 1022, - 1061, - 10388, - 10392, - 115, - 116, - 117, - 118, - 10469, - 10470, - 10477, - 10499, - 10503, - 1264, - 1267, - 1269, - 10000, - 10002, - 10003, - 10005, - 10011, - 1272, - 1273, - 1274, - 1275, - 1276, - 1277, - 1278, - 1279, - 1280, - 1281, - 1282, - 10039, - 1283, - 1284, - 1285, - 1286, - 1287, - 10050, - 1288, - 1289, - 10056, - 1290, - 1291, - 1292, - 1293, - 10062, - 10066, - 1294, - 1295, - 1296, - 1297, - 10081, - 1298, - 1299, - 1300, - 1301, - 1302, - 10090, - 10092, - 10097, - 1303, - 1304, - 1305, - 1306, - 1307, - 1308, - 10115, - 10119, - 1309, - 1310, - 1311, - 10124, - 1312, - 1313, - 10138, - 10139, - 1348, - 10157, - 10162, - 10166, - 10171, - 1349, - 1350, - 10176, - 1445, - 10194, - 10195, - 10204, - 10205, - 10210, - 10211, - 10225, - 10231, - 1462, - 10244, - 10251, - 10253, - 10255, - 10272, - 10279, - 10284, - 10287, - 10290, - 10300, - 10301, - 10303, - 10310, - 10318, - 10323, - 10324, - 10326, - 10337, - 10344, - 10346, - 10349, - 10351, - 10288, - 10357, - 10364, - 10394, - 10396, - 10417, - 10420, - 10423, - 10424, - 10428, - 10438, - 10448, - 10449, - 10452, - 10457, - 10459, - 10466, - 1051, - 8, - 9, - 10, - 1430, - 1433, - 1434, - 1473, - 1481, - 1524, - 1374, - 1431, - 1432, - 1435, - 1436, - 1437, - 1438, - 1439, - 1440, - 1441, - 1442, - 1443, - 1444, - 1520, - 1522, - 1562, - 1563, - 1564, - 1568, - 1610, - 1611, - 1622, - 1636, - 1633, - 1574, - 1618 - ], - "controlUnits": [ - { - "id": 11, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Ulam 29 (historique)", - "termsNote": null - }, - { - "id": 12, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Ulam 33 (historique)", - "termsNote": null - }, - { - "id": 13, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Ulam 35 (historique)", - "termsNote": null - }, - { - "id": 14, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Ulam 44 (historique)", - "termsNote": null - }, - { - "id": 15, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Ulam 50 (historique)", - "termsNote": null - }, - { - "id": 16, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Ulam 56 (historique)", - "termsNote": null - }, - { - "id": 17, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Ulam 62/80 (historique)", - "termsNote": null - }, - { - "id": 18, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Ulam 64/40 (historique)", - "termsNote": null - }, - { - "id": 19, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Ulam 85 (historique)", - "termsNote": null - }, - { - "id": 1000, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Ulam 34/30 (historique)", - "termsNote": null - }, - { - "id": 1022, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Ulam 2b (historique)", - "termsNote": null - }, - { - "id": 1061, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Ulam 06 (historique)", - "termsNote": null - }, - { - "id": 10388, - "areaNote": "Var (83)", - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "Cultures marines 83", - "termsNote": null - }, - { - "id": 10392, - "areaNote": "Rance et baie du Mont-Saint-Michel", - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "Cultures marines 35", - "termsNote": null - }, - { - "id": 115, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Ulam 13 (historique)", - "termsNote": null - }, - { - "id": 116, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Ulam 2a (historique)", - "termsNote": null - }, - { - "id": 117, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Ulam 66/11 (historique)", - "termsNote": null - }, - { - "id": 118, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Ulam 83 (historique)", - "termsNote": null - }, - { - "id": 10469, - "areaNote": "Seine-Maritime (76)", - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "Police de l'eau 76", - "termsNote": null - }, - { - "id": 10470, - "areaNote": "Manche (50)", - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "Police de l'eau 50", - "termsNote": null - }, - { - "id": 10477, - "areaNote": "Alpes-Maritimes (06)", - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "DPM 06", - "termsNote": null - }, - { - "id": 10499, - "areaNote": "Morbihan (56)", - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "Cultures marines 56", - "termsNote": null - }, - { - "id": 10503, - "areaNote": "Var (83)", - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "DPM 83", - "termsNote": null - }, - { - "id": 1264, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Cultures Marines - Ddtm 62 (historique)", - "termsNote": null - }, - { - "id": 1267, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Cultures Marines - Ddtm 76 (historique)", - "termsNote": null - }, - { - "id": 1269, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Cultures Marines - Ddtm 80 (historique)", - "termsNote": null - }, - { - "id": 10000, - "areaNote": "Pyrénées-Atlantiques (64) – Landes (40)", - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "Cultures marines 64/40", - "termsNote": null - }, - { - "id": 10002, - "areaNote": "Nord (59)", - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "DPM 59", - "termsNote": null - }, - { - "id": 10003, - "areaNote": "Pas-de-Calais (62)", - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "Police de l'eau 62", - "termsNote": null - }, - { - "id": 10005, - "areaNote": "Gironde (33)", - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "Police de l'eau 33", - "termsNote": null - }, - { - "id": 10011, - "areaNote": "Charente-Maritime (17)", - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "Police de l'eau 17", - "termsNote": null - }, - { - "id": 1272, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Cultures Marines - Ddtm 50 (historique)", - "termsNote": null - }, - { - "id": 1273, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Cultures Marines - Ddtm 14 (historique)", - "termsNote": null - }, - { - "id": 1274, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Cultures Marines - Ddtm 35 (historique)", - "termsNote": null - }, - { - "id": 1275, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Cultures Marines - Ddtm 22 (historique)", - "termsNote": null - }, - { - "id": 1276, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Cultures Marines - Ddtm 29 (historique)", - "termsNote": null - }, - { - "id": 1277, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Cultures Marines - Ddtm 56 (historique)", - "termsNote": null - }, - { - "id": 1278, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Cultures Marines - Ddtm 44 (historique)", - "termsNote": null - }, - { - "id": 1279, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Cultures Marines - Ddtm 85 (historique)", - "termsNote": null - }, - { - "id": 1280, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Cultures Marines - Ddtm 66 (historique)", - "termsNote": null - }, - { - "id": 1281, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Cultures Marines - Ddtm 11 (historique)", - "termsNote": null - }, - { - "id": 1282, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Cultures Marines - Ddtm 34 (historique)", - "termsNote": null - }, - { - "id": 10039, - "areaNote": "Bouches-du-Rhône (13)", - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "ULAM 13", - "termsNote": null - }, - { - "id": 1283, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Cultures Marines - Ddtm 30 (historique)", - "termsNote": null - }, - { - "id": 1284, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Cultures Marines - Ddtm 13 (historique)", - "termsNote": null - }, - { - "id": 1285, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Cultures Marines - Ddtm 83 (historique)", - "termsNote": null - }, - { - "id": 1286, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Cultures Marines - Ddtm 06 (historique)", - "termsNote": null - }, - { - "id": 1287, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Cultures Marines - Ddtm 2b (historique)", - "termsNote": null - }, - { - "id": 10050, - "areaNote": "Nord (59)", - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "ULAM 59", - "termsNote": null - }, - { - "id": 1288, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Cultures Marines - Ddtm 2a (historique)", - "termsNote": null - }, - { - "id": 1289, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Dpm - Ddtm 35 (historique)", - "termsNote": null - }, - { - "id": 10056, - "areaNote": "Vendée (85)", - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "Cultures marines 85", - "termsNote": null - }, - { - "id": 1290, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Dml - Ddtm 59 (historique)", - "termsNote": null - }, - { - "id": 1291, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Dpm - Ddtm 62 (historique)", - "termsNote": null - }, - { - "id": 1292, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Dpm - Ddtm 80 (historique)", - "termsNote": null - }, - { - "id": 1293, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Dpm - Ddtm 76 (historique)", - "termsNote": null - }, - { - "id": 10062, - "areaNote": "Finistère (29)", - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "Cultures marines 29", - "termsNote": null - }, - { - "id": 10066, - "areaNote": "Morbihan (56)", - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "DPM 56", - "termsNote": null - }, - { - "id": 1294, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Dpm - Ddtm 14 (historique)", - "termsNote": null - }, - { - "id": 1295, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Dpm - Ddtm 50 (historique)", - "termsNote": null - }, - { - "id": 1296, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Dpm - Ddtm 22 (historique)", - "termsNote": null - }, - { - "id": 1297, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Dpm - Ddtm 29 (historique)", - "termsNote": null - }, - { - "id": 10081, - "areaNote": "Manche (50)", - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "Cultures marines 50", - "termsNote": null - }, - { - "id": 1298, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Dpm - Ddtm 56 (historique)", - "termsNote": null - }, - { - "id": 1299, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Dpm - Ddtm 44 (historique)", - "termsNote": null - }, - { - "id": 1300, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Dpm - Ddtm 85 (historique)", - "termsNote": null - }, - { - "id": 1301, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Dpm - Ddtm 17 (historique)", - "termsNote": null - }, - { - "id": 1302, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Dpm - Ddtm 33 (historique)", - "termsNote": null - }, - { - "id": 10090, - "areaNote": "Var (83)", - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "Police de l'eau 83", - "termsNote": null - }, - { - "id": 10092, - "areaNote": "Calvados (14)", - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "Police de l'eau 14", - "termsNote": null - }, - { - "id": 10097, - "areaNote": "Côtes-d’Armor (22)", - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "DPM 22", - "termsNote": null - }, - { - "id": 1303, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Dpm - Ddtm 40 (historique)", - "termsNote": null - }, - { - "id": 1304, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Dpm - Ddtm 64 (historique)", - "termsNote": null - }, - { - "id": 1305, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Dpm - Ddtm 66 (historique)", - "termsNote": null - }, - { - "id": 1306, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Dpm - Ddtm 11 (historique)", - "termsNote": null - }, - { - "id": 1307, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Dpm - Ddtm 34 (historique)", - "termsNote": null - }, - { - "id": 1308, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Dpm - Ddtm 30 (historique)", - "termsNote": null - }, - { - "id": 10115, - "areaNote": "Bouches-du-Rhône (13)", - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "Police de l'eau 13", - "termsNote": null - }, - { - "id": 10119, - "areaNote": "Gironde (33) hors Grand Port Maritime de Bordeaux", - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "DPM 33", - "termsNote": null - }, - { - "id": 1309, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Dpm - Ddtm 13 (historique)", - "termsNote": null - }, - { - "id": 1310, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Dpm - Ddtm 83 (historique)", - "termsNote": null - }, - { - "id": 1311, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Dpm - Ddtm 06 (historique)", - "termsNote": null - }, - { - "id": 10124, - "areaNote": "Charente-Maritime (17)", - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "Cultures marines 17", - "termsNote": null - }, - { - "id": 1312, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Dpm - Ddtm 2a (historique)", - "termsNote": null - }, - { - "id": 1313, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Dpm - Ddtm 2b (historique)", - "termsNote": null - }, - { - "id": 10138, - "areaNote": "Vendée (85)", - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "DPM 85", - "termsNote": null - }, - { - "id": 10139, - "areaNote": "Loire-Atlantique (44)", - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "Cultures marines 44", - "termsNote": null - }, - { - "id": 1348, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Cultures Marines - Ddtm 17 (historique)", - "termsNote": null - }, - { - "id": 10157, - "areaNote": "Morbihan (56)", - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "Police de l'eau 56", - "termsNote": null - }, - { - "id": 10162, - "areaNote": "Hérault (34)", - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "DPM 34", - "termsNote": null - }, - { - "id": 10166, - "areaNote": "Var (83)", - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "ULAM 83", - "termsNote": null - }, - { - "id": 10171, - "areaNote": "Vendée (85)", - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "ULAM 85", - "termsNote": null - }, - { - "id": 1349, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Cultures Marines - Ddtm 33 (historique)", - "termsNote": null - }, - { - "id": 1350, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Cultures Marines - Ddtm 40 (historique)", - "termsNote": null - }, - { - "id": 10176, - "areaNote": "Ile-et-Vilaine (35)", - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "ULAM 35", - "termsNote": null - }, - { - "id": 1445, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Ulam 35 [2] (historique)", - "termsNote": null - }, - { - "id": 10194, - "areaNote": "Alpes-Maritimes (06)", - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "ULAM 06", - "termsNote": null - }, - { - "id": 10195, - "areaNote": "Hérault (Etang de Thau et filières en mer de Sète et de Frontignan)", - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "Cultures marines 34/30", - "termsNote": null - }, - { - "id": 10204, - "areaNote": "Côtes-d’Armor (22)", - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "ULAM 22", - "termsNote": null - }, - { - "id": 10205, - "areaNote": "Aude (11)", - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "DPM 11", - "termsNote": null - }, - { - "id": 10210, - "areaNote": "Manche (50)", - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "ULAM 50", - "termsNote": null - }, - { - "id": 10211, - "areaNote": "Nord (59)", - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "Police de l'eau 59", - "termsNote": null - }, - { - "id": 10225, - "areaNote": "Gironde (33)", - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "ULAM 33", - "termsNote": null - }, - { - "id": 10231, - "areaNote": "Pyrénées-Atlantiques (64)", - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "Police de l'eau 64", - "termsNote": null - }, - { - "id": 1462, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Police De L'Eau - Ddtm50 (historique)", - "termsNote": null - }, - { - "id": 10244, - "areaNote": "Corse-du-Sud (2A)", - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "Police de l'eau 2A", - "termsNote": null - }, - { - "id": 10251, - "areaNote": "Finistère (29)", - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "Police de l'eau 29", - "termsNote": null - }, - { - "id": 10253, - "areaNote": "Ille-et-Vilaine (35)", - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "Police de l'eau 35", - "termsNote": null - }, - { - "id": 10255, - "areaNote": "Charente-maritime (17), Nord Gironde et Sud Vendée", - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "ULAM 17", - "termsNote": null - }, - { - "id": 10272, - "areaNote": "Calvados (14)", - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "DPM 14", - "termsNote": null - }, - { - "id": 10279, - "areaNote": "Charente-Maritime (17)", - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "DPM 17", - "termsNote": null - }, - { - "id": 10284, - "areaNote": "Somme (80)", - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "DPM 80", - "termsNote": null - }, - { - "id": 10287, - "areaNote": "Gard (30)", - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "DPM 30", - "termsNote": null - }, - { - "id": 10290, - "areaNote": "Vendée (85)", - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "Police de l'eau 85", - "termsNote": null - }, - { - "id": 10300, - "areaNote": "Loire-Atlantique (44)", - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "DPM 44", - "termsNote": null - }, - { - "id": 10301, - "areaNote": "Gironde (33)", - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "Cultures marines 33", - "termsNote": null - }, - { - "id": 10303, - "areaNote": "Pyrénées-Orientales (66) et l'Aude (11)", - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "ULAM 66/11", - "termsNote": null - }, - { - "id": 10310, - "areaNote": "Calvados (14)", - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "Cultures marines 14", - "termsNote": null - }, - { - "id": 10318, - "areaNote": "Pas-de-Calais (62) et Somme (80)", - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "ULAM 62/80", - "termsNote": null - }, - { - "id": 10323, - "areaNote": "Seine-Maritime (76)", - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "DPM 76", - "termsNote": null - }, - { - "id": 10324, - "areaNote": "Manche (50)", - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "DPM 50", - "termsNote": null - }, - { - "id": 10326, - "areaNote": "Pyrénées-Orientales (66)", - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "DPM 66", - "termsNote": null - }, - { - "id": 10337, - "areaNote": "Finistère Nord (Locquirec à Argol)", - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "DPM (Brest – Morlaix) 29", - "termsNote": null - }, - { - "id": 10344, - "areaNote": "Finistère Sud", - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "DPM (Gulvinec – Concarneau – Douarnenez ) 29", - "termsNote": null - }, - { - "id": 10346, - "areaNote": "Côtes-d’Armor (22)", - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "Police de l'eau 22", - "termsNote": null - }, - { - "id": 10349, - "areaNote": "Loire-Atlantique (44)", - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "Police de l'eau 44", - "termsNote": null - }, - { - "id": 10351, - "areaNote": "Seine-Maritime (76)", - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "Cultures marines 76", - "termsNote": null - }, - { - "id": 10288, - "areaNote": "Finistère sud", - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "ULAM 29 Douarnenez", - "termsNote": null - }, - { - "id": 10357, - "areaNote": "Ile-et-Vilaine (35) et Rance", - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "DPM 35", - "termsNote": null - }, - { - "id": 10364, - "areaNote": "Pyrénées-Atlantiques (64) et Landes (40)", - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "ULAM 64/40", - "termsNote": null - }, - { - "id": 10394, - "areaNote": "Pas-de-Calais (62)", - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "DPM 62", - "termsNote": null - }, - { - "id": 10396, - "areaNote": "Pyrénées-Atlantiques (64) – Landes (40)", - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "DPM 64/40", - "termsNote": null - }, - { - "id": 10417, - "areaNote": "Bouches-du-Rhône (13)", - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "DPM 13", - "termsNote": null - }, - { - "id": 10420, - "areaNote": "Hérault (34) et Gard (30)", - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "ULAM 34/30", - "termsNote": null - }, - { - "id": 10423, - "areaNote": "Seine-Maritime (76)", - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "ULAM 76", - "termsNote": null - }, - { - "id": 10424, - "areaNote": "Alpes-Maritimes (06)", - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "Police de l'eau 06", - "termsNote": null - }, - { - "id": 10428, - "areaNote": "Loire-Atlantique (44)", - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "ULAM 44", - "termsNote": null - }, - { - "id": 10438, - "areaNote": "Somme maritime (80)", - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "Police de l'eau 80", - "termsNote": null - }, - { - "id": 10448, - "areaNote": "Nord Bretagne – Côtes d’Armor (22)", - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "Cultures marines 22", - "termsNote": null - }, - { - "id": 10449, - "areaNote": "Morbihan (56)", - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "ULAM 56 ", - "termsNote": null - }, - { - "id": 10452, - "areaNote": "Calvados (14)", - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "ULAM 14", - "termsNote": null - }, - { - "id": 10457, - "areaNote": "Finistère nord", - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "ULAM 29 Brest", - "termsNote": null - }, - { - "id": 10459, - "areaNote": "Haute-Corse (2B)", - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "Police de l'eau 2B", - "termsNote": null - }, - { - "id": 10466, - "areaNote": "Pas-de-Calais (62) et Somme (80)", - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "Cultures marines 62/80", - "termsNote": null - }, - { - "id": 1051, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Ulam 76 (historique)", - "termsNote": null - }, - { - "id": 8, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Ulam 14 (historique)", - "termsNote": null - }, - { - "id": 9, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Ulam 17 (historique)", - "termsNote": null - }, - { - "id": 10, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Ulam 22 (historique)", - "termsNote": null - }, - { - "id": 1430, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Police De L'Eau - Ddtm56 (historique)", - "termsNote": null - }, - { - "id": 1433, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Police De L'Eau - Ddtm44 (historique)", - "termsNote": null - }, - { - "id": 1434, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Police De L'Eau - Ddtm22 (historique)", - "termsNote": null - }, - { - "id": 1473, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Cellule Ops Bureau Environnement Marin Ddtm83 (historique)", - "termsNote": null - }, - { - "id": 1481, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Saiml Ddtm 59 (historique)", - "termsNote": null - }, - { - "id": 1524, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Gelm 44 (historique)", - "termsNote": null - }, - { - "id": 1374, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Plam Morlaix (historique)", - "termsNote": null - }, - { - "id": 1431, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Police De L'Eau - Ddtm29 (historique)", - "termsNote": null - }, - { - "id": 1432, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Police De L'Eau - Ddtm35 (historique)", - "termsNote": null - }, - { - "id": 1435, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Police De L'Eau - Ddtm85 (historique)", - "termsNote": null - }, - { - "id": 1436, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Police De L'Eau - Ddtm66 (historique)", - "termsNote": null - }, - { - "id": 1437, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Police De L'Eau - Ddtm11 (historique)", - "termsNote": null - }, - { - "id": 1438, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Police De L'Eau - Ddtm34 (historique)", - "termsNote": null - }, - { - "id": 1439, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Police De L'Eau - Ddtm30 (historique)", - "termsNote": null - }, - { - "id": 1440, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Police De L'Eau - Ddtm13 (historique)", - "termsNote": null - }, - { - "id": 1441, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Police De L'Eau - Ddtm83 (historique)", - "termsNote": null - }, - { - "id": 1442, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Police De L'Eau - Ddtm06 (historique)", - "termsNote": null - }, - { - "id": 1443, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Police De L'Eau - Ddtm2b (historique)", - "termsNote": null - }, - { - "id": 1444, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Police De L'Eau - Ddtm2a (historique)", - "termsNote": null - }, - { - "id": 1520, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Service Mer Et Littoral 50 (historique)", - "termsNote": null - }, - { - "id": 1522, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Samel 56 (historique)", - "termsNote": null - }, - { - "id": 1562, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Service Mer Et Littoral 76 (historique)", - "termsNote": null - }, - { - "id": 1563, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Police De L'Eau 76 (historique)", - "termsNote": null - }, - { - "id": 1564, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Saml 62 (historique)", - "termsNote": null - }, - { - "id": 1568, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Dml 85 (historique)", - "termsNote": null - }, - { - "id": 1610, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Dml 2a (historique)", - "termsNote": null - }, - { - "id": 1611, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Service Mer Et Littoral 33 (historique)", - "termsNote": null - }, - { - "id": 1622, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Plam Guilvinec - Concarneau (historique)", - "termsNote": null - }, - { - "id": 1636, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Dt Sud 50 (historique)", - "termsNote": null - }, - { - "id": 1633, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Dml Corse (historique)", - "termsNote": null - }, - { - "id": 1574, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Dml 35 (historique)", - "termsNote": null - }, - { - "id": 1618, - "areaNote": null, - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Dml Haute-Corse (historique)", - "termsNote": null - } - ], - "isArchived": false, - "name": "DDTM" - }, - { - "id": 1009, - "controlUnitIds": [ - 10227, - 10275, - 1084, - 1099, - 119, - 1090, - 1210, - 10483, - 10075, - 10169, - 10172, - 10183, - 10222, - 1494, - 10265, - 1164, - 10298, - 10327, - 1213, - 10358, - 10365, - 1370, - 1385, - 10456, - 10080, - 10121, - 10141, - 10345, - 10534, - 10404, - 2, - 3, - 4, - 1482, - 1515, - 1211, - 1214, - 1509, - 1556, - 1557, - 1558, - 1559, - 1567, - 1603, - 1612, - 1586, - 1602, - 1647, - 1585 - ], - "controlUnits": [ - { - "id": 10227, - "areaNote": null, - "administrationId": 1009, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "CSN – Centres de sécurité des navires", - "termsNote": null - }, - { - "id": 10275, - "areaNote": null, - "administrationId": 1009, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "Cellule SESAME (enquête DIRM NAMO)", - "termsNote": null - }, - { - "id": 1084, - "areaNote": null, - "administrationId": 1009, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Ulam 972 (historique)", - "termsNote": null - }, - { - "id": 1099, - "areaNote": null, - "administrationId": 1009, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Ulam 971 (historique)", - "termsNote": null - }, - { - "id": 119, - "areaNote": null, - "administrationId": 1009, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Vrs Mauve (historique)", - "termsNote": null - }, - { - "id": 1090, - "areaNote": null, - "administrationId": 1009, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Ulam 972 [2] (historique)", - "termsNote": null - }, - { - "id": 1210, - "areaNote": null, - "administrationId": 1009, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Thasard (historique)", - "termsNote": null - }, - { - "id": 10483, - "areaNote": "Sud Bretagne à la frontière espagnole", - "administrationId": 1009, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "Cross Etel", - "termsNote": null - }, - { - "id": 10075, - "areaNote": "Martinique (972)", - "administrationId": 1009, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "Cultures marines 972 Martinique", - "termsNote": null - }, - { - "id": 10169, - "areaNote": "Archipel Guadeloupéen (971)", - "administrationId": 1009, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "ULAM 971 Guadeloupe", - "termsNote": null - }, - { - "id": 10172, - "areaNote": "Hauts-de-France", - "administrationId": 1009, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "Cross Jobourg", - "termsNote": null - }, - { - "id": 10183, - "areaNote": "La Réunion (974)", - "administrationId": 1009, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "ULAM 974 Réunion", - "termsNote": null - }, - { - "id": 10222, - "areaNote": "Nord Bretagne", - "administrationId": 1009, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "Cross Corsen", - "termsNote": null - }, - { - "id": 1494, - "areaNote": null, - "administrationId": 1009, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Osiris Ii (historique)", - "termsNote": null - }, - { - "id": 10265, - "areaNote": "Guyane (973)", - "administrationId": 1009, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "ULAM 973 Guyane", - "termsNote": null - }, - { - "id": 1164, - "areaNote": null, - "administrationId": 1009, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Pm 298 Campeche (historique)", - "termsNote": null - }, - { - "id": 10298, - "areaNote": "Normandie", - "administrationId": 1009, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "Cross Gris Nez", - "termsNote": null - }, - { - "id": 10327, - "areaNote": "Martinique (972)", - "administrationId": 1009, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "ULAM 972 Martinique", - "termsNote": null - }, - { - "id": 1213, - "areaNote": null, - "administrationId": 1009, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Dml Guyane (historique)", - "termsNote": null - }, - { - "id": 10358, - "areaNote": "Antilles-Guyane", - "administrationId": 1009, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "CROSS Antilles-Guyane", - "termsNote": null - }, - { - "id": 10365, - "areaNote": "Méditerranée", - "administrationId": 1009, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "Cross Med", - "termsNote": null - }, - { - "id": 1370, - "areaNote": null, - "administrationId": 1009, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Paam Osiris (historique)", - "termsNote": null - }, - { - "id": 1385, - "areaNote": null, - "administrationId": 1009, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Ulam 973 Cayenne (historique)", - "termsNote": null - }, - { - "id": 10456, - "areaNote": "Martinique (972)", - "administrationId": 1009, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "DPM 972 Martinique", - "termsNote": null - }, - { - "id": 10080, - "areaNote": "Nord Atlantique Manche Ouest", - "administrationId": 1009, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "PAM Themis", - "termsNote": "Division contrôle de la DIRM NAMO" - }, - { - "id": 10121, - "areaNote": "Manche Est Mer du Nord", - "administrationId": 1009, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "PAM Jeanne Barret", - "termsNote": "Division contrôle de la DIRM MEMN" - }, - { - "id": 10141, - "areaNote": "Méditerranée", - "administrationId": 1009, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "PAM Gyptis", - "termsNote": "Division contrôle de la DIRM MED" - }, - { - "id": 10345, - "areaNote": "Sud Océan Indien", - "administrationId": 1009, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "PAM Osiris II", - "termsNote": "Division contrôle de la DM SOI" - }, - { - "id": 10534, - "areaNote": null, - "administrationId": 1009, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "CACEM", - "termsNote": null - }, - { - "id": 10404, - "areaNote": "Atlantique", - "administrationId": 1009, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "PAM Iris", - "termsNote": "Division contrôle de la DIRM SA" - }, - { - "id": 2, - "areaNote": null, - "administrationId": 1009, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Vrs Gabian (historique)", - "termsNote": null - }, - { - "id": 3, - "areaNote": null, - "administrationId": 1009, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Pam Iris (historique)", - "termsNote": null - }, - { - "id": 4, - "areaNote": null, - "administrationId": 1009, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Pam Themis (historique)", - "termsNote": null - }, - { - "id": 1482, - "areaNote": null, - "administrationId": 1009, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Ulam 976 (historique)", - "termsNote": null - }, - { - "id": 1515, - "areaNote": null, - "administrationId": 1009, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Ulam 974 (historique)", - "termsNote": null - }, - { - "id": 1211, - "areaNote": null, - "administrationId": 1009, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Pm 453 - Watalibi (historique)", - "termsNote": null - }, - { - "id": 1214, - "areaNote": null, - "administrationId": 1009, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Ucaml 973 (historique)", - "termsNote": null - }, - { - "id": 1509, - "areaNote": null, - "administrationId": 1009, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Dirm Namo Cellule Cesam (historique)", - "termsNote": null - }, - { - "id": 1556, - "areaNote": null, - "administrationId": 1009, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Cross Med (historique)", - "termsNote": null - }, - { - "id": 1557, - "areaNote": null, - "administrationId": 1009, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Cross Etel (historique)", - "termsNote": null - }, - { - "id": 1558, - "areaNote": null, - "administrationId": 1009, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Cross Jobourg (historique)", - "termsNote": null - }, - { - "id": 1559, - "areaNote": null, - "administrationId": 1009, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Cross Gris Nez (historique)", - "termsNote": null - }, - { - "id": 1567, - "areaNote": null, - "administrationId": 1009, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "L'Aciola (historique)", - "termsNote": null - }, - { - "id": 1603, - "areaNote": null, - "administrationId": 1009, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Ulam 975 (historique)", - "termsNote": null - }, - { - "id": 1612, - "areaNote": null, - "administrationId": 1009, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Dpm 972 (historique)", - "termsNote": null - }, - { - "id": 1586, - "areaNote": null, - "administrationId": 1009, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Pam Gyptis (historique)", - "termsNote": null - }, - { - "id": 1602, - "areaNote": null, - "administrationId": 1009, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Ensam (historique)", - "termsNote": null - }, - { - "id": 1647, - "areaNote": null, - "administrationId": 1009, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Ulam 973 Saint-Laurent-Du-Maroni (historique)", - "termsNote": null - }, - { - "id": 1585, - "areaNote": null, - "administrationId": 1009, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Pam Jeanne Barret (historique)", - "termsNote": null - } - ], - "isArchived": false, - "name": "DIRM / DM" - }, - { - "id": 2, - "controlUnitIds": [ - 22, - 23, - 24, - 25, - 26, - 27, - 28, - 29, - 30, - 31, - 32, - 33, - 34, - 35, - 36, - 37, - 38, - 39, - 40, - 41, - 42, - 10084, - 1013, - 1014, - 1018, - 1108, - 1111, - 1132, - 1039, - 1046, - 1050, - 1089, - 1103, - 1104, - 1107, - 112, - 113, - 114, - 1055, - 1076, - 1077, - 1093, - 1161, - 1162, - 1183, - 1249, - 10484, - 10489, - 10496, - 10497, - 10500, - 1254, - 1255, - 1256, - 1257, - 1258, - 1259, - 1361, - 1381, - 1491, - 1157, - 1163, - 1169, - 1170, - 1189, - 1226, - 1248, - 10277, - 10510, - 10017, - 10028, - 10033, - 10040, - 10057, - 10072, - 10088, - 10109, - 10126, - 10174, - 10020, - 10196, - 10214, - 10217, - 10218, - 10283, - 10299, - 10317, - 10350, - 10362, - 10371, - 10374, - 10382, - 10398, - 10405, - 10414, - 10415, - 10429, - 10431, - 1066, - 1092, - 1112, - 1127, - 1139, - 1496, - 1504, - 1534, - 1535, - 1537, - 1538, - 1539, - 1168, - 1212, - 1227, - 1235, - 1239, - 1262, - 1360, - 1362, - 1383, - 1519, - 1526, - 1536, - 1540, - 1541, - 1543, - 1544, - 1545, - 1546, - 1547, - 1565, - 1566, - 1570, - 1571, - 1650, - 1617, - 1582, - 1638, - 1575, - 1631, - 1639, - 1651 - ], - "controlUnits": [ - { - "id": 22, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Bsam Lbh (historique)", - "termsNote": null - }, - { - "id": 23, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Bsam Lh (historique)", - "termsNote": null - }, - { - "id": 24, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Bsam Merignac (historique)", - "termsNote": null - }, - { - "id": 25, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Df 12 U.Marinu (historique)", - "termsNote": null - }, - { - "id": 26, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Df 36 Kan An Avel (historique)", - "termsNote": null - }, - { - "id": 27, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Df 37 Nordet (historique)", - "termsNote": null - }, - { - "id": 28, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Df 40 Vent D'Amont ( Ne Plus Utiliser ) (historique)", - "termsNote": null - }, - { - "id": 29, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Df 41 Avel Gwalarm (historique)", - "termsNote": null - }, - { - "id": 30, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Df 42 Suroit (historique)", - "termsNote": null - }, - { - "id": 31, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Df 43 Haize Hegoa (historique)", - "termsNote": null - }, - { - "id": 32, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Df 44 Rakawa (historique)", - "termsNote": null - }, - { - "id": 33, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Df 46 Avel Sterenn (historique)", - "termsNote": null - }, - { - "id": 34, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Df 49 Orsuro (historique)", - "termsNote": null - }, - { - "id": 35, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Df 77 Vire Ne Plus Utiliser (historique)", - "termsNote": null - }, - { - "id": 36, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Df 78 Charente (historique)", - "termsNote": null - }, - { - "id": 37, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Df 79 Gregau (historique)", - "termsNote": null - }, - { - "id": 38, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Df 89 Kervily (historique)", - "termsNote": null - }, - { - "id": 39, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Df 92 Saire (historique)", - "termsNote": null - }, - { - "id": 40, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Df P2 Kermorvan (historique)", - "termsNote": null - }, - { - "id": 41, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Df P1 Jacques Oudart Fourmentin (historique)", - "termsNote": null - }, - { - "id": 42, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Helo Douanes (historique)", - "termsNote": null - }, - { - "id": 10084, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "BSN Marin - DF 287 Lao", - "termsNote": null - }, - { - "id": 1013, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Df 47 (historique)", - "termsNote": null - }, - { - "id": 1014, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Df 16 Cers (Ne Plus Utilisier) (historique)", - "termsNote": null - }, - { - "id": 1018, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Kermorvan Ne Plus Utiliser Voir Df P2 (historique)", - "termsNote": null - }, - { - "id": 1108, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Bsn Saint Martin (historique)", - "termsNote": null - }, - { - "id": 1111, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Racam (historique)", - "termsNote": null - }, - { - "id": 1132, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Df 30 Marinada [2] (historique)", - "termsNote": null - }, - { - "id": 1039, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Df 80 Aude (historique)", - "termsNote": null - }, - { - "id": 1046, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Avion Douanes Hyeres (historique)", - "termsNote": null - }, - { - "id": 1050, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Df 47 Lisserot (historique)", - "termsNote": null - }, - { - "id": 1089, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Df 30 Marinada (historique)", - "termsNote": null - }, - { - "id": 1103, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Bgc Pap (historique)", - "termsNote": null - }, - { - "id": 1104, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Bsn Pap (historique)", - "termsNote": null - }, - { - "id": 1107, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Bgc Saint Martin (historique)", - "termsNote": null - }, - { - "id": 112, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Df 45 Sirocco (historique)", - "termsNote": null - }, - { - "id": 113, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Df 91 (historique)", - "termsNote": null - }, - { - "id": 114, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Df 96 (historique)", - "termsNote": null - }, - { - "id": 1055, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Golf Hotel (historique)", - "termsNote": null - }, - { - "id": 1076, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Patrouilleur Arafenua (historique)", - "termsNote": null - }, - { - "id": 1077, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Brigade Douane Papeete (historique)", - "termsNote": null - }, - { - "id": 1093, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Bsn Marin (historique)", - "termsNote": null - }, - { - "id": 1161, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Df 44 (historique)", - "termsNote": null - }, - { - "id": 1162, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Df 291 Tarpon (historique)", - "termsNote": null - }, - { - "id": 1183, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Df 21 (historique)", - "termsNote": null - }, - { - "id": 1249, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Df 294 Ptherois (historique)", - "termsNote": null - }, - { - "id": 10484, - "areaNote": "Morbihan (56)", - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "BGC Lorient - DF 36 Kan An Avel", - "termsNote": "COD Manche Mer du Nord Atlantique" - }, - { - "id": 10489, - "areaNote": "66-11-34-30-13", - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "BGC Sète - DF 26 Cers", - "termsNote": "COD Méditérannée" - }, - { - "id": 10496, - "areaNote": "Nord de la Bretagne", - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "BGC Saint-Malo - DF 46 Avel Sterenn", - "termsNote": "COD Manche Mer du Nord Atlantique" - }, - { - "id": 10497, - "areaNote": "Martinique (972)", - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "BSN Fort-de-France - DF 292 Macouba", - "termsNote": "COD Antilles-Guyane" - }, - { - "id": 10500, - "areaNote": "Martinique (972)", - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "BSN Marin – DF 287 Inoua Lao – DF 291 Tarpon", - "termsNote": "COD Antilles-Guyane" - }, - { - "id": 1254, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Df 61 Touloubre (historique)", - "termsNote": null - }, - { - "id": 1255, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Df63 Arenc (historique)", - "termsNote": null - }, - { - "id": 1256, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Dfp3 Jean Francois Deniau (historique)", - "termsNote": null - }, - { - "id": 1257, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Df 66 Olbia [2] (historique)", - "termsNote": null - }, - { - "id": 1258, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Df33 Levante (historique)", - "termsNote": null - }, - { - "id": 1259, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Df 25 Libecciu (historique)", - "termsNote": null - }, - { - "id": 1361, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Df47 Ajaccio Ne Plus Utiliser (historique)", - "termsNote": null - }, - { - "id": 1381, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Df 26 Cers (historique)", - "termsNote": null - }, - { - "id": 1491, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Df 28 Mistral (historique)", - "termsNote": null - }, - { - "id": 1157, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Helicoptere Douanes Antilles (historique)", - "termsNote": null - }, - { - "id": 1163, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Df 292 Macouba (historique)", - "termsNote": null - }, - { - "id": 1169, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Df 291 Tarpon [2] (historique)", - "termsNote": null - }, - { - "id": 1170, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Df 94 (historique)", - "termsNote": null - }, - { - "id": 1189, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Df 24 Sua Luiga (historique)", - "termsNote": null - }, - { - "id": 1226, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Df 64 Preconil (historique)", - "termsNote": null - }, - { - "id": 1248, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Df 293 Lapwent (historique)", - "termsNote": null - }, - { - "id": 10277, - "areaNote": "DF 39 Alize : Guyane (973)\n- Axe Kourou : Kourou", - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "BGC Kourou – DF 39 Alizé – Axe Kourou", - "termsNote": "COD Antilles-Guyane" - }, - { - "id": 10510, - "areaNote": "France métropolitaine hors Corse", - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "BSAT Margny-Compiegne", - "termsNote": "COD Manche Mer du Nord Atlantique" - }, - { - "id": 10017, - "areaNote": "Saint-Martin et Saint-Barthélemy", - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "BGC Saint-Martin – DF 38 Soualiouga", - "termsNote": "COD Antilles-Guyane" - }, - { - "id": 10028, - "areaNote": "Bouches-du-Rhône (13)", - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "BSN Port de Bouc - DF 61 Touloubre", - "termsNote": "COD Méditérannée" - }, - { - "id": 10033, - "areaNote": "Guadeloupe (971)", - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "BGC Pointe-à-Pitre - DF 34 Kaladja", - "termsNote": "COD Antilles-Guyane" - }, - { - "id": 10040, - "areaNote": "34-30-13-83", - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "BGC Marseille - DF 28 Mistral", - "termsNote": "COD Méditérannée" - }, - { - "id": 10057, - "areaNote": "Manche (50) ouest", - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "BSN Granville - DF 62 Pleville Le Pelley", - "termsNote": "COD Manche Mer du Nord Atlantique" - }, - { - "id": 10072, - "areaNote": "Finistère Atlantique", - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "DF P2 Kermorvan", - "termsNote": "COD Manche Mer du Nord Atlantique" - }, - { - "id": 10088, - "areaNote": "Guadeloupe (971)", - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "BSN Pointe-à-Pitre - DF 293 Lapwent", - "termsNote": "COD Antilles-Guyane" - }, - { - "id": 10109, - "areaNote": "Loire-Atlantique (44) / Vendée (85)", - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "BSN Saint-Nazaire - DF 65 La Courance", - "termsNote": "COD Manche Mer du Nord Atlantique" - }, - { - "id": 10126, - "areaNote": "Antilles françaises, Guyane et Saint-Pierre et Miquelon", - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "BSAM Martinique – Le Lamentin", - "termsNote": "COD Antilles-Guyane" - }, - { - "id": 10174, - "areaNote": "Kourou", - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "BGC Kourou - Axe Kourou", - "termsNote": "COD Antilles-Guyane" - }, - { - "id": 10020, - "areaNote": "Méditerranée", - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "BSA Hyères", - "termsNote": "COD Méditérannée" - }, - { - "id": 10196, - "areaNote": "Martinique (972) (éventuellement Guadeloupe et Ile du Nord)", - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "BGC Fort-de-France – DF 35 Sokan", - "termsNote": "COD Antilles-Guyane" - }, - { - "id": 10214, - "areaNote": "Manche Est Mer du Nord", - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "DF P1 Jacques Oudart Fourmentin", - "termsNote": "COD Manche Mer du Nord Atlantique" - }, - { - "id": 10217, - "areaNote": "Bouches-du-Rhône (13) et Var (83)", - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "BSN Bandol - DF 63 Arenc", - "termsNote": "COD Méditérannée" - }, - { - "id": 10218, - "areaNote": "de Belle-île à Hendaye", - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "BGC La Rochelle - DF 32 Seudre", - "termsNote": "COD Manche Mer du Nord Atlantique" - }, - { - "id": 10283, - "areaNote": "Manche Est Mer du Nord", - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "BGC Dunkerque - DF 37 Nordet", - "termsNote": "COD Manche Mer du Nord Atlantique" - }, - { - "id": 10299, - "areaNote": "Corse", - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "BGC Ajaccio - DF 47 Muntese", - "termsNote": "COD Méditérannée" - }, - { - "id": 10317, - "areaNote": "Calais jusqu’à Mont Saint-Michel (jusqu’à Brest pour des cas particulier)", - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "BSAM Le Havre", - "termsNote": "COD Manche Mer du Nord Atlantique" - }, - { - "id": 10350, - "areaNote": "Cap Camarat à la Ciotat (parfois Boûches-du-Rhône et Côte d’Azur)", - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "BSN Hyères - DF 66 Olbia", - "termsNote": "COD Méditérannée" - }, - { - "id": 10362, - "areaNote": "Corse", - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "BGC Bastia - DF 25 Libecciu", - "termsNote": "COD Méditérannée" - }, - { - "id": 10371, - "areaNote": "Var (83) et Alpes-Maritimes (06)", - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "BSN Sainte-Maxime - DF 64 Preconil", - "termsNote": "COD Méditérannée" - }, - { - "id": 10374, - "areaNote": "Côte basque et Landes", - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "BSN Hendaye - DF 68 Errobi", - "termsNote": "COD Manche Mer du Nord Atlantique" - }, - { - "id": 10382, - "areaNote": "Hérault (34), Gard (30) et Boûches-du-Rhône (13)", - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "BSN La Grande Motte - DF 67 Gregau", - "termsNote": "COD Méditérannée" - }, - { - "id": 10398, - "areaNote": "Guadeloupe (971)", - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "BSN Basse-Terre - DF 294 Ptherois", - "termsNote": "COD Antilles-Guyane" - }, - { - "id": 10405, - "areaNote": "Méditerranée", - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "DF P3 Jean-François Deniau", - "termsNote": "COD Méditérannée" - }, - { - "id": 10414, - "areaNote": "NAMO", - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "BSAM Lann-Bihoué", - "termsNote": "COD Manche Mer du Nord Atlantique" - }, - { - "id": 10415, - "areaNote": "Centre Manche (Iles Chausey à Fécamp)", - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "BGC Cherbourg - DF 27 Vent D'Amont", - "termsNote": "COD Manche Mer du Nord Atlantique" - }, - { - "id": 10429, - "areaNote": "Golfe du Lion jusqu’à Toulon", - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "BGC Port-Vendres - DF 30 Marinada", - "termsNote": "COD Méditérannée" - }, - { - "id": 10431, - "areaNote": "Var (83 ) et Alpes-Maritimes (06)", - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "BGC Nice - DF 33 Levante", - "termsNote": "COD Méditérannée" - }, - { - "id": 1066, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Df 90 Maravenne (historique)", - "termsNote": null - }, - { - "id": 1092, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Bgc Fort De France (historique)", - "termsNote": null - }, - { - "id": 1112, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Galaxy (historique)", - "termsNote": null - }, - { - "id": 1127, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Df 83 Saint Louis (historique)", - "termsNote": null - }, - { - "id": 1139, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Df 62 Pleville Le Pelley (historique)", - "termsNote": null - }, - { - "id": 1496, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Df 65 La Courance (historique)", - "termsNote": null - }, - { - "id": 1504, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Bsam Martinique (historique)", - "termsNote": null - }, - { - "id": 1534, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Bsn Port De Bouc (historique)", - "termsNote": null - }, - { - "id": 1535, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Bsn Hyeres (historique)", - "termsNote": null - }, - { - "id": 1537, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Bgc Port-Vendres (historique)", - "termsNote": null - }, - { - "id": 1538, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Bgc Sete (historique)", - "termsNote": null - }, - { - "id": 1539, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Bgc Ajaccio (historique)", - "termsNote": null - }, - { - "id": 1168, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Df 31 (historique)", - "termsNote": null - }, - { - "id": 1212, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Df 66 Olbia (historique)", - "termsNote": null - }, - { - "id": 1227, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Df 67 Gregau (historique)", - "termsNote": null - }, - { - "id": 1235, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Df 32 Seudre (historique)", - "termsNote": null - }, - { - "id": 1239, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Df 68 Errobi (historique)", - "termsNote": null - }, - { - "id": 1262, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Df 45 Alize (historique)", - "termsNote": null - }, - { - "id": 1360, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Vgc Kourou (historique)", - "termsNote": null - }, - { - "id": 1362, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Df 49 Marseille Ne Plus Utiliser (historique)", - "termsNote": null - }, - { - "id": 1383, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Df 27 Vent D'Amont (historique)", - "termsNote": null - }, - { - "id": 1519, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Drone (Emsa) (historique)", - "termsNote": null - }, - { - "id": 1526, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Helicoptere Douanes Cherbourg (historique)", - "termsNote": null - }, - { - "id": 1536, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Bsn Ste Maxime (historique)", - "termsNote": null - }, - { - "id": 1540, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Bgc Ajaccio [2] (historique)", - "termsNote": null - }, - { - "id": 1541, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Bgc Bastia (historique)", - "termsNote": null - }, - { - "id": 1543, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Bgc Marseille (historique)", - "termsNote": null - }, - { - "id": 1544, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Bsn Bandol (historique)", - "termsNote": null - }, - { - "id": 1545, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Bgc Nice (historique)", - "termsNote": null - }, - { - "id": 1546, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Patrouilleur Toulon-La-Seyne (historique)", - "termsNote": null - }, - { - "id": 1547, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Bsat Compiegne (historique)", - "termsNote": null - }, - { - "id": 1565, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Df39 Alize (historique)", - "termsNote": null - }, - { - "id": 1566, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Df 34 - Kaladja (historique)", - "termsNote": null - }, - { - "id": 1570, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Autre Moyen (historique)", - "termsNote": null - }, - { - "id": 1571, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Helico Douanes Hyeres (historique)", - "termsNote": null - }, - { - "id": 1650, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Bsn Basse Terre (historique)", - "termsNote": null - }, - { - "id": 1617, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Bsn Fort-De-France (historique)", - "termsNote": null - }, - { - "id": 1582, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Bsam Le Havre (historique)", - "termsNote": null - }, - { - "id": 1638, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Df 38 Sualouiga (historique)", - "termsNote": null - }, - { - "id": 1575, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Bsam Le Lamentin (historique)", - "termsNote": null - }, - { - "id": 1631, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Bsn Granville (historique)", - "termsNote": null - }, - { - "id": 1639, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Bgc Pap [2] (historique)", - "termsNote": null - }, - { - "id": 1651, - "areaNote": null, - "administrationId": 2, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Df35 Sokan (historique)", - "termsNote": null - } - ], - "isArchived": false, - "name": "Douane" - }, - { - "id": 4, - "controlUnitIds": [ - 20, - 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, - 1009, - 1010, - 1017, - 10199, - 1020, - 1037, - 1060, - 1040, - 1042, - 1044, - 1011, - 1016, - 1036, - 1102, - 1149, - 111, - 120, - 121, - 1001, - 1002, - 1043, - 1128, - 1184, - 10473, - 10509, - 10391, - 10078, - 10054, - 1458, - 1484, - 1485, - 1166, - 1207, - 1221, - 1358, - 10519, - 10356, - 10004, - 10016, - 10049, - 10093, - 10099, - 10108, - 10112, - 10122, - 10128, - 10148, - 10155, - 10164, - 10182, - 10191, - 10202, - 10213, - 10219, - 10142, - 10264, - 10286, - 10293, - 10296, - 10302, - 10313, - 10325, - 10336, - 10378, - 10380, - 10412, - 10416, - 10434, - 10442, - 10447, - 10455, - 10152, - 1023, - 1075, - 1116, - 1117, - 1148, - 1185, - 1243, - 1250, - 1475, - 1598, - 1623, - 1643, - 1584, - 1609, - 1607, - 1624, - 1646, - 1615, - 1627, - 1634, - 1621, - 1642 - ], - "controlUnits": [ - { - "id": 20, - "areaNote": null, - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "P719 Armoise (historique)", - "termsNote": null - }, - { - "id": 61, - "areaNote": null, - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "P621 Aber Wrac'H (historique)", - "termsNote": null - }, - { - "id": 62, - "areaNote": null, - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "P603 Adour (historique)", - "termsNote": null - }, - { - "id": 63, - "areaNote": null, - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Bsl Boulogne (historique)", - "termsNote": null - }, - { - "id": 64, - "areaNote": null, - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Bsl Brest (historique)", - "termsNote": null - }, - { - "id": 65, - "areaNote": null, - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Bsl Cherbourg (historique)", - "termsNote": null - }, - { - "id": 66, - "areaNote": null, - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Bsl Lege Cap Ferret (historique)", - "termsNote": null - }, - { - "id": 67, - "areaNote": null, - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Bsl Lorient (historique)", - "termsNote": null - }, - { - "id": 68, - "areaNote": null, - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Bsl La Rochelle (historique)", - "termsNote": null - }, - { - "id": 69, - "areaNote": null, - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Bsl St Malo Ne Plus Utiliser (historique)", - "termsNote": null - }, - { - "id": 70, - "areaNote": null, - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Capitaine Moulie (historique)", - "termsNote": null - }, - { - "id": 71, - "areaNote": null, - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "P613 Charente (historique)", - "termsNote": null - }, - { - "id": 72, - "areaNote": null, - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "P601 Elorn (historique)", - "termsNote": null - }, - { - "id": 73, - "areaNote": null, - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Epee (historique)", - "termsNote": null - }, - { - "id": 74, - "areaNote": null, - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Gendarmerie Pornichet - Ne Pas Utiliser (historique)", - "termsNote": null - }, - { - "id": 75, - "areaNote": null, - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "P791 Hortensia (historique)", - "termsNote": null - }, - { - "id": 76, - "areaNote": null, - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "P 410 (historique)", - "termsNote": null - }, - { - "id": 77, - "areaNote": null, - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "P604 Scarpe (historique)", - "termsNote": null - }, - { - "id": 78, - "areaNote": null, - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "P607 Yser (historique)", - "termsNote": null - }, - { - "id": 79, - "areaNote": null, - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "P618 Escaut (historique)", - "termsNote": null - }, - { - "id": 80, - "areaNote": null, - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "P622 Esteron (historique)", - "termsNote": null - }, - { - "id": 81, - "areaNote": null, - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "P671 Glaive (historique)", - "termsNote": null - }, - { - "id": 82, - "areaNote": null, - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "P720 Geranium (historique)", - "termsNote": null - }, - { - "id": 83, - "areaNote": null, - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "P615 Penfeld (historique)", - "termsNote": null - }, - { - "id": 84, - "areaNote": null, - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "P778 Reseda (historique)", - "termsNote": null - }, - { - "id": 85, - "areaNote": null, - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "P620 Sevre (historique)", - "termsNote": null - }, - { - "id": 86, - "areaNote": null, - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "P616 Trieux (historique)", - "termsNote": null - }, - { - "id": 87, - "areaNote": null, - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "P605 Vertonne (historique)", - "termsNote": null - }, - { - "id": 1009, - "areaNote": null, - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Bsl Marseille (historique)", - "termsNote": null - }, - { - "id": 1010, - "areaNote": null, - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Bsl Port La Nouvelle (historique)", - "termsNote": null - }, - { - "id": 1017, - "areaNote": null, - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "P619 Huevaune - Ne Pas Utiliser (historique)", - "termsNote": null - }, - { - "id": 10199, - "areaNote": null, - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "PSMP – Pelotons de sûreté maritime et portuaire", - "termsNote": null - }, - { - "id": 1020, - "areaNote": null, - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "P610 Gravona (historique)", - "termsNote": null - }, - { - "id": 1037, - "areaNote": null, - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Gendmar Sete - Ne Pas Utiliser (historique)", - "termsNote": null - }, - { - "id": 1060, - "areaNote": null, - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "P608 - Ne Plus Utiliser (historique)", - "termsNote": null - }, - { - "id": 1040, - "areaNote": null, - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Bsl Pornichet (historique)", - "termsNote": null - }, - { - "id": 1042, - "areaNote": null, - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Bsl Lezardrieux Ne Plus Utiliser Voir Bn (historique)", - "termsNote": null - }, - { - "id": 1044, - "areaNote": null, - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "P612 Maury (historique)", - "termsNote": null - }, - { - "id": 1011, - "areaNote": null, - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Bsl Toulon (historique)", - "termsNote": null - }, - { - "id": 1016, - "areaNote": null, - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Bsl Nice (historique)", - "termsNote": null - }, - { - "id": 1036, - "areaNote": null, - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Athos (historique)", - "termsNote": null - }, - { - "id": 1102, - "areaNote": null, - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "P722 - Violette (historique)", - "termsNote": null - }, - { - "id": 1149, - "areaNote": null, - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "P717 Lavande (historique)", - "termsNote": null - }, - { - "id": 111, - "areaNote": null, - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Bsl Caen (historique)", - "termsNote": null - }, - { - "id": 120, - "areaNote": null, - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "P609 Herault - Sete (historique)", - "termsNote": null - }, - { - "id": 121, - "areaNote": null, - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "P614 Tech - Port Vendres (historique)", - "termsNote": null - }, - { - "id": 1001, - "areaNote": null, - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "P619 Huveaune (historique)", - "termsNote": null - }, - { - "id": 1002, - "areaNote": null, - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "P617 Vesubie (historique)", - "termsNote": null - }, - { - "id": 1043, - "areaNote": null, - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "P721 Jonquille (historique)", - "termsNote": null - }, - { - "id": 1128, - "areaNote": null, - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Bsl Sete (historique)", - "termsNote": null - }, - { - "id": 1184, - "areaNote": null, - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "P624 Organabo (historique)", - "termsNote": null - }, - { - "id": 10473, - "areaNote": "Nord (59) et Pas-de-Calais (62)", - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "BGMAR Boulogne-sur-Mer - P694 Aber Ildut", - "termsNote": "CORGMAR MEMN" - }, - { - "id": 10509, - "areaNote": "littoral du Calvados (14)", - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "BSL Caen", - "termsNote": "CORGMAR MEMN" - }, - { - "id": 10391, - "areaNote": "Guyane (973)", - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "BGMAR Kourou - P624 Organabo", - "termsNote": "Pas de hiérarchie" - }, - { - "id": 10078, - "areaNote": "Saint-Pierre-et-Miquelon (975)", - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "EN Saint-Pierre-et-Miquelon – Sao", - "termsNote": null - }, - { - "id": 10054, - "areaNote": "La Réunion (974)", - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "BSL Port des Galets", - "termsNote": "Pas de hiérarchie" - }, - { - "id": 1458, - "areaNote": null, - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Le Dumbea (historique)", - "termsNote": null - }, - { - "id": 1484, - "areaNote": null, - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "P 611 Odet (historique)", - "termsNote": null - }, - { - "id": 1485, - "areaNote": null, - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "P 602 Verdon (historique)", - "termsNote": null - }, - { - "id": 1166, - "areaNote": null, - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "P 722 Violette (historique)", - "termsNote": null - }, - { - "id": 1207, - "areaNote": null, - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Aramis [2] (historique)", - "termsNote": null - }, - { - "id": 1221, - "areaNote": null, - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Jasmin (historique)", - "termsNote": null - }, - { - "id": 1358, - "areaNote": null, - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Gm Bastia (historique)", - "termsNote": null - }, - { - "id": 10519, - "areaNote": "Guyane (973)", - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "PAM Cayenne", - "termsNote": "Pas de hiérarchie" - }, - { - "id": 10356, - "areaNote": "Antilles française", - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "PGMAR Pointe-à-Pitre - P722 Violette", - "termsNote": "Pas de hiérarchie" - }, - { - "id": 10004, - "areaNote": "Pyrénées-Orientales (66)", - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "BGMAR Port-Vendres - P614 Tech", - "termsNote": "CORGMAR Méditérannée" - }, - { - "id": 10016, - "areaNote": "Bouches-du-Rhône (13)", - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "BGMAR Marseille - P619 Huveaune", - "termsNote": "CORGMAR Méditérannée" - }, - { - "id": 10049, - "areaNote": "Iroise et Nord Finistère", - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "BGMAR Brest - P621 Aber Wrac'h", - "termsNote": "CORGMAR Atlantique" - }, - { - "id": 10093, - "areaNote": "Vendée (85) et Charente-Maritime (17)", - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "BSL La Rochelle", - "termsNote": "CORGMAR Atlantique" - }, - { - "id": 10099, - "areaNote": "Finistère (29) – Morbihan (56)", - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "BGMAR Concarneau - P601 Elorn", - "termsNote": "CORGMAR Atlantique" - }, - { - "id": 10108, - "areaNote": "Gironde (33), Landes (40) et Pyrénées-Atlantiques (64)", - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "BSL Lège-Cap-Ferret", - "termsNote": "CORGMAR Atlantique" - }, - { - "id": 10112, - "areaNote": "Nord Bretagne", - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "BGMAR Saint-Malo - P616 Trieux", - "termsNote": "CORGMAR Atlantique" - }, - { - "id": 10122, - "areaNote": "de Cherbourg à Calais", - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "BGMAR Dieppe - P607 Yser", - "termsNote": "CORGMAR MEMN" - }, - { - "id": 10128, - "areaNote": "Manche Est Mer du Nord", - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "BGMAR Dunkerque - P693 Oyapock", - "termsNote": "CORGMAR MEMN" - }, - { - "id": 10148, - "areaNote": "Atlantique Sud Bretagne", - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "BGMAR Les-Sables-d’Olonne - P605 Vertonne", - "termsNote": "CORGMAR Atlantique" - }, - { - "id": 10155, - "areaNote": "littoral de la Manche (50)", - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "BSL Cherbourg", - "termsNote": "CORGMAR MEMN" - }, - { - "id": 10164, - "areaNote": "Manche est Mer du Nord", - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "BGMAR Cherbourg – P692 Maroni", - "termsNote": "CORGMAR MEMN" - }, - { - "id": 10182, - "areaNote": "Aude (11) – Pyrénées-Orientales (66) – hérault (34)", - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "BSL Port-la-Nouvelle", - "termsNote": "CORGMAR Méditérannée" - }, - { - "id": 10191, - "areaNote": "Finistère Nord (entre Brest et Saint-Quay)", - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "BGMAR Roscoff - P618 Escaut", - "termsNote": "CORGMAR Atlantique" - }, - { - "id": 10202, - "areaNote": "Mayotte (976)", - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "BGMAR Dzaoudzi - P611 Odet", - "termsNote": "Pas de hiérarchie" - }, - { - "id": 10213, - "areaNote": "Loire-Atlantique (44) – Morbihan (56) – Vendée (85)", - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "BGMAR Pornichet - P620 Sevre", - "termsNote": "CORGMAR Atlantique" - }, - { - "id": 10219, - "areaNote": "Méditerranée", - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "PGMAR Toulon - P721 Jonquille", - "termsNote": "CORGMAR Méditérannée" - }, - { - "id": 10142, - "areaNote": "Arcachon à Noirmoutier", - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "BGMAR La Rochelle – P604 Scarpe", - "termsNote": "CORGMAR Atlantique" - }, - { - "id": 10264, - "areaNote": "Finistère (29) – Côtes-d’Armor (22) – Ille-et-Vilaine (35)", - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "BSL Brest", - "termsNote": "CORGMAR Atlantique" - }, - { - "id": 10286, - "areaNote": "Pas-de-Calais (62)", - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "BSL Boulogne-sur-Mer", - "termsNote": "CORGMAR MEMN" - }, - { - "id": 10293, - "areaNote": "Alpes-Maritimes (06) – Var (83)", - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "BGMAR Nice - P617 Vesubie", - "termsNote": "CORGMAR Méditérannée" - }, - { - "id": 10296, - "areaNote": "Mayotte (976)", - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "BGMAR Dzaoudzi - P602 Verdon", - "termsNote": "Pas de hiérarchie" - }, - { - "id": 10302, - "areaNote": "De la Ciotat à le Grau du Roi", - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "BSL Marseille", - "termsNote": "CORGMAR Méditérannée" - }, - { - "id": 10313, - "areaNote": "Var (83)", - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "BSL Toulon", - "termsNote": "CORGMAR Méditérannée" - }, - { - "id": 10325, - "areaNote": "Manche Mer du Nord", - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "PGMAR Cherbourg – P719 Armoise ", - "termsNote": "CORGMAR MEMN" - }, - { - "id": 10336, - "areaNote": "Morbihan (56) – Loire-Atlantique (44)", - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "BSL Lorient", - "termsNote": "CORGMAR Atlantique" - }, - { - "id": 10378, - "areaNote": "Var (83) et Alpes-Maritimes (06)", - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "BGMAR Saint-Raphael - P608 Argens", - "termsNote": "CORGMAR Méditérannée" - }, - { - "id": 10380, - "areaNote": "Pyrénées-Atlantiques (64), Landes (40) et Gironde (33)", - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "BGMAR Anglet - P603 Adour", - "termsNote": "CORGMAR Atlantique" - }, - { - "id": 10412, - "areaNote": "Manche Est Mer du Nord", - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "BGMAR Le Havre - P622 Esteron", - "termsNote": "CORGMAR MEMN" - }, - { - "id": 10416, - "areaNote": "Aude (11)", - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "BGMAR Gruissan - P612 Maury", - "termsNote": "CORGMAR Méditérannée" - }, - { - "id": 10434, - "areaNote": "Ouest Méditerranée", - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "BGMAR Sète - P609 Herault", - "termsNote": "CORGMAR Méditérannée" - }, - { - "id": 10442, - "areaNote": "Corse-du-Sud (2A)", - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "BGMAR Ajaccio - P610 Gravona", - "termsNote": "CORGMAR Méditérannée" - }, - { - "id": 10447, - "areaNote": "Mer d’iroise", - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "BGMAR Brest - P615 Penfeld", - "termsNote": "CORGMAR Atlantique" - }, - { - "id": 10455, - "areaNote": "Golfe de Gascogne – Bretagne", - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "PGMAR Lorient - P720 Geranium", - "termsNote": "CORGMAR Atlantique" - }, - { - "id": 10152, - "areaNote": "Guyane (973)", - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "BGMAR Cayenne – P613 Charente", - "termsNote": "Pas de hiérarchie" - }, - { - "id": 1023, - "areaNote": null, - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "G-Neplusutiliser (historique)", - "termsNote": null - }, - { - "id": 1075, - "areaNote": null, - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Patrouilleur Jasmin (historique)", - "termsNote": null - }, - { - "id": 1116, - "areaNote": null, - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Organabo (historique)", - "termsNote": null - }, - { - "id": 1117, - "areaNote": null, - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Mahury (historique)", - "termsNote": null - }, - { - "id": 1148, - "areaNote": null, - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "P608 Argens (historique)", - "termsNote": null - }, - { - "id": 1185, - "areaNote": null, - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "P623 Mahury (historique)", - "termsNote": null - }, - { - "id": 1243, - "areaNote": null, - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Pam Cayenne (historique)", - "termsNote": null - }, - { - "id": 1250, - "areaNote": null, - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Bsl Les Galets (historique)", - "termsNote": null - }, - { - "id": 1475, - "areaNote": null, - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Peloton De Sûreté Maritime Et Portuaire Le Havre (historique)", - "termsNote": null - }, - { - "id": 1598, - "areaNote": null, - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Peloton Sûreté Maritime Portuaire Militaire Toulon (historique)", - "termsNote": null - }, - { - "id": 1623, - "areaNote": null, - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Dsi Cannes (historique)", - "termsNote": null - }, - { - "id": 1643, - "areaNote": null, - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Barracuda (historique)", - "termsNote": null - }, - { - "id": 1584, - "areaNote": null, - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Sable D'Olonne (historique)", - "termsNote": null - }, - { - "id": 1609, - "areaNote": null, - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "P693 Oyapock (historique)", - "termsNote": null - }, - { - "id": 1607, - "areaNote": null, - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Vscm Maroni (historique)", - "termsNote": null - }, - { - "id": 1624, - "areaNote": null, - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Peloton De Sûreté Maritime Et Portuaire De Dunkerq (historique)", - "termsNote": null - }, - { - "id": 1646, - "areaNote": null, - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "P604 Scarpe [2] (historique)", - "termsNote": null - }, - { - "id": 1615, - "areaNote": null, - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Psmp Port De Bouc (Suretéportuaiure) (historique)", - "termsNote": null - }, - { - "id": 1627, - "areaNote": null, - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Peloton Sûreté Maritime Portuaire Calais (historique)", - "termsNote": null - }, - { - "id": 1634, - "areaNote": null, - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Bsl Marseillais (historique)", - "termsNote": null - }, - { - "id": 1621, - "areaNote": null, - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Peloton Sûreté Maritime Portuaire Militaire St Naz (historique)", - "termsNote": null - }, - { - "id": 1642, - "areaNote": null, - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Gendarmerie Maritime Cayenne (historique)", - "termsNote": null - } - ], - "isArchived": false, - "name": "Gendarmerie Maritime" - }, - { - "id": 1011, - "controlUnitIds": [ - 10156, - 10490, - 1448, - 1315, - 1314, - 1316, - 10014, - 10030, - 10041, - 10048, - 10070, - 10076, - 10098, - 10110, - 10118, - 1321, - 1322, - 1324, - 1332, - 1333, - 1334, - 10150, - 1335, - 1336, - 1369, - 10185, - 10189, - 10190, - 10200, - 10201, - 10207, - 10224, - 10236, - 10237, - 10246, - 1480, - 10259, - 10266, - 10289, - 10304, - 10338, - 10341, - 10347, - 1238, - 10367, - 1330, - 1353, - 10401, - 10407, - 1367, - 1372, - 10425, - 10426, - 10436, - 10440, - 10453, - 10061, - 10512, - 10454, - 1477, - 1488, - 1495, - 1512, - 1514, - 1237, - 1318, - 1323, - 1325, - 1328, - 1329, - 1331, - 1337, - 1338, - 1339, - 1354, - 1371, - 1447, - 1464, - 1469, - 1640, - 1579, - 1581, - 1580, - 1592 - ], - "controlUnits": [ - { - "id": 10156, - "areaNote": "Méditerranée", - "administrationId": 1011, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "OFB Brigade Mobile d'Intervention – Sud Est", - "termsNote": "Direction de la police des BMI de l’OFB" - }, - { - "id": 10490, - "areaNote": "Bouches-du-Rhône (13)", - "administrationId": 1011, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "OFB SD 13", - "termsNote": null - }, - { - "id": 1448, - "areaNote": null, - "administrationId": 1011, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Ofb Unité Spéciale Migrateurs Nouvelle-Aquitaine (historique)", - "termsNote": null - }, - { - "id": 1315, - "areaNote": null, - "administrationId": 1011, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Ofb Guadeloupe (historique)", - "termsNote": null - }, - { - "id": 1314, - "areaNote": null, - "administrationId": 1011, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Ofb Guyane (historique)", - "termsNote": null - }, - { - "id": 1316, - "areaNote": null, - "administrationId": 1011, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Ofb Martinique (historique)", - "termsNote": null - }, - { - "id": 10014, - "areaNote": "Pas-de-Calais (62)", - "administrationId": 1011, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "OFB SD 62", - "termsNote": null - }, - { - "id": 10030, - "areaNote": "Gironde (33)", - "administrationId": 1011, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "OFB SD 33", - "termsNote": null - }, - { - "id": 10041, - "areaNote": "Seine-Maritime (76)", - "administrationId": 1011, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "OFB SD 76", - "termsNote": null - }, - { - "id": 10048, - "areaNote": "Sud Atlantique", - "administrationId": 1011, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "OFB Unité Spéciale Migrateurs 33", - "termsNote": null - }, - { - "id": 10070, - "areaNote": "Martinique (972)", - "administrationId": 1011, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "OFB SD 972 Martinique", - "termsNote": null - }, - { - "id": 10076, - "areaNote": "Vendée (85)", - "administrationId": 1011, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "OFB SD 85", - "termsNote": null - }, - { - "id": 10098, - "areaNote": "Haute-Corse (2B)", - "administrationId": 1011, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "OFB SD 2B", - "termsNote": null - }, - { - "id": 10110, - "areaNote": "Nord (59)", - "administrationId": 1011, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "OFB SD 59", - "termsNote": null - }, - { - "id": 10118, - "areaNote": "Atlantique nord-est", - "administrationId": 1011, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "OFB SD 975 Saint-Pierre et Miquelon", - "termsNote": null - }, - { - "id": 1321, - "areaNote": null, - "administrationId": 1011, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Ofb Sd 14 (historique)", - "termsNote": null - }, - { - "id": 1322, - "areaNote": null, - "administrationId": 1011, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Ofb Sd 27 (historique)", - "termsNote": null - }, - { - "id": 1324, - "areaNote": null, - "administrationId": 1011, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Ofb Sd 80 (historique)", - "termsNote": null - }, - { - "id": 1332, - "areaNote": null, - "administrationId": 1011, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Ofb Sd 11 (historique)", - "termsNote": null - }, - { - "id": 1333, - "areaNote": null, - "administrationId": 1011, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Ofb Sd 34 (historique)", - "termsNote": null - }, - { - "id": 1334, - "areaNote": null, - "administrationId": 1011, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Ofb Sd 30 (historique)", - "termsNote": null - }, - { - "id": 10150, - "areaNote": "Hérault (34)", - "administrationId": 1011, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "OFB SD 34", - "termsNote": null - }, - { - "id": 1335, - "areaNote": null, - "administrationId": 1011, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Ofb Sd 13 (historique)", - "termsNote": null - }, - { - "id": 1336, - "areaNote": null, - "administrationId": 1011, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Ofbsd 83 (historique)", - "termsNote": null - }, - { - "id": 1369, - "areaNote": null, - "administrationId": 1011, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Ofb Sd 85 (historique)", - "termsNote": null - }, - { - "id": 10185, - "areaNote": "Manche (50)", - "administrationId": 1011, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "OFB SD 50", - "termsNote": null - }, - { - "id": 10189, - "areaNote": "Eure (27)", - "administrationId": 1011, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "OFB SD 27", - "termsNote": null - }, - { - "id": 10190, - "areaNote": "Charente-Maritime (17)", - "administrationId": 1011, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "OFB SD 17", - "termsNote": null - }, - { - "id": 10200, - "areaNote": "La Réunion (974)", - "administrationId": 1011, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "OFB SD 974 La Réunion – BNOI", - "termsNote": null - }, - { - "id": 10201, - "areaNote": "Calvados (14)", - "administrationId": 1011, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "OFB SD 14", - "termsNote": null - }, - { - "id": 10207, - "areaNote": "Var (83) / PACA", - "administrationId": 1011, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "OFB SD 83", - "termsNote": null - }, - { - "id": 10224, - "areaNote": "Aude (11)", - "administrationId": 1011, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "OFB SD 11", - "termsNote": null - }, - { - "id": 10236, - "areaNote": "Nouvelle-Aquitaine", - "administrationId": 1011, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "OFB Unité Spéciale Migrateurs 64-40", - "termsNote": null - }, - { - "id": 10237, - "areaNote": "Somme (80) (et PNMEPMO)", - "administrationId": 1011, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "OFB SD 80", - "termsNote": null - }, - { - "id": 10246, - "areaNote": "Alpes-Maritimes (06)", - "administrationId": 1011, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "OFB SD 06", - "termsNote": null - }, - { - "id": 1480, - "areaNote": null, - "administrationId": 1011, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Ofb Unité Spéciale Migrateurs, Normandie Hauts De (historique)", - "termsNote": null - }, - { - "id": 10259, - "areaNote": "Mayotte (976)", - "administrationId": 1011, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "OFB SD 976 Mayotte", - "termsNote": null - }, - { - "id": 10266, - "areaNote": "Pyrénées-Atlantiques (64)", - "administrationId": 1011, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "OFB SD 64", - "termsNote": null - }, - { - "id": 10289, - "areaNote": "Pyrénées-Orientales (66)", - "administrationId": 1011, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "OFB SD 66", - "termsNote": null - }, - { - "id": 10304, - "areaNote": "Pays de la Loire et Bretagne", - "administrationId": 1011, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "OFB Unité Spéciale Migrateurs 44", - "termsNote": null - }, - { - "id": 10338, - "areaNote": "Morbihan (56)", - "administrationId": 1011, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "OFB SD 56", - "termsNote": null - }, - { - "id": 10341, - "areaNote": "Corse-du-Sud (2A)", - "administrationId": 1011, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "OFB SD 2A", - "termsNote": null - }, - { - "id": 10347, - "areaNote": "Loire-Atlantique (44)", - "administrationId": 1011, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "OFB SD 44", - "termsNote": null - }, - { - "id": 1238, - "areaNote": null, - "administrationId": 1011, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Ofb Sd 22 (historique)", - "termsNote": null - }, - { - "id": 10367, - "areaNote": "Côtes-d’Armor (22)", - "administrationId": 1011, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "OFB SD 22", - "termsNote": null - }, - { - "id": 1330, - "areaNote": null, - "administrationId": 1011, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Ofb Sd 64 (historique)", - "termsNote": null - }, - { - "id": 1353, - "areaNote": null, - "administrationId": 1011, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Ofbsd 56 (historique)", - "termsNote": null - }, - { - "id": 10401, - "areaNote": "Guyane (973)", - "administrationId": 1011, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "OFB SD 973 Guyane", - "termsNote": null - }, - { - "id": 10407, - "areaNote": "Gard (30)", - "administrationId": 1011, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "OFB SD 30", - "termsNote": null - }, - { - "id": 1367, - "areaNote": null, - "administrationId": 1011, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Ofb Unité Spéciale Migrateurs Bretagne (historique)", - "termsNote": null - }, - { - "id": 1372, - "areaNote": null, - "administrationId": 1011, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Ofb Sd 14 [2] (historique)", - "termsNote": null - }, - { - "id": 10425, - "areaNote": "Guadeloupe (971)", - "administrationId": 1011, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "OFB SD 971 Guadeloupe", - "termsNote": null - }, - { - "id": 10426, - "areaNote": "Landes (40)", - "administrationId": 1011, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "OFB SD 40", - "termsNote": null - }, - { - "id": 10436, - "areaNote": "Ille-et-Vilaine (35)", - "administrationId": 1011, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "OFB SD 35", - "termsNote": null - }, - { - "id": 10440, - "areaNote": "Manche est Mer du Nord", - "administrationId": 1011, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "OFB Unité Spéciale Migrateurs – Normandie", - "termsNote": null - }, - { - "id": 10453, - "areaNote": "Finistère (29)", - "administrationId": 1011, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "OFB SD 29", - "termsNote": null - }, - { - "id": 10061, - "areaNote": "Normandie", - "administrationId": 1011, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "OFB Brigade Mobile d'Intervention – Normandie", - "termsNote": "Direction de la police des BMI de l’OFB" - }, - { - "id": 10512, - "areaNote": "Nouvelle Aquitaine", - "administrationId": 1011, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "OFB Brigade Mobile d'Intervention - Nouvelle-Aquitaine", - "termsNote": "Direction de la police des BMI de l’OFB" - }, - { - "id": 10454, - "areaNote": "National", - "administrationId": 1011, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "OFB Brigade Mobile d'Intervention – Bretagne", - "termsNote": "Direction de la police des BMI de l’OFB" - }, - { - "id": 1477, - "areaNote": null, - "administrationId": 1011, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Ofb Sd 59 (historique)", - "termsNote": null - }, - { - "id": 1488, - "areaNote": null, - "administrationId": 1011, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Ofbsd 29 (historique)", - "termsNote": null - }, - { - "id": 1495, - "areaNote": null, - "administrationId": 1011, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Ofbsd 62 (historique)", - "termsNote": null - }, - { - "id": 1512, - "areaNote": null, - "administrationId": 1011, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Ofb Mayotte (historique)", - "termsNote": null - }, - { - "id": 1514, - "areaNote": null, - "administrationId": 1011, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Ofb Sd974 Brigade Nature Soi (historique)", - "termsNote": null - }, - { - "id": 1237, - "areaNote": null, - "administrationId": 1011, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Ofb Sd 35 (historique)", - "termsNote": null - }, - { - "id": 1318, - "areaNote": null, - "administrationId": 1011, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Ofb Sd 22 Aerien (historique)", - "termsNote": null - }, - { - "id": 1323, - "areaNote": null, - "administrationId": 1011, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Ofb Sd 76 (historique)", - "termsNote": null - }, - { - "id": 1325, - "areaNote": null, - "administrationId": 1011, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Ofb Sd 62 (historique)", - "termsNote": null - }, - { - "id": 1328, - "areaNote": null, - "administrationId": 1011, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Ofb Sd 33 (historique)", - "termsNote": null - }, - { - "id": 1329, - "areaNote": null, - "administrationId": 1011, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Ofb Sd 40 (historique)", - "termsNote": null - }, - { - "id": 1331, - "areaNote": null, - "administrationId": 1011, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Ofb Sd 66 (historique)", - "termsNote": null - }, - { - "id": 1337, - "areaNote": null, - "administrationId": 1011, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Ofb Sd 06 (historique)", - "termsNote": null - }, - { - "id": 1338, - "areaNote": null, - "administrationId": 1011, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Ofb Sd 2a (historique)", - "termsNote": null - }, - { - "id": 1339, - "areaNote": null, - "administrationId": 1011, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Ofb Sd 2b (historique)", - "termsNote": null - }, - { - "id": 1354, - "areaNote": null, - "administrationId": 1011, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Ofb Sd 44 (historique)", - "termsNote": null - }, - { - "id": 1371, - "areaNote": null, - "administrationId": 1011, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Ofb Brigade Mobile D'Intervention Ofb 80 (historique)", - "termsNote": null - }, - { - "id": 1447, - "areaNote": null, - "administrationId": 1011, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Ofb Unité Spéciale Migrateurs Loire-Estuaire (historique)", - "termsNote": null - }, - { - "id": 1464, - "areaNote": null, - "administrationId": 1011, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Ofb Sd 50 (historique)", - "termsNote": null - }, - { - "id": 1469, - "areaNote": null, - "administrationId": 1011, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Ofb Sd 17 (historique)", - "termsNote": null - }, - { - "id": 1640, - "areaNote": null, - "administrationId": 1011, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Brigade Terrestre Bras Panon (historique)", - "termsNote": null - }, - { - "id": 1579, - "areaNote": null, - "administrationId": 1011, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Ofb Brigade Mobile Intervention Bretagne (historique)", - "termsNote": null - }, - { - "id": 1581, - "areaNote": null, - "administrationId": 1011, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Ofb Direction Regionale Normandie (historique)", - "termsNote": null - }, - { - "id": 1580, - "areaNote": null, - "administrationId": 1011, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Ofb Brigade Mobile Intervention Normandie (historique)", - "termsNote": null - }, - { - "id": 1592, - "areaNote": null, - "administrationId": 1011, - "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Ofb Brigade Mobile Intervention Med (historique)", - "termsNote": null - } - ], - "isArchived": false, - "name": "Office Français de la Biodiversité" - } - ] - } -} \ No newline at end of file From ae181ad5d71013dcb4ee4b8ddddc38a5d0e7e8c8 Mon Sep 17 00:00:00 2001 From: Ivan Gabriele Date: Mon, 28 Oct 2024 10:28:44 +0100 Subject: [PATCH 40/59] Add missing row id resolver in pno subscriber table --- .../PriorNotificationSubscriberTable/index.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/frontend/src/features/PriorNotification/components/PriorNotificationSubscriberTable/index.tsx b/frontend/src/features/PriorNotification/components/PriorNotificationSubscriberTable/index.tsx index f8d0cf1681..bbac920874 100644 --- a/frontend/src/features/PriorNotification/components/PriorNotificationSubscriberTable/index.tsx +++ b/frontend/src/features/PriorNotification/components/PriorNotificationSubscriberTable/index.tsx @@ -33,7 +33,14 @@ export function PriorNotificationSubscriberTable() { - + String(subscriber.controlUnit.id) + }} + /> ) } From be0d3fc25724bf30cdfcb50797a11f8255d6070f Mon Sep 17 00:00:00 2001 From: Ivan Gabriele Date: Mon, 28 Oct 2024 11:11:25 +0100 Subject: [PATCH 41/59] Close unsubscription confirmation modal on confirm in pno subscriber form --- .../FullPortSubscriptionsField.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/frontend/src/features/PriorNotification/components/PriorNotificationSubscriberForm/FullPortSubscriptionsField.tsx b/frontend/src/features/PriorNotification/components/PriorNotificationSubscriberForm/FullPortSubscriptionsField.tsx index cb3f572c3a..24af6164e7 100644 --- a/frontend/src/features/PriorNotification/components/PriorNotificationSubscriberForm/FullPortSubscriptionsField.tsx +++ b/frontend/src/features/PriorNotification/components/PriorNotificationSubscriberForm/FullPortSubscriptionsField.tsx @@ -49,6 +49,8 @@ export function FullPortSubscriptionsField({ return } + closeRemovalConfirmationModal() + onRemove(unsubscriptionConfirmationModalPortLocode, true) } From f3c08a53f2b57a85568934fba4ed5c4a7ea6b2e0 Mon Sep 17 00:00:00 2001 From: Ivan Gabriele Date: Tue, 29 Oct 2024 02:26:44 +0100 Subject: [PATCH 42/59] Add and update MonitorEnv API control unit stubs --- .../mappings/get-administrations.v1.json | 474 +++++ .../mappings/get-control_units.v2.json | 1739 ++++++----------- 2 files changed, 1068 insertions(+), 1145 deletions(-) create mode 100644 frontend/cypress/mappings/get-administrations.v1.json diff --git a/frontend/cypress/mappings/get-administrations.v1.json b/frontend/cypress/mappings/get-administrations.v1.json new file mode 100644 index 0000000000..4d5549ca25 --- /dev/null +++ b/frontend/cypress/mappings/get-administrations.v1.json @@ -0,0 +1,474 @@ +{ + "request": { + "method": "GET", + "url": "/api/v1/administrations" + }, + "response": { + "status": 200, + "headers": { + "Content-Type": "application/json", + "Access-Control-Allow-Origin": "*", + "Access-Control-Allow-Methods": "*" + }, + "jsonBody": [ + { "id": 1001, "controlUnitIds": [], "controlUnits": [], "isArchived": false, "name": "-" }, + { "id": 1007, "controlUnitIds": [], "controlUnits": [], "isArchived": false, "name": "AECP" }, + { "id": 1002, "controlUnitIds": [], "controlUnits": [], "isArchived": false, "name": "AFB" }, + { "id": 21, "controlUnitIds": [], "controlUnits": [], "isArchived": true, "name": "Administration Archivée 1" }, + { + "id": 22, + "controlUnitIds": [10033], + "controlUnits": [ + { + "id": 10033, + "areaNote": null, + "administrationId": 22, + "departmentAreaInseeCode": null, + "isArchived": true, + "name": "Unité archivée", + "termsNote": null + } + ], + "isArchived": true, + "name": "Administration Archivée 2" + }, + { "id": 5, "controlUnitIds": [], "controlUnits": [], "isArchived": false, "name": "Administration Étrangère" }, + { "id": 1, "controlUnitIds": [], "controlUnits": [], "isArchived": false, "name": "Affaires Maritimes" }, + { "id": 8, "controlUnitIds": [], "controlUnits": [], "isArchived": false, "name": "Armée Air" }, + { "id": 2003, "controlUnitIds": [], "controlUnits": [], "isArchived": false, "name": "Autre" }, + { + "id": 1012, + "controlUnitIds": [], + "controlUnits": [], + "isArchived": false, + "name": "Comité Régional des Pêches Maritimes" + }, + { + "id": 1003, + "controlUnitIds": [], + "controlUnits": [], + "isArchived": false, + "name": "Conservatoire du littoral" + }, + { + "id": 1005, + "controlUnitIds": [10000, 10001, 10002, 10003, 10004, 10005, 10006, 10007, 10008, 10032], + "controlUnits": [ + { + "id": 10000, + "areaNote": null, + "administrationId": 1005, + "departmentAreaInseeCode": null, + "isArchived": false, + "name": "Cultures marines – DDTM 40", + "termsNote": null + }, + { + "id": 10001, + "areaNote": null, + "administrationId": 1005, + "departmentAreaInseeCode": null, + "isArchived": false, + "name": "DML – DDTM 59", + "termsNote": null + }, + { + "id": 10002, + "areaNote": null, + "administrationId": 1005, + "departmentAreaInseeCode": null, + "isArchived": false, + "name": "DML 2A", + "termsNote": null + }, + { + "id": 10003, + "areaNote": null, + "administrationId": 1005, + "departmentAreaInseeCode": null, + "isArchived": false, + "name": "DPM – DDTM 14", + "termsNote": null + }, + { + "id": 10004, + "areaNote": null, + "administrationId": 1005, + "departmentAreaInseeCode": null, + "isArchived": false, + "name": "DPM – DDTM 35", + "termsNote": null + }, + { + "id": 10005, + "areaNote": null, + "administrationId": 1005, + "departmentAreaInseeCode": null, + "isArchived": false, + "name": "DPM – DDTM 44", + "termsNote": null + }, + { + "id": 10006, + "areaNote": null, + "administrationId": 1005, + "departmentAreaInseeCode": null, + "isArchived": false, + "name": "SML 33", + "termsNote": null + }, + { + "id": 10007, + "areaNote": null, + "administrationId": 1005, + "departmentAreaInseeCode": null, + "isArchived": false, + "name": "SML 50", + "termsNote": null + }, + { + "id": 10008, + "areaNote": null, + "administrationId": 1005, + "departmentAreaInseeCode": null, + "isArchived": false, + "name": "Police de l'eau – DDTM 11", + "termsNote": null + }, + { + "id": 10032, + "areaNote": null, + "administrationId": 1005, + "departmentAreaInseeCode": null, + "isArchived": false, + "name": "Cultures marines – DDTM 30", + "termsNote": null + } + ], + "isArchived": false, + "name": "DDTM" + }, + { "id": 1016, "controlUnitIds": [], "controlUnits": [], "isArchived": false, "name": "DEAL Réunion" }, + { "id": 2001, "controlUnitIds": [], "controlUnits": [], "isArchived": false, "name": "DGTM" }, + { + "id": 1009, + "controlUnitIds": [10011, 10012, 10121, 10080], + "controlUnits": [ + { + "id": 10011, + "areaNote": null, + "administrationId": 1009, + "departmentAreaInseeCode": null, + "isArchived": false, + "name": "Cross Etel", + "termsNote": null + }, + { + "id": 10012, + "areaNote": null, + "administrationId": 1009, + "departmentAreaInseeCode": null, + "isArchived": false, + "name": "Cross Gris Nez", + "termsNote": null + }, + { + "id": 10121, + "areaNote": null, + "administrationId": 1009, + "departmentAreaInseeCode": null, + "isArchived": false, + "name": "PAM Jeanne Barret", + "termsNote": null + }, + { + "id": 10080, + "areaNote": null, + "administrationId": 1009, + "departmentAreaInseeCode": null, + "isArchived": false, + "name": "PAM Themis", + "termsNote": null + } + ], + "isArchived": false, + "name": "DIRM / DM" + }, + { "id": 2000, "controlUnitIds": [], "controlUnits": [], "isArchived": false, "name": "DMLC" }, + { + "id": 1008, + "controlUnitIds": [10018], + "controlUnits": [ + { + "id": 10018, + "areaNote": null, + "administrationId": 1008, + "departmentAreaInseeCode": null, + "isArchived": false, + "name": "DREAL Pays-de-La-Loire", + "termsNote": null + } + ], + "isArchived": false, + "name": "DREAL / DEAL" + }, + { + "id": 2, + "controlUnitIds": [10013, 10014, 10015, 10016, 10017], + "controlUnits": [ + { + "id": 10013, + "areaNote": null, + "administrationId": 2, + "departmentAreaInseeCode": null, + "isArchived": true, + "name": "BGC Ajaccio", + "termsNote": null + }, + { + "id": 10014, + "areaNote": null, + "administrationId": 2, + "departmentAreaInseeCode": null, + "isArchived": true, + "name": "BGC Bastia", + "termsNote": null + }, + { + "id": 10015, + "areaNote": null, + "administrationId": 2, + "departmentAreaInseeCode": null, + "isArchived": false, + "name": "BSN Ste Maxime", + "termsNote": null + }, + { + "id": 10016, + "areaNote": null, + "administrationId": 2, + "departmentAreaInseeCode": null, + "isArchived": false, + "name": "DF 25 Libecciu", + "termsNote": null + }, + { + "id": 10017, + "areaNote": null, + "administrationId": 2, + "departmentAreaInseeCode": null, + "isArchived": false, + "name": "DF 61 Port-de-Bouc", + "termsNote": null + } + ], + "isArchived": false, + "name": "Douane" + }, + { "id": 2006, "controlUnitIds": [], "controlUnits": [], "isArchived": false, "name": "FOSIT" }, + { + "id": 4, + "controlUnitIds": [10019], + "controlUnits": [ + { + "id": 10019, + "areaNote": null, + "administrationId": 4, + "departmentAreaInseeCode": null, + "isArchived": false, + "name": "P602 Verdon", + "termsNote": null + } + ], + "isArchived": false, + "name": "Gendarmerie Maritime" + }, + { + "id": 6, + "controlUnitIds": [10020, 10021], + "controlUnits": [ + { + "id": 10020, + "areaNote": null, + "administrationId": 6, + "departmentAreaInseeCode": null, + "isArchived": false, + "name": "BN Toulon", + "termsNote": null + }, + { + "id": 10021, + "areaNote": null, + "administrationId": 6, + "departmentAreaInseeCode": null, + "isArchived": false, + "name": "Brigade fluviale de Rouen", + "termsNote": null + } + ], + "isArchived": false, + "name": "Gendarmerie Nationale" + }, + { + "id": 1013, + "controlUnitIds": [10022], + "controlUnits": [ + { + "id": 10022, + "areaNote": null, + "administrationId": 1013, + "departmentAreaInseeCode": null, + "isArchived": false, + "name": "Natura 2000 Côte Bleue Marine", + "termsNote": null + } + ], + "isArchived": false, + "name": "Gestionnaire AMP" + }, + { "id": 1000, "controlUnitIds": [], "controlUnits": [], "isArchived": false, "name": "Inter administration" }, + { + "id": 3, + "controlUnitIds": [10023], + "controlUnits": [ + { + "id": 10023, + "areaNote": null, + "administrationId": 3, + "departmentAreaInseeCode": null, + "isArchived": false, + "name": "A636 Maïto", + "termsNote": null + } + ], + "isArchived": false, + "name": "Marine Nationale" + }, + { "id": 9, "controlUnitIds": [], "controlUnits": [], "isArchived": false, "name": "ONCFS" }, + { + "id": 1011, + "controlUnitIds": [10024, 10025], + "controlUnits": [ + { + "id": 10024, + "areaNote": null, + "administrationId": 1011, + "departmentAreaInseeCode": null, + "isArchived": false, + "name": "OFB Sd 85", + "termsNote": null + }, + { + "id": 10025, + "areaNote": null, + "administrationId": 1011, + "departmentAreaInseeCode": null, + "isArchived": false, + "name": "OFB SD974 Brigade Nature – SOI", + "termsNote": null + } + ], + "isArchived": false, + "name": "Office Français de la Biodiversité" + }, + { + "id": 10, + "controlUnitIds": [10027], + "controlUnits": [ + { + "id": 10027, + "areaNote": null, + "administrationId": 10, + "departmentAreaInseeCode": null, + "isArchived": false, + "name": "Parc National de Guadeloupe", + "termsNote": null + } + ], + "isArchived": false, + "name": "Parcs Nationaux" + }, + { + "id": 1006, + "controlUnitIds": [10028], + "controlUnits": [ + { + "id": 10028, + "areaNote": null, + "administrationId": 1006, + "departmentAreaInseeCode": null, + "isArchived": false, + "name": "PNM Martinique", + "termsNote": null + } + ], + "isArchived": false, + "name": "Parcs Naturels Marins" + }, + { + "id": 1014, + "controlUnitIds": [10026], + "controlUnits": [ + { + "id": 10026, + "areaNote": null, + "administrationId": 1014, + "departmentAreaInseeCode": null, + "isArchived": false, + "name": "Parc Naturel Régional Martinique", + "termsNote": null + } + ], + "isArchived": false, + "name": "Parcs Naturels Régionaux" + }, + { "id": 2002, "controlUnitIds": [], "controlUnits": [], "isArchived": false, "name": "Parquet" }, + { + "id": 1015, + "controlUnitIds": [10029], + "controlUnits": [ + { + "id": 10029, + "areaNote": null, + "administrationId": 1015, + "departmentAreaInseeCode": null, + "isArchived": false, + "name": "Police Municipale Le Marin 972", + "termsNote": null + } + ], + "isArchived": false, + "name": "Police Municipale" + }, + { "id": 7, "controlUnitIds": [], "controlUnits": [], "isArchived": false, "name": "Police Nationale" }, + { "id": 2005, "controlUnitIds": [], "controlUnits": [], "isArchived": false, "name": "Port" }, + { + "id": 1004, + "controlUnitIds": [10030, 10031], + "controlUnits": [ + { + "id": 10030, + "areaNote": null, + "administrationId": 1004, + "departmentAreaInseeCode": null, + "isArchived": false, + "name": "Réserve Naturelle de L'Ilot M'Bouzi", + "termsNote": null + }, + { + "id": 10031, + "areaNote": null, + "administrationId": 1004, + "departmentAreaInseeCode": null, + "isArchived": false, + "name": "Réserve Naturelle 7 Iles", + "termsNote": null + } + ], + "isArchived": false, + "name": "Réserves Naturelles" + }, + { "id": 2004, "controlUnitIds": [], "controlUnits": [], "isArchived": false, "name": "Sécurité Civile" } + ] + } +} diff --git a/frontend/cypress/mappings/get-control_units.v2.json b/frontend/cypress/mappings/get-control_units.v2.json index 043b5ae582..ec3f922a29 100644 --- a/frontend/cypress/mappings/get-control_units.v2.json +++ b/frontend/cypress/mappings/get-control_units.v2.json @@ -12,1381 +12,830 @@ }, "jsonBody": [ { - "id": 10121, - "areaNote": "Manche Est Mer du Nord", - "administration": { - "id": 1009, - "isArchived": false, - "name": "DIRM / DM" - }, + "id": 10023, + "areaNote": null, + "administration": { "id": 3, "isArchived": false, "name": "Marine Nationale" }, + "administrationId": 3, + "controlUnitContactIds": [], + "controlUnitContacts": [], + "controlUnitResourceIds": [], + "controlUnitResources": [], + "departmentArea": null, + "departmentAreaInseeCode": null, + "isArchived": false, + "name": "A636 Maïto", + "termsNote": null + }, + { + "id": 10013, + "areaNote": null, + "administration": { "id": 2, "isArchived": false, "name": "Douane" }, + "administrationId": 2, + "controlUnitContactIds": [], + "controlUnitContacts": [], + "controlUnitResourceIds": [], + "controlUnitResources": [], + "departmentArea": null, + "departmentAreaInseeCode": null, + "isArchived": true, + "name": "BGC Ajaccio", + "termsNote": null + }, + { + "id": 10014, + "areaNote": null, + "administration": { "id": 2, "isArchived": false, "name": "Douane" }, + "administrationId": 2, + "controlUnitContactIds": [], + "controlUnitContacts": [], + "controlUnitResourceIds": [], + "controlUnitResources": [], + "departmentArea": null, + "departmentAreaInseeCode": null, + "isArchived": true, + "name": "BGC Bastia", + "termsNote": null + }, + { + "id": 10020, + "areaNote": null, + "administration": { "id": 6, "isArchived": false, "name": "Gendarmerie Nationale" }, + "administrationId": 6, + "controlUnitContactIds": [], + "controlUnitContacts": [], + "controlUnitResourceIds": [], + "controlUnitResources": [], + "departmentArea": null, + "departmentAreaInseeCode": null, + "isArchived": false, + "name": "BN Toulon", + "termsNote": null + }, + { + "id": 10015, + "areaNote": null, + "administration": { "id": 2, "isArchived": false, "name": "Douane" }, + "administrationId": 2, + "controlUnitContactIds": [], + "controlUnitContacts": [], + "controlUnitResourceIds": [], + "controlUnitResources": [], + "departmentArea": null, + "departmentAreaInseeCode": null, + "isArchived": false, + "name": "BSN Ste Maxime", + "termsNote": null + }, + { + "id": 10021, + "areaNote": null, + "administration": { "id": 6, "isArchived": false, "name": "Gendarmerie Nationale" }, + "administrationId": 6, + "controlUnitContactIds": [], + "controlUnitContacts": [], + "controlUnitResourceIds": [], + "controlUnitResources": [], + "departmentArea": null, + "departmentAreaInseeCode": null, + "isArchived": false, + "name": "Brigade fluviale de Rouen", + "termsNote": null + }, + { + "id": 10011, + "areaNote": null, + "administration": { "id": 1009, "isArchived": false, "name": "DIRM / DM" }, "administrationId": 1009, - "controlUnitContactIds": [ - 288, - 289, - 287, - 290, - 284, - 285, - 286, - 283, - 281, - 282 - ], - "controlUnitContacts": [ - { - "id": 288, - "controlUnitId": 10121, - "email": "pam-jeanne-barret.dirm-memn@developpement-durable.gouv.fr", - "name": "UNKNOWN", - "phone": "+47 23 41 26 00" - }, - { - "id": 289, - "controlUnitId": 10121, - "email": "pam-jeanne-barret.dirm-memn@developpement-durable.gouv.fr", - "name": "UNKNOWN", - "phone": "+47 23 41 26 01" - }, - { - "id": 287, - "controlUnitId": 10121, - "email": null, - "name": "ONBOARD_PHONE", - "phone": "00 47 2341261" - }, - { - "id": 290, - "controlUnitId": 10121, - "email": "pam-jeanne-barret.dirm-memn@developpement-durable.gouv.fr", - "name": "ONBOARD_PHONE", - "phone": "+881677110865" - }, - { - "id": 284, - "controlUnitId": 10121, - "email": "pam-jeanne-barret.dirm-memn@developpement-durable.gouv.fr", - "name": "COMMANDER_B", - "phone": "06 50 38 02 13" - }, - { - "id": 285, - "controlUnitId": 10121, - "email": null, - "name": "COMMANDER_A", - "phone": "06 65 51 86 24" - }, - { - "id": 286, - "controlUnitId": 10121, - "email": null, - "name": "COMMANDER_B", - "phone": "06 50 38 02 13" - }, - { - "id": 283, - "controlUnitId": 10121, - "email": "pam-jeanne-barret.dirm-memn@developpement-durable.gouv.fr", - "name": "COMMANDER_A", - "phone": "06 65 51 86 24" - }, - { - "id": 281, - "controlUnitId": 10121, - "email": "alexandre.eveno@developpement-durable.gouv.fr", - "name": "OPERATIONAL_CENTER", - "phone": "02 35 43 38 70" - }, - { - "id": 282, - "controlUnitId": 10121, - "email": "alexandre.eveno@developpement-durable.gouv.fr", - "name": "OPERATIONAL_CENTER", - "phone": "02 76 89 98 97" - } - ], - "controlUnitResourceIds": [ - 561, - 175 - ], - "controlUnitResources": [ - { - "id": 561, - "controlUnit": { - "id": 10121, - "areaNote": "Manche Est Mer du Nord", - "administrationId": 1009, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "PAM Jeanne Barret", - "termsNote": "Division contrôle de la DIRM MEMN" - }, - "controlUnitId": 10121, - "isArchived": false, - "name": "Jeanne Barret", - "note": null, - "photo": null, - "station": { - "id": 136, - "latitude": 49.49437, - "longitude": 0.107929, - "name": "Le Havre" - }, - "stationId": 136, - "type": "PATROL_BOAT" - }, - { - "id": 175, - "controlUnit": { - "id": 10121, - "areaNote": "Manche Est Mer du Nord", - "administrationId": 1009, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "PAM Jeanne Barret", - "termsNote": "Division contrôle de la DIRM MEMN" - }, - "controlUnitId": 10121, - "isArchived": false, - "name": "Voiture", - "note": null, - "photo": null, - "station": { - "id": 136, - "latitude": 49.49437, - "longitude": 0.107929, - "name": "Le Havre" - }, - "stationId": 136, - "type": "CAR" - } - ], + "controlUnitContactIds": [], + "controlUnitContacts": [], + "controlUnitResourceIds": [], + "controlUnitResources": [], "departmentArea": null, "departmentAreaInseeCode": null, "isArchived": false, - "name": "PAM Jeanne Barret", - "termsNote": "Division contrôle de la DIRM MEMN" + "name": "Cross Etel", + "termsNote": null }, { - "id": 10141, - "areaNote": "Méditerranée", - "administration": { - "id": 1009, - "isArchived": false, - "name": "DIRM / DM" - }, + "id": 10012, + "areaNote": null, + "administration": { "id": 1009, "isArchived": false, "name": "DIRM / DM" }, "administrationId": 1009, - "controlUnitContactIds": [ - 339, - 335, - 336, - 333, - 334, - 337, - 338 - ], - "controlUnitContacts": [ - { - "id": 339, - "controlUnitId": 10141, - "email": null, - "name": "ONBOARD_PHONE", - "phone": "+881 677 121 122" - }, - { - "id": 335, - "controlUnitId": 10141, - "email": "pam.dirm-med@mer.gouv.fr", - "name": "COMMANDER_A", - "phone": "07 64 45 13 62" - }, - { - "id": 336, - "controlUnitId": 10141, - "email": "pam.dirm-med@mer.gouv.fr", - "name": "COMMANDER_B", - "phone": "06 19 42 86 03" - }, - { - "id": 333, - "controlUnitId": 10141, - "email": "aurelia.sargeot@mer.gouv.fr", - "name": "OPERATIONAL_CENTER", - "phone": "04 86 94 67 48" - }, - { - "id": 334, - "controlUnitId": 10141, - "email": "aurelia.sargeot@mer.gouv.fr", - "name": "OPERATIONAL_CENTER", - "phone": "06 69 17 61 82" - }, - { - "id": 337, - "controlUnitId": 10141, - "email": null, - "name": "PERMANENT_CONTACT_ONBOARD", - "phone": "+47 23 41 25 84" - }, - { - "id": 338, - "controlUnitId": 10141, - "email": null, - "name": "PERMANENT_CONTACT_ONBOARD", - "phone": "+47 23 41 25 85" - } - ], - "controlUnitResourceIds": [ - 329, - 64 - ], - "controlUnitResources": [ - { - "id": 329, - "controlUnit": { - "id": 10141, - "areaNote": "Méditerranée", - "administrationId": 1009, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "PAM Gyptis", - "termsNote": "Division contrôle de la DIRM MED" - }, - "controlUnitId": 10141, - "isArchived": false, - "name": "Gyptis", - "note": null, - "photo": null, - "station": { - "id": 164, - "latitude": 43.296482, - "longitude": 5.36978, - "name": "Marseille" - }, - "stationId": 164, - "type": "PATROL_BOAT" - }, - { - "id": 64, - "controlUnit": { - "id": 10141, - "areaNote": "Méditerranée", - "administrationId": 1009, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "PAM Gyptis", - "termsNote": "Division contrôle de la DIRM MED" - }, - "controlUnitId": 10141, - "isArchived": false, - "name": "Voiture", - "note": null, - "photo": null, - "station": { - "id": 164, - "latitude": 43.296482, - "longitude": 5.36978, - "name": "Marseille" - }, - "stationId": 164, - "type": "CAR" - } - ], + "controlUnitContactIds": [], + "controlUnitContacts": [], + "controlUnitResourceIds": [], + "controlUnitResources": [], "departmentArea": null, "departmentAreaInseeCode": null, "isArchived": false, - "name": "PAM Gyptis", - "termsNote": "Division contrôle de la DIRM MED" + "name": "Cross Gris Nez", + "termsNote": null }, { - "id": 10484, - "areaNote": "Morbihan (56)", - "administration": { - "id": 2, - "isArchived": false, - "name": "Douane" - }, - "administrationId": 2, - "controlUnitContactIds": [ - 1076, - 1073, - 1074, - 1075 - ], + "id": 10032, + "areaNote": null, + "administration": { "id": 1005, "isArchived": false, "name": "DDTM" }, + "administrationId": 1005, + "controlUnitContactIds": [], + "controlUnitContacts": [], + "controlUnitResourceIds": [], + "controlUnitResources": [], + "departmentArea": null, + "departmentAreaInseeCode": null, + "isArchived": false, + "name": "Cultures marines – DDTM 30", + "termsNote": null + }, + { + "id": 10000, + "areaNote": null, + "administration": { "id": 1005, "isArchived": false, "name": "DDTM" }, + "administrationId": 1005, + "controlUnitContactIds": [1, 2], "controlUnitContacts": [ { - "id": 1076, - "controlUnitId": 10484, - "email": "bgc-lorient@douane.finances.gouv.fr", - "name": "UNKNOWN", - "phone": "09 70 27 46 12" - }, - { - "id": 1073, - "controlUnitId": 10484, - "email": "sgcd-nantes-codm@douane.finances.gouv.fr", - "name": "OPERATIONAL_CENTER", - "phone": "06 64 57 64 04" - }, - { - "id": 1074, - "controlUnitId": 10484, - "email": "sgcd-nantes-codm@douane.finances.gouv.fr", - "name": "OPERATIONAL_CENTER", - "phone": "09 70 27 51 94" + "id": 1, + "controlUnitId": 10000, + "email": "email_1", + "isEmailSubscriptionContact": true, + "isSmsSubscriptionContact": false, + "name": "Contact 1", + "phone": "0601xxxxxx" }, { - "id": 1075, - "controlUnitId": 10484, + "id": 2, + "controlUnitId": 10000, "email": null, - "name": "PERMANENT_CONTACT_ONBOARD", - "phone": "06 64 57 64 58" + "isEmailSubscriptionContact": false, + "isSmsSubscriptionContact": true, + "name": "Contact 2", + "phone": "0602xxxxxx" } ], - "controlUnitResourceIds": [ - 553 - ], + "controlUnitResourceIds": [1, 2, 13, 14], "controlUnitResources": [ { - "id": 553, + "id": 1, "controlUnit": { - "id": 10484, - "areaNote": "Morbihan (56)", - "administrationId": 2, + "id": 10000, + "areaNote": null, + "administrationId": 1005, "departmentAreaInseeCode": null, "isArchived": false, - "name": "BGC Lorient - DF 36 Kan An Avel", - "termsNote": "COD Manche Mer du Nord Atlantique" + "name": "Cultures marines – DDTM 40", + "termsNote": null }, - "controlUnitId": 10484, + "controlUnitId": 10000, "isArchived": false, - "name": "DF 36 Kan An Avel", + "name": "Semi-rigide 1", "note": null, "photo": null, - "station": { - "id": 153, - "latitude": 47.7482524, - "longitude": -3.3702449, - "name": "Lorient" - }, - "stationId": 153, - "type": "FAST_BOAT" - } - ], - "departmentArea": null, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "BGC Lorient - DF 36 Kan An Avel", - "termsNote": "COD Manche Mer du Nord Atlantique" - }, - { - "id": 10336, - "areaNote": "Morbihan (56) – Loire-Atlantique (44)", - "administration": { - "id": 4, - "isArchived": false, - "name": "Gendarmerie Maritime" - }, - "administrationId": 4, - "controlUnitContactIds": [ - 727, - 728, - 729, - 730, - 726 - ], - "controlUnitContacts": [ - { - "id": 727, - "controlUnitId": 10336, - "email": "bsl.lorient@gendarmerie.defense.gouv.fr", - "name": "UNKNOWN", - "phone": "02 97 12 40 67" - }, - { - "id": 728, - "controlUnitId": 10336, - "email": "bsl.lorient@gendarmerie.defense.gouv.fr", - "name": "UNKNOWN", - "phone": "02 97 12 40 67" - }, - { - "id": 729, - "controlUnitId": 10336, - "email": "bsl.lorient@gendarmerie.defense.gouv.fr", - "name": "UNKNOWN", - "phone": "06 72 95 29 02" - }, - { - "id": 730, - "controlUnitId": 10336, - "email": "bsl.lorient@gendarmerie.defense.gouv.fr", - "name": "UNKNOWN", - "phone": "06 72 95 29 03" + "station": { "id": 1, "latitude": 43.295765, "longitude": 5.375486, "name": "Marseille" }, + "stationId": 1, + "type": "BARGE" }, { - "id": 726, - "controlUnitId": 10336, - "email": "ggmaratlan@gendarmerie.defense.gouv.fr", - "name": "OPERATIONAL_CENTER", - "phone": "02 98 22 22 17" - } - ], - "controlUnitResourceIds": [ - 353, - 90, - 1042 - ], - "controlUnitResources": [ - { - "id": 353, + "id": 2, "controlUnit": { - "id": 10336, - "areaNote": "Morbihan (56) – Loire-Atlantique (44)", - "administrationId": 4, + "id": 10000, + "areaNote": null, + "administrationId": 1005, "departmentAreaInseeCode": null, "isArchived": false, - "name": "BSL Lorient", - "termsNote": "CORGMAR Atlantique" + "name": "Cultures marines – DDTM 40", + "termsNote": null }, - "controlUnitId": 10336, + "controlUnitId": 10000, "isArchived": false, - "name": "BSL Lorient", + "name": "Semi-rigide 2", "note": null, "photo": null, - "station": { - "id": 153, - "latitude": 47.7482524, - "longitude": -3.3702449, - "name": "Lorient" - }, - "stationId": 153, - "type": "SEMI_RIGID" + "station": { "id": 1, "latitude": 43.295765, "longitude": 5.375486, "name": "Marseille" }, + "stationId": 1, + "type": "BARGE" }, { - "id": 90, + "id": 13, "controlUnit": { - "id": 10336, - "areaNote": "Morbihan (56) – Loire-Atlantique (44)", - "administrationId": 4, + "id": 10000, + "areaNote": null, + "administrationId": 1005, "departmentAreaInseeCode": null, "isArchived": false, - "name": "BSL Lorient", - "termsNote": "CORGMAR Atlantique" + "name": "Cultures marines – DDTM 40", + "termsNote": null }, - "controlUnitId": 10336, - "isArchived": false, + "controlUnitId": 10000, + "isArchived": true, "name": "Voiture", "note": null, "photo": null, - "station": { - "id": 153, - "latitude": 47.7482524, - "longitude": -3.3702449, - "name": "Lorient" - }, - "stationId": 153, + "station": { "id": 1, "latitude": 43.295765, "longitude": 5.375486, "name": "Marseille" }, + "stationId": 1, "type": "CAR" }, { - "id": 1042, + "id": 14, "controlUnit": { - "id": 10336, - "areaNote": "Morbihan (56) – Loire-Atlantique (44)", - "administrationId": 4, + "id": 10000, + "areaNote": null, + "administrationId": 1005, "departmentAreaInseeCode": null, "isArchived": false, - "name": "BSL Lorient", - "termsNote": "CORGMAR Atlantique" + "name": "Cultures marines – DDTM 40", + "termsNote": null }, - "controlUnitId": 10336, + "controlUnitId": 10000, "isArchived": false, - "name": "Moto", + "name": "Drône", "note": null, "photo": null, - "station": { - "id": 153, - "latitude": 47.7482524, - "longitude": -3.3702449, - "name": "Lorient" - }, - "stationId": 153, - "type": "MOTORCYCLE" + "station": { "id": 2, "latitude": 48.648105, "longitude": -2.013144, "name": "Saint-Malo" }, + "stationId": 2, + "type": "DRONE" } ], "departmentArea": null, "departmentAreaInseeCode": null, "isArchived": false, - "name": "BSL Lorient", - "termsNote": "CORGMAR Atlantique" + "name": "Cultures marines – DDTM 40", + "termsNote": null }, { - "id": 10455, - "areaNote": "Golfe de Gascogne – Bretagne", - "administration": { - "id": 4, - "isArchived": false, - "name": "Gendarmerie Maritime" - }, - "administrationId": 4, - "controlUnitContactIds": [ - 1018, - 1019, - 1015, - 1016, - 1017 - ], - "controlUnitContacts": [ - { - "id": 1018, - "controlUnitId": 10455, - "email": "pgmarc720.lorient@gendarmerie.defense.gouv.fr", - "name": "UNKNOWN", - "phone": "06 84 76 97 62" - }, - { - "id": 1019, - "controlUnitId": 10455, - "email": "pgmarc720.lorient@gendarmerie.defense.gouv.fr", - "name": "UNKNOWN", - "phone": "06 85 72 02 20" - }, - { - "id": 1015, - "controlUnitId": 10455, - "email": "ggmaratlan@gendarmerie.defense.gouv.fr", - "name": "OPERATIONAL_CENTER", - "phone": "02 98 22 22 17" - }, - { - "id": 1016, - "controlUnitId": 10455, - "email": null, - "name": "PERMANENT_CONTACT_ONBOARD", - "phone": "06 84 76 97 62" - }, - { - "id": 1017, - "controlUnitId": 10455, - "email": null, - "name": "PERMANENT_CONTACT_ONBOARD", - "phone": "06 85 72 02 20" - } - ], - "controlUnitResourceIds": [ - 189, - 251 - ], - "controlUnitResources": [ - { - "id": 189, - "controlUnit": { - "id": 10455, - "areaNote": "Golfe de Gascogne – Bretagne", - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "PGMAR Lorient - P720 Geranium", - "termsNote": "CORGMAR Atlantique" - }, - "controlUnitId": 10455, - "isArchived": false, - "name": "P720 Geranium", - "note": null, - "photo": null, - "station": { - "id": 153, - "latitude": 47.7482524, - "longitude": -3.3702449, - "name": "Lorient" - }, - "stationId": 153, - "type": "PATROL_BOAT" - }, - { - "id": 251, - "controlUnit": { - "id": 10455, - "areaNote": "Golfe de Gascogne – Bretagne", - "administrationId": 4, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "PGMAR Lorient - P720 Geranium", - "termsNote": "CORGMAR Atlantique" - }, - "controlUnitId": 10455, - "isArchived": false, - "name": "Voiture", - "note": null, - "photo": null, - "station": { - "id": 153, - "latitude": 47.7482524, - "longitude": -3.3702449, - "name": "Lorient" - }, - "stationId": 153, - "type": "CAR" - } - ], + "id": 10016, + "areaNote": null, + "administration": { "id": 2, "isArchived": false, "name": "Douane" }, + "administrationId": 2, + "controlUnitContactIds": [], + "controlUnitContacts": [], + "controlUnitResourceIds": [], + "controlUnitResources": [], "departmentArea": null, "departmentAreaInseeCode": null, "isArchived": false, - "name": "PGMAR Lorient - P720 Geranium", - "termsNote": "CORGMAR Atlantique" + "name": "DF 25 Libecciu", + "termsNote": null }, { - "id": 1277, + "id": 10017, "areaNote": null, - "administration": { - "id": 1005, - "isArchived": false, - "name": "DDTM" - }, - "administrationId": 1005, + "administration": { "id": 2, "isArchived": false, "name": "Douane" }, + "administrationId": 2, "controlUnitContactIds": [], "controlUnitContacts": [], "controlUnitResourceIds": [], "controlUnitResources": [], "departmentArea": null, "departmentAreaInseeCode": null, - "isArchived": true, - "name": "Cultures Marines - Ddtm 56 (historique)", + "isArchived": false, + "name": "DF 61 Port-de-Bouc", "termsNote": null }, { - "id": 10499, - "areaNote": "Morbihan (56)", - "administration": { - "id": 1005, - "isArchived": false, - "name": "DDTM" - }, + "id": 10002, + "areaNote": null, + "administration": { "id": 1005, "isArchived": false, "name": "DDTM" }, "administrationId": 1005, - "controlUnitContactIds": [ - 1121, - 1122 - ], - "controlUnitContacts": [ - { - "id": 1121, - "controlUnitId": 10499, - "email": "ddtm-samel@morbihan.gouv.fr", - "name": "UNKNOWN", - "phone": "02 56 63 75 32" - }, - { - "id": 1122, - "controlUnitId": 10499, - "email": "ddtm-samel@morbihan.gouv.fr", - "name": "UNKNOWN", - "phone": "02 97 64 85 06" - } - ], - "controlUnitResourceIds": [ - 314, - 323, - 1208 - ], + "controlUnitContactIds": [], + "controlUnitContacts": [], + "controlUnitResourceIds": [3, 4, 5], "controlUnitResources": [ { - "id": 314, + "id": 3, "controlUnit": { - "id": 10499, - "areaNote": "Morbihan (56)", + "id": 10002, + "areaNote": null, "administrationId": 1005, "departmentAreaInseeCode": null, "isArchived": false, - "name": "Cultures marines 56", + "name": "DML 2A", "termsNote": null }, - "controlUnitId": 10499, + "controlUnitId": 10002, "isArchived": false, - "name": "Brezel - FAH 7185", + "name": "Semi-rigide 1", "note": null, "photo": null, - "station": { - "id": 245, - "latitude": 47.658236, - "longitude": -2.760847, - "name": "Vannes" - }, - "stationId": 245, - "type": "FAST_BOAT" + "station": { "id": 2, "latitude": 48.648105, "longitude": -2.013144, "name": "Saint-Malo" }, + "stationId": 2, + "type": "BARGE" }, { - "id": 323, + "id": 4, "controlUnit": { - "id": 10499, - "areaNote": "Morbihan (56)", + "id": 10002, + "areaNote": null, "administrationId": 1005, "departmentAreaInseeCode": null, "isArchived": false, - "name": "Cultures marines 56", + "name": "DML 2A", "termsNote": null }, - "controlUnitId": 10499, + "controlUnitId": 10002, "isArchived": false, - "name": "Voiture", + "name": "Semi-rigide 2", "note": null, "photo": null, - "station": { - "id": 245, - "latitude": 47.658236, - "longitude": -2.760847, - "name": "Vannes" - }, - "stationId": 245, - "type": "CAR" + "station": { "id": 2, "latitude": 48.648105, "longitude": -2.013144, "name": "Saint-Malo" }, + "stationId": 2, + "type": "BARGE" }, { - "id": 1208, + "id": 5, "controlUnit": { - "id": 10499, - "areaNote": "Morbihan (56)", + "id": 10002, + "areaNote": null, "administrationId": 1005, "departmentAreaInseeCode": null, "isArchived": false, - "name": "Cultures marines 56", + "name": "DML 2A", "termsNote": null }, - "controlUnitId": 10499, + "controlUnitId": 10002, "isArchived": false, "name": "Voiture", "note": null, "photo": null, - "station": { - "id": 8, - "latitude": 47.66649100000001, - "longitude": -2.983767, - "name": "Auray" - }, - "stationId": 8, + "station": { "id": 3, "latitude": 51.035534, "longitude": 2.372845, "name": "Dunkerque" }, + "stationId": 3, "type": "CAR" } ], "departmentArea": null, "departmentAreaInseeCode": null, "isArchived": false, - "name": "Cultures marines 56", + "name": "DML 2A", "termsNote": null }, { - "id": 10454, - "areaNote": "National", - "administration": { - "id": 1011, - "isArchived": false, - "name": "Office Français de la Biodiversité" - }, - "administrationId": 1011, - "controlUnitContactIds": [ - 1014, - 1012, - 1013 - ], - "controlUnitContacts": [ - { - "id": 1014, - "controlUnitId": 10454, - "email": "fabrice.bernard.bmibpl@ofb.gouv.fr", - "name": "UNKNOWN", - "phone": "06 27 02 56 25" - }, - { - "id": 1012, - "controlUnitId": 10454, - "email": "sebastien.perusson@ofb.gouv.fr", - "name": "OPERATIONAL_CENTER", - "phone": "02 38 45 99 71" - }, - { - "id": 1013, - "controlUnitId": 10454, - "email": "sebastien.perusson@ofb.gouv.fr", - "name": "OPERATIONAL_CENTER", - "phone": "06 25 03 23 81" - } - ], - "controlUnitResourceIds": [ - 516 - ], - "controlUnitResources": [ - { - "id": 516, - "controlUnit": { - "id": 10454, - "areaNote": "National", - "administrationId": 1011, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "OFB Brigade Mobile d'Intervention – Bretagne", - "termsNote": "Direction de la police des BMI de l’OFB" - }, - "controlUnitId": 10454, - "isArchived": false, - "name": "Voiture", - "note": null, - "photo": null, - "station": { - "id": 245, - "latitude": 47.658236, - "longitude": -2.760847, - "name": "Vannes" - }, - "stationId": 245, - "type": "CAR" - } - ], + "id": 10001, + "areaNote": null, + "administration": { "id": 1005, "isArchived": false, "name": "DDTM" }, + "administrationId": 1005, + "controlUnitContactIds": [], + "controlUnitContacts": [], + "controlUnitResourceIds": [], + "controlUnitResources": [], "departmentArea": null, "departmentAreaInseeCode": null, "isArchived": false, - "name": "OFB Brigade Mobile d'Intervention – Bretagne", - "termsNote": "Direction de la police des BMI de l’OFB" + "name": "DML – DDTM 59", + "termsNote": null }, { - "id": 10338, - "areaNote": "Morbihan (56)", - "administration": { - "id": 1011, - "isArchived": false, - "name": "Office Français de la Biodiversité" - }, - "administrationId": 1011, - "controlUnitContactIds": [ - 733 - ], + "id": 10003, + "areaNote": null, + "administration": { "id": 1005, "isArchived": false, "name": "DDTM" }, + "administrationId": 1005, + "controlUnitContactIds": [3], "controlUnitContacts": [ { - "id": 733, - "controlUnitId": 10338, - "email": "sd56@ofb.gouv.fr", - "name": "UNKNOWN", - "phone": "02 97 47 02 83" + "id": 3, + "controlUnitId": 10003, + "email": "email_3", + "isEmailSubscriptionContact": false, + "isSmsSubscriptionContact": true, + "name": "Contact 3", + "phone": null } ], - "controlUnitResourceIds": [ - 211, - 580, - 388, - 320 - ], + "controlUnitResourceIds": [6, 7], "controlUnitResources": [ { - "id": 211, + "id": 6, "controlUnit": { - "id": 10338, - "areaNote": "Morbihan (56)", - "administrationId": 1011, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "OFB SD 56", - "termsNote": null - }, - "controlUnitId": 10338, - "isArchived": false, - "name": "Penn Blei – AY 938412 N", - "note": null, - "photo": null, - "station": { - "id": 245, - "latitude": 47.658236, - "longitude": -2.760847, - "name": "Vannes" - }, - "stationId": 245, - "type": "SEMI_RIGID" - }, - { - "id": 580, - "controlUnit": { - "id": 10338, - "areaNote": "Morbihan (56)", - "administrationId": 1011, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "OFB SD 56", - "termsNote": null - }, - "controlUnitId": 10338, - "isArchived": false, - "name": "Kereon II – AY 933119 K", - "note": null, - "photo": null, - "station": { - "id": 245, - "latitude": 47.658236, - "longitude": -2.760847, - "name": "Vannes" - }, - "stationId": 245, - "type": "SEMI_RIGID" - }, - { - "id": 388, - "controlUnit": { - "id": 10338, - "areaNote": "Morbihan (56)", - "administrationId": 1011, + "id": 10003, + "areaNote": null, + "administrationId": 1005, "departmentAreaInseeCode": null, "isArchived": false, - "name": "OFB SD 56", + "name": "DPM – DDTM 14", "termsNote": null }, - "controlUnitId": 10338, + "controlUnitId": 10003, "isArchived": false, - "name": "Jean Armel – AY 894009", + "name": "AR VECHEN", "note": null, "photo": null, - "station": { - "id": 245, - "latitude": 47.658236, - "longitude": -2.760847, - "name": "Vannes" - }, - "stationId": 245, - "type": "FAST_BOAT" + "station": { "id": 2, "latitude": 48.648105, "longitude": -2.013144, "name": "Saint-Malo" }, + "stationId": 2, + "type": "FRIGATE" }, { - "id": 320, + "id": 7, "controlUnit": { - "id": 10338, - "areaNote": "Morbihan (56)", - "administrationId": 1011, + "id": 10003, + "areaNote": null, + "administrationId": 1005, "departmentAreaInseeCode": null, "isArchived": false, - "name": "OFB SD 56", + "name": "DPM – DDTM 14", "termsNote": null }, - "controlUnitId": 10338, + "controlUnitId": 10003, "isArchived": false, - "name": "Voiture", + "name": "Semi-rigide", "note": null, "photo": null, - "station": { - "id": 245, - "latitude": 47.658236, - "longitude": -2.760847, - "name": "Vannes" - }, - "stationId": 245, - "type": "CAR" + "station": { "id": 3, "latitude": 51.035534, "longitude": 2.372845, "name": "Dunkerque" }, + "stationId": 3, + "type": "BARGE" } ], "departmentArea": null, "departmentAreaInseeCode": null, "isArchived": false, - "name": "OFB SD 56", + "name": "DPM – DDTM 14", "termsNote": null }, { - "id": 10157, - "areaNote": "Morbihan (56)", - "administration": { - "id": 1005, - "isArchived": false, - "name": "DDTM" - }, + "id": 10004, + "areaNote": null, + "administration": { "id": 1005, "isArchived": false, "name": "DDTM" }, "administrationId": 1005, - "controlUnitContactIds": [ - 366 - ], - "controlUnitContacts": [ - { - "id": 366, - "controlUnitId": 10157, - "email": "ddtm-pre@morbihan.gouv.fr", - "name": "UNKNOWN", - "phone": "02 56 63 72 00" - } - ], - "controlUnitResourceIds": [ - 579 - ], - "controlUnitResources": [ - { - "id": 579, - "controlUnit": { - "id": 10157, - "areaNote": "Morbihan (56)", - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "Police de l'eau 56", - "termsNote": null - }, - "controlUnitId": 10157, - "isArchived": false, - "name": "Voiture", - "note": null, - "photo": null, - "station": { - "id": 245, - "latitude": 47.658236, - "longitude": -2.760847, - "name": "Vannes" - }, - "stationId": 245, - "type": "CAR" - } - ], + "controlUnitContactIds": [], + "controlUnitContacts": [], + "controlUnitResourceIds": [], + "controlUnitResources": [], "departmentArea": null, "departmentAreaInseeCode": null, "isArchived": false, - "name": "Police de l'eau 56", + "name": "DPM – DDTM 35", "termsNote": null }, { - "id": 10066, - "areaNote": "Morbihan (56)", - "administration": { - "id": 1005, - "isArchived": false, - "name": "DDTM" - }, + "id": 10005, + "areaNote": null, + "administration": { "id": 1005, "isArchived": false, "name": "DDTM" }, "administrationId": 1005, - "controlUnitContactIds": [ - 165 - ], - "controlUnitContacts": [ - { - "id": 165, - "controlUnitId": 10066, - "email": "ddtm-samel@morbihan.gouv.fr", - "name": "UNKNOWN", - "phone": "02 97 64 85 06" - } - ], - "controlUnitResourceIds": [ - 181, - 133, - 300, - 1212 - ], + "controlUnitContactIds": [], + "controlUnitContacts": [], + "controlUnitResourceIds": [], + "controlUnitResources": [], + "departmentArea": null, + "departmentAreaInseeCode": null, + "isArchived": false, + "name": "DPM – DDTM 44", + "termsNote": null + }, + { + "id": 10018, + "areaNote": null, + "administration": { "id": 1008, "isArchived": false, "name": "DREAL / DEAL" }, + "administrationId": 1008, + "controlUnitContactIds": [], + "controlUnitContacts": [], + "controlUnitResourceIds": [10, 11, 12], "controlUnitResources": [ { - "id": 181, - "controlUnit": { - "id": 10066, - "areaNote": "Morbihan (56)", - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "DPM 56", - "termsNote": null - }, - "controlUnitId": 10066, - "isArchived": false, - "name": "Brezel - FAH 7185", - "note": null, - "photo": null, - "station": { - "id": 245, - "latitude": 47.658236, - "longitude": -2.760847, - "name": "Vannes" - }, - "stationId": 245, - "type": "RIGID_HULL" - }, - { - "id": 133, + "id": 10, "controlUnit": { - "id": 10066, - "areaNote": "Morbihan (56)", - "administrationId": 1005, + "id": 10018, + "areaNote": null, + "administrationId": 1008, "departmentAreaInseeCode": null, "isArchived": false, - "name": "DPM 56", + "name": "DREAL Pays-de-La-Loire", "termsNote": null }, - "controlUnitId": 10066, + "controlUnitId": 10018, "isArchived": false, - "name": "Voiture", + "name": "ALTAIR", "note": null, "photo": null, - "station": { - "id": 245, - "latitude": 47.658236, - "longitude": -2.760847, - "name": "Vannes" - }, - "stationId": 245, - "type": "CAR" + "station": { "id": 3, "latitude": 51.035534, "longitude": 2.372845, "name": "Dunkerque" }, + "stationId": 3, + "type": "FRIGATE" }, { - "id": 300, + "id": 11, "controlUnit": { - "id": 10066, - "areaNote": "Morbihan (56)", - "administrationId": 1005, + "id": 10018, + "areaNote": null, + "administrationId": 1008, "departmentAreaInseeCode": null, "isArchived": false, - "name": "DPM 56", + "name": "DREAL Pays-de-La-Loire", "termsNote": null }, - "controlUnitId": 10066, + "controlUnitId": 10018, "isArchived": false, - "name": "Sterenn - FAC 7421", + "name": "PHEROUSA", "note": null, "photo": null, - "station": { - "id": 153, - "latitude": 47.7482524, - "longitude": -3.3702449, - "name": "Lorient" - }, - "stationId": 153, - "type": "SEMI_RIGID" + "station": { "id": 3, "latitude": 51.035534, "longitude": 2.372845, "name": "Dunkerque" }, + "stationId": 3, + "type": "FRIGATE" }, { - "id": 1212, + "id": 12, "controlUnit": { - "id": 10066, - "areaNote": "Morbihan (56)", - "administrationId": 1005, + "id": 10018, + "areaNote": null, + "administrationId": 1008, "departmentAreaInseeCode": null, "isArchived": false, - "name": "DPM 56", + "name": "DREAL Pays-de-La-Loire", "termsNote": null }, - "controlUnitId": 10066, + "controlUnitId": 10018, "isArchived": false, - "name": "Voiture", + "name": "ARIOLA", "note": null, "photo": null, - "station": { - "id": 153, - "latitude": 47.7482524, - "longitude": -3.3702449, - "name": "Lorient" - }, - "stationId": 153, - "type": "CAR" + "station": { "id": 3, "latitude": 51.035534, "longitude": 2.372845, "name": "Dunkerque" }, + "stationId": 3, + "type": "FRIGATE" } ], "departmentArea": null, "departmentAreaInseeCode": null, "isArchived": false, - "name": "DPM 56", + "name": "DREAL Pays-de-La-Loire", "termsNote": null }, { - "id": 10449, - "areaNote": "Morbihan (56)", - "administration": { - "id": 1005, - "isArchived": false, - "name": "DDTM" - }, - "administrationId": 1005, - "controlUnitContactIds": [ - 993, - 994, - 995, - 996, - 997, - 998, - 999, - 1000 - ], - "controlUnitContacts": [ - { - "id": 993, - "controlUnitId": 10449, - "email": "ddtm-ulam@morbihan.gouv.fr", - "name": "Dml Auray", - "phone": "02 97 24 01 43" - }, - { - "id": 994, - "controlUnitId": 10449, - "email": "ddtm-ulam@morbihan.gouv.fr", - "name": "Dml Lorient", - "phone": "02 97 37 16 22" - }, - { - "id": 995, - "controlUnitId": 10449, - "email": "ddtm-ulam@morbihan.gouv.fr", - "name": "UNKNOWN", - "phone": "02 97 29 34 92" - }, - { - "id": 996, - "controlUnitId": 10449, - "email": "ddtm-ulam@morbihan.gouv.fr", - "name": "UNKNOWN", - "phone": "02 97 29 34 92" - }, - { - "id": 997, - "controlUnitId": 10449, - "email": "ddtm-ulam@morbihan.gouv.fr", - "name": "UNKNOWN", - "phone": "02 97 37 17 47" - }, - { - "id": 998, - "controlUnitId": 10449, - "email": "ddtm-ulam@morbihan.gouv.fr", - "name": "UNKNOWN", - "phone": "02 97 37 17 47" - }, - { - "id": 999, - "controlUnitId": 10449, - "email": "ddtm-ulam@morbihan.gouv.fr", - "name": "UNKNOWN", - "phone": "06 63 73 05 59" - }, - { - "id": 1000, - "controlUnitId": 10449, - "email": "ddtm-ulam@morbihan.gouv.fr", - "name": "UNKNOWN", - "phone": "06 63 73 05 59" - } - ], - "controlUnitResourceIds": [ - 361, - 134, - 259, - 512, - 1219 - ], + "id": 10022, + "areaNote": null, + "administration": { "id": 1013, "isArchived": false, "name": "Gestionnaire AMP" }, + "administrationId": 1013, + "controlUnitContactIds": [], + "controlUnitContacts": [], + "controlUnitResourceIds": [], + "controlUnitResources": [], + "departmentArea": null, + "departmentAreaInseeCode": null, + "isArchived": false, + "name": "Natura 2000 Côte Bleue Marine", + "termsNote": null + }, + { + "id": 10025, + "areaNote": null, + "administration": { "id": 1011, "isArchived": false, "name": "Office Français de la Biodiversité" }, + "administrationId": 1011, + "controlUnitContactIds": [], + "controlUnitContacts": [], + "controlUnitResourceIds": [], + "controlUnitResources": [], + "departmentArea": null, + "departmentAreaInseeCode": null, + "isArchived": false, + "name": "OFB SD974 Brigade Nature – SOI", + "termsNote": null + }, + { + "id": 10024, + "areaNote": null, + "administration": { "id": 1011, "isArchived": false, "name": "Office Français de la Biodiversité" }, + "administrationId": 1011, + "controlUnitContactIds": [], + "controlUnitContacts": [], + "controlUnitResourceIds": [], + "controlUnitResources": [], + "departmentArea": null, + "departmentAreaInseeCode": null, + "isArchived": false, + "name": "OFB Sd 85", + "termsNote": null + }, + { + "id": 10019, + "areaNote": null, + "administration": { "id": 4, "isArchived": false, "name": "Gendarmerie Maritime" }, + "administrationId": 4, + "controlUnitContactIds": [], + "controlUnitContacts": [], + "controlUnitResourceIds": [], + "controlUnitResources": [], + "departmentArea": null, + "departmentAreaInseeCode": null, + "isArchived": false, + "name": "P602 Verdon", + "termsNote": null + }, + { + "id": 10121, + "areaNote": null, + "administration": { "id": 1009, "isArchived": false, "name": "DIRM / DM" }, + "administrationId": 1009, + "controlUnitContactIds": [], + "controlUnitContacts": [], + "controlUnitResourceIds": [8], "controlUnitResources": [ { - "id": 361, - "controlUnit": { - "id": 10449, - "areaNote": "Morbihan (56)", - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "ULAM 56 ", - "termsNote": null - }, - "controlUnitId": 10449, - "isArchived": false, - "name": "Petrel – PM 438", - "note": "9 m", - "photo": null, - "station": { - "id": 153, - "latitude": 47.7482524, - "longitude": -3.3702449, - "name": "Lorient" - }, - "stationId": 153, - "type": "SEMI_RIGID" - }, - { - "id": 134, - "controlUnit": { - "id": 10449, - "areaNote": "Morbihan (56)", - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "ULAM 56 ", - "termsNote": null - }, - "controlUnitId": 10449, - "isArchived": false, - "name": "Ilur - PM 470", - "note": "9 m", - "photo": null, - "station": { - "id": 222, - "latitude": 47.587901, - "longitude": -2.9994489, - "name": "Saint-Philibert" - }, - "stationId": 222, - "type": "SEMI_RIGID" - }, - { - "id": 259, - "controlUnit": { - "id": 10449, - "areaNote": "Morbihan (56)", - "administrationId": 1005, - "departmentAreaInseeCode": null, - "isArchived": false, - "name": "ULAM 56 ", - "termsNote": null - }, - "controlUnitId": 10449, - "isArchived": false, - "name": "Atoup - PM 412", - "note": "6 m", - "photo": null, - "station": { - "id": 8, - "latitude": 47.66649100000001, - "longitude": -2.983767, - "name": "Auray" - }, - "stationId": 8, - "type": "SEMI_RIGID" - }, - { - "id": 512, + "id": 8, "controlUnit": { - "id": 10449, - "areaNote": "Morbihan (56)", - "administrationId": 1005, + "id": 10121, + "areaNote": null, + "administrationId": 1009, "departmentAreaInseeCode": null, "isArchived": false, - "name": "ULAM 56 ", + "name": "PAM Jeanne Barret", "termsNote": null }, - "controlUnitId": 10449, + "controlUnitId": 10121, "isArchived": false, - "name": "Voiture", + "name": "PAM Jeanne Barret", "note": null, "photo": null, - "station": { - "id": 245, - "latitude": 47.658236, - "longitude": -2.760847, - "name": "Vannes" - }, - "stationId": 245, - "type": "CAR" - }, + "station": { "id": 3, "latitude": 51.035534, "longitude": 2.372845, "name": "Dunkerque" }, + "stationId": 3, + "type": "FRIGATE" + } + ], + "departmentArea": null, + "departmentAreaInseeCode": null, + "isArchived": false, + "name": "PAM Jeanne Barret", + "termsNote": null + }, + { + "id": 10080, + "areaNote": null, + "administration": { "id": 1009, "isArchived": false, "name": "DIRM / DM" }, + "administrationId": 1009, + "controlUnitContactIds": [], + "controlUnitContacts": [], + "controlUnitResourceIds": [9], + "controlUnitResources": [ { - "id": 1219, + "id": 9, "controlUnit": { - "id": 10449, - "areaNote": "Morbihan (56)", - "administrationId": 1005, + "id": 10080, + "areaNote": null, + "administrationId": 1009, "departmentAreaInseeCode": null, "isArchived": false, - "name": "ULAM 56 ", + "name": "PAM Themis", "termsNote": null }, - "controlUnitId": 10449, + "controlUnitId": 10080, "isArchived": false, - "name": "Voiture", + "name": "PAM Themis", "note": null, "photo": null, - "station": { - "id": 153, - "latitude": 47.7482524, - "longitude": -3.3702449, - "name": "Lorient" - }, - "stationId": 153, - "type": "CAR" + "station": { "id": 3, "latitude": 51.035534, "longitude": 2.372845, "name": "Dunkerque" }, + "stationId": 3, + "type": "FRIGATE" } ], "departmentArea": null, "departmentAreaInseeCode": null, "isArchived": false, - "name": "ULAM 56 ", + "name": "PAM Themis", + "termsNote": null + }, + { + "id": 10028, + "areaNote": null, + "administration": { "id": 1006, "isArchived": false, "name": "Parcs Naturels Marins" }, + "administrationId": 1006, + "controlUnitContactIds": [], + "controlUnitContacts": [], + "controlUnitResourceIds": [], + "controlUnitResources": [], + "departmentArea": null, + "departmentAreaInseeCode": null, + "isArchived": false, + "name": "PNM Martinique", + "termsNote": null + }, + { + "id": 10027, + "areaNote": null, + "administration": { "id": 10, "isArchived": false, "name": "Parcs Nationaux" }, + "administrationId": 10, + "controlUnitContactIds": [], + "controlUnitContacts": [], + "controlUnitResourceIds": [], + "controlUnitResources": [], + "departmentArea": null, + "departmentAreaInseeCode": null, + "isArchived": false, + "name": "Parc National de Guadeloupe", + "termsNote": null + }, + { + "id": 10026, + "areaNote": null, + "administration": { "id": 1014, "isArchived": false, "name": "Parcs Naturels Régionaux" }, + "administrationId": 1014, + "controlUnitContactIds": [], + "controlUnitContacts": [], + "controlUnitResourceIds": [], + "controlUnitResources": [], + "departmentArea": null, + "departmentAreaInseeCode": null, + "isArchived": false, + "name": "Parc Naturel Régional Martinique", + "termsNote": null + }, + { + "id": 10029, + "areaNote": null, + "administration": { "id": 1015, "isArchived": false, "name": "Police Municipale" }, + "administrationId": 1015, + "controlUnitContactIds": [], + "controlUnitContacts": [], + "controlUnitResourceIds": [], + "controlUnitResources": [], + "departmentArea": null, + "departmentAreaInseeCode": null, + "isArchived": false, + "name": "Police Municipale Le Marin 972", + "termsNote": null + }, + { + "id": 10008, + "areaNote": null, + "administration": { "id": 1005, "isArchived": false, "name": "DDTM" }, + "administrationId": 1005, + "controlUnitContactIds": [], + "controlUnitContacts": [], + "controlUnitResourceIds": [], + "controlUnitResources": [], + "departmentArea": null, + "departmentAreaInseeCode": null, + "isArchived": false, + "name": "Police de l'eau – DDTM 11", + "termsNote": null + }, + { + "id": 10030, + "areaNote": null, + "administration": { "id": 1004, "isArchived": false, "name": "Réserves Naturelles" }, + "administrationId": 1004, + "controlUnitContactIds": [], + "controlUnitContacts": [], + "controlUnitResourceIds": [], + "controlUnitResources": [], + "departmentArea": null, + "departmentAreaInseeCode": null, + "isArchived": false, + "name": "Réserve Naturelle de L'Ilot M'Bouzi", + "termsNote": null + }, + { + "id": 10031, + "areaNote": null, + "administration": { "id": 1004, "isArchived": false, "name": "Réserves Naturelles" }, + "administrationId": 1004, + "controlUnitContactIds": [], + "controlUnitContacts": [], + "controlUnitResourceIds": [], + "controlUnitResources": [], + "departmentArea": null, + "departmentAreaInseeCode": null, + "isArchived": false, + "name": "Réserve Naturelle 7 Iles", + "termsNote": null + }, + { + "id": 10006, + "areaNote": null, + "administration": { "id": 1005, "isArchived": false, "name": "DDTM" }, + "administrationId": 1005, + "controlUnitContactIds": [], + "controlUnitContacts": [], + "controlUnitResourceIds": [], + "controlUnitResources": [], + "departmentArea": null, + "departmentAreaInseeCode": null, + "isArchived": false, + "name": "SML 33", + "termsNote": null + }, + { + "id": 10007, + "areaNote": null, + "administration": { "id": 1005, "isArchived": false, "name": "DDTM" }, + "administrationId": 1005, + "controlUnitContactIds": [], + "controlUnitContacts": [], + "controlUnitResourceIds": [], + "controlUnitResources": [], + "departmentArea": null, + "departmentAreaInseeCode": null, + "isArchived": false, + "name": "SML 50", + "termsNote": null + }, + { + "id": 10033, + "areaNote": null, + "administration": { "id": 22, "isArchived": true, "name": "Administration Archivée 2" }, + "administrationId": 22, + "controlUnitContactIds": [], + "controlUnitContacts": [], + "controlUnitResourceIds": [], + "controlUnitResources": [], + "departmentArea": null, + "departmentAreaInseeCode": null, + "isArchived": true, + "name": "Unité archivée", "termsNote": null } ] } -} \ No newline at end of file +} From 8f863c1734caffc3ba388e7b6bf16dd808137e43 Mon Sep 17 00:00:00 2001 From: Ivan Gabriele Date: Tue, 29 Oct 2024 02:29:40 +0100 Subject: [PATCH 43/59] Lint var names in Backend --- .../infrastructure/monitorenv/APIControlUnitRepository.kt | 6 +++--- .../monitorenv/APILegacyControlUnitRepository.kt | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/APIControlUnitRepository.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/APIControlUnitRepository.kt index 4a21fdc37e..450d502eee 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/APIControlUnitRepository.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/APIControlUnitRepository.kt @@ -22,12 +22,12 @@ class APIControlUnitRepository( @Cacheable(value = ["control_units"]) override fun findAll(): List = runBlocking { - val missionsUrl = "${monitorenvProperties.url}/api/v2/control_units" + val controlUnitsUrl = "${monitorenvProperties.url}/api/v2/control_units" try { - apiClient.httpClient.get(missionsUrl).body() + apiClient.httpClient.get(controlUnitsUrl).body() } catch (e: Exception) { - logger.error("Could not fetch control units at $missionsUrl", e) + logger.error("Could not fetch control units at $controlUnitsUrl", e) listOf() } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/APILegacyControlUnitRepository.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/APILegacyControlUnitRepository.kt index 30f20186e1..77f2e02b43 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/APILegacyControlUnitRepository.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/APILegacyControlUnitRepository.kt @@ -22,12 +22,12 @@ class APILegacyControlUnitRepository( @Cacheable(value = ["legacy_control_units"]) override fun findAll(): List = runBlocking { - val missionsUrl = "${monitorenvProperties.url}/api/v1/control_units" + val legacyControlUnitsUrl = "${monitorenvProperties.url}/api/v1/control_units" try { - apiClient.httpClient.get(missionsUrl).body() + apiClient.httpClient.get(legacyControlUnitsUrl).body() } catch (e: Exception) { - logger.error("Could not fetch control units at $missionsUrl", e) + logger.error("Could not fetch legacy control units at $legacyControlUnitsUrl", e) listOf() } From d229f78af8ef8b354a7d25af91e06dbbdac84dab Mon Sep 17 00:00:00 2001 From: Ivan Gabriele Date: Tue, 29 Oct 2024 02:47:10 +0100 Subject: [PATCH 44/59] Update e2e tests for pno subscriber list filters with real API calls --- .../constants.ts | 100 ------------------ .../filter_bar.spec.ts | 20 ++-- .../utils.ts | 11 +- 3 files changed, 13 insertions(+), 118 deletions(-) delete mode 100644 frontend/cypress/e2e/backoffice/prior_notification_subscriber_table/constants.ts diff --git a/frontend/cypress/e2e/backoffice/prior_notification_subscriber_table/constants.ts b/frontend/cypress/e2e/backoffice/prior_notification_subscriber_table/constants.ts deleted file mode 100644 index 3b82a30a36..0000000000 --- a/frontend/cypress/e2e/backoffice/prior_notification_subscriber_table/constants.ts +++ /dev/null @@ -1,100 +0,0 @@ -import type { PriorNotificationSubscriber } from '@features/PriorNotification/PriorNotificationSubscriber.types' - -export const FAKE_PRIOR_NOTIFICATION_SUBSCRIBERS: PriorNotificationSubscriber.Subscriber[] = [ - { - controlUnit: { - administration: { - id: 101, - name: 'Administration 1' - }, - id: 1, - name: 'Unité 1' - }, - fleetSegmentSubscriptions: [ - { - controlUnitId: 1, - segmentCode: 'SEG001', - segmentName: 'Segment 1' - }, - { - controlUnitId: 1, - segmentCode: 'SEG002', - segmentName: 'Segment 2' - }, - { - controlUnitId: 1, - segmentCode: 'SEG003', - segmentName: 'Segment 3' - }, - { - controlUnitId: 1, - segmentCode: 'SEG004', - segmentName: undefined - } - ], - portSubscriptions: [ - { - controlUnitId: 1, - hasSubscribedToAllPriorNotifications: false, - portLocode: 'FRABC', - portName: 'Port Français' - }, - { - controlUnitId: 1, - hasSubscribedToAllPriorNotifications: true, - portLocode: 'GBDEF', - portName: 'Port Anglais' - }, - { - controlUnitId: 1, - hasSubscribedToAllPriorNotifications: false, - portLocode: 'ESGHI', - portName: 'Port Espagnol' - }, - { - controlUnitId: 1, - hasSubscribedToAllPriorNotifications: false, - portLocode: 'ZZJKL', - portName: undefined - } - ], - vesselSubscriptions: [ - { - controlUnitId: 1, - vesselCallSign: 'CALLSIGN001', - vesselCfr: 'CFR001', - vesselExternalMarking: 'EXT001', - vesselId: 100001, - vesselMmsi: 'MMSI001', - vesselName: 'Navire 1' - }, - { - controlUnitId: 1, - vesselCallSign: 'CALLSIGN002', - vesselCfr: 'CFR002', - vesselExternalMarking: 'EXT002', - vesselId: 100002, - vesselMmsi: 'MMSI002', - vesselName: 'Navire 2' - }, - { - controlUnitId: 1, - vesselCallSign: 'CALLSIGN003', - vesselCfr: 'CFR003', - vesselExternalMarking: 'EXT003', - vesselId: 100003, - vesselMmsi: 'MMSI003', - vesselName: 'Navire 3' - }, - { - controlUnitId: 1, - vesselCallSign: undefined, - vesselCfr: undefined, - vesselExternalMarking: undefined, - vesselId: 100004, - vesselMmsi: undefined, - vesselName: undefined - } - ] - } -] diff --git a/frontend/cypress/e2e/backoffice/prior_notification_subscriber_table/filter_bar.spec.ts b/frontend/cypress/e2e/backoffice/prior_notification_subscriber_table/filter_bar.spec.ts index eda030b9b6..b8df01c832 100644 --- a/frontend/cypress/e2e/backoffice/prior_notification_subscriber_table/filter_bar.spec.ts +++ b/frontend/cypress/e2e/backoffice/prior_notification_subscriber_table/filter_bar.spec.ts @@ -11,23 +11,23 @@ context('BackOffice > Prior Notification Table > Filter Bar', () => { }) it('Should filter subscribers by search query', () => { - cy.intercept('GET', '/bff/v1/prior_notification_subscribers?*searchQuery=abc*').as( - 'getPriorNotificationSubscribers' - ) + cy.contains('A636 Maïto (Marine Nationale)').should('be.visible') - cy.fill('Rechercher...', 'abc') + cy.fill('Rechercher...', 'natu') - cy.wait('@getPriorNotificationSubscribers') + cy.contains('A636 Maïto (Marine Nationale)').should('not.exist') + cy.contains('Natura 2000 Côte Bleue Marine (Gestionnaire AMP)').should('be.visible') + cy.contains('PNM Martinique (Parcs Naturels Marins)').should('be.visible') }) it('Should filter subscribers by administration', () => { - cy.intercept('GET', '/bff/v1/prior_notification_subscribers?*administrationId=1*').as( - 'getPriorNotificationSubscribers' - ) + cy.contains('A636 Maïto (Marine Nationale)').should('be.visible') - cy.fill('Administration', 'Administration 1') + cy.fill('Administration', 'Gendarmerie Nationale') - cy.wait('@getPriorNotificationSubscribers') + cy.contains('A636 Maïto (Marine Nationale)').should('not.exist') + cy.contains('BN Toulon (Gendarmerie Nationale)').should('be.visible') + cy.contains('Brigade fluviale de Rouen (Gendarmerie Nationale)').should('be.visible') }) it('Should filter subscribers by port', () => { diff --git a/frontend/cypress/e2e/backoffice/prior_notification_subscriber_table/utils.ts b/frontend/cypress/e2e/backoffice/prior_notification_subscriber_table/utils.ts index 9d066d345c..6b1fd0a160 100644 --- a/frontend/cypress/e2e/backoffice/prior_notification_subscriber_table/utils.ts +++ b/frontend/cypress/e2e/backoffice/prior_notification_subscriber_table/utils.ts @@ -1,12 +1,7 @@ -import { FAKE_PRIOR_NOTIFICATION_SUBSCRIBERS } from './constants' -import { FAKE_ADMINISTRATIONS } from '../../constants' - export const openBackOfficePriorNotificationSubscriberList = () => { - cy.intercept( - '/bff/v1/prior_notification_subscribers?sortColumn=CONTROL_UNIT_NAME&sortDirection=ASC', - FAKE_PRIOR_NOTIFICATION_SUBSCRIBERS - ).as('getPriorNotificationSubscribers') - cy.intercept('http://localhost:9880/api/v1/administrations', FAKE_ADMINISTRATIONS).as('getAdministrations') + cy.intercept('GET', '/bff/v1/prior_notification_subscribers?sortColumn=CONTROL_UNIT_NAME&sortDirection=ASC').as( + 'getPriorNotificationSubscribers' + ) cy.visit('/backoffice/prior_notification_subscribers') cy.wait('@getPriorNotificationSubscribers') From e47032086b5a9ae0ac04dcb342997985ab7f2e46 Mon Sep 17 00:00:00 2001 From: Ivan Gabriele Date: Tue, 29 Oct 2024 03:04:21 +0100 Subject: [PATCH 45/59] Ensure pno subscriptions uniqueness in UpdatePriorNotificationSubscriber use case --- .../UpdatePriorNotificationSubscriber.kt | 25 ++++++++----------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/UpdatePriorNotificationSubscriber.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/UpdatePriorNotificationSubscriber.kt index d64114b73a..ddc8c36951 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/UpdatePriorNotificationSubscriber.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/prior_notification/UpdatePriorNotificationSubscriber.kt @@ -6,13 +6,7 @@ import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotifica import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotificationVesselSubscription import fr.gouv.cnsp.monitorfish.domain.exceptions.BackendUsageErrorCode import fr.gouv.cnsp.monitorfish.domain.exceptions.BackendUsageException -import fr.gouv.cnsp.monitorfish.domain.repositories.ControlUnitRepository -import fr.gouv.cnsp.monitorfish.domain.repositories.FleetSegmentRepository -import fr.gouv.cnsp.monitorfish.domain.repositories.PnoFleetSegmentSubscriptionRepository -import fr.gouv.cnsp.monitorfish.domain.repositories.PnoPortSubscriptionRepository -import fr.gouv.cnsp.monitorfish.domain.repositories.PnoVesselSubscriptionRepository -import fr.gouv.cnsp.monitorfish.domain.repositories.PortRepository -import fr.gouv.cnsp.monitorfish.domain.repositories.VesselRepository +import fr.gouv.cnsp.monitorfish.domain.repositories.* import fr.gouv.cnsp.monitorfish.domain.use_cases.prior_notification.dtos.PriorNotificationSubscriber @UseCase @@ -40,18 +34,21 @@ class UpdatePriorNotificationSubscriber( throw BackendUsageException(BackendUsageErrorCode.NOT_FOUND) } - pnoPortSubscriptionRepository.deleteByControlUnitId(controlUnitId) pnoFleetSegmentSubscriptionRepository.deleteByControlUnitId(controlUnitId) + pnoPortSubscriptionRepository.deleteByControlUnitId(controlUnitId) pnoVesselSubscriptionRepository.deleteByControlUnitId(controlUnitId) - pnoFleetSegmentSubscriptionRepository.saveAll(fleetSegmentSubscriptions) - pnoPortSubscriptionRepository.saveAll(portSubscriptions) - pnoVesselSubscriptionRepository.saveAll(vesselSubscriptions) + val updatedPnoFleetSegmentSubscriptions = + pnoFleetSegmentSubscriptionRepository.saveAll(fleetSegmentSubscriptions.distinctBy { it.segmentCode }) + val updatedPnoPortSubscriptions = + pnoPortSubscriptionRepository.saveAll(portSubscriptions.distinctBy { it.portLocode }) + val updatedPnoVesselSubscriptions = + pnoVesselSubscriptionRepository.saveAll(vesselSubscriptions.distinctBy { it.vesselId }) return PriorNotificationSubscriber.create( controlUnit, - fleetSegmentSubscriptions, - portSubscriptions, - vesselSubscriptions, + fleetSegmentSubscriptions = updatedPnoFleetSegmentSubscriptions, + portSubscriptions = updatedPnoPortSubscriptions, + vesselSubscriptions = updatedPnoVesselSubscriptions, allFleetSegments, allPorts, allVessels, From 9d33e001cfebda485e91e4d6d14f0f095939f8c5 Mon Sep 17 00:00:00 2001 From: Ivan Gabriele Date: Tue, 29 Oct 2024 03:51:37 +0100 Subject: [PATCH 46/59] Add e2e tests for pno subscriber form --- .../form.spec.ts | 321 ++++++++++++++++++ .../utils.ts | 14 + frontend/cypress/e2e/constants.ts | 36 -- .../AllPortSubscriptionsField.tsx | 2 +- .../FullPortSubscriptionsField.tsx | 4 +- .../VesselSearch/VesselSearchResultItem.tsx | 2 +- .../Vessel/components/VesselSearch/index.tsx | 2 +- 7 files changed, 340 insertions(+), 41 deletions(-) create mode 100644 frontend/cypress/e2e/backoffice/prior_notification_subscriber_form/form.spec.ts create mode 100644 frontend/cypress/e2e/backoffice/prior_notification_subscriber_form/utils.ts diff --git a/frontend/cypress/e2e/backoffice/prior_notification_subscriber_form/form.spec.ts b/frontend/cypress/e2e/backoffice/prior_notification_subscriber_form/form.spec.ts new file mode 100644 index 0000000000..0fa4a9be81 --- /dev/null +++ b/frontend/cypress/e2e/backoffice/prior_notification_subscriber_form/form.spec.ts @@ -0,0 +1,321 @@ +import { editBackOfficePriorNotificationSubscriber } from './utils' + +import type { PriorNotificationSubscriber } from '@features/PriorNotification/PriorNotificationSubscriber.types' + +context('BackOffice > Prior Notification Form > Form', () => { + it('Should add and remove both partial and full port subscriptions', () => { + cy.intercept('PUT', '/bff/v1/prior_notification_subscribers/10023').as('updatePriorNotificationSubscriber') + + editBackOfficePriorNotificationSubscriber(10023) + + cy.get('td:visible:contains("Vannes")').should('have.length', 0) + cy.get('td:visible:contains("Saint-Malo")').should('have.length', 0) + + // ------------------------------------------------------------------------- + // Add partial port subscription + + cy.fill('Ajouter un port de diffusion partielle', 'Vannes') + + cy.wait('@updatePriorNotificationSubscriber').then(updateInterception1 => { + if (!updateInterception1.response) { + assert.fail('`updateInterception1.response` is undefined.') + } + + const updatedPriorNotificationSubscriber1: PriorNotificationSubscriber.Subscriber = + updateInterception1.response.body + + assert.deepEqual(updatedPriorNotificationSubscriber1.portSubscriptions, [ + { controlUnitId: 10023, hasSubscribedToAllPriorNotifications: false, portLocode: 'FRVNE', portName: 'Vannes' } + ]) + + cy.get('td:visible:contains("Vannes")').should('have.length', 1) + cy.get('td:visible:contains("Saint-Malo")').should('have.length', 0) + + // ------------------------------------------------------------------------- + // Add full port subscription + + cy.fill('Ajouter un port de diffusion complète', 'Saint-Malo') + + cy.wait('@updatePriorNotificationSubscriber').then(updateInterception2 => { + if (!updateInterception2.response) { + assert.fail('`updateInterception2.response` is undefined.') + } + + const updatedPriorNotificationSubscriber2: PriorNotificationSubscriber.Subscriber = + updateInterception2.response.body + + assert.deepEqual(updatedPriorNotificationSubscriber2.portSubscriptions, [ + { + controlUnitId: 10023, + hasSubscribedToAllPriorNotifications: false, + portLocode: 'FRVNE', + portName: 'Vannes' + }, + { + controlUnitId: 10023, + hasSubscribedToAllPriorNotifications: true, + portLocode: 'FRSML', + portName: 'Saint-Malo' + } + ]) + + cy.get('td:visible:contains("Vannes")').should('have.length', 1) + cy.get('td:visible:contains("Saint-Malo")').should('have.length', 2) + + // ------------------------------------------------------------------------- + // Remove full port subscription + + cy.get('td:visible:contains("Saint-Malo")') + .eq(0) + .parent() + .clickButton("Désinscrire l'unité de tous les préavis liés à ce port") + + cy.wait('@updatePriorNotificationSubscriber').then(updateInterception3 => { + if (!updateInterception3.response) { + assert.fail('`updateInterception3.response` is undefined.') + } + + const updatedPriorNotificationSubscriber3: PriorNotificationSubscriber.Subscriber = + updateInterception3.response.body + + assert.deepEqual(updatedPriorNotificationSubscriber3.portSubscriptions, [ + { + controlUnitId: 10023, + hasSubscribedToAllPriorNotifications: false, + portLocode: 'FRVNE', + portName: 'Vannes' + } + ]) + + cy.get('td:visible:contains("Vannes")').should('have.length', 1) + cy.get('td:visible:contains("Saint-Malo")').should('have.length', 0) + + // ------------------------------------------------------------------------- + // Remove partial port subscription + + cy.get('td:visible:contains("Vannes")') + .eq(0) + .parent() + .clickButton("Désinscrire l'unité de tous les préavis liés à ce port") + + cy.wait('@updatePriorNotificationSubscriber').then(updateInterception4 => { + if (!updateInterception4.response) { + assert.fail('`updateInterception4.response` is undefined.') + } + + const updatedPriorNotificationSubscriber4: PriorNotificationSubscriber.Subscriber = + updateInterception4.response.body + + assert.isEmpty(updatedPriorNotificationSubscriber4.portSubscriptions) + + cy.get('td:visible:contains("Vannes")').should('have.length', 0) + cy.get('td:visible:contains("Saint-Malo")').should('have.length', 0) + }) + }) + }) + }) + }) + + it('Should add, upgrade, downgrade and remove a port subscription', () => { + cy.intercept('PUT', '/bff/v1/prior_notification_subscribers/10023').as('updatePriorNotificationSubscriber') + + editBackOfficePriorNotificationSubscriber(10023) + + cy.get('td:visible:contains("Nice")').should('have.length', 0) + + // ------------------------------------------------------------------------- + // Add partial port subscription + + cy.fill('Ajouter un port de diffusion partielle', 'Nice') + + cy.wait('@updatePriorNotificationSubscriber').then(updateInterception1 => { + if (!updateInterception1.response) { + assert.fail('`updateInterception1.response` is undefined.') + } + + const updatedPriorNotificationSubscriber1: PriorNotificationSubscriber.Subscriber = + updateInterception1.response.body + + assert.deepEqual(updatedPriorNotificationSubscriber1.portSubscriptions, [ + { controlUnitId: 10023, hasSubscribedToAllPriorNotifications: false, portLocode: 'FRNCE', portName: 'Nice' } + ]) + + cy.get('td:visible:contains("Nice")').should('have.length', 1) + + // ------------------------------------------------------------------------- + // Upgrade partial port subscription to full one + + cy.fill('Ajouter un port de diffusion complète', 'Nice') + + cy.wait('@updatePriorNotificationSubscriber').then(updateInterception2 => { + if (!updateInterception2.response) { + assert.fail('`updateInterception2.response` is undefined.') + } + + const updatedPriorNotificationSubscriber2: PriorNotificationSubscriber.Subscriber = + updateInterception2.response.body + + assert.deepEqual(updatedPriorNotificationSubscriber2.portSubscriptions, [ + { controlUnitId: 10023, hasSubscribedToAllPriorNotifications: true, portLocode: 'FRNCE', portName: 'Nice' } + ]) + + cy.get('td:visible:contains("Nice")').should('have.length', 2) + + // ------------------------------------------------------------------------- + // Downgrade full port subscription to partial one + + cy.get('td:visible:contains("Nice")') + .eq(1) + .parent() + .clickButton( + "Désinscrire l'unité des préavis liés à ce port pour les navires dont la note de risque est supérieure à 2,3" + ) + + cy.get('.Component-Dialog').contains('Supprimer un port de diffusion').should('be.visible') + + cy.clickButton('Confirmer la suppression') + + cy.wait('@updatePriorNotificationSubscriber').then(updateInterception3 => { + if (!updateInterception3.response) { + assert.fail('`updateInterception3.response` is undefined.') + } + + const updatedPriorNotificationSubscriber3: PriorNotificationSubscriber.Subscriber = + updateInterception3.response.body + + assert.deepEqual(updatedPriorNotificationSubscriber3.portSubscriptions, [ + { controlUnitId: 10023, hasSubscribedToAllPriorNotifications: false, portLocode: 'FRNCE', portName: 'Nice' } + ]) + + cy.get('td:visible:contains("Nice")').should('have.length', 1) + + // ------------------------------------------------------------------------- + // Remove partial port subscription + + cy.get('td:visible:contains("Nice")') + .eq(0) + .parent() + .clickButton("Désinscrire l'unité de tous les préavis liés à ce port") + + cy.wait('@updatePriorNotificationSubscriber').then(updateInterception4 => { + if (!updateInterception4.response) { + assert.fail('`updateInterception4.response` is undefined.') + } + + const updatedPriorNotificationSubscriber4: PriorNotificationSubscriber.Subscriber = + updateInterception4.response.body + + assert.isEmpty(updatedPriorNotificationSubscriber4.portSubscriptions) + + cy.get('td:visible:contains("Nice")').should('have.length', 0) + }) + }) + }) + }) + }) + + it('Should add and remove a fleet segment subscription', () => { + cy.intercept('PUT', '/bff/v1/prior_notification_subscribers/10023').as('updatePriorNotificationSubscriber') + + editBackOfficePriorNotificationSubscriber(10023) + + cy.get('td:visible:contains("MED01 (All Trawls 1)")').should('have.length', 0) + + // ------------------------------------------------------------------------- + // Add fleet segment subscription + + cy.fill('Ajouter un segment de flotte', 'MED01') + + cy.wait('@updatePriorNotificationSubscriber').then(updateInterception1 => { + if (!updateInterception1.response) { + assert.fail('`updateInterception1.response` is undefined.') + } + + const updatedPriorNotificationSubscriber1: PriorNotificationSubscriber.Subscriber = + updateInterception1.response.body + + assert.deepEqual(updatedPriorNotificationSubscriber1.fleetSegmentSubscriptions, [ + { controlUnitId: 10023, segmentCode: 'MED01', segmentName: 'All Trawls 1' } + ]) + + cy.get('td:visible:contains("MED01 (All Trawls 1)")').should('have.length', 1) + + // ------------------------------------------------------------------------- + // Remove fleet segment subscription + + cy.get('td:visible:contains("MED01 (All Trawls 1)")') + .parent() + .clickButton("Désinscrire l'unité de tous les préavis liés à ce segment de flotte") + + cy.wait('@updatePriorNotificationSubscriber').then(updateInterception2 => { + if (!updateInterception2.response) { + assert.fail('`updateInterception2.response` is undefined.') + } + + const updatedPriorNotificationSubscriber3: PriorNotificationSubscriber.Subscriber = + updateInterception2.response.body + + assert.isEmpty(updatedPriorNotificationSubscriber3.fleetSegmentSubscriptions) + + cy.get('td:visible:contains("MED01 (All Trawls 1)")').should('have.length', 0) + }) + }) + }) + + it('Should add and remove a vessel subscription', () => { + cy.intercept('PUT', '/bff/v1/prior_notification_subscribers/10023').as('updatePriorNotificationSubscriber') + + editBackOfficePriorNotificationSubscriber(10023) + + cy.get('td:visible:contains("PHENOMENE")').should('have.length', 0) + + // ------------------------------------------------------------------------- + // Add fleet segment subscription + + cy.getDataCy('VesselSearch-input').type('PHENOMENE') + cy.getDataCy('VesselSearch-item').first().click() + + cy.wait('@updatePriorNotificationSubscriber').then(updateInterception1 => { + if (!updateInterception1.response) { + assert.fail('`updateInterception1.response` is undefined.') + } + + const updatedPriorNotificationSubscriber1: PriorNotificationSubscriber.Subscriber = + updateInterception1.response.body + + assert.deepEqual(updatedPriorNotificationSubscriber1.vesselSubscriptions, [ + { + controlUnitId: 10023, + vesselCallSign: 'CALLME', + vesselCfr: 'FAK000999999', + vesselExternalMarking: 'DONTSINK', + vesselId: 1, + vesselMmsi: '224103750', + vesselName: 'PHENOMENE' + } + ]) + + cy.get('td:visible:contains("PHENOMENE")').should('have.length', 1) + + // ------------------------------------------------------------------------- + // Remove fleet segment subscription + + cy.get('td:visible:contains("PHENOMENE")') + .parent() + .clickButton("Désinscrire l'unité de tous les préavis liés à ce navire") + + cy.wait('@updatePriorNotificationSubscriber').then(updateInterception2 => { + if (!updateInterception2.response) { + assert.fail('`updateInterception2.response` is undefined.') + } + + const updatedPriorNotificationSubscriber3: PriorNotificationSubscriber.Subscriber = + updateInterception2.response.body + + assert.isEmpty(updatedPriorNotificationSubscriber3.vesselSubscriptions) + + cy.get('td:visible:contains("PHENOMENE")').should('have.length', 0) + }) + }) + }) +}) diff --git a/frontend/cypress/e2e/backoffice/prior_notification_subscriber_form/utils.ts b/frontend/cypress/e2e/backoffice/prior_notification_subscriber_form/utils.ts new file mode 100644 index 0000000000..e4e7b594d9 --- /dev/null +++ b/frontend/cypress/e2e/backoffice/prior_notification_subscriber_form/utils.ts @@ -0,0 +1,14 @@ +import { openBackOfficePriorNotificationSubscriberList } from '../prior_notification_subscriber_table/utils' + +export const editBackOfficePriorNotificationSubscriber = (controlUnitId: number) => { + cy.intercept('GET', `/bff/v1/prior_notification_subscribers/${controlUnitId}`).as('getPriorNotificationSubscriber') + + openBackOfficePriorNotificationSubscriberList() + + cy.getTableRowById(controlUnitId).clickButton('Éditer la diffusion pour cette unité de contrôle') + cy.wait('@getPriorNotificationSubscriber') + + cy.get('[id="portSubscription"]').should('not.be.disabled') + cy.get('[id="fullPortSubscription"]').should('not.be.disabled') + cy.get('[id="fleetSegmentSubscription"]').should('not.be.disabled') +} diff --git a/frontend/cypress/e2e/constants.ts b/frontend/cypress/e2e/constants.ts index 4229582bbe..01b7feb777 100644 --- a/frontend/cypress/e2e/constants.ts +++ b/frontend/cypress/e2e/constants.ts @@ -1,5 +1,3 @@ -import { type Administration } from '@mtes-mct/monitor-ui' - export const FAKE_API_POST_RESPONSE = { body: {}, statusCode: 201 @@ -19,37 +17,3 @@ export const FAKE_MISSION_WITHOUT_EXTERNAL_ACTIONS = { body: { canDelete: true, sources: [] }, statusCode: 200 } - -export const FAKE_ADMINISTRATIONS: Administration.Administration[] = [ - { - controlUnitIds: [1], - controlUnits: [ - { - administrationId: 101, - areaNote: undefined, - departmentAreaInseeCode: undefined, - id: 1, - isArchived: false, - name: 'Unité 1', - termsNote: undefined - } - ], - id: 101, - isArchived: false, - name: 'Administration 1' - }, - { - controlUnitIds: [], - controlUnits: [], - id: 102, - isArchived: false, - name: 'Administration 2' - }, - { - controlUnitIds: [], - controlUnits: [], - id: 103, - isArchived: false, - name: 'Administration 3' - } -] diff --git a/frontend/src/features/PriorNotification/components/PriorNotificationSubscriberForm/AllPortSubscriptionsField.tsx b/frontend/src/features/PriorNotification/components/PriorNotificationSubscriberForm/AllPortSubscriptionsField.tsx index 3f1825a12e..f4f713d1d1 100644 --- a/frontend/src/features/PriorNotification/components/PriorNotificationSubscriberForm/AllPortSubscriptionsField.tsx +++ b/frontend/src/features/PriorNotification/components/PriorNotificationSubscriberForm/AllPortSubscriptionsField.tsx @@ -59,7 +59,7 @@ export function AllPortSubscriptionsField({