Skip to content

Commit

Permalink
[Missions] Finalise la validation des formulaires (#2265)
Browse files Browse the repository at this point in the history
## Linked issues

- #2117
- Resolve #2168
- Resolve #2191
- Resolve #2253
- Resolve #2261
- Resolve #2266
- **+** Fix des marges verticales dans les checkbox des appréhensions

----

- [x] Tests E2E (Cypress)
  • Loading branch information
ivangabriele committed Jul 10, 2023
2 parents 0ed598f + e524227 commit a95e610
Show file tree
Hide file tree
Showing 72 changed files with 843 additions and 229 deletions.
3 changes: 3 additions & 0 deletions .sonarcloud.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@ sonar.projectKey = MTES-MCT_monitorfish
sonar.host.url = https://sonarcloud.io

# https://docs.sonarcloud.io/advanced-setup/analysis-scope/
# Exclude Frontend E2E tests from SonarCloud analysis
sonar.exclusions = frontend/cypress/e2e/**/*
# Exclude code duplication detection from SonarCloud analysis
sonar.cpd.exclusions = **/*
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ data class VesselBeaconMalfunctionsResume(
val lastBeaconMalfunctionVesselStatus: VesselStatus?,
) {
companion object {
fun fromBeaconMalfunctions(beaconMalfunctionsWithDetails: List<BeaconMalfunctionWithDetails>): VesselBeaconMalfunctionsResume {
fun fromBeaconMalfunctions(
beaconMalfunctionsWithDetails: List<BeaconMalfunctionWithDetails>,
): VesselBeaconMalfunctionsResume {
val oneYearBefore = ZonedDateTime.now().minusYears(1)

val lastBeaconMalfunction = beaconMalfunctionsWithDetails
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class GearControl {
var gearName: String? = null
var declaredMesh: Double? = null
var controlledMesh: Double? = null
var hasUncontrolledMesh: Boolean = false
var gearWasControlled: Boolean? = null
var comments: String? = null
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,9 @@ import fr.gouv.cnsp.monitorfish.domain.entities.alerts.type.AlertTypeMapping

interface PNOAndLANAlertRepository {
fun save(alert: PNOAndLANAlert)
fun findAlertsOfTypes(types: List<AlertTypeMapping>, internalReferenceNumber: String, tripNumber: String): List<PNOAndLANAlert>
fun findAlertsOfTypes(
types: List<AlertTypeMapping>,
internalReferenceNumber: String,
tripNumber: String,
): List<PNOAndLANAlert>
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ class GetBeaconMalfunction(
beaconMalfunctionId,
)

val riskFactor = lastPositions.find(BeaconMalfunction.getVesselFromBeaconMalfunction(beaconMalfunction))?.riskFactor
val riskFactor = lastPositions.find(
BeaconMalfunction.getVesselFromBeaconMalfunction(beaconMalfunction),
)?.riskFactor
beaconMalfunction.riskFactor = riskFactor

if (riskFactor == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ class SaveBeaconMalfunctionComment(
private val getBeaconMalfunction: GetBeaconMalfunction,
) {
@Throws(IllegalArgumentException::class)
fun execute(beaconMalfunctionId: Int, comment: String, userType: BeaconMalfunctionCommentUserType): BeaconMalfunctionResumeAndDetails {
fun execute(
beaconMalfunctionId: Int,
comment: String,
userType: BeaconMalfunctionCommentUserType,
): BeaconMalfunctionResumeAndDetails {
val beaconMalfunctionComment = BeaconMalfunctionComment(
beaconMalfunctionId = beaconMalfunctionId,
comment = comment,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ class UserAuthorizationController(
*/
@GetMapping("current")
@Operation(summary = "Get current logged user authorization")
fun getCurrentUserAuthorization(request: HttpServletRequest, response: HttpServletResponse): UserAuthorizationDataOutput? {
fun getCurrentUserAuthorization(
request: HttpServletRequest,
response: HttpServletResponse,
): UserAuthorizationDataOutput? {
val email: String? = response.getHeader(UserAuthorizationCheckFilter.EMAIL_HEADER)
if (email == null) {
response.status = HttpServletResponse.SC_UNAUTHORIZED
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ data class BeaconMalfunctionActionDataOutput(
val dateTime: ZonedDateTime,
) {
companion object {
fun fromBeaconMalfunctionAction(beaconMalfunctionAction: BeaconMalfunctionAction): BeaconMalfunctionActionDataOutput {
fun fromBeaconMalfunctionAction(
beaconMalfunctionAction: BeaconMalfunctionAction,
): BeaconMalfunctionActionDataOutput {
return BeaconMalfunctionActionDataOutput(
beaconMalfunctionId = beaconMalfunctionAction.beaconMalfunctionId,
propertyName = beaconMalfunctionAction.propertyName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ data class BeaconMalfunctionCommentDataOutput(
val dateTime: ZonedDateTime,
) {
companion object {
fun fromBeaconMalfunctionComment(beaconMalfunctionComment: BeaconMalfunctionComment): BeaconMalfunctionCommentDataOutput {
fun fromBeaconMalfunctionComment(
beaconMalfunctionComment: BeaconMalfunctionComment,
): BeaconMalfunctionCommentDataOutput {
return BeaconMalfunctionCommentDataOutput(
beaconMalfunctionId = beaconMalfunctionComment.beaconMalfunctionId,
comment = beaconMalfunctionComment.comment,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ data class BeaconMalfunctionNotificationDataOutput(
) {

companion object {
fun fromBeaconMalfunctionNotification(beaconMalfunctionNotification: BeaconMalfunctionNotification): BeaconMalfunctionNotificationDataOutput {
fun fromBeaconMalfunctionNotification(
beaconMalfunctionNotification: BeaconMalfunctionNotification,
): BeaconMalfunctionNotificationDataOutput {
return BeaconMalfunctionNotificationDataOutput(
beaconMalfunctionId = beaconMalfunctionNotification.beaconMalfunctionId,
dateTime = beaconMalfunctionNotification.dateTimeUtc,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ data class BeaconMalfunctionNotificationsDataOutput(
val notifications: List<BeaconMalfunctionNotificationDataOutput>,
) {
companion object {
fun fromBeaconMalfunctionNotifications(beaconMalfunctionNotifications: BeaconMalfunctionNotifications): BeaconMalfunctionNotificationsDataOutput =
fun fromBeaconMalfunctionNotifications(
beaconMalfunctionNotifications: BeaconMalfunctionNotifications,
): BeaconMalfunctionNotificationsDataOutput =
BeaconMalfunctionNotificationsDataOutput(
beaconMalfunctionId = beaconMalfunctionNotifications.beaconMalfunctionId,
dateTime = beaconMalfunctionNotifications.dateTimeUtc,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ data class BeaconMalfunctionResumeAndDetailsDataOutput(
val notifications: List<BeaconMalfunctionNotificationsDataOutput>,
) {
companion object {
fun fromBeaconMalfunctionResumeAndDetails(beaconMalfunctionResumeAndDetails: BeaconMalfunctionResumeAndDetails): BeaconMalfunctionResumeAndDetailsDataOutput {
fun fromBeaconMalfunctionResumeAndDetails(
beaconMalfunctionResumeAndDetails: BeaconMalfunctionResumeAndDetails,
): BeaconMalfunctionResumeAndDetailsDataOutput {
return BeaconMalfunctionResumeAndDetailsDataOutput(
beaconMalfunction = BeaconMalfunctionDataOutput.fromBeaconMalfunction(
beaconMalfunctionResumeAndDetails.beaconMalfunction,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ data class BeaconMalfunctionWithDetailsDataOutput(
val actions: List<BeaconMalfunctionActionDataOutput>,
) {
companion object {
fun fromBeaconMalfunctionWithDetails(beaconMalfunctionWithDetails: BeaconMalfunctionWithDetails): BeaconMalfunctionWithDetailsDataOutput {
fun fromBeaconMalfunctionWithDetails(
beaconMalfunctionWithDetails: BeaconMalfunctionWithDetails,
): BeaconMalfunctionWithDetailsDataOutput {
return BeaconMalfunctionWithDetailsDataOutput(
beaconMalfunction = BeaconMalfunctionDataOutput.fromBeaconMalfunction(
beaconMalfunctionWithDetails.beaconMalfunction,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ class CurrentAndArchivedReportingDataOutput(
val archived: List<ReportingDataOutput>,
) {
companion object {
fun fromCurrentAndArchivedReporting(currentAndArchivedReportings: CurrentAndArchivedReportings) = CurrentAndArchivedReportingDataOutput(
fun fromCurrentAndArchivedReporting(
currentAndArchivedReportings: CurrentAndArchivedReportings,
) = CurrentAndArchivedReportingDataOutput(
currentAndArchivedReportings.current.map {
ReportingDataOutput.fromReporting(it.first, it.second)
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ data class GearControlDataOutput(
var gearName: String? = null,
var declaredMesh: Double? = null,
var controlledMesh: Double? = null,
var hasUncontrolledMesh: Boolean,
var gearWasControlled: Boolean? = null,
) {
companion object {
Expand All @@ -15,6 +16,7 @@ data class GearControlDataOutput(
gearName = gearControl.gearName,
declaredMesh = gearControl.declaredMesh,
controlledMesh = gearControl.controlledMesh,
hasUncontrolledMesh = gearControl.hasUncontrolledMesh,
gearWasControlled = gearControl.gearWasControlled,
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ data class InfractionSuspicionDataOutput(
val dml: String? = null,
) : ReportingValueDataOutput() {
companion object {
fun fromInfractionSuspicion(infractionSuspicion: InfractionSuspicion, controlUnit: ControlUnit? = null): InfractionSuspicionDataOutput {
fun fromInfractionSuspicion(
infractionSuspicion: InfractionSuspicion,
controlUnit: ControlUnit? = null,
): InfractionSuspicionDataOutput {
return InfractionSuspicionDataOutput(
reportingActor = infractionSuspicion.reportingActor,
controlUnitId = infractionSuspicion.controlUnitId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ data class LogbookMessagesAndAlertsDataOutput(
val alerts: List<PNOAndLANAlert>,
) {
companion object {
fun fromLogbookMessagesAndAlerts(logbookMessagesAndAlerts: LogbookMessagesAndAlerts) = LogbookMessagesAndAlertsDataOutput(
fun fromLogbookMessagesAndAlerts(
logbookMessagesAndAlerts: LogbookMessagesAndAlerts,
) = LogbookMessagesAndAlertsDataOutput(
logbookMessagesAndAlerts.logbookMessages.map { LogbookMessageDataOutput.fromLogbookMessage(it) },
logbookMessagesAndAlerts.alerts,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ data class SpeciesAndSpeciesGroupsDataOutput(
val groups: List<SpeciesGroupDataOutput>,
) {
companion object {
fun fromSpeciesAndSpeciesGroups(speciesAndSpeciesGroups: SpeciesAndSpeciesGroups): SpeciesAndSpeciesGroupsDataOutput {
fun fromSpeciesAndSpeciesGroups(
speciesAndSpeciesGroups: SpeciesAndSpeciesGroups,
): SpeciesAndSpeciesGroupsDataOutput {
return SpeciesAndSpeciesGroupsDataOutput(
speciesAndSpeciesGroups.species.map { SpeciesDataOutput.fromSpecies(it) },
speciesAndSpeciesGroups.groups.map { SpeciesGroupDataOutput.fromSpeciesGroup(it) },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ data class VesselBeaconMalfunctionResumeDataOutput(
val lastBeaconMalfunctionVesselStatus: VesselStatus?,
) {
companion object {
fun fromVesselBeaconMalfunctionResume(vesselBeaconMalfunctionsResume: VesselBeaconMalfunctionsResume): VesselBeaconMalfunctionResumeDataOutput {
fun fromVesselBeaconMalfunctionResume(
vesselBeaconMalfunctionsResume: VesselBeaconMalfunctionsResume,
): VesselBeaconMalfunctionResumeDataOutput {
return VesselBeaconMalfunctionResumeDataOutput(
numberOfBeaconsAtSea = vesselBeaconMalfunctionsResume.numberOfBeaconsAtSea,
numberOfBeaconsAtPort = vesselBeaconMalfunctionsResume.numberOfBeaconsAtPort,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,11 @@ class UserAuthorizationCheckFilter(
}

logger.debug(
LoggedMessage("HTTP request: access granted.", hash(userInfoResponse.email), request.requestURI!!).toString(),
LoggedMessage(
"HTTP request: access granted.",
hash(userInfoResponse.email),
request.requestURI!!,
).toString(),
)

if (request.requestURI == CURRENT_USER_AUTHORIZATION_CONTROLLER_PATH) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ data class BeaconMalfunctionActionEntity(
)

companion object {
fun fromBeaconMalfunctionAction(beaconMalfunctionAction: BeaconMalfunctionAction): BeaconMalfunctionActionEntity {
fun fromBeaconMalfunctionAction(
beaconMalfunctionAction: BeaconMalfunctionAction,
): BeaconMalfunctionActionEntity {
if (beaconMalfunctionAction.propertyName === BeaconMalfunctionActionPropertyName.VESSEL_STATUS) {
try {
VesselStatus.valueOf(beaconMalfunctionAction.previousValue)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ data class BeaconMalfunctionCommentEntity(
)

companion object {
fun fromBeaconMalfunctionComment(beaconMalfunctionComment: BeaconMalfunctionComment) = BeaconMalfunctionCommentEntity(
fun fromBeaconMalfunctionComment(
beaconMalfunctionComment: BeaconMalfunctionComment,
) = BeaconMalfunctionCommentEntity(
id = beaconMalfunctionComment.id,
beaconMalfunctionId = beaconMalfunctionComment.beaconMalfunctionId,
comment = beaconMalfunctionComment.comment,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,11 @@ data class ReportingEntity(
}

companion object {
fun fromPendingAlert(alert: PendingAlert, validationDate: ZonedDateTime?, mapper: ObjectMapper) = ReportingEntity(
fun fromPendingAlert(
alert: PendingAlert,
validationDate: ZonedDateTime?,
mapper: ObjectMapper,
) = ReportingEntity(
vesselName = alert.vesselName,
type = ReportingType.ALERT,
vesselId = alert.vesselId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ import org.springframework.transaction.annotation.Transactional
import java.time.ZonedDateTime

@Repository
class JpaBeaconMalfunctionsRepository(private val dbBeaconMalfunctionsRepository: DBBeaconMalfunctionsRepository) : BeaconMalfunctionsRepository {
class JpaBeaconMalfunctionsRepository(
private val dbBeaconMalfunctionsRepository: DBBeaconMalfunctionsRepository,
) : BeaconMalfunctionsRepository {

override fun findAll(): List<BeaconMalfunction> {
return dbBeaconMalfunctionsRepository.findAll().map { it.toBeaconMalfunction() }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ import org.springframework.stereotype.Repository
import org.springframework.transaction.annotation.Transactional

@Repository
class JpaControlObjectivesRepository(private val dbControlObjectivesRepository: DBControlObjectivesRepository) : ControlObjectivesRepository {
class JpaControlObjectivesRepository(
private val dbControlObjectivesRepository: DBControlObjectivesRepository,
) : ControlObjectivesRepository {

override fun findAllByYear(year: Int): List<ControlObjective> {
return dbControlObjectivesRepository.findAllByYearEquals(year).map {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ import jakarta.transaction.Transactional
import org.springframework.stereotype.Repository

@Repository
class JpaFleetSegmentRepository(private val dbFleetSegmentRepository: DBFleetSegmentRepository) : FleetSegmentRepository {
class JpaFleetSegmentRepository(
private val dbFleetSegmentRepository: DBFleetSegmentRepository,
) : FleetSegmentRepository {

override fun findAll(): List<FleetSegment> {
return dbFleetSegmentRepository.findAll().map {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ import org.springframework.dao.EmptyResultDataAccessException
import org.springframework.stereotype.Repository

@Repository
class JpaGearCodeGroupRepository(private val dbGearCodeGroupRepository: DBGearCodeGroupRepository) : GearCodeGroupRepository {
class JpaGearCodeGroupRepository(
private val dbGearCodeGroupRepository: DBGearCodeGroupRepository,
) : GearCodeGroupRepository {

@Cacheable(value = ["gear_code_groups"])
override fun findAll(): List<GearCodeGroup> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import org.springframework.dao.EmptyResultDataAccessException
import org.springframework.stereotype.Repository

@Repository
class JpaLogbookRawMessageRepository(private val DBLogbookRawMessageRepository: DBLogbookRawMessageRepository) : LogbookRawMessageRepository {
class JpaLogbookRawMessageRepository(
private val DBLogbookRawMessageRepository: DBLogbookRawMessageRepository,
) : LogbookRawMessageRepository {

@Cacheable(value = ["logbook_raw_message"])
override fun findRawMessage(operationNumber: String): String? {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ class JpaLogbookReportRepository(
}

@Cacheable(value = ["previous_logbook"])
override fun findTripBeforeTripNumber(internalReferenceNumber: String, tripNumber: String): VoyageDatesAndTripNumber {
override fun findTripBeforeTripNumber(
internalReferenceNumber: String,
tripNumber: String,
): VoyageDatesAndTripNumber {
try {
if (internalReferenceNumber.isNotEmpty()) {
val previousTripNumber = dbERSRepository.findPreviousTripNumber(
Expand Down Expand Up @@ -83,7 +86,10 @@ class JpaLogbookReportRepository(
}

@Cacheable(value = ["next_logbook"])
override fun findTripAfterTripNumber(internalReferenceNumber: String, tripNumber: String): VoyageDatesAndTripNumber {
override fun findTripAfterTripNumber(
internalReferenceNumber: String,
tripNumber: String,
): VoyageDatesAndTripNumber {
try {
if (internalReferenceNumber.isNotEmpty()) {
val nextTripNumber = dbERSRepository.findNextTripNumber(
Expand Down Expand Up @@ -198,7 +204,10 @@ class JpaLogbookReportRepository(
PageRequest.of(0, 1),
).first()

return dbERSRepository.findFirstAcknowledgedDateOfTrip(internalReferenceNumber, lastTrip.tripNumber).atZone(
return dbERSRepository.findFirstAcknowledgedDateOfTrip(
internalReferenceNumber,
lastTrip.tripNumber,
).atZone(
UTC,
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,11 @@ class JpaReportingRepository(

if (ircs.isNotEmpty()) {
return dbReportingRepository
.findCurrentAndArchivedByVesselIdentifier(VesselIdentifier.IRCS.toString(), ircs, fromDate.toInstant()).map {
.findCurrentAndArchivedByVesselIdentifier(
VesselIdentifier.IRCS.toString(),
ircs,
fromDate.toInstant(),
).map {
it.toReporting(mapper)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import org.springframework.cache.annotation.Cacheable
import org.springframework.stereotype.Repository

@Repository
class JpaSpeciesGroupRepository(private val dbSpeciesGroupRepository: DBSpeciesGroupRepository) : SpeciesGroupRepository {
class JpaSpeciesGroupRepository(
private val dbSpeciesGroupRepository: DBSpeciesGroupRepository,
) : SpeciesGroupRepository {

@Cacheable(value = ["all_species_groups"])
override fun findAll(): List<SpeciesGroup> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ import org.springframework.data.jpa.repository.Modifying
import org.springframework.stereotype.Repository

@Repository
class JpaUserAuthorizationRepository(private val dbUserAuthorizationRepository: DBUserAuthorizationRepository) : UserAuthorizationRepository {
class JpaUserAuthorizationRepository(
private val dbUserAuthorizationRepository: DBUserAuthorizationRepository,
) : UserAuthorizationRepository {
@Cacheable(value = ["user_authorization"])
override fun findByHashedEmail(hashedEmail: String): UserAuthorization {
return dbUserAuthorizationRepository.findByHashedEmail(hashedEmail).toUserAuthorization()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ class JpaVesselRepository(private val dbVesselRepository: DBVesselRepository) :

if (externalReferenceNumber.isNotEmpty()) {
try {
return dbVesselRepository.findByExternalReferenceNumberIgnoreCaseContaining(externalReferenceNumber).toVessel()
return dbVesselRepository.findByExternalReferenceNumberIgnoreCaseContaining(
externalReferenceNumber,
).toVessel()
} catch (e: EmptyResultDataAccessException) {
logger.warn("No vessel found for external marking $externalReferenceNumber", e)
}
Expand Down
Loading

0 comments on commit a95e610

Please sign in to comment.