diff --git a/pom.xml b/pom.xml index abb9a0416..5841d52cf 100644 --- a/pom.xml +++ b/pom.xml @@ -116,7 +116,7 @@ org.gridsuite gridsuite-network-modification - ${network-modification.version} + 0.2.0-SNAPSHOT com.powsybl diff --git a/src/main/java/org/gridsuite/modification/server/entities/equipment/creation/BranchCreationEntity.java b/src/main/java/org/gridsuite/modification/server/entities/equipment/creation/BranchCreationEntity.java index a5219e036..7eae20839 100644 --- a/src/main/java/org/gridsuite/modification/server/entities/equipment/creation/BranchCreationEntity.java +++ b/src/main/java/org/gridsuite/modification/server/entities/equipment/creation/BranchCreationEntity.java @@ -14,6 +14,8 @@ import jakarta.persistence.*; +import java.util.List; + /** * @author Sylvain Bouzols */ @@ -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 allCurrentLimits1; // TODO : passerĂ  currentLimits1 + + @ElementCollection + @CollectionTable( + name = "currentLimits2", + joinColumns = @JoinColumn(name = "id", foreignKey = @ForeignKey(name = "current_limits2_fk_constraint")) + ) + private List allCurrentLimits2; // TODO : passerĂ  currentLimits2 + + @Column(name = "selectedOperationalLimitsGroupId1") + private String selectedOperationalLimitsGroupId1; + + @Column(name = "selectedOperationalLimitsGroupId2") + private String selectedOperationalLimitsGroupId2; + protected BranchCreationEntity(BranchCreationInfos branchCreationInfos) { super(branchCreationInfos); assignAttributes(branchCreationInfos); @@ -100,12 +122,12 @@ 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; } @@ -113,6 +135,8 @@ private void assignAttributes(BranchCreationInfos branchCreationInfos) { connectionName1 = branchCreationInfos.getConnectionName1(); connectionDirection2 = branchCreationInfos.getConnectionDirection2(); connectionName2 = branchCreationInfos.getConnectionName2(); + selectedOperationalLimitsGroupId1 = branchCreationInfos.getSelectedOperationalLimitsGroupId1(); + selectedOperationalLimitsGroupId2 = branchCreationInfos.getSelectedOperationalLimitsGroupId2(); connectionPosition1 = branchCreationInfos.getConnectionPosition1(); connectionPosition2 = branchCreationInfos.getConnectionPosition2(); connected1 = branchCreationInfos.isConnected1(); diff --git a/src/main/java/org/gridsuite/modification/server/entities/equipment/creation/CurrentLimitsEntity.java b/src/main/java/org/gridsuite/modification/server/entities/equipment/creation/CurrentLimitsEntity.java index 9cc000375..75375bfbc 100644 --- a/src/main/java/org/gridsuite/modification/server/entities/equipment/creation/CurrentLimitsEntity.java +++ b/src/main/java/org/gridsuite/modification/server/entities/equipment/creation/CurrentLimitsEntity.java @@ -14,6 +14,7 @@ import java.util.List; import java.util.UUID; +import java.util.stream.Collectors; import jakarta.persistence.*; @@ -25,7 +26,8 @@ @NoArgsConstructor @AllArgsConstructor @Entity -@Table(name = "currentLimits") +@Embeddable +@Table(name = "currentLimitsCreation") public class CurrentLimitsEntity { @Id @@ -36,6 +38,9 @@ public class CurrentLimitsEntity { @Column(name = "permanentLimit") private Double permanentLimit; + @Column(name = "operationalLimitGroupId") + private String operationalLimitGroupId; + @ElementCollection @CollectionTable( name = "currentTemporaryLimits", @@ -43,15 +48,30 @@ public class CurrentLimitsEntity { ) private List temporaryLimits; - public CurrentLimitsInfos toCurrentLimitsInfos() { - return CurrentLimitsInfos - .builder() - .permanentLimit(getPermanentLimit()) - .temporaryLimits(CurrentTemporaryLimitCreationEmbeddable.fromEmbeddableCurrentTemporaryLimits(getTemporaryLimits())) - .build(); + public static List fromEmbeddableCurrentLimits(List 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 toEmbeddableCurrentLimits(List limits) { + return limits == null ? null : + limits.stream() + .map(currentLimit -> + new CurrentLimitsEntity( + null, + currentLimit.getPermanentLimit(), + currentLimit.getOperationalLimitGroupId(), + CurrentTemporaryLimitCreationEmbeddable.toEmbeddableCurrentTemporaryLimits(currentLimit.getTemporaryLimits()) + ) + ) + .collect(Collectors.toList()); } } diff --git a/src/main/java/org/gridsuite/modification/server/entities/equipment/creation/LineCreationEntity.java b/src/main/java/org/gridsuite/modification/server/entities/equipment/creation/LineCreationEntity.java index 6680471ba..e709f1866 100644 --- a/src/main/java/org/gridsuite/modification/server/entities/equipment/creation/LineCreationEntity.java +++ b/src/main/java/org/gridsuite/modification/server/entities/equipment/creation/LineCreationEntity.java @@ -79,6 +79,8 @@ public LineCreationInfos toModificationInfos() { .busOrBusbarSectionId2(getBusOrBusbarSectionId2()) .connectionName1(getConnectionName1()) .connectionName2(getConnectionName2()) + .selectedOperationalLimitsGroupId1(getSelectedOperationalLimitsGroupId1()) + .selectedOperationalLimitsGroupId2(getSelectedOperationalLimitsGroupId2()) .connectionDirection1(getConnectionDirection1()) .connectionDirection2(getConnectionDirection2()) .connectionPosition1(getConnectionPosition1()) @@ -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; } diff --git a/src/main/java/org/gridsuite/modification/server/entities/equipment/creation/TwoWindingsTransformerCreationEntity.java b/src/main/java/org/gridsuite/modification/server/entities/equipment/creation/TwoWindingsTransformerCreationEntity.java index 92e14bc60..66c39a78c 100644 --- a/src/main/java/org/gridsuite/modification/server/entities/equipment/creation/TwoWindingsTransformerCreationEntity.java +++ b/src/main/java/org/gridsuite/modification/server/entities/equipment/creation/TwoWindingsTransformerCreationEntity.java @@ -192,6 +192,8 @@ public TwoWindingsTransformerCreationInfos toModificationInfos() { .busOrBusbarSectionId2(getBusOrBusbarSectionId2()) .connectionName1(getConnectionName1()) .connectionName2(getConnectionName2()) + .selectedOperationalLimitsGroupId1(getSelectedOperationalLimitsGroupId1()) + .selectedOperationalLimitsGroupId2(getSelectedOperationalLimitsGroupId2()) .connectionDirection1(getConnectionDirection1()) .connectionDirection2(getConnectionDirection2()) .connectionPosition1(getConnectionPosition1()) @@ -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()) {