Skip to content

Commit

Permalink
enhance diagram PQ (#579)
Browse files Browse the repository at this point in the history
Signed-off-by: Rehili Ghazwa <[email protected]>
  • Loading branch information
ghazwarhili authored Dec 20, 2024
1 parent dae8009 commit 82bc06a
Show file tree
Hide file tree
Showing 29 changed files with 244 additions and 210 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
<mockwebserver3.version>5.0.0-alpha.14</mockwebserver3.version>
<liquibase-hibernate-package>org.gridsuite.modification.server</liquibase-hibernate-package>
<sonar.coverage.exclusions>**/migration/**/*</sonar.coverage.exclusions>
<network-modification.version>0.2.0</network-modification.version>
<network-modification.version>0.4.0</network-modification.version>
<!-- FIXME : Remove when gridsuite-dependencies.version are updated to include gridsuite-filter
version 1.0.16 or later -->
<filter.version>1.0.16</filter.version>
Expand Down
23 changes: 16 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 @@ -6,11 +6,13 @@
*/
package org.gridsuite.modification.server.dto;

import org.gridsuite.modification.dto.ReactiveCapabilityCurveModificationInfos;
import org.gridsuite.modification.dto.ReactiveCapabilityCurvePointsInfos;
import org.gridsuite.modification.server.entities.equipment.creation.ReactiveCapabilityCurveCreationEmbeddable;
import org.gridsuite.modification.server.entities.equipment.modification.ReactiveCapabilityCurveModificationEmbeddable;
import org.springframework.util.CollectionUtils;

import java.util.List;
import java.util.Objects;

/**
* @author jamal kheyyad <jamal.kheyyad at rte-france.com>
Expand All @@ -19,12 +21,19 @@ public final class DTOUtils {
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()))
public static List<ReactiveCapabilityCurvePointsInfos> toReactiveCapabilityCurvePointsCreationInfos(List<ReactiveCapabilityCurveCreationEmbeddable> rCCpoints) {
return Objects.isNull(rCCpoints) || CollectionUtils.isEmpty(rCCpoints) ? null
: rCCpoints.stream().map(point -> new ReactiveCapabilityCurvePointsInfos(point.getMinQ(),
point.getMaxQ(),
point.getP()))
.toList();
}

public static List<ReactiveCapabilityCurvePointsInfos> toReactiveCapabilityCurvePointsModificationInfos(List<ReactiveCapabilityCurveModificationEmbeddable> rCCpoints) {
return Objects.isNull(rCCpoints) || CollectionUtils.isEmpty(rCCpoints) ? null
: rCCpoints.stream().map(point -> new ReactiveCapabilityCurvePointsInfos(point.getMinQ(),
point.getMaxQ(),
point.getP()))
.toList();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@
*/
package org.gridsuite.modification.server.entities.equipment.creation;

import jakarta.persistence.*;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.NonNull;
import org.gridsuite.modification.dto.BatteryCreationInfos;
import org.gridsuite.modification.dto.ModificationInfos;
import org.gridsuite.modification.dto.ReactiveCapabilityCurveCreationInfos;

import jakarta.persistence.*;
import org.gridsuite.modification.server.dto.DTOUtils;
import org.gridsuite.modification.server.entities.equipment.modification.FreePropertyEntity;
import org.springframework.util.CollectionUtils;

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

import static org.gridsuite.modification.server.entities.equipment.creation.ReactiveCapabilityCurveCreationEmbeddable.toEmbeddablePoints;

/**
* @author Ghazwa Rehili <ghazwa.rehili at rte-france.com>
Expand Down Expand Up @@ -85,28 +85,12 @@ private void assignAttributes(BatteryCreationInfos batteryCreationInfos) {
this.droop = batteryCreationInfos.getDroop();
}

public static List<ReactiveCapabilityCurveCreationEmbeddable> toEmbeddablePoints(
List<ReactiveCapabilityCurveCreationInfos> points) {
return points == null ? null : points.stream()
.map(point -> new ReactiveCapabilityCurveCreationEmbeddable(point.getMinQ(),
point.getMaxQ(),
point.getP()))
.collect(Collectors.toList());
}

@Override
public BatteryCreationInfos toModificationInfos() {
return toBatteryCreationInfosBuilder().build();
}

private BatteryCreationInfos.BatteryCreationInfosBuilder<?, ?> toBatteryCreationInfosBuilder() {
List<ReactiveCapabilityCurveCreationInfos> points = getReactiveCapabilityCurvePoints() != null ? getReactiveCapabilityCurvePoints()
.stream()
.map(value -> new ReactiveCapabilityCurveCreationInfos(value.getMinQ(),
value.getMaxQ(),
value.getP()))
.collect(Collectors.toList()) : null;

return BatteryCreationInfos
.builder()
.uuid(getId())
Expand All @@ -128,7 +112,7 @@ public BatteryCreationInfos toModificationInfos() {
.reactiveCapabilityCurve(this.getReactiveCapabilityCurve())
.minQ(this.getMinQ())
.maxQ(this.getMaxQ())
.reactiveCapabilityCurvePoints(points)
.reactiveCapabilityCurvePoints(DTOUtils.toReactiveCapabilityCurvePointsCreationInfos(getReactiveCapabilityCurvePoints()))
.targetP(getTargetP())
.targetQ(getTargetQ())
.participate(getParticipate())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,17 @@

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

import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.gridsuite.modification.dto.ConverterStationCreationInfos;
import org.gridsuite.modification.dto.ReactiveCapabilityCurveCreationInfos;

import jakarta.persistence.CollectionTable;
import jakarta.persistence.Column;
import jakarta.persistence.ElementCollection;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import org.gridsuite.modification.server.dto.DTOUtils;

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

import static org.gridsuite.modification.server.entities.equipment.creation.ReactiveCapabilityCurveCreationEmbeddable.toEmbeddablePoints;

/**
* @author Seddik Yengui <seddik.yengui at rte-france.com>
Expand Down Expand Up @@ -101,31 +95,8 @@ public ConverterStationCreationInfos toConverterStationInfos() {
.reactivePowerSetpoint(getReactivePowerSetpoint())
.voltageRegulationOn(getVoltageRegulationOn())
.voltageSetpoint(getVoltageSetpoint())
.reactiveCapabilityCurvePoints(toReactiveCapabilityCurveInfos(getReactiveCapabilityCurvePoints()))
.reactiveCapabilityCurvePoints(DTOUtils.toReactiveCapabilityCurvePointsCreationInfos(getReactiveCapabilityCurvePoints()))
.reactiveCapabilityCurve(getReactiveCapabilityCurve())
.build();
}

private static List<ReactiveCapabilityCurveCreationEmbeddable> toEmbeddablePoints(
List<ReactiveCapabilityCurveCreationInfos> points) {
return points == null ? null : points.stream()
.map(point -> new ReactiveCapabilityCurveCreationEmbeddable(point.getMinQ(),
point.getMaxQ(),
point.getP()))
.collect(Collectors.toList());
}

private static List<ReactiveCapabilityCurveCreationInfos> toReactiveCapabilityCurveInfos(List<ReactiveCapabilityCurveCreationEmbeddable> pointsEmbeddable) {
if (pointsEmbeddable == null) {
return null;
}

return pointsEmbeddable.stream()
.map(pointEmbeddable -> ReactiveCapabilityCurveCreationInfos.builder()
.p(pointEmbeddable.getP())
.maxQ(pointEmbeddable.getMaxQ())
.minQ(pointEmbeddable.getMinQ())
.build())
.collect(Collectors.toList());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@
import lombok.NonNull;
import org.gridsuite.modification.dto.GeneratorCreationInfos;
import org.gridsuite.modification.dto.ModificationInfos;
import org.gridsuite.modification.dto.ReactiveCapabilityCurveCreationInfos;
import org.gridsuite.modification.server.dto.DTOUtils;
import org.gridsuite.modification.server.entities.equipment.modification.FreePropertyEntity;
import org.springframework.util.CollectionUtils;

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

import static org.gridsuite.modification.server.entities.equipment.creation.ReactiveCapabilityCurveCreationEmbeddable.toEmbeddablePoints;

/**
* @author Franck Lecuyer <franck.lecuyer at rte-france.com>
Expand Down Expand Up @@ -140,28 +141,12 @@ private void assignAttributes(GeneratorCreationInfos generatorCreationInfos) {
this.reactiveCapabilityCurve = generatorCreationInfos.getReactiveCapabilityCurve();
}

public static List<ReactiveCapabilityCurveCreationEmbeddable> toEmbeddablePoints(
List<ReactiveCapabilityCurveCreationInfos> points) {
return points == null ? null : points.stream()
.map(point -> new ReactiveCapabilityCurveCreationEmbeddable(point.getMinQ(),
point.getMaxQ(),
point.getP()))
.collect(Collectors.toList());
}

@Override
public GeneratorCreationInfos toModificationInfos() {
return toGeneratorCreationInfosBuilder().build();
}

private GeneratorCreationInfos.GeneratorCreationInfosBuilder<?, ?> toGeneratorCreationInfosBuilder() {
List<ReactiveCapabilityCurveCreationInfos> points = getReactiveCapabilityCurvePoints() != null ? getReactiveCapabilityCurvePoints()
.stream()
.map(value -> new ReactiveCapabilityCurveCreationInfos(value.getMinQ(),
value.getMaxQ(),
value.getP()))
.collect(Collectors.toList()) : null;

return GeneratorCreationInfos
.builder()
.uuid(getId())
Expand Down Expand Up @@ -194,7 +179,7 @@ public GeneratorCreationInfos toModificationInfos() {
.participate(getParticipate())
.droop(getDroop())
.maxQ(this.getMaxQ())
.reactiveCapabilityCurvePoints(points)
.reactiveCapabilityCurvePoints(DTOUtils.toReactiveCapabilityCurvePointsCreationInfos(getReactiveCapabilityCurvePoints()))
.regulatingTerminalId(getRegulatingTerminalId())
.regulatingTerminalType(getRegulatingTerminalType())
.regulatingTerminalVlId(getRegulatingTerminalVlId())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,16 @@

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

import jakarta.persistence.Column;
import jakarta.persistence.Embeddable;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.gridsuite.modification.dto.ReactiveCapabilityCurvePointsInfos;
import org.springframework.util.CollectionUtils;

import jakarta.persistence.Column;
import jakarta.persistence.Embeddable;
import java.util.List;
import java.util.Objects;

/**
* @author Seddik Yengui <seddik.yengui at rte-france.com>
Expand All @@ -31,4 +35,13 @@ public class ReactiveCapabilityCurveCreationEmbeddable {

@Column
private Double p;

public static List<ReactiveCapabilityCurveCreationEmbeddable> toEmbeddablePoints(
List<ReactiveCapabilityCurvePointsInfos> points) {
return Objects.isNull(points) || CollectionUtils.isEmpty(points) ? null
: points.stream()
.map(point -> new ReactiveCapabilityCurveCreationEmbeddable(point.getMinQ(),
point.getMaxQ(), point.getP()))
.toList();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,18 @@
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.NonNull;

import org.gridsuite.modification.dto.AttributeModification;
import org.gridsuite.modification.dto.BatteryModificationInfos;
import org.gridsuite.modification.dto.ModificationInfos;
import org.gridsuite.modification.dto.ReactiveCapabilityCurveModificationInfos;
import org.gridsuite.modification.server.dto.*;
import org.gridsuite.modification.server.dto.DTOUtils;
import org.gridsuite.modification.server.entities.equipment.modification.attribute.BooleanModificationEmbedded;
import org.gridsuite.modification.server.entities.equipment.modification.attribute.DoubleModificationEmbedded;
import org.gridsuite.modification.server.entities.equipment.modification.attribute.FloatModificationEmbedded;
import org.springframework.util.CollectionUtils;

import java.util.List;

import static org.gridsuite.modification.server.entities.equipment.modification.ReactiveCapabilityCurveModificationEmbeddable.toEmbeddablePoints;
import static org.gridsuite.modification.server.entities.equipment.modification.attribute.IAttributeModificationEmbeddable.toAttributeModification;

/**
Expand Down Expand Up @@ -107,16 +106,6 @@ private void assignAttributes(BatteryModificationInfos batteryModificationInfos)
this.reactiveCapabilityCurvePoints = toEmbeddablePoints(batteryModificationInfos.getReactiveCapabilityCurvePoints());
}

public static List<ReactiveCapabilityCurveModificationEmbeddable> toEmbeddablePoints(
List<ReactiveCapabilityCurveModificationInfos> points) {
return points == null ? null
: points.stream()
.map(point -> new ReactiveCapabilityCurveModificationEmbeddable(point.getMinQ(), point.getOldMinQ(),
point.getMaxQ(), point.getOldMaxQ(), point.getP(),
point.getOldP()))
.toList();
}

@Override
public BatteryModificationInfos toModificationInfos() {
return toBatteryModificationInfosBuilder().build();
Expand Down Expand Up @@ -146,7 +135,7 @@ public BatteryModificationInfos toModificationInfos() {
.participate(toAttributeModification(getParticipate()))
.droop(toAttributeModification(getDroop()))
.reactiveCapabilityCurve(toAttributeModification(getReactiveCapabilityCurve()))
.reactiveCapabilityCurvePoints(DTOUtils.convertToReactiveCapabilityCurveModificationInfos(getReactiveCapabilityCurvePoints()))
.reactiveCapabilityCurvePoints(DTOUtils.toReactiveCapabilityCurvePointsModificationInfos(getReactiveCapabilityCurvePoints()))
// properties
.properties(CollectionUtils.isEmpty(getProperties()) ? null :
getProperties().stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,17 @@
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.NonNull;
import org.gridsuite.modification.dto.*;
import org.gridsuite.modification.dto.AttributeModification;
import org.gridsuite.modification.dto.ConverterStationModificationInfos;
import org.gridsuite.modification.dto.ModificationInfos;
import org.gridsuite.modification.server.dto.DTOUtils;
import org.gridsuite.modification.server.entities.equipment.modification.attribute.BooleanModificationEmbedded;
import org.gridsuite.modification.server.entities.equipment.modification.attribute.DoubleModificationEmbedded;
import org.gridsuite.modification.server.entities.equipment.modification.attribute.FloatModificationEmbedded;

import java.util.List;

import static org.gridsuite.modification.server.entities.equipment.modification.ReactiveCapabilityCurveModificationEmbeddable.toEmbeddablePoints;
import static org.gridsuite.modification.server.entities.equipment.modification.attribute.IAttributeModificationEmbeddable.toAttributeModification;

/**
Expand Down Expand Up @@ -94,16 +97,6 @@ private void assignAttributes(ConverterStationModificationInfos converterStation

}

public static List<ReactiveCapabilityCurveModificationEmbeddable> toEmbeddablePoints(
List<ReactiveCapabilityCurveModificationInfos> points) {
return points == null ? null
: points.stream()
.map(point -> new ReactiveCapabilityCurveModificationEmbeddable(point.getMinQ(), point.getOldMinQ(),
point.getMaxQ(), point.getOldMaxQ(), point.getP(),
point.getOldP()))
.toList();
}

@Override
public ConverterStationModificationInfos toModificationInfos() {
return toConverterStationModificationInfoBuilder().build();
Expand All @@ -125,6 +118,6 @@ public ConverterStationModificationInfos toModificationInfos() {
.voltageRegulationOn(toAttributeModification(getVoltageRegulationOn()))
.voltageSetpoint(toAttributeModification(getVoltageSetpoint()))
.reactiveCapabilityCurve(toAttributeModification(getReactiveCapabilityCurve()))
.reactiveCapabilityCurvePoints(DTOUtils.convertToReactiveCapabilityCurveModificationInfos(getReactiveCapabilityCurvePoints()));
.reactiveCapabilityCurvePoints(DTOUtils.toReactiveCapabilityCurvePointsModificationInfos(getReactiveCapabilityCurvePoints()));
}
}
Loading

0 comments on commit 82bc06a

Please sign in to comment.