diff --git a/.gitignore b/.gitignore
index 9b1ae502..0c187eaa 100644
--- a/.gitignore
+++ b/.gitignore
@@ -51,3 +51,8 @@ glowroot.jar
/secrets/postgres_password.txt
/secrets/secrets_protools_properties.properties
/secrets/**
+/src/main/resources/application-conteneur.properties
+/src/main/resources/application-dev.properties
+/src/main/resources/application-kubedev.properties
+
+/src/test/httpRequests/fak/
diff --git a/changelog.md b/changelog.md
index 0f9d8499..4f94a7cf 100644
--- a/changelog.md
+++ b/changelog.md
@@ -1,19 +1,26 @@
# Change Log
All notable changes to this project will be documented in this file.
-
+
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).
+## [Unreleased 1.1.1-SNAPSHOT] - xx-xx-xxxx
+### Changed
+#### BPMN TASKS
+- [sugoiCreateUserTask](TODO)
+ La longueur du mot de passe crée dépend du contexte (8 pour household ; 12 sinon)
+- [cleanUserPasswordTask](TODO)
+ Suppression de toutes les variables de mots de passe (sur le contexte et dans l'historique)
-## [Unreleased 1.1.0] - yyyy-mm-dd
+## [1.1.0] - 14-05-2024
### Added
#### BPMN TASKS
- [SabianePilotageCreateSUTask](http://preparation_collecte.gitlab-pages.insee.fr/prepadoc/Protools/taches/#cr%c3%a9er-une-ue-dans-la-plateforme-de-collecte-enqu%c3%aateur-partie-pilotage)
Tâche de création d'une UE dans sabiane pilotage
- [SabianeQuestionnaireCreateSUTask](http://preparation_collecte.gitlab-pages.insee.fr/prepadoc/Protools/taches/#cr%c3%a9er-une-ue-dans-la-plateforme-de-collecte-enqu%c3%aateur-partie-questionnaire)
Tâche de création d'une UE dans sabiane questionnaire
-- [sugoiCreateUserTask](TODO)
- Tâche de création d'un utilisateur dans l'annuaire Sugoi et initialization d'un mot de passe par défaut.
+- [sugoiCreateUserTask](http://preparation_collecte.gitlab-pages.insee.fr/prepadoc/Protools/taches/#cr%c3%a9ation-de-comptes-dans-lannuaire-sugoi)
+ Tâche de création d'un utilisateur dans l'annuaire Sugoi et initialization d'un mot de passe par défaut
- [platinePilotageGetSUIsToFollowUpTask]( TODO)
Tâche de lecture dans Platine Pilotage de l'état a-relancer/eligible/isToFollowUp d'une UE (d'une partition).
- [platinePilotageAddSUFollowUpTask]( TODO)
@@ -38,7 +45,7 @@ Travail sur les tâches BPMN pour ERA et REM.
- [remGetSUTask](http://preparation_collecte.gitlab-pages.insee.fr/prepadoc/Protools/taches/#r%c3%a9cup%c3%a9ration-dune-ue-dans-rem)
Tâche de récupération d'une UE dans REM à partir de son ID.
- [extractContactIdentifierFromREMSUTask](http://preparation_collecte.gitlab-pages.insee.fr/prepadoc/Protools/taches/#extraire-lidentifiant-de-compte-des-additionals-info-dans-une-ue-rem)
- Tâche d'extraction de l'identifiant internet depuis les additionalInformations d'un json d'UE REM
+ Tâche d'extraction de l'identifiant internet depuis les additionalInformations d'un json d'UE REM
- [remWriteEraSUListTask](http://preparation_collecte.gitlab-pages.insee.fr/prepadoc/Protools/taches/#ecriture-dune-liste-due-dans-une-partition-rem)
Tâche d'écriture dans REM d'une liste d'UE récupérée dans ERA
- [eraGetSUForPeriodAndGenderTask](http://preparation_collecte.gitlab-pages.insee.fr/prepadoc/Protools/taches/#extractions-de-donn%c3%a9ees-du-rp-avec-era)
@@ -54,24 +61,24 @@ Travail sur les tâches BPMN pour ERA et REM.
#### Endpoints
- /api_configuration qui renverra la configuration de chaque API orchestrée par protools. Cela permet donc de savoir
-quelle plateforme est appelée.
+ quelle plateforme est appelée.
#### Autres
- Vérification que le fichier de contexte satisfait bien toutes les tâches du BPMN associé au processus.
- Possibilité d'utiliser la date de début et de fin de collecte d'une partition dans les expressions BPMN via PartitionCtxResolver
-- Ajout des périodes X01 à X99 à l'énumération pour pilotage
+- Ajout des périodes X01 à X99 à l'énumération pour pilotage
--
+-
### Changed
#### Variables du processus
- "sugoi-id-contact" devient "directory_access-id-contact" (peut casser les BPMN la référençant en dur).
-
+
### Fixed
-
+
## [0.0.3] - 2023-05-16
### Added
- Création de contexte de campagne dans sabiane et platine
+Création de contexte de campagne dans sabiane et platine
### Changed
### Fixed
diff --git a/pom.xml b/pom.xml
index 3aa4d5fa..ce6b834d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,17 +5,18 @@
org.springframework.boot
spring-boot-starter-parent
- 3.3.1
+ 3.3.4
fr.insee.sndil.protools
protools-protlsbo
- 1.1.0
+ 1.1.1-SNAPSHOT
Protools Back Office
Protools Back Office: Survey Orchestrator and Management Tool - Built with Flowable Engine
17
2.5.0
+ 1.0.0
7.0.1-insee
1.16.1
1.2.1
@@ -42,6 +43,13 @@
${flowable.version}
+
+
+ fr.insee
+ boot-properties-logger-starter
+ ${properties-logger.version}
+
+
org.passay
@@ -125,6 +133,29 @@
test
+
+ io.micrometer
+ micrometer-core
+ 1.12.3
+
+
+
+ org.springframework.boot
+ spring-boot-starter-data-mongodb
+
+
+
+ com.networknt
+ json-schema-validator
+ 1.5.1
+
+
+
+
+ com.fasterxml.jackson.datatype
+ jackson-datatype-jsr310
+
+
@@ -140,6 +171,11 @@
+
@@ -148,12 +184,24 @@
${pitest.version}
- fr.insee.protools.backend.service.*
- fr.insee.protools.backend.controller.StarterController
+ fr.insee.protools.backend.*
STRONGER
+
+ java.util.logging
+ org.apache.log4j
+ org.slf4j
+ org.apache.commons.logging
+ fr.insee.protools.backend.logging
+ fr.insee.protools.backend.logging.LoggingHelper
+
+
+ fr.insee.protools.backend.logging.*
+ fr.insee.protools.backend.dto.*
+ *xxBPMNError
+
@@ -185,28 +233,58 @@
- maven-resources-plugin
+ org.apache.maven.plugins
+ maven-compiler-plugin
+
+ 21
+ 21
+
+ fr/insee/protools/backend/deprecated/**/*.java
+
+
+ **/deprecated/**/*.java
+
+
+
+
+
+ org.jsonschema2pojo
+ jsonschema2pojo-maven-plugin
+ 1.2.1
+
+ java.time.Instant
+ ${basedir}/src/main/resources/schema
+ fr.insee.protools.backend.dto
+ ALWAYS
+
- copy-resources
- validate
- copy-resources
+ generate
+
+
+
+
+
+
+ org.codehaus.mojo
+ build-helper-maven-plugin
+
+
+ generate-sources
+
+ add-source
- ${project.build.outputDirectory}
-
-
- ${basedir}
-
- changelog.md
-
-
-
+
+ ${project.build.directory}/generated-sources/jsonschema2pojo
+
+
+
diff --git a/src/main/java/fr/insee/protools/backend/StarterApplication.java b/src/main/java/fr/insee/protools/backend/StarterApplication.java
index f18c8d6f..522df08e 100644
--- a/src/main/java/fr/insee/protools/backend/StarterApplication.java
+++ b/src/main/java/fr/insee/protools/backend/StarterApplication.java
@@ -1,6 +1,5 @@
package fr.insee.protools.backend;
-import fr.insee.protools.backend.configuration.PropertiesLogger;
import jakarta.servlet.ServletRequest;
import jakarta.servlet.http.HttpServletRequest;
import org.springdoc.core.utils.SpringDocUtils;
@@ -15,8 +14,7 @@ public static void main(String[] args) {
configureApplicationBuilder(new SpringApplicationBuilder()).build().run(args); }
public static SpringApplicationBuilder configureApplicationBuilder(SpringApplicationBuilder springApplicationBuilder){
- return springApplicationBuilder.sources(StarterApplication.class)
- .listeners(new PropertiesLogger());
+ return springApplicationBuilder.sources(StarterApplication.class);
}
@EventListener(ApplicationReadyEvent.class)
diff --git a/src/main/java/fr/insee/protools/backend/configuration/PropertiesLogger.java b/src/main/java/fr/insee/protools/backend/configuration/PropertiesLogger.java
deleted file mode 100644
index e0469771..00000000
--- a/src/main/java/fr/insee/protools/backend/configuration/PropertiesLogger.java
+++ /dev/null
@@ -1,193 +0,0 @@
-package fr.insee.protools.backend.configuration;
-
-import lombok.AccessLevel;
-import lombok.AllArgsConstructor;
-import lombok.NonNull;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.boot.context.event.ApplicationEnvironmentPreparedEvent;
-import org.springframework.context.ApplicationListener;
-import org.springframework.core.env.AbstractEnvironment;
-import org.springframework.core.env.EnumerablePropertySource;
-import org.springframework.core.env.Environment;
-import org.springframework.core.env.PropertySource;
-
-import java.util.*;
-import java.util.function.Supplier;
-
-/**
- * Listener Spring permettant d'afficher les props dans les logs au démarrage de l'application : se déclenche
- * sur l'évènement ApplicationEnvironmentPreparedEvent.
- *
- * Par défaut affiche les propriétés qui vérifient les conditions suivantes :
- * 1. passées soit par la ligne de commande (--maProp=valeur), soit présentes dans les fichiers properties
- * détectés par Spring boot au démarrage (une propriété présente uniquement dans le code sous la forme
- * @Value("${ma.propriete}") dont la valeur serait passée uniquement par variable d'environnement ne sera
- * donc pas détectée. Pour qu'elle le soit, il faut la faire figurer dans le fichier application.properties par exemple)
- * 2. qui sont préfixées par l'un des éléments de PropertiesLogger.prefixesAffichesParDefaut
- *
- * Pour chaque propriété affichée :
- * - si la clé contient l'un des mots parmi PropertiesLogger.motsCachesParDefaut, affiche alors "****"
- * - sinon c'est la valeur de la propriété telle qu'elle sera résolue par Spring boot dans l'application qui est affichée
- *
- * Enfin, sont loguées également les noms des PropertySource de Spring dont proviennent les clés des propriétés qui sont affichées
- *
- * Le comportement de cette classe peut être amendé par les propriétés suivantes :
- * - fr.insee.properties.log.key.select : stratégie de sélection des sources de propriétés qui seront affichées :
- * - trois valeurs possibles :
- * - ALL(toutes les propriétés des propertysource traitées seront affichées, peu importe les prefixes)
- * - NONE (rien ne sera affiché)
- * - PREFIX (valeur par défaut) : affiche les propriétés dont le prefixe est dans fr.insee.properties.log.key.prefixes
- * et qui ne font pas partie des propertySource ignorés (le nom des propertysource ignorés figurent
- * dans fr.insee.properties.log.sources.ignored))
- * - cf enum PropertySelectorEnum
- * - fr.insee.properties.log.sources.ignored : nom des propertysource (ex: application-dev.properties) qui seront ignorées.
- * - la valeur attendue est une liste de noms séparés par des virgules. Si vide alors aucune propertysource ne sera ignorée
- * - Valeur par défaut : PropertiesLogger.propertySourcesIgnoreesParDefaut
- * - fr.insee.properties.log.key.prefixes : permet de définir les préfixes des propriétés qui seront affichées.
- * - Valeur par défaut : PropertiesLogger.prefixesAffichesParDefaut
- * - la valeur attendue est une liste de noms séparés par des virgules. Si vide aucune propriété ne sera affichée
- * - fr.insee.properties.log.key.hidden : liste des mots pour lesquels la valeur de la propriété sera masquée (si la clé de
- * la propriété contient l'un des mots de la liste alors la valeur sera masquée).
- * - Valeur par défaut : PropertiesLogger.motsCachesParDefaut
- * - la valeur attendue est une liste de noms séparés par des virgules. /!\ ☠️ si vide tous les secrets seront affichés dans la log
- *
- */
-@Slf4j
-public class PropertiesLogger implements ApplicationListener {
-
- public static final String PROPERTY_KEY_FOR_PREFIXES = "fr.insee.properties.log.key.prefixes";
- public static final String PROPERTY_KEY_FOR_MORE_HIDDEN = "fr.insee.properties.log.key.hidden.more";
- public static final String PROPERTY_KEY_FOR_SOURCES_IGNORED = "fr.insee.properties.log.sources.ignored";
- public static final String PROPERTY_KEY_FOR_SOURCES_SELECT = "fr.insee.properties.log.key.select";
- private static final Set baseMotsCaches = Set.of("password", "pwd", "jeton", "token", "secret", "credential", "pw");
- private static final Set prefixesAffichesParDefaut= Set.of("fr.insee","logging","keycloak","spring","application","server","springdoc","management");
- private static final Set propertySourcesIgnoreesParDefaut = Set.of("systemProperties", "systemEnvironment");
- public static final PropertySelectorEnum PROPERTY_SELECTOR_PAR_DEFAUT = PropertySelectorEnum.PREFIX;
- private static Set prefixForSelectedProps;
-
- private final Collection propertySourceNames=new ArrayList<>();
- private Set hiddensProps;
- private Set ignoredPropertySources;
- private PropertySelector propertySelector;
-
- @Override
- public void onApplicationEvent(@NonNull ApplicationEnvironmentPreparedEvent event) {
- Environment environment=event.getEnvironment();
-
- var props= new StringBuilder();
- this.hiddensProps = getMoreHiddenPropsFromPropertyAndMerge(environment);
- prefixForSelectedProps = environment.getProperty(PROPERTY_KEY_FOR_PREFIXES, Set.class, prefixesAffichesParDefaut);
- this.ignoredPropertySources = environment.getProperty(PROPERTY_KEY_FOR_SOURCES_IGNORED, Set.class, propertySourcesIgnoreesParDefaut);
- var propertySelectorType=this.getSelectorFromProperty(environment.getProperty(PROPERTY_KEY_FOR_SOURCES_SELECT))
- .orElse(PROPERTY_SELECTOR_PAR_DEFAUT);
- log.atDebug().log(()->"Logging "+propertySelectorType.forLogging());
- this.propertySelector=propertySelectorType.propertySelector();
-
- ((AbstractEnvironment) environment).getPropertySources().stream()
- .filter(this::isEnumerable)
- .filter(this::sourceWillBeProcessed)
- .map(this::rememberPropertySourceNameThenCast)
- .map(EnumerablePropertySource::getPropertyNames)
- .flatMap(Arrays::stream)
- .distinct()
- .filter(Objects::nonNull)
- .filter(this::filterFromPropertySelector)
- .forEach(key-> props.append(key).append(" = ")
- .append(resoutValeurAvecMasquePwd(key, environment))
- .append(System.lineSeparator()));
- props.append("============================================================================");
- props.insert(0, """
- ===============================================================================================
- Valeurs des properties pour :
- %s
- ===============================================================================================
- """.formatted(this.propertySourceNames.stream().reduce("",(l, e)->l+System.lineSeparator()+"- "+e )));
- log.info(props.toString());
-
- }
-
- private static Set getMoreHiddenPropsFromPropertyAndMerge(Environment environment) {
- var moreProps = environment.getProperty(PROPERTY_KEY_FOR_MORE_HIDDEN, Set.class);
- var retour = baseMotsCaches;
- if (moreProps != null){
- retour=new HashSet<>(moreProps);
- retour.addAll(baseMotsCaches);
- }
- return retour;
- }
-
- private Optional getSelectorFromProperty(String property) {
- if(property!=null){
- try{
- return Optional.of(PropertySelectorEnum.valueOf(property));
- }catch (IllegalArgumentException ie){
- log.atTrace().log(()->"Impossible de convertir "+property+" en une constante de PropertySelectorEnum. Le PropertySelector par défaut sera utilisé.");
- }
- }
- return Optional.empty();
- }
-
- private boolean filterFromPropertySelector(@NonNull String s) {
- if (! this.propertySelector.filter(s)){
- log.atDebug().log(()->s+ " ne commence pas par un des prefix retenus pour être loguée");
- return false;
- }
- return true;
- }
-
- private boolean sourceWillBeProcessed(PropertySource> propertySource) {
-
- if (ignoredPropertySources.contains(propertySource.getName())){
- log.atDebug().log(()->propertySource+ " sera ignorée");
- return false;
- }
- return true;
- }
-
- private EnumerablePropertySource> rememberPropertySourceNameThenCast(PropertySource> propertySource) {
- this.propertySourceNames.add(propertySource.getName());
- return (EnumerablePropertySource>) propertySource;
- }
-
- private boolean isEnumerable(PropertySource> propertySource) {
- if (! (propertySource instanceof EnumerablePropertySource)){
- log.atDebug().log(()->propertySource+ " n'est pas EnumerablePropertySource : impossible à lister");
- return false;
- }
- return true;
- }
-
- private Object resoutValeurAvecMasquePwd(String key, Environment environment) {
- if (hiddensProps.stream().anyMatch(key::contains)) {
- return "******";
- }
- return environment.getProperty(key);
-
- }
-
-
- @FunctionalInterface
- private interface PropertySelector {
- boolean filter(String s);
- }
-
- @AllArgsConstructor(access = AccessLevel.PRIVATE)
- private enum PropertySelectorEnum {
- ALL(s->true, ()->"all properties"),
- NONE(s->false, ()->"no properties"),
- PREFIX(k->prefixForSelectedProps.stream().anyMatch(k::startsWith), () -> "properties starting with "+ prefixForSelectedProps);
-
- private final PropertySelector propertySelector;
- private final Supplier logString;
-
- public PropertySelector propertySelector() {
- return propertySelector;
- }
-
- public String forLogging(){
- return logString.get();
- }
-
- }
-}
-
diff --git a/src/main/java/fr/insee/protools/backend/configuration/SchedulerCondition.java b/src/main/java/fr/insee/protools/backend/configuration/SchedulerCondition.java
new file mode 100644
index 00000000..d4bd5104
--- /dev/null
+++ b/src/main/java/fr/insee/protools/backend/configuration/SchedulerCondition.java
@@ -0,0 +1,13 @@
+package fr.insee.protools.backend.configuration;
+
+import org.springframework.context.annotation.Condition;
+import org.springframework.context.annotation.ConditionContext;
+import org.springframework.core.type.AnnotatedTypeMetadata;
+
+public class SchedulerCondition implements Condition {
+ @Override
+ public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
+ return false;
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/java/fr/insee/protools/backend/configuration/SpringDocConfiguration.java b/src/main/java/fr/insee/protools/backend/configuration/SpringDocConfiguration.java
index 6df81cb4..ee20ab57 100644
--- a/src/main/java/fr/insee/protools/backend/configuration/SpringDocConfiguration.java
+++ b/src/main/java/fr/insee/protools/backend/configuration/SpringDocConfiguration.java
@@ -8,9 +8,9 @@
import io.swagger.v3.oas.models.security.OAuthFlows;
import io.swagger.v3.oas.models.security.SecurityRequirement;
import io.swagger.v3.oas.models.security.SecurityScheme;
+import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springdoc.core.customizers.OperationCustomizer;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.info.BuildProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -19,13 +19,11 @@
@Configuration
@Slf4j
+@RequiredArgsConstructor
public class SpringDocConfiguration {
- @Autowired
- private InseeSpringdocProperties springdocProperties;
-
- @Autowired(required = false)
- private Optional buildProperties;
+ private final InseeSpringdocProperties springdocProperties;
+ private final Optional buildProperties;
public static final String OAUTHSCHEME = "oAuth";
@@ -86,7 +84,12 @@ private OpenAPI createOpenAPI() {
.info(
new Info()
.title(buildProperties.map(BuildProperties::getName).orElse("n.a"))
- .description(springdocProperties.getDescription())
+ .description(
+ String.format("`Application version : %s`\n\n%s",
+ buildProperties.map(BuildProperties::getVersion).orElse("n.a"),
+ springdocProperties.getDescription()
+ )
+ )
.version(buildProperties.map(BuildProperties::getVersion).orElse("n.a"))
/*.license(
new License()
diff --git a/src/main/java/fr/insee/protools/backend/controller/ProtoolsProcessController.java b/src/main/java/fr/insee/protools/backend/controller/ProtoolsProcessController.java
index bf445c9c..c3397da4 100644
--- a/src/main/java/fr/insee/protools/backend/controller/ProtoolsProcessController.java
+++ b/src/main/java/fr/insee/protools/backend/controller/ProtoolsProcessController.java
@@ -1,6 +1,6 @@
package fr.insee.protools.backend.controller;
-import fr.insee.protools.backend.service.context.ContextService;
+import fr.insee.protools.backend.service.context.IContextService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
@@ -21,7 +21,7 @@
@RequiredArgsConstructor
public class ProtoolsProcessController {
- private final ContextService contextService;
+ private final IContextService contextService;
@PostMapping(value = "/upload-context", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
@Operation(summary = "Upload of the context file",
diff --git a/src/main/java/fr/insee/protools/backend/controller/ProtoolsProcessControllerAdvice.java b/src/main/java/fr/insee/protools/backend/controller/ProtoolsProcessControllerAdvice.java
index 6249690b..085c1726 100644
--- a/src/main/java/fr/insee/protools/backend/controller/ProtoolsProcessControllerAdvice.java
+++ b/src/main/java/fr/insee/protools/backend/controller/ProtoolsProcessControllerAdvice.java
@@ -1,11 +1,11 @@
package fr.insee.protools.backend.controller;
+import fr.insee.protools.backend.restclient.exception.runtime.HttpClient4xxBPMNError;
+import fr.insee.protools.backend.restclient.exception.runtime.HttpClient5xxBPMNError;
import fr.insee.protools.backend.service.context.exception.BadContextIOException;
import fr.insee.protools.backend.service.context.exception.BadContextIncorrectBPMNError;
import fr.insee.protools.backend.service.context.exception.BadContextNotJSONBPMNError;
import fr.insee.protools.backend.service.exception.*;
-import fr.insee.protools.backend.webclient.exception.runtime.WebClient4xxBPMNError;
-import fr.insee.protools.backend.webclient.exception.runtime.WebClient5xxBPMNError;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
@@ -49,14 +49,14 @@ public ResponseEntity exeptionProcessDefinitionNotFoundHandler(/*final H
return new ResponseEntity<>(exception.getMessage(), HttpStatus.NOT_FOUND);
}
- @ExceptionHandler({ WebClient4xxBPMNError.class })
- public ResponseEntity exceptionWebClient4xxHandler(/*final HttpServletRequest req, */final WebClient4xxBPMNError exception) {
+ @ExceptionHandler({ HttpClient4xxBPMNError.class })
+ public ResponseEntity exceptionWebClient4xxHandler(/*final HttpServletRequest req, */final HttpClient4xxBPMNError exception) {
log.error("exceptionWebClient4xxHandler : "+exception.getMessage());
return new ResponseEntity<>(exception.getMessage(), exception.getHttpStatusCodeError());
}
- @ExceptionHandler({ WebClient5xxBPMNError.class })
- public ResponseEntity exceptionWebClient5xxHandler(/*final HttpServletRequest req, */final WebClient5xxBPMNError exception) {
+ @ExceptionHandler({ HttpClient5xxBPMNError.class })
+ public ResponseEntity exceptionWebClient5xxHandler(/*final HttpServletRequest req, */final HttpClient5xxBPMNError exception) {
log.error("exceptionWebClient5xxHandler : "+exception.getMessage());
return new ResponseEntity<>(exception.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
}
diff --git a/src/main/java/fr/insee/protools/backend/controller/StarterController.java b/src/main/java/fr/insee/protools/backend/controller/StarterController.java
index b6c9cce9..08aa5213 100644
--- a/src/main/java/fr/insee/protools/backend/controller/StarterController.java
+++ b/src/main/java/fr/insee/protools/backend/controller/StarterController.java
@@ -1,8 +1,8 @@
package fr.insee.protools.backend.controller;
import com.fasterxml.jackson.databind.JsonNode;
-import fr.insee.protools.backend.webclient.WebClientHelper;
-import org.springframework.beans.factory.annotation.Autowired;
+import fr.insee.protools.backend.restclient.RestClientHelper;
+import lombok.RequiredArgsConstructor;
import org.springframework.boot.info.BuildProperties;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
@@ -17,13 +17,12 @@
@RequestMapping("/starter")
@RestController
+@RequiredArgsConstructor
public class StarterController {
- @Autowired(required = false)
- private Optional buildProperties;
+ private final Optional buildProperties;
- @Autowired
- private WebClientHelper webClientHelper;
+ private final RestClientHelper restClientHelper;
@GetMapping("/healthcheck")
public ResponseEntity healthcheck(){
@@ -59,7 +58,7 @@ public ResponseEntity healthcheckadmin(){
@GetMapping("/token_details_by_api")
public ResponseEntity tokensDetailsByAPI(){
StringBuilder result = new StringBuilder("List of tokens roles : ");
- for(var x : webClientHelper.getTokenDetailsByAPI().entrySet()){
+ for(var x : restClientHelper.getTokenDetailsByAPI().entrySet()){
result.append("\n").append(x.getKey()).append(" : ").append(x.getValue());
}
return ResponseEntity.ok(result.toString());
@@ -67,7 +66,7 @@ public ResponseEntity tokensDetailsByAPI(){
@GetMapping("/api_configuration")
public ResponseEntity apiConfiguration(){
- return ResponseEntity.ok(webClientHelper.getAPIConfigDetails());
+ return ResponseEntity.ok(restClientHelper.getAPIConfigDetails());
}
@GetMapping(value="/changelog" , produces = MediaType.TEXT_PLAIN_VALUE)
diff --git a/src/main/java/fr/insee/protools/backend/dto/era/CensusJsonDto.java b/src/main/java/fr/insee/protools/backend/dto/era/CensusJsonDto.java
deleted file mode 100644
index db583670..00000000
--- a/src/main/java/fr/insee/protools/backend/dto/era/CensusJsonDto.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package fr.insee.protools.backend.dto.era;
-
-import com.fasterxml.jackson.databind.node.BaseJsonNode;
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-
-import java.io.Serializable;
-
-@Data
-@Builder
-@AllArgsConstructor
-@NoArgsConstructor
-public class CensusJsonDto implements Serializable {
- private Long id;
- private String numvoiloc;
- private String bisterloc;
- private String typevoiloc;
- private String nomvoiloc;
- private String resloc;
- private String car;
- private String cpostloc;
- private Long idinternaute;
- private String mail;
- private String identifiantCompte;
- private BaseJsonNode externals;
-}
diff --git a/src/main/java/fr/insee/protools/backend/dto/era/GenderType.java b/src/main/java/fr/insee/protools/backend/dto/era/GenderType.java
deleted file mode 100644
index 2b79f8da..00000000
--- a/src/main/java/fr/insee/protools/backend/dto/era/GenderType.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package fr.insee.protools.backend.dto.era;
-
-import lombok.Getter;
-
-@Getter
-public enum GenderType {
- MALE("1", "hommes"), FEMALE("2", "femmes");
-
- private final String value;
- private final String label;
-
- GenderType(String value, String label) {
- this.value = value;
- this.label = label;
- }
-
- public static GenderType fromValue(int value) {
- return switch (value) {
- case 1 -> MALE;
- case 2 -> FEMALE;
- default -> throw new IllegalStateException("Unexpected value for ERA gender: " + value);
- };
- }
-
- public static GenderType fromLabel(String label) {
- return switch (label) {
- case "hommes" -> MALE;
- case "femmes" -> FEMALE;
- default -> throw new IllegalStateException("Unexpected value for ERA gender label: " + label);
- };
- }
-
- public static String getAllValidLabels() {
- return MALE.label + "," + FEMALE.label;
- }
-
-}
diff --git a/src/main/java/fr/insee/protools/backend/dto/meshuggah/MeshuggahComDetails.java b/src/main/java/fr/insee/protools/backend/dto/meshuggah/MeshuggahComDetails.java
deleted file mode 100644
index 289eed28..00000000
--- a/src/main/java/fr/insee/protools/backend/dto/meshuggah/MeshuggahComDetails.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package fr.insee.protools.backend.dto.meshuggah;
-
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-
-@Data
-@Builder
-@NoArgsConstructor @AllArgsConstructor
-public class MeshuggahComDetails {
- String campaignId;
- String partitioningId;
- String medium;
- String phase;
- String operation;
- String mode;
- String protocol;
- boolean avecQuestionnaire;
-}
\ No newline at end of file
diff --git a/src/main/java/fr/insee/protools/backend/dto/platine/pilotage/PlatineAddressDto.java b/src/main/java/fr/insee/protools/backend/dto/platine/pilotage/PlatineAddressDto.java
deleted file mode 100644
index 76a385f7..00000000
--- a/src/main/java/fr/insee/protools/backend/dto/platine/pilotage/PlatineAddressDto.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package fr.insee.protools.backend.dto.platine.pilotage;
-
-import lombok.Getter;
-import lombok.Setter;
-
-@Getter
-@Setter
-//Note: Mutualise the two Identical Adresses DTO used by platine (contact/questionning)
-public class PlatineAddressDto {
-
- private String streetNumber;
- private String repetitionIndex;
- private String streetType;
- private String streetName;
- private String addressSupplement;
- private String cityName;
- private String zipCode;
- private String cedexCode;
- private String cedexName;
- private String specialDistribution;
- private String countryCode;
- private String countryName;
-
-}
diff --git a/src/main/java/fr/insee/protools/backend/dto/platine/pilotage/PlatinePilotageCommunicationEventDto.java b/src/main/java/fr/insee/protools/backend/dto/platine/pilotage/PlatinePilotageCommunicationEventDto.java
new file mode 100644
index 00000000..a0e70db5
--- /dev/null
+++ b/src/main/java/fr/insee/protools/backend/dto/platine/pilotage/PlatinePilotageCommunicationEventDto.java
@@ -0,0 +1,8 @@
+package fr.insee.protools.backend.dto.platine.pilotage;
+
+public record PlatinePilotageCommunicationEventDto(
+ String interrogationId,
+ String communicationId,
+ String communicationRequestId,
+ PlatinePilotageCommunicationEventType state
+) {}
\ No newline at end of file
diff --git a/src/main/java/fr/insee/protools/backend/dto/platine/pilotage/PlatinePilotageCommunicationEventType.java b/src/main/java/fr/insee/protools/backend/dto/platine/pilotage/PlatinePilotageCommunicationEventType.java
new file mode 100644
index 00000000..f305675c
--- /dev/null
+++ b/src/main/java/fr/insee/protools/backend/dto/platine/pilotage/PlatinePilotageCommunicationEventType.java
@@ -0,0 +1,14 @@
+package fr.insee.protools.backend.dto.platine.pilotage;
+
+import lombok.Getter;
+
+@Getter
+public enum PlatinePilotageCommunicationEventType {
+ COMMUNICATION_STATE_SENT("SENT");
+
+ public final String label;
+
+ PlatinePilotageCommunicationEventType(String label) {
+ this.label = label;
+ }
+}
diff --git a/src/main/java/fr/insee/protools/backend/dto/platine/pilotage/PlatinePilotageEligibleDto.java b/src/main/java/fr/insee/protools/backend/dto/platine/pilotage/PlatinePilotageEligibleDto.java
deleted file mode 100644
index 8a9696c0..00000000
--- a/src/main/java/fr/insee/protools/backend/dto/platine/pilotage/PlatinePilotageEligibleDto.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package fr.insee.protools.backend.dto.platine.pilotage;
-
-import lombok.Data;
-
-@Data
-public class PlatinePilotageEligibleDto {
-
- private String eligible;
-}
diff --git a/src/main/java/fr/insee/protools/backend/dto/platine/pilotage/PlatinePilotageGenderType.java b/src/main/java/fr/insee/protools/backend/dto/platine/pilotage/PlatinePilotageGenderType.java
deleted file mode 100644
index 59c9e64e..00000000
--- a/src/main/java/fr/insee/protools/backend/dto/platine/pilotage/PlatinePilotageGenderType.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package fr.insee.protools.backend.dto.platine.pilotage;
-
-import lombok.Getter;
-
-@Getter
-@SuppressWarnings("java:S115") //allow constants not in capital letters
-public enum PlatinePilotageGenderType {
- Female("1", "Female"), Male("2", "Male"),Undefined("3","Undefined") ;
-
- private final String value;
- private final String label;
-
- PlatinePilotageGenderType(String value, String label) {
- this.value = value;
- this.label = label;
- }
-}
diff --git a/src/main/java/fr/insee/protools/backend/dto/platine/pilotage/contact/PlatineContactDto.java b/src/main/java/fr/insee/protools/backend/dto/platine/pilotage/contact/PlatineContactDto.java
deleted file mode 100644
index f183a937..00000000
--- a/src/main/java/fr/insee/protools/backend/dto/platine/pilotage/contact/PlatineContactDto.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package fr.insee.protools.backend.dto.platine.pilotage.contact;
-
-import fr.insee.protools.backend.dto.platine.pilotage.PlatineAddressDto;
-import fr.insee.protools.backend.dto.platine.pilotage.PlatinePilotageGenderType;
-import lombok.*;
-
-@Getter
-@Setter
-@Builder
-@AllArgsConstructor @NoArgsConstructor
-public class PlatineContactDto {
-
- private String identifier;
- private String externalId;
- private PlatinePilotageGenderType civility;
- private String lastName;
- private String firstName;
- private String function;
- private String email;
- private String phone;
- private PlatineAddressDto address;
-
-}
\ No newline at end of file
diff --git a/src/main/java/fr/insee/protools/backend/dto/platine/pilotage/query/ContactAccreditationDto.java b/src/main/java/fr/insee/protools/backend/dto/platine/pilotage/query/ContactAccreditationDto.java
deleted file mode 100644
index 95750c92..00000000
--- a/src/main/java/fr/insee/protools/backend/dto/platine/pilotage/query/ContactAccreditationDto.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package fr.insee.protools.backend.dto.platine.pilotage.query;
-
-import fr.insee.protools.backend.dto.platine.pilotage.PlatineAddressDto;
-import lombok.Builder;
-import lombok.Data;
-
-@Data
-@Builder
-public class ContactAccreditationDto {
-
- private String identifier;
- private String externalId;
- private boolean isMain;
- private String civility;
- private String lastName;
- private String firstName;
- private String function;
- private String email;
- private String phone;
- private PlatineAddressDto address;
-
-}
diff --git a/src/main/java/fr/insee/protools/backend/dto/platine/pilotage/query/QuestioningWebclientDto.java b/src/main/java/fr/insee/protools/backend/dto/platine/pilotage/query/QuestioningWebclientDto.java
deleted file mode 100644
index 6f2cb0fb..00000000
--- a/src/main/java/fr/insee/protools/backend/dto/platine/pilotage/query/QuestioningWebclientDto.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package fr.insee.protools.backend.dto.platine.pilotage.query;
-
-import fr.insee.protools.backend.dto.platine.pilotage.questioning.PlatineQuestioningSurveyUnitDto;
-import lombok.Builder;
-import lombok.Data;
-
-import java.util.List;
-
-@Data
-@Builder
-public class QuestioningWebclientDto {
-
- private String idPartitioning;
- private String modelName;
- private PlatineQuestioningSurveyUnitDto surveyUnit;
- private List contacts;
-
-}
diff --git a/src/main/java/fr/insee/protools/backend/dto/platine/pilotage/questioning/PlatineQuestioningSurveyUnitDto.java b/src/main/java/fr/insee/protools/backend/dto/platine/pilotage/questioning/PlatineQuestioningSurveyUnitDto.java
deleted file mode 100644
index 88e80fc1..00000000
--- a/src/main/java/fr/insee/protools/backend/dto/platine/pilotage/questioning/PlatineQuestioningSurveyUnitDto.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package fr.insee.protools.backend.dto.platine.pilotage.questioning;
-
-import fr.insee.protools.backend.dto.platine.pilotage.PlatineAddressDto;
-import lombok.Builder;
-import lombok.Getter;
-import lombok.Setter;
-
-@Getter
-@Setter
-@Builder
-public class PlatineQuestioningSurveyUnitDto {
-
- private String idSu;
- private String identificationCode;
- private String identificationName;
- private PlatineAddressDto address;
-}
diff --git a/src/main/java/fr/insee/protools/backend/dto/platine_sabiane_questionnaire/MetadataConstants.java b/src/main/java/fr/insee/protools/backend/dto/platine_sabiane_questionnaire/MetadataConstants.java
deleted file mode 100644
index 958e05e3..00000000
--- a/src/main/java/fr/insee/protools/backend/dto/platine_sabiane_questionnaire/MetadataConstants.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package fr.insee.protools.backend.dto.platine_sabiane_questionnaire;
-
-/**
- * Class defining names of the meta data to pass to the questionnaire
- * suppress warning on var names so it can match with the values
- */
-@java.lang.SuppressWarnings("squid:S115")
-public class MetadataConstants {
-
- public static final String Enq_LibelleEnquete="Enq_LibelleEnquete";
- public static final String Enq_ObjectifsCourts="Enq_ObjectifsCourts";
- public static final String Enq_CaractereObligatoire="Enq_CaractereObligatoire";
- public static final String Enq_NumeroVisa="Enq_NumeroVisa";
- public static final String Enq_MinistereTutelle="Enq_MinistereTutelle";
- public static final String Enq_ParutionJo="Enq_ParutionJo";
- public static final String Enq_DateParutionJo="Enq_DateParutionJo";
- public static final String Enq_RespOperationnel="Enq_RespOperationnel";
- public static final String Enq_RespTraitement="Enq_RespTraitement";
- public static final String Enq_AnneeVisa="Enq_AnneeVisa";
- public static final String Enq_QualiteStatistique="Enq_QualiteStatistique";
- public static final String Enq_TestNonLabellise="Enq_TestNonLabellise";
- public static final String Loi_statistique="Loi_statistique";
- public static final String Loi_rgpd="Loi_rgpd";
- public static final String Loi_informatique="Loi_informatique";
-
- private MetadataConstants(){}
-}
diff --git a/src/main/java/fr/insee/protools/backend/dto/platine_sabiane_questionnaire/NomenclatureDto.java b/src/main/java/fr/insee/protools/backend/dto/platine_sabiane_questionnaire/NomenclatureDto.java
deleted file mode 100644
index b5c6fa8e..00000000
--- a/src/main/java/fr/insee/protools/backend/dto/platine_sabiane_questionnaire/NomenclatureDto.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package fr.insee.protools.backend.dto.platine_sabiane_questionnaire;
-
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.databind.JsonNode;
-import lombok.AllArgsConstructor;
-import lombok.Data;
-
-@Data @AllArgsConstructor
-@JsonInclude(JsonInclude.Include.NON_NULL)
-public class NomenclatureDto {
- private String id;
- private String label;
- private JsonNode value;
-}
diff --git a/src/main/java/fr/insee/protools/backend/dto/platine_sabiane_questionnaire/QuestionnaireModelCreateDto.java b/src/main/java/fr/insee/protools/backend/dto/platine_sabiane_questionnaire/QuestionnaireModelCreateDto.java
deleted file mode 100644
index 67c9ccf2..00000000
--- a/src/main/java/fr/insee/protools/backend/dto/platine_sabiane_questionnaire/QuestionnaireModelCreateDto.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package fr.insee.protools.backend.dto.platine_sabiane_questionnaire;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import lombok.AllArgsConstructor;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-
-import java.util.Set;
-
-@Data
-@AllArgsConstructor
-@NoArgsConstructor
-public class QuestionnaireModelCreateDto {
-
- private String idQuestionnaireModel;
- private String label;
- private JsonNode value;
- private Set requiredNomenclatureIds;
-}
\ No newline at end of file
diff --git a/src/main/java/fr/insee/protools/backend/dto/platine_sabiane_questionnaire/campaign/CampaignDto.java b/src/main/java/fr/insee/protools/backend/dto/platine_sabiane_questionnaire/campaign/CampaignDto.java
deleted file mode 100644
index bfd0e3fe..00000000
--- a/src/main/java/fr/insee/protools/backend/dto/platine_sabiane_questionnaire/campaign/CampaignDto.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package fr.insee.protools.backend.dto.platine_sabiane_questionnaire.campaign;
-
-import com.fasterxml.jackson.annotation.JsonInclude;
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Data;
-
-import java.util.Set;
-
-@Builder
-@AllArgsConstructor
-@Data
-@JsonInclude(JsonInclude.Include.NON_NULL)
-public class CampaignDto {
- String id;
- String label;
- Set questionnaireIds;
- MetadataValue metadata;
-
-
-
-
-}
\ No newline at end of file
diff --git a/src/main/java/fr/insee/protools/backend/dto/platine_sabiane_questionnaire/campaign/MetadataValue.java b/src/main/java/fr/insee/protools/backend/dto/platine_sabiane_questionnaire/campaign/MetadataValue.java
deleted file mode 100644
index 0beac878..00000000
--- a/src/main/java/fr/insee/protools/backend/dto/platine_sabiane_questionnaire/campaign/MetadataValue.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package fr.insee.protools.backend.dto.platine_sabiane_questionnaire.campaign;
-
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-
-@Builder
-@Data
-@AllArgsConstructor
-@NoArgsConstructor
-public
-class MetadataValue {
- MetadataVariables value;
-}
\ No newline at end of file
diff --git a/src/main/java/fr/insee/protools/backend/dto/platine_sabiane_questionnaire/campaign/MetadataValueItem.java b/src/main/java/fr/insee/protools/backend/dto/platine_sabiane_questionnaire/campaign/MetadataValueItem.java
deleted file mode 100644
index d92a0c27..00000000
--- a/src/main/java/fr/insee/protools/backend/dto/platine_sabiane_questionnaire/campaign/MetadataValueItem.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package fr.insee.protools.backend.dto.platine_sabiane_questionnaire.campaign;
-
-import lombok.Data;
-import lombok.NoArgsConstructor;
-
-@Data
-@NoArgsConstructor
-public class MetadataValueItem{
- String name;
- Object value;
-
- public MetadataValueItem(String name, Object value) {
- this.name = name;
- this.value = value;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/fr/insee/protools/backend/dto/platine_sabiane_questionnaire/campaign/MetadataVariables.java b/src/main/java/fr/insee/protools/backend/dto/platine_sabiane_questionnaire/campaign/MetadataVariables.java
deleted file mode 100644
index 2059ffff..00000000
--- a/src/main/java/fr/insee/protools/backend/dto/platine_sabiane_questionnaire/campaign/MetadataVariables.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package fr.insee.protools.backend.dto.platine_sabiane_questionnaire.campaign;
-
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-
-import java.util.List;
-
-@Builder
-@Data
-@NoArgsConstructor@AllArgsConstructor
-public
-class MetadataVariables{
- List variables;
- String inseeContext;
-}
\ No newline at end of file
diff --git a/src/main/java/fr/insee/protools/backend/dto/platine_sabiane_questionnaire/surveyunit/SurveyUnitResponseDto.java b/src/main/java/fr/insee/protools/backend/dto/platine_sabiane_questionnaire/surveyunit/SurveyUnitResponseDto.java
deleted file mode 100644
index ba4dad45..00000000
--- a/src/main/java/fr/insee/protools/backend/dto/platine_sabiane_questionnaire/surveyunit/SurveyUnitResponseDto.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package fr.insee.protools.backend.dto.platine_sabiane_questionnaire.surveyunit;
-
-
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.databind.JsonNode;
-import lombok.Builder;
-import lombok.Data;
-
-@Builder
-@Data
-@JsonInclude(JsonInclude.Include.NON_NULL)
-public class SurveyUnitResponseDto {
- String id;
- String questionnaireId;
- private JsonNode personalization;
- private JsonNode data;
- private JsonNode comment;
-// private JsonNode stateData;
-}
\ No newline at end of file
diff --git a/src/main/java/fr/insee/protools/backend/dto/rem/AdditionalInformationDto.java b/src/main/java/fr/insee/protools/backend/dto/rem/AdditionalInformationDto.java
deleted file mode 100644
index 9599987d..00000000
--- a/src/main/java/fr/insee/protools/backend/dto/rem/AdditionalInformationDto.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package fr.insee.protools.backend.dto.rem;
-
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-
-@Builder
-@Data
-@NoArgsConstructor @AllArgsConstructor
-public class AdditionalInformationDto {
-
- private String key;
- private String value;
-}
\ No newline at end of file
diff --git a/src/main/java/fr/insee/protools/backend/dto/rem/EmailDto.java b/src/main/java/fr/insee/protools/backend/dto/rem/EmailDto.java
deleted file mode 100644
index 02a58cd5..00000000
--- a/src/main/java/fr/insee/protools/backend/dto/rem/EmailDto.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package fr.insee.protools.backend.dto.rem;
-
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-
-@Builder
-@Data
-@NoArgsConstructor
-@AllArgsConstructor
-public class EmailDto {
-
- private Boolean favorite;
- private String mailAddress;
-}
\ No newline at end of file
diff --git a/src/main/java/fr/insee/protools/backend/dto/rem/LocationHelpDto.java b/src/main/java/fr/insee/protools/backend/dto/rem/LocationHelpDto.java
deleted file mode 100644
index 029bcb03..00000000
--- a/src/main/java/fr/insee/protools/backend/dto/rem/LocationHelpDto.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package fr.insee.protools.backend.dto.rem;
-
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-
-@Builder
-@Data
-@NoArgsConstructor
-@AllArgsConstructor
-public class LocationHelpDto {
-
- private String cityCode;
- private String building;
- private String floor;
- private String staircase;
- private String door;
- private String iris;
- private String sector;
- private Boolean elevator;
- private Boolean cityPriorityDistrict;
-}
\ No newline at end of file
diff --git a/src/main/java/fr/insee/protools/backend/dto/rem/OtherIdentifierDto.java b/src/main/java/fr/insee/protools/backend/dto/rem/OtherIdentifierDto.java
deleted file mode 100644
index d2a77507..00000000
--- a/src/main/java/fr/insee/protools/backend/dto/rem/OtherIdentifierDto.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package fr.insee.protools.backend.dto.rem;
-
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-
-@Builder
-@Data
-@AllArgsConstructor
-@NoArgsConstructor
-public class OtherIdentifierDto {
-
- private String numfa;
- private String rges;
- private String ssech;
- private String cle;
- private String le;
- private String ec;
- private String bs;
- private String nograp;
- private String nolog;
- private String noi;
- private String nole;
- private String autre;
-}
diff --git a/src/main/java/fr/insee/protools/backend/dto/rem/PersonDto.java b/src/main/java/fr/insee/protools/backend/dto/rem/PersonDto.java
deleted file mode 100644
index c3d8ac90..00000000
--- a/src/main/java/fr/insee/protools/backend/dto/rem/PersonDto.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package fr.insee.protools.backend.dto.rem;
-
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-
-import java.util.List;
-
-@Builder
-@Data
-@NoArgsConstructor
-@AllArgsConstructor
-public class PersonDto {
-
- private Integer index;
- private String externalId;
- private String function;
- private String gender;
- private String firstName;
- private String lastName;
- private String birthName;
- private String dateOfBirth;
- private Boolean surveyed;
- private Boolean main;
- private Boolean coDeclarant;
- private List phoneNumbers;
- private List emails;
- //private REMAddressDto address; //Will be used for buisness; not for household
-
-}
\ No newline at end of file
diff --git a/src/main/java/fr/insee/protools/backend/dto/rem/PhoneNumberDto.java b/src/main/java/fr/insee/protools/backend/dto/rem/PhoneNumberDto.java
deleted file mode 100644
index 5b60e41b..00000000
--- a/src/main/java/fr/insee/protools/backend/dto/rem/PhoneNumberDto.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package fr.insee.protools.backend.dto.rem;
-
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-
-@Builder
-@Data
-@NoArgsConstructor
-@AllArgsConstructor
-public class PhoneNumberDto {
- private REMPhoneSource source;
- private Boolean favorite;
- private String number;
-}
\ No newline at end of file
diff --git a/src/main/java/fr/insee/protools/backend/dto/rem/REMAddressDto.java b/src/main/java/fr/insee/protools/backend/dto/rem/REMAddressDto.java
deleted file mode 100644
index 534266ae..00000000
--- a/src/main/java/fr/insee/protools/backend/dto/rem/REMAddressDto.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package fr.insee.protools.backend.dto.rem;
-
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-
-@Builder
-@Data
-@NoArgsConstructor
-@AllArgsConstructor
-public class REMAddressDto {
-
- private String streetNumber;
- private String repetitionIndex;
- private String streetType;
- private String streetName;
- private String addressSupplement;
- private String cityName;
- private String zipCode;
- private String cedexCode;
- private String cedexName;
- private String specialDistribution;
- private String countryCode;
- private String countryName;
-
- private LocationHelpDto locationHelp;
-}
\ No newline at end of file
diff --git a/src/main/java/fr/insee/protools/backend/dto/rem/REMPhoneSource.java b/src/main/java/fr/insee/protools/backend/dto/rem/REMPhoneSource.java
deleted file mode 100644
index 2a2d7eda..00000000
--- a/src/main/java/fr/insee/protools/backend/dto/rem/REMPhoneSource.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package fr.insee.protools.backend.dto.rem;
-
-public enum REMPhoneSource {
- OTHER, INITIAL, INTERVIEWER, DIRECTORY
-}
\ No newline at end of file
diff --git a/src/main/java/fr/insee/protools/backend/dto/rem/REMSurveyUnitDto.java b/src/main/java/fr/insee/protools/backend/dto/rem/REMSurveyUnitDto.java
deleted file mode 100644
index e1a733b2..00000000
--- a/src/main/java/fr/insee/protools/backend/dto/rem/REMSurveyUnitDto.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package fr.insee.protools.backend.dto.rem;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import lombok.*;
-
-import java.util.List;
-
-@Builder
-@Data
-@NoArgsConstructor
-@AllArgsConstructor
-public class REMSurveyUnitDto {
-
- private Long repositoryId;
-
- private String externalId;
-
- private String externalName;
-
- private REMAddressDto address;
-
- private List persons;
- private OtherIdentifierDto otherIdentifier;
-
- private List additionalInformations;
-
- @Getter(AccessLevel.NONE)
- private JsonNode externals;
-
- public JsonNode getExternals() {
- if(externals==null || externals.isNull())
- externals= new ObjectMapper().createObjectNode();
- return this.externals;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/fr/insee/protools/backend/dto/rem/SampleDto.java b/src/main/java/fr/insee/protools/backend/dto/rem/SampleDto.java
deleted file mode 100644
index 3649cad7..00000000
--- a/src/main/java/fr/insee/protools/backend/dto/rem/SampleDto.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package fr.insee.protools.backend.dto.rem;
-
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-
-@Builder
-@Data
-@NoArgsConstructor
-@AllArgsConstructor
-public class SampleDto {
-
- private Long id;
-
- private String label;
-
-}
\ No newline at end of file
diff --git a/src/main/java/fr/insee/protools/backend/dto/rem/SuIdMappingJson.java b/src/main/java/fr/insee/protools/backend/dto/rem/SuIdMappingJson.java
deleted file mode 100644
index 5c21efae..00000000
--- a/src/main/java/fr/insee/protools/backend/dto/rem/SuIdMappingJson.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package fr.insee.protools.backend.dto.rem;
-
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-
-import java.util.List;
-
-@Data
-@NoArgsConstructor
-@AllArgsConstructor
-@Builder
-public class SuIdMappingJson {
- private long partitionId;
- private List data;
- private int count;
-}
diff --git a/src/main/java/fr/insee/protools/backend/dto/rem/SuIdMappingRecord.java b/src/main/java/fr/insee/protools/backend/dto/rem/SuIdMappingRecord.java
deleted file mode 100644
index cd7b0129..00000000
--- a/src/main/java/fr/insee/protools/backend/dto/rem/SuIdMappingRecord.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package fr.insee.protools.backend.dto.rem;
-
-public record SuIdMappingRecord(Long repositoryId, String externalId) {
-
-}
diff --git a/src/main/java/fr/insee/protools/backend/dto/rem_tmp/InterrogationAccountDto.java b/src/main/java/fr/insee/protools/backend/dto/rem_tmp/InterrogationAccountDto.java
new file mode 100644
index 00000000..842e681f
--- /dev/null
+++ b/src/main/java/fr/insee/protools/backend/dto/rem_tmp/InterrogationAccountDto.java
@@ -0,0 +1,164 @@
+package fr.insee.protools.backend.dto.rem_tmp;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonTypeName;
+import jakarta.annotation.Generated;
+import jakarta.validation.Valid;
+
+import java.util.Objects;
+import java.util.UUID;
+
+/**
+ * InterrogationAccountDto
+ */
+
+@JsonTypeName("InterrogationAccount")
+@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", date = "2024-08-30T10:25:29.966974800+02:00[Europe/Paris]", comments = "Generator version: 7.8.0")
+public class InterrogationAccountDto {
+
+ private UUID interrogationId;
+
+ private String account;
+
+ public InterrogationAccountDto interrogationId(UUID interrogationId) {
+ this.interrogationId = interrogationId;
+ return this;
+ }
+
+ /**
+ * Get interrogationId
+ * @return interrogationId
+ */
+ @Valid
+ @JsonProperty("interrogationId")
+ public UUID getInterrogationId() {
+ return interrogationId;
+ }
+
+ public void setInterrogationId(UUID interrogationId) {
+ this.interrogationId = interrogationId;
+ }
+
+ public InterrogationAccountDto account(String account) {
+ this.account = account;
+ return this;
+ }
+
+ /**
+ * Get account
+ * @return account
+ */
+
+ @JsonProperty("account")
+ public String getAccount() {
+ return account;
+ }
+
+ public void setAccount(String account) {
+ this.account = account;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ InterrogationAccountDto interrogationAccount = (InterrogationAccountDto) o;
+ return Objects.equals(this.interrogationId, interrogationAccount.interrogationId) &&
+ Objects.equals(this.account, interrogationAccount.account);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(interrogationId, account);
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("class InterrogationAccountDto {\n");
+ sb.append(" interrogationId: ").append(toIndentedString(interrogationId)).append("\n");
+ sb.append(" account: ").append(toIndentedString(account)).append("\n");
+ sb.append("}");
+ return sb.toString();
+ }
+
+ /**
+ * Convert the given object to string with each line indented by 4 spaces
+ * (except the first line).
+ */
+ private String toIndentedString(Object o) {
+ if (o == null) {
+ return "null";
+ }
+ return o.toString().replace("\n", "\n ");
+ }
+
+ public static class Builder {
+
+ private InterrogationAccountDto instance;
+
+ public Builder() {
+ this(new InterrogationAccountDto());
+ }
+
+ protected Builder(InterrogationAccountDto instance) {
+ this.instance = instance;
+ }
+
+ protected Builder copyOf(InterrogationAccountDto value) {
+ this.instance.setInterrogationId(value.interrogationId);
+ this.instance.setAccount(value.account);
+ return this;
+ }
+
+ public Builder interrogationId(UUID interrogationId) {
+ this.instance.interrogationId(interrogationId);
+ return this;
+ }
+
+ public Builder account(String account) {
+ this.instance.account(account);
+ return this;
+ }
+
+ /**
+ * returns a built InterrogationAccountDto instance.
+ *
+ * The builder is not reusable (NullPointerException)
+ */
+ public InterrogationAccountDto build() {
+ try {
+ return this.instance;
+ } finally {
+ // ensure that this.instance is not reused
+ this.instance = null;
+ }
+ }
+
+ @Override
+ public String toString() {
+ return getClass() + "=(" + instance + ")";
+ }
+ }
+
+ /**
+ * Create a builder with no initialized field (except for the default values).
+ */
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ /**
+ * Create a builder with a shallow copy of this instance.
+ */
+ public Builder toBuilder() {
+ Builder builder = new Builder();
+ return builder.copyOf(this);
+ }
+
+}
+
diff --git a/src/main/java/fr/insee/protools/backend/dto/rem_tmp/InterrogationIdentifiersDto.java b/src/main/java/fr/insee/protools/backend/dto/rem_tmp/InterrogationIdentifiersDto.java
new file mode 100644
index 00000000..3e1f30f9
--- /dev/null
+++ b/src/main/java/fr/insee/protools/backend/dto/rem_tmp/InterrogationIdentifiersDto.java
@@ -0,0 +1,193 @@
+package fr.insee.protools.backend.dto.rem_tmp;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonTypeName;
+import jakarta.annotation.Generated;
+import jakarta.validation.Valid;
+
+import java.util.Objects;
+import java.util.UUID;
+
+/**
+ * InterrogationIdentifiersDto
+ */
+
+@JsonTypeName("InterrogationIdentifiers")
+@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", date = "2024-08-30T10:25:29.966974800+02:00[Europe/Paris]", comments = "Generator version: 7.8.0")
+public class InterrogationIdentifiersDto {
+
+ private UUID interrogationId;
+
+ private UUID surveyUnitId;
+
+ private String originId;
+
+ public InterrogationIdentifiersDto interrogationId(UUID interrogationId) {
+ this.interrogationId = interrogationId;
+ return this;
+ }
+
+ /**
+ * Get interrogationId
+ * @return interrogationId
+ */
+ @Valid
+ @JsonProperty("interrogationId")
+ public UUID getInterrogationId() {
+ return interrogationId;
+ }
+
+ public void setInterrogationId(UUID interrogationId) {
+ this.interrogationId = interrogationId;
+ }
+
+ public InterrogationIdentifiersDto surveyUnitId(UUID surveyUnitId) {
+ this.surveyUnitId = surveyUnitId;
+ return this;
+ }
+
+ /**
+ * Get surveyUnitId
+ * @return surveyUnitId
+ */
+ @Valid
+ @JsonProperty("surveyUnitId")
+ public UUID getSurveyUnitId() {
+ return surveyUnitId;
+ }
+
+ public void setSurveyUnitId(UUID surveyUnitId) {
+ this.surveyUnitId = surveyUnitId;
+ }
+
+ public InterrogationIdentifiersDto originId(String originId) {
+ this.originId = originId;
+ return this;
+ }
+
+ /**
+ * Get originId
+ * @return originId
+ */
+
+ @JsonProperty("originId")
+ public String getOriginId() {
+ return originId;
+ }
+
+ public void setOriginId(String originId) {
+ this.originId = originId;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ InterrogationIdentifiersDto interrogationIdentifiers = (InterrogationIdentifiersDto) o;
+ return Objects.equals(this.interrogationId, interrogationIdentifiers.interrogationId) &&
+ Objects.equals(this.surveyUnitId, interrogationIdentifiers.surveyUnitId) &&
+ Objects.equals(this.originId, interrogationIdentifiers.originId);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(interrogationId, surveyUnitId, originId);
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("class InterrogationIdentifiersDto {\n");
+ sb.append(" interrogationId: ").append(toIndentedString(interrogationId)).append("\n");
+ sb.append(" surveyUnitId: ").append(toIndentedString(surveyUnitId)).append("\n");
+ sb.append(" originId: ").append(toIndentedString(originId)).append("\n");
+ sb.append("}");
+ return sb.toString();
+ }
+
+ /**
+ * Convert the given object to string with each line indented by 4 spaces
+ * (except the first line).
+ */
+ private String toIndentedString(Object o) {
+ if (o == null) {
+ return "null";
+ }
+ return o.toString().replace("\n", "\n ");
+ }
+
+ public static class Builder {
+
+ private InterrogationIdentifiersDto instance;
+
+ public Builder() {
+ this(new InterrogationIdentifiersDto());
+ }
+
+ protected Builder(InterrogationIdentifiersDto instance) {
+ this.instance = instance;
+ }
+
+ protected Builder copyOf(InterrogationIdentifiersDto value) {
+ this.instance.setInterrogationId(value.interrogationId);
+ this.instance.setSurveyUnitId(value.surveyUnitId);
+ this.instance.setOriginId(value.originId);
+ return this;
+ }
+
+ public Builder interrogationId(UUID interrogationId) {
+ this.instance.interrogationId(interrogationId);
+ return this;
+ }
+
+ public Builder surveyUnitId(UUID surveyUnitId) {
+ this.instance.surveyUnitId(surveyUnitId);
+ return this;
+ }
+
+ public Builder originId(String originId) {
+ this.instance.originId(originId);
+ return this;
+ }
+
+ /**
+ * returns a built InterrogationIdentifiersDto instance.
+ *
+ * The builder is not reusable (NullPointerException)
+ */
+ public InterrogationIdentifiersDto build() {
+ try {
+ return this.instance;
+ } finally {
+ // ensure that this.instance is not reused
+ this.instance = null;
+ }
+ }
+
+ @Override
+ public String toString() {
+ return getClass() + "=(" + instance + ")";
+ }
+ }
+
+ /**
+ * Create a builder with no initialized field (except for the default values).
+ */
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ /**
+ * Create a builder with a shallow copy of this instance.
+ */
+ public Builder toBuilder() {
+ Builder builder = new Builder();
+ return builder.copyOf(this);
+ }
+
+}
+
diff --git a/src/main/java/fr/insee/protools/backend/dto/sabiane/pilotage/AddressDto.java b/src/main/java/fr/insee/protools/backend/dto/sabiane/pilotage/AddressDto.java
deleted file mode 100644
index cd330d1c..00000000
--- a/src/main/java/fr/insee/protools/backend/dto/sabiane/pilotage/AddressDto.java
+++ /dev/null
@@ -1,57 +0,0 @@
-package fr.insee.protools.backend.dto.sabiane.pilotage;
-
-import com.fasterxml.jackson.annotation.JsonInclude;
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-
-@Data
-@AllArgsConstructor
-@Builder
-@NoArgsConstructor
-@JsonInclude(JsonInclude.Include.NON_NULL)
-public class AddressDto {
-
- /**
- * First line of the AdressDto
- */
- private String l1;
-
- /**
- * Second line of the AdressDto
- */
- private String l2;
-
- /**
- * Third line of the AdressDto
- */
- private String l3;
-
- /**
- * Fourth line of the AdressDto
- */
- private String l4;
-
- /**
- * Fifth line of the AdressDto
- */
- private String l5;
-
- /**
- * Sixtth line of the AdressDto
- */
- private String l6;
-
- /**
- * Seventh line of the AdressDto
- */
- private String l7;
-
- private Boolean elevator;
- private String building;
- private String floor;
- private String door;
- private String staircase;
- private Boolean cityPriorityDistrict;
-}
\ No newline at end of file
diff --git a/src/main/java/fr/insee/protools/backend/dto/sabiane/pilotage/CampaignContextDto.java b/src/main/java/fr/insee/protools/backend/dto/sabiane/pilotage/CampaignContextDto.java
deleted file mode 100644
index dbc66489..00000000
--- a/src/main/java/fr/insee/protools/backend/dto/sabiane/pilotage/CampaignContextDto.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package fr.insee.protools.backend.dto.sabiane.pilotage;
-
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-
-import java.util.List;
-
-@Data
-@AllArgsConstructor
-@Builder
-@NoArgsConstructor
-public class CampaignContextDto {
- private String campaign;
- private String campaignLabel;
- private List visibilities;
- private List referents;
- private String email;
- private IdentificationConfiguration identificationConfiguration;
- private ContactOutcomeConfiguration contactOutcomeConfiguration;
- private ContactAttemptConfiguration contactAttemptConfiguration;
-}
\ No newline at end of file
diff --git a/src/main/java/fr/insee/protools/backend/dto/sabiane/pilotage/ContactAttemptConfiguration.java b/src/main/java/fr/insee/protools/backend/dto/sabiane/pilotage/ContactAttemptConfiguration.java
deleted file mode 100644
index 904aa294..00000000
--- a/src/main/java/fr/insee/protools/backend/dto/sabiane/pilotage/ContactAttemptConfiguration.java
+++ /dev/null
@@ -1,47 +0,0 @@
-package fr.insee.protools.backend.dto.sabiane.pilotage;
-
-public enum ContactAttemptConfiguration {
- F2F("faf"), TEL("tel");
-
- /**
- * label of the ContactAttemptConfiguration
- */
- private final String label;
-
- /**
- * Defaut constructor for a ContactAttemptConfiguration
- *
- * @param label
- */
- ContactAttemptConfiguration(String label) {
- this.label = label;
- }
-
- /**
- * Get the label for a ContactAttemptConfiguration
- *
- * @return label
- */
- public String getLabel() {
- return label;
- }
-
- public static ContactAttemptConfiguration valueOfLabel(String label) {
- for (ContactAttemptConfiguration e : values()) {
- if (e.label.equalsIgnoreCase(label)) {
- return e;
- }
- }
- throw new IllegalArgumentException("No enum constant with value="+label+ " for class " + ContactAttemptConfiguration.class.getCanonicalName());
- }
- public static String[] labels(){
- String[] results = new String[values().length];
- int i=0;
- for (var e : values()) {
- results[i]=e.label;
- i++;
- }
- return results;
- }
-
-}
\ No newline at end of file
diff --git a/src/main/java/fr/insee/protools/backend/dto/sabiane/pilotage/ContactOutcomeConfiguration.java b/src/main/java/fr/insee/protools/backend/dto/sabiane/pilotage/ContactOutcomeConfiguration.java
deleted file mode 100644
index 2d00cb44..00000000
--- a/src/main/java/fr/insee/protools/backend/dto/sabiane/pilotage/ContactOutcomeConfiguration.java
+++ /dev/null
@@ -1,47 +0,0 @@
-package fr.insee.protools.backend.dto.sabiane.pilotage;
-
-public enum ContactOutcomeConfiguration {
- F2F("faf"), TEL("tel");
-
- /**
- * label of the ContactOutcomeConfiguration
- */
- private final String label;
-
- /**
- * Defaut constructor for a ContactOutcomeConfiguration
- *
- * @param label
- */
- ContactOutcomeConfiguration(String label) {
- this.label = label;
- }
-
- /**
- * Get the label for a ContactOutcomeConfiguration
- *
- * @return label
- */
- public String getLabel() {
- return label;
- }
-
- public static ContactOutcomeConfiguration valueOfLabel(String label) {
- for (ContactOutcomeConfiguration e : values()) {
- if (e.label.equalsIgnoreCase(label)) {
- return e;
- }
- }
- throw new IllegalArgumentException("No enum constant with value="+label+ " for class " + ContactOutcomeConfiguration.class.getCanonicalName());
- }
-
- public static String[] labels(){
- String[] results = new String[values().length];
- int i=0;
- for (var e : values()) {
- results[i]=e.label;
- i++;
- }
- return results;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/fr/insee/protools/backend/dto/sabiane/pilotage/IdentificationConfiguration.java b/src/main/java/fr/insee/protools/backend/dto/sabiane/pilotage/IdentificationConfiguration.java
deleted file mode 100644
index a8a10735..00000000
--- a/src/main/java/fr/insee/protools/backend/dto/sabiane/pilotage/IdentificationConfiguration.java
+++ /dev/null
@@ -1,49 +0,0 @@
-package fr.insee.protools.backend.dto.sabiane.pilotage;
-
-public enum IdentificationConfiguration {
- //"Identification - Access - Situation - Category - Occupant"
- IASCO("faf_logement"),
- NOIDENT("aucun");
-
- /**
- * label of the IdentificationConfiguration
- */
- private final String label;
-
- /**
- * Defaut constructor for a IdentificationConfiguration
- *
- * @param label
- */
- IdentificationConfiguration(String label) {
- this.label = label;
- }
-
- /**
- * Get the label for a IdentificationConfiguration
- *
- * @return label
- */
- public String getLabel() {
- return label;
- }
-
- public static IdentificationConfiguration valueOfLabel(String label) {
- for (IdentificationConfiguration e : values()) {
- if (e.label.equalsIgnoreCase(label)) {
- return e;
- }
- }
- throw new IllegalArgumentException("No enum constant with value="+label+ " for class " + IdentificationConfiguration.class.getCanonicalName());
- }
-
- public static String[] labels(){
- String[] results = new String[values().length];
- int i=0;
- for (var e : values()) {
- results[i]=e.label;
- i++;
- }
- return results;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/fr/insee/protools/backend/dto/sabiane/pilotage/PhoneNumber.java b/src/main/java/fr/insee/protools/backend/dto/sabiane/pilotage/PhoneNumber.java
deleted file mode 100644
index 16d354b6..00000000
--- a/src/main/java/fr/insee/protools/backend/dto/sabiane/pilotage/PhoneNumber.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package fr.insee.protools.backend.dto.sabiane.pilotage;
-
-
-public class PhoneNumber {
-
- Source source;
- boolean favorite;
- String number;
-
-}
\ No newline at end of file
diff --git a/src/main/java/fr/insee/protools/backend/dto/sabiane/pilotage/ReferentDto.java b/src/main/java/fr/insee/protools/backend/dto/sabiane/pilotage/ReferentDto.java
deleted file mode 100644
index 91a96adc..00000000
--- a/src/main/java/fr/insee/protools/backend/dto/sabiane/pilotage/ReferentDto.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package fr.insee.protools.backend.dto.sabiane.pilotage;
-
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-
-@Data
-@Builder
-@AllArgsConstructor
-@NoArgsConstructor
-public class ReferentDto {
- private String firstName;
- private String lastName;
- private String phoneNumber;
- private String role;
-}
\ No newline at end of file
diff --git a/src/main/java/fr/insee/protools/backend/dto/sabiane/pilotage/SabianePersonDto.java b/src/main/java/fr/insee/protools/backend/dto/sabiane/pilotage/SabianePersonDto.java
deleted file mode 100644
index fe0948e6..00000000
--- a/src/main/java/fr/insee/protools/backend/dto/sabiane/pilotage/SabianePersonDto.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package fr.insee.protools.backend.dto.sabiane.pilotage;
-
-import com.fasterxml.jackson.annotation.JsonInclude;
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-
-import java.util.List;
-
-@JsonInclude(JsonInclude.Include.NON_NULL)
-@Data
-@AllArgsConstructor
-@Builder
-@NoArgsConstructor
-public class SabianePersonDto {
- private Long id;
- private SabianeTitle title;
- private String firstName;
- private String lastName;
- private String email;
- private Long birthdate;
-
- private Boolean favoriteEmail;
- private Boolean privileged;
- private List phoneNumbers;
-
-
-}
diff --git a/src/main/java/fr/insee/protools/backend/dto/sabiane/pilotage/SabianePhoneNumberDto.java b/src/main/java/fr/insee/protools/backend/dto/sabiane/pilotage/SabianePhoneNumberDto.java
deleted file mode 100644
index 4c64641f..00000000
--- a/src/main/java/fr/insee/protools/backend/dto/sabiane/pilotage/SabianePhoneNumberDto.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package fr.insee.protools.backend.dto.sabiane.pilotage;
-
-
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-
-@Data
-@AllArgsConstructor
-@Builder
-@NoArgsConstructor
-public class SabianePhoneNumberDto {
-
- private Source source;
- private boolean favorite;
- private String number;
-}
\ No newline at end of file
diff --git a/src/main/java/fr/insee/protools/backend/dto/sabiane/pilotage/SabianeTitle.java b/src/main/java/fr/insee/protools/backend/dto/sabiane/pilotage/SabianeTitle.java
deleted file mode 100644
index 4f3d5233..00000000
--- a/src/main/java/fr/insee/protools/backend/dto/sabiane/pilotage/SabianeTitle.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package fr.insee.protools.backend.dto.sabiane.pilotage;
-
-import lombok.Getter;
-
-@Getter
-public enum SabianeTitle {
- MISTER("M","Mister"), MISS("MME","MISS");
-
- private final String frenchCivility;
- private final String sabianeTitle;
- SabianeTitle(String frenchCivility, String sabianeTitle) {
- this.frenchCivility = frenchCivility;
- this.sabianeTitle = sabianeTitle;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/fr/insee/protools/backend/dto/sabiane/pilotage/SampleIdentifiersDto.java b/src/main/java/fr/insee/protools/backend/dto/sabiane/pilotage/SampleIdentifiersDto.java
deleted file mode 100644
index 7e5a196e..00000000
--- a/src/main/java/fr/insee/protools/backend/dto/sabiane/pilotage/SampleIdentifiersDto.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package fr.insee.protools.backend.dto.sabiane.pilotage;
-
-
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-
-@Data
-@NoArgsConstructor
-@AllArgsConstructor
-@Builder
-public class SampleIdentifiersDto {
- private Integer bs;
- private String ec;
- private Integer le;
- private Integer noi;
- private Integer numfa;
- private Integer rges;
- private Long ssech;
- private Integer nolog;
- private Integer nole;
- private String autre;
- private String nograp;
-
-}
\ No newline at end of file
diff --git a/src/main/java/fr/insee/protools/backend/dto/sabiane/pilotage/Source.java b/src/main/java/fr/insee/protools/backend/dto/sabiane/pilotage/Source.java
deleted file mode 100644
index 36eb27ab..00000000
--- a/src/main/java/fr/insee/protools/backend/dto/sabiane/pilotage/Source.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package fr.insee.protools.backend.dto.sabiane.pilotage;
-
-public enum Source {
- FISCAL, DIRECTORY, INTERVIEWER
-}
\ No newline at end of file
diff --git a/src/main/java/fr/insee/protools/backend/dto/sabiane/pilotage/StateDto.java b/src/main/java/fr/insee/protools/backend/dto/sabiane/pilotage/StateDto.java
deleted file mode 100644
index c20db44d..00000000
--- a/src/main/java/fr/insee/protools/backend/dto/sabiane/pilotage/StateDto.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package fr.insee.protools.backend.dto.sabiane.pilotage;
-
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-
-@Data
-@NoArgsConstructor
-@AllArgsConstructor
-@Builder
-public class StateDto {
-
- private Long date;
- private StateType type;
-}
\ No newline at end of file
diff --git a/src/main/java/fr/insee/protools/backend/dto/sabiane/pilotage/StateType.java b/src/main/java/fr/insee/protools/backend/dto/sabiane/pilotage/StateType.java
deleted file mode 100644
index 8ba34dc2..00000000
--- a/src/main/java/fr/insee/protools/backend/dto/sabiane/pilotage/StateType.java
+++ /dev/null
@@ -1,51 +0,0 @@
-package fr.insee.protools.backend.dto.sabiane.pilotage;
-
-import lombok.NoArgsConstructor;
-
-/**
- * The possible types of a State entity
- * @author scorcaud
- *
- */
-@NoArgsConstructor
-public enum StateType {
-
- NVM("Not visible to management"),
- NNS("Not Assigned, not started"),
- ANV("Assigned Not visible to interviewer"),
- VIN("Visible to the interviewer and not clickable"),
- VIC("Visible to the interviewer and clickable"),
- PRC("Preparing contact"),
- AOC("At least one contact made"),
- APS("Appointment scheduled"),
- INS("Interview started"),
- WFT("Waiting for transmission"),
- WFS("Waiting for synchronization"),
- TBR("To be reviewed"),
- FIN("Finalized"),
- CLO("Closed"),
- NVA("Not Available to All");
-
- /**
- * label of the State type
- */
- private String label;
-
- /**
- * Defaut constructor for a StateType
- *
- * @param label
- */
- StateType(String label) {
- this.label = label;
- }
-
- /**
- * Get the label for a StateType
- *
- * @return label
- */
- public String getLabel() {
- return label;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/fr/insee/protools/backend/dto/sabiane/pilotage/SurveyUnitContextDto.java b/src/main/java/fr/insee/protools/backend/dto/sabiane/pilotage/SurveyUnitContextDto.java
deleted file mode 100644
index 9a309a3b..00000000
--- a/src/main/java/fr/insee/protools/backend/dto/sabiane/pilotage/SurveyUnitContextDto.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package fr.insee.protools.backend.dto.sabiane.pilotage;
-
-import java.util.List;
-
-import com.fasterxml.jackson.annotation.JsonInclude;
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-
-@Data
-@AllArgsConstructor
-@Builder
-@NoArgsConstructor
-@JsonInclude(JsonInclude.Include.NON_NULL)
-public class SurveyUnitContextDto {
- private String id;
- private List persons;
- private AddressDto address;
- private String organizationUnitId;
- private Boolean priority;
- private String campaign;
- private SampleIdentifiersDto sampleIdentifiers;
- private List states;
-}
\ No newline at end of file
diff --git a/src/main/java/fr/insee/protools/backend/dto/sabiane/pilotage/VisibilityContextDto.java b/src/main/java/fr/insee/protools/backend/dto/sabiane/pilotage/VisibilityContextDto.java
deleted file mode 100644
index 8536dba5..00000000
--- a/src/main/java/fr/insee/protools/backend/dto/sabiane/pilotage/VisibilityContextDto.java
+++ /dev/null
@@ -1,51 +0,0 @@
-package fr.insee.protools.backend.dto.sabiane.pilotage;
-
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-
-@AllArgsConstructor
-@Data
-@Builder
-@NoArgsConstructor
-public class VisibilityContextDto {
-
-
- /**
- * Organizational unit of the visibility
- */
- private String organizationalUnit;
-
- /**
- * Collection start date of the visibility
- */
- private Long collectionStartDate;
-
- /**
- * Collection end date of the visibility
- */
- private Long collectionEndDate;
-
- /**
- * Identification phase start date of the visibility
- */
- private Long identificationPhaseStartDate;
-
- /**
- * interviewer start date of the visibility
- */
- private Long interviewerStartDate;
-
- /**
- * Manager start date of the visibility
- */
- private Long managementStartDate;
-
- /**
- * End date of the visibility
- */
- private Long endDate;
-
-
-}
\ No newline at end of file
diff --git a/src/main/java/fr/insee/protools/backend/exception/ProtoolsProcessFlowBPMNError.java b/src/main/java/fr/insee/protools/backend/exception/ProtoolsProcessFlowBPMNError.java
new file mode 100644
index 00000000..da390eb4
--- /dev/null
+++ b/src/main/java/fr/insee/protools/backend/exception/ProtoolsProcessFlowBPMNError.java
@@ -0,0 +1,9 @@
+package fr.insee.protools.backend.exception;
+
+import static fr.insee.protools.backend.service.BPMNErrorCode.BPMNERROR_CODE_DEFAULT;
+
+public class ProtoolsProcessFlowBPMNError extends ProtoolsBpmnError {
+ public ProtoolsProcessFlowBPMNError(String message) {
+ super(BPMNERROR_CODE_DEFAULT, message);
+ }
+}
diff --git a/src/main/java/fr/insee/protools/backend/flowable/types/ListLong.java b/src/main/java/fr/insee/protools/backend/flowable/types/ListLong.java
index 0b9a6f79..6af0f907 100644
--- a/src/main/java/fr/insee/protools/backend/flowable/types/ListLong.java
+++ b/src/main/java/fr/insee/protools/backend/flowable/types/ListLong.java
@@ -1,13 +1,13 @@
package fr.insee.protools.backend.flowable.types;
-import java.util.Arrays;
-import java.util.List;
-import java.util.stream.Collectors;
-
import org.flowable.common.engine.api.FlowableIllegalArgumentException;
import org.flowable.variable.api.types.ValueFields;
import org.flowable.variable.api.types.VariableType;
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
+
public class ListLong implements VariableType {
@@ -39,7 +39,7 @@ public Object getValue(ValueFields valueFields) {
try {
return Arrays.stream(valStr.split(","))
.map(Long::parseLong)
- .collect(Collectors.toList());
+ .toList();
} catch (NumberFormatException e) {
throw new FlowableIllegalArgumentException("The given variable value is not comma separated list of Long: '" + valStr+ "'", e);
}
diff --git a/src/main/java/fr/insee/protools/backend/flowcontrol/FlowcontrolIsSUToFollowUp.java b/src/main/java/fr/insee/protools/backend/flowcontrol/FlowcontrolIsSUToFollowUp.java
deleted file mode 100644
index e33efc96..00000000
--- a/src/main/java/fr/insee/protools/backend/flowcontrol/FlowcontrolIsSUToFollowUp.java
+++ /dev/null
@@ -1,52 +0,0 @@
-package fr.insee.protools.backend.flowcontrol;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import fr.insee.protools.backend.service.DelegateContextVerifier;
-import fr.insee.protools.backend.service.context.ContextService;
-import fr.insee.protools.backend.service.utils.FlowableVariableUtils;
-import lombok.RequiredArgsConstructor;
-import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.lang3.tuple.Triple;
-import org.flowable.engine.delegate.DelegateExecution;
-import org.flowable.engine.delegate.JavaDelegate;
-import org.springframework.stereotype.Service;
-
-import java.time.Instant;
-
-import static fr.insee.protools.backend.service.FlowableVariableNameConstants.*;
-
-@Service
-@Slf4j
-@RequiredArgsConstructor
-public class FlowcontrolIsSUToFollowUp implements JavaDelegate, DelegateContextVerifier {
-
- private final ContextService protoolsContext;
-
- @Override
- public void execute(DelegateExecution execution) {
- Boolean isToFollowUp = false;
-
- JsonNode contextRootNode = protoolsContext.getContextByProcessInstance(execution.getProcessInstanceId());
- checkContextOrThrow(log, execution.getProcessInstanceId(), contextRootNode);
-
- Long currentPartitionId = FlowableVariableUtils.getVariableOrThrow(execution, VARNAME_CURRENT_PARTITION_ID, Long.class);
- // checkContextOrThrow(log,execution.getProcessInstanceId(), contextRootNode);
-
- Triple suItem = FlowableVariableUtils.getVariableOrThrow(execution, VARNAME_SU_CREATION_ITEM, Triple.class);
- log.info("ProcessInstanceId={} - suItem={} begin", execution.getProcessInstanceId(), suItem);
-
- Instant openingInstant = suItem.getLeft();
- //TODO : à enlever ; mettre de la conf (période ou date fixe) sur la partition et récupérer la conf de la partition
- Instant dateRelance = openingInstant.plusSeconds(3 * 60l);
-
- if (openingInstant != null && dateRelance.isBefore(Instant.now())) {
- isToFollowUp = true;
- }
- execution.getParent().setVariableLocal(VARNAME_SU_IS_TO_FOLLOWUP, isToFollowUp);
-
- //Extract SU id and partition id as it will be used in following tasks
- execution.getParent().setVariableLocal(VARNAME_REM_SURVEY_UNIT_IDENTIFIER, suItem.getRight());
- execution.getParent().setVariableLocal(VARNAME_CURRENT_PARTITION_ID, suItem.getMiddle());
- log.info("ProcessInstanceId={} - suItem={} - isToFollowUp={} end", execution.getProcessInstanceId(), suItem, isToFollowUp);
- }
-}
diff --git a/src/main/java/fr/insee/protools/backend/logging/LoggingHelper.java b/src/main/java/fr/insee/protools/backend/logging/LoggingHelper.java
new file mode 100644
index 00000000..013e1f55
--- /dev/null
+++ b/src/main/java/fr/insee/protools/backend/logging/LoggingHelper.java
@@ -0,0 +1,41 @@
+package fr.insee.protools.backend.logging;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.slf4j.Logger;
+import org.slf4j.event.Level;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+
+
+public class LoggingHelper {
+
+ @Retention(RetentionPolicy.RUNTIME)
+ @Target(ElementType.METHOD)
+ public @interface ExcludeFromJacocoGeneratedReport {}
+
+ @ExcludeFromJacocoGeneratedReport
+ public static void logJson(String msg, Object dto, Logger logger, Level level) {
+ if (logger.isEnabledForLevel(level)) {
+ try {
+ String json = new ObjectMapper().writeValueAsString(dto);
+ String logLine = msg +" - " + json;
+ switch (level) {
+ case TRACE -> logger.trace(logLine);
+ case DEBUG -> logger.debug(logLine);
+ case INFO -> logger.info(logLine);
+ case WARN -> logger.warn(logLine);
+ case ERROR -> logger.error(logLine);
+ default -> logger.trace(logLine);
+ }
+ } catch (JsonProcessingException e) {
+ throw new RuntimeException("Failed to parse json");
+ }
+ }
+ }
+ private LoggingHelper(){}
+}
diff --git a/src/main/java/fr/insee/protools/backend/repository/IUniteEnquetee.java b/src/main/java/fr/insee/protools/backend/repository/IUniteEnquetee.java
new file mode 100644
index 00000000..136a6f1c
--- /dev/null
+++ b/src/main/java/fr/insee/protools/backend/repository/IUniteEnquetee.java
@@ -0,0 +1,20 @@
+package fr.insee.protools.backend.repository;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.List;
+
+public interface IUniteEnquetee {
+
+ @Transactional
+ void addManyUniteEnquetee(List listeUe);
+
+ void addManyUniteEnquetee(List listeUe, String processInstanceId, String currentActivityId);
+
+ void addManyUniteEnqueteeDeleteColonneClass(List listeUe);
+
+ boolean isTerminated(String processInstanceId, String currentActivityId, long numberCommandes);
+
+ long getCommandesByProcessInstanceIdAndCurrentActivityId(String processInstanceId, String currentActivityId);
+}
\ No newline at end of file
diff --git a/src/main/java/fr/insee/protools/backend/repository/UniteEnqueteeImpl.java b/src/main/java/fr/insee/protools/backend/repository/UniteEnqueteeImpl.java
new file mode 100644
index 00000000..5b358063
--- /dev/null
+++ b/src/main/java/fr/insee/protools/backend/repository/UniteEnqueteeImpl.java
@@ -0,0 +1,132 @@
+package fr.insee.protools.backend.repository;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.mongodb.BasicDBObject;
+import lombok.Getter;
+import lombok.RequiredArgsConstructor;
+import lombok.Setter;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.mongodb.core.MongoTemplate;
+import org.springframework.data.mongodb.core.convert.DefaultMongoTypeMapper;
+import org.springframework.data.mongodb.core.convert.MappingMongoConverter;
+import org.springframework.data.mongodb.core.mapping.MongoMappingContext;
+import org.springframework.data.mongodb.core.query.Criteria;
+import org.springframework.data.mongodb.core.query.Query;
+import org.springframework.stereotype.Repository;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.UUID;
+
+import static com.fasterxml.jackson.databind.DeserializationFeature.FAIL_ON_MISSING_CREATOR_PROPERTIES;
+import static com.fasterxml.jackson.databind.DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES;
+import static org.codehaus.groovy.runtime.DefaultGroovyMethods.collect;
+import static org.springframework.data.mongodb.core.query.Criteria.where;
+import static org.springframework.data.mongodb.core.query.Query.query;
+
+@RequiredArgsConstructor
+@Repository
+@Slf4j
+public class UniteEnqueteeImpl implements IUniteEnquetee {
+
+ private final MongoTemplate mongoTemplate;
+
+ @Setter
+ @Getter
+ private String processInstanceId;
+ @Setter
+ @Getter
+ private String currentActivityId;
+
+ private static final ObjectMapper objectMapper =
+ new ObjectMapper()
+ .configure(FAIL_ON_UNKNOWN_PROPERTIES, false)
+ .configure(FAIL_ON_MISSING_CREATOR_PROPERTIES, true);
+
+
+ private BasicDBObject getUEUpdate(JsonNode test){
+ String correlationID = UUID.randomUUID().toString();
+ BasicDBObject dbObject = new BasicDBObject();
+ HashMap keyValuePairs = null;
+ keyValuePairs = new HashMap<>();
+ try {
+ keyValuePairs.put("payload", new ObjectMapper().writeValueAsString(test));
+ } catch (JsonProcessingException e) {
+ throw new RuntimeException(e);
+ }
+ keyValuePairs.put("correlationID", correlationID);
+ keyValuePairs.put("inProgress", false);
+ keyValuePairs.put("done", false);
+ keyValuePairs.put("processInstanceID", getProcessInstanceId());
+ keyValuePairs.put("currentActivityID", getCurrentActivityId());
+ dbObject.putAll(keyValuePairs);
+ return dbObject;
+ }
+
+
+ @Override
+ public void addManyUniteEnquetee(List listeUe) {
+ List bo = listeUe.parallelStream()
+ .map(this::getUEUpdate)
+ .toList();
+ mongoTemplate.insert(bo, "commandes");
+ }
+
+ @Override
+ public void addManyUniteEnqueteeDeleteColonneClass(List listeUe) {
+ List bo = listeUe.parallelStream()
+ .map(this::getUEUpdate)
+ .toList();
+ //remove _class
+ MappingMongoConverter converter =
+ new MappingMongoConverter(mongoTemplate.getMongoDatabaseFactory(), new MongoMappingContext());
+ converter.setTypeMapper(new DefaultMongoTypeMapper(null));
+ MongoTemplate mongoTemplate2 = new MongoTemplate(mongoTemplate.getMongoDatabaseFactory(), converter);
+ mongoTemplate2.insert(bo, "commandes");
+ }
+
+ @Override
+ public void addManyUniteEnquetee(List listeUe, String processInstanceId, String currentActivityId) {
+ this.setProcessInstanceId(processInstanceId);
+ this.setCurrentActivityId(currentActivityId);
+// List bo = listeUe.parallelStream()
+// .map(this::getUEUpdate)
+// .toList();
+ //remove _class
+ MappingMongoConverter converter =
+ new MappingMongoConverter(mongoTemplate.getMongoDatabaseFactory(), new MongoMappingContext());
+ converter.setTypeMapper(new DefaultMongoTypeMapper(null));
+ MongoTemplate mongoTemplate2 = new MongoTemplate(mongoTemplate.getMongoDatabaseFactory(), converter);
+ mongoTemplate2.insert(listeUe, "commandes");
+ }
+
+ @Override
+ public boolean isTerminated(String processInstanceId, String currentActivityId, long numberCommandes) {
+ log.debug("UniteEnqueteeImpl.isTerminated.");
+ boolean result=false;
+ Query query = new Query();
+ query.addCriteria(Criteria.where("processInstanceID").is(processInstanceId));
+ query.addCriteria(Criteria.where("currentActivityID").is(currentActivityId));
+ query.addCriteria(where("inProgress").is(true).and("done").is(true));
+ List listeCommandes = mongoTemplate.find(query, String.class, "commandes");
+ if(!listeCommandes.isEmpty() && listeCommandes.size()==numberCommandes){
+ result=true;
+ }
+ return result;
+ }
+
+ @Override
+ public long getCommandesByProcessInstanceIdAndCurrentActivityId(String processInstanceId, String currentActivityId) {
+ log.debug("getCommandesByProcessInstanceIdAndCurrentActivityId : " + processInstanceId + "|" + currentActivityId);
+ long result=0;
+ Query query = new Query();
+ query.addCriteria(Criteria.where("processInstanceID").is(processInstanceId));
+ query.addCriteria(Criteria.where("currentActivityID").is(currentActivityId));
+ result = mongoTemplate.count(query, String.class, "commandes");
+ return result;
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/java/fr/insee/protools/backend/restclient/RestClientHelper.java b/src/main/java/fr/insee/protools/backend/restclient/RestClientHelper.java
new file mode 100644
index 00000000..b7966cba
--- /dev/null
+++ b/src/main/java/fr/insee/protools/backend/restclient/RestClientHelper.java
@@ -0,0 +1,218 @@
+package fr.insee.protools.backend.restclient;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ArrayNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import fr.insee.protools.backend.restclient.configuration.APIProperties;
+import fr.insee.protools.backend.restclient.configuration.ApiConfigProperties;
+import fr.insee.protools.backend.restclient.exception.ApiNotConfiguredBPMNError;
+import fr.insee.protools.backend.restclient.exception.KeycloakTokenConfigBPMNError;
+import fr.insee.protools.backend.restclient.exception.runtime.HttpClient4xxBPMNError;
+import fr.insee.protools.backend.restclient.exception.runtime.HttpClient5xxBPMNError;
+import fr.insee.protools.backend.restclient.keycloak.KeycloakService;
+import io.netty.handler.logging.LogLevel;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.http.HttpRequest;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.HttpStatusCode;
+import org.springframework.http.client.ClientHttpResponse;
+import org.springframework.http.client.ReactorNettyClientRequestFactory;
+import org.springframework.lang.Nullable;
+import org.springframework.stereotype.Component;
+import org.springframework.util.StreamUtils;
+import org.springframework.web.client.RestClient;
+import reactor.netty.http.client.HttpClient;
+import reactor.netty.transport.logging.AdvancedByteBufFormat;
+
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.util.*;
+
+/**
+ * Helper class for RestClient
+ */
+@Component
+@Slf4j
+public class RestClientHelper {
+ private final KeycloakService keycloakService;
+ private final ApiConfigProperties apiConfigProperties;
+
+ private final EnumMap initializedClients = new EnumMap<>(ApiConfigProperties.KNOWN_API.class);
+
+ public RestClientHelper(KeycloakService keycloakService, ApiConfigProperties apiConfigProperties) {
+ this.keycloakService = keycloakService;
+ this.apiConfigProperties = apiConfigProperties;
+ }
+
+ //I cannot have a single builder and store it in a private variable because every call to .filter(...) append a new filter to the builder
+ //Still true for Restclient?
+ public RestClient.Builder getBuilder() {
+ return RestClient.builder()
+ .defaultStatusHandler(HttpStatusCode::isError, this::handleError)
+ .requestFactory(new ReactorNettyClientRequestFactory(HttpClient.create()
+ //Handles a proxy conf passed on system properties
+ .proxyWithSystemProperties()
+ //enable logging of request/responses
+ //configurable in properties as if it was this class logers
+ .wiretap(this.getClass().getCanonicalName(), LogLevel.DEBUG, AdvancedByteBufFormat.TEXTUAL)));
+ }
+
+ private void handleError(HttpRequest httpRequest, ClientHttpResponse clientResponse) throws IOException {
+ String errorMsg = String.format("request=[%s %s] - statusCode=[%s]",
+ httpRequest.getMethod(),httpRequest.getURI(), clientResponse.getStatusCode());
+ if (clientResponse.getStatusCode().equals(HttpStatusCode.valueOf(HttpStatus.UNAUTHORIZED.value()))) {
+ errorMsg = "HttpStatus.UNAUTHORIZED. WWW-Authenticate=[" + String.join("", clientResponse.getHeaders().get("WWW-Authenticate")) + "]";
+ }
+
+ String finalErrorMsg = errorMsg;
+ String errorMessage = StreamUtils.copyToString(clientResponse.getBody(), StandardCharsets.UTF_8);
+ if(errorMessage.isBlank()){
+ errorMessage= "No error message provided by API";
+ }
+ if (clientResponse.getStatusCode().is4xxClientError()) {
+ throw new HttpClient4xxBPMNError(finalErrorMsg + " - " + errorMessage, clientResponse.getStatusCode());
+ } else {
+ throw new HttpClient5xxBPMNError(finalErrorMsg + " - " + errorMessage);
+ }
+ }
+
+
+ /**
+ * init a new RestClient proxy aware (default one ignore system proxy)
+ */
+ public RestClient getRestClient() {
+ return getBuilder()
+ .build();
+ }
+
+
+ /**
+ * Get a RestClient preconfigured for proxy and able to get the JWT token required for authentication
+ *
+ * @param api the client will connect to this api
+ * @return preconfigured RestClient for the api
+ */
+ public RestClient getRestClient(ApiConfigProperties.KNOWN_API api) {
+ APIProperties apiProperties = apiConfigProperties.getAPIProperties(api);
+ if (apiProperties == null) {
+ throw new ApiNotConfiguredBPMNError(String.format("API %s is not configured in properties", api));
+ } else if (Boolean.FALSE.equals(apiProperties.getEnabled())) {
+ throw new ApiNotConfiguredBPMNError(String.format("API %s is disabled in properties", api));
+ }
+ return initializedClients.computeIfAbsent(api,
+ knownApi ->
+ getBuilder()
+ .baseUrl(apiProperties.getUrl())
+ .requestInitializer(new RestClientKeycloakHeadersInitializer(keycloakService, apiProperties.getAuth()))
+ .build());
+ }
+
+
+ public Map getTokenDetailsByAPI(){
+ Map result = new HashMap<>();
+ for (var api :ApiConfigProperties.KNOWN_API.values() ) {
+ try {
+ APIProperties apiProperties = apiConfigProperties.getAPIProperties(api);
+ if (apiProperties == null) {
+ throw new ApiNotConfiguredBPMNError(String.format("API %s is not configured in properties", api));
+ } else if (Boolean.FALSE.equals(apiProperties.getEnabled())) {
+ throw new ApiNotConfiguredBPMNError(String.format("API %s is disabled in properties", api));
+ }
+ var token = keycloakService.getToken(apiProperties.getAuth());
+ if(token !=null && !token.isBlank()) {
+ String details = analyseToken(token);
+ result.put(api.name(),details);
+
+ }
+ } catch (KeycloakTokenConfigBPMNError | ApiNotConfiguredBPMNError e) {
+ result.put(api.name(),e.getMessage());
+ }
+ catch (Exception e){
+ result.put(api.name(),"Internal error with token");
+ }
+ }
+ return result;
+ }
+
+ /**
+ * @return A json with the configuration of the APIs handled by protools
+ */
+ public JsonNode getAPIConfigDetails(){
+ ObjectMapper objectMapper = new ObjectMapper();
+ ArrayNode rootNode = objectMapper.createArrayNode();
+ for (var api :ApiConfigProperties.KNOWN_API.values() ) {
+ APIProperties apiProperties = apiConfigProperties.getAPIProperties(api);
+ ObjectNode apiNode = objectMapper.valueToTree(apiProperties);
+ apiNode.put("name",api.name());
+ rootNode.add(apiNode);
+ }
+ return rootNode;
+ }
+
+ //analyse a single token to retrieve roles
+ private static String analyseToken(String token) {
+ String result;
+ String[] chunks = token.split("\\.");
+ if(chunks.length<2){
+ return "Token size is incorrect. It should contain at least one dot";
+ }
+ Base64.Decoder decoder = Base64.getUrlDecoder();
+ String payload = new String(decoder.decode(chunks[1]));
+ ObjectMapper objectMapper = new ObjectMapper();
+ try {
+ JsonNode tokenPayloadNode = objectMapper.readTree(payload);
+ JsonNode roles = tokenPayloadNode.path("realm_access").path("roles");
+ if(roles.isEmpty()){
+ result="No Role found in token";
+ }
+ else{
+ result= roles.toString();
+ }
+ } catch (JsonProcessingException e) {
+ result="Exception during json token parsing";
+ }
+ return result;
+ }
+
+ /**
+ * special version of NestedRuntimeException.contains accepting a list of types :
+ * Check whether the Ex exception contains an exception of the given list of types:
+ * either it is of the given class itself or it contains a nested cause of one of these types.
+ * @param ex : The exception
+ * @param exTypes : The searched types
+ * @return true if a matching exception type has been found
+ */
+ @SuppressWarnings("java:S3776")
+ public static boolean containsCauseOfType(Exception ex, @Nullable List> exTypes) {
+ if (exTypes == null || exTypes.isEmpty()) {
+ return false;
+ } else {
+ if (exTypes.stream().anyMatch(exType -> exType.isInstance(ex))) {
+ return true;
+ }
+
+ //Current exception is not of the configured types ; check parents
+ Throwable cause = ex.getCause();
+ if (cause == ex) {
+ return false;
+ } else {
+ while (cause != null) {
+ Throwable finalCause = cause; //to be used in lambda
+ if (exTypes.stream().anyMatch(exType -> exType.isInstance(finalCause))) {
+ return true;
+ }
+
+ if (cause.getCause() == cause) {
+ break;
+ }
+
+ cause = cause.getCause();
+ }
+
+ return false;
+ }
+ }
+ }
+}
diff --git a/src/main/java/fr/insee/protools/backend/restclient/RestClientKeycloakHeadersInitializer.java b/src/main/java/fr/insee/protools/backend/restclient/RestClientKeycloakHeadersInitializer.java
new file mode 100644
index 00000000..3389ecd4
--- /dev/null
+++ b/src/main/java/fr/insee/protools/backend/restclient/RestClientKeycloakHeadersInitializer.java
@@ -0,0 +1,36 @@
+package fr.insee.protools.backend.restclient;
+
+
+import fr.insee.protools.backend.restclient.configuration.APIProperties;
+import fr.insee.protools.backend.restclient.exception.KeycloakTokenConfigBPMNError;
+import fr.insee.protools.backend.restclient.exception.KeycloakTokenConfigUncheckedBPMNError;
+import fr.insee.protools.backend.restclient.keycloak.KeycloakService;
+import org.springframework.http.MediaType;
+import org.springframework.http.client.ClientHttpRequest;
+import org.springframework.http.client.ClientHttpRequestInitializer;
+
+/**
+ * Class in charge of adding the correct bearer token for API calls
+ * It will retrieve a fresh token if needed using our KeycloakService
+ */
+class RestClientKeycloakHeadersInitializer implements ClientHttpRequestInitializer {
+
+ final KeycloakService keycloakService;
+ //Configuration of the connexion to the auth server
+ private final APIProperties.AuthProperties authProperties;
+
+ public RestClientKeycloakHeadersInitializer(KeycloakService keycloakService, APIProperties.AuthProperties authProperties) {
+ this.keycloakService = keycloakService;
+ this.authProperties = authProperties;
+ }
+
+ @Override
+ public void initialize(ClientHttpRequest request) {
+ try {
+ request.getHeaders().setBearerAuth(keycloakService.getToken(authProperties));
+ } catch (KeycloakTokenConfigBPMNError e) {
+ throw new KeycloakTokenConfigUncheckedBPMNError(e);
+ }
+ request.getHeaders().setContentType(MediaType.APPLICATION_JSON);
+ }
+}
diff --git a/src/main/java/fr/insee/protools/backend/webclient/configuration/APIProperties.java b/src/main/java/fr/insee/protools/backend/restclient/configuration/APIProperties.java
similarity index 96%
rename from src/main/java/fr/insee/protools/backend/webclient/configuration/APIProperties.java
rename to src/main/java/fr/insee/protools/backend/restclient/configuration/APIProperties.java
index 37734c3c..ae079920 100644
--- a/src/main/java/fr/insee/protools/backend/webclient/configuration/APIProperties.java
+++ b/src/main/java/fr/insee/protools/backend/restclient/configuration/APIProperties.java
@@ -1,4 +1,4 @@
-package fr.insee.protools.backend.webclient.configuration;
+package fr.insee.protools.backend.restclient.configuration;
import com.fasterxml.jackson.annotation.JsonIgnore;
import jakarta.validation.Valid;
diff --git a/src/main/java/fr/insee/protools/backend/webclient/configuration/ApiConfigProperties.java b/src/main/java/fr/insee/protools/backend/restclient/configuration/ApiConfigProperties.java
similarity index 88%
rename from src/main/java/fr/insee/protools/backend/webclient/configuration/ApiConfigProperties.java
rename to src/main/java/fr/insee/protools/backend/restclient/configuration/ApiConfigProperties.java
index b15867d3..4b8ce460 100644
--- a/src/main/java/fr/insee/protools/backend/webclient/configuration/ApiConfigProperties.java
+++ b/src/main/java/fr/insee/protools/backend/restclient/configuration/ApiConfigProperties.java
@@ -1,4 +1,4 @@
-package fr.insee.protools.backend.webclient.configuration;
+package fr.insee.protools.backend.restclient.configuration;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
@@ -16,7 +16,8 @@ public enum KNOWN_API {
KNOWN_API_SABIANE_QUESTIONNAIRE,
KNOWN_API_REM,
KNOWN_API_MESHUGGAH,
- KNOWN_API_SUGOI
+ KNOWN_API_SUGOI,
+ KNOWN_API_TRAITERXXX
}
public APIProperties getAPIProperties(KNOWN_API api){
@@ -29,6 +30,7 @@ public APIProperties getAPIProperties(KNOWN_API api){
case KNOWN_API_REM -> remApiProperties();
case KNOWN_API_MESHUGGAH -> meshuggahApiProperties();
case KNOWN_API_SUGOI -> sugoiApiProperties();
+ case KNOWN_API_TRAITERXXX -> traiterXXXApiProperties();
};
}
@@ -81,4 +83,10 @@ public APIProperties sugoiApiProperties() {
return new APIProperties();
}
+ @Bean("traiterXXXApiProperties")
+ @ConfigurationProperties("fr.insee.protools.api.traiterxxx")
+ public APIProperties traiterXXXApiProperties() {
+ return new APIProperties();
+ }
+
}
diff --git a/src/main/java/fr/insee/protools/backend/webclient/exception/ApiNotConfiguredBPMNError.java b/src/main/java/fr/insee/protools/backend/restclient/exception/ApiNotConfiguredBPMNError.java
similarity index 85%
rename from src/main/java/fr/insee/protools/backend/webclient/exception/ApiNotConfiguredBPMNError.java
rename to src/main/java/fr/insee/protools/backend/restclient/exception/ApiNotConfiguredBPMNError.java
index 0b5c99ea..c164c6c6 100644
--- a/src/main/java/fr/insee/protools/backend/webclient/exception/ApiNotConfiguredBPMNError.java
+++ b/src/main/java/fr/insee/protools/backend/restclient/exception/ApiNotConfiguredBPMNError.java
@@ -1,4 +1,4 @@
-package fr.insee.protools.backend.webclient.exception;
+package fr.insee.protools.backend.restclient.exception;
import fr.insee.protools.backend.exception.ProtoolsBpmnError;
diff --git a/src/main/java/fr/insee/protools/backend/webclient/exception/KeycloakTokenConfigBPMNError.java b/src/main/java/fr/insee/protools/backend/restclient/exception/KeycloakTokenConfigBPMNError.java
similarity index 85%
rename from src/main/java/fr/insee/protools/backend/webclient/exception/KeycloakTokenConfigBPMNError.java
rename to src/main/java/fr/insee/protools/backend/restclient/exception/KeycloakTokenConfigBPMNError.java
index a4306881..596bfd77 100644
--- a/src/main/java/fr/insee/protools/backend/webclient/exception/KeycloakTokenConfigBPMNError.java
+++ b/src/main/java/fr/insee/protools/backend/restclient/exception/KeycloakTokenConfigBPMNError.java
@@ -1,4 +1,4 @@
-package fr.insee.protools.backend.webclient.exception;
+package fr.insee.protools.backend.restclient.exception;
import fr.insee.protools.backend.exception.ProtoolsBpmnError;
diff --git a/src/main/java/fr/insee/protools/backend/webclient/exception/KeycloakTokenConfigUncheckedBPMNError.java b/src/main/java/fr/insee/protools/backend/restclient/exception/KeycloakTokenConfigUncheckedBPMNError.java
similarity index 86%
rename from src/main/java/fr/insee/protools/backend/webclient/exception/KeycloakTokenConfigUncheckedBPMNError.java
rename to src/main/java/fr/insee/protools/backend/restclient/exception/KeycloakTokenConfigUncheckedBPMNError.java
index 925739ee..6360006a 100644
--- a/src/main/java/fr/insee/protools/backend/webclient/exception/KeycloakTokenConfigUncheckedBPMNError.java
+++ b/src/main/java/fr/insee/protools/backend/restclient/exception/KeycloakTokenConfigUncheckedBPMNError.java
@@ -1,4 +1,4 @@
-package fr.insee.protools.backend.webclient.exception;
+package fr.insee.protools.backend.restclient.exception;
import fr.insee.protools.backend.exception.ProtoolsBpmnError;
diff --git a/src/main/java/fr/insee/protools/backend/webclient/exception/runtime/WebClient4xxBPMNError.java b/src/main/java/fr/insee/protools/backend/restclient/exception/runtime/HttpClient4xxBPMNError.java
similarity index 68%
rename from src/main/java/fr/insee/protools/backend/webclient/exception/runtime/WebClient4xxBPMNError.java
rename to src/main/java/fr/insee/protools/backend/restclient/exception/runtime/HttpClient4xxBPMNError.java
index a8a2a908..2fa65498 100644
--- a/src/main/java/fr/insee/protools/backend/webclient/exception/runtime/WebClient4xxBPMNError.java
+++ b/src/main/java/fr/insee/protools/backend/restclient/exception/runtime/HttpClient4xxBPMNError.java
@@ -1,15 +1,15 @@
-package fr.insee.protools.backend.webclient.exception.runtime;
+package fr.insee.protools.backend.restclient.exception.runtime;
import fr.insee.protools.backend.exception.ProtoolsBpmnError;
import org.springframework.http.HttpStatusCode;
import static fr.insee.protools.backend.service.BPMNErrorCode.BPMNERROR_CODE_DEFAULT;
-public class WebClient4xxBPMNError extends ProtoolsBpmnError {
+public class HttpClient4xxBPMNError extends ProtoolsBpmnError {
private final HttpStatusCode httpStatusCodeError;
- public WebClient4xxBPMNError(String message, HttpStatusCode httpStatusCodeError) {
+ public HttpClient4xxBPMNError(String message, HttpStatusCode httpStatusCodeError) {
super(BPMNERROR_CODE_DEFAULT, message);
this.httpStatusCodeError = httpStatusCodeError;
}
diff --git a/src/main/java/fr/insee/protools/backend/webclient/exception/runtime/WebClientNullReturnBPMNError.java b/src/main/java/fr/insee/protools/backend/restclient/exception/runtime/HttpClient5xxBPMNError.java
similarity index 51%
rename from src/main/java/fr/insee/protools/backend/webclient/exception/runtime/WebClientNullReturnBPMNError.java
rename to src/main/java/fr/insee/protools/backend/restclient/exception/runtime/HttpClient5xxBPMNError.java
index 589f866f..4827862b 100644
--- a/src/main/java/fr/insee/protools/backend/webclient/exception/runtime/WebClientNullReturnBPMNError.java
+++ b/src/main/java/fr/insee/protools/backend/restclient/exception/runtime/HttpClient5xxBPMNError.java
@@ -1,12 +1,11 @@
-package fr.insee.protools.backend.webclient.exception.runtime;
-
+package fr.insee.protools.backend.restclient.exception.runtime;
import fr.insee.protools.backend.exception.ProtoolsBpmnError;
import static fr.insee.protools.backend.service.BPMNErrorCode.BPMNERROR_CODE_DEFAULT;
-public class WebClientNullReturnBPMNError extends ProtoolsBpmnError {
- public WebClientNullReturnBPMNError(String message) {
+public class HttpClient5xxBPMNError extends ProtoolsBpmnError {
+ public HttpClient5xxBPMNError(String message) {
super(BPMNERROR_CODE_DEFAULT, message);
}
}
diff --git a/src/main/java/fr/insee/protools/backend/webclient/exception/runtime/WebClientNetworkExceptionBPMNError.java b/src/main/java/fr/insee/protools/backend/restclient/exception/runtime/HttpClientNetworkExceptionBPMNError.java
similarity index 82%
rename from src/main/java/fr/insee/protools/backend/webclient/exception/runtime/WebClientNetworkExceptionBPMNError.java
rename to src/main/java/fr/insee/protools/backend/restclient/exception/runtime/HttpClientNetworkExceptionBPMNError.java
index b2a8390d..209cf4e4 100644
--- a/src/main/java/fr/insee/protools/backend/webclient/exception/runtime/WebClientNetworkExceptionBPMNError.java
+++ b/src/main/java/fr/insee/protools/backend/restclient/exception/runtime/HttpClientNetworkExceptionBPMNError.java
@@ -1,4 +1,4 @@
-package fr.insee.protools.backend.webclient.exception.runtime;
+package fr.insee.protools.backend.restclient.exception.runtime;
import fr.insee.protools.backend.exception.ProtoolsBpmnError;
import lombok.extern.slf4j.Slf4j;
@@ -7,11 +7,11 @@
import static fr.insee.protools.backend.service.BPMNErrorCode.BPMNERROR_CODE_DEFAULT;
@Slf4j
-public class WebClientNetworkExceptionBPMNError extends ProtoolsBpmnError {
+public class HttpClientNetworkExceptionBPMNError extends ProtoolsBpmnError {
private final WebClientRequestException ex;
- public WebClientNetworkExceptionBPMNError(WebClientRequestException ex) {
+ public HttpClientNetworkExceptionBPMNError(WebClientRequestException ex) {
super(BPMNERROR_CODE_DEFAULT, computeMessage(ex));
this.ex = ex;
log.error(this.getMessage());
diff --git a/src/main/java/fr/insee/protools/backend/restclient/exception/runtime/HttpClientNullReturnBPMNError.java b/src/main/java/fr/insee/protools/backend/restclient/exception/runtime/HttpClientNullReturnBPMNError.java
new file mode 100644
index 00000000..314b3a8b
--- /dev/null
+++ b/src/main/java/fr/insee/protools/backend/restclient/exception/runtime/HttpClientNullReturnBPMNError.java
@@ -0,0 +1,12 @@
+package fr.insee.protools.backend.restclient.exception.runtime;
+
+
+import fr.insee.protools.backend.exception.ProtoolsBpmnError;
+
+import static fr.insee.protools.backend.service.BPMNErrorCode.BPMNERROR_CODE_DEFAULT;
+
+public class HttpClientNullReturnBPMNError extends ProtoolsBpmnError {
+ public HttpClientNullReturnBPMNError(String message) {
+ super(BPMNERROR_CODE_DEFAULT, message);
+ }
+}
diff --git a/src/main/java/fr/insee/protools/backend/webclient/exception/runtime/WebClientRequestExceptionBPMNError.java b/src/main/java/fr/insee/protools/backend/restclient/exception/runtime/HttpClientRequestExceptionBPMNError.java
similarity index 81%
rename from src/main/java/fr/insee/protools/backend/webclient/exception/runtime/WebClientRequestExceptionBPMNError.java
rename to src/main/java/fr/insee/protools/backend/restclient/exception/runtime/HttpClientRequestExceptionBPMNError.java
index a11c1aa0..2b38e2ce 100644
--- a/src/main/java/fr/insee/protools/backend/webclient/exception/runtime/WebClientRequestExceptionBPMNError.java
+++ b/src/main/java/fr/insee/protools/backend/restclient/exception/runtime/HttpClientRequestExceptionBPMNError.java
@@ -1,4 +1,4 @@
-package fr.insee.protools.backend.webclient.exception.runtime;
+package fr.insee.protools.backend.restclient.exception.runtime;
import fr.insee.protools.backend.exception.ProtoolsBpmnError;
import lombok.extern.slf4j.Slf4j;
@@ -7,11 +7,11 @@
import static fr.insee.protools.backend.service.BPMNErrorCode.BPMNERROR_CODE_DEFAULT;
@Slf4j
-public class WebClientRequestExceptionBPMNError extends ProtoolsBpmnError {
+public class HttpClientRequestExceptionBPMNError extends ProtoolsBpmnError {
private final WebClientRequestException ex;
- public WebClientRequestExceptionBPMNError(WebClientRequestException ex) {
+ public HttpClientRequestExceptionBPMNError(WebClientRequestException ex) {
super(BPMNERROR_CODE_DEFAULT, computeMessage(ex));
this.ex = ex;
log.error(this.getMessage());
diff --git a/src/main/java/fr/insee/protools/backend/webclient/KeycloakResponse.java b/src/main/java/fr/insee/protools/backend/restclient/keycloak/KeycloakResponse.java
similarity index 76%
rename from src/main/java/fr/insee/protools/backend/webclient/KeycloakResponse.java
rename to src/main/java/fr/insee/protools/backend/restclient/keycloak/KeycloakResponse.java
index 615e675d..4563ce38 100644
--- a/src/main/java/fr/insee/protools/backend/webclient/KeycloakResponse.java
+++ b/src/main/java/fr/insee/protools/backend/restclient/keycloak/KeycloakResponse.java
@@ -1,19 +1,16 @@
-package fr.insee.protools.backend.webclient;
+package fr.insee.protools.backend.restclient.keycloak;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
@Data
-class KeycloakResponse {
+public class KeycloakResponse {
@JsonProperty("access_token")
private String accesToken;
@JsonProperty("expires_in")
private Integer expiresIn;
- public KeycloakResponse() {
- }
-
public KeycloakResponse(String accesToken, Integer expiresIn) {
this.accesToken = accesToken;
this.expiresIn = expiresIn;
diff --git a/src/main/java/fr/insee/protools/backend/webclient/KeycloakService.java b/src/main/java/fr/insee/protools/backend/restclient/keycloak/KeycloakService.java
similarity index 72%
rename from src/main/java/fr/insee/protools/backend/webclient/KeycloakService.java
rename to src/main/java/fr/insee/protools/backend/restclient/keycloak/KeycloakService.java
index 02d2f31b..47a2a125 100644
--- a/src/main/java/fr/insee/protools/backend/webclient/KeycloakService.java
+++ b/src/main/java/fr/insee/protools/backend/restclient/keycloak/KeycloakService.java
@@ -1,7 +1,7 @@
-package fr.insee.protools.backend.webclient;
+package fr.insee.protools.backend.restclient.keycloak;
-import fr.insee.protools.backend.webclient.configuration.APIProperties;
-import fr.insee.protools.backend.webclient.exception.KeycloakTokenConfigBPMNError;
+import fr.insee.protools.backend.restclient.configuration.APIProperties;
+import fr.insee.protools.backend.restclient.exception.KeycloakTokenConfigBPMNError;
import io.netty.handler.logging.LogLevel;
import jakarta.annotation.PostConstruct;
import lombok.Data;
@@ -10,12 +10,11 @@
import org.springframework.core.env.Environment;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
-import org.springframework.http.client.reactive.ReactorClientHttpConnector;
+import org.springframework.http.client.ReactorNettyClientRequestFactory;
import org.springframework.stereotype.Service;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
-import org.springframework.web.reactive.function.BodyInserters;
-import org.springframework.web.reactive.function.client.WebClient;
+import org.springframework.web.client.RestClient;
import reactor.netty.http.client.HttpClient;
import reactor.netty.transport.logging.AdvancedByteBufFormat;
@@ -34,7 +33,7 @@
public class KeycloakService {
private final Environment environment;
- private WebClient webClient;
+ private RestClient restClient;
public static final int TOKEN_REFRESH_LIMIT_MILLISECONDS = 30*1000;
//We will keep one token by auth server / realm / clientId
@@ -54,11 +53,11 @@ public String getToken(APIProperties.AuthProperties authProperties) throws Keycl
logToken(token);
//We refresh any expired token or that will expire within TOKEN_REFRESH_LIMIT_MILISECONDS
- if(token==null || Instant.now().toEpochMilli() >= (token.endValidityTimeMillis- TOKEN_REFRESH_LIMIT_MILLISECONDS)){
+ if(token==null || Instant.now().toEpochMilli() >= (token.endValidityTimeMillis()- TOKEN_REFRESH_LIMIT_MILLISECONDS)){
log.trace("Refresh the token");
refreshToken(authProperties);
}
- return tokenByAuthRealm.get(authProperties).value;
+ return tokenByAuthRealm.get(authProperties).value();
}
private void refreshToken(APIProperties.AuthProperties authProperties) throws KeycloakTokenConfigBPMNError {
@@ -68,6 +67,7 @@ private void refreshToken(APIProperties.AuthProperties authProperties) throws Ke
try {
uri = new URI(uri).normalize().toString();
} catch (URISyntaxException e) {
+ //Will probably never be reached if URL is tests before
throw new KeycloakTokenConfigBPMNError(String.format("Auth is not correctly configured for [%s]",authProperties));
}
MultiValueMap requestBody = new LinkedMultiValueMap<>();
@@ -77,15 +77,12 @@ private void refreshToken(APIProperties.AuthProperties authProperties) throws Ke
long endValidityTimeMillis = Instant.now().toEpochMilli();
- KeycloakResponse response = webClient.post()
+ KeycloakResponse response = restClient.post()
.uri(uri)
.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED_VALUE)
- .body(BodyInserters.fromValue(requestBody))
+ .body(requestBody)
.retrieve()
- //.onStatus(httpStatus -> HttpStatus.NOT_FOUND.equals(httpStatus),
- // clientResponse -> Mono.empty())
- .bodyToMono(KeycloakResponse.class)
- .block();
+ .toEntity(KeycloakResponse.class).getBody();
//TODO: timeout configurable ; handling des exceptions (ex: block) ; codes erreur http
//TODO : voir aussi cette histoire de timeout
if(response!=null) {
@@ -98,16 +95,14 @@ private void refreshToken(APIProperties.AuthProperties authProperties) throws Ke
}
@PostConstruct
- void initialize() {
- webClient = WebClient.builder()
- .clientConnector(
- new ReactorClientHttpConnector(
- HttpClient.create()
- //Handles a proxy conf passed on system properties
- .proxyWithSystemProperties()
- //enable logging of request/responses
- //configurable in properties as if it was this class logers
- .wiretap(this.getClass().getCanonicalName(), LogLevel.DEBUG, AdvancedByteBufFormat.TEXTUAL)))
+ public void initialize() {
+ restClient = RestClient.builder()
+ .requestFactory(new ReactorNettyClientRequestFactory(HttpClient.create()
+ //Handles a proxy conf passed on system properties
+ .proxyWithSystemProperties()
+ //enable logging of request/responses
+ //configurable in properties as if it was this class logers
+ .wiretap(this.getClass().getCanonicalName(), LogLevel.DEBUG, AdvancedByteBufFormat.TEXTUAL)))
.build();
}
@@ -123,12 +118,13 @@ boolean isValidURL(String url) {
}
}
+// @ExcludeFromJacocoGeneratedReport
private void logToken(Token token){
if(log.isTraceEnabled()){
var currentDt = Instant.now().toEpochMilli();
if(token!=null) {
log.trace("token.endValidityTimeMillis = {} - currentTimeMillis={} - diff={}",
- token.endValidityTimeMillis,currentDt, token.endValidityTimeMillis-currentDt);
+ token.endValidityTimeMillis(),currentDt, token.endValidityTimeMillis()-currentDt);
}
else
log.trace("token=null - currentTimeMillis={}",currentDt);
diff --git a/src/main/java/fr/insee/protools/backend/restclient/keycloak/Token.java b/src/main/java/fr/insee/protools/backend/restclient/keycloak/Token.java
new file mode 100644
index 00000000..dce403c0
--- /dev/null
+++ b/src/main/java/fr/insee/protools/backend/restclient/keycloak/Token.java
@@ -0,0 +1,4 @@
+package fr.insee.protools.backend.restclient.keycloak;
+
+record Token(String value, long endValidityTimeMillis) {
+}
diff --git a/src/main/java/fr/insee/protools/backend/restclient/pagination/PageResponse.java b/src/main/java/fr/insee/protools/backend/restclient/pagination/PageResponse.java
new file mode 100644
index 00000000..a150c125
--- /dev/null
+++ b/src/main/java/fr/insee/protools/backend/restclient/pagination/PageResponse.java
@@ -0,0 +1,35 @@
+package fr.insee.protools.backend.restclient.pagination;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import lombok.*;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@Builder
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+@ToString
+@JsonIgnoreProperties(ignoreUnknown=true)
+public class PageResponse {
+ @Builder.Default
+ private List content = new ArrayList<>();
+ @Builder.Default
+ private Integer currentPage=0;
+ @Builder.Default
+ private Integer pageSize=5000;
+ @Builder.Default
+ private Long totalElements=0L;
+ @Builder.Default
+ private Integer pageCount=0;
+
+ public Boolean isLastPage(){
+ if(currentPage==null || pageCount==null){
+ return true;
+ }
+ else return ((currentPage+1)>=pageCount);
+ }
+
+}
+
diff --git a/src/main/java/fr/insee/protools/backend/service/DelegateContextVerifier.java b/src/main/java/fr/insee/protools/backend/service/DelegateContextVerifier.java
index 02a379c9..6b134bb7 100644
--- a/src/main/java/fr/insee/protools/backend/service/DelegateContextVerifier.java
+++ b/src/main/java/fr/insee/protools/backend/service/DelegateContextVerifier.java
@@ -1,10 +1,10 @@
package fr.insee.protools.backend.service;
-import com.fasterxml.jackson.databind.JsonNode;
+import fr.insee.protools.backend.dto.ContexteProcessus;
+import fr.insee.protools.backend.service.context.exception.BadContexMissingBPMNError;
import fr.insee.protools.backend.service.context.exception.BadContextIncorrectBPMNError;
import org.slf4j.Logger;
-import java.util.HashSet;
import java.util.Set;
/**
@@ -13,7 +13,9 @@
*/
public interface DelegateContextVerifier {
- default Set getContextErrors(JsonNode contextRootNode) {return Set.of();}
+ default Set getContextErrors(ContexteProcessus context) {
+ return Set.of();
+ }
static String computeMissingMessage(String missingElement, Class> classUsingThisElement){
return String.format("Class=%s : Missing Context element name=%s ", classUsingThisElement.getSimpleName(),missingElement);
@@ -29,24 +31,12 @@ static String computeIncorrectEnumMessage(String incorrectElement,String value,
, value
,enumValues);
}
- static Set computeMissingChildrenMessages(Set requiredChildren, JsonNode parentNode, Class> classUsingThisElement){
- if(parentNode == null){
- return new HashSet<>();
- }
- Set missingNodes = new HashSet<>();
- for (String child: requiredChildren ) {
- if(parentNode.get(child) == null){
- missingNodes.add(computeMissingMessage(child,classUsingThisElement));
- }
- }
- return missingNodes;
- }
- default void checkContextOrThrow(Logger log,String processInstanceId, JsonNode contextRootNode) {
- if(contextRootNode==null)
- throw new BadContextIncorrectBPMNError(String.format("ProcessInstanceId=%s - context is missing", processInstanceId));
+ default void checkContextOrThrow(Logger log,String processInstanceId, ContexteProcessus context) {
+ if(context==null)
+ throw new BadContexMissingBPMNError(String.format("ProcessInstanceId=%s - context is missing", processInstanceId));
- var errors = getContextErrors(contextRootNode);
+ var errors = getContextErrors(context);
if(!errors.isEmpty()){
for (var msg: errors) {
log.error(msg);
diff --git a/src/main/java/fr/insee/protools/backend/service/FlowableVariableNameConstants.java b/src/main/java/fr/insee/protools/backend/service/FlowableVariableNameConstants.java
index 0b728d5c..a1c49076 100644
--- a/src/main/java/fr/insee/protools/backend/service/FlowableVariableNameConstants.java
+++ b/src/main/java/fr/insee/protools/backend/service/FlowableVariableNameConstants.java
@@ -8,31 +8,37 @@ public class FlowableVariableNameConstants {
//TODO : renommer toutes ces variables pour remplacer les - par des _ (comme ca ca sera utilisable dans les resolvers)
//Protools context
public static final String VARNAME_CONTEXT="context";
- public static final String VARNAME_CONTEXT_PARTITION_ID_LIST="contexte_partition_id_list";
- public static final String VARNAME_CONTEXT_PARTITION_VARIABLES_BY_ID="contexte_partition_variables_by_partitionid";
//To treat partitions one by one (Long)
public static final String VARNAME_CURRENT_PARTITION_ID="current_partition_id";
- //to pass a list of REM survey ids (List)
- public static final String VARNAME_REM_SU_ID_LIST="rem_survey_unit_id_list";
- //to pass a single REM survey unit's ID (Long)
- public static final String VARNAME_REM_SURVEY_UNIT_IDENTIFIER ="rem_survey_unit_id";
- //to pass a REM survey unit content (JsonNode)
- public static final String VARNAME_REM_SURVEY_UNIT ="rem_survey_unit";
+
//Sugoi ID/PWD
- public static final String VARNAME_DIRECTORYACCESS_ID_CONTACT ="directory_access_id_contact";
public static final String VARNAME_DIRECTORYACCESS_PWD_CONTACT ="directory_access_pwd_contact";
- //ERA response
- public static final String VARNAME_ERA_RESPONSE="era_response_list";
- public static final String VARNAME_ERA_QUERY_START_DATE="era_query_start_date";
- public static final String VARNAME_ERA_QUERY_END_DATE="era_query_end_date";
- //Platine Contact details
- public static final String VARNAME_PLATINE_CONTACT="platine_contact";
- //Indicates whether a questioning should be follow up or not
- public static final String VARNAME_SU_IS_TO_FOLLOWUP="survey_unit_is_to_follow_up";
- //List with for each SU the Instant when the opening communication has been sent
- //each row is Tuple
- public static final String VARNAME_SU_CREATION_ITEM="su_creation_date_item";
+ public static final String VARNAME_DIRECTORYACCESS_PWD_FOR_INTERRO_ID_MAP ="directory_access_pwd_contact_by_interroration_id";
+
+ //For communication
+ public static final String VARNAME_CURRENT_COMMUNICATION_ID="current_communication_id";
+ public static final String VARNAME_COMMUNICATION_REQUEST_ID_FOR_INTERRO_ID_MAP="communication_request_id_by_interrogation_id";
+ //List of the UUIDs of the communications that have already been scheduled
+ public static final String VARNAME_ALREADY_SCHEDULED_COMMUNICATION_ID_SET = "communication_already_scheduled_id_set";
+ //List of the UUIDs of the communcation that are in error (echeance was too far past)
+ public static final String VARNAME_COMMUNICATION_ERROR_ID_SET = "communication_in_error_id_set";
+
+
+ //To pass a list of REM interrogations content (JsonNode)
+ public static final String VARNAME_REM_INTERRO_LIST ="rem_interrogation_list";
+ //REM PAGEABLE
+ public static final String VARNAME_INTERRO_LIST_PAGEABLE_IS_LAST_PAGE ="interro_list_page_is_last";
+ public static final String VARNAME_INTERRO_LIST_PAGEABLE_CURRENT_PAGE ="interro_list_page_current";
+
+
+ //Contacts
+ public static final String VARNAME_PLATINE_CONTACT_LIST ="platine_contact_list";
+
+ //Remise en collecte
+ public static final String VARNAME_INTERRO_REMISE_EN_COLLECTE_LIST ="interro_remise_en_collecte_list";
+
+
private FlowableVariableNameConstants(){}
}
diff --git a/src/main/java/fr/insee/protools/backend/service/common/platine_sabiane/QuestionnaireHelper.java b/src/main/java/fr/insee/protools/backend/service/common/platine_sabiane/QuestionnaireHelper.java
deleted file mode 100644
index 26f7e1ea..00000000
--- a/src/main/java/fr/insee/protools/backend/service/common/platine_sabiane/QuestionnaireHelper.java
+++ /dev/null
@@ -1,332 +0,0 @@
-package fr.insee.protools.backend.service.common.platine_sabiane;
-
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import fr.insee.protools.backend.service.DelegateContextVerifier;
-import fr.insee.protools.backend.dto.platine_sabiane_questionnaire.campaign.CampaignDto;
-import fr.insee.protools.backend.dto.platine_sabiane_questionnaire.campaign.MetadataValue;
-import fr.insee.protools.backend.dto.platine_sabiane_questionnaire.surveyunit.SurveyUnitResponseDto;
-import fr.insee.protools.backend.service.context.ContextService;
-import fr.insee.protools.backend.service.exception.JsonParsingBPMNError;
-import fr.insee.protools.backend.service.nomenclature.NomenclatureService;
-import fr.insee.protools.backend.service.platine.utils.PlatineHelper;
-import fr.insee.protools.backend.service.questionnaire_model.QuestionnaireModelService;
-import fr.insee.protools.backend.dto.rem.REMSurveyUnitDto;
-import fr.insee.protools.backend.service.sabiane.SabianeIdHelper;
-import fr.insee.protools.backend.service.utils.FlowableVariableUtils;
-import lombok.extern.slf4j.Slf4j;
-import org.flowable.engine.delegate.DelegateExecution;
-
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-import static com.fasterxml.jackson.databind.DeserializationFeature.FAIL_ON_MISSING_CREATOR_PROPERTIES;
-import static com.fasterxml.jackson.databind.DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES;
-import static fr.insee.protools.backend.service.FlowableVariableNameConstants.VARNAME_CURRENT_PARTITION_ID;
-import static fr.insee.protools.backend.service.FlowableVariableNameConstants.VARNAME_REM_SURVEY_UNIT;
-import static fr.insee.protools.backend.service.context.ContextConstants.*;
-import static fr.insee.protools.backend.service.utils.ContextUtils.getCurrentPartitionNode;
-
-@Slf4j
-public class QuestionnaireHelper {
-
- private static final ObjectMapper objectMapper =
- new ObjectMapper()
- .configure(FAIL_ON_UNKNOWN_PROPERTIES, false)
- .configure(FAIL_ON_MISSING_CREATOR_PROPERTIES, true);
-
- private QuestionnaireHelper() {
- }
-
- public static void createQuestionnaire(JsonNode contextRootNode,
- QuestionnairePlatineSabianeService questionnairePlatineSabianeService,
- NomenclatureService nomenclatureService,
- QuestionnaireModelService questionnaireModelService,
- String processInstanceId,
- MetadataValue metadataDto
- ) {
- //Get the list of nomenclatures defined in Protools Context
- //Create them if needed
- var nomenclatureIterator = contextRootNode.path(CTX_NOMENCLATURES).elements();
- if (!nomenclatureIterator.hasNext()) {
- log.info("ProcessInstanceId={} - does not declare any nomenclature", processInstanceId);
- } else {
- initRequiredNomenclatures(questionnairePlatineSabianeService, nomenclatureService, processInstanceId, nomenclatureIterator);
- }
-
- //Get the list of Questionnaire Models defined in Protools Context
- Set questionnaireModelIds = initQuestionnaireModels(questionnairePlatineSabianeService, questionnaireModelService, processInstanceId, contextRootNode);
- CampaignDto campaignDto = CampaignDto.builder()
- .id(contextRootNode.path(CTX_CAMPAGNE_ID).textValue())
- .label(contextRootNode.path(CTX_CAMPAGNE_LABEL).textValue())
- .metadata(metadataDto)
- .questionnaireIds(questionnaireModelIds)
- .build();
- questionnairePlatineSabianeService.postCampaign(campaignDto);
- }
-
- static void initRequiredNomenclatures(QuestionnairePlatineSabianeService questionnairePlatineSabianeService, NomenclatureService nomenclatureService, String processInstanceId, Iterator nomenclatureIterator) {
- //Get the list of existing nomenclatures on platine
- Set existingNomenclatures = questionnairePlatineSabianeService.getNomenclaturesId();
-
- //Create the nomenclatures not existing yet on platine
- while (nomenclatureIterator.hasNext()) {
- var node = nomenclatureIterator.next();
- String nomenclatureId = node.get(CTX_NOMENCLATURE_ID).asText();
- String nomenclatureCheminRepertoire = node.path(CTX_NOMENCLATURE_CHEMIN_REPERTOIRE).asText();
- String nomenclatureLabel = node.get(CTX_NOMENCLATURE_LABEL).asText();
- //check if platine know this nomenclature
- if (existingNomenclatures.contains(nomenclatureId)) {
- log.info("ProcessInstanceId={} - nomenclature ID={} already exists in collect platform ", processInstanceId, nomenclatureId);
- } else {
- //Retrieve the nomenclature from remote source
- String nomenclatureValueStr = nomenclatureService.getNomenclatureContent(nomenclatureId, nomenclatureCheminRepertoire);
- JsonNode nomenclatureValue;
- try {
- nomenclatureValue = objectMapper.readTree(nomenclatureValueStr);
- } catch (JsonProcessingException e) {
- throw new JsonParsingBPMNError("Error while parsing the json retrieved for nomenclatureId=" + nomenclatureId, e);
- }
-
- //Write this nomenclature to platine/sabiane
- questionnairePlatineSabianeService.postNomenclature(nomenclatureId, nomenclatureLabel, nomenclatureValue);
- //TODO : handles the exceptions here?
- log.info("ProcessInstanceId={} - nomenclature ID={} created in remote collect platform", processInstanceId, nomenclatureId);
- }
- }
- }
-
- /**
- * For every questionnaireModel defined in context : check if it exists in platine/sabiane questionnaire.
- * If it does not exists : retrieve it from questionnaireModelService and create it in platine/sabiane
- *
- * @param questionnairePlatineSabianeService : the service object used to access Sabiane Or Platine
- * @param questionnaireModelService : The service object used to retrieve questionnaire models (ex: from gitlab)
- * @param processInstanceId : used in logs
- * @param contextRootNode : the protools context
- * @return the set of questionnaireModel ids
- */
- public static Set initQuestionnaireModels(QuestionnairePlatineSabianeService questionnairePlatineSabianeService, QuestionnaireModelService questionnaireModelService, String processInstanceId, JsonNode contextRootNode) {
- var questionnaireModelIterator = contextRootNode.path(CTX_QUESTIONNAIRE_MODELS).elements();
- Set questionnaireModelIds = new HashSet<>(); //Used to build the CampaignDto later
- while (questionnaireModelIterator.hasNext()) {
- var node = questionnaireModelIterator.next();
- String questionnaireId = node.get(CTX_QUESTIONNAIRE_MODEL_ID).asText();
- String questionnaireCheminRepertoire = node.get(CTX_QUESTIONNAIRE_MODEL_CHEMIN_REPERTOIRE).asText();
- String questionnaireLabel = node.get(CTX_QUESTIONNAIRE_MODEL_LABEL).asText();
- questionnaireModelIds.add(questionnaireId);
-
- //check if platine/sabiane know this questionnaire
- if (questionnairePlatineSabianeService.questionnaireModelExists(questionnaireId)) {
- log.info("getProcessInstanceId={} - questionnaireId ID={} already exists", processInstanceId, questionnaireId);
- } else {
- //Get the questionnaire model from remote source
- String questionnaireValueStr = questionnaireModelService.getQuestionnaireModel(questionnaireId, questionnaireCheminRepertoire);
-
- JsonNode questionnaireValue;
- try {
- questionnaireValue = objectMapper.readTree(questionnaireValueStr);
- } catch (JsonProcessingException e) {
- throw new JsonParsingBPMNError("Error while parsing the json retrieved for Model questionnaireId=" + questionnaireId, e);
- }
- //get the list of nomenclatures needed by this Questionnaire Model
- JsonNode nomenclaturesArrayNode = node.get(CTX_QUESTIONNAIRE_MODEL_REQUIRED_NOMENCLATURES);
- Set requiredNomenclatures = new HashSet<>(nomenclaturesArrayNode.size());
- nomenclaturesArrayNode.forEach(jsonNode -> requiredNomenclatures.add(jsonNode.asText()));
-
- //TODO : should we check context coherence here and verify that we dont have any unknown nomenclature?
- //Write this questionnaire model to platine/sabiane
- questionnairePlatineSabianeService.postQuestionnaireModel(questionnaireId, questionnaireLabel, questionnaireValue, requiredNomenclatures);
- //TODO : handles the exceptions here?
- }
- }
- return questionnaireModelIds;
- }
-
- @SuppressWarnings("java:S3776") //disable the warning about cognitive complexity as it is long but simple
- public static Set getCreateCtxContextErrors(JsonNode contextRootNode) {
- if (contextRootNode == null) {
- return Set.of(String.format("Class=%s : Context is missing ", QuestionnaireHelper.class.getSimpleName()));
- }
-
- Set requiredNodes =
- Set.of(CTX_CAMPAGNE_ID, CTX_CAMPAGNE_LABEL, CTX_NOMENCLATURES, CTX_QUESTIONNAIRE_MODELS, CTX_METADONNEES);
- Set missingNodes = new HashSet<>(DelegateContextVerifier.computeMissingChildrenMessages(requiredNodes, contextRootNode, QuestionnaireHelper.class));
-
- if (contextRootNode.get(CTX_NOMENCLATURES) != null) {
- //Check on nomenclatures
- var nomenclatureIterator = contextRootNode.path(CTX_NOMENCLATURES).elements();
- int i = 0;
- while (nomenclatureIterator.hasNext()) {
- i++;
- var nomenclatureNode = nomenclatureIterator.next();
- if (nomenclatureNode.get(CTX_NOMENCLATURE_ID) == null || nomenclatureNode.get(CTX_NOMENCLATURE_ID).asText().isEmpty()) {
- missingNodes.add(missingCTXMessage(CTX_NOMENCLATURES, i, CTX_NOMENCLATURE_ID));
- }
- if (nomenclatureNode.get(CTX_NOMENCLATURE_LABEL) == null || nomenclatureNode.get(CTX_NOMENCLATURE_LABEL).asText().isEmpty()) {
- missingNodes.add(missingCTXMessage(CTX_NOMENCLATURES, i, CTX_NOMENCLATURE_LABEL));
- }
- if (nomenclatureNode.get(CTX_NOMENCLATURE_CHEMIN_REPERTOIRE) == null || nomenclatureNode.get(CTX_NOMENCLATURE_CHEMIN_REPERTOIRE).asText().isEmpty()) {
- missingNodes.add(missingCTXMessage(CTX_NOMENCLATURES, i, CTX_NOMENCLATURE_CHEMIN_REPERTOIRE));
- }
- }
-
- }
-
- if (contextRootNode.get(CTX_QUESTIONNAIRE_MODELS) != null) {
- //Check on questionnaire models
- var questionnaireModelsIterator = contextRootNode.get(CTX_QUESTIONNAIRE_MODELS).elements();
- int i = 0;
- while (questionnaireModelsIterator.hasNext()) {
- i++;
- var nomenclatureNode = questionnaireModelsIterator.next();
- if (nomenclatureNode.get(CTX_QUESTIONNAIRE_MODEL_ID) == null || nomenclatureNode.get(CTX_QUESTIONNAIRE_MODEL_ID).asText().isEmpty()) {
- missingNodes.add(missingCTXMessage(CTX_QUESTIONNAIRE_MODELS, i, CTX_QUESTIONNAIRE_MODEL_ID));
- }
- if (nomenclatureNode.get(CTX_QUESTIONNAIRE_MODEL_LABEL) == null || nomenclatureNode.get(CTX_QUESTIONNAIRE_MODEL_LABEL).asText().isEmpty()) {
- missingNodes.add(missingCTXMessage(CTX_QUESTIONNAIRE_MODELS, i, CTX_QUESTIONNAIRE_MODEL_LABEL));
- }
- if (nomenclatureNode.get(CTX_QUESTIONNAIRE_MODEL_CHEMIN_REPERTOIRE) == null || nomenclatureNode.get(CTX_QUESTIONNAIRE_MODEL_CHEMIN_REPERTOIRE).asText().isEmpty()) {
- missingNodes.add(missingCTXMessage(CTX_QUESTIONNAIRE_MODELS, i, CTX_QUESTIONNAIRE_MODEL_CHEMIN_REPERTOIRE));
- }
- }
- }
- return missingNodes;
- }
-
- private static String missingCTXMessage(String parent, int index, String child) {
- return DelegateContextVerifier.computeMissingMessage(String.format("%s[%s].%s", parent, index, child), QuestionnaireHelper.class);
- }
-
- private static SurveyUnitResponseDto computeDtoPlatine(JsonNode remSUNode, JsonNode currentPartitionNode) {
- REMSurveyUnitDto remSurveyUnitDto = PlatineHelper.parseRemSUNode(objectMapper, VARNAME_REM_SURVEY_UNIT, remSUNode);
- String id = remSurveyUnitDto.getRepositoryId().toString();
- String nameKey = "name";
- String valueKey = "value";
-
- ArrayNode personalizationNode = objectMapper.createArrayNode();
- personalizationNode.add(objectMapper.createObjectNode()
- .put(nameKey, "whoAnswers1")
- .put(valueKey, currentPartitionNode.path(CTX_PARTITION_QUIREPOND1).asText()));
- personalizationNode.add(objectMapper.createObjectNode()
- .put(nameKey, "whoAnswers2")
- .put(valueKey, currentPartitionNode.path(CTX_PARTITION_QUIREPOND2).asText()));
- personalizationNode.add(objectMapper.createObjectNode()
- .put(nameKey, "whoAnswers3")
- .put(valueKey, currentPartitionNode.path(CTX_PARTITION_QUIREPOND3).asText()));
-
- return SurveyUnitResponseDto.builder()
- .id(id) //Platine
- .questionnaireId(currentPartitionNode.path(CTX_PARTITION_QUESTIONNAIRE_MODEL).asText())
- .data(remSurveyUnitDto.getExternals())
- .personalization(personalizationNode)
- .comment(objectMapper.createObjectNode())
- //.stateData(objectMapper.createObjectNode())
- .build();
- }
-
- private static SurveyUnitResponseDto computeDtoSabiane(JsonNode remSUNode, JsonNode currentPartitionNode) {
- REMSurveyUnitDto remSurveyUnitDto = PlatineHelper.parseRemSUNode(objectMapper, VARNAME_REM_SURVEY_UNIT, remSUNode);
- String id = SabianeIdHelper.computeSabianeID(currentPartitionNode.path(CTX_PARTITION_ID).asText(),remSurveyUnitDto.getRepositoryId().toString());
-
- return SurveyUnitResponseDto.builder()
- .id(id)//Sabiane uses identified of the form IdPartition P idREM
- .questionnaireId(currentPartitionNode.path(CTX_PARTITION_QUESTIONNAIRE_MODEL).asText())
- .data(remSurveyUnitDto.getExternals())
- .personalization(objectMapper.createObjectNode())//No personalization for sabiane
- .comment(objectMapper.createObjectNode())
- //.stateData(objectMapper.createObjectNode())
- .build();
- }
-
- /**
- * Create a SU in Platine Questionnaire
- * @param execution
- * @param protoolsContext
- * @param service
- */
- public static void createSUTaskPlatine(DelegateExecution execution, ContextService protoolsContext, QuestionnairePlatineSabianeService service) {
- createSUTaskPlatineSabiane(execution, protoolsContext, service, false);
- }
-
- /**
- * Create a SU in Sabiane Questionnaire
- * @param execution
- * @param protoolsContext
- * @param service
- */
- public static void createSUTaskSabiane(DelegateExecution execution, ContextService protoolsContext, QuestionnairePlatineSabianeService service) {
- createSUTaskPlatineSabiane(execution, protoolsContext, service, true);
- }
-
- private static void createSUTaskPlatineSabiane(DelegateExecution execution, ContextService protoolsContext, QuestionnairePlatineSabianeService service, boolean modeSabiane) {
- JsonNode contextRootNode = protoolsContext.getContextByProcessInstance(execution.getProcessInstanceId());
-
- Long currentPartitionId = FlowableVariableUtils.getVariableOrThrow(execution, VARNAME_CURRENT_PARTITION_ID, Long.class);
- JsonNode remSUNode = FlowableVariableUtils.getVariableOrThrow(execution, VARNAME_REM_SURVEY_UNIT, JsonNode.class);
- JsonNode currentPartitionNode = getCurrentPartitionNode(contextRootNode, currentPartitionId);
-
- //Create the DTO object
- SurveyUnitResponseDto dto =
- (modeSabiane)
- ?
- QuestionnaireHelper.computeDtoSabiane(remSUNode, currentPartitionNode)
- :
- QuestionnaireHelper.computeDtoPlatine(remSUNode, currentPartitionNode);
-
- log.info("ProcessInstanceId={} - mode={} - currentPartitionId={} - remSU.id={}",
- execution.getProcessInstanceId(), modeSabiane ? "sabiane" : "platine", currentPartitionId, dto.getId());
-
- //Call service
- service.postSurveyUnit(dto, contextRootNode.path(CTX_CAMPAGNE_ID).asText());
-
- log.debug("ProcessInstanceId={} end", execution.getProcessInstanceId());
- }
-
- /**
- * Get the context errors for an SU creation in Platine
- * @param contextRootNode : the context to verify
- * @return a Set with the errors
- */
- public static Set getCreateSUContextErrorsPlatine(JsonNode contextRootNode){
- Set requiredPartition =
- Set.of(CTX_PARTITION_ID,CTX_PARTITION_QUESTIONNAIRE_MODEL,CTX_PARTITION_QUIREPOND1,CTX_PARTITION_QUIREPOND2,CTX_PARTITION_QUIREPOND3);
- return getCreateSUContextErrorsCommonPlatineSabiane(contextRootNode,requiredPartition);
- }
-
- /**
- * Get the context errors for an SU creation in Sabiane
- * @param contextRootNode : the context to verify
- * @return a Set with the errors
- */
- public static Set getCreateSUContextErrorsSabiane(JsonNode contextRootNode){
- Set requiredPartition =
- Set.of(CTX_PARTITION_ID,CTX_PARTITION_QUESTIONNAIRE_MODEL);
- return getCreateSUContextErrorsCommonPlatineSabiane(contextRootNode,requiredPartition);
- }
-
- private static Set getCreateSUContextErrorsCommonPlatineSabiane(JsonNode contextRootNode, Set requiredPartition){
- if(contextRootNode==null){
- return Set.of("Context is missing");
- }
- Set results=new HashSet<>();
- Set requiredNodes =
- Set.of(
- //Global & Campaign
- CTX_PARTITIONS, CTX_QUESTIONNAIRE_MODELS
- );
-
- results.addAll(DelegateContextVerifier.computeMissingChildrenMessages(requiredNodes,contextRootNode,QuestionnaireHelper.class));
- //Maybe one day we will have partitions for platine and partitions for sabiane and we will only validate the platine ones
- //Partitions
- var partitionIterator =contextRootNode.path(CTX_PARTITIONS).elements();
- while (partitionIterator.hasNext()) {
- var partitionNode = partitionIterator.next();
- results.addAll(DelegateContextVerifier.computeMissingChildrenMessages(requiredPartition,partitionNode,QuestionnaireHelper.class));
- }
- return results;
- }
-}
diff --git a/src/main/java/fr/insee/protools/backend/service/common/platine_sabiane/QuestionnairePlatineSabianeService.java b/src/main/java/fr/insee/protools/backend/service/common/platine_sabiane/QuestionnairePlatineSabianeService.java
deleted file mode 100644
index d3752adf..00000000
--- a/src/main/java/fr/insee/protools/backend/service/common/platine_sabiane/QuestionnairePlatineSabianeService.java
+++ /dev/null
@@ -1,181 +0,0 @@
-package fr.insee.protools.backend.service.common.platine_sabiane;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import fr.insee.protools.backend.dto.platine_sabiane_questionnaire.NomenclatureDto;
-import fr.insee.protools.backend.dto.platine_sabiane_questionnaire.QuestionnaireModelCreateDto;
-import fr.insee.protools.backend.dto.platine_sabiane_questionnaire.campaign.CampaignDto;
-import fr.insee.protools.backend.dto.platine_sabiane_questionnaire.surveyunit.SurveyUnitResponseDto;
-import fr.insee.protools.backend.webclient.WebClientHelper;
-import fr.insee.protools.backend.webclient.exception.runtime.WebClient4xxBPMNError;
-import fr.insee.protools.backend.webclient.exception.runtime.WebClient5xxBPMNError;
-import fr.insee.protools.backend.webclient.exception.runtime.WebClientNullReturnBPMNError;
-import org.slf4j.event.Level;
-import org.springframework.http.HttpStatus;
-import org.springframework.web.reactive.function.client.WebClient;
-
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.stream.Collectors;
-
-public interface QuestionnairePlatineSabianeService {
-
- //Internal methods
- WebClient webClient();
- org.slf4j.Logger getLogger();
-
- /** Create a new nomenclature **/
- default void postNomenclature(String nomenclatureId, String nomenclatureLabel , JsonNode nomenclatureValue) {
- NomenclatureDto dto = new NomenclatureDto(nomenclatureId,nomenclatureLabel,nomenclatureValue);
- NomenclatureDto response =
- webClient()
- .post()
- .uri("/api/nomenclature")
- .bodyValue(dto)
- .retrieve()
- .bodyToMono(NomenclatureDto.class)
- .block();
- getLogger().info("postNomenclature: nomenclatureId={} - response={}",nomenclatureId,response);
- //TODO: gestion des erreurs (ex: 403...)
- }
-
- /** Create a new questionnaireModel **/
- default void postQuestionnaireModel(String questionnaireId, String questionnaireLabel, JsonNode questionnaireValue, Set requiredNomenclatures) {
- QuestionnaireModelCreateDto dto =
- new QuestionnaireModelCreateDto(questionnaireId,questionnaireLabel,questionnaireValue,requiredNomenclatures);
-
- QuestionnaireModelCreateDto response =
- webClient()
- .post()
- .uri("/api/questionnaire-models")
- .bodyValue(dto)
- .retrieve()
- .bodyToMono(QuestionnaireModelCreateDto.class)
- .block();
- getLogger().info("postQuestionnaireModel: questionnaireId={} - response={}",questionnaireId,response);
- //TODO: gestion des erreurs (ex: 403...)
-
- }
-
- /** Get the list of existing nomenclatures */
- default Set getNomenclaturesId() {
- List response = webClient()
- .get()
- .uri("/api/nomenclatures")
- .retrieve()
- .bodyToMono(List.class)
- .block();
- getLogger().info("getNomenclaturesId: response= {}",response);
- return (response==null)?new HashSet<>():response.stream().collect(Collectors.toSet());
- }
-
- /** Checks if the questionnaireModel exists **/
- default boolean questionnaireModelExists(String idQuestionnaireModel) {
- getLogger().info("questionnaireModelExists: idQuestionnaireModel={} ",idQuestionnaireModel);
- boolean modelExists = false;
- try{
- var response = webClient()
- .get()
- .uri(uriBuilder -> uriBuilder
- .path("/api/questionnaire/{id}")
- .build(idQuestionnaireModel))
- .retrieve().toBodilessEntity().block();
- if(response==null) {
- throw new WebClientNullReturnBPMNError("Error while checking if questionnaireModel exists - null result");
- }
-
- if(response.getStatusCode().is2xxSuccessful()) {
- modelExists = true;
- }
- else if(response.getStatusCode().is4xxClientError()){
- if(response.getStatusCode()==HttpStatus.NOT_FOUND){
- modelExists=false;
- }
- else{
- throw new WebClient4xxBPMNError("Error while checking if questionnaireModel exists ", response.getStatusCode());
- }
- }
- else{
- throw new WebClient5xxBPMNError("Error while checking if questionnaireModel exists ");
- }
- getLogger().debug("response code={}",response.getStatusCode());
- }
- catch (WebClient4xxBPMNError e){
- if(e.getHttpStatusCodeError().equals(HttpStatus.NOT_FOUND)){
- modelExists=false;
- }
- else {
- throw e;
- }
- }
- getLogger().info("questionnaireModelExists: idQuestionnaireModel={} - modelExists={}",idQuestionnaireModel,modelExists);
- return modelExists;
- }
-
- /** Create the campaign **/
- default void postCampaign(CampaignDto campaignDto) {
- WebClientHelper.logJson("postCampaign: ", campaignDto,getLogger(), Level.DEBUG);
- //Http Status Codes : https://github.com/InseeFr/Queen-Back-Office/blob/3.5.36-rc/src/main/java/fr/insee/queen/api/controller/CampaignController.java
- // HttpStatus.BAD_REQUEST(400) if campaign already exists
- // HttpStatus.FORBIDDEN (403) if the questionnaire does not exist or is already associated (Request to change it to 409)
- // WARNING : 403 will also be returned if user does not have an authorized role
- try {
- var response = webClient()
- .post()
- .uri("/api/campaigns")
- .bodyValue(campaignDto)
- .retrieve()
- .bodyToMono(String.class)
- .block();
- getLogger().info("postCampaign: idCampaign={} - response={} ", campaignDto.getId(), response);
- }
- catch (WebClient4xxBPMNError e){
- if(e.getHttpStatusCodeError().equals(HttpStatus.FORBIDDEN)){
- String msg=
- "Error 403/FORBIDEN during Questionnaire postCampaign."
- + " It can be caused by a missing permission or if a questionnaire model"
- + " "+campaignDto.getQuestionnaireIds()
- +" is already assigned to another campaign."
- + " msg="+e.getMessage();
- getLogger().error(msg);
- throw new WebClient4xxBPMNError(msg,e.getHttpStatusCodeError());
- }
- else if(e.getHttpStatusCodeError().equals(HttpStatus.BAD_REQUEST)){
- String msg="Error 400/BAD_REQUEST during Questionnaire postCampaign."
- + " One possible cause is that the campaign already exists "
- + " msg="+e.getMessage();
- getLogger().error(msg);
- throw new WebClient4xxBPMNError(msg,e.getHttpStatusCodeError());
- }
- //Currently no remediation so just rethrow
- throw e;
- }
- }
-
- /** Create a survey Unit **/
- default void postSurveyUnit(SurveyUnitResponseDto suDto, String idCampaign) {
- WebClientHelper.logJson("postSurveyUnit: idCampaign="+idCampaign, suDto,getLogger(),Level.DEBUG);
- try {
- var response = webClient()
- .post()
- .uri(uriBuilder -> uriBuilder
- .path("/api/campaign/{id}/survey-unit")
- .build(idCampaign))
- .bodyValue(suDto)
- .retrieve()
- .bodyToMono(String.class)
- .block();
- getLogger().info("postSurveyUnit: idCampaign={} - idSu={} - response={} ", idCampaign,suDto.getId(), response);
- }
- catch (WebClient4xxBPMNError e){
- if(e.getHttpStatusCodeError().equals(HttpStatus.BAD_REQUEST)){
- String msg="Error 400/BAD_REQUEST during Questionnaire postSurveyUnit."
- + " msg="+e.getMessage();
- getLogger().error(msg);
- throw new WebClient4xxBPMNError(msg,e.getHttpStatusCodeError());
- }
- //Currently no remediation so just rethrow
- throw e;
- }
- }
-}
diff --git a/src/main/java/fr/insee/protools/backend/service/context/ContextConstants.java b/src/main/java/fr/insee/protools/backend/service/context/ContextConstants.java
deleted file mode 100644
index ad129b9e..00000000
--- a/src/main/java/fr/insee/protools/backend/service/context/ContextConstants.java
+++ /dev/null
@@ -1,135 +0,0 @@
-package fr.insee.protools.backend.service.context;
-
-public final class ContextConstants {
-
- // Campaign context constants - Metadata
- public static final String CTX_CAMPAGNE_ID = "id";
- public static final String CTX_CAMPAGNE_LABEL = "label";
- public static final String CTX_CAMPAGNE_CONTEXTE = "contexte"; //Values: Enum CampaignContext...
-
-
- //Metadonnees Part
- public static final String CTX_METADONNEES = "metadonnees";
- public static final String CTX_META_OPERATION_ID = "operationId";//== platine : Survey
- public static final String CTX_META_SERIE_ID = "serieId"; //== platine : source
- public static final String CTX_META_ANNEE = "annee";
- public static final String CTX_META_PERIODE = "periode";
- public static final String CTX_META_PERIODICITE = "periodicite";
-
- public static final String CTX_META_LABEL_COURT_OPERATION = "operationLabelCourt";
- public static final String CTX_META_LABEL_LONG_OPERATION = "operationLabelLong";
- public static final String CTX_META_SERIE_LABEL_COURT = "serieLabelCourt";
- public static final String CTX_META_SERIE_LABEL_LONG = "serieLabelLong";
- public static final String CTX_META_PORTAIL_MES_ENQUETE_OPERATION = "portailMesEnquetesOperation";
- public static final String CTX_META_OBJECTIFS_COURTS = "objectifsCourts";
- public static final String CTX_META_OBJECTIFS_LONGS = "objectifsLongs";
- public static final String CTX_META_CARACTERE_OBLIGATOIRE = "caractereObligatoire";
- public static final String CTX_META_QUALITE_STATISTIQUE = "qualiteStatistique";
- public static final String CTX_META_TEST_NON_LABELLISE = "testNonLabellise";
- public static final String CTX_META_ANNEE_VISA = "anneeVisa";
- public static final String CTX_META_NUMERO_VISA = "numeroVisa";
- public static final String CTX_META_MINISTERE_TUTELLE = "ministereTutelle";
- public static final String CTX_META_PARUTION_JO = "parutionJo";
- public static final String CTX_META_DATE_PARUTION_JO = "dateParutionJo";
- public static final String CTX_META_RESPONSABLE_OPERATIONNEL = "responsableOperationnel";
- public static final String CTX_META_RESPONSABLE_TRAITEMENT = "responsableTraitement";
- public static final String CTX_META_CNIS_URL = "cnisUrl";
- public static final String CTX_META_DIFFUSION_URL = "diffusionUrl";
- public static final String CTX_META_NOTICE_URL = "noticeUrl";
- public static final String CTX_META_SPECIMENT_URL = "specimenUrl";
- //Metadonnees proprietaire (platine)
- public static final String CTX_META_PROPRIETAIRE_ID = "proprietaireId";
- public static final String CTX_META_PROPRIETAIRE_LABEL = "proprietaireLabel";
- public static final String CTX_META_PROPRIETAIRE_LOGO = "proprietaireLogo";
- //Metadonnees assistance (platine)
- public static final String CTX_META_ASSISTANCE_NIVO2_ID = "assistanceNiveau2Id";
- public static final String CTX_META_ASSISTANCE_NIVO2_LABEL = "assistanceNiveau2Label";
- public static final String CTX_META_ASSISTANCE_NIVO2_TEL = "assistanceNiveau2Tel";
- public static final String CTX_META_ASSISTANCE_NIVO2_MAIL = "assitanceNiveau2Mail";
- public static final String CTX_META_ASSISTANCE_NIVO2_PAYS = "asssistanceNiveau2Pays";
- public static final String CTX_META_ASSISTANCE_NIVO2_NUMERO_VOIE = "assistanceNiveau2NumeroVoie";
- public static final String CTX_META_ASSISTANCE_NIVO2_NOM_VOIE = "assistanceNiveau2NomVoie";
- public static final String CTX_META_ASSISTANCE_NIVO2_COMMUNE = "assistanceNiveau2Commune";
- public static final String CTX_META_ASSISTANCE_NIVO2_CODE_POSTAL = "assistanceNiveau2CodePostal";
- public static final String CTX_META_MAIL_BOITE_RETOUR = "mailBoiteRetour";
- public static final String CTX_META_URL_ENQUETE = "urlEnquete";
- public static final String CTX_META_THEME_MIEUX_CONNAITRE_MAIL = "themeMieuxConnaitreMail";
- public static final String CTX_META_SRVC_COL_SIGN_FONCTION = "serviceCollecteurSignataireFonction";
- public static final String CTX_META_SRVC_COL_SIGN_NOM = "serviceCollecteurSignataireNom";
- public static final String CTX_META_PRESTATAIRE = "prestataire";
- public static final String CTX_META_MAIL_RESP_OPERATIONNEL = "mailResponsableOperationnel";
- public static final String CTX_META_LOGO_PRESTATAIRE = "logoPrestataire";
- //Metadonnes platine
- public static final String CTX_META_URL_LOI_RGPD = "urlLoiRGPD";
- public static final String CTX_META_URL_LOI_STATISTIQUE = "urlLoiStatistique";
- public static final String CTX_META_URL_LOI_INFORMATIQUE = "urlLoiInformatique";
-
-
- //Pour sabiane
- public static final String CTX_META_REPERAGE = "reperage";
- public static final String CTX_META_ESSAIS_CONTACT = "essaisContact";
- public static final String CTX_META_BILAN_CONTACT = "bilanContact";
- public static final String CTX_META_REFERENTS_PRINCIPAUX = "referentsPrincipaux";
- public static final String CTX_META_REFERENTS_SECONDAIRES = "referentsSecondaires";
- public static final String CTX_META_SITES_GESTION = "sitesGestion";
- //Referents principaux et secondaires (sabiane)
- public static final String CTX_META_REFERENT_NOM = "nom";
- public static final String CTX_META_REFERENT_PRENOM = "prenom";
- public static final String CTX_META_REFERENT_TELEPHONE = "telephone";
-
- // Partitions
- public static final String CTX_PARTITIONS = "partitions";
- public static final String CTX_PARTITION_ID = "id";
- public static final String CTX_PARTITION_LABEL = "label";
- public static final String CTX_PARTITION_TYPE_ECHANTILLON = "typeEchantillon";
- public static final String CTX_PARTITION_DATE_DEBUT_COLLECTE = "dateDebutCollecte";
- public static final String CTX_PARTITION_DATE_FIN_COLLECTE = "dateFinCollecte";
- public static final String CTX_PARTITION_DATE_RETOUR = "dateRetour";
- public static final String CTX_PARTITION_QUESTIONNAIRE_MODEL = "questionnaireModel";
- public static final String CTX_PARTITION_QUIREPOND1 = "quiRepond1";
- public static final String CTX_PARTITION_QUIREPOND2 = "quiRepond2";
- public static final String CTX_PARTITION_QUIREPOND3 = "quiRepond3";
- public static final String CTX_PARTITION_PRIORITAIRE = "prioritaire";
-
- // Partitions Communications
- public static final String CTX_PARTITION_COMMUNICATIONS = "communications";
- public static final String CTX_PARTITION_COMMUNICATION_MOYEN = "moyenCommunication";
- public static final String CTX_PARTITION_COMMUNICATION_PHASE = "phaseCommunication";
- public static final String CTX_PARTITION_COMMUNICATION_AVEC_QUESTIONNAIRE_PAPIER = "avecQuestionnairePapier";
- public static final String CTX_PARTITION_COMMUNICATION_PROTOCOLE = "protocole";
- public static final String CTX_PARTITION_COMMUNICATION_MODE = "mode";
- public static final String CTX_PARTITION_COMMUNICATION_TYPE_MODELE = "typeModele";
- public static final String CTX_PARTITION_COMMUNICATION_OBJET_MAIL = "objetMail";
- public static final String CTX_PARTITION_COMMUNICATION_RELANCE_LIBRE_PARAGRAPHE1 = "relanceLibreMailParagraphe1";
- public static final String CTX_PARTITION_COMMUNICATION_RELANCE_LIBRE_PARAGRAPHE2 = "relanceLibreMailParagraphe2";
- public static final String CTX_PARTITION_COMMUNICATION_RELANCE_LIBRE_PARAGRAPHE3 = "relanceLibreMailParagraphe3";
- public static final String CTX_PARTITION_COMMUNICATION_RELANCE_LIBRE_PARAGRAPHE4 = "relanceLibreMailParagraphe4";
- public static final String CTX_PARTITION_COMMUNICATION_COMPLEMENT_CONNEXION = "complementConnexion";
-
-
-
- //Partitions, specific sabiane
- public static final String CTX_PARTITION_SABIANE_DATE_DEBUT_VISIBILITE_GESTIONNAIRE = "dateDebutVisibiliteGestionnaire";
- public static final String CTX_PARTITION_SABIANE_DATE_DEBUT_VISIBILITE_ENQUETEUR = "dateDebutVisibiliteEnqueteur";
- public static final String CTX_PARTITION_SABIANE_DATE_DEBUT_REPERAGE = "dateDebutReperage";
- public static final String CTX_PARTITION_SABIANE_DATE_FIN_TRAITEMENT = "dateFinTraitement";
-
- //Partitions, specific ERA
- public static final String CTX_PARTITION_ERA_SEXE = "sexe";
-
- // QuestionnaireModels
- public static final String CTX_QUESTIONNAIRE_MODELS = "questionnaireModels";
- public static final String CTX_QUESTIONNAIRE_MODEL_ID = "id";
- public static final String CTX_QUESTIONNAIRE_MODEL_CHEMIN_REPERTOIRE = "cheminRepertoire";
- public static final String CTX_QUESTIONNAIRE_MODEL_LABEL = "label";
- public static final String CTX_QUESTIONNAIRE_MODEL_REQUIRED_NOMENCLATURES = "requiredNomenclatureIds";
-
- // Nomenclatures
- public static final String CTX_NOMENCLATURES = "nomenclatures";
- public static final String CTX_NOMENCLATURE_ID = "id";
- public static final String CTX_NOMENCLATURE_CHEMIN_REPERTOIRE = "cheminRepertoire";
- public static final String CTX_NOMENCLATURE_LABEL = "label";
- //Constants class should not be initialized
- private ContextConstants() {
- }
- }
\ No newline at end of file
diff --git a/src/main/java/fr/insee/protools/backend/service/context/ContextServiceImpl.java b/src/main/java/fr/insee/protools/backend/service/context/ContextServiceImpl.java
index 7f3a5a7c..b3434938 100644
--- a/src/main/java/fr/insee/protools/backend/service/context/ContextServiceImpl.java
+++ b/src/main/java/fr/insee/protools/backend/service/context/ContextServiceImpl.java
@@ -4,8 +4,14 @@
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectReader;
+import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
+import com.networknt.schema.JsonSchema;
+import com.networknt.schema.JsonSchemaFactory;
+import com.networknt.schema.SpecVersion;
+import com.networknt.schema.ValidationMessage;
+import fr.insee.protools.backend.dto.ContexteProcessus;
import fr.insee.protools.backend.service.DelegateContextVerifier;
-import fr.insee.protools.backend.service.context.exception.BadContextDateTimeParseBPMNError;
+import fr.insee.protools.backend.service.context.exception.BadContexMissingBPMNError;
import fr.insee.protools.backend.service.context.exception.BadContextIOException;
import fr.insee.protools.backend.service.context.exception.BadContextIncorrectBPMNError;
import fr.insee.protools.backend.service.context.exception.BadContextNotJSONBPMNError;
@@ -14,7 +20,6 @@
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
-import org.apache.commons.lang3.tuple.Pair;
import org.flowable.bpmn.model.BpmnModel;
import org.flowable.bpmn.model.FlowElement;
import org.flowable.bpmn.model.ServiceTask;
@@ -33,33 +38,30 @@
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
-import java.io.Serializable;
import java.nio.charset.StandardCharsets;
-import java.time.Instant;
-import java.time.LocalDateTime;
-import java.time.ZoneId;
-import java.time.format.DateTimeFormatter;
-import java.time.format.DateTimeParseException;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
-import static fr.insee.protools.backend.service.FlowableVariableNameConstants.*;
-import static fr.insee.protools.backend.service.context.ContextConstants.*;
+import static fr.insee.protools.backend.service.FlowableVariableNameConstants.VARNAME_CONTEXT;
@Service
@Slf4j
@RequiredArgsConstructor
-public class ContextServiceImpl implements ContextService {
-
+public class ContextServiceImpl implements IContextService {
+
+ private static final ObjectReader defaultReader = new ObjectMapper().registerModule(new JavaTimeModule()).reader(); // maybe with configs
+ //Key : processInstanceID
+ //Value: Pair
+ private static final Map contextCache = new ConcurrentHashMap<>();
+ //TODO: Peut être que ca va sortir dans une dépendance externe
+ private static final String SCHEMA_VALIDATION_FILE = "/schema/contexte-processus.json";
private final RuntimeService runtimeService;
private final TaskService taskService;
private final RepositoryService repositoryService;
private final ApplicationContext springApplicationContext;
-
- private static final ObjectMapper mapper = new ObjectMapper();
- private static final ObjectReader defaultReader = mapper.reader(); // maybe with configs
-
- private static final Map contextCache = new ConcurrentHashMap<>();
+ private static final JsonSchema contextJsonSchema = JsonSchemaFactory
+ .getInstance(SpecVersion.VersionFlag.V202012)
+ .getSchema(ContextServiceImpl.class.getResourceAsStream(SCHEMA_VALIDATION_FILE));
@Override
public void processContextFileAndCompleteTask(MultipartFile file, String taskId) {
@@ -75,11 +77,14 @@ public void processContextFileAndCompleteTask(MultipartFile file, String taskId)
}
//check context
- Pair