Skip to content

Commit

Permalink
Update lunatic reader when no loop dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
loichenninger committed Jul 15, 2024
1 parent cc12943 commit b8607d8
Showing 1 changed file with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -214,11 +214,22 @@ private static void processPrimaryLoop(List<String> variables, MetadataModel met
*/
private static Group processDependingLoop(List<String> variables, MetadataModel metadataModel, Group parentGroup, JsonNode component) {
JsonNode loopDependencies = component.get("loopDependencies");
StringBuilder groupNameBuilder = new StringBuilder(loopDependencies.get(0).asText());
for (int i = 1; i < loopDependencies.size(); i++) {
groupNameBuilder.append("_").append(loopDependencies.get(i).asText());
String groupName;
if (!loopDependencies.isEmpty()) {
StringBuilder groupNameBuilder = new StringBuilder(loopDependencies.get(0).asText());
for (int i = 1; i < loopDependencies.size(); i++) {
groupNameBuilder.append("_").append(loopDependencies.get(i).asText());
}
groupName = groupNameBuilder.toString();
} else {
int i = 1;
groupName = "UNNAMED_" + i;
List<String> groups = metadataModel.getGroupNames();
while (groups.contains(groupName)) {
i++;
groupName = "UNNAMED_" + i;
}
}
String groupName = groupNameBuilder.toString();
log.info("Creation of group :" + groupName);
Group group = getNewGroup(metadataModel, groupName, parentGroup);
iterateOnComponentsToFindResponses(component, variables, metadataModel, group);
Expand Down Expand Up @@ -301,6 +312,7 @@ private static void addResponsesAndMissing(JsonNode primaryComponent, Group grou
iterateOnTableBody(primaryComponent, group, variables, metadataModel, isLunaticV2);
break;
case null:
log.warn(String.format("%s component type not recognized", primaryComponent.get(COMPONENT_TYPE).asText()));
break;
}
//We also had the missing variable if it exists (only one missing variable even if multiple responses)
Expand Down

0 comments on commit b8607d8

Please sign in to comment.