Skip to content

Commit

Permalink
Upgrade to powsybl dependencies 2024.2.0
Browse files Browse the repository at this point in the history
Signed-off-by: Franck LECUYER <[email protected]>
  • Loading branch information
FranckLecuyer committed Jul 22, 2024
1 parent cbef7e3 commit 94a9222
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 36 deletions.
10 changes: 4 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,10 @@
</developers>

<properties>
<gridsuite-dependencies.version>26</gridsuite-dependencies.version>
<gridsuite-dependencies.version>31</gridsuite-dependencies.version>
<commons-lang3.version>3.9</commons-lang3.version>
<liquibase-hibernate-package>org.gridsuite.merge.orchestrator.server</liquibase-hibernate-package>
<groovy.version>4.0.21</groovy.version>
</properties>

<build>
Expand Down Expand Up @@ -107,10 +108,6 @@
<groupId>com.powsybl</groupId>
<artifactId>powsybl-case-datasource-client</artifactId>
</dependency>
<dependency>
<groupId>com.powsybl</groupId>
<artifactId>powsybl-iidm-mergingview</artifactId>
</dependency>
<dependency>
<groupId>com.powsybl</groupId>
<artifactId>powsybl-network-store-client</artifactId>
Expand All @@ -137,8 +134,9 @@
<artifactId>spring-cloud-stream</artifactId>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<groupId>org.apache.groovy</groupId>
<artifactId>groovy</artifactId>
<version>${groovy.version}</version>
</dependency>
<dependency>
<groupId>com.powsybl</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@
package org.gridsuite.merge.orchestrator.server;

import com.fasterxml.jackson.databind.Module;
import com.powsybl.commons.reporter.ReporterModelJsonModule;
import com.powsybl.commons.report.ReportNodeJsonModule;
import com.powsybl.loadflow.json.LoadFlowResultJsonModule;
import com.powsybl.network.store.client.NetworkStoreService;
import com.powsybl.ws.commons.Utils;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
Expand All @@ -23,7 +22,6 @@
@SpringBootApplication(scanBasePackageClasses = { MergeOrchestratorApplication.class, NetworkStoreService.class })
public class MergeOrchestratorApplication {
public static void main(String[] args) {
Utils.initProperties();
SpringApplication.run(MergeOrchestratorApplication.class, args);
}

Expand All @@ -34,8 +32,8 @@ public Module createLoadFlowResultModule() {

@Bean
public Module createReporterModelModule() {
ReporterModelJsonModule reporterModelJsonModule = new ReporterModelJsonModule();
reporterModelJsonModule.setSerializers(null); // FIXME: remove when dicos will be used on the front side
return reporterModelJsonModule;
ReportNodeJsonModule reportNodeJsonModule = new ReportNodeJsonModule();
reportNodeJsonModule.setSerializers(null); // FIXME: remove when dicos will be used on the front side
return reportNodeJsonModule;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@

import com.fasterxml.jackson.databind.InjectableValues;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.powsybl.commons.reporter.ReporterModel;
import com.powsybl.commons.reporter.ReporterModelDeserializer;
import com.powsybl.commons.reporter.ReporterModelJsonModule;
import com.powsybl.commons.report.ReportNode;
import com.powsybl.commons.report.ReportNodeDeserializer;
import com.powsybl.commons.report.ReportNodeImpl;
import com.powsybl.commons.report.ReportNodeJsonModule;
import com.powsybl.network.store.client.NetworkStoreService;
import org.gridsuite.merge.orchestrator.server.dto.BoundaryInfo;
import org.gridsuite.merge.orchestrator.server.dto.ProcessConfig;
Expand Down Expand Up @@ -96,9 +97,9 @@ String getReportServerURI() {
private MappingJackson2HttpMessageConverter getJackson2HttpMessageConverter() {
MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter();
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.registerModule(new ReporterModelJsonModule());
objectMapper.registerModule(new ReportNodeJsonModule());
objectMapper.setInjectableValues(
new InjectableValues.Std().addValue(ReporterModelDeserializer.DICTIONARY_VALUE_ID, null));
new InjectableValues.Std().addValue(ReportNodeDeserializer.DICTIONARY_VALUE_ID, null));
converter.setObjectMapper(objectMapper);
return converter;
}
Expand Down Expand Up @@ -136,12 +137,12 @@ public void addConfig(ProcessConfig processConfig) {
processConfigRepository.save(entity);
}

public ReporterModel getReport(UUID report) {
public ReportNode getReport(UUID report) {
Objects.requireNonNull(report);
try {
UriComponentsBuilder uriBuilder = UriComponentsBuilder.fromPath("/{reportId}");
String uri = uriBuilder.build().toUriString();
return reportRestClient.exchange(uri, HttpMethod.GET, null, ReporterModel.class, report.toString())
return reportRestClient.exchange(uri, HttpMethod.GET, null, ReportNodeImpl.class, report.toString())
.getBody();
} catch (HttpClientErrorException e) {
throw (e.getStatusCode() == HttpStatus.NOT_FOUND)
Expand All @@ -157,7 +158,7 @@ public void deleteReport(UUID report) {
try {
UriComponentsBuilder uriBuilder = UriComponentsBuilder.fromPath("/{reportId}");
String uri = uriBuilder.build().toUriString();
reportRestClient.exchange(uri, HttpMethod.DELETE, null, ReporterModel.class, report.toString());
reportRestClient.exchange(uri, HttpMethod.DELETE, null, ReportNode.class, report.toString());
} catch (HttpClientErrorException e) {
throw (e.getStatusCode() == HttpStatus.NOT_FOUND)
? new MergeOrchestratorException(MERGE_REPORT_NOT_FOUND, e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/
package org.gridsuite.merge.orchestrator.server;

import com.powsybl.commons.reporter.ReporterModel;
import com.powsybl.commons.report.ReportNode;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
Expand Down Expand Up @@ -105,8 +105,8 @@ public ResponseEntity<Map<String, IgmReplacingInfo>> replaceIGMs(@Parameter(desc
@GetMapping(value = "{processUuid}/{date}/report", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "Get merge report")
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The report for process"), @ApiResponse(responseCode = "404", description = "The process not found")})
public ResponseEntity<ReporterModel> getReport(@Parameter(description = "Process uuid") @PathVariable("processUuid") UUID processUuid,
@Parameter(description = "Process date") @PathVariable("date") String date) {
public ResponseEntity<ReportNode> getReport(@Parameter(description = "Process uuid") @PathVariable("processUuid") UUID processUuid,
@Parameter(description = "Process date") @PathVariable("date") String date) {
LOGGER.debug("Get report for merge process {} : {}", processUuid, date);
String decodedDate = URLDecoder.decode(date, StandardCharsets.UTF_8);
LocalDateTime dateTime = LocalDateTime.ofInstant(ZonedDateTime.parse(decodedDate).toInstant(), ZoneOffset.UTC);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
package org.gridsuite.merge.orchestrator.server;

import com.powsybl.commons.PowsyblException;
import com.powsybl.commons.reporter.ReporterModel;
import com.powsybl.commons.report.ReportNode;
import com.powsybl.network.store.client.NetworkStoreService;
import groovy.lang.Binding;
import groovy.lang.GroovyShell;
Expand Down Expand Up @@ -305,7 +305,7 @@ FileInfos exportMerge(UUID processUuid, ZonedDateTime processDate, String format
return networkConversionService.exportMerge(networkUuids, caseUuid, format, baseFileName, boundaries);
}

ReporterModel getReport(UUID processUuid, LocalDateTime processDate) {
ReportNode getReport(UUID processUuid, LocalDateTime processDate) {
MergeEntity mergeEntity = mergeRepository.findByKeyProcessUuidAndKeyDate(processUuid, processDate).orElseThrow(() -> new MergeOrchestratorException(MERGE_NOT_FOUND, "<" + processUuid + ", " + processDate + ">"));
return mergeConfigService.getReport(mergeEntity.getReportUUID());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
package org.gridsuite.merge.orchestrator.server;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.powsybl.commons.reporter.ReporterModel;
import com.powsybl.commons.reporter.ReporterModelJsonModule;
import com.powsybl.commons.report.ReportNode;
import com.powsybl.commons.report.ReportNodeJsonModule;
import com.powsybl.commons.report.ReportNodeRootBuilderImpl;
import com.powsybl.iidm.network.NetworkFactory;
import com.powsybl.iidm.network.ValidationException;
import com.powsybl.network.store.client.NetworkStoreService;
Expand Down Expand Up @@ -151,7 +152,7 @@ public class MergeOrchestratorIT {
private static final String SPECIFIC_BOUNDARY_EQ_ID = "66666666-d9e2-4ea0-afdc-dba189ab4358";
private static final String SPECIFIC_BOUNDARY_TP_ID = "77777777-aab9-4284-a965-71d5cd151f71";

private static final ReporterModel REPORT_TEST = new ReporterModel("test", "test");
private static final ReportNode REPORT_TEST = new ReportNodeRootBuilderImpl().withMessageTemplate("test", "test").build();

private static final DateTimeFormatter DATE_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssXXX");

Expand Down Expand Up @@ -253,7 +254,7 @@ private void initMockServer() {

// FIXME: remove lines when dicos will be used on the front side
mapper = new ObjectMapper();
mapper.registerModule(new ReporterModelJsonModule());
mapper.registerModule(new ReportNodeJsonModule());

// Start the server.
mockServer.start();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,26 @@
*/
package org.gridsuite.merge.orchestrator.server.utils;

import com.powsybl.commons.reporter.ReporterModel;
import com.powsybl.commons.report.ReportNode;
import org.hamcrest.Description;
import org.hamcrest.TypeSafeMatcher;

/**
* @author Slimane Amar <slimane.amar at rte-france.com>
*/
public class MatcherReport extends TypeSafeMatcher<ReporterModel> {
public class MatcherReport extends TypeSafeMatcher<ReportNode> {

ReporterModel reference;
ReportNode reference;

public MatcherReport(ReporterModel report) {
public MatcherReport(ReportNode report) {
this.reference = report;
}

@Override
public boolean matchesSafely(ReporterModel m) {
return reference.getTaskKey().equals(m.getTaskKey()) &&
reference.getDefaultName().equals(m.getDefaultName());
public boolean matchesSafely(ReportNode m) {
return reference.getMessageKey().equals(m.getMessageKey()) &&
reference.getMessage().equals(m.getMessage()) &&
reference.getMessageTemplate().equals(m.getMessageTemplate());
}

@Override
Expand Down

0 comments on commit 94a9222

Please sign in to comment.