Skip to content

Commit

Permalink
Paramétrage diffusion préavis – Créer la liste des unités recevant de…
Browse files Browse the repository at this point in the history
…s préavis (#3794)

## Linked issues

- Resolve #3768
- Changements dans `VesselSearch`:
- On passe de uncontrolled à controlled value en utilisant
useFieldControl() ce qui retire les useEffect du composant (et le
remplacent donc par l'unique useEffect interne à useFieldControl())
  - Plus d'appels aux slices Redux dans le composant interne
- Les navires "cachés" en local (sur la carte pour l'instant) sont
maintenant à passer via la prop cachedVesselIdentities
- On ne manipule plus que des VesselIdentity à l'intérieur de ce
composant, aucun autre type similaire ou dérivé (=> Plus de
transformation via getOnlyVesselIdentityProperties)


----

- [x] Tests E2E (Cypress)
  • Loading branch information
ivangabriele authored Oct 30, 2024
2 parents d9f0e73 + d82ed9b commit a686b13
Show file tree
Hide file tree
Showing 161 changed files with 4,912 additions and 6,362 deletions.
9 changes: 7 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package fr.gouv.cnsp.monitorfish.domain.entities.administration

data class Administration(
val id: Int,
val isArchived: Boolean,
val name: String,
)
Original file line number Diff line number Diff line change
@@ -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?,
)
Original file line number Diff line number Diff line change
@@ -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?,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
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,
val name: String,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package fr.gouv.cnsp.monitorfish.domain.entities.control_unit

import kotlinx.serialization.Serializable

@Serializable
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"),
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package fr.gouv.cnsp.monitorfish.domain.entities.mission
package fr.gouv.cnsp.monitorfish.domain.entities.control_unit

import kotlinx.serialization.Serializable
import fr.gouv.cnsp.monitorfish.domain.entities.mission.ControlResource

@Serializable
data class ControlUnit(
data class LegacyControlUnit(
val id: Int,
val administration: String,
val isArchived: Boolean,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> = listOf(),
val gears: List<String>,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package fr.gouv.cnsp.monitorfish.domain.entities.mission

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

Expand All @@ -25,5 +26,5 @@ data class Mission(
val missionSource: MissionSource,
val hasMissionOrder: Boolean? = false,
val isUnderJdp: Boolean? = false,
val controlUnits: List<ControlUnit> = listOf(),
val controlUnits: List<LegacyControlUnit> = listOf(),
)
Original file line number Diff line number Diff line change
Expand Up @@ -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.control_unit.LegacyControlUnit
import java.time.ZonedDateTime

data class MissionAction(
Expand Down Expand Up @@ -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<ControlUnit> = listOf(),
var controlUnits: List<LegacyControlUnit> = listOf(),
val isDeleted: Boolean,
val hasSomeGearsSeized: Boolean,
val hasSomeSpeciesSeized: Boolean,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package fr.gouv.cnsp.monitorfish.domain.entities.prior_notification

data class PriorNotificationFleetSegmentSubscription(
val controlUnitId: Int,
val segmentCode: String,
val segmentName: String?,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package fr.gouv.cnsp.monitorfish.domain.entities.prior_notification

data class PriorNotificationPortSubscription(
val controlUnitId: Int,
val portLocode: String,
val portName: String?,
val hasSubscribedToAllPriorNotifications: Boolean,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
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?,
)
Original file line number Diff line number Diff line change
@@ -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,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.sorters

enum class PriorNotificationSubscribersSortColumn {
CONTROL_UNIT_NAME,
}
Original file line number Diff line number Diff line change
@@ -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.control_unit.LegacyControlUnit

data class ReportingAndOccurrences(
val otherOccurrencesOfSameAlert: List<Reporting>,
val reporting: Reporting,
val controlUnit: ControlUnit?,
val controlUnit: LegacyControlUnit?,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package fr.gouv.cnsp.monitorfish.domain.entities.station

data class Station(
val id: Int,
val latitude: Double,
val longitude: Double,
val name: String,
)
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,22 @@ 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). */
// 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,
val flagState: CountryCode,
val width: Double? = null,
Expand Down
Original file line number Diff line number Diff line change
@@ -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.use_cases.control_units.dtos.FullControlUnit

interface ControlUnitRepository {
fun findAll(): List<ControlUnit>
fun findAll(): List<FullControlUnit>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package fr.gouv.cnsp.monitorfish.domain.repositories

import fr.gouv.cnsp.monitorfish.domain.entities.control_unit.LegacyControlUnit

interface LegacyControlUnitRepository {
fun findAll(): List<LegacyControlUnit>
}
Original file line number Diff line number Diff line change
@@ -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.control_unit.LegacyControlUnit
import fr.gouv.cnsp.monitorfish.domain.entities.mission.Mission
import fr.gouv.cnsp.monitorfish.domain.exceptions.CouldNotFindException
import kotlinx.coroutines.CoroutineScope
Expand All @@ -11,7 +11,7 @@ interface MissionRepository {
fun findControlUnitsOfMission(
scope: CoroutineScope,
missionId: Int,
): Deferred<List<ControlUnit>>
): Deferred<List<LegacyControlUnit>>

fun findAllMissions(
pageNumber: Int?,
Expand Down
Original file line number Diff line number Diff line change
@@ -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<PriorNotificationFleetSegmentSubscription>

fun findByControlUnitId(controlUnitId: Int): List<PriorNotificationFleetSegmentSubscription>

fun has(
portLocode: String,
segmentCodes: List<String>,
): Boolean

fun saveAll(
priorNotificationFleetSegmentSubscriptions: List<PriorNotificationFleetSegmentSubscription>,
): List<PriorNotificationFleetSegmentSubscription>
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
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<PriorNotificationPortSubscription>

fun findByControlUnitId(controlUnitId: Int): List<PriorNotificationPortSubscription>

fun has(portLocode: String): Boolean

fun saveAll(
priorNotificationPortSubscriptions: List<PriorNotificationPortSubscription>,
): List<PriorNotificationPortSubscription>
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
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<PriorNotificationVesselSubscription>

fun findByControlUnitId(controlUnitId: Int): List<PriorNotificationVesselSubscription>

fun has(vesselId: Int): Boolean

fun saveAll(
priorNotificationVesselSubscriptions: List<PriorNotificationVesselSubscription>,
): List<PriorNotificationVesselSubscription>
}
Original file line number Diff line number Diff line change
@@ -1,18 +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.repositories.ControlUnitRepository
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import fr.gouv.cnsp.monitorfish.domain.use_cases.control_units.dtos.FullControlUnit

@UseCase
class GetAllControlUnits(
private val controlUnitsRepository: ControlUnitRepository,
) {
private val logger: Logger = LoggerFactory.getLogger(GetAllControlUnits::class.java)

fun execute(): List<ControlUnit> {
fun execute(): List<FullControlUnit> {
return controlUnitsRepository.findAll()
}
}
Original file line number Diff line number Diff line change
@@ -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.entities.control_unit.LegacyControlUnit
import fr.gouv.cnsp.monitorfish.domain.repositories.LegacyControlUnitRepository

@UseCase
class GetAllLegacyControlUnits(
private val legacyControlUnitsRepository: LegacyControlUnitRepository,
) {
fun execute(): List<LegacyControlUnit> {
return legacyControlUnitsRepository.findAll()
}
}
Loading

0 comments on commit a686b13

Please sign in to comment.