Пример #1
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);
        }
Пример #2
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);
                }
            }
        }
Пример #3
0
        internal void AddRelationship(DefinitionLocatorRelationshipInfo newRelation)
        {
            if (CanAddRelationship(newRelation))
            {
                bool add = true;
                if (locatorRelationshipInfos.Count > 0)
                {
                    if (newRelation.NodeType == DimensionNode.NodeType.Item)
                    {
                        if (newRelation.IsDefault)
                        {
                            //we maybe just adding the default flag  to an existing relationship.
                            add = false;
                            foreach (DefinitionLocatorRelationshipInfo lri in this.locatorRelationshipInfos)
                            {
                                //since default canot be used in the instance document....
                                (lri.NodeInfo as DefinitionNodeInfoMember).IsDefault = true;
                                (lri.NodeInfo as DefinitionNodeInfoMember).Usable    = false;
                            }
                        }
                        else
                        {
                            //if the list already has a default value then we need to update it
                            //with the current one..
                            //the default should have all the members other than the order matching.
                            for (int i = 0; i < locatorRelationshipInfos.Count; i++)
                            {
                                DefinitionLocatorRelationshipInfo lri = locatorRelationshipInfos[i] as DefinitionLocatorRelationshipInfo;
                                if (lri.IsDefault)
                                {
                                    //update lri
                                    if (newRelation.IsProhibited == lri.IsProhibited &&
                                        newRelation.Priority == lri.Priority)
                                    {
                                        (newRelation.NodeInfo as DefinitionNodeInfoMember).IsDefault = true;
                                        (newRelation.NodeInfo as DefinitionNodeInfoMember).Usable    = false;
                                        locatorRelationshipInfos[i] = newRelation;
                                        add = false;
                                    }
                                    else
                                    {
                                        //since there is a defaul we need to make this new relationship also a default.
                                        (newRelation.NodeInfo as DefinitionNodeInfoMember).IsDefault = true;
                                        (newRelation.NodeInfo as DefinitionNodeInfoMember).Usable    = false;
                                    }
                                }
                            }
                        }
                    }
                }

                if (add)
                {
                    this.locatorRelationshipInfos.Add(newRelation);
                    locatorRelationshipInfos.Sort();
                }
            }
        }
Пример #4
0
        internal bool IsNonXlinkEquivalentRelationship(DefinitionLocatorRelationshipInfo other)
        {
            if (!base.IsNonXlinkEquivalentRelationship(other))
            {
                return(false);
            }


            return(true);
        }
Пример #5
0
        /// <summary>
        /// Determines whether a supplied <see cref="Object"/> is equal to this <see cref="DefinitionLocatorRelationshipInfo"/>.
        /// </summary>
        /// <param name="obj">The <see cref="Object"/> to be compared to this <see cref="DefinitionLocatorRelationshipInfo"/>.
        /// Assumed to be a <see cref="DefinitionLocatorRelationshipInfo"/>.</param>
        /// <returns>True if <paramref name="obj"/> is equal to this <see cref="DefinitionLocatorRelationshipInfo"/>.</returns>
        /// <remarks>
        /// To be equal, the following properties in the two <see cref="DefinitionLocatorRelationshipInfo"/> must be equal:
        /// <bl>
        /// <li>Target role.</li>
        /// <li>Is closed.</li>
        /// <li>Usable.</li>
        /// <li>IsAllRelationship.</li>
        /// <li>IsScenario.</li>
        /// <li>IsDefault.</li>
        /// <li>IsRequiresElement.</li>
        /// <li>NodeType.</li>
        /// </bl>
        /// </remarks>
        public override bool Equals(object obj)
        {
            DefinitionLocatorRelationshipInfo lri = obj as DefinitionLocatorRelationshipInfo;

            if (!this.NodeInfo.Equals(lri.NodeInfo))
            {
                return(false);
            }

            return(base.Equals(obj));
        }
Пример #6
0
        internal bool CanAddRelationship(DefinitionLocatorRelationshipInfo newRelation)
        {
            foreach (DefinitionLocatorRelationshipInfo lri in this.locatorRelationshipInfos)
            {
                if (lri.Equals(newRelation))
                {
                    return(false);
                }
            }

            return(true);
        }
Пример #7
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);
            }
        }
Пример #8
0
        internal void SetRequiredElementRelationshipInfo(ref List <string> vals)
        {
            foreach (ChildDefinitionLocator cdl in this.childLocatorsByHRef.Values)
            {
                float checkedOrder = -1;
                for (int i = cdl.LocatorRelationshipInfos.Count - 1; i >= 0; i--)
                {
                    DefinitionLocatorRelationshipInfo dlri = cdl.LocatorRelationshipInfos[i] as DefinitionLocatorRelationshipInfo;

                    if (dlri.IsRequiresElement != true || dlri.OrigOrder == checkedOrder)
                    {
                        continue;
                    }

                    checkedOrder = dlri.OrigOrder;

                    if (!dlri.IsProhibited)
                    {
                        vals.Add(cdl.HRef);
                    }
                }
            }
        }
Пример #9
0
        /// <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;
        }
 /// <summary>
 /// Creates a new instance of <see cref="DefinitionLocatorRelationshipInfo"/> 
 /// and initializes its properties from a parameter-supplied <see cref="DefinitionLocatorRelationshipInfo"/>
 /// </summary>
 /// <param name="orig"></param>
 public DefinitionLocatorRelationshipInfo(DefinitionLocatorRelationshipInfo orig)
     : base(orig)
 {
     this.NodeInfo = orig.NodeInfo.CreateCopy();
 }
Пример #11
0
        internal void AddRelationship( DefinitionLocatorRelationshipInfo newRelation )
        {
            if ( CanAddRelationship( newRelation ) )
            {
                bool add = true;
                if (locatorRelationshipInfos.Count > 0)
                {
                    if (newRelation.NodeType == DimensionNode.NodeType.Item)
                    {
                        if (newRelation.IsDefault)
                        {
                            //we maybe just adding the default flag  to an existing relationship.
                            add = false;
                            foreach (DefinitionLocatorRelationshipInfo lri in this.locatorRelationshipInfos)
                            {
                                //since default canot be used in the instance document....
                                (lri.NodeInfo as DefinitionNodeInfoMember).IsDefault = true;
                                (lri.NodeInfo as DefinitionNodeInfoMember).Usable = false;
                            }

                        }
                        else
                        {
                            //if the list already has a default value then we need to update it
                            //with the current one..
                            //the default should have all the members other than the order matching.
                            for (int i = 0; i < locatorRelationshipInfos.Count; i++)
                            {
                                DefinitionLocatorRelationshipInfo lri = locatorRelationshipInfos[i] as DefinitionLocatorRelationshipInfo;
                                if (lri.IsDefault)
                                {
                                    //update lri
                                    if (newRelation.IsProhibited == lri.IsProhibited &&
                                        newRelation.Priority == lri.Priority)
                                    {
                                        (newRelation.NodeInfo as DefinitionNodeInfoMember).IsDefault = true;
                                        (newRelation.NodeInfo as DefinitionNodeInfoMember).Usable = false;
                                        locatorRelationshipInfos[i] = newRelation;
                                        add = false;
                                    }
                                    else
                                    {
                                        //since there is a defaul we need to make this new relationship also a default.
                                        (newRelation.NodeInfo as DefinitionNodeInfoMember).IsDefault = true;
                                        (newRelation.NodeInfo as DefinitionNodeInfoMember).Usable = false;

                                    }

                                }
                            }
                        }
                    }

                }

                if (add)
                {
                    this.locatorRelationshipInfos.Add(newRelation);
                    locatorRelationshipInfos.Sort();

                }
            }
        }
Пример #12
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);
        }
        internal bool IsNonXlinkEquivalentRelationship(DefinitionLocatorRelationshipInfo other)
        {
            if (!base.IsNonXlinkEquivalentRelationship(other)) return false;

            return true;
        }
Пример #14
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="tax"></param>
        /// <param name="hypercubeId"></param>
        /// <param name="buildHyperubeChildren"></param>
        /// <param name="dimNodes"></param>
        public void BuildMeasureElementTreeForHypercubeId(Taxonomy tax, string hypercubeId,
		bool buildHyperubeChildren, out List<DimensionNode> dimNodes)
        {
            dimNodes = new List<DimensionNode>();
            string curLang = tax.currentLanguage;
            string curLabelRole = tax.currentLabelRole;

            if (curLang == null)
            {
                curLang = "en";

            }

            if (curLabelRole == null)
            {
                curLabelRole = PresentationLocator.preferredLabelRole;
            }

            //determine all the measure element parents of the hypercube element id

            foreach (string measureId in this.MeasureLocatorsHrefs)
            {
                DefinitionLocator dloc;
                if (!this.TryGetLocator(measureId, out dloc)) continue;

                if (dloc.childLocatorsByHRef == null) continue;

                bool add = false;
                foreach (string key in dloc.childLocatorsByHRef.Keys)
                {
                    if (key.Equals(hypercubeId))
                    {
                        ChildDefinitionLocator lri = dloc.childLocatorsByHRef[hypercubeId] as ChildDefinitionLocator;
                        foreach (DefinitionLocatorRelationshipInfo dri in lri.LocatorRelationshipInfos)
                        {
                            if (!dri.IsProhibited)
                            {

                                add = true;

                            }

                        }
                        break;

                    }
                }

                if (add )
                {
                    DefinitionLocatorRelationshipInfo parentDRI = new DefinitionLocatorRelationshipInfo(DimensionNode.NodeType.Item);

                    DimensionNode dimNode = dloc.CreateDimensionNode(curLang, curLabelRole,
                    null,	measureId, this, true, tax.NetDefinisionInfo.DefinitionLinks,
                    parentDRI, null, buildHyperubeChildren,
                    IsScenarioHypercube(hypercubeId, tax.NetDefinisionInfo.DefinitionLinks));

                    if (dimNode != null)
                    {
                        dimNodes.Add(dimNode);
                    }

                }
            }

            return;
        }
Пример #15
0
        internal bool CanAddRelationship( DefinitionLocatorRelationshipInfo newRelation )
        {
            foreach( DefinitionLocatorRelationshipInfo lri in this.locatorRelationshipInfos )
            {
                if ( lri.Equals( newRelation ) )
                {
                    return false;
                }
            }

            return true;
        }
Пример #16
0
 /// <summary>
 /// Creates a new instance of <see cref="DefinitionLocatorRelationshipInfo"/>
 /// and initializes its properties from a parameter-supplied <see cref="DefinitionLocatorRelationshipInfo"/>
 /// </summary>
 /// <param name="orig"></param>
 public DefinitionLocatorRelationshipInfo(DefinitionLocatorRelationshipInfo orig)
     : base(orig)
 {
     this.NodeInfo = orig.NodeInfo.CreateCopy();
 }
Пример #17
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;
        }
Пример #18
0
        public bool UpdateOptionalArc(string elementId, string parentElementId,
    DefinitionLocatorRelationshipInfo newLocatorRelationshipInfo, Taxonomy taxonomy)
        {
            DefinitionLocator parentLocator = locators[parentElementId] as DefinitionLocator;
            newLocatorRelationshipInfo.IsProhibited = false;
            newLocatorRelationshipInfo.OrigOrder = newLocatorRelationshipInfo.Order;

            if (parentLocator == null && !string.IsNullOrEmpty(parentElementId))
            {

                parentLocator = new DefinitionLocator();
                parentLocator.href = parentElementId;
                parentLocator.MyElement = taxonomy.allElements[parentElementId] as Element;

                locators[parentElementId] = parentLocator;

            }

            DefinitionLocator childLocator = locators[elementId] as DefinitionLocator;

            if (childLocator == null)
            {
                childLocator = new DefinitionLocator();
                childLocator.href = elementId;
                childLocator.MyElement = taxonomy.allElements[elementId] as Element;

                if (parentLocator != null)
                {
                    childLocator.AddParent(parentLocator);

                }
                locators[elementId] = childLocator;
            }

            if (parentLocator != null)
            {
                if (parentLocator.childLocatorsByHRef == null)
                {
                    parentLocator.childLocatorsByHRef = new HybridDictionary();
                }
                ChildDefinitionLocator cpl
                    = parentLocator.childLocatorsByHRef[elementId] as ChildDefinitionLocator;
                if (cpl != null)
                {
                    cpl.AddRelationship(newLocatorRelationshipInfo);
                }
                else
                {
                    cpl = new ChildDefinitionLocator(elementId, newLocatorRelationshipInfo);
                    parentLocator.childLocatorsByHRef[elementId] = cpl;
                }

            }

            return true;
        }
        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;
        }