Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions .github/workflows/cicd-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,8 @@ jobs:

e2e_test:
name: Run E2E tests
needs: [version, build]
if: false
needs: [ version, build ]
runs-on: ubuntu-22.04
strategy:
# when one test fails, DO NOT cancel the other
Expand All @@ -196,7 +197,7 @@ jobs:
# https://github.com/cypress-io/github-action/issues/48
fail-fast: false
matrix:
containers: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
containers: [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ]
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
CYPRESS_PROJECT_ID: ${{ secrets.CYPRESS_PROJECT_ID }}
Expand Down Expand Up @@ -257,7 +258,7 @@ jobs:

e2e_multi_windows_test:
name: Run E2E multi windows tests
needs: [version, build]
needs: [ version, build ]
runs-on: ubuntu-22.04
if: false
env:
Expand Down Expand Up @@ -307,7 +308,7 @@ jobs:

generate_and_upload_source_maps:
name: Generate and upload source maps to Sentry
needs: [version, build, unit_test_backend, unit_test_frontend, e2e_test]
needs: [ version, build, unit_test_backend, unit_test_frontend, e2e_test ]
runs-on: ubuntu-22.04
env:
VERSION: ${{ needs.version.outputs.VERSION }}
Expand Down Expand Up @@ -352,7 +353,7 @@ jobs:

push_to_registry:
name: Push to registry
needs: [version, unit_test_backend, unit_test_frontend, e2e_test, generate_and_upload_source_maps]
needs: [ version, unit_test_backend, unit_test_frontend ]
# needs: [version, e2e_test, e2e_multi_windows_test, unit_test_frontend, e2e_test]
runs-on: ubuntu-22.04
env:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import java.time.format.DateTimeFormatter
data class AMPEntity(
val id: Int,
val designation: String,
val geom: MultiPolygon,
val geom: MultiPolygon?,
val name: String,
val refReg: String? = null,
val type: String? = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ import fr.gouv.cacem.monitorenv.domain.entities.amp.AMPEntity
import org.locationtech.jts.geom.Geometry

interface IAMPRepository {
fun findAll(): List<AMPEntity>
fun findAll(
withGeometry: Boolean,
zoom: Int? = null,
bbox: List<Double>? = null,
): List<AMPEntity>

fun count(): Long

Expand All @@ -15,4 +19,6 @@ interface IAMPRepository {
ids: List<Int>,
axis: AxisEnum,
): List<AMPEntity>

fun findById(id: Int): AMPEntity?
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@
import org.locationtech.jts.geom.Geometry

interface IRegulatoryAreaNewRepository {
fun findAll(

Check warning on line 8 in backend/src/main/kotlin/fr/gouv/cacem/monitorenv/domain/repositories/IRegulatoryAreaNewRepository.kt

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

This function has 8 parameters, which is greater than the 7 authorized.

See more on https://sonarcloud.io/project/issues?id=MTES-MCT_monitorenv&issues=AZ1EiTXBkWhB4ytKtH4C&open=AZ1EiTXBkWhB4ytKtH4C&pullRequest=2481
controlPlan: String? = null,
query: String? = null,
seaFronts: List<String>? = null,
tags: List<Int>? = null,
themes: List<Int>? = null,
withGeometry: Boolean = true,
zoom: Int? = null,
bbox: List<Double>? = null,
): List<RegulatoryAreaEntity>

fun findAllIdsByGeometry(geometry: Geometry): List<Int>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@ import org.locationtech.jts.geom.Geometry
interface IRegulatoryAreaRepository {
fun findById(id: Int): RegulatoryAreaEntity?

fun findAll(): List<RegulatoryAreaEntity>
fun findAllByIds(ids: List<Int>): List<RegulatoryAreaEntity>

fun findAll(
withGeometry: Boolean,
zoom: Int? = null,
bbox: List<Double>? = null,
): List<RegulatoryAreaEntity>

fun count(): Long

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package fr.gouv.cacem.monitorenv.domain.use_cases.amps

import fr.gouv.cacem.monitorenv.config.UseCase
import fr.gouv.cacem.monitorenv.domain.entities.amp.AMPEntity
import fr.gouv.cacem.monitorenv.domain.exceptions.BackendUsageErrorCode
import fr.gouv.cacem.monitorenv.domain.exceptions.BackendUsageException
import fr.gouv.cacem.monitorenv.domain.repositories.IAMPRepository
import org.slf4j.LoggerFactory

@UseCase
class GetAMPById(
private val ampRepository: IAMPRepository,
) {
private val logger = LoggerFactory.getLogger(GetAMPById::class.java)

fun execute(id: Int): AMPEntity {
ampRepository.findById(id)?.let { return it }
val errorMessage = "amp $id not found"
logger.error(errorMessage)
throw BackendUsageException(BackendUsageErrorCode.ENTITY_NOT_FOUND, errorMessage)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,13 @@ class GetAllAMPs(
) {
private val logger = LoggerFactory.getLogger(GetAllAMPs::class.java)

fun execute(): List<AMPEntity> {
fun execute(
withGeometry: Boolean,
zoom: Int? = null,
bbox: List<Double>? = null,
): List<AMPEntity> {
logger.info("Attempt to GET all AMPs")
val amps = ampRepository.findAll()
val amps = ampRepository.findAll(withGeometry, zoom, bbox)
logger.info("Found ${amps.size} AMPs")

return amps
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class GetAllAMPsByIds(
ids: List<Int>,
axis: AxisEnum,
): List<AMPEntity> {
logger.info("Attempt to GET AMPs with ids: $ids")
logger.info("Attempt to GET AMPs with ids: $ids")
val amps = ampRepository.findAllByIds(ids, axis)
logger.info("Found ${amps.size} AMPs")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@
) {
private val logger = LoggerFactory.getLogger(GetAllRegulatoryAreas::class.java)

fun execute(

Check warning on line 14 in backend/src/main/kotlin/fr/gouv/cacem/monitorenv/domain/use_cases/regulatoryAreas/GetAllNewRegulatoryAreas.kt

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

This function has 8 parameters, which is greater than the 7 authorized.

See more on https://sonarcloud.io/project/issues?id=MTES-MCT_monitorenv&issues=AZ1EiTWvkWhB4ytKtH4B&open=AZ1EiTWvkWhB4ytKtH4B&pullRequest=2481
controlPlan: String?,
searchQuery: String?,
seaFronts: List<String>?,
tags: List<Int>?,
themes: List<Int>?,
withGeometry: Boolean,
zoom: Int?,
bbox: List<Double>?,
): AllRegulatoryAreasAndTotal {
logger.info("Attempt to GET all regulatory areas")

Expand All @@ -27,6 +30,9 @@
seaFronts = seaFronts,
tags = tags,
themes = themes,
withGeometry = withGeometry,
zoom = zoom,
bbox = bbox,
)

val totalCount = allAreas.size.toLong()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,13 @@ class GetAllRegulatoryAreas(
) {
private val logger = LoggerFactory.getLogger(GetAllRegulatoryAreas::class.java)

fun execute(): List<RegulatoryAreaEntity> {
fun execute(
withGeometry: Boolean,
zoom: Int? = null,
bbox: List<Double>? = null,
): List<RegulatoryAreaEntity> {
logger.info("Attempt to GET all regulatory areas")
val regulatoryAreas = regulatoryAreaRepository.findAll()
val regulatoryAreas = regulatoryAreaRepository.findAll(withGeometry, zoom, bbox)
logger.info("Found ${regulatoryAreas.size} regulatory areas")

return regulatoryAreas
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
@file:Suppress("ktlint:standard:package-name")

package fr.gouv.cacem.monitorenv.domain.use_cases.regulatoryAreas

import fr.gouv.cacem.monitorenv.config.UseCase
import fr.gouv.cacem.monitorenv.domain.entities.regulatoryArea.RegulatoryAreaEntity
import fr.gouv.cacem.monitorenv.domain.repositories.IRegulatoryAreaRepository

@UseCase
class GetRegulatoryAreasByIds(
private val regulatoryAreaRepository: IRegulatoryAreaRepository,
) {
fun execute(ids: List<Int>): List<RegulatoryAreaEntity> = regulatoryAreaRepository.findAllByIds(ids)
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import org.locationtech.jts.geom.MultiPolygon
data class AMPDataOutput(
val id: Int,
val designation: String,
val geom: MultiPolygon,
val geom: MultiPolygon?,
val name: String,
val refReg: String? = null,
val type: String? = null,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
package fr.gouv.cacem.monitorenv.infrastructure.api.endpoints.bff.v1

import fr.gouv.cacem.monitorenv.domain.use_cases.amps.GetAMPById
import fr.gouv.cacem.monitorenv.domain.use_cases.amps.GetAllAMPs
import fr.gouv.cacem.monitorenv.domain.use_cases.amps.GetAllAMPsByIds
import fr.gouv.cacem.monitorenv.infrastructure.api.adapters.bff.inputs.amps.AmpByIdsDataInput
import fr.gouv.cacem.monitorenv.infrastructure.api.adapters.bff.outputs.AMPDataOutput
import io.swagger.v3.oas.annotations.Operation
import io.swagger.v3.oas.annotations.tags.Tag
import jakarta.websocket.server.PathParam
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PathVariable
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RequestParam
import org.springframework.web.bind.annotation.RestController

@RestController
Expand All @@ -18,14 +22,30 @@ import org.springframework.web.bind.annotation.RestController
class Amps(
private val getAllAMPs: GetAllAMPs,
private val getAllAMPByIds: GetAllAMPsByIds,
private val getAMPById: GetAMPById,
) {
@GetMapping("")
@Operation(summary = "Get AMPs")
fun getAll(): List<AMPDataOutput> {
val amps = getAllAMPs.execute()
fun getAll(
@RequestParam(name = "withGeometry") withGeometry: Boolean,
@RequestParam(name = "zoom", required = false) zoom: Int?,
@RequestParam(name = "bbox", required = false) bbox: List<Double>?,
): List<AMPDataOutput> {
val amps = getAllAMPs.execute(withGeometry, zoom, bbox)
return amps.map { AMPDataOutput.fromAMPEntity(it) }
}

@GetMapping("/{ampId}")
@Operation(summary = "Get AMP by Id")
fun get(
@PathParam("Amp id")
@PathVariable(name = "ampId")
ampId: Int,
): AMPDataOutput? =
getAMPById.execute(id = ampId).let {
AMPDataOutput.fromAMPEntity(it)
}

@PostMapping("")
@Operation(summary = "Get AMPs by ids")
fun getAll(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@ package fr.gouv.cacem.monitorenv.infrastructure.api.endpoints.bff.v1

import fr.gouv.cacem.monitorenv.domain.use_cases.regulatoryAreas.GetAllRegulatoryAreas
import fr.gouv.cacem.monitorenv.domain.use_cases.regulatoryAreas.GetRegulatoryAreaById
import fr.gouv.cacem.monitorenv.domain.use_cases.regulatoryAreas.GetRegulatoryAreasByIds
import fr.gouv.cacem.monitorenv.infrastructure.api.adapters.bff.outputs.RegulatoryAreaWithMetadataDataOutput
import io.swagger.v3.oas.annotations.Operation
import io.swagger.v3.oas.annotations.tags.Tag
import jakarta.websocket.server.PathParam
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PathVariable
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RequestParam
import org.springframework.web.bind.annotation.RestController

@RestController("regulatoryAreasV1")
Expand All @@ -17,6 +21,7 @@ import org.springframework.web.bind.annotation.RestController
class RegulatoryAreas(
private val getAllRegulatoryAreas: GetAllRegulatoryAreas,
private val getRegulatoryAreaById: GetRegulatoryAreaById,
private val getRegulatoryAreasByIds: GetRegulatoryAreasByIds,
) {
@GetMapping("/{regulatoryAreaId}")
@Operation(summary = "Get regulatory area by Id")
Expand All @@ -31,12 +36,21 @@ class RegulatoryAreas(

@GetMapping("")
@Operation(summary = "Get regulatory Areas")
fun getAll(): List<RegulatoryAreaWithMetadataDataOutput> {
val regulatoryAreas = getAllRegulatoryAreas.execute()
return regulatoryAreas.map {
RegulatoryAreaWithMetadataDataOutput.fromRegulatoryAreaEntity(
it,
)
}
fun getAll(
@RequestParam(name = "withGeometry") withGeometry: Boolean,
@RequestParam(name = "zoom", required = false) zoom: Int?,
@RequestParam(name = "bbox", required = false) bbox: List<Double>?,
): List<RegulatoryAreaWithMetadataDataOutput> {
val regulatoryAreas = getAllRegulatoryAreas.execute(withGeometry, zoom, bbox)
return regulatoryAreas.map { RegulatoryAreaWithMetadataDataOutput.fromRegulatoryAreaEntity(it) }
}

@PostMapping("")
@Operation(summary = "Get regulatory Areas by ids")
fun getAll(
@RequestBody ids: List<Int>,
): List<RegulatoryAreaWithMetadataDataOutput> =
getRegulatoryAreasByIds
.execute(ids)
.map { RegulatoryAreaWithMetadataDataOutput.fromRegulatoryAreaEntity(it) }
}
Loading
Loading