Skip to content

Commit

Permalink
upgrade to gridsuite dependencies 36 and network modification 0.5.0 (#…
Browse files Browse the repository at this point in the history
…583)

* upgrade to gridsuite dependencies 36
* use new network-modification release 0.5.0

Signed-off-by: Franck LECUYER <[email protected]>
  • Loading branch information
FranckLecuyer authored Jan 15, 2025
1 parent 9f0c266 commit ebe56ce
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 36 deletions.
19 changes: 2 additions & 17 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,12 @@
</developers>

<properties>
<gridsuite-dependencies.version>35</gridsuite-dependencies.version>
<gridsuite-dependencies.version>36</gridsuite-dependencies.version>
<db-util.version>1.0.5</db-util.version>
<mockwebserver3.version>5.0.0-alpha.14</mockwebserver3.version>
<liquibase-hibernate-package>org.gridsuite.modification.server</liquibase-hibernate-package>
<sonar.coverage.exclusions>**/migration/**/*</sonar.coverage.exclusions>
<network-modification.version>0.4.0</network-modification.version>
<!-- FIXME : Remove when gridsuite-dependencies.version are updated to include gridsuite-filter
version 1.0.16 or later -->
<filter.version>1.0.16</filter.version>

<!-- FIXME: powsybl-ws-commons module's version is overloaded in the dependencies section.The overloads and this property below have to be removed at next powsybl-ws-commons.version upgrade -->
<powsybl-ws-commons.version>1.18.0</powsybl-ws-commons.version>
<network-modification.version>0.5.0</network-modification.version>
</properties>

<build>
Expand Down Expand Up @@ -98,13 +92,6 @@
<type>pom</type>
<scope>import</scope>
</dependency>
<!-- FIXME : Remove this dependency when gridsuite-dependencies.version are updated to include gridsuite-filter
version ${filter.version} below or later -->
<dependency>
<groupId>org.gridsuite</groupId>
<artifactId>gridsuite-filter</artifactId>
<version>${filter.version}</version>
</dependency>

<!-- imports -->
<dependency>
Expand Down Expand Up @@ -146,8 +133,6 @@
<dependency>
<groupId>com.powsybl</groupId>
<artifactId>powsybl-ws-commons</artifactId>
<!-- FIXME: to be removed at next powsybl-ws-dependencies upgrade -->
<version>${powsybl-ws-commons.version}</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,26 +104,20 @@ private void addSimpleModificationImpact(Identifiable<?> identifiable) {
}

@Override
public void onElementRemoved(Identifiable identifiable, String attribute, Object oldValue) {
public void onPropertyRemoved(Identifiable identifiable, String attribute, Object oldValue) {
addSimpleModificationImpact(identifiable);
}

@Override
public void onElementAdded(Identifiable identifiable, String attribute, Object newValue) {
public void onPropertyAdded(Identifiable identifiable, String attribute, Object newValue) {
addSimpleModificationImpact(identifiable);
}

@Override
public void onElementReplaced(Identifiable identifiable, String attribute, Object oldValue, Object newValue) {
public void onPropertyReplaced(Identifiable identifiable, String attribute, Object oldValue, Object newValue) {
addSimpleModificationImpact(identifiable);
}

@Override
public void onUpdate(Identifiable identifiable, String attribute, Object oldValue, Object newValue) {
addSimpleModificationImpact(identifiable);
updateEquipmentIndexation(identifiable, attribute, networkUuid, network.getVariantManager().getWorkingVariantId());
}

@Override
public void onUpdate(Identifiable identifiable, String attribute, String variantId, Object oldValue, Object newValue) {
addSimpleModificationImpact(identifiable);
Expand Down Expand Up @@ -337,8 +331,23 @@ public void onExtensionBeforeRemoval(Extension<?> extension) {
}

@Override
public void onExtensionUpdate(Extension<?> extendable, String attribute, Object oldValue, Object newValue) {
public void onExtensionUpdate(Extension<?> extendable, String attribute, String variantId, Object oldValue, Object newValue) {
Identifiable<?> identifiable = (Identifiable<?>) extendable.getExtendable();
onUpdate(identifiable, attribute, variantId, oldValue, newValue);
}

@Override
public void onVariantCreated(String sourceVariantId, String targetVariantId) {
// FIXME: implement this method
}

@Override
public void onVariantOverwritten(String sourceVariantId, String targetVariantId) {
// FIXME: implement this method
}

@Override
public void onVariantRemoved(String variantId) {
// FIXME: implement this method
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,6 @@ public void beforeRemoval(Identifiable identifiable) {
public void afterRemoval(String s) {
}

@Override
public void onUpdate(Identifiable identifiable, String attribute, Object oldValue, Object newValue) {
}

@Override
public void onVariantCreated(String sourceVariantId, String targetVariantId) {
// Initial variant modifications are not cloned
Expand All @@ -64,13 +60,18 @@ public void onVariantRemoved(String variantId) {
}

@Override
public void onUpdate(Identifiable<?> identifiable, String attribute, String variantId, Object oldValue,
Object newValue) {
public void onVariantOverwritten(String sourceVariantId, String targetVariantId) {
equipmentInfosService.deleteVariants(networkUuid, List.of(targetVariantId));
onVariantCreated(sourceVariantId, targetVariantId);
}

@Override
public void onUpdate(Identifiable<?> identifiable, String attribute, String variantId, Object oldValue, Object newValue) {
// do nothing
}

@Override
public void onExtensionCreation(Extension<?> extension) {
public void onExtensionBeforeRemoval(Extension<?> extension) {
// do nothing
}

Expand All @@ -80,13 +81,27 @@ public void onExtensionAfterRemoval(Identifiable<?> identifiable, String extensi
}

@Override
public void onExtensionBeforeRemoval(Extension<?> extension) {
public void onExtensionUpdate(Extension<?> extendable, String attribute, String variantId, Object oldValue, Object newValue) {
// do nothing
}

@Override
public void onExtensionUpdate(Extension<?> extendable, String attribute, Object oldValue, Object newValue) {
public void onExtensionCreation(Extension<?> extension) {
// do nothing
}

@Override
public void onPropertyAdded(Identifiable identifiable, String attribute, Object newValue) {
// do nothing
}

@Override
public void onPropertyReplaced(Identifiable identifiable, String attribute, Object oldValue, Object newValue) {
// do nothing
}

@Override
public void onPropertyRemoved(Identifiable identifiable, String attribute, Object oldValue) {
// do nothing
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* Copyright (c) 2024, RTE (http://www.rte-france.com)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package org.gridsuite.modification.server.service;

import org.gridsuite.modification.server.elasticsearch.EquipmentInfosService;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.elasticsearch.NoSuchIndexException;

import java.util.List;
import java.util.UUID;

import static org.junit.jupiter.api.Assertions.assertEquals;


/**
* @author Franck Lecuyer <franck.lecuyer at rte-france.com>
*/
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE)
class NetworkVariantsListenerTests {
private static final UUID NETWORK_UUID = UUID.randomUUID();
private static final String VARIANT_ID = "variant_1";

@Autowired
private EquipmentInfosService equipmentInfosService;

@AfterEach
void tearDown() {
try {
equipmentInfosService.deleteAll();
} catch (NoSuchIndexException ex) {
// no need to worry that much
}
}

@Test
void testVariantNotifications() {
NetworkVariantsListener listener = new NetworkVariantsListener(null, NETWORK_UUID, equipmentInfosService);

listener.onVariantRemoved(VARIANT_ID);
listener.onVariantCreated("variant_1", "variant_2");
assertEquals(0, equipmentInfosService.findEquipmentInfosList(List.of("equipment1", "equipment2"), NETWORK_UUID, "variant_2").size());
listener.onVariantOverwritten("variant_2", "variant_3");
listener.onUpdate(null, null, null, null, null);
listener.onExtensionUpdate(null, null, null, null, null);
listener.onPropertyAdded(null, null, null);
listener.onPropertyReplaced(null, null, null, null);
listener.onPropertyRemoved(null, null, null);
}
}

0 comments on commit ebe56ce

Please sign in to comment.