Skip to content

Commit

Permalink
[Thématiques Plans de Contrôle] Création des nouvelles tables de gest…
Browse files Browse the repository at this point in the history
…ion des thèmes (#1011)

- Resolve #755
  • Loading branch information
claire2212 committed Dec 20, 2023
2 parents 3d1e46f + cf6345a commit 513d2f8
Show file tree
Hide file tree
Showing 152 changed files with 3,780 additions and 1,905 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package fr.gouv.cacem.monitorenv.domain.entities.controlPlan

data class ControlPlanSubThemeEntity(
val id: Int,
val themeId: Int,
val subTheme: String,
val year: Int,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package fr.gouv.cacem.monitorenv.domain.entities.controlPlan

data class ControlPlanTagEntity(
val id: Int,
val tag: String,
val themeId: Int,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package fr.gouv.cacem.monitorenv.domain.entities.controlPlan

data class ControlPlanThemeEntity(
val id: Int,
val theme: String,
)
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package fr.gouv.cacem.monitorenv.domain.entities.controlTheme

@Deprecated("Use ControlPlanSubThemesEntity instead")
data class ControlThemeEntity(
val id: Int,
val themeLevel1: String,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package fr.gouv.cacem.monitorenv.domain.entities.mission.envAction

data class EnvActionControlPlanEntity(
val themeId: Int? = null,
val subThemeIds: List<Int>? = emptyList(),
val tagIds: List<Int>? = emptyList(),
)
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ import java.util.UUID
abstract class EnvActionEntity(
open val id: UUID,
open val actionType: ActionTypeEnum,
open val actionStartDateTimeUtc: ZonedDateTime? = null,
open val actionEndDateTimeUtc: ZonedDateTime? = null,
open val actionStartDateTimeUtc: ZonedDateTime? = null,
open val controlPlans: List<EnvActionControlPlanEntity>? = listOf(),
open val department: String? = null,
open val facade: String? = null,
open val geom: Geometry? = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ import java.util.UUID

data class EnvActionSurveillanceEntity(
override val id: UUID,
override val actionStartDateTimeUtc: ZonedDateTime? = null,
override val actionEndDateTimeUtc: ZonedDateTime? = null,
override val actionStartDateTimeUtc: ZonedDateTime? = null,
override val controlPlans: List<EnvActionControlPlanEntity>? = listOf(),
override val geom: Geometry? = null,
override val facade: String? = null,
override val department: String? = null,
val themes: List<ThemeEntity>? = listOf(),
val observations: String? = null,
val coverMissionZone: Boolean? = null,
val observations: String? = null,
@Deprecated("Use controlPlan instead") val themes: List<ThemeEntity>? = listOf(),
) :
EnvActionEntity(
actionType = ActionTypeEnum.SURVEILLANCE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,37 @@ import java.time.ZonedDateTime
import java.util.*

data class EnvActionSurveillanceProperties(
val themes: List<ThemeEntity>? = listOf(),
val observations: String? = null,
val coverMissionZone: Boolean? = null,
val observations: String? = null,
@Deprecated("Use controlPlans instead") val themes: List<ThemeEntity>? = listOf(),
) {
fun toEnvActionSurveillanceEntity(
id: UUID,
actionStartDateTimeUtc: ZonedDateTime?,
actionEndDateTimeUtc: ZonedDateTime?,
facade: String?,
controlPlans: List<EnvActionControlPlanEntity>?,
department: String?,
facade: String?,
geom: Geometry?,
) =
EnvActionSurveillanceEntity(
id = id,
actionStartDateTimeUtc = actionStartDateTimeUtc,
actionEndDateTimeUtc = actionEndDateTimeUtc,
facade = facade,
controlPlans = controlPlans,
coverMissionZone = coverMissionZone,
department = department,
facade = facade,
geom = geom,
themes = themes,
observations = observations,
coverMissionZone = coverMissionZone,
themes = themes,
)
companion object {
fun fromEnvActionSurveillanceEntity(envAction: EnvActionSurveillanceEntity) =
EnvActionSurveillanceProperties(
themes = envAction.themes,
observations = envAction.observations,
coverMissionZone = envAction.coverMissionZone,
observations = envAction.observations,
themes = envAction.themes,
)
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package fr.gouv.cacem.monitorenv.domain.entities.mission.envAction

@Deprecated("Use EnvActionControlPlanSubThemeEntity instead")
data class ThemeEntity(
val theme: String? = null,
val subThemes: List<String>? = listOf(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package fr.gouv.cacem.monitorenv.domain.entities.mission.envAction.envActionCont

import fr.gouv.cacem.monitorenv.domain.entities.VehicleTypeEnum
import fr.gouv.cacem.monitorenv.domain.entities.mission.envAction.ActionTypeEnum
import fr.gouv.cacem.monitorenv.domain.entities.mission.envAction.EnvActionControlPlanEntity
import fr.gouv.cacem.monitorenv.domain.entities.mission.envAction.EnvActionEntity
import fr.gouv.cacem.monitorenv.domain.entities.mission.envAction.ThemeEntity
import fr.gouv.cacem.monitorenv.domain.entities.mission.envAction.envActionControl.infraction.InfractionEntity
Expand All @@ -11,21 +12,22 @@ import java.util.UUID

data class EnvActionControlEntity(
override val id: UUID,
override val actionStartDateTimeUtc: ZonedDateTime? = null,
override val actionEndDateTimeUtc: ZonedDateTime? = null,
override val geom: Geometry? = null,
override val facade: String? = null,
override val actionStartDateTimeUtc: ZonedDateTime? = null,
override val controlPlans: List<EnvActionControlPlanEntity>? = listOf(),
override val department: String? = null,
override val facade: String? = null,
override val geom: Geometry? = null,
override val isAdministrativeControl: Boolean? = null,
override val isComplianceWithWaterRegulationsControl: Boolean? = null,
override val isSafetyEquipmentAndStandardsComplianceControl: Boolean? = null,
override val isSeafarersControl: Boolean? = null,
val themes: List<ThemeEntity>? = listOf(),
val observations: String? = null,
val actionNumberOfControls: Int? = null,
val actionTargetType: ActionTargetTypeEnum? = null,
val vehicleType: VehicleTypeEnum? = null,
val infractions: List<InfractionEntity>? = listOf(),
val observations: String? = null,
@Deprecated("Use controlPlan instead") val themes: List<ThemeEntity>? = listOf(),
val vehicleType: VehicleTypeEnum? = null,
) :
EnvActionEntity(
id = id,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,28 @@
package fr.gouv.cacem.monitorenv.domain.entities.mission.envAction.envActionControl

import fr.gouv.cacem.monitorenv.domain.entities.VehicleTypeEnum
import fr.gouv.cacem.monitorenv.domain.entities.mission.envAction.EnvActionControlPlanEntity
import fr.gouv.cacem.monitorenv.domain.entities.mission.envAction.ThemeEntity
import fr.gouv.cacem.monitorenv.domain.entities.mission.envAction.envActionControl.infraction.InfractionEntity
import org.locationtech.jts.geom.Geometry
import java.time.ZonedDateTime
import java.util.UUID

data class EnvActionControlProperties(
val themes: List<ThemeEntity>? = listOf(),
val observations: String? = null,
val actionNumberOfControls: Int? = null,
val actionTargetType: ActionTargetTypeEnum? = null,
val vehicleType: VehicleTypeEnum? = null,
val infractions: List<InfractionEntity>? = listOf(),
val observations: String? = null,
@Deprecated("Use controlPlans instead") val themes: List<ThemeEntity>? = listOf(),
val vehicleType: VehicleTypeEnum? = null,
) {
fun toEnvActionControlEntity(
id: UUID,
actionStartDateTimeUtc: ZonedDateTime?,
actionEndDateTimeUtc: ZonedDateTime?,
facade: String?,
actionStartDateTimeUtc: ZonedDateTime?,
controlPlans: List<EnvActionControlPlanEntity>?,
department: String?,
facade: String?,
geom: Geometry?,
isAdministrativeControl: Boolean?,
isComplianceWithWaterRegulationsControl: Boolean?,
Expand All @@ -29,34 +31,35 @@ data class EnvActionControlProperties(
) =
EnvActionControlEntity(
id = id,
actionStartDateTimeUtc = actionStartDateTimeUtc,
actionEndDateTimeUtc = actionEndDateTimeUtc,
facade = facade,
department = department,
geom = geom,
themes = themes,
observations = observations,
actionNumberOfControls = actionNumberOfControls,
actionStartDateTimeUtc = actionStartDateTimeUtc,
actionTargetType = actionTargetType,
vehicleType = vehicleType,
controlPlans = controlPlans,
department = department,
facade = facade,
geom = geom,
infractions = infractions,
isAdministrativeControl = isAdministrativeControl,
isComplianceWithWaterRegulationsControl =
isComplianceWithWaterRegulationsControl,
isSafetyEquipmentAndStandardsComplianceControl =
isSafetyEquipmentAndStandardsComplianceControl,
isSeafarersControl = isSeafarersControl,
observations = observations,
themes = themes,
vehicleType = vehicleType,
)

companion object {
fun fromEnvActionControlEntity(envAction: EnvActionControlEntity) =
EnvActionControlProperties(
themes = envAction.themes,
observations = envAction.observations,
actionNumberOfControls = envAction.actionNumberOfControls,
actionTargetType = envAction.actionTargetType,
vehicleType = envAction.vehicleType,
infractions = envAction.infractions,
observations = envAction.observations,
themes = envAction.themes,
vehicleType = envAction.vehicleType,
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ data class ReportingEntity(
val seaFront: String? = null,
val description: String? = null,
val reportType: ReportingTypeEnum? = null,
val theme: String? = null,
val subThemes: List<String>? = listOf(),
val themeId: Int? = null,
val subThemeIds: List<Int>? = emptyList(),
val actionTaken: String? = null,
val isControlRequired: Boolean? = null,
val hasNoUnitAvailable: Boolean? = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package fr.gouv.cacem.monitorenv.domain.mappers

import com.fasterxml.jackson.databind.ObjectMapper
import fr.gouv.cacem.monitorenv.domain.entities.mission.envAction.ActionTypeEnum
import fr.gouv.cacem.monitorenv.domain.entities.mission.envAction.EnvActionControlPlanEntity
import fr.gouv.cacem.monitorenv.domain.entities.mission.envAction.EnvActionEntity
import fr.gouv.cacem.monitorenv.domain.entities.mission.envAction.EnvActionNoteEntity
import fr.gouv.cacem.monitorenv.domain.entities.mission.envAction.EnvActionNoteProperties
Expand All @@ -22,17 +23,18 @@ object EnvActionMapper {
fun getEnvActionEntityFromJSON(
mapper: ObjectMapper,
id: UUID,
actionStartDateTimeUtc: ZonedDateTime?,
actionEndDateTimeUtc: ZonedDateTime?,
geom: Geometry?,
actionType: ActionTypeEnum,
facade: String?,
actionStartDateTimeUtc: ZonedDateTime?,
controlPlans: List<EnvActionControlPlanEntity>?,
department: String?,
value: String?,
facade: String?,
geom: Geometry?,
isAdministrativeControl: Boolean?,
isComplianceWithWaterRegulationsControl: Boolean?,
isSafetyEquipmentAndStandardsComplianceControl: Boolean?,
isSeafarersControl: Boolean?,
value: String?,
): EnvActionEntity {
return try {
if (!value.isNullOrEmpty() && value != jsonbNullString) {
Expand All @@ -43,38 +45,42 @@ object EnvActionMapper {
EnvActionSurveillanceProperties::class.java,
)
.toEnvActionSurveillanceEntity(
id,
actionStartDateTimeUtc,
actionEndDateTimeUtc,
facade,
department,
geom,
id = id,
actionEndDateTimeUtc = actionEndDateTimeUtc,
actionStartDateTimeUtc = actionStartDateTimeUtc,
controlPlans = controlPlans,
department = department,
facade = facade,
geom = geom,
)
ActionTypeEnum.CONTROL ->
mapper.readValue(
value,
EnvActionControlProperties::class.java,
)
.toEnvActionControlEntity(
id,
actionStartDateTimeUtc,
actionEndDateTimeUtc,
facade,
department,
geom,
isAdministrativeControl,
id = id,
actionEndDateTimeUtc = actionEndDateTimeUtc,
actionStartDateTimeUtc = actionStartDateTimeUtc,
controlPlans = controlPlans,
department = department,
facade = facade,
geom = geom,
isAdministrativeControl = isAdministrativeControl,
isComplianceWithWaterRegulationsControl =
isComplianceWithWaterRegulationsControl,
isSafetyEquipmentAndStandardsComplianceControl =
isSafetyEquipmentAndStandardsComplianceControl,
isSeafarersControl,
isSeafarersControl = isSeafarersControl,
)
ActionTypeEnum.NOTE ->
mapper.readValue(
value,
EnvActionNoteProperties::class.java,
)
.toEnvActionNoteEntity(
id,
actionStartDateTimeUtc,
id = id,
actionStartDateTimeUtc = actionStartDateTimeUtc,
)
}
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package fr.gouv.cacem.monitorenv.domain.repositories

import fr.gouv.cacem.monitorenv.domain.entities.controlPlan.ControlPlanSubThemeEntity

interface IControlPlanSubThemeRepository {
fun findAll(): List<ControlPlanSubThemeEntity>
fun findByYear(year: Int): List<ControlPlanSubThemeEntity>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package fr.gouv.cacem.monitorenv.domain.repositories

import fr.gouv.cacem.monitorenv.domain.entities.controlPlan.ControlPlanTagEntity

interface IControlPlanTagRepository {
fun findAll(): List<ControlPlanTagEntity>
fun findByYear(year: Int): List<ControlPlanTagEntity>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package fr.gouv.cacem.monitorenv.domain.repositories

import fr.gouv.cacem.monitorenv.domain.entities.controlPlan.ControlPlanThemeEntity

interface IControlPlanThemeRepository {
fun findAll(): List<ControlPlanThemeEntity>
fun findByYear(year: Int): List<ControlPlanThemeEntity>
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package fr.gouv.cacem.monitorenv.domain.repositories

import fr.gouv.cacem.monitorenv.domain.entities.controlTheme.ControlThemeEntity

@Deprecated("Use IControlPlanSubThemeRepository instead")
interface IControlThemeRepository {
fun findById(controlThemeId: Int): ControlThemeEntity
fun findAll(): List<ControlThemeEntity>
Expand Down
Loading

0 comments on commit 513d2f8

Please sign in to comment.