Esempio n. 1
0
        /// <summary>
        /// Get SCD configuration for a SCD table name
        /// </summary>
        /// <param name="tableName">SCD table name</param>
        /// <param name="timeStampGranularity">timeStampGranularity</param>
        /// <returns>SCDConfiguration</returns>
        private SCDConfiguration GetSCD(string tableName, ColumnConfig.ScdTimeStampGranularityType timeStampGranularity)
        {
            if (_scdList.ContainsKey(tableName))
            {
                return(_scdList[tableName]);
            }

            SCDConfiguration newScd = new SCDConfiguration(timeStampGranularity);

            _scdList.Add(tableName, newScd);

            return(newScd);
        }
Esempio n. 2
0
        /// <summary>
        /// Creates a new list of SCDs (slowly changing dimension)
        /// </summary>
        /// <param name="columnConfigList">Column config list</param>
        /// <param name="tableLoaderDestinationTable">TableLoader destination table (not SCD table)</param>
        public SCDList(BindingList <ColumnConfig> columnConfigList, string tableLoaderDestinationTable)
        {
            if (tableLoaderDestinationTable == null)
            {
                tableLoaderDestinationTable = string.Empty;
            }

            SetFKColumnPrefix(tableLoaderDestinationTable);

            List <SCDColumn> bkList = new List <SCDColumn>();

            foreach (ColumnConfig config in columnConfigList)
            {
                if (config.Key)
                {
                    bkList.Add(new SCDColumn(config.OutputColumnName, config.BulkDataType));
                }
            }

            foreach (ColumnConfig config in columnConfigList)
            {
                if (!string.IsNullOrEmpty(config.ScdTable))
                {
                    string[] scdTables = config.ScdTable.Split(",".ToCharArray());
                    for (int i = 0; i < scdTables.Length; i++)
                    {
                        string           tableName = scdTables[i].Trim();
                        SCDConfiguration scd       = GetSCD(tableName, config.ScdTimeStampGranularity);

                        scd.BkList    = bkList;
                        scd.TableName = tableName;
                        scd.PrefixFK  = _prefixFK;

                        if (config.IsScdValidFrom)
                        {
                            scd.SetranularityMaxValue(config.ScdTimeStampGranularity);
                        }

                        if (config.IsScdColumn)
                        {
                            scd.AttributeList.Add(new SCDColumn(config.BulkColumnName, config.BulkDataType));
                        }

                        if (config.IsScdValidFrom)
                        {
                            scd.ValidFrom = new SCDColumn(config.BulkColumnName, config.BulkDataType);
                        }
                    }
                }
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Are all SCD configuration valid?
        /// </summary>
        /// <param name="message">Errors in a SCD configuration will be written into this ref parameter</param>
        /// <returns>Are all SCD configuration valid?</returns>
        public bool IsValid(ref string message)
        {
            message = "";
            bool isValid = true;

            foreach (string tableName in _scdList.Keys)
            {
                SCDConfiguration scd        = _scdList[tableName];
                string           scdMessage = "";
                isValid = isValid & scd.IsValid(ref scdMessage);
                if (scdMessage != "")
                {
                    if (message != "")
                    {
                        message += Environment.NewLine;
                    }
                    message += scdMessage;
                }
            }

            return(isValid);
        }
Esempio n. 4
0
        /// <summary>
        /// Creates sql command for creating the SCD table
        /// </summary>
        /// <returns>sql command for creating the SCD </returns>
        public string GetCreateScdTables()
        {
            string result = "";

            foreach (string tableName in _scdList.Keys)
            {
                SCDConfiguration scd        = _scdList[tableName];
                string           bks        = SCDHelper.GetSqlBkListWithDataType(scd.BkList, _prefixFK, "", 2);
                string           attributes = SCDHelper.GetSqlColumnListWithDataType(scd.AttributeList, "", "", 2, false, "NULL", "");


                string create = TEMPLATE_CREATE_SCD_TABLE.Replace("<tableName>", tableName);
                create  = create.Replace("<GranularityMaxValue>", scd.GranularityMaxValue);
                create  = create.Replace("<bks>", bks);
                create  = create.Replace("<attributes>", attributes);
                create  = create.Replace("<FK_ID>", _prefixFK + "ID");
                create += Environment.NewLine + Environment.NewLine;

                result += create;
            }

            return(result);
        }