Skip to content

Commit

Permalink
Fix : components without componentType are ignored
Browse files Browse the repository at this point in the history
  • Loading branch information
loichenninger committed Oct 29, 2024
1 parent 7d751dd commit db01381
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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<String> variables, MetadataModel metadataModel, boolean isLunaticV2) {
Expand All @@ -19,9 +22,13 @@ public void process(JsonNode primaryComponent, Group group, List<String> 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);
}
}

Expand Down

0 comments on commit db01381

Please sign in to comment.