Skip to content

Commit 5705a1c

Browse files
authored
allow to filter bus by substation properties (#106)
Signed-off-by: Etienne LESOT <etienne.lesot@rte-france.com>
1 parent 39a8102 commit 5705a1c

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/main/java/org/gridsuite/filter/utils/expertfilter/ExpertFilterUtils.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public static <I extends Identifiable<I>> String getFieldValue(FieldType field,
4949
case GENERATOR -> getGeneratorFieldValue(field, propertyName, (Generator) identifiable);
5050
case LOAD -> getLoadFieldValue(field, propertyName, (Load) identifiable);
5151
case SHUNT_COMPENSATOR -> getShuntCompensatorFieldValue(field, propertyName, (ShuntCompensator) identifiable);
52-
case BUS -> getBusFieldValue(field, (Bus) identifiable);
52+
case BUS -> getBusFieldValue(field, (Bus) identifiable, propertyName);
5353
case BUSBAR_SECTION -> getBusBarSectionFieldValue(field, (BusbarSection) identifiable);
5454
case BATTERY -> getBatteryFieldValue(field, propertyName, (Battery) identifiable);
5555
case SUBSTATION -> getSubstationFieldValue(field, (Substation) identifiable);
@@ -229,12 +229,13 @@ private static String getGeneratorStartupFieldValue(Generator generator, FieldTy
229229
}
230230
}
231231

232-
private static String getBusFieldValue(FieldType field, Bus bus) {
232+
private static String getBusFieldValue(FieldType field, Bus bus, String propertyName) {
233233
return switch (field) {
234234
case COUNTRY,
235235
NOMINAL_VOLTAGE,
236236
VOLTAGE_LEVEL_ID,
237-
SUBSTATION_ID -> getVoltageLevelFieldValue(field, null, bus.getVoltageLevel());
237+
SUBSTATION_ID,
238+
SUBSTATION_PROPERTIES -> getVoltageLevelFieldValue(field, propertyName, bus.getVoltageLevel());
238239
default -> throw new PowsyblException(FIELD_AND_TYPE_NOT_IMPLEMENTED + " [" + field + "," + bus.getType() + "]");
239240
};
240241
}

src/test/java/org/gridsuite/filter/globalfilter/GlobalFilterUtilsTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,8 @@ private static Stream<Arguments> substationPropertyFieldTypeData() {
286286
// Substation properties
287287
Arguments.of(EquipmentType.LINE, List.of(FieldType.SUBSTATION_PROPERTIES_1, FieldType.SUBSTATION_PROPERTIES_2)),
288288
Arguments.of(EquipmentType.GENERATOR, List.of(FieldType.SUBSTATION_PROPERTIES)),
289-
Arguments.of(EquipmentType.SUBSTATION, List.of(FieldType.FREE_PROPERTIES))
289+
Arguments.of(EquipmentType.SUBSTATION, List.of(FieldType.FREE_PROPERTIES)),
290+
Arguments.of(EquipmentType.BUS, List.of(FieldType.SUBSTATION_PROPERTIES))
290291
);
291292
}
292293

0 commit comments

Comments
 (0)