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

upgrade to gridsuite dependencies 36 and network modification 0.5.0 #583

Merged
merged 6 commits into from
Jan 15, 2025
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
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);
}
}
Loading