Exemple #1
0
        protected void SetFilingIndicators()
        {
            var finds = new Dictionary <string, string>();

            this.FilingIndicators.Clear();
            this.XbrlFilingIndicators.Clear();
            foreach (var fact in Facts)
            {
                var cells = fact.Cells;
                foreach (var cell in cells)
                {
                    var tableid = cell.Remove(cell.IndexOf("<"));

                    if (!finds.ContainsKey(tableid))
                    {
                        var table = this.Taxonomy.Tables.FirstOrDefault(i => i.ID == tableid);
                        var find  = table.FilingIndicator;

                        finds.Add(tableid, find);
                        var filingndicator = new FilingIndicator();
                        filingndicator.ContextID = FilingIndicator.DefaultContextID;

                        filingndicator.Value = find;
                        this.XbrlFilingIndicators.Add(filingndicator);
                        var logicalFind = new LogicalModel.FilingIndicator();
                        logicalFind.ID = find;
                        this.FilingIndicators.Add(logicalFind);
                    }
                }
            }
            //return finds.Select(i=>i.Key).ToList();
        }
Exemple #2
0
        public void LoadComplex()
        {
            var XbrlTaxonomy = (XBRLProcessor.Models.XbrlTaxonomy) this.Taxonomy;

            Clear();
            var allnodes            = Utilities.Xml.AllNodes(XmlDocument);
            var nsm                 = Utilities.Xml.GetTaxonomyNamespaceManager(XmlDocument);
            var dimensionnamespaces = this.Taxonomy.DimensionItems.Select(i => i.NamespaceURI).Distinct().ToList();
            var domainnsdictionary  = new Dictionary <string, string>();

            var lastfactpartid = Taxonomy.CounterFactParts.Keys.Max();
            var ctdimdict      = new Dictionary <string, string>();
            var sb_ctlog       = new StringBuilder();

            foreach (var ct in Contexts.Items.Values)
            {
                FixContextNamespaces(ct, nsm, domainnsdictionary, dimensionnamespaces, sb_ctlog);

                if (ct.Dimensions != null)
                {
                    var dimensions = ct.Dimensions.OrderBy(i => i.DomainMemberFullName, StringComparer.Ordinal);
                    foreach (var dimension in dimensions)
                    {
                        var dimstr     = dimension.ToString();
                        var dimdompart = dimension.DimensionItemWithDomain;

                        if (!Taxonomy.FactParts.ContainsKey(dimstr))
                        {
                            if (!this.FactParts.ContainsKey(dimstr))
                            {
                                lastfactpartid++;
                                this.FactParts.Add(dimstr, lastfactpartid);
                                this.CounterFactParts.Add(lastfactpartid, dimstr);
                            }
                        }

                        var partexists       = Taxonomy.FactParts.ContainsKey(dimstr);
                        var partdomainexists = Taxonomy.FactParts.ContainsKey(dimstr);
                        if (dimension.IsTyped)
                        {
                            partexists = Taxonomy.FactParts.ContainsKey(dimdompart);

                            var dimdompartid = Taxonomy.FactParts[dimdompart];
                            var member       = dimension.DomainMember;

                            var typedmemberid = FactParts[dimstr];
                            if (!this.TypedFactMembers.ContainsKey(dimdompartid))
                            {
                                this.TypedFactMembers.Add(dimdompartid, new HashSet <int>());
                            }
                            if (!this.TypedFactMembers[dimdompartid].Contains(typedmemberid))
                            {
                                this.TypedFactMembers[dimdompartid].Add(typedmemberid);
                                this.CounterTypedFactMembers.Add(typedmemberid, dimdompartid);
                            }
                        }

                        dimension.MapID = GetPartID(dimstr);
                        ct.DimensionIds.Add(dimension.MapID);

                        if (!partexists)
                        {
                            ct.IsValid = false;
                        }
                    }
                }
                ct.SetContent();
                var key = Utilities.Strings.ListToString(ct.DimensionIds, ",");
                if (!ctdimdict.ContainsKey(key))
                {
                    ctdimdict.Add(key, ct.Content);
                }
                else
                {
                    Utilities.Logger.WriteLine(String.Format("Duplicate context found {0} vs {1}", ctdimdict[key], ct.Content));
                }
                ct.Dimensions.Clear();
            }
            if (sb_ctlog.Length > 0)
            {
                sb_ctlog.Insert(0, "Incorrect Dimension(s) at FixContextNamespaces:\r\n");
                Utilities.Logger.WriteLine(sb_ctlog.ToString());
                sb_ctlog.Clear();
            }
            var conceptnsurilist = Taxonomy.Concepts.Select(i => i.Value).Select(i => i.NamespaceURI).Distinct().ToList();

            foreach (var conceptnsuri in conceptnsurilist)
            {
                var sampleconcept = Taxonomy.Concepts.FirstOrDefault(i => i.Value.NamespaceURI == conceptnsuri);
                var factnodes     = allnodes.Where(i => i.NamespaceURI == conceptnsuri).ToList();
                foreach (var factnode in factnodes)
                {
                    var item = new XbrlFact();
                    Mappings.CurrentMapping.Map <XbrlFact>(factnode, item);
                    var parts = item.Concept.Split(':');
                    item.Concept = String.Format("{0}:{1}", sampleconcept.Value.Namespace, parts[1]);
                    this.XbrlFacts.Add(item);
                }
            }

            this.XbrlFilingIndicators.Clear();
            var filingnodes = allnodes.Where(i => i.Name.Equals("find:filingIndicator", StringComparison.OrdinalIgnoreCase)).ToList();

            foreach (var filingnode in filingnodes)
            {
                var item = new FilingIndicator();
                Mappings.CurrentMapping.Map <FilingIndicator>(filingnode, item);
                this.XbrlFilingIndicators.Add(item);
            }
            LoadLogicalData();
        }