Skip to content

Commit

Permalink
Modification by filter
Browse files Browse the repository at this point in the history
  • Loading branch information
thangqp committed Aug 1, 2024
1 parent 107ace1 commit b949a9a
Show file tree
Hide file tree
Showing 44 changed files with 1,321 additions and 394 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public enum ModificationType {
TABULAR_MODIFICATION(PreloadingStrategy.COLLECTION),
TABULAR_CREATION(PreloadingStrategy.COLLECTION),
BY_FORMULA_MODIFICATION(PreloadingStrategy.COLLECTION),
BY_FILTER_MODIFICATION(PreloadingStrategy.COLLECTION),
COMPOSITE_MODIFICATION(PreloadingStrategy.COLLECTION);

private final PreloadingStrategy strategy;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,10 @@ public enum Type {
CREATE_CONVERTER_STATION_ERROR(HttpStatus.INTERNAL_SERVER_ERROR),
MODIFY_CONVERTER_STATION_ERROR(HttpStatus.INTERNAL_SERVER_ERROR),
BY_FORMULA_MODIFICATION_ERROR(HttpStatus.INTERNAL_SERVER_ERROR),
BY_FILTER_MODIFICATION_ERROR(HttpStatus.INTERNAL_SERVER_ERROR),
HVDC_LINE_NOT_FOUND(HttpStatus.NOT_FOUND),
COMPOSITE_MODIFICATION_ERROR(HttpStatus.INTERNAL_SERVER_ERROR);


public final HttpStatus status;
private final String message;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
import lombok.experimental.SuperBuilder;
import org.gridsuite.modification.server.ModificationType;
import org.gridsuite.modification.server.dto.annotation.ModificationErrorTypeName;
import org.gridsuite.modification.server.dto.formula.FormulaInfos;
import org.gridsuite.modification.server.entities.equipment.modification.ByFormulaModificationEntity;
import org.gridsuite.modification.server.modifications.ByFormulaModification;
import org.gridsuite.modification.server.dto.byfilter.formula.FormulaInfos;
import org.gridsuite.modification.server.entities.equipment.modification.byfilter.ByFormulaModificationEntity;
import org.gridsuite.modification.server.modifications.byfilter.ByFormulaModification;

import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/**
* Copyright (c) 2024, RTE (http://www.rte-france.com)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

package org.gridsuite.modification.server.dto;

import com.fasterxml.jackson.annotation.JsonTypeName;
import com.powsybl.commons.report.ReportNode;
import com.powsybl.iidm.network.IdentifiableType;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import lombok.experimental.SuperBuilder;
import org.gridsuite.modification.server.ModificationType;
import org.gridsuite.modification.server.dto.annotation.ModificationErrorTypeName;
import org.gridsuite.modification.server.dto.byfilter.simple.AbstractSimpleModificationInfos;
import org.gridsuite.modification.server.entities.equipment.modification.byfilter.BySimpleModificationEntity;
import org.gridsuite.modification.server.modifications.byfilter.BySimpleModification;

import java.util.List;

/**
* @author Thang PHAM <quyet-thang.pham at rte-france.com>
*/
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@Getter
@Setter
@JsonTypeName("BY_SIMPLE_MODIFICATION")
@ModificationErrorTypeName("BY_SIMPLE_MODIFICATION_ERROR")
@ToString(callSuper = true)
@Schema(description = "Modification by simple assignment")
public class BySimpleModificationInfos extends ModificationInfos {
@Schema(description = "Identifiable type")
private IdentifiableType identifiableType;

@Schema(description = "list of modifications")
private List<? extends AbstractSimpleModificationInfos<?>> simpleModificationInfosList;

@Override
public BySimpleModificationEntity toEntity() {
return new BySimpleModificationEntity(this);
}

@Override
public BySimpleModification toModification() {
return new BySimpleModification(this);
}

@Override
public ReportNode createSubReportNode(ReportNode reportNode) {
return reportNode.newReportNode().withMessageTemplate(ModificationType.BY_FILTER_MODIFICATION.name(), "By filter modification").add();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
@JsonSubTypes.Type(value = ConverterStationCreationInfos.class),
@JsonSubTypes.Type(value = TabularModificationInfos.class),
@JsonSubTypes.Type(value = ByFormulaModificationInfos.class),
@JsonSubTypes.Type(value = BySimpleModificationInfos.class),
@JsonSubTypes.Type(value = VscModificationInfos.class),
@JsonSubTypes.Type(value = ConverterStationModificationInfos.class),
@JsonSubTypes.Type(value = TabularCreationInfos.class),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/**
* Copyright (c) 2024, RTE (http://www.rte-france.com)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

package org.gridsuite.modification.server.dto.byfilter;

/**
* @author Thang PHAM <quyet-thang.pham at rte-france.com>
*/
public enum DataType {
STRING,
ENUM,
BOOLEAN,
INTEGER,
DOUBLE,
PROPERTY
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package org.gridsuite.modification.server.dto.byfilter;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import org.gridsuite.modification.server.dto.FilterInfos;

import java.util.List;
import java.util.UUID;

@SuperBuilder
@NoArgsConstructor
@Data
public class FilterModificationInfos {
@Schema(description = "id")
private UUID id;

@Schema(description = "List of filters")
private List<FilterInfos> filters;

@Schema(description = "Edited field")
private String editedField;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

package org.gridsuite.modification.server.dto.formula.equipmentfield;
package org.gridsuite.modification.server.dto.byfilter.equipmentfield;

import com.powsybl.iidm.network.Battery;
import com.powsybl.iidm.network.extensions.ActivePowerControl;
import com.powsybl.iidm.network.extensions.ActivePowerControlAdder;
import org.gridsuite.modification.server.dto.byfilter.simple.AbstractSimpleModificationInfos;

/**
* @author Seddik Yengui <Seddik.yengui at rte-france.com>
Expand Down Expand Up @@ -46,4 +47,10 @@ public static void setNewValue(Battery battery, String batteryField, Double newV
.add();
}
}

public static void setNewValue(Battery battery, AbstractSimpleModificationInfos<?> fieldModificationInfos) {
switch (fieldModificationInfos.getDataType()) {
case DOUBLE -> setNewValue(battery, fieldModificationInfos.getEditedField(), (Double) fieldModificationInfos.getValue());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,11 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

package org.gridsuite.modification.server.dto.formula.equipmentfield;
package org.gridsuite.modification.server.dto.byfilter.equipmentfield;

import com.powsybl.iidm.network.Generator;
import com.powsybl.iidm.network.extensions.ActivePowerControl;
import com.powsybl.iidm.network.extensions.ActivePowerControlAdder;
import com.powsybl.iidm.network.extensions.CoordinatedReactiveControl;
import com.powsybl.iidm.network.extensions.CoordinatedReactiveControlAdder;
import com.powsybl.iidm.network.extensions.GeneratorShortCircuit;
import com.powsybl.iidm.network.extensions.GeneratorShortCircuitAdder;
import com.powsybl.iidm.network.extensions.GeneratorStartup;
import com.powsybl.iidm.network.extensions.GeneratorStartupAdder;
import com.powsybl.iidm.network.extensions.*;
import org.gridsuite.modification.server.dto.byfilter.simple.AbstractSimpleModificationInfos;

/**
* @author Seddik Yengui <Seddik.yengui at rte-france.com>
Expand Down Expand Up @@ -146,4 +140,10 @@ public static void setNewValue(Generator generator, String generatorField, Doubl
}
}
}

public static void setNewValue(Generator generator, AbstractSimpleModificationInfos<?> fieldModificationInfos) {
switch (fieldModificationInfos.getDataType()) {
case DOUBLE -> setNewValue(generator, fieldModificationInfos.getEditedField(), (Double) fieldModificationInfos.getValue());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

package org.gridsuite.modification.server.dto.formula.equipmentfield;
package org.gridsuite.modification.server.dto.byfilter.equipmentfield;

import com.powsybl.iidm.network.Load;
import org.gridsuite.modification.server.dto.byfilter.simple.AbstractSimpleModificationInfos;

/**
* @author Seddik Yengui <Seddik.yengui at rte-france.com>
Expand All @@ -32,4 +33,10 @@ public static void setNewValue(Load load, String loadField, Double newValue) {
case REACTIVE_POWER -> load.setQ0(newValue);
}
}

public static void setNewValue(Load load, AbstractSimpleModificationInfos<?> fieldModificationInfos) {
switch (fieldModificationInfos.getDataType()) {
case DOUBLE -> setNewValue(load, fieldModificationInfos.getEditedField(), (Double) fieldModificationInfos.getValue());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

package org.gridsuite.modification.server.dto.formula.equipmentfield;
package org.gridsuite.modification.server.dto.byfilter.equipmentfield;

import com.powsybl.iidm.network.ShuntCompensator;
import com.powsybl.iidm.network.ShuntCompensatorLinearModel;
import com.powsybl.iidm.network.ShuntCompensatorModelType;
import com.powsybl.iidm.network.VoltageLevel;
import org.gridsuite.modification.server.NetworkModificationException;
import org.gridsuite.modification.server.dto.byfilter.simple.AbstractSimpleModificationInfos;

/**
* @author Seddik Yengui <Seddik.yengui at rte-france.com>
Expand Down Expand Up @@ -57,4 +58,10 @@ public static void setNewValue(ShuntCompensator shuntCompensator, String shuntCo
}
}
}

public static void setNewValue(ShuntCompensator shuntCompensator, AbstractSimpleModificationInfos<?> fieldModificationInfos) {
switch (fieldModificationInfos.getDataType()) {
case DOUBLE -> setNewValue(shuntCompensator, fieldModificationInfos.getEditedField(), (Double) fieldModificationInfos.getValue());
}
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package org.gridsuite.modification.server.dto.formula.equipmentfield;
package org.gridsuite.modification.server.dto.byfilter.equipmentfield;

import com.powsybl.iidm.network.PhaseTapChanger;
import com.powsybl.iidm.network.RatioTapChanger;
import com.powsybl.iidm.network.TwoWindingsTransformer;
import org.gridsuite.modification.server.dto.byfilter.simple.AbstractSimpleModificationInfos;

public enum TwoWindingsTransformerField {
R,
Expand Down Expand Up @@ -67,4 +68,10 @@ public static void setNewValue(TwoWindingsTransformer transformer, String twoWin
case PHASE_TARGET_DEADBAND -> phaseTapChanger.setTargetDeadband(newValue);
}
}

public static void setNewValue(TwoWindingsTransformer transformer, AbstractSimpleModificationInfos<?> fieldModificationInfos) {
switch (fieldModificationInfos.getDataType()) {
case DOUBLE -> setNewValue(transformer, fieldModificationInfos.getEditedField(), (Double) fieldModificationInfos.getValue());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

package org.gridsuite.modification.server.dto.formula.equipmentfield;
package org.gridsuite.modification.server.dto.byfilter.equipmentfield;

import com.powsybl.iidm.network.VoltageLevel;
import com.powsybl.iidm.network.extensions.IdentifiableShortCircuit;
import com.powsybl.iidm.network.extensions.IdentifiableShortCircuitAdder;
import org.gridsuite.modification.server.dto.byfilter.simple.AbstractSimpleModificationInfos;

/**
* @author Seddik Yengui <Seddik.yengui at rte-france.com>
Expand Down Expand Up @@ -57,4 +58,10 @@ public static void setNewValue(VoltageLevel voltageLevel, String voltageLevelFie
}
}
}

public static void setNewValue(VoltageLevel voltageLevel, AbstractSimpleModificationInfos<?> fieldModificationInfos) {
switch (fieldModificationInfos.getDataType()) {
case DOUBLE -> setNewValue(voltageLevel, fieldModificationInfos.getEditedField(), (Double) fieldModificationInfos.getValue());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,38 +5,23 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

package org.gridsuite.modification.server.dto.formula;
package org.gridsuite.modification.server.dto.byfilter.formula;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.SuperBuilder;
import org.gridsuite.modification.server.dto.FilterInfos;
import org.gridsuite.modification.server.entities.equipment.modification.FormulaEntity;

import java.util.List;
import java.util.UUID;
import org.gridsuite.modification.server.dto.byfilter.FilterModificationInfos;
import org.gridsuite.modification.server.entities.equipment.modification.byfilter.formula.FormulaEntity;

/**
* @author Seddik Yengui <Seddik.yengui at rte-france.com>
*/

@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@Getter
@Setter
public class FormulaInfos {
@Schema(description = "id")
private UUID id;

@Schema(description = "List of filters")
private List<FilterInfos> filters;

@Schema(description = "Edited field")
private String editedField;
@Data
public class FormulaInfos extends FilterModificationInfos {

@Schema(description = "First reference field or value")
private ReferenceFieldOrValue fieldOrValue1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

package org.gridsuite.modification.server.dto.formula;
package org.gridsuite.modification.server.dto.byfilter.formula;

/**
* @author Seddik Yengui <Seddik.yengui at rte-france.com>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

package org.gridsuite.modification.server.dto.formula;
package org.gridsuite.modification.server.dto.byfilter.formula;

import com.powsybl.iidm.network.Battery;
import com.powsybl.iidm.network.Generator;
Expand All @@ -21,12 +21,12 @@
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.gridsuite.modification.server.NetworkModificationException;
import org.gridsuite.modification.server.dto.formula.equipmentfield.BatteryField;
import org.gridsuite.modification.server.dto.formula.equipmentfield.GeneratorField;
import org.gridsuite.modification.server.dto.formula.equipmentfield.LoadField;
import org.gridsuite.modification.server.dto.formula.equipmentfield.ShuntCompensatorField;
import org.gridsuite.modification.server.dto.formula.equipmentfield.TwoWindingsTransformerField;
import org.gridsuite.modification.server.dto.formula.equipmentfield.VoltageLevelField;
import org.gridsuite.modification.server.dto.byfilter.equipmentfield.BatteryField;
import org.gridsuite.modification.server.dto.byfilter.equipmentfield.GeneratorField;
import org.gridsuite.modification.server.dto.byfilter.equipmentfield.LoadField;
import org.gridsuite.modification.server.dto.byfilter.equipmentfield.ShuntCompensatorField;
import org.gridsuite.modification.server.dto.byfilter.equipmentfield.TwoWindingsTransformerField;
import org.gridsuite.modification.server.dto.byfilter.equipmentfield.VoltageLevelField;


/**
Expand Down
Loading

0 comments on commit b949a9a

Please sign in to comment.