Skip to content

Commit

Permalink
Modification by filter (without formula data migration) (#526)
Browse files Browse the repository at this point in the history
Signed-off-by: Thang PHAM <[email protected]
  • Loading branch information
thangqp authored Oct 3, 2024
1 parent 6ab069a commit ffd24f7
Show file tree
Hide file tree
Showing 50 changed files with 3,580 additions and 657 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),
MODIFICATION_BY_ASSIGNMENT(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,6 +113,7 @@ 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),
MODIFICATION_BY_ASSIGNMENT_ERROR(HttpStatus.INTERNAL_SERVER_ERROR),
HVDC_LINE_NOT_FOUND(HttpStatus.NOT_FOUND),
COMPOSITE_MODIFICATION_ERROR(HttpStatus.INTERNAL_SERVER_ERROR),
WRONG_HVDC_ANGLE_DROOP_ACTIVE_POWER_CONTROL(HttpStatus.BAD_REQUEST);
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 Expand Up @@ -57,6 +57,6 @@ public ByFormulaModification toModification() {

@Override
public ReportNode createSubReportNode(ReportNode reportNode) {
return reportNode.newReportNode().withMessageTemplate(ModificationType.BY_FORMULA_MODIFICATION.name(), "By formula modification").add();
return reportNode.newReportNode().withMessageTemplate(ModificationType.BY_FORMULA_MODIFICATION.name(), "Modification by formula").add();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/**
* 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.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
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.assignment.AssignmentInfos;
import org.gridsuite.modification.server.entities.equipment.modification.byfilter.ModificationByAssignmentEntity;
import org.gridsuite.modification.server.modifications.byfilter.ModificationByAssignment;

import java.util.List;

/**
* @author Thang PHAM <quyet-thang.pham at rte-france.com>
*/
@SuperBuilder
@NoArgsConstructor
@Getter
@Setter
@JsonTypeName("MODIFICATION_BY_ASSIGNMENT")
@ModificationErrorTypeName("MODIFICATION_BY_ASSIGNMENT_ERROR")
@ToString(callSuper = true)
@Schema(description = "Modification by assignment")
public class ModificationByAssignmentInfos extends ModificationInfos {
@Schema(description = "Equipment type")
private IdentifiableType equipmentType;

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

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

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

@Override
public ReportNode createSubReportNode(ReportNode reportNode) {
return reportNode.newReportNode().withMessageTemplate(ModificationType.MODIFICATION_BY_ASSIGNMENT.name(), "Modification by filter").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 = ModificationByAssignmentInfos.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,42 @@
/**
* 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;

import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.SuperBuilder;
import org.gridsuite.modification.server.dto.FilterInfos;

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

/**
* @author Thang PHAM <quyet-thang.pham at rte-france.com>
*/
@SuperBuilder
@NoArgsConstructor
@Getter
@Setter
public abstract class AbstractAssignmentInfos {
@Schema(description = "id")
private UUID id;

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

@Schema(description = "Edited field")
private String editedField;

@JsonIgnore
public String getEditedFieldLabel() {
return editedField;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
* 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 {
ENUM,
BOOLEAN,
INTEGER,
DOUBLE,
PROPERTY
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/**
* 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.assignment;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.SuperBuilder;
import org.gridsuite.modification.server.dto.byfilter.AbstractAssignmentInfos;
import org.gridsuite.modification.server.dto.byfilter.DataType;
import org.gridsuite.modification.server.entities.equipment.modification.byfilter.assignment.AssignmentEntity;

/**
* @author Thang PHAM <quyet-thang.pham at rte-france.com>
*/
@JsonTypeInfo(
use = JsonTypeInfo.Id.NAME,
property = "dataType",
include = JsonTypeInfo.As.EXISTING_PROPERTY)
@JsonSubTypes({
@JsonSubTypes.Type(value = BooleanAssignmentInfos.class, name = "BOOLEAN"),
@JsonSubTypes.Type(value = EnumAssignmentInfos.class, name = "ENUM"),
@JsonSubTypes.Type(value = DoubleAssignmentInfos.class, name = "DOUBLE"),
@JsonSubTypes.Type(value = IntegerAssignmentInfos.class, name = "INTEGER"),
@JsonSubTypes.Type(value = PropertyAssignmentInfos.class, name = "PROPERTY"),
})
@JsonInclude(JsonInclude.Include.NON_NULL)
@SuperBuilder
@NoArgsConstructor
@Getter
@Setter
public class AssignmentInfos<T> extends AbstractAssignmentInfos {
@Schema(description = "Value")
private T value;

public DataType getDataType() {
throw new UnsupportedOperationException("This method should not be called");
}

@JsonIgnore
public AssignmentEntity toEntity() {
return new AssignmentEntity(this);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* 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.assignment;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import org.gridsuite.modification.server.dto.byfilter.DataType;

/**
* @author Thang PHAM <quyet-thang.pham at rte-france.com>
*/
@SuperBuilder
@NoArgsConstructor
public class BooleanAssignmentInfos extends AssignmentInfos<Boolean> {
@Override
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
public DataType getDataType() {
return DataType.BOOLEAN;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* 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.assignment;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import org.gridsuite.modification.server.dto.byfilter.DataType;

/**
* @author Thang PHAM <quyet-thang.pham at rte-france.com>
*/
@SuperBuilder
@NoArgsConstructor
public class DoubleAssignmentInfos extends AssignmentInfos<Double> {
@Override
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
public DataType getDataType() {
return DataType.DOUBLE;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* 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.assignment;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import org.gridsuite.modification.server.dto.byfilter.DataType;

/**
* @author Thang PHAM <quyet-thang.pham at rte-france.com>
*/
@SuperBuilder
@NoArgsConstructor
public class EnumAssignmentInfos extends AssignmentInfos<String> {
@Override
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
public DataType getDataType() {
return DataType.ENUM;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* 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.assignment;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import org.gridsuite.modification.server.dto.byfilter.DataType;

/**
* @author Thang PHAM <quyet-thang.pham at rte-france.com>
*/
@SuperBuilder
@NoArgsConstructor
public class IntegerAssignmentInfos extends AssignmentInfos<Integer> {
@Override
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
public DataType getDataType() {
return DataType.INTEGER;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/**
* 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.assignment;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import org.gridsuite.modification.server.dto.byfilter.DataType;
import org.gridsuite.modification.server.entities.equipment.modification.byfilter.assignment.AssignmentEntity;

/**
* @author Thang PHAM <quyet-thang.pham at rte-france.com>
*/
@SuperBuilder
@NoArgsConstructor
public class PropertyAssignmentInfos extends AssignmentInfos<String> {
@Schema(description = "Property name")
@Getter
private String propertyName;

@Override
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
public DataType getDataType() {
return DataType.PROPERTY;
}

@JsonIgnore
@Override
public String getEditedFieldLabel() {
return propertyName + " " + super.getEditedFieldLabel();
}

@Override
public AssignmentEntity toEntity() {
AssignmentEntity assignmentEntity = super.toEntity();
assignmentEntity.setPropertyName(propertyName);
return assignmentEntity;
}
}
Loading

0 comments on commit ffd24f7

Please sign in to comment.