Skip to content

Commit

Permalink
feat(mision-action): output and controller
Browse files Browse the repository at this point in the history
 - output object (mission action output, envOutput, fishoutput, navOutput)
 - Controller and conversion from entity to output
 - graphql définition
 - test outputs
  • Loading branch information
xtiannyeto committed Nov 9, 2024
1 parent 2eb51eb commit 56248a0
Show file tree
Hide file tree
Showing 18 changed files with 1,054 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package fr.gouv.dgampa.rapportnav.infrastructure.api.bff.model.v2

import fr.gouv.dgampa.rapportnav.domain.entities.mission.env.envActions.ActionTargetTypeEnum
import fr.gouv.dgampa.rapportnav.domain.entities.mission.env.envActions.InfractionEntity
import fr.gouv.dgampa.rapportnav.domain.entities.mission.env.envActions.VehicleTypeEnum
import org.locationtech.jts.geom.Geometry

interface BaseMissionEnvActionDataOutput {
val completedBy: String?
val geom: Geometry?
val facade: String?
val department: String?
val isAdministrativeControl: Boolean?
val isComplianceWithWaterRegulationsControl: Boolean?
val isSafetyEquipmentAndStandardsComplianceControl: Boolean?
val isSeafarersControl: Boolean?
val openBy: String?
val observations: String?
val observationsByUnit: String?
val actionNumberOfControls: Int?
val actionTargetType: ActionTargetTypeEnum?
val vehicleType: VehicleTypeEnum?
val infractions: List<InfractionEntity>?
val coverMissionZone: Boolean?
val formattedControlPlans: Any?
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package fr.gouv.dgampa.rapportnav.infrastructure.api.bff.model.v2

import fr.gouv.dgampa.rapportnav.domain.entities.mission.fish.fishActions.*

interface BaseMissionFishActionDataOutput {
val vesselId: Int?
val vesselName: String?
val internalReferenceNumber: String?
val externalReferenceNumber: String?
val districtCode: String?
val faoAreas: List<String>
val fishActionType: MissionActionType
val emitsVms: ControlCheck?
val emitsAis: ControlCheck?
val logbookMatchesActivity: ControlCheck?
val licencesMatchActivity: ControlCheck?
val speciesWeightControlled: Boolean?
val speciesSizeControlled: Boolean?
val separateStowageOfPreservedSpecies: ControlCheck?
val logbookInfractions: List<LogbookInfraction>
val licencesAndLogbookObservations: String?
val gearInfractions: List<GearInfraction>
val speciesInfractions: List<SpeciesInfraction>
val speciesObservations: String?
val seizureAndDiversion: Boolean?
val otherInfractions: List<OtherInfraction>
val numberOfVesselsFlownOver: Int?
val unitWithoutOmegaGauge: Boolean?
val controlQualityComments: String?
val feedbackSheetRequired: Boolean?
val userTrigram: String
val segments: List<FleetSegment>
val facade: String?
val longitude: Double?
val latitude: Double?
val portLocode: String?
var portName: String?
val vesselTargeted: ControlCheck?
val seizureAndDiversionComments: String?
val otherComments: String?
val gearOnboard: List<GearControl>
val speciesOnboard: List<SpeciesControl>
val isFromPoseidon: Boolean
val isDeleted: Boolean
val hasSomeGearsSeized: Boolean
val hasSomeSpeciesSeized: Boolean
val completedBy: String?
val completion: Completion
val isAdministrativeControl: Boolean?
val isComplianceWithWaterRegulationsControl: Boolean?
val isSafetyEquipmentAndStandardsComplianceControl: Boolean?
val isSeafarersControl: Boolean?
var observationsByUnit: String?
var speciesQuantitySeized: Int ?
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package fr.gouv.dgampa.rapportnav.infrastructure.api.bff.model.v2

import fr.gouv.dgampa.rapportnav.domain.entities.mission.env.envActions.VesselSizeEnum
import fr.gouv.dgampa.rapportnav.domain.entities.mission.env.envActions.VesselTypeEnum
import fr.gouv.dgampa.rapportnav.domain.entities.mission.nav.control.ControlMethod
import fr.gouv.dgampa.rapportnav.domain.entities.mission.nav.status.ActionStatusReason
import java.time.Instant

interface BaseMissionNavActionDataOutput {
val startDateTimeUtc: Instant?
val endDateTimeUtc: Instant?
val observations: String?
val latitude: Double?
val longitude: Double?
val detectedPollution: Boolean?
val pollutionObservedByAuthorizedAgent: Boolean?
val diversionCarriedOut: Boolean?
val isSimpleBrewingOperationDone: Boolean?
val isAntiPolDeviceDeployed: Boolean?
val controlMethod: ControlMethod?
val vesselIdentifier: String?
val vesselType: VesselTypeEnum?
val vesselSize: VesselSizeEnum?
val identityControlledPerson: String?
val nbOfInterceptedVessels: Int?
val nbOfInterceptedMigrants: Int?
val nbOfSuspectedSmugglers: Int?
val isVesselRescue: Boolean?
val isPersonRescue: Boolean?
val isVesselNoticed: Boolean?
val isVesselTowed: Boolean?
val isInSRRorFollowedByCROSSMRCC: Boolean?
val numberPersonsRescued: Int?
val numberOfDeaths: Int?
val operationFollowsDEFREP: Boolean?
val locationDescription: String?
val isMigrationRescue: Boolean?
val nbOfVesselsTrackedWithoutIntervention: Int?
val nbAssistedVesselsReturningToShore: Int?
val reason: ActionStatusReason?
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package fr.gouv.dgampa.rapportnav.infrastructure.api.bff.model.v2

import fr.gouv.dgampa.rapportnav.domain.use_cases.mission.GetMission
import fr.gouv.dgampa.rapportnav.domain.use_cases.mission.action.v2.*
import fr.gouv.dgampa.rapportnav.infrastructure.api.bff.model.v2.MissionActionOutput
import fr.gouv.dgampa.rapportnav.infrastructure.api.bff.model.v2.MissionActionTimeLineOutput
import org.slf4j.LoggerFactory
import org.springframework.graphql.data.method.annotation.Argument
import org.springframework.graphql.data.method.annotation.QueryMapping
import org.springframework.stereotype.Controller
import java.util.*

@Controller
class MissionActionController(
private val getMission: GetMission,
private val getNavActionById: GetNavActionById,
private val getEnvActionById: GetEnvActionById,
private val getFishActionById: GetFishActionById,
private val getEnvActionByMissionId: GetEnvActionListByMissionId,
private val getNavActionByMissionId: GetNavActionListByMissionId,
private val getFIshListActionByMissionId: GetFishActionListByMissionId
) {
private val logger = LoggerFactory.getLogger(MissionActionController::class.java)

@QueryMapping
fun timeline(@Argument missionId: Int): List<MissionActionTimeLineOutput?> {
val envActions = getEnvActionByMissionId.execute(missionId = missionId)
val navActions = getNavActionByMissionId.execute(missionId = missionId)
val fishActions = getFIshListActionByMissionId.execute(missionId = missionId)
return (envActions + navActions + fishActions)
.sortedByDescending { action -> action.startDateTimeUtc }
.map { action -> MissionActionTimeLineOutput.fromMissionActionEntity(action) }
}

@QueryMapping
fun missionAction(
@Argument actionId: String,
@Argument missionId: Int,
): MissionActionOutput? {
val navAction = getNavActionById.execute(actionId = UUID.fromString(actionId))
if (navAction != null) return MissionActionOutput.fromMissionActionEntity(navAction)
val fishAction = getFishActionById.execute(missionId = missionId, actionId = actionId)
if (fishAction != null) return MissionActionOutput.fromMissionActionEntity(fishAction)
val envAction = getEnvActionById.execute(missionId = missionId, actionId = actionId) ?: return null
return MissionActionOutput.fromMissionActionEntity(envAction)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package fr.gouv.dgampa.rapportnav.infrastructure.api.bff.model.v2

import fr.gouv.dgampa.rapportnav.domain.entities.mission.nav.control.ControlAdministrativeEntity
import fr.gouv.dgampa.rapportnav.domain.entities.mission.nav.control.ControlGensDeMerEntity
import fr.gouv.dgampa.rapportnav.domain.entities.mission.nav.control.ControlNavigationEntity
import fr.gouv.dgampa.rapportnav.domain.entities.mission.nav.control.ControlSecurityEntity
import java.time.Instant

open class MissionActionDataOutput(
open val startDateTimeUtc: Instant?,
open val endDateTimeUtc: Instant? = null,
open val controlSecurity: ControlSecurityEntity? = null,
open val controlGensDeMer: ControlGensDeMerEntity? = null,
open val controlNavigation: ControlNavigationEntity? = null,
open val controlAdministrative: ControlAdministrativeEntity? = null,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package fr.gouv.dgampa.rapportnav.infrastructure.api.bff.model.v2

import fr.gouv.dgampa.rapportnav.domain.entities.mission.CompletenessForStatsEntity
import fr.gouv.dgampa.rapportnav.domain.entities.mission.env.MissionSourceEnum
import fr.gouv.dgampa.rapportnav.domain.entities.mission.nav.action.ActionType
import fr.gouv.dgampa.rapportnav.domain.entities.mission.v2.MissionActionEntity
import fr.gouv.dgampa.rapportnav.domain.entities.mission.v2.MissionEnvActionEntity
import fr.gouv.dgampa.rapportnav.domain.entities.mission.v2.MissionFishActionEntity
import fr.gouv.dgampa.rapportnav.domain.entities.mission.v2.MissionNavActionEntity

open class MissionActionOutput(
open val id: String,
open val missionId: Int,
open val actionType: ActionType,
open val isCompleteForStats: Boolean? = null,
open val completenessForStats: CompletenessForStatsEntity? = null,
open val sourcesOfMissingDataForStats: List<MissionSourceEnum>? = null,
open val data: MissionActionDataOutput
) {
companion object {
fun fromMissionActionEntity(action: MissionActionEntity): MissionActionOutput? {
return when (action) {
is MissionNavActionEntity -> MissionNavActionOutput.fromMissionActionEntity(action)
is MissionEnvActionEntity -> MissionEnvActionOutput.fromMissionActionEntity(action)
is MissionFishActionEntity -> MissionFishActionOutput.fromMissionActionEntity(action)
else -> null
}
}
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package fr.gouv.dgampa.rapportnav.infrastructure.api.bff.model.v2

import fr.gouv.dgampa.rapportnav.domain.entities.mission.env.envActions.ActionTargetTypeEnum
import fr.gouv.dgampa.rapportnav.domain.entities.mission.env.envActions.InfractionEntity
import fr.gouv.dgampa.rapportnav.domain.entities.mission.env.envActions.VehicleTypeEnum
import fr.gouv.dgampa.rapportnav.domain.entities.mission.nav.control.ControlAdministrativeEntity
import fr.gouv.dgampa.rapportnav.domain.entities.mission.nav.control.ControlGensDeMerEntity
import fr.gouv.dgampa.rapportnav.domain.entities.mission.nav.control.ControlNavigationEntity
import fr.gouv.dgampa.rapportnav.domain.entities.mission.nav.control.ControlSecurityEntity
import org.locationtech.jts.geom.Geometry
import java.time.Instant

class MissionEnvActionDataOutput(
override val startDateTimeUtc: Instant? = null,
override val endDateTimeUtc: Instant? = null,
override val completedBy: String? = null,
override val geom: Geometry? = null,
override val facade: String? = null,
override val department: String? = null,
override val isAdministrativeControl: Boolean? = null,
override val isComplianceWithWaterRegulationsControl: Boolean? = null,
override val isSafetyEquipmentAndStandardsComplianceControl: Boolean? = null,
override val isSeafarersControl: Boolean? = null,
override val openBy: String? = null,
override val observations: String? = null,
override val observationsByUnit: String? = null,
override val actionNumberOfControls: Int? = null,
override val actionTargetType: ActionTargetTypeEnum? = null,
override val vehicleType: VehicleTypeEnum? = null,
override val infractions: List<InfractionEntity>? = listOf(),
override val coverMissionZone: Boolean? = null,
override val controlSecurity: ControlSecurityEntity? = null,
override val controlGensDeMer: ControlGensDeMerEntity? = null,
override val controlNavigation: ControlNavigationEntity? = null,
override val controlAdministrative: ControlAdministrativeEntity? = null,
override val formattedControlPlans: Any? = null
) : MissionActionDataOutput(
startDateTimeUtc = startDateTimeUtc, endDateTimeUtc = endDateTimeUtc, controlSecurity = controlSecurity,
controlGensDeMer = controlGensDeMer,
controlNavigation = controlNavigation,
controlAdministrative = controlAdministrative
),
BaseMissionEnvActionDataOutput











Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package fr.gouv.dgampa.rapportnav.infrastructure.api.bff.model.v2

import fr.gouv.dgampa.rapportnav.domain.entities.mission.CompletenessForStatsEntity
import fr.gouv.dgampa.rapportnav.domain.entities.mission.env.MissionSourceEnum
import fr.gouv.dgampa.rapportnav.domain.entities.mission.nav.action.ActionType
import fr.gouv.dgampa.rapportnav.domain.entities.mission.v2.MissionActionEntity
import fr.gouv.dgampa.rapportnav.domain.entities.mission.v2.MissionEnvActionEntity

class MissionEnvActionOutput(
override val id: String,
override val missionId: Int,
override val actionType: ActionType,
override val isCompleteForStats: Boolean?,
override val completenessForStats: CompletenessForStatsEntity? = null,
override val sourcesOfMissingDataForStats: List<MissionSourceEnum>? = null,
override val data: MissionEnvActionDataOutput
) : MissionActionOutput(id = id, missionId = missionId, actionType = actionType, data = data) {

companion object {
fun fromMissionActionEntity(action: MissionActionEntity): MissionEnvActionOutput {
val envAction = action as MissionEnvActionEntity
return MissionEnvActionOutput(
id = envAction.id.toString(),
missionId = envAction.missionId,
actionType = envAction.actionType.toString().let { ActionType.valueOf(it) },
isCompleteForStats = envAction.isCompleteForStats,
data = MissionEnvActionDataOutput(
startDateTimeUtc = envAction.actionStartDateTimeUtc,
endDateTimeUtc = envAction.actionEndDateTimeUtc,
completedBy = envAction.completedBy,
formattedControlPlans = null, //TODO: transform controlPlans into formatted,
geom = envAction.geom,
facade = envAction.facade,
department = envAction.department,
isAdministrativeControl = envAction.isAdministrativeControl,
isComplianceWithWaterRegulationsControl = envAction.isComplianceWithWaterRegulationsControl,
isSafetyEquipmentAndStandardsComplianceControl = envAction.isSafetyEquipmentAndStandardsComplianceControl,
isSeafarersControl = envAction.isSeafarersControl,
openBy = envAction.openBy,
observations = envAction.observations,
observationsByUnit = envAction.observationsByUnit,
actionNumberOfControls = envAction.actionNumberOfControls,
actionTargetType = envAction.actionTargetType,
vehicleType = envAction.vehicleType,
infractions = envAction.infractions,
coverMissionZone = envAction.coverMissionZone,
controlSecurity = envAction.controlSecurity,
controlGensDeMer = envAction.controlGensDeMer,
controlNavigation = envAction.controlNavigation,
controlAdministrative = envAction.controlAdministrative,
)
)
}
}
}
Loading

0 comments on commit 56248a0

Please sign in to comment.