コード例 #1
0
        internal bool TryGetMeasureDimensionNodesForRole(string currentLanguage, string currentLabelRole,
                                                         string roleId, Taxonomy tax, out DimensionNode topLevelNode)
        {
            topLevelNode = null;
            DefinitionLink dl = definitionLinks[roleId] as DefinitionLink;

            if (dl != null)
            {
                string label = dl.Title;


                topLevelNode = new DimensionNode(label);
                topLevelNode.MyDefinitionLink = dl;
                if (dl.HypercubeLocatorsHrefs.Count > 0)
                {
                    foreach (string hypercubeHref in dl.HypercubeLocatorsHrefs)
                    {
                        List <DimensionNode> dns;
                        dl.BuildMeasureElementTreeForHypercubeId(tax, hypercubeHref, false, out dns);

                        if (dns != null)
                        {
                            foreach (DimensionNode dn in dns)
                            {
                                topLevelNode.AddChild(dn);
                            }
                        }
                    }
                }
            }

            return(topLevelNode != null);
        }
コード例 #2
0
        private DimensionNode GetDefaultChild()
        {
            if (this.children != null)
            {
                foreach (DimensionNode dn in this.children)
                {
                    if (dn.IsProhibited)
                    {
                        continue;
                    }

                    if (dn.nodeInfo.NodeType == NodeType.Item &&
                        dn.nodeInfo.IsDefault)
                    {
                        return(dn);
                    }
                    DimensionNode defDN = dn.GetDefaultChild();
                    if (defDN != null)
                    {
                        return(defDN);
                    }
                }
            }


            return(null);
        }
コード例 #3
0
 internal bool TryGetHypercubeNode(string currentLanguage, string currentLabelRole,
                                   string role,
                                   string hypercubeId,
                                   out DimensionNode hypercubeNode)
 {
     return(TryGetHypercubeNode(currentLanguage, currentLabelRole,
                                role, hypercubeId, false, out hypercubeNode));
 }
コード例 #4
0
        private void CreateChildNodes(string lang, string role,
                                      DimensionNode parentNode,
                                      DefinitionLink dLink, Hashtable definisionLinks,
                                      HybridDictionary ChildDefinitionLocatorsHD, bool buildHypercubeChildren, bool isScenarioMarkup)
        {
            if (ChildDefinitionLocatorsHD == null)
            {
                return;
            }

            if (!buildHypercubeChildren)
            {
                if (parentNode.NodeDimensionInfo != null &&
                    parentNode.NodeDimensionInfo.NodeType == DimensionNode.NodeType.Hypercube)
                {
                    //no need to build the children...
                    return;
                }
            }
            foreach (ChildDefinitionLocator cdl in ChildDefinitionLocatorsHD.Values)
            {
                DefinitionLocator childLocator;
                if (!dLink.TryGetLocator(cdl.HRef, out childLocator))
                {
                    continue;
                }

                bool recursive = true;
                if (parentNode != null && parentNode.GetParent(childLocator.HRef) != null)
                {
                    recursive = false;                     //we have a recursion..
                    //this might be ok if one of the links is a prohibitted link...
                }

                //organize locators by non xlink attributes
                //we should have only one valid LocatorRelationshipInfo for each order...
                DefinitionLocatorRelationshipInfo currentRelationShip = null;

                for (int i = cdl.LocatorRelationshipInfos.Count - 1; i >= 0; i--)
                {
                    DefinitionLocatorRelationshipInfo lri = cdl.LocatorRelationshipInfos[i] as DefinitionLocatorRelationshipInfo;
                    if (currentRelationShip != null && lri.IsNonXlinkEquivalentRelationship(currentRelationShip))
                    {
                        continue;
                    }
                    currentRelationShip = lri;

                    //if (lri.IsDefault) continue; //this is just the default definition...no need to include it when we build the tree..
                    if (lri.IsProhibited)
                    {
                        continue;
                    }

                    childLocator.CreateDimensionNode(lang, role,
                                                     parentNode, parentNode.Id, dLink, recursive, definisionLinks, lri, null, buildHypercubeChildren, isScenarioMarkup);
                }
            }
        }
コード例 #5
0
        internal bool TryGetDimensionNodeForRole(string currentLanguage, string currentLabelRole,
                                                 string roleId, out DimensionNode topLevelNode)
        {
            topLevelNode = null;
            DefinitionLink dl = definitionLinks[roleId] as DefinitionLink;

            if (dl != null)
            {
                string label = dl.Title;


                topLevelNode = new DimensionNode(label);
                topLevelNode.MyDefinitionLink = dl;
                if (dl.HypercubeLocatorsHrefs.Count > 0)
                {
                    foreach (string hypercubeHref in dl.HypercubeLocatorsHrefs)
                    {
                        DimensionNode hyperCubeNode;
                        if (dl.TryGetHypercubeNode(currentLanguage, currentLabelRole, this.definitionLinks,
                                                   hypercubeHref, false, out hyperCubeNode))
                        {
                            topLevelNode.AddChild(hyperCubeNode);
                        }
                    }
                }
                else
                {
                    //we might have to build the dimension nodes by itself...
                    if (dl.DimensionLocatorsHrefs.Count > 0)
                    {
                        foreach (string dimHref in dl.DimensionLocatorsHrefs)
                        {
                            DefinitionLocator dloc;
                            if (!dl.TryGetLocator(dimHref, out dloc))
                            {
                                return(false);
                            }

                            DimensionNode dn = dloc.CreateDimensionNode(currentLanguage, currentLabelRole,
                                                                        null, dimHref, dl, true, definitionLinks, null, null, true, false);

                            if (dn != null)
                            {
                                topLevelNode.AddChild(dn);
                            }
                        }
                    }
                }
            }

            return(topLevelNode != null);
        }
コード例 #6
0
        /// <summary>
        /// Creates a new instance of <see cref="DefinitionLocatorRelationshipInfo"/>.
        /// </summary>
        public DefinitionLocatorRelationshipInfo(DimensionNode.NodeType nodeType)
        {
            switch (nodeType)
            {
                case DimensionNode.NodeType.Dimension:
                    this.NodeInfo = new DefinitionNodeInfoDimension(null);
                    break;
                case DimensionNode.NodeType.Hypercube:
                    this.NodeInfo = new DefinitionNodeInfoHypercube();
                    break;

                case DimensionNode.NodeType.Item:
                    this.NodeInfo = new DefinitionNodeInfoMember();
                    break;

            }
        }
コード例 #7
0
        /// <summary>
        /// Constructs a <see cref="ContextDimensionInfo"/> object from the
        /// parent <see cref="DimensionNode"/> of this <see cref="DimensionNode"/>.
        /// </summary>
        /// <returns>The newly constructed <see cref="ContextDimensionInfo"/>.</returns>
        public ContextDimensionInfo BuildContextInfo()
        {
            DimensionNode parentNode = GetParentDimensionTypeDimensionNode();

            if (parentNode == null || parentNode.Id == this.Id)
            {
                return(null);
            }

            ContextDimensionInfo cdi = new ContextDimensionInfo();

            cdi.Id = this.Id;

            cdi.dimensionId = parentNode.Id;
            cdi.type        = ContextDimensionInfo.DimensionType.explicitMember;
            return(cdi);
        }
コード例 #8
0
        internal bool TryGetHypercubeNode(string currentLanguage, string currentLabelRole,
                                          string role,
                                          string hypercubeId,
                                          bool buildnew,
                                          out DimensionNode hypercubeNode)
        {
            hypercubeNode = null;
            DefinitionLink dl = definitionLinks[role] as DefinitionLink;

            if (dl != null)
            {
                if (dl.TryGetHypercubeNode(currentLanguage, currentLabelRole, this.definitionLinks,
                                           hypercubeId, buildnew, out hypercubeNode))
                {
                    return(true);
                }

                return(false);
            }

            return(false);
        }
コード例 #9
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="isClosed"></param>
        /// <param name="isUsable"></param>
        /// <param name="isall"></param>
        /// <param name="isScenario"></param>
        /// <param name="isDefault"></param>
        /// <param name="isRequired"></param>
        /// <param name="targetRole"></param>
        /// <param name="nodeType"></param>
        /// <returns></returns>
        public static DefinitionNodeInfoBase CreateDefinitionNodeInfo(bool? isClosed,
			bool? isUsable, bool? isall, bool? isScenario,
			bool? isDefault, bool? isRequired, string targetRole,  DimensionNode.NodeType nodeType)
        {
            DefinitionNodeInfoBase ret = null;
            switch( nodeType )
            {
                case DimensionNode.NodeType.Dimension:
                    ret = new DefinitionNodeInfoDimension(targetRole);
                    break;
                case DimensionNode.NodeType.Hypercube:
                    ret = new DefinitionNodeInfoHypercube(isClosed, isall, isScenario, targetRole);
                    break;

                case DimensionNode.NodeType.Item:
                    ret = new DefinitionNodeInfoMember(isUsable, isDefault, isRequired, targetRole);
                    break;

            }

            return ret;
        }
コード例 #10
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="tax"></param>
        /// <param name="curNode"></param>
        /// <returns></returns>
        public DimensionNode GetMemberUsingTargetRole(Taxonomy tax, DimensionNode curNode)
        {
            if (curNode.NodeDimensionInfo.TargetRole == null)
            {
                return(curNode);
            }
            DimensionNode topLevelNode;

            if (TryGetDimensionNodeForRole(tax.CurrentLanguage,
                                           tax.CurrentLabelRole,
                                           curNode.NodeDimensionInfo.TargetRole,
                                           out topLevelNode))
            {
                Node ret = topLevelNode.GetChildNode(curNode.parent.Id, curNode.Id);
                if (ret != null)
                {
                    return(ret as DimensionNode);
                }
            }



            return(curNode);
        }
コード例 #11
0
        /// <summary>
        /// Determins if the node or any of the node's parents have the TargetRoleProperty set
        /// </summary>
        /// <returns></returns>
        public bool HasTargetRole()
        {
            if (this.NodeDimensionInfo == null)
            {
                return(false);
            }
            if (this.NodeDimensionInfo.TargetRole != null)
            {
                return(true);
            }
            if (this.Parent == null)
            {
                return(false);
            }

            DimensionNode parentDn = this.Parent as DimensionNode;

            if (parentDn == null)
            {
                return(false);
            }

            return(parentDn.HasTargetRole());
        }
コード例 #12
0
ファイル: Dimension.cs プロジェクト: plamikcho/xbrlpoc
        /// <summary>
        /// 
        /// </summary>
        /// <param name="tax"></param>
        /// <param name="curNode"></param>
        /// <returns></returns>
        public DimensionNode GetMemberUsingTargetRole(Taxonomy tax,    DimensionNode curNode)
        {
            if (curNode.NodeDimensionInfo.TargetRole == null) return curNode;
            DimensionNode topLevelNode;
            if (TryGetDimensionNodeForRole(tax.CurrentLanguage,
                tax.CurrentLabelRole,
                curNode.NodeDimensionInfo.TargetRole,
                out topLevelNode))
            {

                Node ret =  topLevelNode.GetChildNode(curNode.parent.Id, curNode.Id) ;
                if (ret != null) return ret as DimensionNode;

            }

            return curNode;
        }
コード例 #13
0
        /// <summary>
        /// Retrieves the segment and scenario dimension nodes for display.
        /// </summary>
        internal bool TryGetDimensionNodesForDisplay(string currentLanguage, string currentLabelRole,
                                                     Hashtable presentationLinks,
                                                     bool isSegment, bool allDimensions, Dictionary <string, RoleType> roleTypesDt,
                                                     out Dictionary <string, DimensionNode> dimensionNodes)
        {
            dimensionNodes = new Dictionary <string, DimensionNode>();

            foreach (DefinitionLink dl in this.definitionLinks.Values)
            {
                string label = dl.Title;
                if (roleTypesDt != null)
                {
                    RoleType rt;
                    if (roleTypesDt.TryGetValue(label, out rt))
                    {
                        if (!string.IsNullOrEmpty(rt.Definition))
                        {
                            label = rt.Definition;
                        }
                    }
                }

                DimensionNode topLevelNode = new DimensionNode(label);
                topLevelNode.MyDefinitionLink = dl;
                if (isSegment)
                {
                    foreach (string hypercubeHref in dl.HypercubeLocatorsHrefs)
                    {
                        if (!allDimensions)
                        {
                            if (presentationLinks != null && presentationLinks.Contains(dl.Role))
                            {
                                //if the hyper cube is part of the segment list or
                                //if it part of the scenario list do not show it here
                                //as we are going to show it in the element pane....
                                if (dl.segmentHypercubesHRef.Contains(hypercubeHref) ||
                                    dl.scenarioHypercubesHref.Contains(hypercubeHref))
                                {
                                    continue;
                                }
                            }
                        }
                        DimensionNode hyperCubeNode;
                        if (dl.TryGetHypercubeNode(currentLanguage, currentLabelRole, this.definitionLinks,
                                                   hypercubeHref, false, out hyperCubeNode))
                        {
                            topLevelNode.AddChild(hyperCubeNode);
                        }
                    }
                }
                else
                {
                    foreach (string hypercubeHref in dl.HypercubeLocatorsHrefs)
                    {
                        //we want to show all the scenario dimensions and
                        //and all the  dimensions that are not associated with the segment

                        if (dl.scenarioHypercubesHref.Contains(hypercubeHref) ||
                            !dl.segmentHypercubesHRef.Contains(hypercubeHref))
                        {
                            DimensionNode hyperCubeNode;
                            if (dl.TryGetHypercubeNode(currentLanguage, currentLabelRole, this.definitionLinks,
                                                       hypercubeHref, false, out hyperCubeNode))
                            {
                                topLevelNode.AddChild(hyperCubeNode);
                            }
                        }
                    }
                }

                if (topLevelNode.Children != null && topLevelNode.Children.Count > 0)
                {
                    dimensionNodes.Add(dl.Role, topLevelNode);
                }
            }

            return(true);
        }
コード例 #14
0
ファイル: DefinitionLink.cs プロジェクト: plamikcho/xbrlpoc
        public bool TryGetHypercubeNode(string currentLanguage, string currentLabelRole,
            Hashtable definitionLinks, 
            string hypercubeId,
            bool buildnew, out DimensionNode hypercubeNode)
        {
            lock (this)
            {
                if (!buildnew)
                {
                    foreach (DimensionNode dn in HyperCubeNodesList)
                    {
                        if (dn.Id.Equals(hypercubeId))
                        {
                            hypercubeNode = dn;
                            return true;
                        }
                    }
                }

                hypercubeNode = null;
                DefinitionLocator dloc;
                if (!this.TryGetLocator(hypercubeId, out dloc)) return false;

                hypercubeNode = dloc.CreateDimensionNode(currentLanguage, currentLabelRole,
                   null, hypercubeId, this, true, definitionLinks, null, null, true, IsScenarioHypercube(hypercubeId, definitionLinks ) );

                if (hypercubeNode != null)
                {

                    hypercubeNode.NodeDimensionInfo = new DefinitionLocatorRelationshipInfo( DimensionNode.NodeType.Hypercube);

                    if (!buildnew)
                    {
                        HyperCubeNodesList.Add(hypercubeNode);

                    }

                }

            }

            return hypercubeNode != null;
        }
コード例 #15
0
ファイル: DefinitionLink.cs プロジェクト: plamikcho/xbrlpoc
        private void RecursivelyBuildMemberList(DimensionNode dn, ref List<string> members )
        {
            members.Add(dn.Id);
            if (dn.children != null)
            {
                foreach (DimensionNode child in dn.children)
                {
                    RecursivelyBuildMemberList(child, ref members);
                }

            }
        }
コード例 #16
0
        internal void  BuildSelectedCommonDimensionDictionary(List <string> commonRoles,
                                                              Dictionary <string, DimensionNode> commonDimensionNodes,
                                                              ref Dictionary <string, DefinitionLink> rolesByCommonDimension)
        {
            foreach (KeyValuePair <string, DimensionNode> kvp in commonDimensionNodes)
            {
                if (!commonRoles.Contains(kvp.Key))
                {
                    continue;
                }

                if (kvp.Value.children == null)
                {
                    continue;
                }

                foreach (DimensionNode hypercubeNode in kvp.Value.children)
                {
                    if (hypercubeNode.children == null)
                    {
                        continue;
                    }

                    foreach (DimensionNode dn in hypercubeNode.children)
                    {
                        if (dn.children == null)
                        {
                            continue;
                        }

                        foreach (DimensionNode dimDom in dn.children)
                        {
                            if (dimDom.children != null && dimDom.children.Count > 0)
                            {
                                //dimension domain has children members....
                                DefinitionLink orig;
                                if (rolesByCommonDimension.TryGetValue(dn.Id, out orig))
                                {
                                    //we have the dimension in multiple linkbase
                                    //hardcoding to get the right us role..,.,
                                    if (dn.MyDefinitionLink.Role.Contains("http://xbrl.us/us-gaap/role/statement/CommonDomainMembers"))
                                    {
                                        rolesByCommonDimension[dn.Id] = dn.MyDefinitionLink;
                                    }
                                    else if (orig.Role.Contains("http://xbrl.us/us-gaap/role/statement/CommonDomainMembers"))
                                    {
                                        //essentially do nothing as we are setting back to the orig
                                        rolesByCommonDimension[dn.Id] = orig;
                                    }
                                    else
                                    {
                                        //found more than one common role...
                                        //better update with the one that has more children
                                        //so that we can get a more complete view...
                                        int origCount = 0;
                                        int curCount  = 0;
                                        dimDom.GetChildrenCount(ref curCount);
                                        foreach (DimensionNode hyNode in orig.HyperCubeNodesList)
                                        {
                                            DimensionNode otherdimDom = hyNode.GetChildNode(dn.Id, dimDom.Id) as DimensionNode;
                                            if (otherdimDom != null)
                                            {
                                                otherdimDom.GetChildrenCount(ref origCount);
                                                break;
                                            }
                                        }

                                        // need to update only
                                        //with the one that has more children...
                                        if (curCount > origCount)
                                        {
                                            rolesByCommonDimension[dn.Id] = dn.MyDefinitionLink;
                                        }
                                    }
                                }
                                else
                                {
                                    rolesByCommonDimension[dn.Id] = dn.MyDefinitionLink;
                                }
                            }
                        }
                    }
                }
            }
        }
コード例 #17
0
ファイル: TestDimension.cs プロジェクト: plamikcho/xbrlpoc
        /// <exclude/>
        protected StringBuilder DisplayNode(DimensionNode n, int level)
        {
            StringBuilder sb = new StringBuilder();

            for (int i = 0; i < level; ++i)
            {
                sb.Append(" ");
            }

            sb.Append(n.Label).Append(Environment.NewLine);

            if (n.Children != null)
            {
                foreach (DimensionNode c in n.Children)
                {
                    sb.Append(DisplayNode(c, level + 1));
                }
            }

            return sb;
        }
コード例 #18
0
        internal DimensionNode CreateDimensionNode(string lang, string role,
			Node parentNode, string parentId , DefinitionLink dLink, bool recursive, Hashtable definisionLinks,
			DefinitionLocatorRelationshipInfo lri, DimensionNode newNode, bool buildHypercubeChildren, bool isScenarioMarkup)
        {
            if (e == null) return null;

            if (newNode == null)
            {
                newNode = new DimensionNode(e);
                newNode.IsSegmentMarkup = !isScenarioMarkup;
                newNode.SetLabel(lang, role);
                newNode.NodeDimensionInfo = lri;
                newNode.IsDraggable = false;
                if (lri != null && lri.NodeType == DimensionNode.NodeType.Item && lri.Usable )
                {

                    if (!e.IsAbstract)
                    {
                        newNode.IsDraggable = true;
                    }
                }

                newNode.MyDefinitionLink = dLink;
            }

            if (lri != null)
            {
                newNode.SetOrder(lri.Order);

                if (PresentationLocator.preferredLabelRole.Equals(role))
                {
                    if (lri.PrefLabel != null)
                    {
                        newNode.UpdatePreferredLabel(lang, lri.PrefLabel);
                    }
                }
            }

            if (parentNode != null)
            {
                // and add it
                parentNode.AddChild(newNode);
                parentId = parentNode.Id;
            }

            if (recursive)
            {

                if (lri != null && lri.TargetRole != null && dLink.Role != lri.TargetRole)
                {
                    if (definisionLinks != null)
                    {
                        DefinitionLink targetDLink = definisionLinks[lri.TargetRole] as DefinitionLink;

                        if (targetDLink != null)
                        {
                            DefinitionLocator targetLocator;
                            if (targetDLink.TryGetLocator(newNode.Id, out targetLocator))
                            {

                                CreateChildNodes(lang, role, newNode,
                                    targetDLink, definisionLinks,
                                    targetLocator.childLocatorsByHRef, buildHypercubeChildren, isScenarioMarkup);
                            }

                        }

                    }
                    if (newNode.Children != null)
                    {
                        newNode.Children.Sort(new NodeOrderSorter());
                    }
                    return newNode;

                }

                CreateChildNodes(lang, role, newNode, dLink, definisionLinks, childLocatorsByHRef, buildHypercubeChildren, isScenarioMarkup);

                //need to sort the nodes
                if (newNode.Children != null)
                {
                    newNode.Children.Sort(new NodeOrderSorter());
                }
            }

            return newNode;
        }
コード例 #19
0
ファイル: ReportBuilder.cs プロジェクト: plamikcho/xbrlpoc
        /// <summary>
        /// Crawls a <see cref="DimensionNode"/> (<paramref name="dNode"/>) looking for Segments and storing them in this.<see cref="commonDimensions"/>
        /// </summary>
        /// <param name="dNode">The <see cref="DimensionNode"/> to crawl looking for Segments.</param>
        //[Obsolete]
        private void PopulateCommonDimensions( DimensionNode dNode )
        {
            if( dNode.NodeDimensionInfo != null && dNode.NodeDimensionInfo.NodeType == DimensionNode.NodeType.Item )
            {
                DimensionNode pNode = dNode.GetParentDimensionTypeDimensionNode();
                if( !this.commonDimensions.ContainsKey( pNode.Id ) )
                {
                    this.commonAxes.Add( pNode.Id );
                    this.commonDimensions[ pNode.Id ] = new List<Segment>();
                }

                Segment segment = new Segment
                {
                    DimensionInfo = new ContextDimensionInfo
                    {
                        dimensionId = pNode.Id,
                        Id = dNode.Id
                    },
                    ValueName = dNode.Label,
                    ValueType = pNode.Id
                };

                this.commonDimensions[ pNode.Id ].Add( segment );
            }

            if( dNode.HasChildren && dNode.Children.Count > 0 )
            {
                foreach( DimensionNode child in dNode.Children )
                {
                    this.PopulateCommonDimensions( child );
                }
            }
        }
コード例 #20
0
        internal void AddChild( DefinitionLocator childPl,
			float orderArg, string prefLabel, 
			string targetRole, bool? isClosed, 
			bool? isUsable, bool? isall, bool? isScenario,
			bool? isDefault, bool? isRequiresElement, DimensionNode.NodeType nodeType,
			string priority, bool isProhibited )
        {
            childPl.AddParent( this );

            if( this.childLocatorsByHRef == null )
            {
                this.childLocatorsByHRef = new HybridDictionary();
                this.childDisplayOrder = new HybridDictionary();
            }

            float dispOrder = orderArg;

            DefinitionLocatorRelationshipInfo newRelation = DefinitionLocatorRelationshipInfo.CreateObj( prefLabel,
                priority, orderArg,dispOrder, prefLabel,  isProhibited,
                targetRole ,isClosed, isUsable, isall,isScenario , isRequiresElement, isDefault, nodeType );

            ChildDefinitionLocator cpl = childLocatorsByHRef[childPl.HRef] as ChildDefinitionLocator;

            if ( cpl == null )
            {
                // doesn't exist in either the href table or the order table
                cpl = new ChildDefinitionLocator( childPl.HRef, newRelation );

                childLocatorsByHRef.Add( childPl.HRef, cpl );

                // keep these separate so they don't impact each other
                ChildDefinitionLocator cplOrder = new ChildDefinitionLocator( cpl );

            }
            else
            {
                // the cpl already exists, append the existing relation info
                cpl.AddRelationship( newRelation );

            }
        }
コード例 #21
0
ファイル: Dimension.cs プロジェクト: plamikcho/xbrlpoc
        internal bool TryGetDimensionNodeForRole(string currentLanguage, string currentLabelRole,
			string roleId,	out DimensionNode  topLevelNode )
        {
            topLevelNode = null;
            DefinitionLink dl = definitionLinks[roleId] as DefinitionLink;

            if( dl != null )
            {

                string label = dl.Title;

                topLevelNode = new DimensionNode(label);
                topLevelNode.MyDefinitionLink = dl;
                if (dl.HypercubeLocatorsHrefs.Count > 0)
                {
                    foreach (string hypercubeHref in dl.HypercubeLocatorsHrefs)
                    {

                        DimensionNode hyperCubeNode;
                        if (dl.TryGetHypercubeNode(currentLanguage, currentLabelRole, this.definitionLinks,
                            hypercubeHref,false, out hyperCubeNode))
                        {
                            topLevelNode.AddChild(hyperCubeNode);

                        }

                    }
                }
                else
                {
                    //we might have to build the dimension nodes by itself...
                    if (dl.DimensionLocatorsHrefs.Count > 0)
                    {
                        foreach (string dimHref in dl.DimensionLocatorsHrefs)
                        {
                            DefinitionLocator dloc;
                            if (!dl.TryGetLocator(dimHref, out dloc)) return false;

                            DimensionNode dn  = dloc.CreateDimensionNode(currentLanguage, currentLabelRole,
                               null, dimHref, dl, true, definitionLinks, null, null, true, false);

                            if (dn != null)
                            {

                                topLevelNode.AddChild(dn);

                            }
                        }
                    }
                }

            }

            return topLevelNode != null;
        }
コード例 #22
0
        private void CreateChildNodes(string lang, string role,
			DimensionNode parentNode ,
			DefinitionLink dLink,  Hashtable definisionLinks,
			HybridDictionary ChildDefinitionLocatorsHD, bool buildHypercubeChildren, bool isScenarioMarkup)
        {
            if (ChildDefinitionLocatorsHD == null) return;

            if (!buildHypercubeChildren)
            {
                if (parentNode.NodeDimensionInfo != null &&
                    parentNode.NodeDimensionInfo.NodeType == DimensionNode.NodeType.Hypercube)
                {
                    //no need to build the children...
                    return;
                }
            }
            foreach (ChildDefinitionLocator cdl in ChildDefinitionLocatorsHD.Values)
            {

                DefinitionLocator childLocator;
                if (!dLink.TryGetLocator(cdl.HRef, out childLocator))
                {
                    continue;
                }

                bool recursive = true;
                if (parentNode != null && parentNode.GetParent(childLocator.HRef) != null)
                {
                    recursive = false; //we have a recursion..
                    //this might be ok if one of the links is a prohibitted link...

                }

                //organize locators by non xlink attributes
                //we should have only one valid LocatorRelationshipInfo for each order...
                DefinitionLocatorRelationshipInfo currentRelationShip=null;

                for (int i = cdl.LocatorRelationshipInfos.Count - 1; i >= 0; i--)
                {
                    DefinitionLocatorRelationshipInfo lri = cdl.LocatorRelationshipInfos[i] as DefinitionLocatorRelationshipInfo;
                    if (currentRelationShip != null && lri.IsNonXlinkEquivalentRelationship(currentRelationShip)) continue;
                    currentRelationShip = lri;

                    //if (lri.IsDefault) continue; //this is just the default definition...no need to include it when we build the tree..
                    if ( lri.IsProhibited)
                        continue;

                    childLocator.CreateDimensionNode(lang, role,
                         parentNode, parentNode.Id, dLink, recursive, definisionLinks, lri, null, buildHypercubeChildren, isScenarioMarkup );

                }

            }
        }
コード例 #23
0
ファイル: Dimension.cs プロジェクト: plamikcho/xbrlpoc
        /// <summary>
        /// Retrieves the segment and scenario dimension nodes for display.
        /// </summary>
        internal bool TryGetDimensionNodesForDisplay(string currentLanguage, string currentLabelRole,
			Hashtable presentationLinks, 
			bool isSegment, bool allDimensions,  Dictionary<string, RoleType> roleTypesDt,
			out Dictionary<string, DimensionNode> dimensionNodes)
        {
            dimensionNodes = new Dictionary<string, DimensionNode>();

            foreach (DefinitionLink dl in this.definitionLinks.Values)
            {
                string label = dl.Title;
                if (roleTypesDt != null)
                {
                    RoleType rt;
                    if (roleTypesDt.TryGetValue(label, out rt))
                    {

                        if (!string.IsNullOrEmpty(rt.Definition))
                        {
                            label = rt.Definition;
                        }
                    }
                }

                DimensionNode topLevelNode = new DimensionNode(label);
                topLevelNode.MyDefinitionLink = dl;
                if (isSegment)
                {
                    foreach (string hypercubeHref in dl.HypercubeLocatorsHrefs)
                    {
                        if (!allDimensions)
                        {
                            if ( presentationLinks!= null &&  presentationLinks.Contains(dl.Role))
                            {
                                //if the hyper cube is part of the segment list or
                                //if it part of the scenario list do not show it here
                                //as we are going to show it in the element pane....
                                if (dl.segmentHypercubesHRef.Contains(hypercubeHref) ||
                                    dl.scenarioHypercubesHref.Contains(hypercubeHref)) continue;

                            }
                        }
                        DimensionNode hyperCubeNode;
                        if (dl.TryGetHypercubeNode(currentLanguage, currentLabelRole, this.definitionLinks,
                            hypercubeHref,false, out hyperCubeNode))
                        {
                            topLevelNode.AddChild(hyperCubeNode);

                        }

                    }
                }
                else
                {
                    foreach (string hypercubeHref in dl.HypercubeLocatorsHrefs)
                    {
                        //we want to show all the scenario dimensions and
                        //and all the  dimensions that are not associated with the segment

                        if (dl.scenarioHypercubesHref.Contains(hypercubeHref)
                            || !dl.segmentHypercubesHRef.Contains(hypercubeHref))
                        {

                            DimensionNode hyperCubeNode;
                            if (dl.TryGetHypercubeNode(currentLanguage, currentLabelRole, this.definitionLinks,
                                hypercubeHref,false, out hyperCubeNode))
                            {
                                topLevelNode.AddChild(hyperCubeNode);

                            }

                        }

                    }

                }

                if (topLevelNode.Children != null && topLevelNode.Children.Count > 0)
                {
                    dimensionNodes.Add(dl.Role, topLevelNode);
                }

            }

            return true;
        }
コード例 #24
0
        internal DimensionNode CreateDimensionNode(string lang, string role,
                                                   Node parentNode, string parentId, DefinitionLink dLink, bool recursive, Hashtable definisionLinks,
                                                   DefinitionLocatorRelationshipInfo lri, DimensionNode newNode, bool buildHypercubeChildren, bool isScenarioMarkup)
        {
            if (e == null)
            {
                return(null);
            }

            if (newNode == null)
            {
                newNode = new DimensionNode(e);
                newNode.IsSegmentMarkup = !isScenarioMarkup;
                newNode.SetLabel(lang, role);
                newNode.NodeDimensionInfo = lri;
                newNode.IsDraggable       = false;
                if (lri != null && lri.NodeType == DimensionNode.NodeType.Item && lri.Usable)
                {
                    if (!e.IsAbstract)
                    {
                        newNode.IsDraggable = true;
                    }
                }

                newNode.MyDefinitionLink = dLink;
            }

            if (lri != null)
            {
                newNode.SetOrder(lri.Order);


                if (PresentationLocator.preferredLabelRole.Equals(role))
                {
                    if (lri.PrefLabel != null)
                    {
                        newNode.UpdatePreferredLabel(lang, lri.PrefLabel);
                    }
                }
            }


            if (parentNode != null)
            {
                // and add it
                parentNode.AddChild(newNode);
                parentId = parentNode.Id;
            }



            if (recursive)
            {
                if (lri != null && lri.TargetRole != null && dLink.Role != lri.TargetRole)
                {
                    if (definisionLinks != null)
                    {
                        DefinitionLink targetDLink = definisionLinks[lri.TargetRole] as DefinitionLink;

                        if (targetDLink != null)
                        {
                            DefinitionLocator targetLocator;
                            if (targetDLink.TryGetLocator(newNode.Id, out targetLocator))
                            {
                                CreateChildNodes(lang, role, newNode,
                                                 targetDLink, definisionLinks,
                                                 targetLocator.childLocatorsByHRef, buildHypercubeChildren, isScenarioMarkup);
                            }
                        }
                    }
                    if (newNode.Children != null)
                    {
                        newNode.Children.Sort(new NodeOrderSorter());
                    }
                    return(newNode);
                }


                CreateChildNodes(lang, role, newNode, dLink, definisionLinks, childLocatorsByHRef, buildHypercubeChildren, isScenarioMarkup);


                //need to sort the nodes
                if (newNode.Children != null)
                {
                    newNode.Children.Sort(new NodeOrderSorter());
                }
            }


            return(newNode);
        }
コード例 #25
0
ファイル: Dimension.cs プロジェクト: plamikcho/xbrlpoc
 internal bool TryGetHypercubeNode(string currentLanguage, string currentLabelRole,
    string role,
     string hypercubeId,
     out DimensionNode hypercubeNode)
 {
     return TryGetHypercubeNode(currentLanguage, currentLabelRole,
         role, hypercubeId, false, out hypercubeNode);
 }
コード例 #26
0
ファイル: DefinitionLink.cs プロジェクト: plamikcho/xbrlpoc
        /// <summary>
        /// based on the parent and child element types in the arc...
        /// we need to decide on the arc type...
        /// </summary>
        /// <param name="parentType"></param>
        /// <param name="childType"></param>
        /// <param name="relInfo"></param>
        /// <returns></returns>
        private static string GetArcRoleType(DimensionNode.NodeType parentType, 
			DimensionNode.NodeType childType ,
			DefinitionLocatorRelationshipInfo relInfo)
        {
            if ( childType == DimensionNode.NodeType.Hypercube )
            {
                //child is a hypercube..
                //so it has to be a all or not all relationship
                if( relInfo.IsAllRelationShip )
                {
                    return ALL_RELATIONSHIP;
                }
                else
                {
                    return NOT_ALL_RELATIONSHIP;
                }
            }

            if( childType == DimensionNode.NodeType.Dimension )
            {

                return HYPERCUBE_DIMENSION_RELATIONSHIP;

            }

            if( parentType == DimensionNode.NodeType.Dimension &&
                childType == DimensionNode.NodeType.Item )
            {
                if (relInfo.IsDefault)
                {
                    return DIMENSION_DEFAULT_RELATIONSHIP;
                }

                return DIMENSION_DOMAIN_RELATIONSHIP;
            }

            return DOMAIN_MEMBER_RELATIONSHIP;
        }
コード例 #27
0
ファイル: Dimension.cs プロジェクト: plamikcho/xbrlpoc
        internal bool TryGetHypercubeNode(string currentLanguage, string currentLabelRole,
           string role,    
            string hypercubeId,
            bool buildnew,
            out DimensionNode hypercubeNode)
        {
            hypercubeNode = null;
            DefinitionLink dl = definitionLinks[role] as DefinitionLink;

            if (dl != null)
            {
                if (dl.TryGetHypercubeNode(currentLanguage, currentLabelRole, this.definitionLinks,
                    hypercubeId,buildnew, out hypercubeNode))
                {
                    return true;
                }

                return false;

            }

            return false;
        }
コード例 #28
0
ファイル: DefinitionLink.cs プロジェクト: plamikcho/xbrlpoc
        /// <summary>
        /// UPDATE DEFINITION LINK TO CHANGE AN ARC TO PROHIBITED
        /// </summary>
        /// <param name="elementToProhibit"></param>
        /// <param name="ParentNode"></param>
        /// <returns></returns>
        public bool ProhibitArc(DimensionNode elementToProhibit,
            Node ParentNode)
        {
            //the cache of dimension node is not clean so clear it..
            this.HyperCubeNodesList.Clear();

            DefinitionLocator parentLocator = locators[ParentNode.Id] as DefinitionLocator;

            if (parentLocator == null) return false;

            ChildDefinitionLocator cpl = parentLocator.childLocatorsByHRef[elementToProhibit.Id] as ChildDefinitionLocator;
            if (cpl != null)
            {
                foreach (DefinitionLocatorRelationshipInfo lri in cpl.LocatorRelationshipInfos)
                {

                    if (((double)(lri.Order)).ToString("####0.####", new CultureInfo("en-US")).Equals(
                            elementToProhibit.order.ToString("####0.####", new CultureInfo("en-US"))) &&
                            lri.IsProhibited == false)
                    {
                        //simply prohibit the link...
                        //when we reload the prohibited link would anyway superseed the optional one
                        lri.IsProhibited = true;
                    }
                }

                //if it is a axis then we need to remove it from the axis collection
                this.DimensionHrefsWithDefault.Remove(elementToProhibit.Id);
                this.DimensionLocatorsHrefs.Remove(elementToProhibit.Id);

                //if it is a hypercube
                this.HypercubeLocatorsHrefs.Remove(elementToProhibit.Id);

            }

            return true;
        }
コード例 #29
0
ファイル: Dimension.cs プロジェクト: plamikcho/xbrlpoc
        internal bool TryGetMeasureDimensionNodesForRole(string currentLanguage, string currentLabelRole,
            string roleId, Taxonomy tax,   out DimensionNode topLevelNode)
        {
            topLevelNode = null;
            DefinitionLink dl = definitionLinks[roleId] as DefinitionLink;

            if (dl != null)
            {

                string label = dl.Title;

                topLevelNode = new DimensionNode(label);
                topLevelNode.MyDefinitionLink = dl;
                if (dl.HypercubeLocatorsHrefs.Count > 0)
                {
                    foreach (string hypercubeHref in dl.HypercubeLocatorsHrefs)
                    {
                        List<DimensionNode> dns ;
                       dl.BuildMeasureElementTreeForHypercubeId( tax, hypercubeHref, false, out dns);

                        if( dns != null)
                        {
                            foreach (DimensionNode dn in dns)
                            {
                                topLevelNode.AddChild(dn);
                            }
                        }

                    }
                }

            }

            return topLevelNode != null;
        }
コード例 #30
0
 private void RecursivelyGetExtendedDimensionNodes(DimensionNode dn, ref Dictionary<string, DimensionNode> extNodes)
 {
     if (dn.TaxonomyInfoId == 0 && dn.NodeDimensionInfo != null)
     {
         extNodes[dn.Id] = dn;
     }
     if (dn.children != null)
     {
         foreach (DimensionNode child in dn.children)
         {
             RecursivelyGetExtendedDimensionNodes(child, ref extNodes);
         }
     }
 }
コード例 #31
0
        internal static DefinitionLocatorRelationshipInfo CreateObj(string label, string priority,
			 float origOrder, float orderArg, string prefLabel, bool isProhibited,
			string targetRole, bool? isClosed,
			bool? isUsable, bool? isall, bool? isScenario,
			bool? isRequiresElement,
			bool? isDefault,
			DimensionNode.NodeType nodeType)
        {
            DefinitionLocatorRelationshipInfo obj = new DefinitionLocatorRelationshipInfo();
            obj.Label = label;
            obj.IsProhibited = isProhibited;
            obj.PrefLabel = prefLabel;
            obj.Order = orderArg;
            obj.OrigOrder = origOrder;
            obj.Priority = Convert.ToInt32(priority);
            obj.NodeInfo = 	DefinitionNodeInfoBase.CreateDefinitionNodeInfo(isClosed,
            isUsable, isall, isScenario, isDefault, isRequiresElement,
            targetRole, nodeType);

            if (prefLabel != null)
            {
                int lastSlash = prefLabel.LastIndexOf("/") + 1;
                obj.PrefLabel = prefLabel.Substring(lastSlash, prefLabel.Length - lastSlash);
            }

            return obj;
        }