-
Notifications
You must be signed in to change notification settings - Fork 1
Enrich process config creation #41
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| /** | ||
| * Copyright (c) 2026, 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.monitor.commons; | ||
|
|
||
| import com.fasterxml.jackson.annotation.JsonProperty; | ||
| import lombok.Getter; | ||
|
|
||
| import java.time.Instant; | ||
| import java.util.List; | ||
| import java.util.UUID; | ||
|
|
||
| /** | ||
| * @author Franck Lecuyer <franck.lecuyer at rte-france.com> | ||
| */ | ||
| @Getter | ||
| public abstract class AbstractProcessConfig implements ProcessConfig { | ||
| @JsonProperty(required = true) | ||
| private final List<UUID> modificationUuids; | ||
|
|
||
| private final String owner; | ||
|
|
||
| private final Instant creationDate; | ||
|
|
||
| private final Instant lastModificationDate; | ||
|
|
||
| private final String lastModifiedBy; | ||
|
|
||
| protected AbstractProcessConfig( | ||
| List<UUID> modificationUuids, | ||
| String owner, | ||
| Instant creationDate, | ||
| Instant lastModificationDate, | ||
| String lastModifiedBy | ||
| ) { | ||
| this.modificationUuids = modificationUuids != null ? List.copyOf(modificationUuids) : null; | ||
| this.owner = owner; | ||
| this.creationDate = creationDate; | ||
| this.lastModificationDate = lastModificationDate; | ||
| this.lastModifiedBy = lastModifiedBy; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| /** | ||
| * Copyright (c) 2026, 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.monitor.commons; | ||
|
|
||
| /** | ||
| * @author Franck Lecuyer <franck.lecuyer at rte-france.com> | ||
| */ | ||
| public final class Constants { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the logic for now is to put in monitor-commons class that are commons to server and worker. |
||
|
|
||
| private Constants() { | ||
| } | ||
|
|
||
| public static final String HEADER_USER_ID = "userId"; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,9 +6,11 @@ | |
| */ | ||
| package org.gridsuite.monitor.commons; | ||
|
|
||
| import com.fasterxml.jackson.annotation.JsonProperty; | ||
| import com.fasterxml.jackson.annotation.JsonSubTypes; | ||
| import com.fasterxml.jackson.annotation.JsonTypeInfo; | ||
|
|
||
| import java.time.Instant; | ||
| import java.util.List; | ||
| import java.util.UUID; | ||
|
|
||
|
|
@@ -25,5 +27,17 @@ | |
| public interface ProcessConfig { | ||
| ProcessType processType(); | ||
|
|
||
| List<UUID> modificationUuids(); | ||
| List<UUID> getModificationUuids(); | ||
|
|
||
| @JsonProperty(access = JsonProperty.Access.READ_ONLY) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is readonly to avoid API requests with this data, right? |
||
| String getOwner(); | ||
|
|
||
| @JsonProperty(access = JsonProperty.Access.READ_ONLY) | ||
| Instant getCreationDate(); | ||
|
|
||
| @JsonProperty(access = JsonProperty.Access.READ_ONLY) | ||
| Instant getLastModificationDate(); | ||
|
|
||
| @JsonProperty(access = JsonProperty.Access.READ_ONLY) | ||
| String getLastModifiedBy(); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,20 +6,43 @@ | |
| */ | ||
| package org.gridsuite.monitor.commons; | ||
|
|
||
| import com.fasterxml.jackson.annotation.JsonProperty; | ||
| import lombok.EqualsAndHashCode; | ||
| import lombok.Getter; | ||
|
|
||
| import java.time.Instant; | ||
| import java.util.List; | ||
| import java.util.UUID; | ||
|
|
||
| /** | ||
| * @author Antoine Bouhours <antoine.bouhours at rte-france.com> | ||
| */ | ||
| public record SecurityAnalysisConfig( | ||
| UUID parametersUuid, | ||
| List<String> contingencies, | ||
| List<UUID> modificationUuids | ||
| ) implements ProcessConfig { | ||
| @Getter | ||
| @EqualsAndHashCode(callSuper = true) | ||
| public class SecurityAnalysisConfig extends AbstractProcessConfig { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same comment for the record vs class and null/required |
||
| @JsonProperty(required = true) | ||
| private final UUID parametersUuid; | ||
|
|
||
| @JsonProperty(required = true) | ||
| private final List<String> contingencies; | ||
|
|
||
| public SecurityAnalysisConfig( | ||
| UUID parametersUuid, | ||
| List<String> contingencies, | ||
| List<UUID> modificationUuids, | ||
| String owner, | ||
| Instant creationDate, | ||
| Instant lastModificationDate, | ||
| String lastModifiedBy | ||
| ) { | ||
| super(modificationUuids, owner, creationDate, lastModificationDate, lastModifiedBy); | ||
| this.parametersUuid = parametersUuid; | ||
| this.contingencies = contingencies != null ? List.copyOf(contingencies) : null; | ||
| } | ||
|
Comment on lines
+20
to
+41
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Check if -parameters compiler flag is configured in any pom.xml or build.gradle
echo "=== Checking for -parameters compiler flag ==="
rg -n '\-parameters' --type xml --type gradle 2>/dev/null || echo "No -parameters flag found"
echo ""
echo "=== Checking pom.xml for maven-compiler-plugin configuration ==="
fd 'pom.xml' -x cat {} \; | head -200
echo ""
echo "=== Checking for build.gradle ==="
fd 'build.gradle' -x cat {} \; 2>/dev/null | head -150
echo ""
echo "=== Checking for jackson-module-parameter-names dependency ==="
rg -n 'jackson-module-parameter-names' 2>/dev/null || echo "No jackson-module-parameter-names found"
echo ""
echo "=== Check parent POM and Spring Boot version ==="
rg -n 'spring-boot' --type xml -A2 -B2 2>/dev/null | head -50Repository: gridsuite/monitor-core Length of output: 10878 Add Jackson deserialization support before deploying the record-to-class migration. The class lacks the necessary configuration for Jackson to deserialize it. It has a multi-arg constructor without Add one of the following before merging:
🤖 Prompt for AI Agents |
||
|
|
||
| @Override | ||
| public ProcessType processType() { | ||
| return ProcessType.SECURITY_ANALYSIS; | ||
| } | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| /** | ||
| * Copyright (c) 2026, 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.monitor.commons; | ||
|
|
||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| import java.time.Instant; | ||
| import java.util.List; | ||
| import java.util.UUID; | ||
|
|
||
| import static org.assertj.core.api.Assertions.assertThat; | ||
|
|
||
| /** | ||
| * @author Franck Lecuyer <franck.lecuyer at rte-france.com> | ||
| */ | ||
| class SecurityAnalysisConfigTest { | ||
|
|
||
| @Test | ||
| void createSecurityAnalysisConfig() { | ||
| UUID parametersUuid = UUID.randomUUID(); | ||
| UUID modificationUuid = UUID.randomUUID(); | ||
| List<String> contingencies = List.of("contingency1", "contingency2"); | ||
| String owner = "user1"; | ||
| Instant creationDate = Instant.now(); | ||
| Instant lastModificationDate = Instant.now().plusSeconds(60); | ||
| String lastModifiedBy = "user2"; | ||
|
|
||
| SecurityAnalysisConfig config = new SecurityAnalysisConfig( | ||
| parametersUuid, | ||
| contingencies, | ||
| List.of(modificationUuid), | ||
| owner, | ||
| creationDate, | ||
| lastModificationDate, | ||
| lastModifiedBy | ||
| ); | ||
|
|
||
| assertThat(config.getParametersUuid()).isEqualTo(parametersUuid); | ||
| assertThat(config.getContingencies()).isEqualTo(contingencies); | ||
| assertThat(config.getModificationUuids()).containsExactly(modificationUuid); | ||
| assertThat(config.getOwner()).isEqualTo(owner); | ||
| assertThat(config.getCreationDate()).isEqualTo(creationDate); | ||
| assertThat(config.getLastModificationDate()).isEqualTo(lastModificationDate); | ||
| assertThat(config.getLastModifiedBy()).isEqualTo(lastModifiedBy); | ||
| assertThat(config.processType()).isEqualTo(ProcessType.SECURITY_ANALYSIS); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,10 +25,12 @@ | |
| import lombok.Getter; | ||
| import lombok.NoArgsConstructor; | ||
| import lombok.Setter; | ||
| import lombok.experimental.SuperBuilder; | ||
| import org.gridsuite.monitor.commons.ProcessType; | ||
|
|
||
| import java.util.List; | ||
| import java.util.UUID; | ||
| import java.time.Instant; | ||
|
|
||
| import static jakarta.persistence.DiscriminatorType.STRING; | ||
|
|
||
|
|
@@ -43,6 +45,7 @@ | |
| @AllArgsConstructor | ||
| @Getter | ||
| @Setter | ||
| @SuperBuilder | ||
| public abstract class AbstractProcessConfigEntity { | ||
| @Id | ||
| @GeneratedValue(strategy = GenerationType.AUTO) | ||
|
|
@@ -57,6 +60,18 @@ public abstract class AbstractProcessConfigEntity { | |
| @OrderColumn(name = "pos_modifications") | ||
| private List<UUID> modificationUuids; | ||
|
|
||
| @Column(name = "owner", length = 80, nullable = false) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we usually don't constrain in the bd but it see that it's consistent with directory server |
||
| private String owner; | ||
|
|
||
| @Column(name = "creation_date", nullable = false) | ||
| private Instant creationDate; | ||
|
|
||
| @Column(name = "last_modification_date", nullable = false) | ||
| private Instant lastModificationDate; | ||
|
|
||
| @Column(name = "last_modified_by", length = 80, nullable = false) | ||
| private String lastModifiedBy; | ||
|
|
||
| public abstract ProcessType getType(); | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.