Skip to content

Commit

Permalink
Add isArchived prop to control unit resources in DB & Backend
Browse files Browse the repository at this point in the history
  • Loading branch information
ivangabriele committed Oct 20, 2023
1 parent 55848c2 commit 91df6b3
Show file tree
Hide file tree
Showing 16 changed files with 68 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ data class ControlUnitResourceEntity(
val id: Int? = null,
val baseId: Int,
val controlUnitId: Int,
val isArchived: Boolean,
val name: String,
val note: String? = null,
val photo: ByteArray? = byteArrayOf(),
Expand All @@ -17,6 +18,7 @@ data class ControlUnitResourceEntity(
if (id != other.id) return false
if (baseId != other.baseId) return false
if (controlUnitId != other.controlUnitId) return false
if (isArchived != other.isArchived) return false
if (name != other.name) return false
if (note != other.note) return false
if (photo != null) {
Expand All @@ -32,6 +34,7 @@ data class ControlUnitResourceEntity(
var result = id ?: 0
result = 31 * result + baseId
result = 31 * result + controlUnitId
result = 31 * result + isArchived.hashCode()
result = 31 * result + name.hashCode()
result = 31 * result + (note?.hashCode() ?: 0)
result = 31 * result + (photo?.contentHashCode() ?: 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ data class FullControlUnitResourceDTO(
id = controlUnitResource.id,
baseId = controlUnitResource.baseId,
controlUnitId = controlUnitResource.controlUnitId,
isArchived = controlUnitResource.isArchived,
name = controlUnitResource.name,
note = controlUnitResource.note,
photo = controlUnitResource.photo,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ data class CreateOrUpdateControlUnitResourceDataInput(
val id: Int? = null,
val baseId: Int,
val controlUnitId: Int,
val isArchived: Boolean,
val name: String,
val note: String? = null,
val photo: ByteArray? = byteArrayOf(),
Expand All @@ -17,6 +18,7 @@ data class CreateOrUpdateControlUnitResourceDataInput(
id = this.id,
baseId = this.baseId,
controlUnitId = this.controlUnitId,
isArchived = this.isArchived,
name = this.name,
note = this.note,
photo = this.photo,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ data class ControlUnitResourceDataOutput(
val id: Int,
val baseId: Int,
val controlUnitId: Int,
val isArchived: Boolean,
val name: String,
val note: String? = null,
val photo: ByteArray? = byteArrayOf(),
Expand All @@ -17,6 +18,7 @@ data class ControlUnitResourceDataOutput(
id = requireNotNull(controlUnitResource.id),
baseId = controlUnitResource.baseId,
controlUnitId = controlUnitResource.controlUnitId,
isArchived = controlUnitResource.isArchived,
name = controlUnitResource.name,
note = controlUnitResource.note,
photo = controlUnitResource.photo,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ data class ControlUnitResourceModel(
@JsonBackReference
val controlUnit: ControlUnitModel,

@Column(name = "is_archived", nullable = false)
val isArchived: Boolean,

@Column(name = "name", nullable = false)
val name: String,

Expand Down Expand Up @@ -60,6 +63,7 @@ data class ControlUnitResourceModel(
if (id != other.id) return false
if (base != other.base) return false
if (controlUnit != other.controlUnit) return false
if (isArchived != other.isArchived) return false
if (name != other.name) return false
if (note != other.note) return false
if (photo != null) {
Expand All @@ -83,6 +87,7 @@ data class ControlUnitResourceModel(
id = controlUnitResource.id,
base = baseModel,
controlUnit = controlUnitModel,
isArchived = controlUnitResource.isArchived,
name = controlUnitResource.name,
note = controlUnitResource.note,
photo = controlUnitResource.photo,
Expand All @@ -95,6 +100,7 @@ data class ControlUnitResourceModel(
var result = id ?: 0
result = 31 * result + base.hashCode()
result = 31 * result + controlUnit.hashCode()
result = 31 * result + isArchived.hashCode()
result = 31 * result + name.hashCode()
result = 31 * result + (note?.hashCode() ?: 0)
result = 31 * result + (photo?.contentHashCode() ?: 0)
Expand All @@ -110,6 +116,7 @@ data class ControlUnitResourceModel(
id,
baseId = requireNotNull(base.id),
controlUnitId = requireNotNull(controlUnit.id),
isArchived,
name,
note,
photo,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ data class MissionControlResourceModel(
id = requireNotNull(controlUnitResource.id),
base = baseModel,
controlUnit = controlUnitModel,
isArchived = controlUnitResource.isArchived,
name = controlUnitResource.name,
note = controlUnitResource.note,
photo = controlUnitResource.photo,
Expand All @@ -44,6 +45,7 @@ data class MissionControlResourceModel(
id = ressource.id,
baseId = requireNotNull(ressource.base.id),
controlUnitId = requireNotNull(ressource.controlUnit.id),
isArchived = ressource.isArchived,
name = ressource.name,
note = ressource.note,
photo = byteArrayOf(),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ALTER TABLE public.control_unit_resources
ADD COLUMN is_archived BOOLEAN NOT NULL DEFAULT false;
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class CreateOrUpdateControlUnitResourceUTests {
val newControlUnitResource = ControlUnitResourceEntity(
baseId = 2,
controlUnitId = 3,
isArchived = false,
name = "Control Unit Resource Name",
note = null,
photo = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,13 @@ import fr.gouv.cacem.monitorenv.domain.entities.VehicleTypeEnum
import fr.gouv.cacem.monitorenv.domain.entities.controlUnit.ControlUnitResourceEntity
import fr.gouv.cacem.monitorenv.domain.entities.controlUnit.ControlUnitResourceType
import fr.gouv.cacem.monitorenv.domain.entities.controlUnit.LegacyControlUnitEntity
import fr.gouv.cacem.monitorenv.domain.entities.mission.ActionTargetTypeEnum
import fr.gouv.cacem.monitorenv.domain.entities.mission.EnvActionControlEntity
import fr.gouv.cacem.monitorenv.domain.entities.mission.MissionEntity
import fr.gouv.cacem.monitorenv.domain.entities.mission.MissionSourceEnum
import fr.gouv.cacem.monitorenv.domain.entities.mission.MissionTypeEnum
import fr.gouv.cacem.monitorenv.domain.entities.mission.*
import fr.gouv.cacem.monitorenv.domain.entities.reporting.ReportingEntity
import fr.gouv.cacem.monitorenv.domain.entities.reporting.ReportingTypeEnum
import fr.gouv.cacem.monitorenv.domain.entities.reporting.SourceTypeEnum
import fr.gouv.cacem.monitorenv.domain.entities.reporting.TargetTypeEnum
import fr.gouv.cacem.monitorenv.domain.entities.semaphore.SemaphoreEntity
import fr.gouv.cacem.monitorenv.domain.use_cases.missions.CreateOrUpdateMission
import fr.gouv.cacem.monitorenv.domain.use_cases.missions.DeleteMission
import fr.gouv.cacem.monitorenv.domain.use_cases.missions.GetEngagedControlUnits
import fr.gouv.cacem.monitorenv.domain.use_cases.missions.GetMissionById
import fr.gouv.cacem.monitorenv.domain.use_cases.missions.GetMonitorEnvMissions
import fr.gouv.cacem.monitorenv.domain.use_cases.missions.*
import fr.gouv.cacem.monitorenv.domain.use_cases.missions.dtos.MissionDTO
import fr.gouv.cacem.monitorenv.domain.use_cases.reportings.dtos.ReportingDTO
import fr.gouv.cacem.monitorenv.infrastructure.api.adapters.bff.inputs.CreateOrUpdateMissionDataInput
Expand All @@ -39,14 +31,12 @@ import org.springframework.boot.test.mock.mockito.MockBean
import org.springframework.context.annotation.Import
import org.springframework.http.MediaType
import org.springframework.test.web.servlet.MockMvc
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders.put
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*
import org.springframework.test.web.servlet.result.MockMvcResultHandlers
import org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath
import org.springframework.test.web.servlet.result.MockMvcResultMatchers.status
import java.time.ZonedDateTime
import java.util.UUID
import java.util.*

@Import(WebSecurityConfig::class, MapperConfiguration::class)
@WebMvcTest(value = [(MissionsController::class)])
Expand Down Expand Up @@ -143,6 +133,7 @@ class MissionsControllerITests {
ControlUnitResourceEntity(
id = 2,
baseId = 3,
isArchived = false,
name = "Ressource 2",
type = ControlUnitResourceType.BARGE,
controlUnitId = 1,
Expand Down Expand Up @@ -192,7 +183,7 @@ class MissionsControllerITests {
isDeleted = false,
openBy = "OpenBy",

),
),
semaphore = SemaphoreEntity(
id = 1,
name = "Semaphore 1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class ApiControlUnitResourcesControllerITests {
id = 1,
baseId = 0,
controlUnitId = 0,
isArchived = false,
name = "Resource Name",
note = null,
photo = null,
Expand All @@ -65,6 +66,7 @@ class ApiControlUnitResourcesControllerITests {
val newControlUnitData = CreateOrUpdateControlUnitResourceDataInput(
baseId = 0,
controlUnitId = 0,
isArchived = false,
name = "Resource Name",
note = null,
photo = null,
Expand Down Expand Up @@ -107,6 +109,7 @@ class ApiControlUnitResourcesControllerITests {
id = 1,
baseId = 0,
controlUnitId = 0,
isArchived = false,
name = "Resource Name",
note = null,
photo = null,
Expand Down Expand Up @@ -147,6 +150,7 @@ class ApiControlUnitResourcesControllerITests {
id = 1,
baseId = 0,
controlUnitId = 3,
isArchived = false,
name = "Resource Name",
note = null,
photo = null,
Expand Down Expand Up @@ -174,6 +178,7 @@ class ApiControlUnitResourcesControllerITests {
id = 2,
baseId = 0,
controlUnitId = 0,
isArchived = false,
name = "Resource Name 2",
note = null,
photo = null,
Expand All @@ -197,6 +202,7 @@ class ApiControlUnitResourcesControllerITests {
id = 1,
baseId = 0,
controlUnitId = 0,
isArchived = false,
name = "Updated Resource Name",
note = null,
photo = null,
Expand All @@ -207,6 +213,7 @@ class ApiControlUnitResourcesControllerITests {
id = 1,
baseId = 0,
controlUnitId = 0,
isArchived = false,
name = "Updated Resource Name",
note = null,
photo = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class ApiLegacyControlUnitsControllerITests {
id = 0,
baseId = 0,
controlUnitId = 0,
isArchived = false,
name = "Vedette",
type = ControlUnitResourceType.BARGE,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class JpaBaseRepositoryITests : AbstractDBTests() {
id = 1,
baseId = 1,
controlUnitId = 10000,
isArchived = false,
name = "Semi-rigide 1",
note = null,
photo = null,
Expand All @@ -42,6 +43,7 @@ class JpaBaseRepositoryITests : AbstractDBTests() {
id = 2,
baseId = 1,
controlUnitId = 10000,
isArchived = false,
name = "Semi-rigide 2",
note = null,
photo = null,
Expand All @@ -64,6 +66,7 @@ class JpaBaseRepositoryITests : AbstractDBTests() {
id = 5,
baseId = 3,
controlUnitId = 10002,
isArchived = false,
name = "Voiture",
note = null,
photo = null,
Expand All @@ -73,6 +76,7 @@ class JpaBaseRepositoryITests : AbstractDBTests() {
id = 7,
baseId = 3,
controlUnitId = 10003,
isArchived = false,
name = "Semi-rigide",
note = null,
photo = null,
Expand All @@ -82,6 +86,7 @@ class JpaBaseRepositoryITests : AbstractDBTests() {
id = 8,
baseId = 3,
controlUnitId = 10121,
isArchived = false,
name = "PAM Jeanne Barret",
note = null,
photo = null,
Expand All @@ -91,6 +96,7 @@ class JpaBaseRepositoryITests : AbstractDBTests() {
id = 9,
baseId = 3,
controlUnitId = 10080,
isArchived = false,
name = "PAM Themis",
note = null,
photo = null,
Expand All @@ -100,6 +106,7 @@ class JpaBaseRepositoryITests : AbstractDBTests() {
id = 10,
baseId = 3,
controlUnitId = 10018,
isArchived = false,
name = "ALTAIR",
note = null,
photo = null,
Expand All @@ -109,6 +116,7 @@ class JpaBaseRepositoryITests : AbstractDBTests() {
id = 11,
baseId = 3,
controlUnitId = 10018,
isArchived = false,
name = "PHEROUSA",
note = null,
photo = null,
Expand All @@ -118,6 +126,7 @@ class JpaBaseRepositoryITests : AbstractDBTests() {
id = 12,
baseId = 3,
controlUnitId = 10018,
isArchived = false,
name = "ARIOLA",
note = null,
photo = null,
Expand Down Expand Up @@ -146,6 +155,7 @@ class JpaBaseRepositoryITests : AbstractDBTests() {
id = 3,
baseId = 2,
controlUnitId = 10002,
isArchived = false,
name = "Semi-rigide 1",
note = null,
photo = null,
Expand All @@ -155,6 +165,7 @@ class JpaBaseRepositoryITests : AbstractDBTests() {
id = 4,
baseId = 2,
controlUnitId = 10002,
isArchived = false,
name = "Semi-rigide 2",
note = null,
photo = null,
Expand All @@ -164,6 +175,7 @@ class JpaBaseRepositoryITests : AbstractDBTests() {
id = 6,
baseId = 2,
controlUnitId = 10003,
isArchived = false,
name = "AR VECHEN",
note = null,
photo = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ class JpaControlUnitRepositoryITests : AbstractDBTests() {
id = 1,
baseId = 1,
controlUnitId = 10000,
isArchived = false,
name = "Semi-rigide 1",
note = null,
photo = null,
Expand All @@ -117,6 +118,7 @@ class JpaControlUnitRepositoryITests : AbstractDBTests() {
id = 2,
baseId = 1,
controlUnitId = 10000,
isArchived = false,
name = "Semi-rigide 2",
note = null,
photo = null,
Expand Down Expand Up @@ -164,6 +166,7 @@ class JpaControlUnitRepositoryITests : AbstractDBTests() {
id = 8,
baseId = 3,
controlUnitId = 10121,
isArchived = false,
name = "PAM Jeanne Barret",
note = null,
photo = null,
Expand Down Expand Up @@ -233,6 +236,7 @@ class JpaControlUnitRepositoryITests : AbstractDBTests() {
id = 1,
baseId = 1,
controlUnitId = 10000,
isArchived = false,
name = "Semi-rigide 1",
note = null,
photo = null,
Expand All @@ -259,6 +263,7 @@ class JpaControlUnitRepositoryITests : AbstractDBTests() {
id = 2,
baseId = 1,
controlUnitId = 10000,
isArchived = false,
name = "Semi-rigide 2",
note = null,
photo = null,
Expand Down
Loading

0 comments on commit 91df6b3

Please sign in to comment.