Skip to content

Commit

Permalink
update to powsybl-ws-dependencies 2.7.0
Browse files Browse the repository at this point in the history
Signed-off-by: BOUHOURS Antoine <[email protected]>
  • Loading branch information
antoinebhs committed Jan 30, 2024
1 parent f000d41 commit 34cb6c5
Show file tree
Hide file tree
Showing 10 changed files with 125 additions and 155 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<log4j2-mock-version>0.0.2</log4j2-mock-version>
<powsybl-ws-dependencies.version>2.6.0</powsybl-ws-dependencies.version>
<powsybl-ws-dependencies.version>2.7.0</powsybl-ws-dependencies.version>
<testcontainers.version>1.16.2</testcontainers.version>
</properties>

Expand Down Expand Up @@ -159,7 +159,7 @@
</dependency>
<dependency>
<groupId>com.powsybl</groupId>
<artifactId>powsybl-iidm-xml-converter</artifactId>
<artifactId>powsybl-iidm-serde</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/**
* Copyright (c) 2022, 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 com.powsybl.network.conversion.server;

import com.google.auto.service.AutoService;
import com.powsybl.commons.extensions.AbstractExtensionSerDe;
import com.powsybl.commons.extensions.ExtensionSerDe;
import com.powsybl.commons.io.DeserializerContext;
import com.powsybl.commons.io.SerializerContext;
import com.powsybl.commons.io.TreeDataReader;
import com.powsybl.iidm.network.Injection;
import com.powsybl.iidm.network.extensions.ActivePowerControl;
import com.powsybl.iidm.network.extensions.ActivePowerControlAdder;

/**
* @author Geoffroy Jamgotchian <geoffroy.jamgotchian at rte-france.com>
*/
@AutoService(ExtensionSerDe.class)
public class GeneratorActivePowerControlSerDe<T extends Injection<T>> extends AbstractExtensionSerDe<T, ActivePowerControl<T>> {

public GeneratorActivePowerControlSerDe() {
super("generatorActivePowerControl", "network", ActivePowerControl.class, "generatorActivePowerControl.xsd", "http://www.itesla_project.eu/schema/iidm/ext/generator_active_power_control/1_0", "gapc");
}

@Override
public void write(ActivePowerControl activePowerControl, SerializerContext serializerContext) {
throw new IllegalStateException("Should never be called");
}

@Override
public ActivePowerControl<T> read(T identifiable, DeserializerContext deserializerContext) {
TreeDataReader reader = deserializerContext.getReader();
boolean participate = reader.readBooleanAttribute("participate");
float droop = reader.readFloatAttribute("droop");
reader.readEndNode();
identifiable.newExtension(ActivePowerControlAdder.class)
.withParticipate(participate)
.withDroop(droop)
.add();
return identifiable.getExtension(ActivePowerControl.class);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/**
* Copyright (c) 2023, 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 com.powsybl.network.conversion.server;

import com.google.auto.service.AutoService;
import com.powsybl.commons.extensions.AbstractExtensionSerDe;
import com.powsybl.commons.extensions.ExtensionSerDe;
import com.powsybl.commons.io.DeserializerContext;
import com.powsybl.commons.io.SerializerContext;
import com.powsybl.commons.io.TreeDataReader;
import com.powsybl.iidm.network.Generator;
import com.powsybl.iidm.network.extensions.GeneratorShortCircuit;
import com.powsybl.iidm.network.extensions.GeneratorShortCircuitAdder;

/**
* @author Miora Vedelago <miora.ralambotiana at rte-france.com>
*/
@AutoService(ExtensionSerDe.class)
public class GeneratorShortCircuitsSerDe extends AbstractExtensionSerDe<Generator, GeneratorShortCircuit> {

public GeneratorShortCircuitsSerDe() {
super("generatorShortCircuits", "network", GeneratorShortCircuit.class, "generatorShortCircuits.xsd", "http://www.itesla_project.eu/schema/iidm/ext/generator_short_circuits/1_0",
"gsc");
}

@Override
public void write(GeneratorShortCircuit extension, SerializerContext serializerContext) {
throw new IllegalStateException("Should not happen");
}

@Override
public GeneratorShortCircuit read(Generator extendable, DeserializerContext deserializerContext) {
TreeDataReader reader = deserializerContext.getReader();
float transientReactance = reader.readFloatAttribute("transientReactance");
float stepUpTransformerReactance = reader.readFloatAttribute("stepUpTransformerReactance");
reader.readEndNode();
return extendable.newExtension(GeneratorShortCircuitAdder.class)
.withDirectTransX(transientReactance)
.withStepUpTransformerX(stepUpTransformerReactance)
.add();
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,7 @@
import com.powsybl.commons.reporter.ReporterModelJsonModule;
import com.powsybl.commons.xml.XmlUtil;
import com.powsybl.iidm.network.*;
import com.powsybl.network.conversion.server.dto.BoundaryInfos;
import com.powsybl.network.conversion.server.dto.CaseInfos;
import com.powsybl.network.conversion.server.dto.EquipmentInfos;
import com.powsybl.network.conversion.server.dto.ImportExportFormatMeta;
import com.powsybl.network.conversion.server.dto.ExportNetworkInfos;
import com.powsybl.network.conversion.server.dto.NetworkInfos;
import com.powsybl.network.conversion.server.dto.ParamMeta;
import com.powsybl.network.conversion.server.dto.*;
import com.powsybl.network.conversion.server.elasticsearch.EquipmentInfosService;
import com.powsybl.network.store.client.NetworkStoreService;
import com.powsybl.network.store.client.PreloadingStrategy;
Expand Down Expand Up @@ -164,7 +158,12 @@ Consumer<Message<UUID>> consumeCaseImportStart() {
String reportUuidStr = message.getHeaders().get(NotificationService.HEADER_REPORT_UUID, String.class);
UUID reportUuid = reportUuidStr != null ? UUID.fromString(reportUuidStr) : null;
String receiver = message.getHeaders().get(NotificationService.HEADER_RECEIVER, String.class);
Map<String, Object> changedImportParameters = (Map<String, Object>) message.getHeaders().get(NotificationService.HEADER_IMPORT_PARAMETERS);
Map<String, Object> rawParameters = (Map<String, Object>) message.getHeaders().get(NotificationService.HEADER_IMPORT_PARAMETERS);
// String longer than 1024 bytes are converted to com.rabbitmq.client.LongString (https://docs.spring.io/spring-amqp/docs/3.0.0/reference/html/#message-properties-converters)
Map<String, Object> changedImportParameters = new HashMap<>();
if (rawParameters != null) {
rawParameters.forEach((key, value) -> changedImportParameters.put(key, value.toString()));
}

CaseInfos caseInfos = getCaseInfos(caseUuid);
Map<String, String> allImportParameters = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,36 +7,38 @@
package com.powsybl.network.conversion.server;

import com.google.auto.service.AutoService;
import com.powsybl.commons.extensions.AbstractExtensionXmlSerializer;
import com.powsybl.commons.extensions.ExtensionXmlSerializer;
import com.powsybl.commons.xml.XmlReaderContext;
import com.powsybl.commons.xml.XmlUtil;
import com.powsybl.commons.xml.XmlWriterContext;
import com.powsybl.commons.extensions.AbstractExtensionSerDe;
import com.powsybl.commons.extensions.ExtensionSerDe;
import com.powsybl.commons.io.DeserializerContext;
import com.powsybl.commons.io.SerializerContext;
import com.powsybl.commons.io.TreeDataReader;
import com.powsybl.iidm.network.VoltageLevel;
import com.powsybl.iidm.network.extensions.IdentifiableShortCircuit;
import com.powsybl.iidm.network.extensions.IdentifiableShortCircuitAdder;

/**
* @author Miora Vedelago <miora.ralambotiana at rte-france.com>
*/
@AutoService(ExtensionXmlSerializer.class)
public class VoltageLevelShortCircuitsXmlSerializer extends AbstractExtensionXmlSerializer<VoltageLevel, IdentifiableShortCircuit<VoltageLevel>> {
@AutoService(ExtensionSerDe.class)
public class VoltageLevelShortCircuitsSerDe extends AbstractExtensionSerDe<VoltageLevel, IdentifiableShortCircuit<VoltageLevel>> {

public VoltageLevelShortCircuitsXmlSerializer() {
public VoltageLevelShortCircuitsSerDe() {
super("voltageLevelShortCircuits", "network", IdentifiableShortCircuit.class,
false, "voltageLevelShortCircuits.xsd", "http://www.itesla_project.eu/schema/iidm/ext/voltagelevel_short_circuits/1_0",
"voltageLevelShortCircuits.xsd", "http://www.itesla_project.eu/schema/iidm/ext/voltagelevel_short_circuits/1_0",
"vlsc");
}

@Override
public void write(IdentifiableShortCircuit<VoltageLevel> extension, XmlWriterContext context) {
public void write(IdentifiableShortCircuit<VoltageLevel> extension, SerializerContext serializerContext) {
throw new IllegalStateException("Should not happen");
}

@Override
public IdentifiableShortCircuit<VoltageLevel> read(VoltageLevel extendable, XmlReaderContext context) {
float minShortCircuitsCurrent = XmlUtil.readFloatAttribute(context.getReader(), "minShortCircuitsCurrent");
float maxShortCircuitsCurrent = XmlUtil.readFloatAttribute(context.getReader(), "maxShortCircuitsCurrent");
public IdentifiableShortCircuit<VoltageLevel> read(VoltageLevel extendable, DeserializerContext deserializerContext) {
TreeDataReader reader = deserializerContext.getReader();
float minShortCircuitsCurrent = reader.readFloatAttribute("minShortCircuitsCurrent");
float maxShortCircuitsCurrent = reader.readFloatAttribute("maxShortCircuitsCurrent");
reader.readEndNode();
return (IdentifiableShortCircuit<VoltageLevel>) extendable.newExtension(IdentifiableShortCircuitAdder.class)
.withIpMin(minShortCircuitsCurrent)
.withIpMax(maxShortCircuitsCurrent)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ public static Set<VoltageLevel> getVoltageLevels(@NonNull Identifiable<?> identi
} else if (identifiable instanceof ThreeWindingsTransformer) {
ThreeWindingsTransformer w3t = (ThreeWindingsTransformer) identifiable;
return Stream.of(
w3t.getTerminal(ThreeWindingsTransformer.Side.ONE).getVoltageLevel(),
w3t.getTerminal(ThreeWindingsTransformer.Side.TWO).getVoltageLevel(),
w3t.getTerminal(ThreeWindingsTransformer.Side.THREE).getVoltageLevel()
w3t.getTerminal(ThreeSides.ONE).getVoltageLevel(),
w3t.getTerminal(ThreeSides.TWO).getVoltageLevel(),
w3t.getTerminal(ThreeSides.THREE).getVoltageLevel()
).collect(Collectors.toSet());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import com.powsybl.commons.datasource.ResourceDataSource;
import com.powsybl.commons.datasource.ResourceSet;
import com.powsybl.iidm.network.*;
import com.powsybl.iidm.xml.XMLImporter;
import com.powsybl.iidm.serde.XMLImporter;
import com.powsybl.network.conversion.server.dto.EquipmentInfos;
import com.powsybl.network.conversion.server.dto.SubstationInfos;
import com.powsybl.network.conversion.server.dto.VoltageLevelInfos;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@
import com.powsybl.commons.reporter.Reporter;
import com.powsybl.commons.reporter.ReporterModel;
import com.powsybl.iidm.network.*;
import com.powsybl.iidm.xml.XMLImporter;
import com.powsybl.network.conversion.server.dto.*;
import com.powsybl.iidm.serde.XMLImporter;
import com.powsybl.network.conversion.server.dto.BoundaryInfos;
import com.powsybl.network.conversion.server.dto.CaseInfos;
import com.powsybl.network.conversion.server.dto.EquipmentInfos;
import com.powsybl.network.store.client.NetworkStoreService;
import com.powsybl.network.store.client.PreloadingStrategy;
import com.powsybl.network.store.iidm.impl.NetworkFactoryImpl;
Expand Down Expand Up @@ -54,9 +56,7 @@
import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.verify;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.head;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;

Expand Down

0 comments on commit 34cb6c5

Please sign in to comment.