Skip to content

Commit

Permalink
Merge branch 'main' into create-modification-without-applying
Browse files Browse the repository at this point in the history
  • Loading branch information
klesaulnier authored Jan 29, 2025
2 parents c399b15 + d53f6ce commit bc54c97
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
e -->
<powsybl-network-store.version>1.21.1</powsybl-network-store.version>
<sonar.coverage.exclusions>**/migration/**/*</sonar.coverage.exclusions>
<network-modification.version>0.5.0</network-modification.version>
<network-modification.version>0.6.1</network-modification.version>
</properties>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down Expand Up @@ -65,6 +64,15 @@ public class VoltageLevelCreationEntity extends EquipmentCreationEntity {
@CollectionTable
private List<CouplingDeviceCreationEmbeddable> 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);
Expand All @@ -88,6 +96,7 @@ public VoltageLevelCreationInfos toVoltageLevelCreationInfos() {
}

private VoltageLevelCreationInfos.VoltageLevelCreationInfosBuilder<?, ?> toVoltageLevelCreationInfosBuilder() {
SubstationCreationEntity substationCreationEntity = getSubstationCreation();
List<CouplingDeviceInfos> couplingDeviceInfos = couplingDevices.stream()
.map(cde -> new CouplingDeviceInfos(cde.getBusbarSectionId1(), cde.getBusbarSectionId2()))
.collect(Collectors.toList());
Expand All @@ -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()
Expand All @@ -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);
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" xmlns:pro="http://www.liquibase.org/xml/ns/pro" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd http://www.liquibase.org/xml/ns/pro http://www.liquibase.org/xml/ns/pro/liquibase-pro-latest.xsd http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd">
<changeSet author="rehiligha (generated)" id="1733351295028-31">
<addColumn tableName="voltage_level_creation_entity">
<column name="substation_creation_id" type="uuid"/>
</addColumn>
</changeSet>
<changeSet author="rehiligha (generated)" id="1733351295028-52">
<addForeignKeyConstraint baseColumnNames="substation_creation_id" baseTableName="voltage_level_creation_entity" constraintName="voltageLevel_substationCreation_fk" deferrable="false" initiallyDeferred="false" referencedColumnNames="id" referencedTableName="substation_creation" validate="true"/>
</changeSet>
</databaseChangeLog>
3 changes: 3 additions & 0 deletions src/main/resources/db/changelog/db.changelog-master.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -329,4 +329,7 @@ databaseChangeLog:
relativeToChangelogFile: true
- include:
file: changesets/changelog_20250114T150006Z.xml
relativeToChangelogFile: true
- include:
file: changesets/changelog_20241204T222759Z.xml
relativeToChangelogFile: true

0 comments on commit bc54c97

Please sign in to comment.