diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9c4bfb3f..7f0523d2 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -16,7 +16,7 @@ variables: value: "postgres:15.7-alpine" description: "Image de la base de données" PROJECT_VERSION: - value: "1.6.6" + value: "1.6.7" description: "Version du projet à déployer" SERVER_ENV_INT: value: "int-rapportnav-appli01" diff --git a/backend/build.gradle.kts b/backend/build.gradle.kts index 3c1f478c..61f90337 100644 --- a/backend/build.gradle.kts +++ b/backend/build.gradle.kts @@ -2,7 +2,7 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile import java.lang.System.getenv group = "fr.gouv.dgampa" -version = "1.6.6" +version = "1.6.7" description = "RapportNav" val kotlinVersion by extra("1.9.24") diff --git a/backend/src/main/kotlin/fr/gouv/dgampa/rapportnav/domain/use_cases/mission/export/ExportMission.kt b/backend/src/main/kotlin/fr/gouv/dgampa/rapportnav/domain/use_cases/mission/export/ExportMission.kt index 6d5c3452..e6a21e28 100644 --- a/backend/src/main/kotlin/fr/gouv/dgampa/rapportnav/domain/use_cases/mission/export/ExportMission.kt +++ b/backend/src/main/kotlin/fr/gouv/dgampa/rapportnav/domain/use_cases/mission/export/ExportMission.kt @@ -16,6 +16,7 @@ import fr.gouv.dgampa.rapportnav.domain.use_cases.mission.crew.GetAgentsCrewByMi import fr.gouv.dgampa.rapportnav.domain.use_cases.mission.generalInfo.GetMissionGeneralInfoByMissionId import fr.gouv.dgampa.rapportnav.domain.use_cases.mission.status.GetNbOfDaysAtSeaFromNavigationStatus import fr.gouv.dgampa.rapportnav.domain.use_cases.utils.ComputeDurations +import fr.gouv.dgampa.rapportnav.domain.use_cases.utils.EncodeSpecialChars import org.slf4j.LoggerFactory import java.time.format.DateTimeFormatter import kotlin.time.DurationUnit @@ -32,6 +33,7 @@ class ExportMission( private val getNbOfDaysAtSeaFromNavigationStatus: GetNbOfDaysAtSeaFromNavigationStatus, private val computeDurations: ComputeDurations, private val getInfoAboutNavAction: GetInfoAboutNavAction, + private val encodeSpecialChars: EncodeSpecialChars, ) { private val logger = LoggerFactory.getLogger(ExportMission::class.java) @@ -105,6 +107,7 @@ class ExportMission( id = DateTimeFormatter.ofPattern("yyyy-MM-dd").format(mission.startDateTimeUtc), startDateTime = mission.startDateTimeUtc, endDateTime = mission.endDateTimeUtc, + observations = mission.observationsByUnit?.let { encodeSpecialChars.escapeForXML(it) } ?: "", presenceMer = durations["atSeaDurations"].orEmpty(), presenceQuai = durations["dockingDurations"].orEmpty(), indisponibilite = durations["unavailabilityDurations"].orEmpty(), @@ -121,7 +124,6 @@ class ExportMission( nauticalEventsInfo = nauticalEventsInfo, antiPollutionInfo = antiPollutionInfo, baaemAndVigimerInfo = baaemAndVigimerInfo, - observations = "", patrouilleSurveillanceEnvInHours = envSurveillanceInfo?.get("durationInHours")?.toFloatOrNull(), patrouilleMigrantInHours = illegalImmigrationInfo?.get("durationInHours")?.toFloatOrNull() ) diff --git a/backend/src/main/kotlin/fr/gouv/dgampa/rapportnav/domain/use_cases/mission/export/FormatActionsForTimeline.kt b/backend/src/main/kotlin/fr/gouv/dgampa/rapportnav/domain/use_cases/mission/export/FormatActionsForTimeline.kt index 9795d678..b9e31a08 100644 --- a/backend/src/main/kotlin/fr/gouv/dgampa/rapportnav/domain/use_cases/mission/export/FormatActionsForTimeline.kt +++ b/backend/src/main/kotlin/fr/gouv/dgampa/rapportnav/domain/use_cases/mission/export/FormatActionsForTimeline.kt @@ -14,11 +14,11 @@ import fr.gouv.dgampa.rapportnav.domain.entities.mission.nav.action.BaseAction import fr.gouv.dgampa.rapportnav.domain.entities.mission.nav.status.mapActionStatusTypeToHumanString import fr.gouv.dgampa.rapportnav.domain.use_cases.mission.action.GroupActionByDate import fr.gouv.dgampa.rapportnav.domain.use_cases.mission.action.MapEnvActionControlPlans +import fr.gouv.dgampa.rapportnav.domain.use_cases.utils.EncodeSpecialChars import fr.gouv.dgampa.rapportnav.domain.use_cases.utils.FormatDateTime import fr.gouv.dgampa.rapportnav.domain.use_cases.utils.FormatGeoCoords import fr.gouv.dgampa.rapportnav.infrastructure.rapportnav1.adapters.inputs.TimelineActionItem import fr.gouv.dgampa.rapportnav.infrastructure.rapportnav1.adapters.inputs.TimelineActions -import org.apache.commons.text.StringEscapeUtils import java.time.LocalDate @UseCase @@ -27,15 +27,14 @@ class FormatActionsForTimeline( private val formatDateTime: FormatDateTime, private val formatGeoCoords: FormatGeoCoords, private val mapEnvActionControlPlans: MapEnvActionControlPlans, + private val encodeSpecialChars: EncodeSpecialChars, ) { /** * Some characters need to be escaped in a XML compliant manner * most notably the following ones: &, <, > */ - fun encodeSpecialChars(input: String?): String { - return StringEscapeUtils.escapeXml10(input) - } + fun formatTimeline(actions: List?): Map>? { @@ -198,7 +197,7 @@ class FormatActionsForTimeline( return action?.let { val startTime = formatDateTime.formatTime(action.startDateTimeUtc) val status = mapActionStatusTypeToHumanString(action.status) - val observation = action.observations?.let { "- ${encodeSpecialChars(it)}" } ?: "" + val observation = action.observations?.let { "- ${encodeSpecialChars.escapeForXML(it)}" } ?: "" return "$startTime - $status $observation" } } @@ -221,7 +220,7 @@ class FormatActionsForTimeline( val endTime = action.endDateTimeUtc?.let { " / ${formatDateTime.formatTime(it)}" } ?: "" val titleStr = if (!title.isNullOrEmpty()) " - $title" else "" val observation = - if (!action.observations.isNullOrEmpty()) " - ${encodeSpecialChars(action.observations)}" else "" + if (!action.observations.isNullOrEmpty()) " - ${encodeSpecialChars.escapeForXML(action.observations)}" else "" "$startTime$endTime$titleStr$observation" } } diff --git a/backend/src/main/kotlin/fr/gouv/dgampa/rapportnav/domain/use_cases/utils/EncodeSpecialChars.kt b/backend/src/main/kotlin/fr/gouv/dgampa/rapportnav/domain/use_cases/utils/EncodeSpecialChars.kt new file mode 100644 index 00000000..a6fd7618 --- /dev/null +++ b/backend/src/main/kotlin/fr/gouv/dgampa/rapportnav/domain/use_cases/utils/EncodeSpecialChars.kt @@ -0,0 +1,16 @@ +package fr.gouv.dgampa.rapportnav.domain.use_cases.utils + +import fr.gouv.dgampa.rapportnav.config.UseCase +import org.apache.commons.text.StringEscapeUtils + +@UseCase +class EncodeSpecialChars { + + /** + * Some characters need to be escaped in a XML compliant manner + * most notably the following ones: &, <, > + */ + fun escapeForXML(input: String?): String { + return StringEscapeUtils.escapeXml10(input) + } +} diff --git a/backend/src/main/kotlin/fr/gouv/dgampa/rapportnav/infrastructure/rapportnav1/APIRpnExportRepository.kt b/backend/src/main/kotlin/fr/gouv/dgampa/rapportnav/infrastructure/rapportnav1/APIRpnExportRepository.kt index e2c4ac05..3b02ebba 100644 --- a/backend/src/main/kotlin/fr/gouv/dgampa/rapportnav/infrastructure/rapportnav1/APIRpnExportRepository.kt +++ b/backend/src/main/kotlin/fr/gouv/dgampa/rapportnav/infrastructure/rapportnav1/APIRpnExportRepository.kt @@ -83,7 +83,7 @@ class APIRpnExportRepository( nauticalEventsInfo = params.nauticalEventsInfo, antiPollutionInfo = params.antiPollutionInfo, baaemAndVigimerInfo = params.baaemAndVigimerInfo, - observations = "" + observations = params.observations ) val gson = Gson(); diff --git a/backend/src/test/kotlin/fr/gouv/gmampa/rapportnav/domain/use_cases/mission/export/ExportMissionTests.kt b/backend/src/test/kotlin/fr/gouv/gmampa/rapportnav/domain/use_cases/mission/export/ExportMissionTests.kt index 015170a0..fa5282ad 100644 --- a/backend/src/test/kotlin/fr/gouv/gmampa/rapportnav/domain/use_cases/mission/export/ExportMissionTests.kt +++ b/backend/src/test/kotlin/fr/gouv/gmampa/rapportnav/domain/use_cases/mission/export/ExportMissionTests.kt @@ -14,6 +14,7 @@ import fr.gouv.dgampa.rapportnav.domain.use_cases.mission.generalInfo.GetMission import fr.gouv.dgampa.rapportnav.domain.use_cases.mission.status.GetNbOfDaysAtSeaFromNavigationStatus import fr.gouv.dgampa.rapportnav.domain.use_cases.mission.status.GetStatusDurations import fr.gouv.dgampa.rapportnav.domain.use_cases.utils.ComputeDurations +import fr.gouv.dgampa.rapportnav.domain.use_cases.utils.EncodeSpecialChars import fr.gouv.gmampa.rapportnav.mocks.mission.MissionEntityMock import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.BeforeEach @@ -36,6 +37,7 @@ import java.time.ZonedDateTime MapStatusDurations::class, GetStatusDurations::class, GetNbOfDaysAtSeaFromNavigationStatus::class, + EncodeSpecialChars::class, ] ) class ExportMissionTests { diff --git a/backend/src/test/kotlin/fr/gouv/gmampa/rapportnav/domain/use_cases/mission/export/FormatActionsForTimelineTests.kt b/backend/src/test/kotlin/fr/gouv/gmampa/rapportnav/domain/use_cases/mission/export/FormatActionsForTimelineTests.kt index a9ac09a2..7c080a7e 100644 --- a/backend/src/test/kotlin/fr/gouv/gmampa/rapportnav/domain/use_cases/mission/export/FormatActionsForTimelineTests.kt +++ b/backend/src/test/kotlin/fr/gouv/gmampa/rapportnav/domain/use_cases/mission/export/FormatActionsForTimelineTests.kt @@ -10,6 +10,7 @@ import fr.gouv.dgampa.rapportnav.domain.entities.mission.nav.action.* import fr.gouv.dgampa.rapportnav.domain.use_cases.mission.action.GroupActionByDate import fr.gouv.dgampa.rapportnav.domain.use_cases.mission.action.MapEnvActionControlPlans import fr.gouv.dgampa.rapportnav.domain.use_cases.mission.export.FormatActionsForTimeline +import fr.gouv.dgampa.rapportnav.domain.use_cases.utils.EncodeSpecialChars import fr.gouv.dgampa.rapportnav.domain.use_cases.utils.FormatDateTime import fr.gouv.dgampa.rapportnav.domain.use_cases.utils.FormatGeoCoords import fr.gouv.dgampa.rapportnav.infrastructure.rapportnav1.adapters.inputs.TimelineActionItem @@ -28,7 +29,7 @@ import java.time.LocalDateTime import java.time.ZoneOffset import java.time.ZonedDateTime -@SpringBootTest(classes = [FormatActionsForTimeline::class, FormatDateTime::class, FormatGeoCoords::class]) +@SpringBootTest(classes = [FormatActionsForTimeline::class, FormatDateTime::class, FormatGeoCoords::class, EncodeSpecialChars::class]) class FormatActionsForTimelineTests { @Autowired diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 26147e32..8aaadcd4 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -1,12 +1,12 @@ { "name": "frontend", - "version": "1.6.6", + "version": "1.6.7", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "frontend", - "version": "1.6.6", + "version": "1.6.7", "dependencies": { "@apollo/client": "^3.10.5", "@mtes-mct/monitor-ui": "^14.3.1", diff --git a/frontend/package.json b/frontend/package.json index 929e8c6f..bf2bf256 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -1,6 +1,6 @@ { "name": "frontend", - "version": "1.6.6", + "version": "1.6.7", "private": true, "type": "module", "engines": { diff --git a/frontend/src/pam/mission/mission-content.tsx b/frontend/src/pam/mission/mission-content.tsx index c520b933..9258fc91 100644 --- a/frontend/src/pam/mission/mission-content.tsx +++ b/frontend/src/pam/mission/mission-content.tsx @@ -25,6 +25,7 @@ import useAddOrUpdateBAAEMPermanence from './others/baaem/use-add-baaem-permanen import useAddOrUpdatePublicOrder from './others/public-order/use-add-public-order.tsx' import useAddRepresentation from './others/representation/use-add-representation.tsx' import useAddIllegalImmigration from './others/illegal-immigration/use-add-illegal-immigration.tsx' +import MissionObservationsUnit from './mission-observations-unit.tsx' export interface MissionProps { mission?: Mission @@ -209,9 +210,12 @@ const MissionContent: React.FC = ({ mission }) => { - {/* */} + {/*/!* *!/*/} + {/**/} + {/* /!* *!/*/} + {/**/} - {/* */} + diff --git a/frontend/src/pam/mission/mission-observations-unit.tsx b/frontend/src/pam/mission/mission-observations-unit.tsx index c22eecd2..3030ed43 100644 --- a/frontend/src/pam/mission/mission-observations-unit.tsx +++ b/frontend/src/pam/mission/mission-observations-unit.tsx @@ -22,7 +22,6 @@ const MissionObservationsUnit: React.FC = ({ mis const handleSubmit = async ({ observations }: ObservationsByUnit) => { if (!observations || observations.length < 4 || observations === observationsByUnit) return - debugger await patchMissionObservation({ variables: { diff --git a/frontend/src/pam/mission/panel-general-info.tsx b/frontend/src/pam/mission/panel-general-info.tsx index 1d4824f9..7ae19ee8 100644 --- a/frontend/src/pam/mission/panel-general-info.tsx +++ b/frontend/src/pam/mission/panel-general-info.tsx @@ -5,7 +5,6 @@ import { Mission } from '../../types/mission-types' import Text from '../../ui/text' import MissionCrew from './crew/mission-crew' import MissionDistanceAndConsumption from './general-info/mission-distance-consumption' -import MissionObservationsUnit from './mission-observations-unit.tsx' import MissionService from './mission-service' interface MissionGeneralInfoPanelProps { @@ -56,9 +55,6 @@ const MissionGeneralInfoPanel: React.FC = ({ missi - - -