示例#1
0
        public static List <LogicalModel.Dimension> ToLogicalDimensions(DimensionFilter item)
        {
            var toitem        = new List <LogicalModel.Dimension>();
            var dimensionitem = item.Dimension;

            if (item is ExplicitDimensionFilter)
            {
                var citem = item as ExplicitDimensionFilter;
                foreach (var member in citem.Members)
                {
                    var dimension = new LogicalModel.Dimension();
                    dimension.DimensionItem = dimensionitem.QName.Content;
                    dimension.Domain        = member.QName.Domain;
                    dimension.DomainMember  = member.QName.Value;
                    toitem.Add(dimension);
                }
            }
            if (item is TypedDimensionFilter)
            {
                var dimension = new LogicalModel.Dimension();
                dimension.DimensionItem = dimensionitem.QName.Content;
                dimension.IsTyped       = true;
                toitem.Add(dimension);
            }
            return(toitem);
        }
示例#2
0
        public void LoadLayoutHierarchy(LogicalModel.Table logicaltable)
        {
            Identifiables.Clear();
            Arcs.Clear();
            Identifiables.AddRange(Tables);
            Identifiables.AddRange(BreakDowns);
            Identifiables.AddRange(RuleNodes);
            Identifiables.AddRange(AspectNodes);
            Identifiables.AddRange(DimensionFilters);
            Identifiables.AddRange(DimensionRelationShips);
            Arcs.AddRange(BreakdownTrees);
            Arcs.AddRange(TableBreakDowns);
            Arcs.AddRange(DefinitionNodeSubTrees);
            Arcs.AddRange(AspectNodeFilters);

            foreach (var identifiable in Identifiables)
            {
                var li = new LogicalModel.LayoutItem();
                li.Table = logicaltable;
                var hi = new Hierarchy <LogicalModel.LayoutItem>(li);
                li.ID      = identifiable.ID;
                li.LabelID = identifiable.LabelID;
                li.LoadLabel(Taxonomy);

                var df = identifiable as DimensionFilter;
                if (df != null)
                {
                    li.Category = LogicalModel.LayoutItemCategory.Filter;

                    var dfexp = df as ExplicitDimensionFilter;
                    if (dfexp != null)
                    {
                        var member = dfexp.Members.FirstOrDefault();
                        if (member != null)
                        {
                            li.Role     = member.LinkRole;
                            li.RoleAxis = member.Axis;
                        }
                    }
                    var drel = df as DimensionRelationShip;
                    if (drel != null)
                    {
                        var member = drel.Member;
                        if (member != null)
                        {
                            li.Role     = drel.LinkRole;
                            li.RoleAxis = drel.Axis;
                            var dim = new LogicalModel.Dimension();
                            dim.DimensionItem = drel.Dimension.QName.Content;
                            dim.Domain        = drel.Member.Domain;
                            //dim.DomainMember = member.Value;
                            dim.SetTyped();
                            li.Dimensions.Add(dim);
                            li.Category = LogicalModel.LayoutItemCategory.Aspect;
                        }
                    }
                }

                var rule = identifiable as RuleNode;
                if (rule != null)
                {
                    li.Category = LogicalModel.LayoutItemCategory.Rule;

                    if (rule.Concept != null)
                    {
                        li.Concept = Mappings.ToLogical(rule.Concept); //rule.Concept.QName.Content;
                    }
                    if (rule.Abstract)
                    {
                        li.IsAbstract = rule.Abstract;
                    }
                    var dimensions = rule.Dimensions;//.Where(i=>i.)
                    foreach (var dimension in dimensions)
                    {
                        var logicaldimension  = new LogicalModel.Dimension();
                        var explicitDimension = dimension as ExplicitDimension;
                        var typedDimension    = dimension as TypedDimension;
                        if (explicitDimension != null)
                        {
                            logicaldimension.DimensionItem = explicitDimension.Dimension;
                            if (explicitDimension.Members.Count == 1)
                            {
                                var member = explicitDimension.Members.FirstOrDefault();
                                logicaldimension.Domain       = member.QName.Domain;
                                logicaldimension.DomainMember = member.QName.Value;
                            }
                            else
                            {
                                Logger.WriteLine("Multiple Members Detected");
                            }
                        }
                        if (typedDimension != null)
                        {
                            Logger.WriteLine("Typed Dimension Detected");
                        }
                        li.Dimensions.Add(logicaldimension);
                    }
                }

                var aspect = identifiable as AspectNode;
                if (aspect != null)
                {
                    li.Category = LogicalModel.LayoutItemCategory.Aspect;
                    var logicaldimension = new LogicalModel.Dimension();
                    logicaldimension.DimensionItem = aspect.DimensionAspect.Content;
                    var hc = logicaltable.HyperCubes.FirstOrDefault(i => i.DimensionItems.Any(j => j.FullName == logicaldimension.DimensionItem));
                    if (hc != null)
                    {
                        var dimitem = hc.DimensionItems.FirstOrDefault(i => i.FullName == logicaldimension.DimensionItem);
                        if (dimitem != null && dimitem.Domains.Count > 0)
                        {
                            //logicaldimension.Domain = dimitem.Domains.FirstOrDefault().FullName;
                            var domain = dimitem.Domains.FirstOrDefault();
                            logicaldimension.Domain = LogicalModel.Taxonomy.IsTyped(domain.FullName) ? domain.FullName : domain.ID;
                        }
                    }
                    logicaldimension.SetTyped();
                    li.Dimensions.Add(logicaldimension);
                }
                var breakdown = identifiable as BreakDown;

                if (breakdown != null)
                {
                    li.Category = LogicalModel.LayoutItemCategory.BreakDown;
                }

                logicaltable.LayoutItems.Add(hi);
            }

            var layoutfilename            = Utilities.Strings.GetFileName(this.LayoutPath);
            XmlNamespaceManager nsmanager = null;
            var layoutdoc = this.Taxonomy.TaxonomyDocuments.FirstOrDefault(i => i.FileName == layoutfilename);

            if (layoutdoc != null)
            {
                nsmanager = Utilities.Xml.GetTaxonomyNamespaceManager(layoutdoc.XmlDocument);
            }
            var d_con = new Dictionary <string, string>();

            foreach (var li in logicaltable.LayoutItems)
            {
                var concept = li.Item.Concept;
                if (concept != null)
                {
                    var nsuri = nsmanager.LookupNamespace(concept.Namespace);
                    concept.Namespace = Taxonomy.FindNamespacePrefix(nsuri, concept.Namespace);
                }
                foreach (var dimension in li.Item.Dimensions)
                {
                    var dimqname = new QName(dimension.DimensionItem);
                    var nsuri    = nsmanager.LookupNamespace(dimqname.Domain);
                    dimqname.Domain         = Taxonomy.FindNamespacePrefix(nsuri, dimqname.Domain);
                    dimension.DimensionItem = dimqname.Content;

                    string domnsuri;

                    if (dimension.IsTyped)
                    {
                        var domqname = new QName(dimension.Domain);
                        domnsuri         = nsmanager.LookupNamespace(domqname.Domain);
                        domqname.Domain  = Taxonomy.FindNamespacePrefix(domnsuri, domqname.Domain);
                        dimension.Domain = domqname.Content;
                    }
                    else
                    {
                        domnsuri         = nsmanager.LookupNamespace(dimension.Domain);
                        dimension.Domain = Taxonomy.FindNamespacePrefix(domnsuri, dimension.Domain);
                    }
                }
            }

            logicaltable.LayoutRoot = Hierarchy <LogicalModel.LayoutItem> .GetHierarchy(Arcs, logicaltable.LayoutItems,
                                                                                        (i, a) => i.Item.LabelID == a.From, (i, a) => i.Item.LabelID == a.To,
                                                                                        (i, a) => { i.Item.Order = a.Order; i.Item.Axis = a is TableBreakDownArc ? ((TableBreakDownArc)a).Axis.ToString() : ""; });

            logicaltable.ID   = logicaltable.LayoutRoot.Item.ID;
            logicaltable.Name = logicaltable.LayoutRoot.Item.LabelContent;
            logicaltable.SetHtmlPath();
            Utilities.FS.WriteAllText(logicaltable.LayoutPath, logicaltable.LayoutRoot.ToHierarchyString(GetLayoutString));
            //var x = GetXbrlRendering();
            //Utilities.FS.WriteAllText(logicaltable.FullHtmlPath.Replace(".html", "_layout.txt"), x.ToHierarchyString(GetLayoutString));
        }