From b5e40d8e86fb513249e67d69271156cc6056b93e Mon Sep 17 00:00:00 2001
From: Thang PHAM <117309322+thangqp@users.noreply.github.com>
Date: Fri, 12 Jul 2024 18:09:23 +0200
Subject: [PATCH] [GridDyna] Using gridsuite filter library for mapping (#95)
---
pom.xml | 7 +
.../ds/server/DynamicSimulationException.java | 13 +-
.../RestResponseEntityExceptionHandler.java | 6 +-
.../dto/dynamicmapping/InputMapping.java | 27 +++
.../dto/dynamicmapping/ParameterFile.java | 23 +++
.../ds/server/dto/dynamicmapping/Rule.java | 36 ++++
.../ds/server/dto/dynamicmapping/Script.java | 36 ----
.../dynamicmapping/automata/Automaton.java | 26 +++
.../automata/BasicProperty.java | 26 +++
.../DynamicSimulationWorkerService.java | 38 ++--
.../ds/server/service/client/RestClient.java | 2 +-
.../dynamicmapping/DynamicMappingClient.java | 14 +-
.../impl/DynamicMappingClientImpl.java | 45 +++--
.../timeseries/impl/TimeSeriesClientImpl.java | 2 +-
.../server/service/client/utils/UrlUtils.java | 9 +-
.../contexts/DynamicSimulationRunContext.java | 18 +-
.../CurveGroovyGeneratorService.java | 1 -
.../EventGroovyGeneratorService.java | 27 ---
.../service/parameters/ParametersService.java | 8 +-
.../impl/CurveGroovyGeneratorServiceImpl.java | 10 +-
.../impl/EventGroovyGeneratorServiceImpl.java | 88 ---------
.../impl/ParametersServiceImpl.java | 119 ++++++++++--
.../ds/server/utils/PropertyType.java | 3 +-
.../ds/server/utils/SetGroupType.java | 25 +++
.../org/gridsuite/ds/server/utils/Utils.java | 62 +++++-
src/main/resources/templates/event/event.st | 3 -
.../templates/event/eventProperty.st | 1 -
src/main/resources/templates/event/events.st | 10 -
...stractDynamicSimulationControllerTest.java | 4 +-
...DynamicSimulationControllerIEEE14Test.java | 50 ++---
.../DynamicSimulationControllerTest.java | 17 +-
.../ds/server/controller/utils/FileUtils.java | 1 +
.../controller/utils/ParameterUtils.java | 15 +-
.../ds/server/controller/utils/TestUtils.java | 2 +-
.../dto/XmlSerializableParameterTest.java | 12 +-
.../DynamicMappingClientTest.java | 79 +++-----
.../timeseries/TimeSeriesClientTest.java | 7 +-
.../data/ieee14/_01/input/mapping.json | 183 ++++++++++++++++++
.../data/ieee14/_01/input/models.groovy | 78 --------
.../data/ieee14/_01/output/result_SIM.json | 90 ++++-----
src/test/resources/dynamicModels.groovy | 35 ----
41 files changed, 751 insertions(+), 507 deletions(-)
create mode 100644 src/main/java/org/gridsuite/ds/server/dto/dynamicmapping/InputMapping.java
create mode 100644 src/main/java/org/gridsuite/ds/server/dto/dynamicmapping/ParameterFile.java
create mode 100644 src/main/java/org/gridsuite/ds/server/dto/dynamicmapping/Rule.java
delete mode 100644 src/main/java/org/gridsuite/ds/server/dto/dynamicmapping/Script.java
create mode 100644 src/main/java/org/gridsuite/ds/server/dto/dynamicmapping/automata/Automaton.java
create mode 100644 src/main/java/org/gridsuite/ds/server/dto/dynamicmapping/automata/BasicProperty.java
delete mode 100644 src/main/java/org/gridsuite/ds/server/service/parameters/EventGroovyGeneratorService.java
delete mode 100644 src/main/java/org/gridsuite/ds/server/service/parameters/impl/EventGroovyGeneratorServiceImpl.java
create mode 100644 src/main/java/org/gridsuite/ds/server/utils/SetGroupType.java
delete mode 100644 src/main/resources/templates/event/event.st
delete mode 100644 src/main/resources/templates/event/eventProperty.st
delete mode 100644 src/main/resources/templates/event/events.st
create mode 100644 src/test/resources/data/ieee14/_01/input/mapping.json
delete mode 100644 src/test/resources/data/ieee14/_01/input/models.groovy
delete mode 100644 src/test/resources/dynamicModels.groovy
diff --git a/pom.xml b/pom.xml
index b99e5fdf..c810b272 100644
--- a/pom.xml
+++ b/pom.xml
@@ -141,10 +141,17 @@
com.powsybl
powsybl-dynawaltz
+ 2.5.0-alpha-1
com.powsybl
powsybl-dynawaltz-dsl
+ 2.5.0-alpha-1
+
+
+ org.gridsuite
+ gridsuite-filter
+ 1.0.9
com.powsybl
diff --git a/src/main/java/org/gridsuite/ds/server/DynamicSimulationException.java b/src/main/java/org/gridsuite/ds/server/DynamicSimulationException.java
index ebc410bc..f1043b4b 100644
--- a/src/main/java/org/gridsuite/ds/server/DynamicSimulationException.java
+++ b/src/main/java/org/gridsuite/ds/server/DynamicSimulationException.java
@@ -6,9 +6,12 @@
*/
package org.gridsuite.ds.server;
+import lombok.Getter;
+
/**
* @author Abdelsalem Hedhili
*/
+@Getter
public class DynamicSimulationException extends RuntimeException {
public enum Type {
@@ -17,9 +20,11 @@ public enum Type {
MAPPING_NOT_PROVIDED,
RESULT_UUID_NOT_FOUND,
DYNAMIC_MAPPING_NOT_FOUND,
- CREATE_MAPPING_SCRIPT_ERROR,
+ EXPORT_PARAMETERS_ERROR,
+ GET_DYNAMIC_MAPPING_ERROR,
CREATE_TIME_SERIES_ERROR,
- DELETE_TIME_SERIES_ERROR
+ DELETE_TIME_SERIES_ERROR,
+ MAPPING_NOT_LAST_RULE_WITH_EMPTY_FILTER_ERROR,
}
private final Type type;
@@ -28,8 +33,4 @@ public DynamicSimulationException(Type type, String message) {
super(message);
this.type = type;
}
-
- public Type getType() {
- return type;
- }
}
diff --git a/src/main/java/org/gridsuite/ds/server/RestResponseEntityExceptionHandler.java b/src/main/java/org/gridsuite/ds/server/RestResponseEntityExceptionHandler.java
index 5f356fc1..685672aa 100644
--- a/src/main/java/org/gridsuite/ds/server/RestResponseEntityExceptionHandler.java
+++ b/src/main/java/org/gridsuite/ds/server/RestResponseEntityExceptionHandler.java
@@ -34,11 +34,13 @@ protected ResponseEntity