Skip to content

Commit 5860073

Browse files
committed
# Conflicts: # src/main/resources/db/changelog/db.changelog-master.yaml
2 parents 18a790d + aabb0a2 commit 5860073

22 files changed

+885
-2
lines changed

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
<groupId>org.gridsuite</groupId>
2121
<artifactId>gridsuite-study-config-server</artifactId>
22-
<version>2.21.0-SNAPSHOT</version>
22+
<version>2.22.0-SNAPSHOT</version>
2323

2424
<packaging>jar</packaging>
2525
<name>Study config server</name>
@@ -42,7 +42,7 @@
4242
</developers>
4343

4444
<properties>
45-
<gridsuite-dependencies.version>41.0.0</gridsuite-dependencies.version>
45+
<gridsuite-dependencies.version>42.0.0</gridsuite-dependencies.version>
4646
<liquibase-hibernate-package>org.gridsuite.studyconfig.server</liquibase-hibernate-package>
4747
<sonar.organization>gridsuite</sonar.organization>
4848
<sonar.projectKey>org.gridsuite:study-config-server</sonar.projectKey>
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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.configuration;
8+
9+
import com.fasterxml.jackson.databind.ObjectMapper;
10+
11+
import org.gridsuite.studyconfig.server.dto.diagramgridlayout.diagramlayout.AbstractDiagramLayout;
12+
import org.gridsuite.studyconfig.server.dto.diagramgridlayout.diagramlayout.AbstractDiagramLayoutJsonMapper;
13+
import org.springframework.context.annotation.Configuration;
14+
15+
import jakarta.annotation.PostConstruct;
16+
17+
/**
18+
* Jackson configuration for diagram layout polymorphic serialization.
19+
* This external configuration avoids circular dependencies between the abstract base class
20+
* and its subtypes by using a mixin approach with type mappings.
21+
*/
22+
@Configuration
23+
public class DiagramLayoutJacksonConfiguration {
24+
25+
private final ObjectMapper objectMapper;
26+
27+
public DiagramLayoutJacksonConfiguration(ObjectMapper objectMapper) {
28+
this.objectMapper = objectMapper;
29+
}
30+
31+
@PostConstruct
32+
public void configureDiagramLayoutMixIn() {
33+
objectMapper.addMixIn(AbstractDiagramLayout.class, AbstractDiagramLayoutJsonMapper.class);
34+
}
35+
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
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.controller;
8+
9+
import io.swagger.v3.oas.annotations.Operation;
10+
import io.swagger.v3.oas.annotations.responses.ApiResponse;
11+
import io.swagger.v3.oas.annotations.responses.ApiResponses;
12+
import io.swagger.v3.oas.annotations.tags.Tag;
13+
import lombok.RequiredArgsConstructor;
14+
import org.gridsuite.studyconfig.server.StudyConfigApi;
15+
import org.gridsuite.studyconfig.server.dto.diagramgridlayout.DiagramGridLayout;
16+
import org.gridsuite.studyconfig.server.service.DiagramGridLayoutService;
17+
import org.springframework.http.MediaType;
18+
import org.springframework.http.ResponseEntity;
19+
import org.springframework.web.bind.annotation.*;
20+
21+
import java.util.UUID;
22+
23+
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
24+
25+
@RestController
26+
@RequestMapping(value = "/" + StudyConfigApi.API_VERSION + "/diagram-grid-layout")
27+
@RequiredArgsConstructor
28+
@Tag(name = "Diagram Grid Layout Config", description = "Diagram Grid Layout Configuration API")
29+
public class DiagramGridLayoutController {
30+
private final DiagramGridLayoutService diagramGridLayoutService;
31+
32+
@PostMapping(consumes = APPLICATION_JSON_VALUE)
33+
@Operation(summary = "Save diagram grid layout")
34+
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The newly created diagram grid layout UUID returned")})
35+
public ResponseEntity<UUID> saveDiagramGridLayout(@RequestBody DiagramGridLayout diagramGridLayout) {
36+
return ResponseEntity.ok().body(diagramGridLayoutService.saveDiagramGridLayout(diagramGridLayout));
37+
}
38+
39+
@PutMapping(value = "/{id}", consumes = APPLICATION_JSON_VALUE)
40+
@Operation(summary = "Update diagram grid layout")
41+
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The diagram grid layout has been updated")})
42+
public ResponseEntity<Void> updateDiagramGridLayout(@PathVariable("id") UUID diagramGridLayoutUuid,
43+
@RequestBody DiagramGridLayout diagramGridLayout) {
44+
diagramGridLayoutService.updateDiagramGridLayout(diagramGridLayoutUuid, diagramGridLayout);
45+
return ResponseEntity.ok().build();
46+
}
47+
48+
@GetMapping(value = "/{id}", produces = APPLICATION_JSON_VALUE)
49+
@Operation(summary = "Get diagram grid layout")
50+
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The diagram grid layout is returned")})
51+
public ResponseEntity<DiagramGridLayout> getDiagramGridLayout(
52+
@PathVariable("id") UUID diagramGridLayoutUuid) {
53+
return ResponseEntity.ok().contentType(MediaType.APPLICATION_JSON).body(diagramGridLayoutService.getByDiagramGridLayoutUuid(diagramGridLayoutUuid));
54+
}
55+
56+
@DeleteMapping(value = "/{id}")
57+
@Operation(summary = "Delete diagram grid layout")
58+
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The diagram grid layout is deleted")})
59+
public ResponseEntity<DiagramGridLayout> deleteDiagramGridLayout(
60+
@PathVariable("id") UUID diagramGridLayoutUuid) {
61+
diagramGridLayoutService.deleteDiagramGridLayout(diagramGridLayoutUuid);
62+
return ResponseEntity.ok().build();
63+
}
64+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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.diagramgridlayout;
8+
9+
import lombok.*;
10+
11+
import java.util.List;
12+
13+
import org.gridsuite.studyconfig.server.dto.diagramgridlayout.diagramlayout.AbstractDiagramLayout;
14+
15+
@Builder
16+
@AllArgsConstructor
17+
@NoArgsConstructor
18+
@Setter
19+
@Getter
20+
public class DiagramGridLayout {
21+
List<AbstractDiagramLayout> diagramLayouts;
22+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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.diagramgridlayout.diagramlayout;
8+
9+
import lombok.AllArgsConstructor;
10+
import lombok.Getter;
11+
import lombok.NoArgsConstructor;
12+
import lombok.Setter;
13+
import lombok.experimental.SuperBuilder;
14+
15+
import java.util.Map;
16+
import java.util.UUID;
17+
18+
@SuperBuilder
19+
@AllArgsConstructor
20+
@NoArgsConstructor
21+
@Setter
22+
@Getter
23+
public abstract class AbstractDiagramLayout {
24+
UUID diagramUuid;
25+
26+
Map<String, DiagramPosition> diagramPositions;
27+
}
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.diagramgridlayout.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+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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.diagramgridlayout.diagramlayout;
8+
9+
import lombok.AllArgsConstructor;
10+
import lombok.Builder;
11+
import lombok.Getter;
12+
13+
@Builder
14+
@AllArgsConstructor
15+
@Getter
16+
public class DiagramPosition {
17+
Integer w;
18+
Integer h;
19+
Integer x;
20+
Integer y;
21+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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.diagramgridlayout.diagramlayout;
8+
9+
import lombok.AllArgsConstructor;
10+
import lombok.Getter;
11+
import lombok.NoArgsConstructor;
12+
import lombok.Setter;
13+
import lombok.experimental.SuperBuilder;
14+
15+
import java.util.UUID;
16+
17+
@SuperBuilder
18+
@AllArgsConstructor
19+
@NoArgsConstructor
20+
@Setter
21+
@Getter
22+
public class NetworkAreaDiagramLayout extends AbstractDiagramLayout {
23+
UUID originalNadConfigUuid;
24+
UUID currentNadConfigUuid;
25+
UUID filterUuid;
26+
String name;
27+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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.diagramgridlayout.diagramlayout;
8+
9+
import lombok.AllArgsConstructor;
10+
import lombok.Getter;
11+
import lombok.NoArgsConstructor;
12+
import lombok.Setter;
13+
import lombok.experimental.SuperBuilder;
14+
15+
@SuperBuilder
16+
@AllArgsConstructor
17+
@NoArgsConstructor
18+
@Setter
19+
@Getter
20+
public class SubstationDiagramLayout extends AbstractDiagramLayout {
21+
String substationId;
22+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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.diagramgridlayout.diagramlayout;
8+
9+
import lombok.AllArgsConstructor;
10+
import lombok.Getter;
11+
import lombok.NoArgsConstructor;
12+
import lombok.Setter;
13+
import lombok.experimental.SuperBuilder;
14+
15+
@SuperBuilder
16+
@AllArgsConstructor
17+
@NoArgsConstructor
18+
@Setter
19+
@Getter
20+
public class VoltageLevelDiagramLayout extends AbstractDiagramLayout {
21+
String voltageLevelId;
22+
}

0 commit comments

Comments
 (0)