Ejemplo n.º 1
0
        private void _PopulateDimensions()
        {
            foreach (XPathNavigator dimNav in _tableNavigator.Select("rc:Columns/rc:Dimension", _vulcanConfig.NamespaceManager))
            {
                string dimName = dimNav.SelectSingleNode("@Name").Value;
                string factTableDimColumnName = dimNav.SelectSingleNode("@OutputName").Value;

                Message.Trace(Severity.Debug,"Mapping {0} to Dimension {1}", _name, dimName);

                if (DimensionHelper.DimDictionary.ContainsKey(dimName))
                {
                    TableHelper dimTableHelper =
                        new TableHelper(
                        dimName,
                        DimensionHelper.DimDictionary[dimName],
                        DimensionHelper.DimNavigatorDictionary[dimName].SelectSingleNode("rc:Table",_vulcanConfig.NamespaceManager));
                    Column dimKeyColumn = dimTableHelper.KeyColumn;

                    if (dimKeyColumn != null)
                    {
                        string constraintName = String.Format(System.Globalization.CultureInfo.InvariantCulture,"{0}_{1}_{2}", _name, dimName, factTableDimColumnName);

                        //Clone the Foreign Key Column and add it into our fact table.
                        Column tableColumn = (Column)dimKeyColumn.Clone();
                        tableColumn.Properties["Name"] = factTableDimColumnName;
                        this.Columns.Add(factTableDimColumnName,tableColumn);

                        ForeignKeyConstraint fkc = new ForeignKeyConstraint(constraintName, tableColumn, dimKeyColumn, dimName);
                        this.Constraints.Add(fkc);
                    }
                    else
                    {
                        dimTableHelper.TraceHelper();
                        Message.Trace(Severity.Error,"Dimension {0} has no key column.\n{1}", dimName,dimTableHelper.TableNavigator.OuterXml);
                    }
                }
                else
                {
                    Message.Trace(Severity.Error,"Dimension {0} cannot be found in the Dimensions Database.", dimName);
                }
            }
        }
Ejemplo n.º 2
0
        private void _PopulateConstraints()
        {
            int index = 0;
            foreach (XPathNavigator conNav in _tableNavigator.Select("rc:Constraints/rc:PrimaryKeyConstraint", _vulcanConfig.NamespaceManager))
            {
                _constraintList.Add(_ParseSimpleConstraint(conNav,true,index));
                index++;
            }

            index = 0;
            foreach (XPathNavigator conNav in _tableNavigator.Select("rc:Constraints/rc:Constraint", _vulcanConfig.NamespaceManager))
            {
                _constraintList.Add(_ParseSimpleConstraint(conNav, false, index));
                index++;
            }

            foreach (XPathNavigator fkCon in _tableNavigator.Select("rc:Constraints/rc:ForeignKeyConstraint", _vulcanConfig.NamespaceManager))
            {
                Column localColumn = new Column();
                Column foreignColumn = new Column();
                foreach (XPathNavigator nav in fkCon.Select("rc:LocalColumn/@*", _vulcanConfig.NamespaceManager))
                {
                    localColumn.Properties[nav.Name] = nav.Value;
                }
                foreach (XPathNavigator nav in fkCon.Select("rc:ForeignColumn/@*", _vulcanConfig.NamespaceManager))
                {
                    foreignColumn.Properties[nav.Name] = nav.Value;
                }
                string fkName = String.Format(System.Globalization.CultureInfo.InvariantCulture,"FK_{0}_{1}_{2}_{3}",_name,localColumn.Name,foreignColumn.Properties["Table"],foreignColumn.Name);
                ForeignKeyConstraint fkc = new ForeignKeyConstraint(fkName, localColumn, foreignColumn, foreignColumn.Properties["Table"]);
                _constraintList.Add(fkc);
            }
        }