@@ -162,17 +162,12 @@ private List<Fault> getAllBusFaults(ShortCircuitRunContext context) {
162162
163163 private List <Fault > getBusFaultFromBusId (ShortCircuitRunContext context ) {
164164 String busId = context .getBusId ();
165- if (context .getParameters ().getSpecificParameters ().containsKey (NODE_CLUSTER )) {
166- List <String > nodeClusters = deserializeNodeClusters (context );
167- if (!nodeClusters .isEmpty () && !nodeClusters .contains (busId )) {
168- throw new ShortCircuitException (BUS_OUT_OF_NODE_CLUSTER , "Selected bus is out of node cluster" );
169- }
170- }
171165 Identifiable <?> identifiable = context .getNetwork ().getIdentifiable (busId );
172166 Map <String , ShortCircuitLimits > shortCircuitLimits = new HashMap <>();
173167
174168 if (identifiable instanceof BusbarSection busbarSection ) {
175169 Bus bus = busbarSection .getTerminal ().getBusView ().getBus ();
170+ throwIfBusIsOutsideNodeCluster (context , bus );
176171 if (bus == null ) {
177172 throw new ShortCircuitException (BUS_OUT_OF_VOLTAGE , "Selected bus is out of voltage" );
178173 }
@@ -185,6 +180,7 @@ private List<Fault> getBusFaultFromBusId(ShortCircuitRunContext context) {
185180 }
186181
187182 if (identifiable instanceof Bus bus ) {
183+ throwIfBusIsOutsideNodeCluster (context , bus );
188184 String busIdFromBusView = bus .getVoltageLevel ().getBusView ().getMergedBus (busId ).getId ();
189185 IdentifiableShortCircuit <VoltageLevel > shortCircuitExtension = bus .getVoltageLevel ().getBusView ().getMergedBus (busId ).getVoltageLevel ().getExtension (IdentifiableShortCircuit .class );
190186 if (shortCircuitExtension != null ) {
@@ -196,6 +192,15 @@ private List<Fault> getBusFaultFromBusId(ShortCircuitRunContext context) {
196192 throw new NoSuchElementException ("No bus found for bus id " + busId );
197193 }
198194
195+ private void throwIfBusIsOutsideNodeCluster (ShortCircuitRunContext context , Bus bus ) {
196+ if (context .getParameters ().getSpecificParameters ().containsKey (NODE_CLUSTER )) {
197+ List <String > nodeClusters = deserializeNodeClusters (context );
198+ if (!nodeClusters .isEmpty () && !nodeClusters .contains (bus .getId ())) {
199+ throw new ShortCircuitException (BUS_OUT_OF_NODE_CLUSTER , "Selected bus is outside node cluster" );
200+ }
201+ }
202+ }
203+
199204 protected String getComputationType () {
200205 return COMPUTATION_TYPE ;
201206 }
0 commit comments