Skip to content

Commit

Permalink
[Act-Rep] Ajout des espèces soumises à quotas pour les navires tiers (#…
Browse files Browse the repository at this point in the history
…2927)

## Linked issues

- Resolve #2926

----

- [ ] Tests E2E (Cypress)
  • Loading branch information
louptheron authored Feb 13, 2024
2 parents 92104d0 + 990176a commit 810c413
Show file tree
Hide file tree
Showing 4 changed files with 104 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,31 @@ enum class JointDeploymentPlan(private val species: List<FaoZonesAndSpecy>) {
return this.species.map { it.second }.distinct()
}

fun isLandControlApplicable(speciesOnboardCodes: List<String>, tripFaoCodes: List<String>): Boolean {
return this.species.any { (jdpFaoZones, jdpSpecy) ->
val isSpecyFound = speciesOnboardCodes.contains(jdpSpecy)
/**
* See "DÉCISION D’EXÉCUTION (UE) 2023/2376 DE LA COMMISSION":
* https://extranet.legipeche.metier.developpement-durable.gouv.fr/fichier/pdf/oj_l_202302376_fr_txt_cle6b198e.pdf?arg=24774&cle=7d14626b709ff7e8c62586bcd8683e7e9fcaa348&file=pdf%2Foj_l_202302376_fr_txt_cle6b198e.pdf
*/
fun isLandControlApplicable(flagState: String?, speciesOnboardCodes: List<String>, tripFaoCodes: List<String>): Boolean {
val isThirdCountryVessel = EU_THIRD_COUNTRIES.contains(flagState)

val isFaoZoneFound = jdpFaoZones
val hasSpeciesInJdp = this.species.any { (jdpFaoZones, jdpSpecy) ->
val isSpecyFoundInJdpSPecies = speciesOnboardCodes.contains(jdpSpecy)

val isFaoZoneFoundInJdpFaoZones = jdpFaoZones
.any { jdpFaoCode ->
// The JDP FAO zone is included in at least one trip FAO code
tripFaoCodes.any { tripFaoCode -> tripFaoCode.contains(jdpFaoCode) }
}

return@any isSpecyFound && isFaoZoneFound
return@any isSpecyFoundInJdpSPecies && isFaoZoneFoundInJdpFaoZones
}

val hasSpeciesInEUQuotas = if (isThirdCountryVessel) {
EU_QUOTAS_SPECIES.any { quotaSpecy -> speciesOnboardCodes.contains(quotaSpecy) }
} else {
false
}

return hasSpeciesInJdp || hasSpeciesInEUQuotas
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ typealias FaoZones = List<String>
typealias FaoZonesAndSpecy = Pair<FaoZones, String>

/**
* The following fao areas and species are defined in the species table document of each JDP.
* The following fao areas and species are defined in the species table (@CNSP) document of each JDP.
* This document has been written from "DÉCISION D’EXÉCUTION (UE) 2023/2376":
* https://extranet.legipeche.metier.developpement-durable.gouv.fr/fichier/pdf/oj_l_202302376_fr_txt_cle6b198e.pdf?arg=24774&cle=7d14626b709ff7e8c62586bcd8683e7e9fcaa348&file=pdf%2Foj_l_202302376_fr_txt_cle6b198e.pdf
*
* These tables could be found in these file names :
* - "Liste Espèces_JDP MED.pdf"
Expand Down Expand Up @@ -154,6 +156,55 @@ val WESTERN_WATERS_SPECIES: List<FaoZonesAndSpecy> = listOf(
),
)

val EU_THIRD_COUNTRIES = listOf("GB")

/**
* See species detailed in p.26 ("CARTES DES ESPÈCES SOUMISES A QUOTAS")
* https://extranet.legipeche.metier.developpement-durable.gouv.fr/fichier/pdf/guide_cnsp_cle79d8b7.pdf?arg=24331&cle=2b455fff3506433f7e33f33562508a576908b941&file=pdf%2Fguide_cnsp_cle79d8b7.pdf
*/
val EU_QUOTAS_SPECIES = listOf(
"DGS",
"ANE",
"ANF",
"ALF",
"USK",
"COD",
"LEZ",
"JAX",
"SBR",
"HAD",
"SWO",
"LEZ",
"GHL",
"ALB",
"ARU",
"RNG",
"HER",
"NEP",
"POL",
"POK",
"LEM",
"WIT",
"BLI",
"LIN",
"MAC",
"WHG",
"WHB",
"BSH",
"BSH",
"PLE",
"SRX",
"RJU",
"RJE",
"BSF",
"SPR",
"SOL",
"BET",
"BFT",
"TUR",
"BLL",
)

fun generateSpeciesWithFaoCode(faoZones: FaoZones, species: List<String>): List<FaoZonesAndSpecy> {
return species.map { Pair(faoZones, it) }
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class GetActivityReports(
val speciesOnboardCodes = control.speciesOnboard.mapNotNull { it.speciesCode }
val tripFaoCodes = control.faoAreas

return@filter jdp.isLandControlApplicable(speciesOnboardCodes, tripFaoCodes)
return@filter jdp.isLandControlApplicable(control.flagState, speciesOnboardCodes, tripFaoCodes)
}
MissionActionType.SEA_CONTROL -> {
val controlMission = missions.firstOrNull { mission -> mission.id == control.missionId }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class JointDeploymentPlanUTests {
val species = listOf("HKE", "ANN", "BOR")

// When
val isLandControlConcerned = jdp.isLandControlApplicable(species, faoCodes)
val isLandControlConcerned = jdp.isLandControlApplicable("FR", species, faoCodes)

// Then
assertThat(isLandControlConcerned).isTrue()
Expand All @@ -30,7 +30,7 @@ class JointDeploymentPlanUTests {
val species = listOf("ANN", "BOR")

// When
val isLandControlConcerned = jdp.isLandControlApplicable(species, faoCodes)
val isLandControlConcerned = jdp.isLandControlApplicable("FR", species, faoCodes)

// Then
assertThat(isLandControlConcerned).isFalse()
Expand All @@ -45,7 +45,36 @@ class JointDeploymentPlanUTests {
val species = listOf("HKE", "ANN", "BOR")

// When
val isLandControlConcerned = jdp.isLandControlApplicable(species, faoCodes)
val isLandControlConcerned = jdp.isLandControlApplicable("FR", species, faoCodes)

// Then
assertThat(isLandControlConcerned).isFalse()
}

@Test
fun `isLandControlConcerned Should return true When a third country vessel has species in the EU quota list`() {
// Given
val jdp = JointDeploymentPlan.NORTH_SEA
val faoCodes = listOf("27.5.b", "27.5.c")
// ALB is contained in the quotas
val species = listOf("HKE", "ANN", "BOR", "ALB")

// When
val isLandControlConcerned = jdp.isLandControlApplicable("GB", species, faoCodes)

// Then
assertThat(isLandControlConcerned).isTrue()
}

@Test
fun `isLandControlConcerned Should return false When a third country vessel has no species in the EU quota list`() {
// Given
val jdp = JointDeploymentPlan.NORTH_SEA
val faoCodes = listOf("27.5.b", "27.5.c")
val species = listOf("HKE", "ANN", "BOR")

// When
val isLandControlConcerned = jdp.isLandControlApplicable("GB", species, faoCodes)

// Then
assertThat(isLandControlConcerned).isFalse()
Expand Down

0 comments on commit 810c413

Please sign in to comment.