Esempio n. 1
0
        public IMetadataRetrievable ImportSource(HashSet <Type> poDataStructList)
        {
            WonkaImportSource NewAggregateSource = new WonkaImportSource();

            if (poDataStructList != null)
            {
                foreach (Type TempType in poDataStructList)
                {
                    IMetadataRetrievable TempSource = ImportSource(TempType);

                    TempSource.GetAttrCache().ForEach(x => NewAggregateSource.AddAttribute(x));
                    TempSource.GetGroupCache().ForEach(x => NewAggregateSource.AddGroup(x));
                }
            }

            return(NewAggregateSource);
        }
        private WonkaRefEnvironment(bool bAllMetadata, IMetadataRetrievable pMetadataRetrievable)
        {
            DebugLevel = 1;

            DefaultCommitThreshold = 500;

            IdXref = new WonkaRefIdXref();

            AttrCache           = pMetadataRetrievable.GetAttrCache();
            AttrCollectionCache = pMetadataRetrievable.GetAttrCollectionCache();
            CurrencyCache       = pMetadataRetrievable.GetCurrencyCache();
            FieldCache          = pMetadataRetrievable.GetFieldCache();
            GroupCache          = pMetadataRetrievable.GetGroupCache();
            SourceCache         = pMetadataRetrievable.GetSourceCache();
            SourceFieldCache    = pMetadataRetrievable.GetSourceFieldCache();
            StandardCache       = pMetadataRetrievable.GetStandardCache();

            // NOTE: To be implemented later
            // CodeDefCache           = pMetadataRetrievable.GetCodeDefCache();

            AttrKeys       = new List <WonkaRefAttr>();
            AttrMap        = new Dictionary <int, WonkaRefAttr>();
            FieldMap       = new Dictionary <int, WonkaRefField>();
            GroupMap       = new Dictionary <int, WonkaRefGroup>();
            SourceMap      = new Dictionary <int, WonkaRefSource>();
            SourceFieldMap = new Dictionary <int, WonkaRefSourceField>();

            foreach (WonkaRefAttr TmpAttribute in AttrCache)
            {
                if (TmpAttribute.IsKey)
                {
                    AttrKeys.Add(TmpAttribute);
                }

                if (!IdXref.FieldIdToAttrIds.Keys.Contains(TmpAttribute.FieldId))
                {
                    IdXref.FieldIdToAttrIds[TmpAttribute.FieldId] = new HashSet <int>();
                }

                IdXref.FieldIdToAttrIds[TmpAttribute.FieldId].Add(TmpAttribute.AttrId);

                if (!IdXref.GroupIdToAttrIds.Keys.Contains(TmpAttribute.GroupId))
                {
                    IdXref.GroupIdToAttrIds[TmpAttribute.GroupId] = new HashSet <int>();
                }

                IdXref.GroupIdToAttrIds[TmpAttribute.GroupId].Add(TmpAttribute.AttrId);

                if (!IdXref.GroupIdToFieldIds.Keys.Contains(TmpAttribute.GroupId))
                {
                    IdXref.GroupIdToFieldIds[TmpAttribute.GroupId] = new HashSet <int>();
                }

                IdXref.GroupIdToFieldIds[TmpAttribute.GroupId].Add(TmpAttribute.FieldId);

                if (!String.IsNullOrEmpty(TmpAttribute.ColName) && (TmpAttribute.ColName == GetStandardByStdName("GSCName").StandardValue))
                {
                    IdXref.GroupIdToGroupSeqAttrId[TmpAttribute.GroupId] = TmpAttribute.AttrId;
                }

                AttrMap[TmpAttribute.AttrId] = TmpAttribute;
            }

            foreach (WonkaRefGroup TmpGroup in GroupCache)
            {
                if (TmpGroup.KeyTabCols.Count > 0)
                {
                    IdXref.GroupIdToKeyAttrIds[TmpGroup.GroupId] = new HashSet <int>();

                    foreach (string sTmpKeyTabCol in TmpGroup.KeyTabCols)
                    {
                        int nTargetAttrId = GetAttributeByTabColName(sTmpKeyTabCol).AttrId;
                        IdXref.GroupIdToKeyAttrIds[TmpGroup.GroupId].Add(nTargetAttrId);
                    }
                }

                GroupMap[TmpGroup.GroupId] = TmpGroup;
            }

            foreach (WonkaRefField TmpField in FieldCache)
            {
                FieldMap[TmpField.FieldId] = TmpField;
            }

            foreach (WonkaRefSource TmpSource in SourceCache)
            {
                SourceMap[TmpSource.SourceId] = TmpSource;
            }

            foreach (WonkaRefSourceField TmpSrcField in SourceFieldCache)
            {
                SourceFieldMap[TmpSrcField.SourceFieldId] = TmpSrcField;
            }

            if (bAllMetadata)
            {
                AttrCollectionCache = pMetadataRetrievable.GetAttrCollectionCache();

                // NOTE: To be implemented later
                // CodeDependencyCache    = pMetadataRetrievable.GetCodeDependencyCache();
                // CodeDependencyDefCache = pMetadataRetrievable.GetCodeDependencyDefCache();
            }
        }