From 591204eb9cf195657bb78b0529178129ab85e9cc Mon Sep 17 00:00:00 2001
From: lucile varloteaux <lucile.varloteaux@inrae.fr>
Date: Mon, 31 Jul 2023 13:54:29 +0200
Subject: [PATCH] =?UTF-8?q?ajout=20s=C3=A9rialisation=20boolean=20groovy?=
 =?UTF-8?q?=20expression?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../java/fr/inra/oresing/checker/GroovyLineChecker.java   | 7 +++++++
 .../java/fr/inra/oresing/persistence/JsonRowMapper.java   | 8 ++++----
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/src/main/java/fr/inra/oresing/checker/GroovyLineChecker.java b/src/main/java/fr/inra/oresing/checker/GroovyLineChecker.java
index 2611552cd..ac94d28d0 100644
--- a/src/main/java/fr/inra/oresing/checker/GroovyLineChecker.java
+++ b/src/main/java/fr/inra/oresing/checker/GroovyLineChecker.java
@@ -1,5 +1,7 @@
 package fr.inra.oresing.checker;
 
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonProperty;
 import com.google.common.collect.ImmutableMap;
 import fr.inra.oresing.groovy.BooleanGroovyExpression;
 import fr.inra.oresing.groovy.GroovyExpression;
@@ -8,6 +10,7 @@ import fr.inra.oresing.model.ReferenceDatum;
 import fr.inra.oresing.model.SomethingThatCanProvideEvaluationContext;
 import fr.inra.oresing.rest.validationcheckresults.DefaultValidationCheckResult;
 import fr.inra.oresing.rest.ValidationCheckResult;
+import org.testcontainers.shaded.com.fasterxml.jackson.databind.annotation.JsonSerialize;
 
 import java.util.Optional;
 import java.util.Set;
@@ -21,6 +24,10 @@ public class GroovyLineChecker implements LineChecker<GroovyLineCheckerConfigura
     private final ImmutableMap<String, Object> context;
 
     private final GroovyLineCheckerConfiguration configuration;
+    @JsonProperty
+    public String getExpression(){
+        return expression.toString();
+    }
 
     private GroovyLineChecker(BooleanGroovyExpression expression, ImmutableMap<String, Object> context, GroovyLineCheckerConfiguration configuration) {
         this.expression = expression;
diff --git a/src/main/java/fr/inra/oresing/persistence/JsonRowMapper.java b/src/main/java/fr/inra/oresing/persistence/JsonRowMapper.java
index 6218e5153..7a601c0b4 100644
--- a/src/main/java/fr/inra/oresing/persistence/JsonRowMapper.java
+++ b/src/main/java/fr/inra/oresing/persistence/JsonRowMapper.java
@@ -6,6 +6,7 @@ import com.fasterxml.jackson.core.JsonProcessingException;
 import com.fasterxml.jackson.databind.*;
 import com.fasterxml.jackson.databind.module.SimpleModule;
 import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
+import fr.inra.oresing.groovy.BooleanGroovyExpression;
 import fr.inra.oresing.model.LocalDateTimeRange;
 import fr.inra.oresing.model.ReferenceDatum;
 import fr.inra.oresing.rest.exceptions.SiOreIllegalArgumentException;
@@ -74,15 +75,14 @@ public class JsonRowMapper<T> implements RowMapper<T> {
                         Map map = p.readValueAs(Map.class);
                         return ReferenceDatum.fromDatabaseJson(map);
                     }
-                })
-                ;
+                });
         jsonMapper.registerModule(module);
     }
 
     @Override
     public T mapRow(ResultSet rs, int rowNum) throws SQLException {
         try {
-            Class<T> type = (Class<T>)Class.forName(rs.getString("@class"));
+            Class<T> type = (Class<T>) Class.forName(rs.getString("@class"));
             String json = rs.getString("json");
             T result = jsonMapper.readValue(json, type);
             return result;
@@ -97,7 +97,7 @@ public class JsonRowMapper<T> implements RowMapper<T> {
                     )
             );
             // throw new SQLException("Can't convert result from database to object", eee);
-        }catch (ClassNotFoundException eee) {
+        } catch (ClassNotFoundException eee) {
             throw new SiOreIllegalArgumentException(
                     "sqlConvertExceptionForClass",
                     Map.of(
-- 
GitLab