Skip to content
Open
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 @@ -3,9 +3,11 @@ package fr.gouv.dgampa.rapportnav.domain.entities.mission.env.controlResources
import fr.gouv.dgampa.rapportnav.infrastructure.api.bff.model.v2.env.ControlUnitResourceEnv

data class ControlResourceEntity(
val id: Int,
val name: String,
val type: ControlUnitResourceType
val id: Int? = null,
val name: String? = null,
val type: ControlUnitResourceType? = null,
val registrationId: String? = null,
val radioFrequency: String? = null
) {
companion object {
fun fromControlUnitResourceEnv(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package fr.gouv.dgampa.rapportnav.domain.entities.mission.fish

data class ControlResource(
val id: Int,
val name: String,
val id: Int? = null,
val name: String? = null,
val registrationId: String? = null,
val radioFrequency: String? = null
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package fr.gouv.dgampa.rapportnav.domain.entities.mission.fish.fishActions

enum class LogbookMessagePurpose {
// TODO Find out what this purpose code means.
ACS,

/** Emergency. */
ECY,

/** Vessels grounded and called by the authorities. */
GRD,

/** Landing. */
LAN,

/** Other. */
OTH,

/** Refueling. */
REF,

/** Repair. */
REP,

/** Rest. */
RES,

/** Return for Scientific Research. */
SCR,

/** Sheltering. */
SHE,

/** Transhipment. */
TRA,
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import com.neovisionaries.i18n.CountryCode
import fr.gouv.dgampa.rapportnav.domain.entities.mission.fish.ControlUnit
import java.time.Instant


typealias FishAction = MissionAction

data class MissionAction(
Expand Down Expand Up @@ -66,5 +67,19 @@ data class MissionAction(
var speciesQuantitySeized: Int ? = null,
val infractions: List<FishInfraction> = listOf(),
val hasDivingDuringOperation: Boolean? = null,
val incidentDuringOperation: Boolean? = null
val incidentDuringOperation: Boolean? = null,
val vesselLength: Double? = null,
val vesselType: String? = null,
val imo: String? = null,
val proprietorName: String? = null,
val proprietorPhones: List<String>? = listOf(),
val proprietorEmails: List<String>? = listOf(),
val proprietorNationality: String? = null,
val proprietorAddress: String? = null,
val tripNumber: String? = null,
val pnoReportId: String? = null,
val pnoPurpose: LogbookMessagePurpose? = null,
val lastDeparturePortLocode: String? = null,
val lastDeparturePortName: String? = null,
val lastDepartureDateTime: Instant? = null
)
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@ package fr.gouv.dgampa.rapportnav.domain.entities.mission.sati

import com.neovisionaries.i18n.CountryCode
import java.time.Instant
import java.util.UUID

data class AddressEntity(
val id: UUID? = null,
val id: Int? = null,
val street: String? = null,
val fullAddress: String? = null,
val zipcode: String? = null,
val town: String? = null,
val lat: Double? = null,
val lng: Double? = null,
val country: CountryCode? = null,
val createdAt: Instant? = null
val lng: Double? = null,
val lat: Double? = null,
val createdAt: Instant? = null,
val updatedAt: Instant? = null
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package fr.gouv.dgampa.rapportnav.domain.entities.mission.sati

enum class AuthorityType {
AECP,
OTHERS,
MEMBER_FR
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
package fr.gouv.dgampa.rapportnav.domain.entities.mission.sati

import com.neovisionaries.i18n.CountryCode
import java.time.Instant
import java.util.UUID

data class ContactEntity(
val id: UUID? = null,
val id: Int? = null,
val fullName: String? = null,
val nationality: CountryCode? = null,
val firstName: String? = null,
val lastName: String? = null,
val nationality: String? = null,
val email: String? = null,
val phone: String? = null,
val address: AddressEntity? = null,
val createdAt: Instant? = null
val createdAt: Instant? = null,
val updatedAt: Instant? = null
)
Original file line number Diff line number Diff line change
@@ -1,69 +1,19 @@
package fr.gouv.dgampa.rapportnav.domain.entities.mission.sati

import com.neovisionaries.i18n.CountryCode
import fr.gouv.dgampa.rapportnav.domain.entities.mission.env.controlResources.ControlResourceEntity
import java.time.Instant
import java.util.UUID
import java.util.*

data class SatiEntity(
val id: UUID? = null,
val module: String,
val actionId: String,
val createdAt: Instant? = null,
val updatedAt: Instant? = null,
val actionTaken: String? = null,

val agentContact: ContactEntity? = null,
val appointingAuthority: String? = null,
val beneficialOwnerContact: ContactEntity? = null,
val catchCertificateInfo: Boolean? = null,
val chartererContact: ContactEntity? = null,
val commonMarketingStandards: Boolean? = null,
val driverContact: ContactEntity? = null,
val euFishingTripId: String? = null,
val fisheryLotLabelling: Boolean? = null,
val fisheryProductDocumentsInspection: Boolean? = null,
val fisheryProductStorageMechanismInspected: Boolean? = null,
val fisheryProductWeighedBeforeSale: Boolean? = null,
val freshnessCategories: String? = null,
val importerContact: ContactEntity? = null,
val infringementsObservations: String? = null,
val inspectionEndDatetimeUtc: Instant? = null,
val inspectionStartDatetimeUtc: Instant,
val inspectionLocationAddressId: String? = null,
val inspectorComments: String? = null,
val inspectorNameOrId: String? = null,
val inspectorSignature: Boolean? = null,
val inspectorUniqueId: String? = null,
val landingDeclarationInfo: Boolean? = null,
val lotIdSpeciesQuantities: String? = null,
val lotsArt58Compliance: Boolean? = null,
val marketOwnerContact: ContactEntity? = null,
val marketOwnerRepresentativeContact: ContactEntity? = null,
val marketPremisesAddressId: String? = null,
val marketPremisesLocation: String? = null,
val marketPremisesName: String? = null,
val masterComments: String? = null,
val masterContact: ContactEntity? = null,
val newLotCompositionInfo: String? = null,
val operatorComments: String? = null,
val operatorSignature: Boolean? = null,
val patrolVesselExternalMarking: String? = null,
val patrolVesselRadioCallSign: String? = null,
val registeredBuyerContact: ContactEntity? = null,
val responsiblePersonSignature: Boolean? = null,
val sizeGradingCategories: String? = null,
val supplierInvoiceInfo: Boolean? = null,
val takeOverDeclarationInfo: Boolean? = null,
val traceabilityRecordingSystemArt58: Boolean? = null,
val traceabilitySupplierIdentificationSystem: Boolean? = null,
val tractorRegistrationNumber: String? = null,
val trailerRegistrationNumber: String? = null,
val transportDocumentInfo: Boolean? = null,
val transporterComments: String? = null,
val transporterSignature: Boolean? = null,
val useOfUndersizedFisheryProducts: Boolean? = null,
val vehicleNationality: CountryCode? = null,
val vehicleOwnerContact: ContactEntity? = null,
val vehicleType: String? = null,
val vesselOwnerContact: ContactEntity? = null
data class SatiEntity(
var id: UUID? = null,
var module: SatiModuleType,
var actionId: String,
var resource: ControlResourceEntity? = null,
var vessel: SatiVesselEntity? = null,
var createdAt: Instant? = null,
var updatedAt: Instant? = null,
var startDatetimeUtc: Instant? = null,
var endDatetimeUtc: Instant? = null,
var inspectors: List<SatiInspectorEntity>? = emptyList(),
)
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,56 @@ package fr.gouv.dgampa.rapportnav.domain.entities.mission.sati

import fr.gouv.dgampa.rapportnav.domain.entities.mission.fish.fishActions.MissionAction
import fr.gouv.dgampa.rapportnav.infrastructure.api.bff.model.v2.sati.Sati
import fr.gouv.dgampa.rapportnav.infrastructure.database.repositories.mission.sati.SatiModelMapper.toModel
import fr.gouv.dgampa.rapportnav.infrastructure.database.model.mission.sati.SatiModelMapper.toModel

object SatiEntityMapper {
fun merge(sati: SatiEntity?, action: MissionAction): SatiEntity? {
return sati
fun merge(sati: SatiEntity, action: MissionAction): SatiEntity {
return SatiEntity(
id = sati.id,
module = sati.module,
actionId = action.id?.toString() ?: "",
createdAt = sati.createdAt,
updatedAt = sati.updatedAt,
vessel = SatiVesselEntity(
jpe = SatiJpeEntity(
pnoId = action.pnoReportId,
portName = action.lastDeparturePortName,
portId = action.lastDeparturePortLocode,
lastStopDate = action.lastDepartureDateTime,
tripNumber = action.tripNumber ?: sati.vessel?.jpe?.tripNumber,
pnoType = action.pnoPurpose ?: sati.vessel?.jpe?.pnoType,
),
ircs = action.ircs,
imo = action.imo,
type = action.vesselType,
name = action.vesselName,
length = action.vesselLength,
immat = action.internalReferenceNumber,
extRef = action.externalReferenceNumber,
owner = SatiPartyEntity(
contact = ContactEntity(
id = null,
createdAt = null,
fullName = action.proprietorName,
email = action.proprietorEmails?.firstOrNull(),
phone = action.proprietorPhones?.firstOrNull(),
nationality = action.proprietorNationality,
address = AddressEntity(
fullAddress = action.proprietorAddress
),
)

),
charterer = null,
agent = sati.vessel?.agent,
master = sati.vessel?.master,
flagState = action.flagState,
),
resource = sati.resource,
inspectors = sati.inspectors,
startDatetimeUtc = action.actionDatetimeUtc,
endDatetimeUtc = action.actionEndDatetimeUtc
)
}

fun merge(sati: SatiEntity?, input: Sati): SatiEntity? {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package fr.gouv.dgampa.rapportnav.domain.entities.mission.sati

import java.time.Instant

data class SatiInspectorEntity(
val id: Int? = null,
val agentId: Int? = null,
val party: SatiPartyEntity? = null,
val authorityType: AuthorityType? = null,
val externalAgentId: String? = null,
val isOutOfUnit: Boolean = false,
val createdAt: Instant? = null,
val updatedAt: Instant? = null
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package fr.gouv.dgampa.rapportnav.domain.entities.mission.sati

import fr.gouv.dgampa.rapportnav.domain.entities.mission.fish.fishActions.LogbookMessagePurpose
import java.time.Instant

data class SatiJpeEntity(
val pnoId: String? = null,
val portId: String? = null,
val portName: String? = null,
val tripNumber: String? = null,
val lastStopDate: Instant? = null,
val pnoType: LogbookMessagePurpose? = null
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package fr.gouv.dgampa.rapportnav.domain.entities.mission.sati

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


enum class SatiModuleType {
M1,
M3,
M5,
M6,
M7;

companion object {
fun fromMissionActionType(type: MissionActionType): SatiModuleType = when (type) {
MissionActionType.SEA_CONTROL -> M1
MissionActionType.LAND_CONTROL -> M3
MissionActionType.AIR_CONTROL -> M5
MissionActionType.AIR_SURVEILLANCE -> M6
MissionActionType.OBSERVATION -> M7
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package fr.gouv.dgampa.rapportnav.domain.entities.mission.sati

import java.time.Instant

data class SatiPartyEntity(
val id: Int? = null,
val partyType: String? = null,
val comments: String? = null,
val signature: Boolean = false,
val contact: ContactEntity? = null,
val createdAt: Instant? = null,
val updatedAt: Instant? = null
Comment on lines +11 to +12

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Les champs d'audit, en général, je les remonte pas côté domain. Ils ont pas vraiment de business logic.
Par contre, je les remonte du Model vers le Admin type quand on les gère depuis l'admin panel

)
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package fr.gouv.dgampa.rapportnav.domain.entities.mission.sati

import com.neovisionaries.i18n.CountryCode
import java.time.Instant

data class SatiVesselEntity(
val id: Int? = null,
val jpe: SatiJpeEntity? = null,
val type: String? = null,
val name: String? = null,
val immat: String? = null,
val imo: String? = null,
val length: Double? = null,
val extRef: String? = null,
val ircs: String? = null,
val owner: SatiPartyEntity? = null,
val flagState: CountryCode? = null,
val charterer: SatiPartyEntity? = null,
val agent: SatiPartyEntity? = null,
val master: SatiPartyEntity? = null,
val isMasterOwner: Boolean = false,
val createdAt: Instant? = null,
val updatedAt: Instant? = null
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package fr.gouv.dgampa.rapportnav.domain.use_cases.mission.action.v2

import fr.gouv.dgampa.rapportnav.config.UseCase
import fr.gouv.dgampa.rapportnav.domain.use_cases.user.GetServiceForUser
import org.springframework.beans.factory.annotation.Value

@UseCase
class EnableSati(
private val getServiceForUser: GetServiceForUser,
@param:Value("\${sati.enabled-services}") private val serviceIds: List<Int>
) {
fun execute(): Boolean {
val serviceId = getServiceForUser.execute()
return (serviceIds.contains(serviceId?.id))
}
}
Loading
Loading