diff --git a/pom.xml b/pom.xml
index 3e5f1edfb..9f4f01257 100644
--- a/pom.xml
+++ b/pom.xml
@@ -52,7 +52,7 @@
e -->
1.21.1
**/migration/**/*
- 0.5.0
+ 0.6.1
diff --git a/src/main/java/org/gridsuite/modification/server/entities/equipment/creation/VoltageLevelCreationEntity.java b/src/main/java/org/gridsuite/modification/server/entities/equipment/creation/VoltageLevelCreationEntity.java
index 06e1c06d4..0e510865f 100644
--- a/src/main/java/org/gridsuite/modification/server/entities/equipment/creation/VoltageLevelCreationEntity.java
+++ b/src/main/java/org/gridsuite/modification/server/entities/equipment/creation/VoltageLevelCreationEntity.java
@@ -6,21 +6,20 @@
*/
package org.gridsuite.modification.server.entities.equipment.creation;
+import com.powsybl.iidm.network.SwitchKind;
+import jakarta.persistence.*;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.NonNull;
import org.gridsuite.modification.dto.CouplingDeviceInfos;
import org.gridsuite.modification.dto.ModificationInfos;
import org.gridsuite.modification.dto.VoltageLevelCreationInfos;
-
-import com.powsybl.iidm.network.SwitchKind;
-
-import jakarta.persistence.*;
import org.gridsuite.modification.server.entities.equipment.modification.FreePropertyEntity;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.List;
+import java.util.Optional;
import java.util.stream.Collectors;
/**
@@ -65,6 +64,15 @@ public class VoltageLevelCreationEntity extends EquipmentCreationEntity {
@CollectionTable
private List couplingDevices;
+ @OneToOne(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY)
+ @JoinColumn(
+ name = "substation_creation_id",
+ referencedColumnName = "id",
+ foreignKey = @ForeignKey(
+ name = "voltageLevel_substationCreation_fk"
+ ))
+ private SubstationCreationEntity substationCreation;
+
public VoltageLevelCreationEntity(VoltageLevelCreationInfos voltageLevelCreationInfos) {
super(voltageLevelCreationInfos);
assignAttributes(voltageLevelCreationInfos);
@@ -88,6 +96,7 @@ public VoltageLevelCreationInfos toVoltageLevelCreationInfos() {
}
private VoltageLevelCreationInfos.VoltageLevelCreationInfosBuilder, ?> toVoltageLevelCreationInfosBuilder() {
+ SubstationCreationEntity substationCreationEntity = getSubstationCreation();
List couplingDeviceInfos = couplingDevices.stream()
.map(cde -> new CouplingDeviceInfos(cde.getBusbarSectionId1(), cde.getBusbarSectionId2()))
.collect(Collectors.toList());
@@ -109,6 +118,7 @@ public VoltageLevelCreationInfos toVoltageLevelCreationInfos() {
.sectionCount(getSectionCount())
.switchKinds(getSwitchKinds())
.couplingDevices(couplingDeviceInfos)
+ .substationCreation(substationCreationEntity != null ? substationCreationEntity.toSubstationCreationInfos() : null)
// properties
.properties(CollectionUtils.isEmpty(getProperties()) ? null :
getProperties().stream()
@@ -133,6 +143,9 @@ private void assignAttributes(VoltageLevelCreationInfos voltageLevelCreationInfo
this.sectionCount = voltageLevelCreationInfos.getSectionCount();
this.switchKinds = new ArrayList<>(voltageLevelCreationInfos.getSwitchKinds());
this.couplingDevices = toEmbeddableCouplingDevices(voltageLevelCreationInfos.getCouplingDevices());
+ this.substationCreation = Optional.ofNullable(voltageLevelCreationInfos.getSubstationCreation())
+ .map(SubstationCreationEntity::new)
+ .orElse(null);
}
}
diff --git a/src/main/resources/db/changelog/changesets/changelog_20241204T222759Z.xml b/src/main/resources/db/changelog/changesets/changelog_20241204T222759Z.xml
new file mode 100644
index 000000000..c245df334
--- /dev/null
+++ b/src/main/resources/db/changelog/changesets/changelog_20241204T222759Z.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/main/resources/db/changelog/db.changelog-master.yaml b/src/main/resources/db/changelog/db.changelog-master.yaml
index 7baf95ebb..67f4f50e2 100644
--- a/src/main/resources/db/changelog/db.changelog-master.yaml
+++ b/src/main/resources/db/changelog/db.changelog-master.yaml
@@ -329,4 +329,7 @@ databaseChangeLog:
relativeToChangelogFile: true
- include:
file: changesets/changelog_20250114T150006Z.xml
+ relativeToChangelogFile: true
+ - include:
+ file: changesets/changelog_20241204T222759Z.xml
relativeToChangelogFile: true
\ No newline at end of file