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

[Préavis] Tentatives d'amélioration de la base de code [DO NOT MERGE] #3277

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
91af5ed
Add & integrate manual prior notifications SQL table
ivangabriele Jun 3, 2024
6652754
Add manual prior notification create & update in Backend
ivangabriele Jun 4, 2024
63af5c2
Fix many issues and refactor manual prior notifications in Backend
ivangabriele Jun 6, 2024
250b10c
Add prior notification form in Frontend
ivangabriele Jun 6, 2024
0f2ca0e
Update SQL migration file name index following rebase
ivangabriele Jun 6, 2024
b5a6a3a
Add missing trip gear codes in manual prior notification in Backend
ivangabriele Jun 6, 2024
bd38eb1
Initialize prior notification sentAt form value with current date
ivangabriele Jun 6, 2024
ba666a1
Add prior notification valid form submission logic & edition header
ivangabriele Jun 6, 2024
d901eb9
Fix mapping for swordfish & bluefin tuna cases in prior notification …
ivangabriele Jun 6, 2024
d3cd547
Remove unused report_datetime_utc column in new manual_prior_notifica…
ivangabriele Jun 6, 2024
4bac197
Add bluefin tuna & swordfish dummy manual prior notifications in test…
ivangabriele Jun 6, 2024
99d5c58
Remove useless isLessThanTwelveMetersVessel filter in manual prior no…
ivangabriele Jun 6, 2024
4eba4c8
Add missing trip segments in Backend manual prior notifications
ivangabriele Jun 10, 2024
008a321
Add JpaManualPriorNotificationRepository inte tests
ivangabriele Jun 10, 2024
c1723d9
Fix DateRangePicker calendar popup width via monitor-ui upgrade
ivangabriele Jun 11, 2024
d63543b
Update fishing catches field label in prior notification form
ivangabriele Jun 11, 2024
3539c00
Add prior notification form create & update e2e test
ivangabriele Jun 11, 2024
240282b
Ensure specific fishing catches ordering in prior notification form
ivangabriele Jun 11, 2024
3985c34
Fix test data for reporting e2e tests
ivangabriele Jun 11, 2024
3c8a48d
Fix missing cloning in prior notification form fishing catches field
ivangabriele Jun 11, 2024
2455eaa
Fix unordered extended specy code cases in prior notification form
ivangabriele Jun 11, 2024
46ff324
Add missing expected landing date validation in prior notification form
ivangabriele Jun 11, 2024
ed48d56
Add prior notification form validation e2e test
ivangabriele Jun 11, 2024
4490c99
Update Backend tests following test data update
ivangabriele Jun 12, 2024
b96c08c
Refactor a few things following review in prior notification Backend
ivangabriele Jun 12, 2024
0fc8ce4
Abstract common prior notification & logbook report entities props in…
ivangabriele Jun 12, 2024
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 @@ -6,7 +6,7 @@ import com.fasterxml.jackson.databind.SerializationFeature
import com.fasterxml.jackson.databind.jsontype.NamedType
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule
import fr.gouv.cnsp.monitorfish.domain.entities.alerts.type.AlertTypeMapping
import fr.gouv.cnsp.monitorfish.domain.entities.logbook.Catch
import fr.gouv.cnsp.monitorfish.domain.entities.logbook.LogbookFishingCatch
import fr.gouv.cnsp.monitorfish.domain.entities.logbook.ProtectedSpeciesCatch
import fr.gouv.cnsp.monitorfish.domain.entities.reporting.ReportingTypeMapping
import fr.gouv.cnsp.monitorfish.domain.entities.rules.type.RuleTypeMapping
Expand All @@ -15,7 +15,7 @@ import org.springframework.context.annotation.Configuration
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder
import java.util.*
import fr.gouv.cnsp.monitorfish.domain.entities.alerts.type.IHasImplementation as IAlertsHasImplementation
import fr.gouv.cnsp.monitorfish.domain.entities.logbook.Gear as GearLogbook
import fr.gouv.cnsp.monitorfish.domain.entities.logbook.LogbookTripGear as GearLogbook
import fr.gouv.cnsp.monitorfish.domain.entities.reporting.IHasImplementation as IReportingsHasImplementation
import fr.gouv.cnsp.monitorfish.domain.entities.rules.type.IHasImplementation as IRulesHasImplementation

Expand All @@ -30,7 +30,7 @@ class MapperConfiguration {
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
mapper.propertyNamingStrategy = PropertyNamingStrategies.LOWER_CAMEL_CASE

mapper.registerSubtypes(NamedType(Catch::class.java, "catch"))
mapper.registerSubtypes(NamedType(LogbookFishingCatch::class.java, "catch"))
mapper.registerSubtypes(NamedType(ProtectedSpeciesCatch::class.java, "protectedSpeciesCatch"))
mapper.registerSubtypes(NamedType(GearLogbook::class.java, "gear"))

Expand All @@ -41,19 +41,28 @@ class MapperConfiguration {
return mapper
}

private fun <E> registerRulesSubType(mapper: ObjectMapper, enumOfTypeToAdd: Class<E>) where E : Enum<E>?, E : IRulesHasImplementation? {
private fun <E> registerRulesSubType(
mapper: ObjectMapper,
enumOfTypeToAdd: Class<E>,
) where E : Enum<E>?, E : IRulesHasImplementation? {
Arrays.stream(enumOfTypeToAdd.enumConstants)
.map { enumItem -> NamedType(enumItem.getImplementation(), enumItem.name) }
.forEach { type -> mapper.registerSubtypes(type) }
}

private fun <E> registerAlertsSubType(mapper: ObjectMapper, enumOfTypeToAdd: Class<E>) where E : Enum<E>?, E : IAlertsHasImplementation? {
private fun <E> registerAlertsSubType(
mapper: ObjectMapper,
enumOfTypeToAdd: Class<E>,
) where E : Enum<E>?, E : IAlertsHasImplementation? {
Arrays.stream(enumOfTypeToAdd.enumConstants)
.map { enumItem -> NamedType(enumItem.getImplementation(), enumItem.name) }
.forEach { type -> mapper.registerSubtypes(type) }
}

private fun <E> registerReportingsSubType(mapper: ObjectMapper, enumOfTypeToAdd: Class<E>) where E : Enum<E>?, E : IReportingsHasImplementation? {
private fun <E> registerReportingsSubType(
mapper: ObjectMapper,
enumOfTypeToAdd: Class<E>,
) where E : Enum<E>?, E : IReportingsHasImplementation? {
Arrays.stream(enumOfTypeToAdd.enumConstants)
.map { enumItem -> NamedType(enumItem.getImplementation(), enumItem.name) }
.forEach { type -> mapper.registerSubtypes(type) }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package fr.gouv.cnsp.monitorfish.domain.entities.alerts

import com.fasterxml.jackson.annotation.JsonTypeName
import fr.gouv.cnsp.monitorfish.domain.entities.logbook.Catch
import fr.gouv.cnsp.monitorfish.domain.entities.logbook.LogbookFishingCatch

@JsonTypeName("pnoAndLanCatches")
data class PNOAndLANCatches(
var pno: Catch? = null,
var lan: Catch? = null,
var pno: LogbookFishingCatch? = null,
var lan: LogbookFishingCatch? = null,
)
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import java.time.ZonedDateTime
class Haul() {
var gear: String? = null
var gearName: String? = null
var catches: List<Catch> = listOf()
var catches: List<LogbookFishingCatch> = listOf()
var mesh: Double? = null
var latitude: Double? = null
var longitude: Double? = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import com.fasterxml.jackson.annotation.JsonProperty
import com.fasterxml.jackson.annotation.JsonTypeName

@JsonTypeName("catch")
data class Catch(
data class LogbookFishingCatch(
var weight: Double? = null,
@JsonProperty("nbFish")
var numberFish: Double? = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,26 @@ import fr.gouv.cnsp.monitorfish.domain.entities.species.Species
import fr.gouv.cnsp.monitorfish.domain.exceptions.EntityConversionException
import org.slf4j.LoggerFactory
import java.time.ZonedDateTime
import fr.gouv.cnsp.monitorfish.domain.entities.logbook.Gear as LogbookGear

data class LogbookMessage(
val id: Long,
val id: Long?,
val reportId: String? = null,
val operationNumber: String,
val operationNumber: String?,
val tripNumber: String? = null,
val referencedReportId: String? = null,
val operationDateTime: ZonedDateTime,
val internalReferenceNumber: String? = null,
val externalReferenceNumber: String? = null,
val ircs: String? = null,
val vesselName: String? = null,
// ISO Alpha-3 country code
/** ISO Alpha-3 country code. */
val flagState: String? = null,
val imo: String? = null,
// Submission date of the report by the vessel
val reportDateTime: ZonedDateTime? = null,
// Reception date of the report by the data center
val integrationDateTime: ZonedDateTime,
val analyzedByRules: List<String>,
var rawMessage: String? = null,
val transmissionFormat: LogbookTransmissionFormat,
val transmissionFormat: LogbookTransmissionFormat?,
val software: String? = null,

var acknowledgment: Acknowledgment? = null,
Expand All @@ -40,7 +37,9 @@ data class LogbookMessage(
val message: LogbookMessageValue? = null,
val messageType: String? = null,
val operationType: LogbookOperationType,
val tripGears: List<LogbookGear>? = emptyList(),
// Submission date of the report by the vessel
val reportDateTime: ZonedDateTime?,
val tripGears: List<LogbookTripGear>? = emptyList(),
val tripSegments: List<LogbookTripSegment>? = emptyList(),
) {
private val logger = LoggerFactory.getLogger(LogbookMessage::class.java)
Expand Down Expand Up @@ -425,7 +424,7 @@ data class LogbookMessage(
}
}

private fun addSpeciesName(catch: Catch, species: String, allSpecies: List<Species>) {
private fun addSpeciesName(catch: LogbookFishingCatch, species: String, allSpecies: List<Species>) {
catch.speciesName = allSpecies.find { it.code == species }?.name
}

Expand All @@ -434,7 +433,7 @@ data class LogbookMessage(
}

private fun addGearName(
gear: LogbookGear,
gear: LogbookTripGear,
gearCode: String,
allGears: List<Gear>,
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package fr.gouv.cnsp.monitorfish.domain.entities.logbook
import com.fasterxml.jackson.annotation.JsonTypeName

@JsonTypeName("gear")
class Gear() {
class LogbookTripGear() {
/** Gear code. */
var gear: String? = null
var gearName: String? = null
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package fr.gouv.cnsp.monitorfish.domain.entities.logbook.messages

import com.fasterxml.jackson.annotation.JsonProperty
import fr.gouv.cnsp.monitorfish.domain.entities.logbook.Catch
import fr.gouv.cnsp.monitorfish.domain.entities.logbook.Gear
import fr.gouv.cnsp.monitorfish.domain.entities.logbook.LogbookFishingCatch
import fr.gouv.cnsp.monitorfish.domain.entities.logbook.LogbookTripGear
import java.time.ZonedDateTime

class DEP() : LogbookMessageValue {
var anticipatedActivity: String? = null
var departurePort: String? = null
var departurePortName: String? = null
var speciesOnboard: List<Catch> = listOf()
var gearOnboard: List<Gear> = listOf()
var speciesOnboard: List<LogbookFishingCatch> = listOf()
var gearOnboard: List<LogbookTripGear> = listOf()

@JsonProperty("departureDatetimeUtc")
var departureDateTime: ZonedDateTime? = null
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package fr.gouv.cnsp.monitorfish.domain.entities.logbook.messages

import com.fasterxml.jackson.annotation.JsonProperty
import fr.gouv.cnsp.monitorfish.domain.entities.logbook.Catch
import fr.gouv.cnsp.monitorfish.domain.entities.logbook.LogbookFishingCatch
import java.time.ZonedDateTime

class DIS() : LogbookMessageValue {
var catches: List<Catch> = listOf()
var catches: List<LogbookFishingCatch> = listOf()

@JsonProperty("discardDatetimeUtc")
var discardDateTime: ZonedDateTime? = null
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package fr.gouv.cnsp.monitorfish.domain.entities.logbook.messages

import com.fasterxml.jackson.annotation.JsonProperty
import fr.gouv.cnsp.monitorfish.domain.entities.logbook.Catch
import fr.gouv.cnsp.monitorfish.domain.entities.logbook.LogbookFishingCatch
import java.time.ZonedDateTime

class LAN() : LogbookMessageValue {
var port: String? = null
var portName: String? = null
var catchLanded: List<Catch> = listOf()
var catchLanded: List<LogbookFishingCatch> = listOf()
var sender: String? = null

@JsonProperty("landingDatetimeUtc")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,45 @@
package fr.gouv.cnsp.monitorfish.domain.entities.logbook.messages

import fr.gouv.cnsp.monitorfish.domain.entities.logbook.Catch
import com.fasterxml.jackson.databind.annotation.JsonDeserialize
import com.fasterxml.jackson.databind.annotation.JsonSerialize
import fr.gouv.cnsp.monitorfish.domain.entities.logbook.LogbookFishingCatch
import fr.gouv.cnsp.monitorfish.domain.entities.prior_notification.PriorNotificationType
import fr.gouv.cnsp.monitorfish.utils.ZonedDateTimeDeserializer
import fr.gouv.cnsp.monitorfish.utils.ZonedDateTimeSerializer
import java.time.ZonedDateTime

// TODO Rename to `LogbookMessageValueForPno`.
class PNO() : LogbookMessageValue {
var faoZone: String? = null
var effortZone: String? = null
var catchOnboard: List<LogbookFishingCatch> = emptyList()
var catchToLand: List<LogbookFishingCatch> = emptyList()
var economicZone: String? = null
var statisticalRectangle: String? = null
var effortZone: String? = null

/**
* Global PNO FAO zone.
*
* Only used for cod fishing in the Baltic Sea (instead of regular "per caught species" zones).
*/
var faoZone: String? = null
var latitude: Double? = null
var longitude: Double? = null
var pnoTypes: List<PriorNotificationType> = listOf()
var purpose: String? = null
var pnoTypes: List<PriorNotificationType> = emptyList()

/** Port locode. */
var port: String? = null
var portName: String? = null
var catchOnboard: List<Catch> = listOf()
var catchToLand: List<Catch> = listOf()

@JsonDeserialize(using = ZonedDateTimeDeserializer::class)
@JsonSerialize(using = ZonedDateTimeSerializer::class)
var predictedArrivalDatetimeUtc: ZonedDateTime? = null

@JsonDeserialize(using = ZonedDateTimeDeserializer::class)
@JsonSerialize(using = ZonedDateTimeSerializer::class)
var predictedLandingDatetimeUtc: ZonedDateTime? = null
var purpose: String? = null
var statisticalRectangle: String? = null

@JsonDeserialize(using = ZonedDateTimeDeserializer::class)
@JsonSerialize(using = ZonedDateTimeSerializer::class)
var tripStartDate: ZonedDateTime? = null
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package fr.gouv.cnsp.monitorfish.domain.entities.logbook.messages

import com.fasterxml.jackson.annotation.JsonProperty
import fr.gouv.cnsp.monitorfish.domain.entities.logbook.Gear
import fr.gouv.cnsp.monitorfish.domain.entities.logbook.LogbookTripGear
import java.time.ZonedDateTime

class RTP() : LogbookMessageValue {
var reasonOfReturn: String? = null
var port: String? = null
var portName: String? = null
var gearOnboard: List<Gear> = listOf()
var gearOnboard: List<LogbookTripGear> = listOf()

@JsonProperty("returnDatetimeUtc")
var dateTime: ZonedDateTime? = null
Expand Down

This file was deleted.

Loading
Loading