Skip to content

Commit

Permalink
feat(backend): remove input and output object
Browse files Browse the repository at this point in the history
 - Remove input and outPut object to be just model
 - Create model combine of input  and output
 - update Test
 - Create Rest controller to CRUD
 - Remove graphql definitions
  • Loading branch information
xtiannyeto committed Dec 30, 2024
1 parent c37869b commit e6452d3
Show file tree
Hide file tree
Showing 59 changed files with 697 additions and 1,148 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ import fr.gouv.dgampa.rapportnav.domain.use_cases.mission.control.v2.ProcessMiss
import fr.gouv.dgampa.rapportnav.domain.use_cases.mission.control.v2.ProcessMissionActionControlEnvTarget
import fr.gouv.dgampa.rapportnav.domain.use_cases.mission.infraction.v2.ProcessMissionActionInfractionEnvTarget
import fr.gouv.dgampa.rapportnav.infrastructure.api.bff.adapters.action.ActionEnvInput
import fr.gouv.dgampa.rapportnav.infrastructure.api.bff.adapters.v2.MissionActionInput
import fr.gouv.dgampa.rapportnav.infrastructure.api.bff.adapters.v2.MissionEnvActionDataInput
import fr.gouv.dgampa.rapportnav.infrastructure.api.bff.model.v2.MissionAction
import fr.gouv.dgampa.rapportnav.infrastructure.api.bff.model.v2.MissionEnvAction
import fr.gouv.dgampa.rapportnav.infrastructure.api.bff.model.v2.MissionEnvActionData
import org.slf4j.LoggerFactory

@UseCase
Expand All @@ -20,13 +21,13 @@ class UpdateEnvAction(
) {

private val logger = LoggerFactory.getLogger(UpdateEnvAction::class.java)
fun execute(input: MissionActionInput): MissionEnvActionEntity? {
val action = MissionEnvActionDataInput.toMissionEnvActionEntity(input)
val controlInputs = input.env?.getControls(actionId = input.id, missionId = input.missionId)
fun execute(id: String, input: MissionEnvAction): MissionEnvActionEntity? {
val action = MissionEnvActionData.toMissionEnvActionEntity(input)
val controlInputs = input.data.getControls(actionId = id, missionId = input.missionId)
return try {
patchEnvAction.execute(
ActionEnvInput(
actionId = input.id,
actionId = id,
missionId = action.missionId,
startDateTimeUtc = action.startDateTimeUtc,
endDateTimeUtc = action.endDateTimeUtc,
Expand All @@ -38,7 +39,7 @@ class UpdateEnvAction(
actionId = action.getActionId()
)

val infractionInput = input.env?.getInfractions(
val infractionInput = (input.data as MissionEnvActionData).getInfractions(
missionId = input.missionId,
actionId = action.getActionId()
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import fr.gouv.dgampa.rapportnav.domain.use_cases.mission.action.PatchFishAction
import fr.gouv.dgampa.rapportnav.domain.use_cases.mission.control.v2.ProcessMissionActionControl
import fr.gouv.dgampa.rapportnav.domain.use_cases.mission.infraction.v2.ProcessMissionActionInfraction
import fr.gouv.dgampa.rapportnav.infrastructure.api.bff.adapters.action.ActionFishInput
import fr.gouv.dgampa.rapportnav.infrastructure.api.bff.adapters.v2.MissionActionInput
import fr.gouv.dgampa.rapportnav.infrastructure.api.bff.adapters.v2.MissionFishActionDataInput
import fr.gouv.dgampa.rapportnav.infrastructure.api.bff.model.v2.MissionFishAction
import fr.gouv.dgampa.rapportnav.infrastructure.api.bff.model.v2.MissionFishActionData
import org.slf4j.LoggerFactory

@UseCase
Expand All @@ -18,13 +18,13 @@ class UpdateFishAction(
) {
private val logger = LoggerFactory.getLogger(UpdateFishAction::class.java)

fun execute(input: MissionActionInput): MissionFishActionEntity? {
val action = MissionFishActionDataInput.toMissionFishActionEntity(input)
val controlInputs = input.fish?.getControls(actionId = input.id, missionId = input.missionId)
fun execute(id: String, input: MissionFishAction): MissionFishActionEntity? {
val action = MissionFishActionData.toMissionFishActionEntity(input)
val controlInputs = input.data.getControls(actionId = id, missionId = input.missionId)
return try {
patchFishAction.execute(
ActionFishInput(
actionId = action.id.toString(),
actionId = id,
missionId = action.missionId,
startDateTimeUtc = action.startDateTimeUtc,
endDateTimeUtc = action.endDateTimeUtc,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ import fr.gouv.dgampa.rapportnav.domain.entities.mission.v2.MissionNavActionEnti
import fr.gouv.dgampa.rapportnav.domain.repositories.mission.action.INavMissionActionRepository
import fr.gouv.dgampa.rapportnav.domain.use_cases.mission.control.v2.ProcessMissionActionControl
import fr.gouv.dgampa.rapportnav.domain.use_cases.mission.infraction.v2.ProcessMissionActionInfraction
import fr.gouv.dgampa.rapportnav.infrastructure.api.bff.adapters.v2.MissionActionInput
import fr.gouv.dgampa.rapportnav.infrastructure.api.bff.adapters.v2.MissionNavActionDataInput
import fr.gouv.dgampa.rapportnav.infrastructure.api.bff.model.v2.MissionAction
import fr.gouv.dgampa.rapportnav.infrastructure.api.bff.model.v2.MissionNavAction
import fr.gouv.dgampa.rapportnav.infrastructure.api.bff.model.v2.MissionNavActionData
import org.slf4j.LoggerFactory

@UseCase
Expand All @@ -17,9 +18,9 @@ class UpdateNavAction(
) {
private val logger = LoggerFactory.getLogger(UpdateNavAction::class.java)

fun execute(input: MissionActionInput): MissionNavActionEntity? {
val action = MissionNavActionDataInput.toMissionNavActionEntity(input)
val controlInputs = input.nav?.getControls(actionId = input.id, missionId = input.missionId)
fun execute(id: String, input: MissionNavAction): MissionNavActionEntity? {
val action = MissionNavActionData.toMissionNavActionEntity(input)
val controlInputs = input.data.getControls(actionId = id, missionId = input.missionId)
return try {
missionActionRepository.save(action)
val controls = processMissionActionControl.execute(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import fr.gouv.dgampa.rapportnav.domain.repositories.mission.control.IControlAdm
import fr.gouv.dgampa.rapportnav.domain.repositories.mission.control.IControlGensDeMerRepository
import fr.gouv.dgampa.rapportnav.domain.repositories.mission.control.IControlNavigationRepository
import fr.gouv.dgampa.rapportnav.domain.repositories.mission.control.IControlSecurityRepository
import fr.gouv.dgampa.rapportnav.infrastructure.api.bff.adapters.v2.*
import fr.gouv.dgampa.rapportnav.infrastructure.api.bff.model.v2.*

@UseCase
class ProcessMissionActionControl(
Expand All @@ -16,22 +16,22 @@ class ProcessMissionActionControl(
private val controlAdministrativeRepo: IControlAdministrativeRepository
) {

fun execute(actionId: String, controls: ActionControlInput?): ActionControlInput {
fun execute(actionId: String, controls: ActionControl?): ActionControl {
val controlSecurity = processControlSecurity(actionId = actionId, control = controls?.controlSecurity)
val controlGensDeMer = processControlGensDeMer(actionId = actionId, control = controls?.controlGensDeMer)
val controlNavigation = processControlNavigation(actionId = actionId, control = controls?.controlNavigation)
val controlAdministrative =
processControlAdministrative(actionId = actionId, control = controls?.controlAdministrative)

return ActionControlInput(
return ActionControl(
controlSecurity = controlSecurity,
controlGensDeMer = controlGensDeMer,
controlNavigation = controlNavigation,
controlAdministrative = controlAdministrative
)
}

private inline fun <M : BaseControlInput, T : BaseControlEntity> processControl(
private inline fun <M : BaseControl, T : BaseControlEntity> processControl(
actionId: String,
control: M?,
findControlByActionId: (String) -> T?,
Expand All @@ -47,7 +47,7 @@ class ProcessMissionActionControl(
}


private fun processControlSecurity(actionId: String, control: ControlSecurityInput2?): ControlSecurityInput2? {
private fun processControlSecurity(actionId: String, control: ControlSecurity?): ControlSecurity? {
val response = processControl(
actionId = actionId,
control = control,
Expand All @@ -58,7 +58,7 @@ class ProcessMissionActionControl(
return control
}

private fun processControlGensDeMer(actionId: String, control: ControlGensDeMerInput2?): ControlGensDeMerInput2? {
private fun processControlGensDeMer(actionId: String, control: ControlGensDeMer?): ControlGensDeMer? {
val response = processControl(
actionId = actionId,
control = control,
Expand All @@ -71,8 +71,8 @@ class ProcessMissionActionControl(

private fun processControlNavigation(
actionId: String,
control: ControlNavigationInput2?
): ControlNavigationInput2? {
control: ControlNavigation?
): ControlNavigation? {
val response = processControl(
actionId = actionId,
control = control,
Expand All @@ -85,8 +85,8 @@ class ProcessMissionActionControl(

private fun processControlAdministrative(
actionId: String,
control: ControlAdministrativeInput2?
): ControlAdministrativeInput2? {
control: ControlAdministrative?
): ControlAdministrative? {
val response = processControl(
actionId = actionId,
control = control,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import fr.gouv.dgampa.rapportnav.domain.repositories.mission.control.IControlAdm
import fr.gouv.dgampa.rapportnav.domain.repositories.mission.control.IControlGensDeMerRepository
import fr.gouv.dgampa.rapportnav.domain.repositories.mission.control.IControlNavigationRepository
import fr.gouv.dgampa.rapportnav.domain.repositories.mission.control.IControlSecurityRepository
import fr.gouv.dgampa.rapportnav.infrastructure.api.bff.adapters.v2.ActionControlInput
import fr.gouv.dgampa.rapportnav.infrastructure.api.bff.adapters.v2.InfractionInput2
import fr.gouv.dgampa.rapportnav.infrastructure.api.bff.model.v2.ActionControl
import fr.gouv.dgampa.rapportnav.infrastructure.api.bff.model.v2.Infraction
import java.util.*

@UseCase
Expand All @@ -18,8 +18,8 @@ class ProcessMissionActionControlEnvTarget(
private val controlAdministrativeRepo: IControlAdministrativeRepository
) {

fun execute(infraction: InfractionInput2, controls: ActionControlInput): String? {
val controlType = infraction.controlType?.let { ControlType.valueOf(it) }
fun execute(infraction: Infraction, controls: ActionControl): String? {
val controlType = infraction.controlType
val id = when (controlType) {
ControlType.SECURITY -> controls.controlSecurity?.id
?: processControlSecurity(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ package fr.gouv.dgampa.rapportnav.domain.use_cases.mission.infraction.v2
import fr.gouv.dgampa.rapportnav.config.UseCase
import fr.gouv.dgampa.rapportnav.domain.entities.mission.nav.infraction.InfractionEntity
import fr.gouv.dgampa.rapportnav.domain.repositories.mission.infraction.IInfractionRepository
import fr.gouv.dgampa.rapportnav.infrastructure.api.bff.adapters.v2.InfractionInput2
import fr.gouv.dgampa.rapportnav.infrastructure.api.bff.model.v2.Infraction

@UseCase
class ProcessMissionActionInfraction(
private val infractionRepo: IInfractionRepository
) {

fun execute(actionId: String, infractions: List<InfractionInput2>): List<InfractionEntity>? {
fun execute(actionId: String, infractions: List<Infraction>): List<InfractionEntity>? {
val infractionIds = infractions.map { it.id }

val databaseInfractions = infractionRepo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,15 @@ package fr.gouv.dgampa.rapportnav.domain.use_cases.mission.infraction.v2

import fr.gouv.dgampa.rapportnav.config.UseCase
import fr.gouv.dgampa.rapportnav.domain.entities.mission.nav.infraction.InfractionEntity
import fr.gouv.dgampa.rapportnav.domain.repositories.mission.infraction.IInfractionEnvTargetRepository
import fr.gouv.dgampa.rapportnav.domain.repositories.mission.infraction.IInfractionRepository
import fr.gouv.dgampa.rapportnav.infrastructure.api.bff.adapters.v2.InfractionInput2
import fr.gouv.dgampa.rapportnav.infrastructure.api.bff.model.v2.Infraction

@UseCase
class ProcessMissionActionInfractionEnvTarget(
private val infractionRepo: IInfractionRepository,
private val infractionEnvTargetRepo: IInfractionEnvTargetRepository,
private val infractionRepo: IInfractionRepository
) {

fun execute(actionId: String, infractions: List<InfractionInput2>?): List<InfractionEntity>? {
fun execute(actionId: String, infractions: List<Infraction>?): List<InfractionEntity>? {
val infractionIds = infractions?.map { it.id } ?: listOf()

val databaseInfractions = infractionRepo
Expand All @@ -25,7 +23,7 @@ class ProcessMissionActionInfractionEnvTarget(
return save(infractions) //TODO: is not equals save
}

fun save(infractions: List<InfractionInput2>?): List<InfractionEntity>? {
fun save(infractions: List<Infraction>?): List<InfractionEntity>? {
// check target / create or Update target
// create infractionEntity -- > save target
//save infraction
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit e6452d3

Please sign in to comment.