Skip to content

Commit

Permalink
revert to parseDouble
Browse files Browse the repository at this point in the history
  • Loading branch information
thangqp committed Oct 1, 2024
1 parent 76e7807 commit ef1ba44
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ public static void setNewValue(ShuntCompensator shuntCompensator, String shuntCo
shuntCompensatorType = ShuntCompensatorType.CAPACITOR;
}
switch (field) {
case MAXIMUM_SECTION_COUNT -> modifyMaximumSectionCount(new AttributeModification<>(Integer.parseInt(newValue), OperationType.SET),
case MAXIMUM_SECTION_COUNT -> modifyMaximumSectionCount(new AttributeModification<>((int) Double.parseDouble(newValue), OperationType.SET),
null, null, null, shuntCompensator, model);
case SECTION_COUNT -> modifySectionCount(new AttributeModification<>(Integer.parseInt(newValue), OperationType.SET), null, shuntCompensator);
case SECTION_COUNT -> modifySectionCount(new AttributeModification<>((int) Double.parseDouble(newValue), OperationType.SET), null, shuntCompensator);
case MAXIMUM_SUSCEPTANCE -> modifyMaxSusceptance(new AttributeModification<>(Double.parseDouble(newValue), OperationType.SET),
shuntCompensator.getMaximumSectionCount(), null, model);
case MAXIMUM_Q_AT_NOMINAL_VOLTAGE -> modifyMaximumQAtNominalVoltage(new AttributeModification<>(Double.parseDouble(newValue), OperationType.SET),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,16 @@ public static void setNewValue(TwoWindingsTransformer transformer, String twoWin
case RATED_S -> modifyRatedS(transformer, attributeModification, null);
case TARGET_V -> modifyTargets(ratioTapChanger, null, true, attributeModification, null, null);
case RATIO_LOW_TAP_POSITION -> processTapChangerPositionsAndSteps(ratioTapChanger, null, true,
new AttributeModification<>(Integer.parseInt(newValue), OperationType.SET), null, null, null);
new AttributeModification<>((int) Double.parseDouble(newValue), OperationType.SET), null, null, null);
case RATIO_TAP_POSITION -> processTapChangerPositionsAndSteps(ratioTapChanger, null, true,
null, new AttributeModification<>(Integer.parseInt(newValue), OperationType.SET), null, null);
null, new AttributeModification<>((int) Double.parseDouble(newValue), OperationType.SET), null, null);
case RATIO_TARGET_DEADBAND -> modifyTargets(ratioTapChanger, null, true, null, attributeModification, null);
case REGULATION_VALUE -> processPhaseTapRegulation(
phaseTapChanger, null, regulationMode, true, attributeModification, null, null);
case PHASE_LOW_TAP_POSITION -> processTapChangerPositionsAndSteps(phaseTapChanger, null, true,
new AttributeModification<>(Integer.parseInt(newValue), OperationType.SET), null, null, null);
new AttributeModification<>((int) Double.parseDouble(newValue), OperationType.SET), null, null, null);
case PHASE_TAP_POSITION -> processTapChangerPositionsAndSteps(phaseTapChanger, null, true,
null, new AttributeModification<>(Integer.parseInt(newValue), OperationType.SET), null, null);
null, new AttributeModification<>((int) Double.parseDouble(newValue), OperationType.SET), null, null);
case PHASE_TARGET_DEADBAND -> processPhaseTapRegulation(
phaseTapChanger, null, null, true, null, attributeModification, null
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.gridsuite.filter.utils.EquipmentType;
import org.gridsuite.modification.server.dto.byfilter.assignment.AssignmentInfos;
import org.gridsuite.modification.server.dto.byfilter.assignment.DoubleAssignmentInfos;
import org.gridsuite.modification.server.dto.byfilter.assignment.IntegerAssignmentInfos;
import org.gridsuite.modification.server.dto.byfilter.equipmentfield.ShuntCompensatorField;
import org.junit.Test;

Expand All @@ -41,9 +42,9 @@ public void testCreateWithWarning() throws Exception {
IdentifierListFilterEquipmentAttributes identifiableAttributes = getIdentifiableAttributes(SHUNT_COMPENSATOR_ID_1, 1.0);
IdentifierListFilterEquipmentAttributes wrongIdAttributes = getIdentifiableAttributes("wrongId", 1.0);

DoubleAssignmentInfos assignmentInfos = DoubleAssignmentInfos.builder()
IntegerAssignmentInfos assignmentInfos = IntegerAssignmentInfos.builder()
.editedField(ShuntCompensatorField.MAXIMUM_SECTION_COUNT.name())
.value(2.)
.value(2)
.filters(List.of(filterWithOneWrongId))
.build();

Expand Down Expand Up @@ -81,15 +82,15 @@ protected List<AbstractFilter> getTestFilters() {

@Override
protected List<AssignmentInfos<?>> getAssignmentInfos() {
DoubleAssignmentInfos assignmentInfos1 = DoubleAssignmentInfos.builder()
IntegerAssignmentInfos assignmentInfos1 = IntegerAssignmentInfos.builder()
.editedField(ShuntCompensatorField.MAXIMUM_SECTION_COUNT.name())
.value(8.)
.value(8)
.filters(List.of(filter1, filter2))
.build();

DoubleAssignmentInfos assignmentInfos2 = DoubleAssignmentInfos.builder()
IntegerAssignmentInfos assignmentInfos2 = IntegerAssignmentInfos.builder()
.editedField(ShuntCompensatorField.SECTION_COUNT.name())
.value(2.)
.value(2)
.filters(List.of(filter3))
.build();

Expand All @@ -113,15 +114,15 @@ protected List<AssignmentInfos<?>> getAssignmentInfos() {

@Override
protected List<AssignmentInfos<?>> getUpdatedAssignmentInfos() {
DoubleAssignmentInfos assignmentInfos1 = DoubleAssignmentInfos.builder()
IntegerAssignmentInfos assignmentInfos1 = IntegerAssignmentInfos.builder()
.editedField(ShuntCompensatorField.MAXIMUM_SECTION_COUNT.name())
.value(150.)
.value(150)
.filters(List.of(filter1, filter2))
.build();

DoubleAssignmentInfos assignmentInfos2 = DoubleAssignmentInfos.builder()
IntegerAssignmentInfos assignmentInfos2 = IntegerAssignmentInfos.builder()
.editedField(ShuntCompensatorField.SECTION_COUNT.name())
.value(2.)
.value(2)
.filters(List.of(filter3))
.build();
return List.of(assignmentInfos1, assignmentInfos2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.gridsuite.modification.server.dto.NetworkModificationResult;
import org.gridsuite.modification.server.dto.byfilter.assignment.AssignmentInfos;
import org.gridsuite.modification.server.dto.byfilter.assignment.DoubleAssignmentInfos;
import org.gridsuite.modification.server.dto.byfilter.assignment.IntegerAssignmentInfos;
import org.gridsuite.modification.server.dto.byfilter.equipmentfield.TwoWindingsTransformerField;
import org.junit.Test;

Expand Down Expand Up @@ -85,10 +86,10 @@ public void testModifyTwtWithWarning() throws Exception {
.withBody(mapper.writeValueAsString(List.of(filterTwt1, filterTwt2)))
.withHeader("Content-Type", "application/json"))).getId();

DoubleAssignmentInfos assignmentInfos = DoubleAssignmentInfos.builder()
IntegerAssignmentInfos assignmentInfos = IntegerAssignmentInfos.builder()
.filters(List.of(filter1, filter4))
.editedField(TwoWindingsTransformerField.RATIO_TAP_POSITION.name())
.value(4.)
.value(4)
.build();

checkCreationApplicationStatus(List.of(assignmentInfos), NetworkModificationResult.ApplicationStatus.WITH_WARNINGS);
Expand Down Expand Up @@ -191,16 +192,16 @@ protected List<AssignmentInfos<?>> getAssignmentInfos() {
.value(2.)
.build();

DoubleAssignmentInfos assignmentInfos2 = DoubleAssignmentInfos.builder()
IntegerAssignmentInfos assignmentInfos2 = IntegerAssignmentInfos.builder()
.filters(List.of(filter2))
.editedField(TwoWindingsTransformerField.RATIO_TAP_POSITION.name())
.value(4.)
.value(4)
.build();

DoubleAssignmentInfos assignmentInfos3 = DoubleAssignmentInfos.builder()
IntegerAssignmentInfos assignmentInfos3 = IntegerAssignmentInfos.builder()
.filters(List.of(filter2))
.editedField(TwoWindingsTransformerField.RATIO_LOW_TAP_POSITION.name())
.value(4.)
.value(4)
.build();

DoubleAssignmentInfos assignmentInfos4 = DoubleAssignmentInfos.builder()
Expand All @@ -215,16 +216,16 @@ protected List<AssignmentInfos<?>> getAssignmentInfos() {
.value(2.)
.build();

DoubleAssignmentInfos assignmentInfos6 = DoubleAssignmentInfos.builder()
IntegerAssignmentInfos assignmentInfos6 = IntegerAssignmentInfos.builder()
.filters(List.of(filter3))
.editedField(TwoWindingsTransformerField.PHASE_TAP_POSITION.name())
.value(2.)
.value(2)
.build();

DoubleAssignmentInfos assignmentInfos7 = DoubleAssignmentInfos.builder()
IntegerAssignmentInfos assignmentInfos7 = IntegerAssignmentInfos.builder()
.filters(List.of(filter3))
.editedField(TwoWindingsTransformerField.PHASE_LOW_TAP_POSITION.name())
.value(2.)
.value(2)
.build();

DoubleAssignmentInfos assignmentInfos8 = DoubleAssignmentInfos.builder()
Expand Down Expand Up @@ -302,16 +303,16 @@ protected List<AssignmentInfos<?>> getUpdatedAssignmentInfos() {
.value(2.)
.build();

DoubleAssignmentInfos assignmentInfos2 = DoubleAssignmentInfos.builder()
IntegerAssignmentInfos assignmentInfos2 = IntegerAssignmentInfos.builder()
.filters(List.of(filter2))
.editedField(TwoWindingsTransformerField.RATIO_TAP_POSITION.name())
.value(3.5)
.value(3)
.build();

DoubleAssignmentInfos assignmentInfos3 = DoubleAssignmentInfos.builder()
IntegerAssignmentInfos assignmentInfos3 = IntegerAssignmentInfos.builder()
.filters(List.of(filter1))
.editedField(TwoWindingsTransformerField.RATIO_LOW_TAP_POSITION.name())
.value(3.)
.value(3)
.build();

return List.of(assignmentInfos1,
Expand Down

0 comments on commit ef1ba44

Please sign in to comment.