Skip to content

Commit 5f524ca

Browse files
authored
Merge branch 'main' into addTagProperties
2 parents 4120648 + 4a640aa commit 5f524ca

21 files changed

+237
-56
lines changed

pom.xml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
<sonar.organization>gridsuite</sonar.organization>
5353
<sonar.projectKey>org.gridsuite:network-modification-server</sonar.projectKey>
5454
<!-- TODO network-modification.version remove when upgrading gridsuite dependencies -->
55-
<network-modification.version>0.39.0-SNAPSHOT</network-modification.version>
55+
<network-modification.version>0.41.0</network-modification.version>
5656
<powsybl-balances-adjustment.version>2.14.1</powsybl-balances-adjustment.version>
5757
</properties>
5858

@@ -207,11 +207,6 @@
207207
<artifactId>powsybl-open-loadflow</artifactId>
208208
<scope>runtime</scope>
209209
</dependency>
210-
<dependency>
211-
<groupId>com.powsybl</groupId>
212-
<artifactId>powsybl-config-classic</artifactId>
213-
<scope>runtime</scope>
214-
</dependency>
215210

216211
<!-- Test dependencies -->
217212
<dependency>

src/main/java/org/gridsuite/modification/server/elasticsearch/EquipmentInfosService.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
package org.gridsuite.modification.server.elasticsearch;
88

99
import com.google.common.collect.Lists;
10+
import com.google.common.collect.Sets;
1011
import com.powsybl.iidm.network.IdentifiableType;
1112
import org.gridsuite.modification.server.dto.elasticsearch.EquipmentInfos;
1213
import org.gridsuite.modification.server.dto.elasticsearch.TombstonedEquipmentInfos;
@@ -38,7 +39,7 @@ public class EquipmentInfosService {
3839
@Value("${spring.data.elasticsearch.partition-size-for-deletion:2048}")
3940
public int partitionSizeForDeletion;
4041

41-
private static final Set<IdentifiableType> TYPES_FOR_INDEXING = Set.of(
42+
private static final Set<IdentifiableType> TYPES_FOR_EQUIPMENT_INDEXING = Set.of(
4243
IdentifiableType.SUBSTATION,
4344
IdentifiableType.VOLTAGE_LEVEL,
4445
IdentifiableType.HVDC_LINE,
@@ -53,8 +54,16 @@ public class EquipmentInfosService {
5354
IdentifiableType.STATIC_VAR_COMPENSATOR,
5455
IdentifiableType.HVDC_CONVERTER_STATION);
5556

57+
private static final Set<IdentifiableType> TYPES_FOR_MODIFICATION_INDEXING = Sets.union(
58+
TYPES_FOR_EQUIPMENT_INDEXING,
59+
Set.of(IdentifiableType.SWITCH, IdentifiableType.BUSBAR_SECTION));
60+
5661
public static Set<IdentifiableType> getIndexedEquipmentTypes() {
57-
return TYPES_FOR_INDEXING;
62+
return TYPES_FOR_EQUIPMENT_INDEXING;
63+
}
64+
65+
public static Set<IdentifiableType> getIndexedEquipmentTypesInModification() {
66+
return TYPES_FOR_MODIFICATION_INDEXING;
5867
}
5968

6069
public EquipmentInfosService(EquipmentInfosRepository equipmentInfosRepository, TombstonedEquipmentInfosRepository tombstonedEquipmentInfosRepository) {

src/main/java/org/gridsuite/modification/server/entities/equipment/creation/BatteryCreationEntity.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,12 @@ public class BatteryCreationEntity extends InjectionCreationEntity {
6161
@Column(name = "droop")
6262
private Float droop;
6363

64+
@Column(name = "directTransX")
65+
private Double directTransX;
66+
67+
@Column(name = "stepUpTransformerX")
68+
private Double stepUpTransformerX;
69+
6470
public BatteryCreationEntity(@NonNull BatteryCreationInfos batteryCreationInfos) {
6571
super(batteryCreationInfos);
6672
assignAttributes(batteryCreationInfos);
@@ -83,6 +89,8 @@ private void assignAttributes(BatteryCreationInfos batteryCreationInfos) {
8389
this.targetQ = batteryCreationInfos.getTargetQ();
8490
this.participate = batteryCreationInfos.getParticipate();
8591
this.droop = batteryCreationInfos.getDroop();
92+
this.directTransX = batteryCreationInfos.getDirectTransX();
93+
this.stepUpTransformerX = batteryCreationInfos.getStepUpTransformerX();
8694
}
8795

8896
@Override
@@ -117,6 +125,8 @@ public BatteryCreationInfos toModificationInfos() {
117125
.targetQ(getTargetQ())
118126
.participate(getParticipate())
119127
.droop(getDroop())
128+
.directTransX(getDirectTransX())
129+
.stepUpTransformerX(getStepUpTransformerX())
120130
// properties
121131
.properties(CollectionUtils.isEmpty(getProperties()) ? null :
122132
getProperties().stream()

src/main/java/org/gridsuite/modification/server/entities/equipment/modification/BatteryModificationEntity.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,16 @@ public class BatteryModificationEntity extends InjectionModificationEntity {
6363
})
6464
private FloatModificationEmbedded droop;
6565

66+
@Embedded
67+
@AttributeOverrides(value = {@AttributeOverride(name = "value", column = @Column(name = "directTransX")), @AttributeOverride(name = "opType", column = @Column(name = "directTransxOp"))
68+
})
69+
private DoubleModificationEmbedded directTransX;
70+
71+
@Embedded
72+
@AttributeOverrides(value = {@AttributeOverride(name = "value", column = @Column(name = "stepUpTransformerX")), @AttributeOverride(name = "opType", column = @Column(name = "stepUpTransformerxOp"))
73+
})
74+
private DoubleModificationEmbedded stepUpTransformerX;
75+
6676
@Embedded
6777
@AttributeOverrides(value = {@AttributeOverride(name = "value", column = @Column(name = "minQ")), @AttributeOverride(name = "opType", column = @Column(name = "minqOp"))
6878
})
@@ -102,6 +112,8 @@ private void assignAttributes(BatteryModificationInfos batteryModificationInfos)
102112
this.maxQ = batteryModificationInfos.getMaxQ() != null ? new DoubleModificationEmbedded(batteryModificationInfos.getMaxQ()) : null;
103113
this.participate = batteryModificationInfos.getParticipate() != null ? new BooleanModificationEmbedded(batteryModificationInfos.getParticipate()) : null;
104114
this.droop = batteryModificationInfos.getDroop() != null ? new FloatModificationEmbedded(batteryModificationInfos.getDroop()) : null;
115+
this.directTransX = batteryModificationInfos.getDirectTransX() != null ? new DoubleModificationEmbedded(batteryModificationInfos.getDirectTransX()) : null;
116+
this.stepUpTransformerX = batteryModificationInfos.getStepUpTransformerX() != null ? new DoubleModificationEmbedded(batteryModificationInfos.getStepUpTransformerX()) : null;
105117
this.reactiveCapabilityCurve = batteryModificationInfos.getReactiveCapabilityCurve() != null ? new BooleanModificationEmbedded(batteryModificationInfos.getReactiveCapabilityCurve()) : null;
106118
this.reactiveCapabilityCurvePoints = toEmbeddablePoints(batteryModificationInfos.getReactiveCapabilityCurvePoints());
107119
}
@@ -134,6 +146,8 @@ public BatteryModificationInfos toModificationInfos() {
134146
.maxQ(toAttributeModification(getMaxQ()))
135147
.participate(toAttributeModification(getParticipate()))
136148
.droop(toAttributeModification(getDroop()))
149+
.directTransX(toAttributeModification(getDirectTransX()))
150+
.stepUpTransformerX(toAttributeModification(getStepUpTransformerX()))
137151
.reactiveCapabilityCurve(toAttributeModification(getReactiveCapabilityCurve()))
138152
.reactiveCapabilityCurvePoints(DTOUtils.toReactiveCapabilityCurvePointsModificationInfos(getReactiveCapabilityCurvePoints()))
139153
// properties

src/main/java/org/gridsuite/modification/server/entities/equipment/modification/BranchModificationEntity.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ public class BranchModificationEntity extends BasicEquipmentModificationEntity {
4747
@OrderColumn(name = "pos_operationalLimitsGroups")
4848
private List<OperationalLimitsGroupModificationEntity> operationalLimitsGroups;
4949

50+
@Column(name = "enable_olg_modification", columnDefinition = "boolean default true")
51+
private Boolean enableOLGModification;
52+
5053
@Embedded
5154
@AttributeOverrides(value = {
5255
@AttributeOverride(name = "value", column = @Column(name = "selectedOperationalLimitsGroupId1")),
@@ -217,6 +220,7 @@ private void assignAttributes(BranchModificationInfos branchModificationInfos) {
217220
x = new DoubleModificationEmbedded(branchModificationInfos.getX());
218221
r = new DoubleModificationEmbedded(branchModificationInfos.getR());
219222
this.operationalLimitsGroups = assignOperationalLimitsGroups(branchModificationInfos.getOperationalLimitsGroups(), operationalLimitsGroups);
223+
this.enableOLGModification = branchModificationInfos.getEnableOLGModification() == null || branchModificationInfos.getEnableOLGModification();
220224
this.voltageLevelId1 = branchModificationInfos.getVoltageLevelId1() != null ? new StringModificationEmbedded(branchModificationInfos.getVoltageLevelId1()) : null;
221225
this.voltageLevelId2 = branchModificationInfos.getVoltageLevelId2() != null ? new StringModificationEmbedded(branchModificationInfos.getVoltageLevelId2()) : null;
222226
this.busOrBusbarSectionId1 = branchModificationInfos.getBusOrBusbarSectionId1() != null ? new StringModificationEmbedded(branchModificationInfos.getBusOrBusbarSectionId1()) : null;

src/main/java/org/gridsuite/modification/server/entities/equipment/modification/LineModificationEntity.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ public LineModificationInfos toModificationInfos() {
9696
.connectionName2(toAttributeModification(getConnectionName2()))
9797
.selectedOperationalLimitsGroup1(toAttributeModification(getSelectedOperationalLimitsGroupId1()))
9898
.selectedOperationalLimitsGroup2(toAttributeModification(getSelectedOperationalLimitsGroupId2()))
99+
.enableOLGModification(getEnableOLGModification())
99100
.connectionDirection1(toAttributeModification(getConnectionDirection1()))
100101
.connectionDirection2(toAttributeModification(getConnectionDirection2()))
101102
.connectionPosition1(toAttributeModification(getConnectionPosition1()))

src/main/java/org/gridsuite/modification/server/entities/equipment/modification/TwoWindingsTransformerModificationEntity.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,7 @@ public TwoWindingsTransformerModificationInfos toModificationInfos() {
397397
.connectionName2(toAttributeModification(getConnectionName2()))
398398
.selectedOperationalLimitsGroup1(toAttributeModification(getSelectedOperationalLimitsGroupId1()))
399399
.selectedOperationalLimitsGroup2(toAttributeModification(getSelectedOperationalLimitsGroupId2()))
400+
.enableOLGModification(getEnableOLGModification())
400401
.connectionDirection1(toAttributeModification(getConnectionDirection1()))
401402
.connectionDirection2(toAttributeModification(getConnectionDirection2()))
402403
.connectionPosition1(toAttributeModification(getConnectionPosition1()))

src/main/java/org/gridsuite/modification/server/modifications/NetworkStoreListener.java

Lines changed: 37 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030
import static org.gridsuite.modification.NetworkModificationException.Type.MODIFICATION_ERROR;
3131
import static org.gridsuite.modification.server.elasticsearch.EquipmentInfosService.getIndexedEquipmentTypes;
32+
import static org.gridsuite.modification.server.elasticsearch.EquipmentInfosService.getIndexedEquipmentTypesInModification;
3233

3334
/**
3435
* @author Franck Lecuyer <franck.lecuyer at rte-france.com>
@@ -64,16 +65,12 @@ protected NetworkStoreListener(Network network, UUID networkUuid,
6465
this.collectionThreshold = collectionThreshold;
6566
}
6667

67-
private void updateImpactedEquipment(BasicEquipmentInfos impactedEquipment, SimpleImpactType impactType) {
68-
updateImpactedEquipment(impactedEquipment, impactType, true, true);
69-
}
70-
71-
private void updateImpactedEquipment(BasicEquipmentInfos impactedEquipment, SimpleImpactType impactType, boolean indexEquipment, boolean indexInModification) {
68+
private void updateImpactedEquipment(BasicEquipmentInfos impactedEquipment, SimpleImpactType impactType, boolean shouldIndexEquipment, boolean shouldIndexModification) {
7269
ImpactedEquipmentsInfos infosToUpdate = modificationApplicationInfosList.getLast().getImpactedEquipmentsInfos();
7370
switch (impactType) {
74-
case CREATION -> infosToUpdate.getCreatedEquipments().add(new IndexedImpactedEquipmentInfos<>((EquipmentInfos) impactedEquipment, indexEquipment, indexInModification));
75-
case MODIFICATION -> infosToUpdate.getModifiedEquipments().add(new IndexedImpactedEquipmentInfos<>((EquipmentInfos) impactedEquipment, indexEquipment, indexInModification));
76-
case DELETION -> infosToUpdate.getTombstonedEquipments().add(new IndexedImpactedEquipmentInfos<>((TombstonedEquipmentInfos) impactedEquipment, indexEquipment, indexInModification));
71+
case CREATION -> infosToUpdate.getCreatedEquipments().add(new IndexedImpactedEquipmentInfos<>((EquipmentInfos) impactedEquipment, shouldIndexEquipment, shouldIndexModification));
72+
case MODIFICATION -> infosToUpdate.getModifiedEquipments().add(new IndexedImpactedEquipmentInfos<>((EquipmentInfos) impactedEquipment, shouldIndexEquipment, shouldIndexModification));
73+
case DELETION -> infosToUpdate.getTombstonedEquipments().add(new IndexedImpactedEquipmentInfos<>((TombstonedEquipmentInfos) impactedEquipment, shouldIndexEquipment, shouldIndexModification));
7774
}
7875
}
7976

@@ -123,43 +120,51 @@ private void addSimpleModificationImpact(Identifiable<?> identifiable) {
123120
@Override
124121
public void onPropertyRemoved(Identifiable identifiable, String attribute, Object oldValue) {
125122
addSimpleModificationImpact(identifiable);
126-
if (getIndexedEquipmentTypes().contains(identifiable.getType())) {
127-
updateEquipmentIndexation(identifiable, attribute, networkUuid, network.getVariantManager().getWorkingVariantId());
128-
}
123+
updateEquipmentIndexation(identifiable, attribute, networkUuid, network.getVariantManager().getWorkingVariantId());
129124
}
130125

131126
@Override
132127
public void onPropertyAdded(Identifiable identifiable, String attribute, Object newValue) {
133128
addSimpleModificationImpact(identifiable);
134-
if (getIndexedEquipmentTypes().contains(identifiable.getType())) {
135-
updateEquipmentIndexation(identifiable, attribute, networkUuid, network.getVariantManager().getWorkingVariantId());
136-
}
129+
updateEquipmentIndexation(identifiable, attribute, networkUuid, network.getVariantManager().getWorkingVariantId());
137130
}
138131

139132
@Override
140133
public void onPropertyReplaced(Identifiable identifiable, String attribute, Object oldValue, Object newValue) {
141134
addSimpleModificationImpact(identifiable);
142-
if (getIndexedEquipmentTypes().contains(identifiable.getType())) {
135+
boolean shouldIndexEquipment = getIndexedEquipmentTypes().contains(identifiable.getType());
136+
boolean shouldIndexModification = getIndexedEquipmentTypesInModification().contains(identifiable.getType());
137+
if (shouldIndexEquipment || shouldIndexModification) {
143138
updateEquipmentIndexation(identifiable, attribute, networkUuid, network.getVariantManager().getWorkingVariantId());
144139
}
145140
}
146141

147142
@Override
148143
public void onUpdate(Identifiable identifiable, String attribute, String variantId, Object oldValue, Object newValue) {
149144
addSimpleModificationImpact(identifiable);
150-
if (getIndexedEquipmentTypes().contains(identifiable.getType())) {
145+
if (getIndexedEquipmentTypesInModification().contains(identifiable.getType())) {
151146
updateEquipmentIndexation(identifiable, attribute, networkUuid, network.getVariantManager().getWorkingVariantId());
152147
}
153148
}
154149

155150
private void updateEquipmentIndexation(Identifiable<?> identifiable, String attribute, UUID networkUuid, String variantId) {
156151
// Equipments should be indexed in equipment index only if equipment name has been updated
157-
boolean shouldIndexEquipments = attribute.equals("name");
158-
updateImpactedEquipment(toEquipmentInfos(identifiable, networkUuid, variantId), SimpleImpactType.MODIFICATION, shouldIndexEquipments, true);
152+
boolean shouldIndexEquipment = getIndexedEquipmentTypes().contains(identifiable.getType()) && "name".equals(attribute);
153+
boolean shouldIndexModification = getIndexedEquipmentTypesInModification().contains(identifiable.getType());
154+
155+
updateImpactedEquipment(
156+
toEquipmentInfos(identifiable, networkUuid, variantId),
157+
SimpleImpactType.MODIFICATION,
158+
shouldIndexEquipment,
159+
shouldIndexModification
160+
);
161+
159162
// If the updated attribute is "name" and the identifiable is a VOLTAGE_LEVEL or SUBSTATION,
160163
// we must update all linked equipment in equipment index to reflect the name change
161164
// modification index is not updated here
162-
if (shouldIndexEquipments && (identifiable.getType().equals(IdentifiableType.VOLTAGE_LEVEL) || identifiable.getType().equals(IdentifiableType.SUBSTATION))) {
165+
if (shouldIndexEquipment
166+
&& (identifiable.getType().equals(IdentifiableType.VOLTAGE_LEVEL)
167+
|| identifiable.getType().equals(IdentifiableType.SUBSTATION))) {
163168
updateLinkedEquipments(identifiable);
164169
}
165170
}
@@ -196,7 +201,9 @@ private void updateEquipmentsLinkedToVoltageLevel(VoltageLevel voltageLevel) {
196201

197202
@Override
198203
public void onCreation(Identifiable identifiable) {
199-
if (getIndexedEquipmentTypes().contains(identifiable.getType())) {
204+
boolean shouldIndexEquipment = getIndexedEquipmentTypes().contains(identifiable.getType());
205+
boolean shouldIndexModification = getIndexedEquipmentTypesInModification().contains(identifiable.getType());
206+
if (shouldIndexEquipment || shouldIndexModification) {
200207
updateImpactedEquipment(EquipmentInfos.builder()
201208
.networkUuid(networkUuid)
202209
.variantId(network.getVariantManager().getWorkingVariantId())
@@ -205,7 +212,7 @@ public void onCreation(Identifiable identifiable) {
205212
.type(EquipmentInfos.getEquipmentTypeName(identifiable))
206213
.voltageLevels(EquipmentInfos.getVoltageLevelsInfos(identifiable))
207214
.substations(EquipmentInfos.getSubstationsInfos(identifiable))
208-
.build(), SimpleImpactType.CREATION);
215+
.build(), SimpleImpactType.CREATION, shouldIndexEquipment, shouldIndexModification);
209216
}
210217
simpleImpacts.add(
211218
SimpleElementImpact.builder()
@@ -219,13 +226,14 @@ public void onCreation(Identifiable identifiable) {
219226

220227
@Override
221228
public void beforeRemoval(Identifiable identifiable) {
222-
if (getIndexedEquipmentTypes().contains(identifiable.getType())) {
223-
updateImpactedEquipment(TombstonedEquipmentInfos.builder()
229+
boolean shouldIndexEquipment = getIndexedEquipmentTypes().contains(identifiable.getType());
230+
boolean shouldIndexModification = getIndexedEquipmentTypesInModification().contains(identifiable.getType());
231+
updateImpactedEquipment(TombstonedEquipmentInfos.builder()
224232
.networkUuid(networkUuid)
225233
.variantId(network.getVariantManager().getWorkingVariantId())
226234
.id(identifiable.getId())
227-
.build(), SimpleImpactType.DELETION);
228-
}
235+
.build(), SimpleImpactType.DELETION, shouldIndexEquipment, shouldIndexModification);
236+
229237
simpleImpacts.add(
230238
SimpleElementImpact.builder()
231239
.simpleImpactType(SimpleImpactType.DELETION)
@@ -390,9 +398,10 @@ private List<EquipmentInfos> getAllModifiedEquipmentsToBeIndexed() {
390398
@Override
391399
public void onExtensionCreation(Extension<?> extension) {
392400
Identifiable<?> identifiable = (Identifiable<?>) extension.getExtendable();
393-
if (getIndexedEquipmentTypes().contains(identifiable.getType())) {
394-
updateImpactedEquipment(toEquipmentInfos(identifiable, networkUuid, network.getVariantManager().getWorkingVariantId()), SimpleImpactType.MODIFICATION);
395-
}
401+
boolean shouldIndexEquipment = getIndexedEquipmentTypes().contains(identifiable.getType());
402+
boolean shouldIndexModification = getIndexedEquipmentTypesInModification().contains(identifiable.getType());
403+
updateImpactedEquipment(toEquipmentInfos(identifiable, networkUuid, network.getVariantManager().getWorkingVariantId()), SimpleImpactType.MODIFICATION, shouldIndexEquipment, shouldIndexModification);
404+
396405
addSimpleModificationImpact(identifiable);
397406
}
398407

0 commit comments

Comments
 (0)