private Stream createNestedNodeScopeHandlers()

in src/main/java/com/epam/digital/data/platform/generator/factory/impl/asyncload/AsyncDataLoadEntityScopeFactory.java [72:97]


  private Stream<ModelScope> createNestedNodeScopeHandlers(
      String structureName, NestedNode node, Context context) {
    if (node.getChildNodes().entrySet().isEmpty()) {
      return Stream.empty();
    }
    var table = findTable(node.getTableName(), context);
    var nestedColumnNames = node.getChildNodes().keySet();
    var nestedColumns =
        table.getColumns().stream()
            .filter(column -> nestedColumnNames.contains(column.getName()))
            .collect(toList());
    var simpleColumns =
        table.getColumns().stream()
            .filter(Predicate.not(nestedColumns::contains))
            .collect(toList());

    var scope = new ModelScope();
    scope.setClassName(getSchemaName(structureName, context) + "NestedCsv");
    scope.getFields().addAll(getSimpleFields(simpleColumns));
    scope.getFields().addAll(getNestedFields(structureName, node, nestedColumns));

    var childScopes =
        node.getChildNodes().values().stream()
            .flatMap(childNode -> createNestedNodeScopeHandlers(structureName, childNode, context));
    return Stream.concat(Stream.of(scope), childScopes);
  }