Skip to content

Commit

Permalink
add position point to reactive capabilty diagram
Browse files Browse the repository at this point in the history
  • Loading branch information
ghazwarhili committed Nov 18, 2024
1 parent b859c67 commit ca05914
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 22 deletions.
19 changes: 12 additions & 7 deletions src/main/java/org/gridsuite/modification/server/dto/DTOUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
package org.gridsuite.modification.server.dto;

import org.gridsuite.modification.server.entities.equipment.modification.ReactiveCapabilityCurveModificationEmbeddable;
import org.springframework.util.CollectionUtils;

import java.util.Collections;
import java.util.List;
import java.util.Optional;

/**
* @author jamal kheyyad <jamal.kheyyad at rte-france.com>
Expand All @@ -19,11 +20,15 @@ private DTOUtils() {
}

public static List<ReactiveCapabilityCurveModificationInfos> convertToReactiveCapabilityCurveModificationInfos(List<ReactiveCapabilityCurveModificationEmbeddable> rCCpoints) {
return CollectionUtils.isEmpty(rCCpoints) ? null : rCCpoints
.stream()
.map(value -> new ReactiveCapabilityCurveModificationInfos(value.getMinQ(), value.getOldMinQ(),
value.getMaxQ(), value.getOldMaxQ(),
value.getP(), value.getOldP()))
.toList();
return Optional.ofNullable(rCCpoints)
.orElse(Collections.emptyList()).stream().map(value -> value == null
? new ReactiveCapabilityCurveModificationInfos(null, null, null, null, null, null)
: new ReactiveCapabilityCurveModificationInfos(
value.getMinQ(),
value.getOldMinQ(),
value.getMaxQ(),
value.getOldMaxQ(),
value.getP(),
value.getOldP())).toList();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,9 @@ public class BatteryModificationEntity extends InjectionModificationEntity {
})
private BooleanModificationEmbedded reactiveCapabilityCurve;

@ElementCollection
@ElementCollection(fetch = FetchType.EAGER)
@CollectionTable
@OrderColumn(name = "pos_point")
private List<ReactiveCapabilityCurveModificationEmbeddable> reactiveCapabilityCurvePoints;

public BatteryModificationEntity(@NonNull BatteryModificationInfos batteryModificationInfos) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,9 @@ public class ConverterStationModificationEntity extends InjectionModificationEnt
})
private DoubleModificationEmbedded voltageSetpoint;

@ElementCollection
@ElementCollection(fetch = FetchType.EAGER)
@CollectionTable(name = "converter_station_modification_rcc_points")
@OrderColumn(name = "pos_point")
private List<ReactiveCapabilityCurveModificationEmbeddable> reactiveCapabilityCurvePoints;

@Embedded
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,9 @@ public class GeneratorModificationEntity extends InjectionModificationEntity {
})
private BooleanModificationEmbedded reactiveCapabilityCurve;

@ElementCollection
@ElementCollection(fetch = FetchType.EAGER)
@CollectionTable
@OrderColumn(name = "pos_point")
private List<ReactiveCapabilityCurveModificationEmbeddable> reactiveCapabilityCurvePoints;

public GeneratorModificationEntity(@NonNull GeneratorModificationInfos generatorModificationInfos) {
Expand Down Expand Up @@ -257,13 +258,6 @@ public GeneratorModificationInfos toModificationInfos() {
}

private GeneratorModificationInfos.GeneratorModificationInfosBuilder<?, ?> toGeneratorModificationInfosBuilder() {
List<ReactiveCapabilityCurveModificationEmbeddable> pointsEmbeddable = !CollectionUtils.isEmpty(reactiveCapabilityCurvePoints) ? reactiveCapabilityCurvePoints : null;
List<ReactiveCapabilityCurveModificationInfos> points = pointsEmbeddable != null ? getReactiveCapabilityCurvePoints()
.stream()
.map(value -> new ReactiveCapabilityCurveModificationInfos(value.getMinQ(), value.getOldMinQ(),
value.getMaxQ(), value.getOldMaxQ(),
value.getP(), value.getOldP()))
.collect(Collectors.toList()) : null;
return GeneratorModificationInfos
.builder()
.uuid(getId())
Expand Down Expand Up @@ -302,7 +296,7 @@ public GeneratorModificationInfos toModificationInfos() {
.regulatingTerminalVlId(toAttributeModification(getRegulatingTerminalVlId()))
.qPercent(toAttributeModification(getQPercent()))
.reactiveCapabilityCurve(toAttributeModification(getReactiveCapabilityCurve()))
.reactiveCapabilityCurvePoints(points)
.reactiveCapabilityCurvePoints(DTOUtils.convertToReactiveCapabilityCurveModificationInfos(getReactiveCapabilityCurvePoints()))
// properties
.properties(CollectionUtils.isEmpty(getProperties()) ? null :
getProperties().stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@

package org.gridsuite.modification.server.entities.equipment.modification;

import jakarta.persistence.Column;
import jakarta.persistence.Embeddable;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

import jakarta.persistence.Column;
import jakarta.persistence.Embeddable;
import org.gridsuite.modification.server.dto.ReactiveCapabilityCurveModificationInfos;

/**
* @author Ayoub LABIDI <ayoub.labidi at rte-france.com>
Expand Down Expand Up @@ -40,4 +40,15 @@ public class ReactiveCapabilityCurveModificationEmbeddable {

@Column
private Double oldP;

public ReactiveCapabilityCurveModificationInfos toInfos() {
return ReactiveCapabilityCurveModificationInfos.builder()
.p(p)
.oldP(oldP)
.minQ(minQ)
.oldMinQ(oldMinQ)
.maxQ(maxQ)
.oldMaxQ(oldMaxQ)
.build();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?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="1731962383078-31">
<addColumn tableName="battery_modification_entity_reactive_capability_curve_points">
<column name="pos_point" type="integer">
<constraints nullable="false"/>
</column>
</addColumn>
</changeSet>
<changeSet author="rehiligha (generated)" id="1731962383078-32">
<addColumn tableName="converter_station_modification_rcc_points">
<column name="pos_point" type="integer">
<constraints nullable="false"/>
</column>
</addColumn>
</changeSet>
<changeSet author="rehiligha (generated)" id="1731962383078-33">
<addColumn tableName="generator_modification_entity_reactive_capability_curve_points">
<column name="pos_point" type="integer">
<constraints nullable="false"/>
</column>
</addColumn>
</changeSet>
<changeSet author="rehiligha (generated)" id="1731962383078-34">
<addPrimaryKey columnNames="battery_modification_entity_id, pos_point" constraintName="battery_modification_entity_reactive_capability_curve_pointsPK" tableName="battery_modification_entity_reactive_capability_curve_points"/>
</changeSet>
<changeSet author="rehiligha (generated)" id="1731962383078-35">
<addPrimaryKey columnNames="converter_station_modification_entity_id, pos_point" constraintName="converter_station_modification_rcc_pointsPK" tableName="converter_station_modification_rcc_points"/>
</changeSet>
<changeSet author="rehiligha (generated)" id="1731962383078-36">
<addPrimaryKey columnNames="generator_modification_entity_id, pos_point" constraintName="generator_modification_entity_reactive_capability_c_4905C1D9_PK" tableName="generator_modification_entity_reactive_capability_curve_points"/>
</changeSet>
</databaseChangeLog>
5 changes: 4 additions & 1 deletion src/main/resources/db/changelog/db.changelog-master.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -317,4 +317,7 @@ databaseChangeLog:
file: changesets/changelog_20240912T130742Z.xml
- include:
relativeToChangelogFile: true
file: changesets/changelog_20241015T130742Z.xml
file: changesets/changelog_20241015T130742Z.xml
- include:
relativeToChangelogFile: true
file: changesets/changelog_20241118T203926Z.xml

0 comments on commit ca05914

Please sign in to comment.