Skip to content

Commit

Permalink
Merge pull request #252 from MTES-MCT/obs-by-u
Browse files Browse the repository at this point in the history
feat(Mission): enable observationsByUnit
  • Loading branch information
lwih authored Jul 10, 2024
2 parents 19f73f2 + aa01dae commit 2a298b8
Show file tree
Hide file tree
Showing 13 changed files with 40 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion backend/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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(),
Expand All @@ -121,7 +124,6 @@ class ExportMission(
nauticalEventsInfo = nauticalEventsInfo,
antiPollutionInfo = antiPollutionInfo,
baaemAndVigimerInfo = baaemAndVigimerInfo,
observations = "",
patrouilleSurveillanceEnvInHours = envSurveillanceInfo?.get("durationInHours")?.toFloatOrNull(),
patrouilleMigrantInHours = illegalImmigrationInfo?.get("durationInHours")?.toFloatOrNull()
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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<MissionActionEntity>?): Map<LocalDate, List<String>>? {

Expand Down Expand Up @@ -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"
}
}
Expand All @@ -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"
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class APIRpnExportRepository(
nauticalEventsInfo = params.nauticalEventsInfo,
antiPollutionInfo = params.antiPollutionInfo,
baaemAndVigimerInfo = params.baaemAndVigimerInfo,
observations = ""
observations = params.observations
)

val gson = Gson();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -36,6 +37,7 @@ import java.time.ZonedDateTime
MapStatusDurations::class,
GetStatusDurations::class,
GetNbOfDaysAtSeaFromNavigationStatus::class,
EncodeSpecialChars::class,
]
)
class ExportMissionTests {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "frontend",
"version": "1.6.6",
"version": "1.6.7",
"private": true,
"type": "module",
"engines": {
Expand Down
8 changes: 6 additions & 2 deletions frontend/src/pam/mission/mission-content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -209,9 +210,12 @@ const MissionContent: React.FC<MissionProps> = ({ mission }) => {
<Stack.Item style={{ width: '100%', padding: '1rem' }}>
<MissionGeneralInfoPanel mission={mission} />
</Stack.Item>
<Stack.Item style={{ width: '100%', padding: '1rem' }}>{/* <MissionActivityPanel /> */}</Stack.Item>
{/*<Stack.Item style={{ width: '100%', padding: '1rem' }}>/!* <MissionActivityPanel /> *!/</Stack.Item>*/}
{/*<Stack.Item style={{ width: '100%', padding: '1rem' }}>*/}
{/* /!* <MissionOperationalSummaryPanel /> *!/*/}
{/*</Stack.Item>*/}
<Stack.Item style={{ width: '100%', padding: '1rem' }}>
{/* <MissionOperationalSummaryPanel /> */}
<MissionObservationsUnit missionId={mission.id} observationsByUnit={mission.observationsByUnit} />
</Stack.Item>
</Stack>
</FlexboxGrid.Item>
Expand Down
1 change: 0 additions & 1 deletion frontend/src/pam/mission/mission-observations-unit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ const MissionObservationsUnit: React.FC<MissionObservationsByUnitProps> = ({ mis

const handleSubmit = async ({ observations }: ObservationsByUnit) => {
if (!observations || observations.length < 4 || observations === observationsByUnit) return
debugger

await patchMissionObservation({
variables: {
Expand Down
4 changes: 0 additions & 4 deletions frontend/src/pam/mission/panel-general-info.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -56,9 +55,6 @@ const MissionGeneralInfoPanel: React.FC<MissionGeneralInfoPanelProps> = ({ missi
<Stack.Item style={{ width: '100%' }}>
<MissionDistanceAndConsumption info={mission.generalInfo} />
</Stack.Item>
<Stack.Item style={{ width: '100%', display: 'none' }}>
<MissionObservationsUnit missionId={mission.id} observationsByUnit={mission.observationsByUnit} />
</Stack.Item>
</Stack>
</FlexboxGrid.Item>
</FlexboxGrid>
Expand Down

0 comments on commit 2a298b8

Please sign in to comment.