Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Act-Rep] Ajout des espèces soumises à quotas pour les navires tiers #2927

Merged
merged 1 commit into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading