Skip to content

Conversation

@EtienneLt
Copy link
Contributor

PR Summary

add voltage level info in line attached to voltage level to override fictious information of the voltage level created

@EtienneLt EtienneLt self-assigned this Nov 28, 2025
Signed-off-by: Etienne LESOT <[email protected]>
Signed-off-by: Etienne LESOT <[email protected]>
@Mathieu-Deharbe Mathieu-Deharbe self-requested a review November 28, 2025 16:11
Copy link
Contributor

@Mathieu-Deharbe Mathieu-Deharbe 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, test OK.
Only optional small remarks.

Comment on lines 100 to 128
// override voltage level
VoltageLevel voltageLevel = network.getVoltageLevel(modificationInfos.getAttachmentPointId());
if (modificationInfos.getAttachmentPointDetailInformation().getHighVoltageLimit() != null) {
voltageLevel.setHighVoltageLimit(modificationInfos.getAttachmentPointDetailInformation().getHighVoltageLimit());
}
if (modificationInfos.getAttachmentPointDetailInformation().getLowVoltageLimit() != null) {
voltageLevel.setLowVoltageLimit(modificationInfos.getAttachmentPointDetailInformation().getLowVoltageLimit());
}
if (modificationInfos.getAttachmentPointDetailInformation().getIpMax() != null || modificationInfos.getAttachmentPointDetailInformation().getIpMin() != null) {
IdentifiableShortCircuitAdder<VoltageLevel> adder = voltageLevel.newExtension(IdentifiableShortCircuitAdder.class);
if (modificationInfos.getAttachmentPointDetailInformation().getIpMax() != null) {
adder.withIpMax(modificationInfos.getAttachmentPointDetailInformation().getIpMax());
}
if (modificationInfos.getAttachmentPointDetailInformation().getIpMin() != null) {
adder.withIpMin(modificationInfos.getAttachmentPointDetailInformation().getIpMin());
}
adder.add();
}
PropertiesUtils.applyProperties(voltageLevel, modificationInfos.getAttachmentPointDetailInformation().getProperties());
// override substation
SubstationCreationInfos substationCreationInfos = modificationInfos.getAttachmentPointDetailInformation().getSubstationCreation();
final Substation substation = network.getSubstation(substationCreationInfos.getEquipmentId());
if (substationCreationInfos.getEquipmentName() != null) {
substation.setName(substationCreationInfos.getEquipmentName());
}
if (substationCreationInfos.getCountry() != null) {
substation.setCountry(substationCreationInfos.getCountry());
}
PropertiesUtils.applyProperties(substation, substationCreationInfos.getProperties());
Copy link
Contributor

Choose a reason for hiding this comment

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

All that part could be extracted to a function taking modificationInfos.getAttachmentPointDetailInformation() as a VoltageLevelCreationInfos parameter.
(I say this to please please sonar but technically this is a separate modification so it kind of make sense)

A bit like this :

private void updateAttachmentVoltageLevel(Network network, @NotNull VoltageLevelCreationInfos attachmentPointDetailInformation) {
        VoltageLevel voltageLevel = network.getVoltageLevel(modificationInfos.getAttachmentPointId());
        if (attachmentPointDetailInformation.getHighVoltageLimit() != null) {
            voltageLevel.setHighVoltageLimit(attachmentPointDetailInformation.getHighVoltageLimit());
        }
        if (attachmentPointDetailInformation.getLowVoltageLimit() != null) {
            voltageLevel.setLowVoltageLimit(attachmentPointDetailInformation.getLowVoltageLimit());
        }
        if (attachmentPointDetailInformation.getIpMax() != null || attachmentPointDetailInformation.getIpMin() != null) {
            IdentifiableShortCircuitAdder<VoltageLevel> adder = voltageLevel.newExtension(IdentifiableShortCircuitAdder.class);
            if (attachmentPointDetailInformation.getIpMax() != null) {
                adder.withIpMax(attachmentPointDetailInformation.getIpMax());
            }
            if (attachmentPointDetailInformation.getIpMin() != null) {
                adder.withIpMin(attachmentPointDetailInformation.getIpMin());
            }
            adder.add();
        }
        PropertiesUtils.applyProperties(voltageLevel, attachmentPointDetailInformation.getProperties());
        // override substation
        SubstationCreationInfos substationCreationInfos = attachmentPointDetailInformation.getSubstationCreation();
        final Substation substation = network.getSubstation(substationCreationInfos.getEquipmentId());
        if (substationCreationInfos.getEquipmentName() != null) {
            substation.setName(substationCreationInfos.getEquipmentName());
        }
        if (substationCreationInfos.getCountry() != null) {
            substation.setCountry(substationCreationInfos.getCountry());
        }
        PropertiesUtils.applyProperties(substation, substationCreationInfos.getProperties());
    }

You can even separate voltage level and substation creation in two functions.

Comment on lines 38 to 40
.substationCreation(SubstationCreationInfos.builder().stashed(false)
.equipmentId("attachmentPointSubstation")
.country(Country.FR)
Copy link
Contributor

Choose a reason for hiding this comment

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

This is the only data that you don't test :

Suggested change
.substationCreation(SubstationCreationInfos.builder().stashed(false)
.equipmentId("attachmentPointSubstation")
.country(Country.FR)
.substationCreation(SubstationCreationInfos.builder().stashed(false)
.equipmentId("attachmentPointSubstation")
.equipmentName("attachmentPointSubstationName")
.country(Country.FR)

@sonarqubecloud
Copy link

sonarqubecloud bot commented Dec 5, 2025

@EtienneLt EtienneLt merged commit 1106224 into main Dec 5, 2025
4 checks passed
@EtienneLt EtienneLt deleted the add-attachment-point-for-modification branch December 5, 2025 08:31
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.

3 participants