/// <summary> /// Gets the hierarchy rows. /// </summary> /// <param name="sheet">The forecast sheet <see cref="Sheet" />.</param> /// <param name="hierarchy">The hierarchy <see cref="HierarchySettingItem" />.</param> /// <param name="pageableConfig">The pageable configuration <see cref="PageableConfig" />.</param> /// <returns> Collection of <see cref="HierarchyRow" /></returns> public IEnumerable <HierarchyRow> GetHierarchyRows(Sheet sheet, IEnumerable <HierarchySettingItem> hierarchy, PageableConfig pageableConfig) { sheet.CheckArgumentNull(nameof(sheet)); pageableConfig.CheckArgumentNull(nameof(pageableConfig)); EntitySchema entitySchema = UserConnection.EntitySchemaManager.GetInstanceByUId(sheet.ForecastEntityUId); var level = pageableConfig.HierarchyLevel; var columns = GetHierarchyColumns(entitySchema, hierarchy).Where(c => c.Key <= level); Select select = GetForecastEntitySelect(entitySchema.Name, sheet); AddColumnsToSelect(select, entitySchema, columns); var rightsCondition = GetRightsCondition(select, entitySchema); if (level > 0) { AddConditionsToSelect(select, columns.Where(c => c.Key < level), pageableConfig.HierarchyRowsId); } if (rightsCondition != null) { select.AddCondition(rightsCondition, LogicalOperation.And); } if (!string.IsNullOrEmpty(pageableConfig.PrimaryFilterValue)) { EntitySchema forecastEntitySchema = UserConnection.EntitySchemaManager.GetInstanceByName(entitySchema.Name); select.AddCondition(Func.Upper(FORECAST_ENTITY_ALIAS, forecastEntitySchema.PrimaryDisplayColumn.Name), LogicalOperation.And) .IsLike(Column.Parameter($"%{pageableConfig.PrimaryFilterValue.ToUpper()}%")); } if (pageableConfig.RowCount > 0 && pageableConfig.RowsOffset >= 0) { select = GetPageableSelect(select, pageableConfig); } if (!select.HasOrderByItems) { select.OrderByAsc(select.Columns.First()); } var lastHierarchyColumn = columns.First(c => c.Key == level); var emptyValue = GetEmptyHierarchyValue(lastHierarchyColumn.Value, entitySchema); var result = GetFilledHierarchyRows(select, level, emptyValue); return(result); }
///<inheritdoc /> public ForecastData GetData(Guid forecastId, IEnumerable <Guid> periodIds, PageableConfig pageableConfig) { pageableConfig.CheckArgumentNull(nameof(pageableConfig)); return(InnerGetData(forecastId, periodIds, pageableConfig)); }