Skip to content

Commit baf7192

Browse files
authored
add limits in line type (#665)
Signed-off-by: Etienne LESOT <[email protected]>
1 parent 7e88fa1 commit baf7192

File tree

13 files changed

+392
-52
lines changed

13 files changed

+392
-52
lines changed

src/main/java/org/gridsuite/modification/server/NetworkModificationController.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,13 @@ public ResponseEntity<List<LineTypeInfos>> getLineTypes() {
189189
return ResponseEntity.ok().body(lineTypesCatalogService.getAllLineTypes());
190190
}
191191

192+
@GetMapping(value = "/network-modifications/catalog/line_types/{uuid}", produces = MediaType.APPLICATION_JSON_VALUE)
193+
@Operation(summary = "Get a line types catalog")
194+
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The line types catalog is returned")})
195+
public ResponseEntity<LineTypeInfos> getOneLineTypeWithLimits(@PathVariable("uuid") UUID uuid) {
196+
return ResponseEntity.ok().body(lineTypesCatalogService.getLineTypesWithLimits(uuid));
197+
}
198+
192199
@PostMapping(value = "/network-modifications/catalog/line_types", consumes = MediaType.APPLICATION_JSON_VALUE)
193200
@Operation(summary = "Create or reset completely a line types catalog")
194201
@ApiResponse(responseCode = "200", description = "The line types catalog is created or reset")
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
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+
* SPDX-License-Identifier: MPL-2.0
7+
*/
8+
package org.gridsuite.modification.server.dto.catalog;
9+
10+
import io.swagger.v3.oas.annotations.media.Schema;
11+
import lombok.AllArgsConstructor;
12+
import lombok.Getter;
13+
import lombok.NoArgsConstructor;
14+
import lombok.Setter;
15+
import lombok.experimental.SuperBuilder;
16+
17+
import java.util.UUID;
18+
19+
/**
20+
* @author Etienne Lesot <etienne.lesot at rte-france.com>
21+
*/
22+
@SuperBuilder
23+
@NoArgsConstructor
24+
@AllArgsConstructor
25+
@Getter
26+
@Setter
27+
@Schema(description = "Limits for line type")
28+
public class LimitsForLineTypeInfos {
29+
30+
@Schema(description = "id")
31+
private UUID id;
32+
33+
@Schema(description = "Limit set name")
34+
private String limitSetName;
35+
36+
@Schema(description = "Permanent limit")
37+
private Double permanentLimit;
38+
39+
@Schema(description = "Temporary limit value")
40+
private Double temporaryLimitValue;
41+
42+
@Schema(description = "Temporary limit acceptable duration")
43+
private Integer temporaryLimitAcceptableDuration;
44+
45+
@Schema(description = "Temporary limit name")
46+
private String temporaryLimitName;
47+
48+
@Schema(description = "Area")
49+
private String area;
50+
51+
@Schema(description = "Temperature")
52+
private String temperature;
53+
}

src/main/java/org/gridsuite/modification/server/dto/catalog/LineTypeInfos.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,17 @@
66
*/
77
package org.gridsuite.modification.server.dto.catalog;
88

9-
import io.swagger.v3.oas.annotations.media.Schema;
10-
import lombok.*;
11-
import lombok.experimental.SuperBuilder;
12-
import java.util.UUID;
139
import com.fasterxml.jackson.annotation.JsonIgnore;
1410
import com.fasterxml.jackson.annotation.JsonSubTypes;
1511
import com.fasterxml.jackson.annotation.JsonTypeInfo;
16-
12+
import io.swagger.v3.oas.annotations.media.Schema;
13+
import lombok.*;
14+
import lombok.experimental.SuperBuilder;
1715
import org.gridsuite.modification.server.entities.catalog.LineTypeEntity;
1816

17+
import java.util.List;
18+
import java.util.UUID;
19+
1920
/**
2021
* @author Sylvain Bouzols <sylvain.bouzols at rte-france.com>
2122
*/
@@ -61,6 +62,9 @@ public class LineTypeInfos {
6162
@Schema(description = "Linear capacity")
6263
private Double linearCapacity;
6364

65+
@Schema(description = "Limits for line type")
66+
private List<LimitsForLineTypeInfos> limitsForLineType;
67+
6468
@JsonIgnore
6569
public LineTypeEntity toEntity() {
6670
throw new UnsupportedOperationException("TODO");

src/main/java/org/gridsuite/modification/server/dto/catalog/UndergroundLineTypeInfos.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@
99
import io.swagger.v3.oas.annotations.media.Schema;
1010
import lombok.*;
1111
import lombok.experimental.SuperBuilder;
12-
1312
import org.gridsuite.modification.server.entities.catalog.UndergroundLineTypeEntity;
1413

14+
import java.util.List;
15+
1516
/**
1617
* @author Sylvain Bouzols <sylvain.bouzols at rte-france.com>
1718
*/
@@ -30,6 +31,9 @@ public class UndergroundLineTypeInfos extends LineTypeInfos {
3031
@Schema(description = "Screen")
3132
private String screen;
3233

34+
@Schema(description = "shapeFactors")
35+
private List<Double> shapeFactors;
36+
3337
@Override
3438
public UndergroundLineTypeEntity toEntity() {
3539
return new UndergroundLineTypeEntity(this);

src/main/java/org/gridsuite/modification/server/entities/catalog/AerialLineTypeEntity.java

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,10 @@
66
*/
77
package org.gridsuite.modification.server.entities.catalog;
88

9+
import jakarta.persistence.*;
910
import lombok.NoArgsConstructor;
10-
1111
import org.gridsuite.modification.server.dto.catalog.AerialLineTypeInfos;
1212

13-
import jakarta.persistence.*;
14-
1513
/**
1614
* @author Sylvain Bouzols <sylvain.bouzols at rte-france.com>
1715
*/
@@ -41,21 +39,31 @@ private void assignAttributes(AerialLineTypeInfos aerialLineType) {
4139
groundWiresNumber = aerialLineType.getGroundWiresNumber();
4240
}
4341

42+
AerialLineTypeInfos.AerialLineTypeInfosBuilder<?, ?> toDtoBuilder() {
43+
return AerialLineTypeInfos.builder()
44+
.id(this.getId())
45+
.type(this.getType())
46+
.voltage(this.getVoltage())
47+
.conductorType(this.getConductorType())
48+
.section(this.getSection())
49+
.conductorsNumber(this.conductorsNumber)
50+
.circuitsNumber(this.circuitsNumber)
51+
.groundWiresNumber(this.groundWiresNumber)
52+
.linearResistance(this.getLinearResistance())
53+
.linearReactance(this.getLinearReactance())
54+
.linearCapacity(this.getLinearCapacity());
55+
}
56+
4457
@Override
4558
public AerialLineTypeInfos toDto() {
46-
return AerialLineTypeInfos.builder()
47-
.id(this.getId())
48-
.type(this.getType())
49-
.voltage(this.getVoltage())
50-
.conductorType(this.getConductorType())
51-
.section(this.getSection())
52-
.conductorsNumber(this.conductorsNumber)
53-
.circuitsNumber(this.circuitsNumber)
54-
.groundWiresNumber(this.groundWiresNumber)
55-
.linearResistance(this.getLinearResistance())
56-
.linearReactance(this.getLinearReactance())
57-
.linearCapacity(this.getLinearCapacity())
58-
.build();
59+
return toDtoBuilder().build();
60+
}
61+
62+
@Override
63+
public AerialLineTypeInfos toDtoWithLimits() {
64+
return toDtoBuilder()
65+
.limitsForLineType(this.getLimitsForLineType().stream().map(LimitsForLineTypeEntity::toLineTypeInfos).toList())
66+
.build();
5967
}
6068
}
6169

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
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+
* SPDX-License-Identifier: MPL-2.0
7+
*/
8+
package org.gridsuite.modification.server.entities.catalog;
9+
10+
import jakarta.persistence.*;
11+
import lombok.AllArgsConstructor;
12+
import lombok.Getter;
13+
import lombok.NoArgsConstructor;
14+
import lombok.experimental.SuperBuilder;
15+
import org.gridsuite.modification.server.dto.catalog.LimitsForLineTypeInfos;
16+
17+
import java.util.UUID;
18+
19+
/**
20+
* @author Etienne Lesot <etienne.lesot at rte-france.com>
21+
*/
22+
@Getter
23+
@NoArgsConstructor
24+
@AllArgsConstructor
25+
@SuperBuilder
26+
@Entity
27+
@Table(name = "limits_for_line_type")
28+
public class LimitsForLineTypeEntity {
29+
30+
@Id
31+
@GeneratedValue(strategy = GenerationType.AUTO)
32+
@Column(name = "id")
33+
private UUID id;
34+
35+
@Column
36+
private String limitSetName;
37+
38+
@Column
39+
private Double permanentLimit;
40+
41+
@Column
42+
private Double temporaryLimitValue;
43+
44+
@Column
45+
private Integer temporaryLimitAcceptableDuration;
46+
47+
@Column
48+
private String temporaryLimitName;
49+
50+
@Column
51+
private String area;
52+
53+
@Column
54+
private String temperature;
55+
56+
public LimitsForLineTypeInfos toLineTypeInfos() {
57+
return LimitsForLineTypeInfos.builder()
58+
.id(id)
59+
.limitSetName(limitSetName)
60+
.permanentLimit(permanentLimit)
61+
.temporaryLimitValue(temporaryLimitValue)
62+
.temporaryLimitAcceptableDuration(temporaryLimitAcceptableDuration)
63+
.temporaryLimitName(temporaryLimitName)
64+
.area(area)
65+
.temperature(temperature)
66+
.build();
67+
}
68+
69+
public LimitsForLineTypeEntity(LimitsForLineTypeInfos limitsForLineTypeInfos) {
70+
this(limitsForLineTypeInfos.getId(),
71+
limitsForLineTypeInfos.getLimitSetName(),
72+
limitsForLineTypeInfos.getPermanentLimit(),
73+
limitsForLineTypeInfos.getTemporaryLimitValue(),
74+
limitsForLineTypeInfos.getTemporaryLimitAcceptableDuration(),
75+
limitsForLineTypeInfos.getTemporaryLimitName(),
76+
limitsForLineTypeInfos.getArea(),
77+
limitsForLineTypeInfos.getTemperature());
78+
}
79+
}

src/main/java/org/gridsuite/modification/server/entities/catalog/LineTypeEntity.java

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
*/
77
package org.gridsuite.modification.server.entities.catalog;
88

9-
import lombok.NoArgsConstructor;
9+
import jakarta.persistence.*;
1010
import lombok.Getter;
11-
11+
import lombok.NoArgsConstructor;
1212
import org.gridsuite.modification.server.dto.catalog.LineTypeInfos;
1313

14-
import jakarta.persistence.*;
14+
import java.util.List;
1515
import java.util.UUID;
1616

1717
/**
@@ -50,6 +50,10 @@ public class LineTypeEntity {
5050
@Column(name = "linearCapacity")
5151
private Double linearCapacity;
5252

53+
@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, orphanRemoval = true)
54+
@JoinColumn(name = "line_type_id", nullable = false)
55+
private List<LimitsForLineTypeEntity> limitsForLineType;
56+
5357
protected LineTypeEntity(LineTypeInfos lineType) {
5458
assignAttributes(lineType);
5559
}
@@ -63,19 +67,31 @@ private void assignAttributes(LineTypeInfos lineType) {
6367
linearResistance = lineType.getLinearResistance();
6468
linearReactance = lineType.getLinearReactance();
6569
linearCapacity = lineType.getLinearCapacity();
70+
if (lineType.getLimitsForLineType() != null) {
71+
limitsForLineType = lineType.getLimitsForLineType().stream().map(LimitsForLineTypeEntity::new).toList();
72+
}
6673
}
6774

68-
public LineTypeInfos toDto() {
75+
LineTypeInfos.LineTypeInfosBuilder<?, ?> toBuilder() {
6976
return LineTypeInfos.builder()
70-
.id(this.id)
71-
.type(this.type)
72-
.voltage(this.voltage)
73-
.conductorType(this.conductorType)
74-
.section(this.section)
75-
.linearResistance(this.linearResistance)
76-
.linearReactance(this.linearReactance)
77-
.linearCapacity(this.linearCapacity)
78-
.build();
77+
.id(this.id)
78+
.type(this.type)
79+
.voltage(this.voltage)
80+
.conductorType(this.conductorType)
81+
.section(this.section)
82+
.linearResistance(this.linearResistance)
83+
.linearReactance(this.linearReactance)
84+
.linearCapacity(this.linearCapacity);
85+
}
86+
87+
public LineTypeInfos toDto() {
88+
return toBuilder().build();
89+
}
90+
91+
public LineTypeInfos toDtoWithLimits() {
92+
return toBuilder()
93+
.limitsForLineType(this.limitsForLineType.stream().map(LimitsForLineTypeEntity::toLineTypeInfos).toList())
94+
.build();
7995
}
8096
}
8197

src/main/java/org/gridsuite/modification/server/entities/catalog/UndergroundLineTypeEntity.java

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
*/
77
package org.gridsuite.modification.server.entities.catalog;
88

9+
import jakarta.persistence.*;
910
import lombok.NoArgsConstructor;
10-
1111
import org.gridsuite.modification.server.dto.catalog.UndergroundLineTypeInfos;
1212

13-
import jakarta.persistence.*;
13+
import java.util.List;
1414

1515
/**
1616
* @author Sylvain Bouzols <sylvain.bouzols at rte-france.com>
@@ -21,6 +21,8 @@
2121
@PrimaryKeyJoinColumn(foreignKey = @ForeignKey(name = "undergroundLineType_id_fk_constraint"))
2222
public class UndergroundLineTypeEntity extends LineTypeEntity {
2323

24+
private static final List<Double> SHAPE_FACTORS = List.of(0.9d, 0.95d, 1d);
25+
2426
@Column(name = "insulator")
2527
private String insulator;
2628

@@ -37,20 +39,31 @@ private void assignAttributes(UndergroundLineTypeInfos undergroundLineType) {
3739
screen = undergroundLineType.getScreen();
3840
}
3941

42+
UndergroundLineTypeInfos.UndergroundLineTypeInfosBuilder<?, ?> toDtoBuilder() {
43+
return UndergroundLineTypeInfos.builder()
44+
.id(this.getId())
45+
.type(this.getType())
46+
.voltage(this.getVoltage())
47+
.conductorType(this.getConductorType())
48+
.section(this.getSection())
49+
.insulator(this.insulator)
50+
.screen(this.screen)
51+
.linearResistance(this.getLinearResistance())
52+
.linearReactance(this.getLinearReactance())
53+
.linearCapacity(this.getLinearCapacity());
54+
}
55+
4056
@Override
4157
public UndergroundLineTypeInfos toDto() {
42-
return UndergroundLineTypeInfos.builder()
43-
.id(this.getId())
44-
.type(this.getType())
45-
.voltage(this.getVoltage())
46-
.conductorType(this.getConductorType())
47-
.section(this.getSection())
48-
.insulator(this.insulator)
49-
.screen(this.screen)
50-
.linearResistance(this.getLinearResistance())
51-
.linearReactance(this.getLinearReactance())
52-
.linearCapacity(this.getLinearCapacity())
53-
.build();
58+
return toDtoBuilder().build();
59+
}
60+
61+
@Override
62+
public UndergroundLineTypeInfos toDtoWithLimits() {
63+
return toDtoBuilder()
64+
.shapeFactors(SHAPE_FACTORS)
65+
.limitsForLineType(this.getLimitsForLineType().stream().map(LimitsForLineTypeEntity::toLineTypeInfos).toList())
66+
.build();
5467
}
5568
}
5669

0 commit comments

Comments
 (0)