Skip to content

Upgrade network-modification v0.71.0 + generate bbs ids suggestions#782

Merged
etiennehomer merged 17 commits intomainfrom
generate_bbs_ids_suggestions
Mar 16, 2026
Merged

Upgrade network-modification v0.71.0 + generate bbs ids suggestions#782
etiennehomer merged 17 commits intomainfrom
generate_bbs_ids_suggestions

Conversation

@etiennehomer
Copy link
Contributor

PR Summary

Add an endpoint that generate bbs ids with the configured naming strategy

Signed-off-by: Etienne Homer <etiennehomer@gmail.com>
@Parameter(description = "Voltage level id") @RequestParam("voltageLevelId") String voltageLevelId,
@Parameter(description = "Bus bar count") @RequestParam("busBarCount") Integer busBarCount,
@Parameter(description = "Section count") @RequestParam("sectionCount") Integer sectionCount,
@Parameter(description = "Switch kinds list") @RequestParam(name="switchKindList", defaultValue = "") Optional<List<SwitchKind>> switchKindList) {
Copy link
Contributor

@ghazwarhili ghazwarhili Mar 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional as @RequestParam ?
we can handle that wuth required = false + defaultValue

Signed-off-by: Etienne Homer <etiennehomer@gmail.com>
Signed-off-by: Etienne Homer <etiennehomer@gmail.com>
@Parameter(description = "Bus bar count") @RequestParam("busBarCount") Integer busBarCount,
@Parameter(description = "Section count") @RequestParam("sectionCount") Integer sectionCount,
@Parameter(description = "Switch kinds list") @RequestParam(name="switchKindList", defaultValue = "") Optional<List<SwitchKind>> switchKindList) {
return ResponseEntity.ok().contentType(MediaType.APPLICATION_JSON)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

already declared via produces = MediaType.APPLICATION_JSON_VALUE

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes done !

Signed-off-by: Etienne Homer <etiennehomer@gmail.com>
NamingStrategy namingStrategy = new NamingStrategiesServiceLoader().findNamingStrategyByName(modificationApplicator.getNamingStrategy()).orElse(new DefaultNamingStrategy());
for (int i = 1; i < busBarCount + 1; i++) {
for (int j = 1; j < sectionCount + 1; j++) {
bbsIds.add(namingStrategy.getBusbarId(voltageLevelId, switchKindList, i, j));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

switchKindList could be an empty string (defaultValue = "")
busBarCount and sectionCount are Integer => could be null, 0 or negative value

no validation before they are used in the loop => could throw NullPointerException

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The defaultValue = "" was wrong. I removed it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And I add @nonnull for other parameters

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we can add @positive also to avoid negative values ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And maybe have a maximum for busBarCount and sectionCount

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It returns an empty list for negative values. Maybe it's ok...


public List<String> getBusBarSectionsForNewCoupler(String voltageLevelId, Integer busBarCount, Integer sectionCount, List<SwitchKind> switchKindList) {
List<String> bbsIds = new ArrayList<>();
NamingStrategy namingStrategy = new NamingStrategiesServiceLoader().findNamingStrategyByName(modificationApplicator.getNamingStrategy()).orElse(new DefaultNamingStrategy());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be injected via constructor to avoid the instantation on every call !

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes done in NetworkModificationApplicator. It's cleaner

Signed-off-by: Etienne Homer <etiennehomer@gmail.com>
Signed-off-by: Etienne Homer <etiennehomer@gmail.com>
Signed-off-by: Etienne Homer <etiennehomer@gmail.com>
Signed-off-by: Etienne Homer <etiennehomer@gmail.com>
Signed-off-by: Etienne Homer <etiennehomer@gmail.com>
Signed-off-by: Etienne Homer <etiennehomer@gmail.com>
Signed-off-by: Etienne Homer <etiennehomer@gmail.com>
@etiennehomer etiennehomer changed the title Generate bbs ids suggestions Upgrade network-modification v0.71.0 + generate bbs ids suggestions Mar 16, 2026
Signed-off-by: Etienne Homer <etiennehomer@gmail.com>
Signed-off-by: Etienne Homer <etiennehomer@gmail.com>
Signed-off-by: Etienne Homer <etiennehomer@gmail.com>
Signed-off-by: Etienne Homer <etiennehomer@gmail.com>
@sonarqubecloud
Copy link

Copy link
Contributor

@ghazwarhili ghazwarhili left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code => OK

@etiennehomer etiennehomer merged commit d072d80 into main Mar 16, 2026
3 checks passed
@etiennehomer etiennehomer deleted the generate_bbs_ids_suggestions branch March 16, 2026 16:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants