Skip to content

Commit

Permalink
Merge pull request #139 from InseeFr/devLunaticReaderGroupName
Browse files Browse the repository at this point in the history
Update lunatic reader when no loop dependencies
  • Loading branch information
alicela authored Jul 16, 2024
2 parents 54314d0 + b8607d8 commit 9328991
Showing 1 changed file with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -215,11 +215,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 @@ -302,6 +313,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 9328991

Please sign in to comment.