From db013813e5f116543de44de217eb41f1168d4960 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Henninger?= Date: Tue, 29 Oct 2024 16:30:35 +0100 Subject: [PATCH] Fix : components without componentType are ignored --- .../metadata/reader/lunatic/LunaticUtils.java | 16 +++++++++------- .../lunatic/processor/DynamicTableProcessor.java | 13 ++++++++++--- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/main/java/fr/insee/bpm/metadata/reader/lunatic/LunaticUtils.java b/src/main/java/fr/insee/bpm/metadata/reader/lunatic/LunaticUtils.java index b48a53a..62512bf 100644 --- a/src/main/java/fr/insee/bpm/metadata/reader/lunatic/LunaticUtils.java +++ b/src/main/java/fr/insee/bpm/metadata/reader/lunatic/LunaticUtils.java @@ -31,13 +31,15 @@ public static String getVariableName(JsonNode component) { public static String getFirstResponseName(JsonNode components) { for (JsonNode component : components) { - ComponentLunatic componentLunatic = ComponentLunatic.fromJsonName(component.get(Constants.COMPONENT_TYPE).asText()); - if (componentLunatic == ComponentLunatic.QUESTION) { - String result = getFirstResponseName(component.get(Constants.COMPONENTS)); - if (result != null) return result; - } else { - if (component.has(RESPONSE)) { - return getVariableName(component); + if (component.has(Constants.COMPONENT_TYPE)){ + ComponentLunatic componentLunatic = ComponentLunatic.fromJsonName(component.get(Constants.COMPONENT_TYPE).asText()); + if (componentLunatic == ComponentLunatic.QUESTION) { + String result = getFirstResponseName(component.get(Constants.COMPONENTS)); + if (result != null) return result; + } else { + if (component.has(RESPONSE)) { + return getVariableName(component); + } } } } diff --git a/src/main/java/fr/insee/bpm/metadata/reader/lunatic/processor/DynamicTableProcessor.java b/src/main/java/fr/insee/bpm/metadata/reader/lunatic/processor/DynamicTableProcessor.java index 16cc909..e0d5a58 100644 --- a/src/main/java/fr/insee/bpm/metadata/reader/lunatic/processor/DynamicTableProcessor.java +++ b/src/main/java/fr/insee/bpm/metadata/reader/lunatic/processor/DynamicTableProcessor.java @@ -1,15 +1,18 @@ package fr.insee.bpm.metadata.reader.lunatic.processor; import com.fasterxml.jackson.databind.JsonNode; +import fr.insee.bpm.metadata.Constants; import fr.insee.bpm.metadata.model.Group; import fr.insee.bpm.metadata.model.MetadataModel; import fr.insee.bpm.metadata.reader.lunatic.ComponentLunatic; import fr.insee.bpm.metadata.reader.lunatic.LunaticUtils; +import lombok.extern.slf4j.Slf4j; import java.util.List; import static fr.insee.bpm.metadata.Constants.COMPONENTS; +@Slf4j public class DynamicTableProcessor implements ComponentProcessor { public void process(JsonNode primaryComponent, Group group, List variables, MetadataModel metadataModel, boolean isLunaticV2) { @@ -19,9 +22,13 @@ public void process(JsonNode primaryComponent, Group group, List variabl String groupName = LunaticUtils.getFirstResponseName(components); Group dynTabGroup = LunaticUtils.getNewGroup(metadataModel,groupName,group); for (JsonNode component : components) { - ComponentLunatic componentType = ComponentLunatic.fromJsonName(component.get("componentType").asText()); - ComponentProcessor processor = ComponentProcessorFactory.getProcessor(componentType); - processor.process(component, dynTabGroup, variables, metadataModel, isLunaticV2); + if (component.has(Constants.COMPONENT_TYPE)){ + ComponentLunatic componentType = ComponentLunatic.fromJsonName(component.get(Constants.COMPONENT_TYPE).asText()); + ComponentProcessor processor = ComponentProcessorFactory.getProcessor(componentType); + processor.process(component, dynTabGroup, variables, metadataModel, isLunaticV2); + continue; + } + log.warn("Component ignored in RosterForLoop with id {} : {}", primaryComponent.get("id"),component); } }