Skip to content

Commit

Permalink
draft complete limits in branch creation (not tested)
Browse files Browse the repository at this point in the history
Signed-off-by: Mathieu DEHARBE <mathieu.deharbe@rte-france.com>
  • Loading branch information
Mathieu-Deharbe committed Dec 10, 2024
1 parent 9d5483f commit 6c6e608
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 24 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
<dependency>
<groupId>org.gridsuite</groupId>
<artifactId>gridsuite-network-modification</artifactId>
<version>${network-modification.version}</version>
<version>0.2.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.powsybl</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

import jakarta.persistence.*;

import java.util.List;

/**
* @author Sylvain Bouzols <sylvain.bouzols at rte-france.com>
*/
Expand Down Expand Up @@ -66,20 +68,40 @@ public class BranchCreationEntity extends EquipmentCreationEntity {

@OneToOne(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY)
@JoinColumn(name = "current_limits_id1",
referencedColumnName = "id",
foreignKey = @ForeignKey(
name = "current_limits_id1_fk"
), nullable = true)
referencedColumnName = "id",
foreignKey = @ForeignKey(
name = "current_limits_id1_fk"
), nullable = true)
private CurrentLimitsEntity currentLimits1;

@OneToOne(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY)
@JoinColumn(name = "current_limits_id2",
referencedColumnName = "id",
foreignKey = @ForeignKey(
name = "current_limits_id2_fk"
), nullable = true)
referencedColumnName = "id",
foreignKey = @ForeignKey(
name = "current_limits_id2_fk"
), nullable = true)
private CurrentLimitsEntity currentLimits2;

@ElementCollection
@CollectionTable(
name = "currentLimits1",
joinColumns = @JoinColumn(name = "id", foreignKey = @ForeignKey(name = "current_limits1_fk_constraint"))
)
private List<CurrentLimitsEntity> allCurrentLimits1; // TODO : passerà currentLimits1

@ElementCollection
@CollectionTable(
name = "currentLimits2",
joinColumns = @JoinColumn(name = "id", foreignKey = @ForeignKey(name = "current_limits2_fk_constraint"))
)
private List<CurrentLimitsEntity> allCurrentLimits2; // TODO : passerà currentLimits2

@Column(name = "selectedOperationalLimitsGroupId1")
private String selectedOperationalLimitsGroupId1;

@Column(name = "selectedOperationalLimitsGroupId2")
private String selectedOperationalLimitsGroupId2;

protected BranchCreationEntity(BranchCreationInfos branchCreationInfos) {
super(branchCreationInfos);
assignAttributes(branchCreationInfos);
Expand All @@ -100,19 +122,21 @@ private void assignAttributes(BranchCreationInfos branchCreationInfos) {
busOrBusbarSectionId1 = branchCreationInfos.getBusOrBusbarSectionId1();
busOrBusbarSectionId2 = branchCreationInfos.getBusOrBusbarSectionId2();
if (branchCreationInfos.getCurrentLimits1() != null) {
currentLimits1 = new CurrentLimitsEntity(branchCreationInfos.getCurrentLimits1());
allCurrentLimits1 = CurrentLimitsEntity.toEmbeddableCurrentLimits(branchCreationInfos.getCurrentLimits1());
} else {
currentLimits1 = null;
}
if (branchCreationInfos.getCurrentLimits2() != null) {
currentLimits2 = new CurrentLimitsEntity(branchCreationInfos.getCurrentLimits2());
allCurrentLimits2 = CurrentLimitsEntity.toEmbeddableCurrentLimits(branchCreationInfos.getCurrentLimits2());
} else {
currentLimits2 = null;
}
connectionDirection1 = branchCreationInfos.getConnectionDirection1();
connectionName1 = branchCreationInfos.getConnectionName1();
connectionDirection2 = branchCreationInfos.getConnectionDirection2();
connectionName2 = branchCreationInfos.getConnectionName2();
selectedOperationalLimitsGroupId1 = branchCreationInfos.getSelectedOperationalLimitsGroupId1();
selectedOperationalLimitsGroupId2 = branchCreationInfos.getSelectedOperationalLimitsGroupId2();
connectionPosition1 = branchCreationInfos.getConnectionPosition1();
connectionPosition2 = branchCreationInfos.getConnectionPosition2();
connected1 = branchCreationInfos.isConnected1();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;

import jakarta.persistence.*;

Expand All @@ -25,7 +26,8 @@
@NoArgsConstructor
@AllArgsConstructor
@Entity
@Table(name = "currentLimits")
@Embeddable
@Table(name = "currentLimitsCreation")
public class CurrentLimitsEntity {

@Id
Expand All @@ -36,22 +38,40 @@ public class CurrentLimitsEntity {
@Column(name = "permanentLimit")
private Double permanentLimit;

@Column(name = "operationalLimitGroupId")
private String operationalLimitGroupId;

@ElementCollection
@CollectionTable(
name = "currentTemporaryLimits",
joinColumns = @JoinColumn(name = "id", foreignKey = @ForeignKey(name = "temporaryLimits_fk_constraint"))
)
private List<CurrentTemporaryLimitCreationEmbeddable> temporaryLimits;

public CurrentLimitsInfos toCurrentLimitsInfos() {
return CurrentLimitsInfos
.builder()
.permanentLimit(getPermanentLimit())
.temporaryLimits(CurrentTemporaryLimitCreationEmbeddable.fromEmbeddableCurrentTemporaryLimits(getTemporaryLimits()))
.build();
public static List<CurrentLimitsInfos> fromEmbeddableCurrentLimits(List<CurrentLimitsEntity> limits) {
return limits == null ? null :
limits.stream()
.map(limitEntity ->
CurrentLimitsInfos.builder()
.operationalLimitGroupId(limitEntity.getOperationalLimitGroupId())
.permanentLimit(limitEntity.getPermanentLimit())
.temporaryLimits(CurrentTemporaryLimitCreationEmbeddable.fromEmbeddableCurrentTemporaryLimits(limitEntity.getTemporaryLimits()))
.build()
)
.collect(Collectors.toList());
}

public CurrentLimitsEntity(CurrentLimitsInfos currentLimitsInfos) {
this(null, currentLimitsInfos.getPermanentLimit(), CurrentTemporaryLimitCreationEmbeddable.toEmbeddableCurrentTemporaryLimits(currentLimitsInfos.getTemporaryLimits()));
public static List<CurrentLimitsEntity> toEmbeddableCurrentLimits(List<CurrentLimitsInfos> limits) {
return limits == null ? null :
limits.stream()
.map(currentLimit ->
new CurrentLimitsEntity(
null,
currentLimit.getPermanentLimit(),
currentLimit.getOperationalLimitGroupId(),
CurrentTemporaryLimitCreationEmbeddable.toEmbeddableCurrentTemporaryLimits(currentLimit.getTemporaryLimits())
)
)
.collect(Collectors.toList());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ public LineCreationInfos toModificationInfos() {
.busOrBusbarSectionId2(getBusOrBusbarSectionId2())
.connectionName1(getConnectionName1())
.connectionName2(getConnectionName2())
.selectedOperationalLimitsGroupId1(getSelectedOperationalLimitsGroupId1())
.selectedOperationalLimitsGroupId2(getSelectedOperationalLimitsGroupId2())
.connectionDirection1(getConnectionDirection1())
.connectionDirection2(getConnectionDirection2())
.connectionPosition1(getConnectionPosition1())
Expand All @@ -97,10 +99,10 @@ public LineCreationInfos toModificationInfos() {
.toList());

if (getCurrentLimits1() != null) {
builder.currentLimits1(getCurrentLimits1().toCurrentLimitsInfos());
builder.currentLimits1(CurrentLimitsEntity.fromEmbeddableCurrentLimits(getAllCurrentLimits1()));
}
if (getCurrentLimits2() != null) {
builder.currentLimits2(getCurrentLimits2().toCurrentLimitsInfos());
builder.currentLimits2(CurrentLimitsEntity.fromEmbeddableCurrentLimits(getAllCurrentLimits2()));
}
return builder;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,8 @@ public TwoWindingsTransformerCreationInfos toModificationInfos() {
.busOrBusbarSectionId2(getBusOrBusbarSectionId2())
.connectionName1(getConnectionName1())
.connectionName2(getConnectionName2())
.selectedOperationalLimitsGroupId1(getSelectedOperationalLimitsGroupId1())
.selectedOperationalLimitsGroupId2(getSelectedOperationalLimitsGroupId2())
.connectionDirection1(getConnectionDirection1())
.connectionDirection2(getConnectionDirection2())
.connectionPosition1(getConnectionPosition1())
Expand All @@ -211,10 +213,10 @@ public TwoWindingsTransformerCreationInfos toModificationInfos() {
.toList());

if (getCurrentLimits1() != null) {
builder.currentLimits1(getCurrentLimits1().toCurrentLimitsInfos());
builder.currentLimits1(CurrentLimitsEntity.fromEmbeddableCurrentLimits(getAllCurrentLimits1()));
}
if (getCurrentLimits2() != null) {
builder.currentLimits2(getCurrentLimits2().toCurrentLimitsInfos());
builder.currentLimits2(CurrentLimitsEntity.fromEmbeddableCurrentLimits(getAllCurrentLimits2()));
}

if (!ratioTapChangerSteps.isEmpty()) {
Expand Down

0 comments on commit 6c6e608

Please sign in to comment.