From a3fa77066b5b3a731ae6549e1274ccaeeeeb93ba Mon Sep 17 00:00:00 2001 From: Hugo Marcellin Date: Wed, 11 Jun 2025 18:29:24 +0200 Subject: [PATCH 1/3] Clean up global filter dto --- .../studyconfig/server/dto/GlobalFilterInfos.java | 9 ++++++--- .../server/mapper/SpreadsheetConfigMapper.java | 1 - 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/gridsuite/studyconfig/server/dto/GlobalFilterInfos.java b/src/main/java/org/gridsuite/studyconfig/server/dto/GlobalFilterInfos.java index 578cc30..a5668f3 100644 --- a/src/main/java/org/gridsuite/studyconfig/server/dto/GlobalFilterInfos.java +++ b/src/main/java/org/gridsuite/studyconfig/server/dto/GlobalFilterInfos.java @@ -6,6 +6,7 @@ */ package org.gridsuite.studyconfig.server.dto; +import com.fasterxml.jackson.annotation.JsonInclude; import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.constraints.NotNull; import lombok.Builder; @@ -19,9 +20,7 @@ @Schema(name = "GlobalFilterDto", description = "Global filter configuration") public record GlobalFilterInfos( - @Schema(description = "Global filter UUID") - UUID id, - + @JsonInclude(JsonInclude.Include.NON_NULL) @Schema(description = "Generic filter ID") UUID uuid, @@ -29,6 +28,7 @@ public record GlobalFilterInfos( @Schema(description = "Filter type") String filterType, + @JsonInclude(JsonInclude.Include.NON_NULL) @Schema(description = "Filter subtype") String filterSubtype, @@ -36,12 +36,15 @@ public record GlobalFilterInfos( @Schema(description = "Filter label") String label, + @JsonInclude(JsonInclude.Include.NON_NULL) @Schema(description = "Was filter recently applied") boolean recent, + @JsonInclude(JsonInclude.Include.NON_NULL) @Schema(description = "Generic filter related equipment type") String equipmentType, + @JsonInclude(JsonInclude.Include.NON_NULL) @Schema(description = "Generic filter path") String path diff --git a/src/main/java/org/gridsuite/studyconfig/server/mapper/SpreadsheetConfigMapper.java b/src/main/java/org/gridsuite/studyconfig/server/mapper/SpreadsheetConfigMapper.java index 1c523ab..bd60a97 100644 --- a/src/main/java/org/gridsuite/studyconfig/server/mapper/SpreadsheetConfigMapper.java +++ b/src/main/java/org/gridsuite/studyconfig/server/mapper/SpreadsheetConfigMapper.java @@ -94,7 +94,6 @@ public static ColumnEntity toColumnEntity(ColumnInfos dto) { public static GlobalFilterInfos toGlobalFilterDto(GlobalFilterEntity entity) { return new GlobalFilterInfos( - entity.getId(), entity.getUuid(), entity.getFilterType(), entity.getFilterSubtype(), From 2f931f07a5f9ee0f8209994003755098ad6314bd Mon Sep 17 00:00:00 2001 From: Hugo Marcellin Date: Wed, 11 Jun 2025 18:48:21 +0200 Subject: [PATCH 2/3] Remove id check from tests --- .../server/dto/GlobalFilterInfos.java | 4 ++++ .../mapper/SpreadsheetConfigMapper.java | 19 ++++++++++--------- .../studyconfig/server/DtoConverterTest.java | 4 ---- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/main/java/org/gridsuite/studyconfig/server/dto/GlobalFilterInfos.java b/src/main/java/org/gridsuite/studyconfig/server/dto/GlobalFilterInfos.java index a5668f3..be7d1ae 100644 --- a/src/main/java/org/gridsuite/studyconfig/server/dto/GlobalFilterInfos.java +++ b/src/main/java/org/gridsuite/studyconfig/server/dto/GlobalFilterInfos.java @@ -20,6 +20,10 @@ @Schema(name = "GlobalFilterDto", description = "Global filter configuration") public record GlobalFilterInfos( + @JsonInclude(JsonInclude.Include.NON_NULL) + @Schema(description = "Global filter UUID") + UUID id, + @JsonInclude(JsonInclude.Include.NON_NULL) @Schema(description = "Generic filter ID") UUID uuid, diff --git a/src/main/java/org/gridsuite/studyconfig/server/mapper/SpreadsheetConfigMapper.java b/src/main/java/org/gridsuite/studyconfig/server/mapper/SpreadsheetConfigMapper.java index bd60a97..6106fd1 100644 --- a/src/main/java/org/gridsuite/studyconfig/server/mapper/SpreadsheetConfigMapper.java +++ b/src/main/java/org/gridsuite/studyconfig/server/mapper/SpreadsheetConfigMapper.java @@ -93,15 +93,16 @@ public static ColumnEntity toColumnEntity(ColumnInfos dto) { } public static GlobalFilterInfos toGlobalFilterDto(GlobalFilterEntity entity) { - return new GlobalFilterInfos( - entity.getUuid(), - entity.getFilterType(), - entity.getFilterSubtype(), - entity.getLabel(), - entity.isRecent(), - entity.getEquipmentType(), - entity.getPath() - ); + return GlobalFilterInfos.builder() + .uuid(entity.getUuid()) + .filterType(entity.getFilterType()) + .filterSubtype(entity.getFilterSubtype()) + .label(entity.getLabel()) + .recent(entity.isRecent()) + .equipmentType(entity.getEquipmentType()) + .path(entity.getPath()) + .build(); + } public static GlobalFilterEntity toGlobalFilterEntity(GlobalFilterInfos dto) { diff --git a/src/test/java/org/gridsuite/studyconfig/server/DtoConverterTest.java b/src/test/java/org/gridsuite/studyconfig/server/DtoConverterTest.java index b6bbabe..99147f3 100644 --- a/src/test/java/org/gridsuite/studyconfig/server/DtoConverterTest.java +++ b/src/test/java/org/gridsuite/studyconfig/server/DtoConverterTest.java @@ -84,10 +84,7 @@ void testConversionToDtoOfSpreadsheetConfig() { assertThat(d.columns().get(1).filterValue()).isNull(); // Global filters assertions assertThat(d.globalFilters()).hasSize(2); - assertThat(d.globalFilters().get(0).id()).isNotNull(); assertThat(d.globalFilters().get(0).label()).isEqualTo("GlobalFilter1"); - - assertThat(d.globalFilters().get(1).id()).isNotNull(); assertThat(d.globalFilters().get(1).label()).isEqualTo("GlobalFilter2"); }); } @@ -249,7 +246,6 @@ void testConversionToDtoOfGlobalFilter() { assertThat(dto) .as("DTO conversion result") .satisfies(d -> { - assertThat(d.id()).isEqualTo(uuid); assertThat(d.uuid()).isEqualTo(filterId); assertThat(d.label()).isEqualTo("TestGlobalFilter"); }); From 0424e5a5c6b91ec708e01f6dd4459ae90500cfdf Mon Sep 17 00:00:00 2001 From: Hugo Marcellin Date: Thu, 12 Jun 2025 10:50:59 +0200 Subject: [PATCH 3/3] Remove NON NULL annotation from primitive --- .../org/gridsuite/studyconfig/server/dto/GlobalFilterInfos.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/org/gridsuite/studyconfig/server/dto/GlobalFilterInfos.java b/src/main/java/org/gridsuite/studyconfig/server/dto/GlobalFilterInfos.java index be7d1ae..f9fee01 100644 --- a/src/main/java/org/gridsuite/studyconfig/server/dto/GlobalFilterInfos.java +++ b/src/main/java/org/gridsuite/studyconfig/server/dto/GlobalFilterInfos.java @@ -40,7 +40,6 @@ public record GlobalFilterInfos( @Schema(description = "Filter label") String label, - @JsonInclude(JsonInclude.Include.NON_NULL) @Schema(description = "Was filter recently applied") boolean recent,