Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
import io.swagger.v3.oas.annotations.tags.Tag;
import org.apache.commons.collections4.CollectionUtils;
import org.gridsuite.computation.dto.ReportInfos;
import org.gridsuite.ds.server.dto.DynamicSimulationParametersInfos;
import org.gridsuite.ds.server.dto.DynamicSimulationStatus;
import org.gridsuite.ds.server.dto.event.EventInfos;
import org.gridsuite.ds.server.service.DynamicSimulationResultService;
import org.gridsuite.ds.server.service.DynamicSimulationService;
import org.gridsuite.ds.server.service.contexts.DynamicSimulationRunContext;
Expand Down Expand Up @@ -58,24 +58,22 @@ public DynamicSimulationController(DynamicSimulationService dynamicSimulationSer
public ResponseEntity<UUID> run(@PathVariable("networkUuid") UUID networkUuid,
@RequestParam(name = "variantId", required = false) String variantId,
@RequestParam(name = "receiver", required = false) String receiver,
@RequestParam(name = "mappingName", required = false) String mappingName,
@RequestParam(name = "reportUuid", required = false) UUID reportId,
@RequestParam(name = "reporterId", required = false) String reportName,
@RequestParam(name = "reportType", required = false, defaultValue = "DynamicSimulation") String reportType,
@RequestParam(name = "provider", required = false) String provider,
@RequestParam(name = "debug", required = false, defaultValue = "false") boolean debug,
@RequestBody DynamicSimulationParametersInfos parameters,
@RequestParam(name = "parametersUuid") UUID parametersUuid,
@RequestBody List<EventInfos> events,
@RequestHeader(HEADER_USER_ID) String userId) {

DynamicSimulationRunContext dynamicSimulationRunContext = parametersService.createRunContext(
networkUuid,
variantId,
receiver,
provider,
mappingName,
ReportInfos.builder().reportUuid(reportId).reporterId(reportName).computationType(reportType).build(),
userId,
parameters,
parametersUuid,
events,
debug);

UUID resultUuid = dynamicSimulationService.runAndSaveResult(dynamicSimulationRunContext);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
package org.gridsuite.ds.server.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
Expand All @@ -18,6 +19,7 @@
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

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

Expand All @@ -36,14 +38,82 @@ public DynamicSimulationParametersController(ParametersService parametersService
this.parametersService = parametersService;
}

@PostMapping(value = "/values", produces = MediaType.APPLICATION_JSON_VALUE)
@PostMapping(value = "", consumes = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "Create parameters")
@ApiResponse(responseCode = "200", description = "parameters were created")
public ResponseEntity<UUID> createParameters(
@RequestBody DynamicSimulationParametersInfos parametersInfos) {
return ResponseEntity.ok(parametersService.createParameters(parametersInfos));
}

@PostMapping(value = "/default")
@Operation(summary = "Create default parameters")
@ApiResponse(responseCode = "200", description = "Default parameters were created")
public ResponseEntity<UUID> createDefaultParameters() {
return ResponseEntity.ok(parametersService.createDefaultParameters());
}

@PostMapping(value = "", params = "duplicateFrom", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "Duplicate parameters")
@ApiResponse(responseCode = "200", description = "parameters were duplicated")
public ResponseEntity<UUID> duplicateParameters(
@Parameter(description = "source parameters UUID") @RequestParam("duplicateFrom") UUID sourceParametersUuid) {
return ResponseEntity.ok(parametersService.duplicateParameters(sourceParametersUuid));
}

@GetMapping(value = "/{uuid}", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "Get parameters")
@ApiResponse(responseCode = "200", description = "parameters were returned")
@ApiResponse(responseCode = "404", description = "parameters were not found")
public ResponseEntity<DynamicSimulationParametersInfos> getParameters(
@Parameter(description = "parameters UUID") @PathVariable("uuid") UUID parametersUuid) {
return ResponseEntity.ok(parametersService.getParameters(parametersUuid));
}

@GetMapping(value = "", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "Get all parameters")
@ApiResponse(responseCode = "200", description = "The list of all parameters was returned")
public ResponseEntity<List<DynamicSimulationParametersInfos>> getAllParameters() {
return ResponseEntity.ok().body(parametersService.getAllParameters());
}

@PutMapping(value = "/{uuid}", consumes = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "Update parameters")
@ApiResponse(responseCode = "200", description = "parameters were updated")
public ResponseEntity<Void> updateParameters(
@Parameter(description = "parameters UUID") @PathVariable("uuid") UUID parametersUuid,
@RequestBody(required = false) DynamicSimulationParametersInfos parametersInfos) {
parametersService.updateParameters(parametersUuid, parametersInfos);
return ResponseEntity.ok().build();
}

@DeleteMapping(value = "/{uuid}")
@Operation(summary = "Delete parameters")
@ApiResponse(responseCode = "200", description = "parameters were deleted")
public ResponseEntity<Void> deleteParameters(
@Parameter(description = "parameters UUID") @PathVariable("uuid") UUID parametersUuid) {
parametersService.deleteParameters(parametersUuid);
return ResponseEntity.ok().build();
}

@GetMapping(value = "/{uuid}/provider", produces = MediaType.TEXT_PLAIN_VALUE)
@Operation(summary = "Get provider")
@ApiResponse(responseCode = "200", description = "provider were returned")
@ApiResponse(responseCode = "404", description = "provider were not found")
public ResponseEntity<String> getProvider(
@Parameter(description = "parameters UUID") @PathVariable("uuid") UUID parametersUuid) {
return ResponseEntity.ok(parametersService.getProvider(parametersUuid));
}

@GetMapping(value = "/{uuid}/values", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "Get the dynamic simulation parameters values")
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The dynamic simulation parameters values"),
@ApiResponse(responseCode = "404", description = "The dynamic simulation parameters has not been found")})
public ResponseEntity<DynamicSimulationParametersValues> getParametersValues(@RequestParam(name = "networkUuid") UUID networkUuid,
@RequestParam(name = "variantId", required = false) String variantId,
@RequestBody DynamicSimulationParametersInfos parameters) {
DynamicSimulationParametersValues parametersValues = parametersService.getParametersValues(parameters, networkUuid, variantId);
public ResponseEntity<DynamicSimulationParametersValues> getParametersValues(
@Parameter(description = "parameters UUID") @PathVariable("uuid") UUID parametersUuid,
@RequestParam(name = "networkUuid") UUID networkUuid,
@RequestParam(name = "variantId", required = false) String variantId) {
DynamicSimulationParametersValues parametersValues = parametersService.getParametersValues(parametersUuid, networkUuid, variantId);
return ResponseEntity.of(Optional.ofNullable(parametersValues));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,14 @@

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import com.powsybl.dynawo.DynawoSimulationParameters.SolverType;
import lombok.*;
import org.gridsuite.ds.server.dto.curve.CurveInfos;
import org.gridsuite.ds.server.dto.event.EventInfos;
import org.gridsuite.ds.server.dto.network.NetworkInfos;
import org.gridsuite.ds.server.dto.solver.SolverInfos;

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

/**
* @author Thang PHAM <quyet-thang.pham at rte-france.com>
Expand All @@ -27,17 +25,18 @@
@AllArgsConstructor
@Getter
@Setter
@Builder
@JsonIgnoreProperties(ignoreUnknown = true)
public class DynamicSimulationParametersInfos {
private UUID id;
private String provider;
@JsonInclude(JsonInclude.Include.NON_EMPTY)
private Double startTime;
@JsonInclude(JsonInclude.Include.NON_EMPTY)
private Double stopTime;
private String mapping;
private String solverId;
private SolverType solver;
private List<SolverInfos> solvers;
private NetworkInfos network;
private List<CurveInfos> curves;
private List<EventInfos> events;
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,22 @@
package org.gridsuite.ds.server.dto.curve;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.*;
import org.gridsuite.ds.server.utils.EquipmentType;

import java.util.UUID;

/**
* @author Thang PHAM <quyet-thang.pham at rte-france.com>
*/
@NoArgsConstructor
@AllArgsConstructor
@Getter
@Setter
@Builder
@JsonIgnoreProperties(ignoreUnknown = true)
public class CurveInfos {
private UUID id;
private EquipmentType equipmentType;
private String equipmentId;
private String variableId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

package org.gridsuite.ds.server.dto.event;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Getter;
Expand All @@ -27,12 +28,16 @@
public class EventInfos {

@JsonProperty("uuid")
@JsonIgnore
private UUID id;
Comment on lines 30 to 32
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

# Locate the files mentioned in the review
find . -type f -name "EventInfos.java" | head -5
find . -type f -name "DynamicSimulationResultContext.java" | head -5

Repository: gridsuite/dynamic-simulation-server

Length of output: 237


🏁 Script executed:

# Check repository structure
git ls-files | grep -E "(EventInfos|DynamicSimulationResultContext)" | head -20

Repository: gridsuite/dynamic-simulation-server

Length of output: 233


🏁 Script executed:

# Read EventInfos.java to verify the annotation state
cat -n ./src/main/java/org/gridsuite/ds/server/dto/event/EventInfos.java | head -50

Repository: gridsuite/dynamic-simulation-server

Length of output: 1467


🏁 Script executed:

# Read DynamicSimulationResultContext.java around lines 81 and 94
cat -n ./src/main/java/org/gridsuite/ds/server/service/contexts/DynamicSimulationResultContext.java | sed -n '70,105p'

Repository: gridsuite/dynamic-simulation-server

Length of output: 1530


🏁 Script executed:

# Check for ObjectMapper configuration or custom setup
rg -A 5 -B 5 "objectMapper" ./src/main/java/org/gridsuite/ds/server/service/contexts/DynamicSimulationResultContext.java | head -40

Repository: gridsuite/dynamic-simulation-server

Length of output: 1712


🏁 Script executed:

# Search for any custom Jackson configuration in the codebase
find ./src -type f -name "*.java" | xargs grep -l "JsonIgnore\|JsonProperty" | head -10

Repository: gridsuite/dynamic-simulation-server

Length of output: 596


🏁 Script executed:

# Search for ObjectMapper bean configuration or Jackson setup
find ./src -type f -name "*.java" | xargs grep -l "ObjectMapper" | xargs grep -l "Bean\|Configuration\|@Configuration" | head -10

Repository: gridsuite/dynamic-simulation-server

Length of output: 963


🏁 Script executed:

# Look for Jackson configuration or feature disabling
rg "ObjectMapper|Jackson|@Bean" ./src --type java -B 2 -A 5 | grep -A 7 -B 2 "ObjectMapper" | head -50

Repository: gridsuite/dynamic-simulation-server

Length of output: 5462


🏁 Script executed:

# Check if there's Jackson configuration in the main config
cat -n ./src/main/java/org/gridsuite/ds/server/config/RestTemplateConfig.java | head -100

Repository: gridsuite/dynamic-simulation-server

Length of output: 3510


🏁 Script executed:

# Verify Jackson annotation behavior is standard - check if there are any custom configurations
rg "setSerializationInclusion|disable|enable|JsonProperty|JsonIgnore" ./src/main/java --type java -B 2 -A 2 | head -60

Repository: gridsuite/dynamic-simulation-server

Length of output: 6052


@JsonIgnore suppresses both serialization and deserialization, completely neutralizing @JsonProperty("uuid").

At lines 30-31, the conflicting annotations cause the uuid field to be dropped during the serialization/deserialization cycle in DynamicSimulationResultContext (lines 81 and 94), preventing round-tripping of event data.

Remove @JsonIgnore if the uuid field should be serialized, or use @JsonProperty(value = "uuid", access = JsonProperty.Access.READ_WRITE) to be explicit about allowing both directions.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/main/java/org/gridsuite/ds/server/dto/event/EventInfos.java` around lines
30 - 32, The EventInfos class currently marks the UUID field `private UUID id`
with both `@JsonProperty`("uuid") and `@JsonIgnore` which cancels
serialization/deserialization; update the annotations on `id` in EventInfos to
allow round-tripping (either remove `@JsonIgnore` or replace the annotation with
`@JsonProperty`(value = "uuid", access = JsonProperty.Access.READ_WRITE)) so
DynamicSimulationResultContext can serialize and deserialize the `uuid` field
correctly.


@JsonIgnore
private UUID nodeId;

@JsonIgnore
private String equipmentId;

@JsonIgnore
private String equipmentType;

private String eventType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter;
import java.util.UUID;

/**
* @author Thang PHAM <quyet-thang.pham at rte-france.com>
Expand Down Expand Up @@ -46,7 +47,7 @@ public class NetworkInfos implements XmlSerializableParameter {

public static final String NETWORK_ID = "NETWORK";

private String id = NETWORK_ID;
private UUID id;

private double capacitorNoReclosingDelay;

Expand Down Expand Up @@ -91,7 +92,7 @@ public class NetworkInfos implements XmlSerializableParameter {
@Override
public void writeParameter(XMLStreamWriter writer) throws XMLStreamException {
writer.writeStartElement(DYN_BASE_URI, "set");
writer.writeAttribute("id", id);
writer.writeAttribute("id", NETWORK_ID);

XmlSerializableParameter.writeParameter(writer, ParameterType.DOUBLE, CAPACITOR_NO_RECLOSING_DELAY, Double.toString(capacitorNoReclosingDelay));
XmlSerializableParameter.writeParameter(writer, ParameterType.DOUBLE, DANGLING_LINE_CURRENT_LIMIT_MAX_TIME_OPERATION, Double.toString(danglingLineCurrentLimitMaxTimeOperation));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
package org.gridsuite.ds.server.dto.solver;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.powsybl.dynawo.DynawoSimulationParameters.SolverType;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
Expand All @@ -16,6 +17,7 @@

import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter;
import java.util.UUID;

/**
* @author Thang PHAM <quyet-thang.pham at rte-france.com>
Expand Down Expand Up @@ -50,8 +52,8 @@ public abstract class AbstractSolverInfos implements SolverInfos {
public static final String MAXIMUM_NUMBER_SLOW_STEP_INCREASE = "maximumNumberSlowStepIncrease";
public static final String MINIMAL_ACCEPTABLE_STEP = "minimalAcceptableStep";

private String id;
private SolverTypeInfos type;
private UUID id;
private SolverType type;

// Important note: must using @JsonProperty to precise property's name when serialize/deserialize
// fields which begin by a minuscule following by a majuscule, for example 'hMxxx', otherwise jackson
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class IdaSolverInfos extends AbstractSolverInfos {
@Override
public void writeParameter(XMLStreamWriter writer) throws XMLStreamException {
writer.writeStartElement(DYN_BASE_URI, "set");
writer.writeAttribute("id", getId());
writer.writeAttribute("id", getType().name());

XmlSerializableParameter.writeParameter(writer, ParameterType.INT, SOLVER_ORDER, Integer.toString(order));
XmlSerializableParameter.writeParameter(writer, ParameterType.DOUBLE, INIT_STEP, Double.toString(initStep));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public class SimSolverInfos extends AbstractSolverInfos {
@Override
public void writeParameter(XMLStreamWriter writer) throws XMLStreamException {
writer.writeStartElement(DYN_BASE_URI, "set");
writer.writeAttribute("id", getId());
writer.writeAttribute("id", getType().name());

XmlSerializableParameter.writeParameter(writer, ParameterType.DOUBLE, H_MIN, Double.toString(hMin));
XmlSerializableParameter.writeParameter(writer, ParameterType.DOUBLE, H_MAX, Double.toString(hMax));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@

import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.powsybl.dynawo.DynawoSimulationParameters.SolverType;
import org.gridsuite.ds.server.dto.XmlSerializableParameter;

import java.util.UUID;

/**
* @author Thang PHAM <quyet-thang.pham at rte-france.com>
*/
Expand All @@ -23,7 +26,7 @@
@JsonSubTypes.Type(value = IdaSolverInfos.class, name = "IDA"),
@JsonSubTypes.Type(value = SimSolverInfos.class, name = "SIM")})
public interface SolverInfos extends XmlSerializableParameter {
String getId();
UUID getId();

SolverTypeInfos getType();
SolverType getType();
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
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.ds.server.model;
package org.gridsuite.ds.server.entities;

import jakarta.persistence.MappedSuperclass;
import jakarta.persistence.PostLoad;
Expand All @@ -18,7 +18,7 @@

// Official documentation: https://docs.spring.io/spring-data/jpa/docs/current/reference/html/#jpa.entity-persistence.saving-entites.strategies
@MappedSuperclass
public abstract class AbstractManuallyAssignedIdentifierEntity<ID> implements Persistable<ID> {

Check warning on line 21 in src/main/java/org/gridsuite/ds/server/entities/AbstractManuallyAssignedIdentifierEntity.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this generic name to match the regular expression '^[A-Z][0-9]?$'.

See more on https://sonarcloud.io/project/issues?id=org.gridsuite%3Adynamic-simulation-server&issues=AZ0CV6G6hEapFrO8tgHS&open=AZ0CV6G6hEapFrO8tgHS&pullRequest=167

@Transient
private boolean isNew = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* 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.ds.server.model;
package org.gridsuite.ds.server.entities;

import jakarta.persistence.*;
import lombok.Getter;
Expand Down Expand Up @@ -47,7 +47,7 @@
byte[] getDynamicModel();
}

public ResultEntity(UUID id, UUID timeSeriesId, UUID timeLineId, DynamicSimulationStatus status, String debugFileLocation, byte[] outputState, byte[] parameters, byte[] dynamicModel) {

Check warning on line 50 in src/main/java/org/gridsuite/ds/server/entities/ResultEntity.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Constructor has 8 parameters, which is greater than 7 authorized.

See more on https://sonarcloud.io/project/issues?id=org.gridsuite%3Adynamic-simulation-server&issues=AZ0CV6DHhEapFrO8tgHR&open=AZ0CV6DHhEapFrO8tgHR&pullRequest=167
this.id = id;
this.timeSeriesId = timeSeriesId;
this.timeLineId = timeLineId;
Expand Down
Loading
Loading