Skip to content

Commit 142beb5

Browse files
committed
Remove useless NadFromElement and add attributes to NetworkAreaDiagram
Signed-off-by: Ayoub LABIDI <[email protected]>
1 parent 65442fe commit 142beb5

23 files changed

+223
-128
lines changed
Lines changed: 18 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,34 @@
1-
/*
2-
Copyright (c) 2024, RTE (http://www.rte-france.com)
3-
This Source Code Form is subject to the terms of the Mozilla Public
4-
License, v. 2.0. If a copy of the MPL was not distributed with this
5-
file, You can obtain one at http://mozilla.org/MPL/2.0/.
1+
/**
2+
* Copyright (c) 2025, RTE (http://www.rte-france.com)
3+
* This Source Code Form is subject to the terms of the Mozilla Public
4+
* License, v. 2.0. If a copy of the MPL was not distributed with this
5+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
66
*/
77
package org.gridsuite.studyconfig.server.configuration;
88

9-
import com.fasterxml.jackson.databind.Module;
10-
import com.fasterxml.jackson.databind.jsontype.NamedType;
11-
import com.fasterxml.jackson.databind.module.SimpleModule;
12-
import org.gridsuite.studyconfig.server.dto.studylayout.diagramlayout.NadFromElementDiagramLayout;
13-
import org.gridsuite.studyconfig.server.dto.studylayout.diagramlayout.NetworkAreaDiagramLayout;
14-
import org.gridsuite.studyconfig.server.dto.studylayout.diagramlayout.SubstationDiagramLayout;
15-
import org.gridsuite.studyconfig.server.dto.studylayout.diagramlayout.VoltageLevelDiagramLayout;
16-
import org.springframework.context.annotation.Bean;
9+
import com.fasterxml.jackson.databind.ObjectMapper;
10+
import org.gridsuite.studyconfig.server.dto.studylayout.diagramlayout.AbstractDiagramLayout;
11+
import org.gridsuite.studyconfig.server.dto.studylayout.diagramlayout.AbstractDiagramLayoutJsonMapper;
1712
import org.springframework.context.annotation.Configuration;
1813

14+
import jakarta.annotation.PostConstruct;
15+
1916
/**
2017
* Jackson configuration for diagram layout polymorphic serialization.
2118
* This external configuration avoids circular dependencies between the abstract base class
22-
* and its subtypes by registering the type mappings outside the class hierarchy.
19+
* and its subtypes by using a mixin approach with type mappings.
2320
*/
2421
@Configuration
2522
public class DiagramLayoutJacksonConfiguration {
2623

27-
@Bean
28-
public Module diagramLayoutTypeModule() {
29-
SimpleModule module = new SimpleModule("DiagramLayoutTypeModule");
24+
private final ObjectMapper objectMapper;
3025

31-
// Register subtypes for polymorphic serialization/deserialization
32-
// This approach avoids circular dependencies that would occur with @JsonSubTypes
33-
module.registerSubtypes(
34-
new NamedType(SubstationDiagramLayout.class, "substation"),
35-
new NamedType(VoltageLevelDiagramLayout.class, "voltage-level"),
36-
new NamedType(NetworkAreaDiagramLayout.class, "network-area-diagram"),
37-
new NamedType(NadFromElementDiagramLayout.class, "nad-from-element")
38-
);
26+
public DiagramLayoutJacksonConfiguration(ObjectMapper objectMapper) {
27+
this.objectMapper = objectMapper;
28+
}
3929

40-
return module;
30+
@PostConstruct
31+
public void configureDiagramLayoutMixIn() {
32+
objectMapper.addMixIn(AbstractDiagramLayout.class, AbstractDiagramLayoutJsonMapper.class);
4133
}
4234
}

src/main/java/org/gridsuite/studyconfig/server/controller/StudyLayoutController.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
/**
2+
* Copyright (c) 2025, RTE (http://www.rte-france.com)
3+
* This Source Code Form is subject to the terms of the Mozilla Public
4+
* License, v. 2.0. If a copy of the MPL was not distributed with this
5+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
6+
*/
17
package org.gridsuite.studyconfig.server.controller;
28

39
import io.swagger.v3.oas.annotations.Operation;

src/main/java/org/gridsuite/studyconfig/server/dto/studylayout/StudyLayout.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
/**
2+
* Copyright (c) 2025, RTE (http://www.rte-france.com)
3+
* This Source Code Form is subject to the terms of the Mozilla Public
4+
* License, v. 2.0. If a copy of the MPL was not distributed with this
5+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
6+
*/
17
package org.gridsuite.studyconfig.server.dto.studylayout;
28

39
import lombok.*;

src/main/java/org/gridsuite/studyconfig/server/dto/studylayout/diagramlayout/AbstractDiagramLayout.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1+
/**
2+
* Copyright (c) 2025, RTE (http://www.rte-france.com)
3+
* This Source Code Form is subject to the terms of the Mozilla Public
4+
* License, v. 2.0. If a copy of the MPL was not distributed with this
5+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
6+
*/
17
package org.gridsuite.studyconfig.server.dto.studylayout.diagramlayout;
28

3-
import com.fasterxml.jackson.annotation.JsonTypeInfo;
49
import lombok.AllArgsConstructor;
510
import lombok.Getter;
611
import lombok.NoArgsConstructor;
@@ -15,12 +20,6 @@
1520
@NoArgsConstructor
1621
@Setter
1722
@Getter
18-
@JsonTypeInfo(
19-
use = JsonTypeInfo.Id.NAME,
20-
include = JsonTypeInfo.As.PROPERTY,
21-
property = "type",
22-
visible = true
23-
)
2423
public abstract class AbstractDiagramLayout {
2524
UUID diagramUuid;
2625

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/**
2+
* Copyright (c) 2025, RTE (http://www.rte-france.com)
3+
* This Source Code Form is subject to the terms of the Mozilla Public
4+
* License, v. 2.0. If a copy of the MPL was not distributed with this
5+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
6+
*/
7+
package org.gridsuite.studyconfig.server.dto.studylayout.diagramlayout;
8+
9+
import com.fasterxml.jackson.annotation.JsonSubTypes;
10+
import com.fasterxml.jackson.annotation.JsonTypeInfo;
11+
12+
/**
13+
* MixIn interface for AbstractDiagramLayout to define polymorphic serialization
14+
* without creating circular dependencies in the class hierarchy.
15+
* This approach avoids circular dependencies that would occur with @JsonSubTypes
16+
* directly on the abstract class.
17+
*/
18+
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type", visible = true)
19+
@JsonSubTypes({
20+
@JsonSubTypes.Type(value = SubstationDiagramLayout.class, name = "substation"),
21+
@JsonSubTypes.Type(value = VoltageLevelDiagramLayout.class, name = "voltage-level"),
22+
@JsonSubTypes.Type(value = NetworkAreaDiagramLayout.class, name = "network-area-diagram")
23+
})
24+
public interface AbstractDiagramLayoutJsonMapper {
25+
}

src/main/java/org/gridsuite/studyconfig/server/dto/studylayout/diagramlayout/DiagramGridLayout.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
/**
2+
* Copyright (c) 2025, RTE (http://www.rte-france.com)
3+
* This Source Code Form is subject to the terms of the Mozilla Public
4+
* License, v. 2.0. If a copy of the MPL was not distributed with this
5+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
6+
*/
17
package org.gridsuite.studyconfig.server.dto.studylayout.diagramlayout;
28

39
import lombok.AllArgsConstructor;

src/main/java/org/gridsuite/studyconfig/server/dto/studylayout/diagramlayout/NadFromElementDiagramLayout.java

Lines changed: 0 additions & 20 deletions
This file was deleted.

src/main/java/org/gridsuite/studyconfig/server/dto/studylayout/diagramlayout/NetworkAreaDiagramLayout.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
/**
2+
* Copyright (c) 2025, RTE (http://www.rte-france.com)
3+
* This Source Code Form is subject to the terms of the Mozilla Public
4+
* License, v. 2.0. If a copy of the MPL was not distributed with this
5+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
6+
*/
17
package org.gridsuite.studyconfig.server.dto.studylayout.diagramlayout;
28

39
import lombok.AllArgsConstructor;
@@ -7,13 +13,18 @@
713
import lombok.experimental.SuperBuilder;
814

915
import java.util.List;
16+
import java.util.UUID;
1017

1118
@SuperBuilder
1219
@AllArgsConstructor
1320
@NoArgsConstructor
1421
@Setter
1522
@Getter
1623
public class NetworkAreaDiagramLayout extends AbstractDiagramLayout {
24+
UUID filterUuid;
25+
UUID nadConfigUuid;
1726
List<String> voltageLevelIds;
27+
List<String> voltageLevelToExpandIds;
28+
List<String> voltageLevelToOmitIds;
1829
Integer depth;
1930
}

src/main/java/org/gridsuite/studyconfig/server/dto/studylayout/diagramlayout/SubstationDiagramLayout.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
/**
2+
* Copyright (c) 2025, RTE (http://www.rte-france.com)
3+
* This Source Code Form is subject to the terms of the Mozilla Public
4+
* License, v. 2.0. If a copy of the MPL was not distributed with this
5+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
6+
*/
17
package org.gridsuite.studyconfig.server.dto.studylayout.diagramlayout;
28

39
import lombok.AllArgsConstructor;

src/main/java/org/gridsuite/studyconfig/server/dto/studylayout/diagramlayout/VoltageLevelDiagramLayout.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
/**
2+
* Copyright (c) 2025, RTE (http://www.rte-france.com)
3+
* This Source Code Form is subject to the terms of the Mozilla Public
4+
* License, v. 2.0. If a copy of the MPL was not distributed with this
5+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
6+
*/
17
package org.gridsuite.studyconfig.server.dto.studylayout.diagramlayout;
28

39
import lombok.AllArgsConstructor;

0 commit comments

Comments
 (0)