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

[Missions] Récupérer les dates d'actions des deux centres pour le calcul des zones de mission #3041

Merged
merged 7 commits into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from 6 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 @@ -2,7 +2,7 @@ package fr.gouv.cnsp.monitorfish.domain.entities.alerts

import com.neovisionaries.i18n.CountryCode
import fr.gouv.cnsp.monitorfish.domain.entities.alerts.type.AlertType
import fr.gouv.cnsp.monitorfish.domain.entities.mission_actions.Infraction
import fr.gouv.cnsp.monitorfish.domain.entities.mission.mission_actions.Infraction
import fr.gouv.cnsp.monitorfish.domain.entities.vessel.VesselIdentifier
import java.time.ZonedDateTime

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.mission.env_mission_action.EnvMissionAction
import java.time.ZonedDateTime

/**
Expand All @@ -15,6 +16,9 @@ data class Mission(
val observationsCnsp: String? = null,
val facade: String? = null,
val geom: MultiPolygon? = null,
val createdAtUtc: ZonedDateTime? = null,
val updatedAtUtc: ZonedDateTime? = null,
val envActions: List<EnvMissionAction>? = listOf(),
val startDateTimeUtc: ZonedDateTime,
val endDateTimeUtc: ZonedDateTime? = null,
val isGeometryComputedFromControls: Boolean,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package fr.gouv.cnsp.monitorfish.domain.entities.mission

import fr.gouv.cnsp.monitorfish.domain.entities.mission_actions.MissionAction
import fr.gouv.cnsp.monitorfish.domain.entities.mission.mission_actions.MissionAction

data class MissionAndActions(
val mission: Mission,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package fr.gouv.cnsp.monitorfish.domain.entities.mission.env_mission_action

import java.time.ZonedDateTime
import java.util.*

data class EnvMissionAction(
val id: UUID,
val actionStartDateTimeUtc: ZonedDateTime? = null,
val actionType: EnvMissionActionType,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package fr.gouv.cnsp.monitorfish.domain.entities.mission.env_mission_action

enum class EnvMissionActionType(val value: String) {
CONTROL("CONTROL"),
NOTE("NOTE"),
SURVEILLANCE("SURVEILLANCE"),
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package fr.gouv.cnsp.monitorfish.domain.entities.mission_actions
package fr.gouv.cnsp.monitorfish.domain.entities.mission.mission_actions

enum class ControlCheck(val value: String) {
YES("YES"),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package fr.gouv.cnsp.monitorfish.domain.entities.mission_actions
package fr.gouv.cnsp.monitorfish.domain.entities.mission.mission_actions

enum class ControlOrigin(val value: String) {
POSEIDON_ENV("POSEIDON_ENV"),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package fr.gouv.cnsp.monitorfish.domain.entities.mission_actions
package fr.gouv.cnsp.monitorfish.domain.entities.mission.mission_actions

data class Controller(
var id: Int,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package fr.gouv.cnsp.monitorfish.domain.entities.mission_actions
package fr.gouv.cnsp.monitorfish.domain.entities.mission.mission_actions

data class ControlsSummary(
val vesselId: Int,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package fr.gouv.cnsp.monitorfish.domain.entities.mission_actions
package fr.gouv.cnsp.monitorfish.domain.entities.mission.mission_actions

data class FleetSegment(
var segment: String? = null,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package fr.gouv.cnsp.monitorfish.domain.entities.mission_actions
package fr.gouv.cnsp.monitorfish.domain.entities.mission.mission_actions

enum class FlightGoal(val value: String) {
VMS_AIS_CHECK("VMS_AIS_CHECK"),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package fr.gouv.cnsp.monitorfish.domain.entities.mission_actions
package fr.gouv.cnsp.monitorfish.domain.entities.mission.mission_actions

class GearControl {
var gearCode: String? = null
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package fr.gouv.cnsp.monitorfish.domain.entities.mission_actions
package fr.gouv.cnsp.monitorfish.domain.entities.mission.mission_actions

data class GearInfraction(
var infractionType: InfractionType? = null,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package fr.gouv.cnsp.monitorfish.domain.entities.mission_actions
package fr.gouv.cnsp.monitorfish.domain.entities.mission.mission_actions

data class Infraction(
var natinfCode: Int,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package fr.gouv.cnsp.monitorfish.domain.entities.mission_actions
package fr.gouv.cnsp.monitorfish.domain.entities.mission.mission_actions

enum class InfractionCategory(val value: String) {
FISHING("Pêche"),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package fr.gouv.cnsp.monitorfish.domain.entities.mission_actions
package fr.gouv.cnsp.monitorfish.domain.entities.mission.mission_actions

enum class InfractionType(val value: String) {
WITH_RECORD("WITH_RECORD"),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package fr.gouv.cnsp.monitorfish.domain.entities.mission_actions
package fr.gouv.cnsp.monitorfish.domain.entities.mission.mission_actions

data class LogbookInfraction(
var infractionType: InfractionType? = null,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package fr.gouv.cnsp.monitorfish.domain.entities.mission_actions
package fr.gouv.cnsp.monitorfish.domain.entities.mission.mission_actions

import fr.gouv.cnsp.monitorfish.domain.entities.mission.ControlUnit
import java.time.ZonedDateTime
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package fr.gouv.cnsp.monitorfish.domain.entities.mission_actions
package fr.gouv.cnsp.monitorfish.domain.entities.mission.mission_actions

enum class MissionActionType(val value: String) {
SEA_CONTROL("SEA_CONTROL"),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package fr.gouv.cnsp.monitorfish.domain.entities.mission_actions
package fr.gouv.cnsp.monitorfish.domain.entities.mission.mission_actions

class OtherInfraction {
var infractionType: InfractionType? = null
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package fr.gouv.cnsp.monitorfish.domain.entities.mission_actions
package fr.gouv.cnsp.monitorfish.domain.entities.mission.mission_actions

class SpeciesControl {
var speciesCode: String? = null
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package fr.gouv.cnsp.monitorfish.domain.entities.mission_actions
package fr.gouv.cnsp.monitorfish.domain.entities.mission.mission_actions

class SpeciesInfraction {
var infractionType: InfractionType? = null
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package fr.gouv.cnsp.monitorfish.domain.entities.mission.mission_actions.actrep

enum class ActivityCode {
FIS,
LAN,
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package fr.gouv.cnsp.monitorfish.domain.entities.mission_actions.actrep
package fr.gouv.cnsp.monitorfish.domain.entities.mission.mission_actions.actrep

enum class JointDeploymentPlan(private val species: List<FaoZonesAndSpecy>) {
MEDITERRANEAN_AND_EASTERN_ATLANTIC(MEDITERRANEAN_AND_EASTERN_ATLANTIC_SPECIES),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package fr.gouv.cnsp.monitorfish.domain.entities.mission_actions.actrep
package fr.gouv.cnsp.monitorfish.domain.entities.mission.mission_actions.actrep

typealias FaoZones = List<String>
typealias FaoZonesAndSpecy = Pair<FaoZones, String>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package fr.gouv.cnsp.monitorfish.domain.entities.reporting

import com.neovisionaries.i18n.CountryCode
import fr.gouv.cnsp.monitorfish.domain.entities.mission_actions.Infraction
import fr.gouv.cnsp.monitorfish.domain.entities.mission.mission_actions.Infraction
import fr.gouv.cnsp.monitorfish.domain.entities.vessel.VesselIdentifier
import java.time.ZonedDateTime

Expand Down
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_actions.Infraction
import fr.gouv.cnsp.monitorfish.domain.entities.mission.mission_actions.Infraction

interface InfractionRepository {
fun findInfractionByNatinfCode(natinfCode: Int): Infraction
Expand Down
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_actions.MissionAction
import fr.gouv.cnsp.monitorfish.domain.entities.mission.mission_actions.MissionAction
import java.time.ZonedDateTime

interface MissionActionsRepository {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,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.Mission
import fr.gouv.cnsp.monitorfish.domain.exceptions.CouldNotFindException
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Deferred
import java.time.ZonedDateTime
Expand All @@ -21,4 +22,7 @@ interface MissionRepository {
fun findByIds(
ids: List<Int>,
): List<Mission>

@Throws(CouldNotFindException::class)
fun findById(id: Int): Mission
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package fr.gouv.cnsp.monitorfish.domain.use_cases.infraction

import fr.gouv.cnsp.monitorfish.config.UseCase
import fr.gouv.cnsp.monitorfish.domain.entities.mission_actions.Infraction
import fr.gouv.cnsp.monitorfish.domain.entities.mission.mission_actions.Infraction
import fr.gouv.cnsp.monitorfish.domain.repositories.InfractionRepository

@UseCase
class GetAllInfractions(private val infractionRepository: InfractionRepository) {
fun execute(): List<Infraction> {
fun execute(): List<fr.gouv.cnsp.monitorfish.domain.entities.mission.mission_actions.Infraction> {
louptheron marked this conversation as resolved.
Show resolved Hide resolved
return infractionRepository.findAll()
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package fr.gouv.cnsp.monitorfish.domain.use_cases.missions
package fr.gouv.cnsp.monitorfish.domain.use_cases.mission

import fr.gouv.cnsp.monitorfish.config.DatabaseProperties
import fr.gouv.cnsp.monitorfish.config.UseCase
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package fr.gouv.cnsp.monitorfish.domain.use_cases.mission

import fr.gouv.cnsp.monitorfish.config.UseCase
import fr.gouv.cnsp.monitorfish.domain.entities.mission.MissionAndActions
import fr.gouv.cnsp.monitorfish.domain.exceptions.CouldNotFindException
import fr.gouv.cnsp.monitorfish.domain.repositories.MissionRepository
import fr.gouv.cnsp.monitorfish.domain.use_cases.mission.mission_actions.GetMissionActions
import kotlinx.coroutines.async
import kotlinx.coroutines.coroutineScope

@UseCase
class GetMission(
private val missionRepository: MissionRepository,
private val getMissionActions: GetMissionActions,
) {
@Throws(CouldNotFindException::class)
suspend fun execute(missionId: Int): MissionAndActions {
return coroutineScope {
val missionFuture = async {
missionRepository.findById(missionId)
}

val actions = getMissionActions.execute(missionId)

return@coroutineScope MissionAndActions(
mission = missionFuture.await(),
actions = actions,
)
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package fr.gouv.cnsp.monitorfish.domain.use_cases.mission_actions
package fr.gouv.cnsp.monitorfish.domain.use_cases.mission.mission_actions

import fr.gouv.cnsp.monitorfish.config.UseCase
import fr.gouv.cnsp.monitorfish.domain.entities.mission_actions.MissionAction
import fr.gouv.cnsp.monitorfish.domain.entities.mission.mission_actions.MissionAction
import fr.gouv.cnsp.monitorfish.domain.repositories.MissionActionsRepository

@UseCase
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package fr.gouv.cnsp.monitorfish.domain.use_cases.mission_actions
package fr.gouv.cnsp.monitorfish.domain.use_cases.mission.mission_actions

import fr.gouv.cnsp.monitorfish.config.UseCase
import fr.gouv.cnsp.monitorfish.domain.exceptions.CouldNotDeleteException
Expand All @@ -10,9 +10,9 @@ class DeleteMissionAction(private val missionActionsRepository: MissionActionsRe
fun execute(actionId: Int) {
try {
val targetedAction = missionActionsRepository.findById(actionId)
val sofDeletedAction = targetedAction.copy(isDeleted = true)
val softDeletedAction = targetedAction.copy(isDeleted = true)

missionActionsRepository.save(sofDeletedAction)
missionActionsRepository.save(softDeletedAction)
} catch (e: Throwable) {
throw CouldNotDeleteException("Could not find mission action with id: ${e.message}", e)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package fr.gouv.cnsp.monitorfish.domain.use_cases.mission_actions
package fr.gouv.cnsp.monitorfish.domain.use_cases.mission.mission_actions

import fr.gouv.cnsp.monitorfish.config.UseCase
import fr.gouv.cnsp.monitorfish.domain.entities.mission_actions.MissionActionType
import fr.gouv.cnsp.monitorfish.domain.entities.mission_actions.actrep.ActivityCode
import fr.gouv.cnsp.monitorfish.domain.entities.mission_actions.actrep.JointDeploymentPlan
import fr.gouv.cnsp.monitorfish.domain.entities.mission.mission_actions.MissionActionType
import fr.gouv.cnsp.monitorfish.domain.entities.mission.mission_actions.actrep.ActivityCode
import fr.gouv.cnsp.monitorfish.domain.entities.mission.mission_actions.actrep.JointDeploymentPlan
import fr.gouv.cnsp.monitorfish.domain.exceptions.CodeNotFoundException
import fr.gouv.cnsp.monitorfish.domain.repositories.MissionActionsRepository
import fr.gouv.cnsp.monitorfish.domain.repositories.MissionRepository
import fr.gouv.cnsp.monitorfish.domain.repositories.PortRepository
import fr.gouv.cnsp.monitorfish.domain.repositories.VesselRepository
import fr.gouv.cnsp.monitorfish.domain.use_cases.mission_actions.dtos.ActivityReport
import fr.gouv.cnsp.monitorfish.domain.use_cases.mission_actions.dtos.ActivityReports
import fr.gouv.cnsp.monitorfish.domain.use_cases.mission.mission_actions.dtos.ActivityReport
import fr.gouv.cnsp.monitorfish.domain.use_cases.mission.mission_actions.dtos.ActivityReports
import org.slf4j.LoggerFactory
import java.time.ZonedDateTime

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package fr.gouv.cnsp.monitorfish.domain.use_cases.mission_actions
package fr.gouv.cnsp.monitorfish.domain.use_cases.mission.mission_actions

import fr.gouv.cnsp.monitorfish.config.UseCase
import fr.gouv.cnsp.monitorfish.domain.entities.mission_actions.MissionAction
import fr.gouv.cnsp.monitorfish.domain.entities.mission.mission_actions.MissionAction
import fr.gouv.cnsp.monitorfish.domain.exceptions.CouldNotFindException
import fr.gouv.cnsp.monitorfish.domain.repositories.MissionActionsRepository

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package fr.gouv.cnsp.monitorfish.domain.use_cases.mission_actions
package fr.gouv.cnsp.monitorfish.domain.use_cases.mission.mission_actions

import fr.gouv.cnsp.monitorfish.config.UseCase
import fr.gouv.cnsp.monitorfish.domain.entities.facade.Facade
import fr.gouv.cnsp.monitorfish.domain.entities.mission_actions.MissionAction
import fr.gouv.cnsp.monitorfish.domain.entities.mission_actions.MissionActionType
import fr.gouv.cnsp.monitorfish.domain.entities.mission.mission_actions.MissionAction
import fr.gouv.cnsp.monitorfish.domain.entities.mission.mission_actions.MissionActionType
import fr.gouv.cnsp.monitorfish.domain.repositories.FacadeAreasRepository
import fr.gouv.cnsp.monitorfish.domain.repositories.PortRepository
import org.locationtech.jts.geom.Coordinate
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package fr.gouv.cnsp.monitorfish.domain.use_cases.mission_actions
package fr.gouv.cnsp.monitorfish.domain.use_cases.mission.mission_actions

import fr.gouv.cnsp.monitorfish.config.UseCase
import fr.gouv.cnsp.monitorfish.domain.entities.mission_actions.MissionAction
import fr.gouv.cnsp.monitorfish.domain.entities.mission.mission_actions.MissionAction
import fr.gouv.cnsp.monitorfish.domain.repositories.MissionActionsRepository
import org.slf4j.LoggerFactory

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package fr.gouv.cnsp.monitorfish.domain.use_cases.mission_actions
package fr.gouv.cnsp.monitorfish.domain.use_cases.mission.mission_actions

import fr.gouv.cnsp.monitorfish.config.UseCase
import fr.gouv.cnsp.monitorfish.domain.entities.mission_actions.ControlsSummary
import fr.gouv.cnsp.monitorfish.domain.entities.mission_actions.MissionActionType
import fr.gouv.cnsp.monitorfish.domain.entities.mission.mission_actions.ControlsSummary
import fr.gouv.cnsp.monitorfish.domain.entities.mission.mission_actions.MissionActionType
import fr.gouv.cnsp.monitorfish.domain.exceptions.CodeNotFoundException
import fr.gouv.cnsp.monitorfish.domain.repositories.GearRepository
import fr.gouv.cnsp.monitorfish.domain.repositories.MissionActionsRepository
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package fr.gouv.cnsp.monitorfish.domain.use_cases.mission_actions
package fr.gouv.cnsp.monitorfish.domain.use_cases.mission.mission_actions

import fr.gouv.cnsp.monitorfish.config.UseCase
import fr.gouv.cnsp.monitorfish.domain.entities.mission_actions.MissionAction
import fr.gouv.cnsp.monitorfish.domain.entities.mission.mission_actions.MissionAction
import fr.gouv.cnsp.monitorfish.domain.repositories.MissionActionsRepository
import org.slf4j.LoggerFactory

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package fr.gouv.cnsp.monitorfish.domain.use_cases.mission_actions.dtos
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_actions.MissionAction
import fr.gouv.cnsp.monitorfish.domain.entities.mission_actions.actrep.ActivityCode
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

data class ActivityReport(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package fr.gouv.cnsp.monitorfish.domain.use_cases.mission_actions.dtos
package fr.gouv.cnsp.monitorfish.domain.use_cases.mission.mission_actions.dtos

data class ActivityReports(
val activityReports: List<ActivityReport>,
Expand Down
Loading
Loading