Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modification can now be disabled #528

Merged
merged 17 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ public ResponseEntity<Map<UUID, UUID>> duplicateModifications(@Parameter(descrip
return ResponseEntity.ok().body(networkModificationService.duplicateModifications(sourceModificationUuids));
}

@PutMapping(value = "/network-modifications", produces = MediaType.APPLICATION_JSON_VALUE)
@PutMapping(value = "/network-modifications", produces = MediaType.APPLICATION_JSON_VALUE, params = "stashed")
@Operation(summary = "stash or unstash network modifications")
@ApiResponse(responseCode = "200", description = "The network modifications were stashed")
public ResponseEntity<Void> stashNetworkModifications(
Expand All @@ -242,6 +242,16 @@ public ResponseEntity<Void> stashNetworkModifications(
return ResponseEntity.ok().build();
}

@PutMapping(value = "/network-modifications", produces = MediaType.APPLICATION_JSON_VALUE, params = "activated")
@Operation(summary = "activate or deactivate network modifications")
@ApiResponse(responseCode = "200", description = "The activation status related to the network modification was successfully updated")
public ResponseEntity<Void> updateNetworkModificationsActivationStatus(
@Parameter(description = "Network modification UUIDs") @RequestParam("uuids") List<UUID> networkModificationUuids,
@Parameter(description = "activate or deactivate network modifications") @RequestParam(name = "activated") Boolean activated) {
networkModificationService.updateNetworkModificationActivation(networkModificationUuids, activated);
return ResponseEntity.ok().build();
}

@PutMapping(value = "/groups/{groupUuid}/duplications", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "Duplicate all modifications in a group and append them at the end of another modifications group")
@ApiResponse(responseCode = "200", description = "The modifications have been duplicated")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,17 @@ public class ModificationInfos {
@Schema(description = "Message values")
private String messageValues;

@Schema(description = "Modification activated")
@Builder.Default
private Boolean activated = true;

// Only for metadata
public static ModificationInfos fromEntity(@NonNull ModificationEntity entity) {
ModificationInfos modificationInfos = ModificationInfos.builder()
.uuid(entity.getId())
.date(entity.getDate())
.stashed(entity.getStashed())
.activated(entity.getActivated())
.messageType(entity.getMessageType())
.messageValues(entity.getMessageValues())
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public CompositeModificationEntity(@NonNull CompositeModificationInfos composite
public CompositeModificationInfos toModificationInfos() {
List<ModificationInfos> modificationsInfos = modifications.stream().map(ModificationEntity::toModificationInfos).toList();
return CompositeModificationInfos.builder()
.activated(getActivated())
.date(getDate())
.uuid(getId())
.stashed(getStashed())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public GroovyScriptInfos toModificationInfos() {
.uuid(getId())
.date(getDate())
.stashed(getStashed())
.activated(getActivated())
.script(getScript());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,15 @@ public class ModificationEntity {
@Column(name = "message_values")
private String messageValues;

public ModificationEntity(UUID id, String type, Instant date, Boolean stashed, String messageType, String messageValues) {
@Column(name = "activated")
private Boolean activated = true;

public ModificationEntity(UUID id, String type, Instant date, Boolean stashed, Boolean activated, String messageType, String messageValues) {
this.id = id;
this.type = type;
this.date = date;
this.stashed = stashed;
this.activated = activated;
this.messageType = messageType;
this.messageValues = messageValues;
}
Expand All @@ -82,6 +86,7 @@ protected ModificationEntity(ModificationInfos modificationInfos) {
this.date = Instant.now().truncatedTo(ChronoUnit.MICROS);
// Do not put this stashed status in assignAttributes, it's not part of a network modification as such.
this.stashed = modificationInfos.getStashed();
this.activated = modificationInfos.getActivated();

assignAttributes(modificationInfos);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public TabularCreationInfos toModificationInfos() {
.date(getDate())
.uuid(getId())
.stashed(getStashed())
.activated(getActivated())
.creationType(creationType)
.creations(creationsInfos)
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public TabularModificationInfos toModificationInfos() {
.date(getDate())
.uuid(getId())
.stashed(getStashed())
.activated(getActivated())
.modificationType(modificationType)
.modifications(modificationsInfos)
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ public BatteryCreationInfos toModificationInfos() {
.uuid(getId())
.date(getDate())
.stashed(getStashed())
.activated(getActivated())
.equipmentId(getEquipmentId())
.equipmentName(getEquipmentName())
// injection
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ private void assignAttributes(ConverterStationCreationInfos converterStationCrea
public ConverterStationCreationInfos toConverterStationInfos() {
return ConverterStationCreationInfos.builder()
.stashed(getStashed())
.activated(getActivated())
.equipmentId(getEquipmentId())
.equipmentName(getEquipmentName())
// Injection
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ public GeneratorCreationInfos toModificationInfos() {
.uuid(getId())
.date(getDate())
.stashed(getStashed())
.activated(getActivated())
.equipmentId(getEquipmentId())
.equipmentName(getEquipmentName())
// injection
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public LineCreationInfos toModificationInfos() {
.uuid(getId())
.date(getDate())
.stashed(getStashed())
.activated(getActivated())
.equipmentId(getEquipmentId())
.equipmentName(getEquipmentName())
// branch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public LoadCreationInfos toModificationInfos() {
.uuid(getId())
.date(getDate())
.stashed(getStashed())
.activated(getActivated())
.equipmentId(getEquipmentId())
.equipmentName(getEquipmentName())
// injection
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ public ShuntCompensatorCreationInfos toModificationInfos() {
.uuid(getId())
.date(getDate())
.stashed(getStashed())
.activated(getActivated())
.equipmentId(getEquipmentId())
.equipmentName(getEquipmentName())
// Injection
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public SubstationCreationInfos toSubstationCreationInfos() {
.uuid(getId())
.date(getDate())
.stashed(getStashed())
.activated(getActivated())
.equipmentId(getEquipmentId())
.equipmentName(getEquipmentName())
.country(getCountry())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ public TwoWindingsTransformerCreationInfos toModificationInfos() {
.uuid(getId())
.date(getDate())
.stashed(getStashed())
.activated(getActivated())
.equipmentId(getEquipmentId())
.equipmentName(getEquipmentName())
// branch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ public VoltageLevelCreationInfos toVoltageLevelCreationInfos() {
.uuid(getId())
.date(getDate())
.stashed(getStashed())
.activated(getActivated())
.equipmentId(getEquipmentId())
.equipmentName(getEquipmentName())
.substationId(getSubstationId())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ public VscCreationInfos toModificationInfos() {
.uuid(getId())
.date(getDate())
.stashed(getStashed())
.activated(getActivated())
.equipmentId(getEquipmentId())
.equipmentName(getEquipmentName())
.activePowerSetpoint(getActivePowerSetpoint())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public ByFilterDeletionInfos toModificationInfos() {
.uuid(getId())
.date(getDate())
.stashed(getStashed())
.activated(getActivated())
.filters(getFilters().stream()
.map(filter -> new FilterInfos(filter.getFilterId(), filter.getName()))
.collect(Collectors.toList()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public EquipmentDeletionInfos toModificationInfos() {
.uuid(getId())
.date(getDate())
.stashed(getStashed())
.activated(getActivated())
.equipmentId(getEquipmentId())
.equipmentType(getEquipmentType());
if (equipmentInfos != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ public BatteryModificationInfos toModificationInfos() {
.uuid(getId())
.date(getDate())
.stashed(getStashed())
.activated(getActivated())
.equipmentId(getEquipmentId())
.equipmentName(AttributeModification.toAttributeModification(getEquipmentNameValue(), getEquipmentNameOp()))
.voltageLevelId(AttributeModification.toAttributeModification(getVoltageLevelIdValue(), getVoltageLevelIdOp()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public ByFormulaModificationInfos toModificationInfos() {
.uuid(getId())
.date(getDate())
.stashed(getStashed())
.activated(getActivated())
.identifiableType(getIdentifiableType())
.formulaInfosList(getFormulaEntities().stream()
.map(FormulaEntity::toFormulaInfos)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ public ConverterStationModificationInfos toModificationInfos() {
.uuid(getId())
.date(getDate())
.stashed(getStashed())
.activated(getActivated())
.equipmentId(getEquipmentId())
.equipmentName(AttributeModification.toAttributeModification(getEquipmentNameValue(), getEquipmentNameOp()))
.lossFactor(toAttributeModification(getLossFactor()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public DeleteAttachingLineInfos toModificationInfos() {
.uuid(getId())
.date(getDate())
.stashed(getStashed())
.activated(getActivated())
.lineToAttachTo1Id(getLineToAttachTo1Id())
.lineToAttachTo2Id(getLineToAttachTo2Id())
.attachedLineId(getAttachedLineId())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public DeleteVoltageLevelOnLineInfos toModificationInfos() {
.uuid(getId())
.date(getDate())
.stashed(getStashed())
.activated(getActivated())
.lineToAttachTo1Id(getLineToAttachTo1Id())
.lineToAttachTo2Id(getLineToAttachTo2Id())
.replacingLine1Id(getReplacingLine1Id())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ public GenerationDispatchInfos toModificationInfos() {
.date(getDate())
.uuid(getId())
.stashed(getStashed())
.activated(getActivated())
.lossCoefficient(getLossCoefficient())
.defaultOutageRate(getDefaultOutageRate())
.generatorsWithoutOutage(toGeneratorsFilters(generatorsWithoutOutage))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ public GeneratorModificationInfos toModificationInfos() {
.uuid(getId())
.date(getDate())
.stashed(getStashed())
.activated(getActivated())
.equipmentId(getEquipmentId())
.equipmentName(AttributeModification.toAttributeModification(getEquipmentNameValue(), getEquipmentNameOp()))
.voltageLevelId(AttributeModification.toAttributeModification(getVoltageLevelIdValue(), getVoltageLevelIdOp()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public GeneratorScalingInfos toModificationInfos() {
.date(getDate())
.uuid(getId())
.stashed(getStashed())
.activated(getActivated())
.variationType(getVariationType())
.variations(getVariations().stream()
.map(ScalingVariationEntity::toScalingVariationInfos)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ public LineAttachToVoltageLevelInfos toModificationInfos() {
.uuid(getId())
.date(getDate())
.stashed(getStashed())
.activated(getActivated())
.lineToAttachToId(getLineToAttachToId())
.percent(getPercent())
.attachmentPointId(getAttachmentPointId())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ public LineModificationInfos toModificationInfos() {
.uuid(getId())
.date(getDate())
.stashed(getStashed())
.activated(getActivated())
.equipmentId(getEquipmentId())
.equipmentName(AttributeModification.toAttributeModification(getEquipmentNameValue(), getEquipmentNameOp()))
.connected1(toAttributeModification(getConnected1()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ public LineSplitWithVoltageLevelInfos toModificationInfos() {
.uuid(getId())
.date(getDate())
.stashed(getStashed())
.activated(getActivated())
.lineToSplitId(getLineToSplitId())
.percent(getPercent())
.mayNewVoltageLevelInfos(mayVoltageLevelCreation == null ? null : mayVoltageLevelCreation.toVoltageLevelCreationInfos())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ private LinesAttachToSplitLinesInfos.LinesAttachToSplitLinesInfosBuilder toLines
.uuid(getId())
.date(getDate())
.stashed(getStashed())
.activated(getActivated())
.lineToAttachTo1Id(getLineToAttachTo1Id())
.lineToAttachTo2Id(getLineToAttachTo2Id())
.attachedLineId(getAttachedLineId())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public LoadModificationInfos toModificationInfos() {
.uuid(getId())
.date(getDate())
.stashed(getStashed())
.activated(getActivated())
.equipmentId(getEquipmentId())
.equipmentName(AttributeModification.toAttributeModification(getEquipmentNameValue(), getEquipmentNameOp()))
.voltageLevelId(AttributeModification.toAttributeModification(getVoltageLevelIdValue(), getVoltageLevelIdOp()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public LoadScalingInfos toModificationInfos() {
.uuid(getId())
.date(getDate())
.stashed(getStashed())
.activated(getActivated())
.variationType(getVariationType())
.variations(getVariations().stream()
.map(ScalingVariationEntity::toScalingVariationInfos)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public OperatingStatusModificationInfos toModificationInfos() {
.uuid(getId())
.date(getDate())
.stashed(getStashed())
.activated(getActivated())
.equipmentId(getEquipmentId())
.action(getAction())
.energizedVoltageLevelId(getEnergizedVoltageLevelId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ public ShuntCompensatorModificationInfos toModificationInfos() {
.uuid(getId())
.date(getDate())
.stashed(getStashed())
.activated(getActivated())
.equipmentId(getEquipmentId())
.equipmentName(toAttributeModification(getEquipmentNameValue(), getEquipmentNameOp()))
.voltageLevelId(AttributeModification.toAttributeModification(getVoltageLevelIdValue(), getVoltageLevelIdOp()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public SubstationModificationInfos toModificationInfos() {
.uuid(getId())
.date(getDate())
.stashed(getStashed())
.activated(getActivated())
.equipmentId(getEquipmentId())
.equipmentName(AttributeModification.toAttributeModification(getEquipmentNameValue(), getEquipmentNameOp()))
.country(AttributeModification.toAttributeModification(getCountry(), getCountryOp()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,7 @@ public TwoWindingsTransformerModificationInfos toModificationInfos() {
.uuid(getId())
.date(getDate())
.stashed(getStashed())
.activated(getActivated())
.equipmentId(getEquipmentId())
.equipmentName(AttributeModification.toAttributeModification(getEquipmentNameValue(), getEquipmentNameOp()))
.connected1(toAttributeModification(getConnected1()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ public VoltageInitModificationInfos toModificationInfos() {
.date(getDate())
.uuid(getId())
.stashed(getStashed())
.activated(getActivated())
.generators(toGeneratorsModification(generators))
.transformers(toTransformersModification(transformers))
.staticVarCompensators(toStaticVarCompensatorsModification(staticVarCompensators))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ public VoltageLevelModificationInfos toModificationInfos() {
.equipmentId(getEquipmentId())
.date(getDate())
.stashed(getStashed())
.activated(getActivated())
.equipmentName(toAttributeModification(getEquipmentNameValue(), getEquipmentNameOp()))
.nominalV(toAttributeModification(getNominalV()))
.lowVoltageLimit(toAttributeModification(getLowVoltageLimit()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ private void assignAttributes(@NonNull VscModificationInfos vscModificationInfos
.uuid(getId())
.date(getDate())
.stashed(getStashed())
.activated(getActivated())
.equipmentId(getEquipmentId())
.equipmentName(toAttributeModification(getEquipmentNameValue(), getEquipmentNameOp()))
.nominalV(toAttributeModification(getNominalV()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public EquipmentAttributeModificationInfos toModificationInfos() {
.uuid(getId())
.date(getDate())
.stashed(getStashed())
.activated(getActivated())
.equipmentId(getEquipmentId())
.equipmentAttributeName(getAttributeName())
.equipmentAttributeValue(getAttributeValue())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ private ApplicationStatus apply(List<ModificationInfos> modificationInfosList, N
reportNode = ReportNode.NO_OP;
}
ApplicationStatus groupApplicationStatus = modificationInfosList.stream()
.filter(ModificationInfos::getActivated)
.map(m -> apply(m, network, reportNode))
.reduce(ApplicationStatus::max)
.orElse(ApplicationStatus.ALL_OK);
Expand Down
Loading
Loading