using GB5Shared.DTO.Ice; using IceImportDAL.DTO.IceImportPipeline; namespace IceImportBLL.HierarchyMapper; // One resolved row plus the correlation index used to attach it under the right parent. // CorrelationIndex is the parsed table's "__ROWINDEX__" column value when present (JSON source — // see JsonSourceFileParser, where several child rows can legitimately share one index, a true // 1:many grouping), otherwise the row's plain positional index within its own table (Excel/CSV/XML // — see FlatTableEntitySplitter, whose per-entity tables all share the same row order/count because // they're column subsets of one physical source table/sheet). public readonly record struct ResolvedCandidateRow(int CorrelationIndex, MappedEntityRowDTO Row); // Builds the parent/child MappedEntityRowDTO tree from independently-resolved per-entity row // lists, and answers "which field on this child entity holds the parent/grandparent id" so // CommitAsync's persistence-then-inject-then-save-children sequencing knows where to write the // real DB-assigned id after the parent's own save returns. public interface IHierarchyMapper { List BuildHierarchy( Dictionary> resolvedRowsByEntity, IceMapDTO mapDefinition); // ValueType = 6 (ParentIdAssignmentResolver) field on the given child entity, if any. string? GetParentIdFieldName(IceMapDTO mapDefinition, int childEntityId); // ValueType = 8 (FirstParentValueResolver) field on the given child entity, if any. string? GetFirstParentIdFieldName(IceMapDTO mapDefinition, int childEntityId); // Every DataType=5 (object/List) destination member in this map — e.g. BOMDTO.BOMDetailArray // holding List — describing which child entity it embeds and which of that // child's own fields groups multiple flat-file rows under one parent record. List GetObjectListRelationships(IceMapDTO mapDefinition); }