Beispiel #1
0
        internal PresentationLink CreateCopyForMerging()
        {
            PresentationLink ret = new PresentationLink();

            ret.role  = this.role;
            ret.title = this.title;

            ret.BaseSchema = this.BaseSchema;
            ret.MyHref     = this.MyHref;

            //need to copy the locators

            ret.locators = new Hashtable();
            foreach (DictionaryEntry de in this.locators)
            {
                PresentationLocator orig = de.Value as PresentationLocator;

                PresentationLocator copy = orig.CreateCopyForMerging();



                ret.locators[de.Key] = copy;
            }

            //using the parentnewvalue list we need to reset the parent infotrmationin
            //presentation locators
            foreach (PresentationLocator pl in ret.locators.Values)
            {
                pl.ResetParentInformation(ret.locators);
            }
            return(ret);
        }
Beispiel #2
0
        /// <summary>
        /// UPDATE PRESENTATION LINK TO CHANGE AN ARC TO PROHIBITED
        /// </summary>
        /// <param name="elementToProhibit"></param>
        /// <param name="ParentNode"></param>
        /// <param name="isPresentation"></param>
        /// <returns></returns>
        public bool ProhibitArc(Node elementToProhibit,
                                Node ParentNode, bool isPresentation)
        {
            PresentationLocator parentLocator = locators[ParentNode.Id] as PresentationLocator;

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

            ChildPresentationLocator cpl = parentLocator.childLocatorsByHRef[elementToProhibit.Id] as ChildPresentationLocator;

            foreach (LocatorRelationshipInfo lri in cpl.LocatorRelationshipInfos)
            {
                if (((double)(lri.Order)).ToString("####0.####", new CultureInfo("en-US")).Equals(
                        elementToProhibit.order.ToString("####0.####", new CultureInfo("en-US"))) &&
                    (!isPresentation || lri.PrefLabel == elementToProhibit.PreferredLabel) &&
                    (isPresentation || lri.CalculationWeight == elementToProhibit.CalculationWeight) &&
                    lri.IsProhibited == false)
                {
                    //simply prohibit the link...
                    //when we reload the prohibited link would anyway superseed the optional one
                    lri.IsProhibited = true;
                    break;
                }
            }

            return(true);
        }
Beispiel #3
0
        /// <summary>
        /// Compare two <see cref="Object"/>s, assumed to be <see cref="PresentationLocator"/>s.
        /// </summary>
        /// <param name="x">The first <see cref="Object"/> to be compared.  Assumed to be
        /// a <see cref="PresentationLocator"/>.</param>
        /// <param name="y">The second <see cref="Object"/> to be compared.  Assumed to be
        /// a <see cref="PresentationLocator"/>.</param>
        /// <returns><bl>
        /// <li>Less than zero if <paramref name="x"/> is less than <paramref name="y"/>.</li>
        /// <li>Zero if <paramref name="x"/> is equal to <paramref name="y"/>.</li>
        /// <li>Greater than zero if <paramref name="x"/> is greater than <paramref name="y"/>.</li>
        /// </bl></returns>
        /// <remarks>The results of the comparison is that of <see cref="String.CompareTo(String)"/>
        /// on
        /// the HRef of the two <see cref="PresentationLocator"/>s.</remarks>
        public int Compare(object x, object y)
        {
            PresentationLocator a = x as PresentationLocator;
            PresentationLocator b = y as PresentationLocator;

            return(a.HRef.CompareTo(b.HRef));
        }
Beispiel #4
0
        public void AddChild(PresentationLocator childPl, string label, string priority,
                             float orderArg, string prefLabel, string weight, bool isProhibited)
        {
            childPl.AddParent(this);

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


            LocatorRelationshipInfo newRelation = LocatorRelationshipInfo.CreateObj(label,
                                                                                    priority, orderArg, orderArg, prefLabel, weight, isProhibited);
            ChildPresentationLocator cpl = childLocatorsByHRef[childPl.HRef] as ChildPresentationLocator;

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

                childLocatorsByHRef.Add(childPl.HRef, cpl);

                // keep these separate so they don't impact each other
                ChildPresentationLocator cplOrder = new ChildPresentationLocator(cpl);
            }
            else
            {
                // the cpl already exists, append the existing relation info
                cpl.AddRelationship(newRelation);
            }
        }
Beispiel #5
0
        internal PresentationLocator CreateCopyForMerging()
        {
            PresentationLocator copy = new PresentationLocator();

            copy.CopyLocatorBaseInformation(this);
            if (this.childDisplayOrder != null)
            {
                copy.childDisplayOrder = new HybridDictionary();
                foreach (DictionaryEntry de1 in this.childDisplayOrder)
                {
                    copy.childDisplayOrder[de1.Key] = de1.Value;
                }
            }

            if (this.childLocatorsByHRef != null)
            {
                copy.childLocatorsByHRef = new HybridDictionary();
                foreach (DictionaryEntry de1 in this.childLocatorsByHRef)
                {
                    ChildPresentationLocator cpl = de1.Value as ChildPresentationLocator;
                    copy.childLocatorsByHRef[de1.Key] = cpl.CreateCopyForMerging();
                }
            }


            //parent info udjused later
            copy.parents = this.parents;


            return(copy);
        }
Beispiel #6
0
        public void Append(PresentationLink arg, ArrayList errors)
        {
            Hashtable tempLocators = new Hashtable();

            if (arg.locators != null && arg.locators.Count > 0)
            {
                foreach (DictionaryEntry de in arg.locators)
                {
                    PresentationLocator presLocator
                        = locators[de.Key] as PresentationLocator;
                    if (presLocator != null)
                    {
                        tempLocators[de.Key] = de.Value;
                    }
                    else
                    {
                        locators[de.Key] = de.Value;
                    }
                }
            }

            // fix up the new locators
            foreach (DictionaryEntry de in tempLocators)
            {
                PresentationLocator presLocator = locators[de.Key] as PresentationLocator;
                PresentationLocator oldLocator  = de.Value as PresentationLocator;

                presLocator.Append(oldLocator);
            }

            //preserve the old BaseSchema, so roleRef href will point to the correct schema
            BaseSchema = arg.BaseSchema;
        }
Beispiel #7
0
        public void Append(PresentationLocator arg)
        {
            if (arg.childLocatorsByHRef != null)
            {
                if (this.childLocatorsByHRef == null)
                {
                    this.childLocatorsByHRef = new HybridDictionary();
                    this.childDisplayOrder   = new HybridDictionary();
                }

                foreach (ChildPresentationLocator cpl in arg.childLocatorsByHRef.Values)
                {
                    ChildPresentationLocator orig = this.childLocatorsByHRef[cpl.HRef] as ChildPresentationLocator;

                    if (orig == null)
                    {
                        childLocatorsByHRef[cpl.HRef] = cpl;
                    }
                    else
                    {
                        foreach (LocatorRelationshipInfo lri in cpl.LocatorRelationshipInfos)
                        {
                            if (orig.CanAddRelationship(lri))
                            {
                                orig.AddRelationship(lri);
                            }
                        }
                    }
                }
            }


            if (arg.parents != null && arg.parents.Count > 0)
            {
                if (parents == null)
                {
                    parents = arg.parents;
                }
                else
                {
                    // unique parents only please
                    foreach (PresentationLocator parent in arg.Parents)
                    {
                        if (!parents.Contains(parent))
                        {
                            parents.Add(parent);
                        }
                    }
                }
            }

            foreach (string label in arg.labelArray)
            {
                AddLabel(label);
            }
        }
Beispiel #8
0
        private bool LoadLocator(XmlNode locNode,
                                 Dictionary <string, string> discoveredSchemas, string schemaPath)
        {
            string href  = null;
            string label = null;

            if (!Common.GetAttribute(locNode, HREF_TAG, ref href, errorList) ||
                !Common.GetAttribute(locNode, LABEL_TAG, ref label, errorList))
            {
                return(false);
            }

            if (string.IsNullOrEmpty(href))
            {
                return(false);
            }

            LocatorBase locator = CreateLocator(href);

            locator.ParseHRef(errorList);
            LinkBase.AddDiscoveredSchema(schemaPath, locator.Xsd, discoveredSchemas);


            locator.AddLabel(label);


            if (locators.ContainsKey(locator.HRef))
            {
                PresentationLocator oll = (PresentationLocator)locators[locator.HRef];


                // add a new one, pointing to the same locator
                if (!oll.LabelArray.Contains(label))
                {
                    oll.AddLabel(label);
                }
            }
            else
            {
                locators[locator.HRef] = locator;
            }

            HybridDictionary hrefList = this.LabelHrefMapping[label] as HybridDictionary;

            if (hrefList == null)
            {
                hrefList = new HybridDictionary();
                this.LabelHrefMapping[label] = hrefList;
            }

            hrefList[locator.HRef] = 1;

            return(true);
        }
Beispiel #9
0
        public bool IsChildProhibited(string parentHref, string childHref, double order)
        {
            PresentationLocator parentPl = this.locators[parentHref] as PresentationLocator;

            if (parentPl != null)
            {
                return(parentPl.IsChildProhibited(childHref, order));
            }

            return(false);
        }
Beispiel #10
0
        /// <summary>
        /// Retrieve a <see cref="PresentationLocator"/> for this <see cref="PresentationLink"/>'s locators
        /// collection by URI (href).
        /// </summary>
        /// <param name="href">The URI (href) of the locator to be retrieved.</param>
        /// <param name="locator">If return value is true, the retrieved locator.</param>
        /// <returns>True if the requested <see cref="PresentationLocator"/> occurs in this <see cref="PresentationLink"/>'s locators
        /// collection.</returns>
        public bool TryGetLocator(string href, out PresentationLocator locator)
        {
            locator = null;

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

            locator = locators[href] as PresentationLocator;
            return(locator != null);
        }
Beispiel #11
0
        /// <summary>
        /// Add a new relationship between two locators...
        /// </summary>
        /// <param name="elementId"></param>
        /// <param name="parentElementId"></param>
        /// <param name="newLocatorRelationshipInfo"></param>
        /// <param name="taxonomy"></param>
        /// <returns></returns>
        public bool UpdateArc(string elementId, string parentElementId,
                              LocatorRelationshipInfo newLocatorRelationshipInfo, Taxonomy taxonomy)
        {
            PresentationLocator parentLocator = locators[parentElementId] as PresentationLocator;


            if (parentLocator == null && !string.IsNullOrEmpty(parentElementId))
            {
                parentLocator           = new PresentationLocator();
                parentLocator.href      = parentElementId;
                parentLocator.MyElement = taxonomy.allElements[parentElementId] as Element;

                locators[parentElementId] = parentLocator;
            }

            PresentationLocator childLocator = locators[elementId] as PresentationLocator;

            if (childLocator == null)
            {
                childLocator           = new PresentationLocator();
                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();
                }
                ChildPresentationLocator cpl = parentLocator.childLocatorsByHRef[elementId] as ChildPresentationLocator;
                if (cpl != null)
                {
                    cpl.AddRelationship(newLocatorRelationshipInfo);
                }
                else
                {
                    cpl = new ChildPresentationLocator(elementId, newLocatorRelationshipInfo);
                    parentLocator.childLocatorsByHRef[elementId] = cpl;
                }
            }



            return(true);
        }
Beispiel #12
0
        internal void AddParent(PresentationLocator parent)
        {
            if (parents == null)
            {
                parents = new ArrayList();
            }

            // BUG 1610 - don't add duplicate parents
            if (!parents.Contains(parent))
            {
                parents.Add(parent);
            }
        }
Beispiel #13
0
        /// <summary>
        /// Constructs a new instance of <see cref="PresentationLocator"/>, initializing
        /// properties from a parameter-supplied <see cref="PresentationLocator"/>.
        /// </summary>
        /// <param name="copy">The <see cref="PresentationLocator"/> from which the properties
        /// of the new <see cref="PresentationLocator"/> are to be initialized.</param>
        public PresentationLocator(PresentationLocator copy)
        {
            this.childLocatorsByHRef = copy.childLocatorsByHRef;
            this.childDisplayOrder   = copy.childDisplayOrder;

            this.e                 = copy.e;
            this.HRef              = copy.HRef;
            this.LabelArray        = copy.LabelArray;
            this.e                 = copy.MyElement;
            this.parents           = copy.parents;
            this.unpartitionedHref = copy.unpartitionedHref;
            this.xsd               = copy.xsd;
        }
Beispiel #14
0
        public virtual bool LoadLocator(XmlNode locNode)
        {
            string href  = null;
            string label = null;

            if (!Common.GetAttribute(locNode, HREF_TAG, ref href, errorList) ||
                !Common.GetAttribute(locNode, LABEL_TAG, ref label, errorList))
            {
                return(false);
            }

            LocatorBase locator = CreateLocator(href);

            locator.ParseHRef(errorList);
            locator.AddLabel(label);

            LocatorBase oll = null;

            if (locators.ContainsKey(label))
            {
                oll = (LocatorBase)locators[label];

                // add a new one, pointing to the same locator
                if (!oll.LabelArray.Contains(label))
                {
                    // BUG 1610 - create a new presentation locator, since two arcs could have different
                    //		priorities.
                    PresentationLocator newPL = new PresentationLocator();
                    newPL.HRef = oll.HRef;
                    newPL.UnpartitionedHref = oll.UnpartitionedHref;
                    newPL.Xsd = oll.Xsd;

                    // Add the label to the new presentation locator.  This will differentiate the two locators.
                    newPL.AddLabel(label);

                    locators[label] = newPL;
                }
            }
            else
            {
                locators[label] = locator;
            }

            return(true);
        }
Beispiel #15
0
        /// <summary>
        /// Retrieves those locators from the locators collection for this <see cref="PresentationLink"/>
        /// that have a given URI.
        /// </summary>
        /// <param name="href">The URI for which method is to search.</param>
        /// <param name="locatorList">An output parameter.  A collection
        /// of <see cref="PresentationLocator"/> objects containing those locators matching <paramref name="href"/>.</param>
        /// <returns>True if one or more locators was found.  False otherwise.</returns>
        public bool TryGetLocatorsByHref(string href, out ArrayList locatorList)
        {
            // BUG 1610 - There can be multiple locators with the same href but different labels,
            // and the element needs to be bound to all of them.
            locatorList = new ArrayList();

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

            PresentationLocator pl = this.locators[href] as PresentationLocator;

            if (pl != null)
            {
                locatorList.Add(pl);
            }


            return(locatorList.Count > 0);
        }
Beispiel #16
0
        /// <returns>The parent node for this link</returns>
        /// <exception cref="AucentException">throws if this link does not contain any locator objects</exception>
        public Node CreateNode(string lang, string role, Dimension dimension)
        {
            ArrayList nodeList = new ArrayList(locators.Count + 1);

            Node parent = new Node(title);

            parent.MyPresentationLink = this;

            IDictionaryEnumerator enumer = locators.GetEnumerator();

            while (enumer.MoveNext())
            {
                PresentationLocator pl = (PresentationLocator)enumer.Value;
                if (!pl.HasParent)
                {
                    // create all the nodes for this presentationLink
                    try
                    {
                        Node childNode = pl.CreateNode(lang, role, 0,
                                                       pl.href, parent, null, this, true, dimension);

                        if (childNode.Children == null &&
                            childNode.MyElement != null && childNode.MyElement.IsHyperCubeItem())
                        {
                            //we might have decided to not show an hypercube.. as it does not have
                            //any children nodes that are valid segments...
                            return(null);
                        }
                        //parent.AddChild(childNode);
                    }
                    catch (Exception ex)
                    {
                        string msg = ex.Message;
                    }
                }
            }

            return(parent);
        }
        public void CheckAppend()
        {
            ArrayList errors = new ArrayList();

            TestPresentationLocator parent = new TestPresentationLocator( "label", "parent#parent" );
            TestPresentationLocator parentToMerge = new TestPresentationLocator( "label", "parent#parent" );

            PresentationLocator pl1 = new PresentationLocator( "child#child" );
            pl1.ParseHRef( errors );
            Assert.AreEqual( 0, errors.Count );

            PresentationLocator pl2 = new PresentationLocator( "child#child2" );
            pl2.ParseHRef( errors );
            Assert.AreEqual( 0, errors.Count );

            parentToMerge.AddChild( pl1, 1.0F, "pref", "1" );
            parentToMerge.AddChild( pl2, 2.0F, "pref", "1" );

            parent.Append( parentToMerge );

            Assert.AreEqual( parent.childDisplayOrder.Count, 2, "wrong number of orders" );
            Assert.AreEqual( parent.childLocatorsByHRef.Count, 2, "wrong number of href's" );
        }
Beispiel #18
0
        /// <summary>
        /// Map the parent values back to the new locator list
        /// </summary>
        /// <param name="newLocatorList"></param>
        internal void ResetParentInformation(Hashtable newLocatorList)
        {
            if (this.parents != null && this.parents.Count > 0)
            {
                ArrayList newList = new ArrayList(this.parents.Count);

                for (int i = 0; i < this.parents.Count; i++)
                {
                    PresentationLocator pl    = parents[i] as PresentationLocator;
                    PresentationLocator newPl = newLocatorList[pl.href] as PresentationLocator;
                    if (newPl != null)
                    {
                        newList.Add(newPl);
                    }
                    else
                    {
                        throw new ApplicationException("Failed to find corresponding parent values");
                    }
                }

                this.parents = newList;
            }
        }
 /// <exclude/>
 public TestPresentationLocator(PresentationLocator pl)
     : base(pl)
 {
 }
        public void CheckAppend3()
        {
            ArrayList errors = new ArrayList();

            TestPresentationLocator parent = new TestPresentationLocator( "label", "parent#parent" );
            TestPresentationLocator parentToMerge = new TestPresentationLocator( "label", "parent#parent" );

            PresentationLocator pl1 = new PresentationLocator( "child#child" );
            pl1.ParseHRef( errors );
            Assert.AreEqual( 0, errors.Count );

            PresentationLocator pl2 = new PresentationLocator( "child#child2" );
            pl2.ParseHRef( errors );
            Assert.AreEqual( 0, errors.Count );

            PresentationLocator pl3 = new PresentationLocator( "child#child" );
            pl3.ParseHRef( errors );
            Assert.AreEqual( 0, errors.Count );

            PresentationLocator pl4 = new PresentationLocator( "child#child2" );
            pl4.ParseHRef( errors );
            Assert.AreEqual( 0, errors.Count );

            parent.AddChild( pl1, 1.0F, "pref", "1" );
            parent.AddChild( pl2, 2.0F, "pref", "1" );

            parentToMerge.AddChild( pl3, 1.0F, "pref", "1" );
            parentToMerge.AddChild( pl4,"label", "2", 2.0F, "pref", "1", true );

            parent.Append( parentToMerge );

            Assert.AreEqual( parent.childDisplayOrder.Count, 2, "wrong number of orders" );
            Assert.AreEqual( parent.childLocatorsByHRef.Count, 2, "wrong number of href's" );
            int count = ((ChildPresentationLocator)parent.childLocatorsByHRef[parent.childDisplayOrder[2.0F]]).LocatorRelationshipInfos.Count;
            LocatorRelationshipInfo lri = ((ChildPresentationLocator)parent.childLocatorsByHRef[parent.childDisplayOrder[2.0F]]).LocatorRelationshipInfos[count - 1] as LocatorRelationshipInfo;
            Assert.IsTrue(lri.IsProhibited);
        }
Beispiel #21
0
        public Node CreateNode(string lang, string role, int level,
                               string currentId, Node parentNode, LocatorRelationshipInfo relation,
                               PresentationLink pLink, bool recursive,
                               Dimension dimensionInfo)
        {
            Node current = null;

            if (e == null && pLink != null)
            {
                /* Something went wrong during mergePresentation because we should have an element at
                 * this point.  Go to the presentationLink and try to get the element. */
                PresentationLocator loc = null;
                pLink.TryGetLocator(this.HRef, out loc);
                if (loc != null && loc.MyElement != null)
                {
                    //update the element and the child locators
                    e = loc.MyElement;
                    this.childLocatorsByHRef = loc.childLocatorsByHRef;
                }
            }
            if (e == null)
            {
                //it is a locator to an invalid element

                //just return null at this point...
                return(null);
            }
            //make sure we have the right element if there's a parent (there could be clones)
            Element elementToUse = e;

            if (dimensionInfo != null && elementToUse != null)
            {
                if (elementToUse.IsDimensionItem())
                {
                    //get the parent node
                    if (parentNode != null)
                    {
                        //DimensionNode hierNode;
                        //if (dimensionInfo.TryGetHypercubeNode(lang,
                        //    role, pLink.Role, parentNode.Id, out hierNode))
                        //{
                        //    foreach (DimensionNode dn in hierNode.Children)
                        //    {
                        //        if (dn.Id == elementToUse.Id)
                        //        {
                        //            if (parentNode != null)
                        //            {

                        //                 and add it
                        //                parentNode.AddChild(dn);

                        //            }

                        //            return dn;
                        //        }
                        //    }


                        //}



                        DimensionNode hierNode;
                        if (dimensionInfo.TryGetHypercubeNode(lang,
                                                              role, pLink.Role, parentNode.Id, true, out hierNode))
                        {
                            if (hierNode.Children != null)
                            {
                                foreach (DimensionNode dn in hierNode.Children)
                                {
                                    if (dn.Id == elementToUse.Id)
                                    {
                                        if (parentNode != null)
                                        {
                                            // and add it
                                            parentNode.AddChild(dn);
                                        }

                                        return(dn);
                                    }
                                }
                            }


                            return(null);                            //strange ..could not find the correct hierarchy..
                        }
                        else
                        {
                            return(null);
                        }
                    }
                }
            }



            current = elementToUse == null ? new Node(href) : elementToUse.CreateNode(lang, role, false);

            if (relation != null)
            {
                current.SetOrder(relation.Order);
                current.CalculationWeight = relation.CalculationWeight;

                if (preferredLabelRole.Equals(role))
                {
                    if (relation.PrefLabel != null)
                    {
                        current.UpdatePreferredLabel(lang, relation.PrefLabel);
                    }
                }
                // now check to see if it's prohibited
                current.IsProhibited = relation.IsProhibited;
            }
            if (parentNode != null)
            {
                // and add it
                parentNode.AddChild(current);
            }



            if (childLocatorsByHRef != null && recursive)
            {
                foreach (ChildPresentationLocator cpl in childLocatorsByHRef.Values)
                {
                    PresentationLocator childLocator;
                    if (!pLink.TryGetLocator(cpl.HRef, out childLocator))
                    {
                        continue;
                    }

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

                    //organize locators by base order
                    //we should have only one valid LocatorRelationshipInfo for each non xlink information...
                    LocatorRelationshipInfo currentRelationShip = null;
                    for (int i = cpl.LocatorRelationshipInfos.Count - 1; i >= 0; i--)
                    {
                        LocatorRelationshipInfo lri = cpl.LocatorRelationshipInfos[i] as LocatorRelationshipInfo;
                        if (currentRelationShip != null && lri.IsNonXlinkEquivalentRelationship(currentRelationShip))
                        {
                            continue;
                        }
                        currentRelationShip = lri;

                        // always create the child

                        childLocator.CreateNode(lang, role,
                                                level + 1, cpl.HRef, current, lri, pLink, innerRecursive, dimensionInfo);
                    }
                }
                //need to sort the nodes
                if (current.Children != null)
                {
                    current.Children.Sort(new NodeOrderSorter());
                }
            }

            return(current);
        }
Beispiel #22
0
        /// <summary>
        /// Retrieve a <see cref="PresentationLocator"/> for this <see cref="PresentationLink"/>'s locators 
        /// collection by URI (href).
        /// </summary>
        /// <param name="href">The URI (href) of the locator to be retrieved.</param>
        /// <param name="locator">If return value is true, the retrieved locator.</param>
        /// <returns>True if the requested <see cref="PresentationLocator"/> occurs in this <see cref="PresentationLink"/>'s locators 
        /// collection.</returns>
        public bool TryGetLocator(string href, out PresentationLocator locator)
        {
            locator = null;

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

            locator = locators[href] as PresentationLocator;
            return locator != null;
        }
        internal PresentationLocator CreateCopyForMerging()
        {
            PresentationLocator copy = new PresentationLocator();
            copy.CopyLocatorBaseInformation(this);
            if (this.childDisplayOrder != null)
            {
                copy.childDisplayOrder = new HybridDictionary();
                foreach (DictionaryEntry de1 in this.childDisplayOrder)
                {
                    copy.childDisplayOrder[de1.Key] = de1.Value;
                }

            }

            if (this.childLocatorsByHRef != null)
            {
                copy.childLocatorsByHRef = new HybridDictionary();
                foreach (DictionaryEntry de1 in this.childLocatorsByHRef)
                {
                    ChildPresentationLocator cpl = de1.Value as ChildPresentationLocator;
                    copy.childLocatorsByHRef[de1.Key] = cpl.CreateCopyForMerging();
                }
            }

            //parent info udjused later
            copy.parents = this.parents;

            return copy;
        }
        public void AddChild(  PresentationLocator childPl, float orderArg,
			string prefLabel, string calculationWeight  )
        {
            AddChild( childPl,childPl.Label, "0", orderArg, prefLabel, calculationWeight ,false );
        }
Beispiel #25
0
        public override bool LoadArc(XmlNode node)
        {
            string arcrole = string.Empty;
            string from    = string.Empty;
            string to      = string.Empty;

            if (!Common.GetAttribute(node, ARCROLE_TAG, ref arcrole, errorList) ||
                !Common.GetAttribute(node, FROM_TAG, ref from, errorList) ||
                !Common.GetAttribute(node, TO_TAG, ref to, errorList))
            {
                return(false);
            }

            //default order should be 1 as defined by xbrl spec 2.1 ( section 3.5.3.9.5)
            string order     = "1";
            string use       = string.Empty;
            string prefLabel = null;
            string weight    = string.Empty;
            string priority  = "0";

            if (!Common.GetAttribute(node, ORDER_TAG, ref order, null) && !FRTAMessageWritten)
            {
                Common.WriteWarning("XBRLParser.Warning.LinkbaseNotFRTACompliant", errorList, ORDER_TAG);
                FRTAMessageWritten = true;
            }

            Common.GetAttribute(node, USE_TAG, ref use, null);
            Common.GetAttribute(node, PREFLABEL_TAG, ref prefLabel, null);
            Common.GetAttribute(node, PRIORITY_TAG, ref priority, null);
            Common.GetAttribute(node, WEIGHT_TAG, ref weight, null);

            if (arcrole.IndexOf(CHILD_PARENT_RELATIONSHIP) > -1)
            {
                //need to switch from and to
                string tmp = from;
                from = to;
                to   = tmp;
            }

            HybridDictionary fromhd = LabelHrefMapping[from] as HybridDictionary;
            HybridDictionary tohd   = LabelHrefMapping[to] as HybridDictionary;


            if (fromhd == null || tohd == null)
            {
                Common.WriteError("XBRLParser.Warning.PLocatorParentChildNotFound", errorList, from, to, title);
                return(false);
            }
            ArrayList parentLocators = new ArrayList(fromhd.Keys);
            ArrayList childLocators  = new ArrayList(tohd.Keys);



            if (parentLocators == null || childLocators == null)
            {
                Common.WriteError("XBRLParser.Warning.PLocatorParentChildNotFound", errorList, from, to, title);
                return(false);
            }

            foreach (string parentHref in parentLocators)
            {
                foreach (string childHref in childLocators)
                {
                    //need to build the relationshipbetween
                    PresentationLocator parentPl = this.locators[parentHref] as PresentationLocator;
                    PresentationLocator childPl  = this.locators[childHref] as PresentationLocator;


                    if (parentPl == null || childPl == null)
                    {
                        Common.WriteError("XBRLParser.Warning.PLocatorParentChildNotFound", errorList, from, to, title);
                        return(false);
                    }

                    float ord          = float.Parse(order, NumberFormatInfo.InvariantInfo);
                    bool  isProhibited = false;
                    if (use == PROHIBITED_TAG)
                    {
                        isProhibited = true;
                    }

                    parentPl.AddChild(childPl, to, priority, ord,
                                      prefLabel, weight, isProhibited);
                }
            }

            return(true);
        }
        public void AddChild( PresentationLocator childPl, string label,  string priority,
			float orderArg,  string prefLabel, string weight, bool isProhibited )
        {
            childPl.AddParent( this );

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

            LocatorRelationshipInfo newRelation = LocatorRelationshipInfo.CreateObj( label,
                priority, orderArg, orderArg, prefLabel, weight, isProhibited);
            ChildPresentationLocator cpl = childLocatorsByHRef[childPl.HRef] as ChildPresentationLocator;

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

                childLocatorsByHRef.Add( childPl.HRef, cpl );

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

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

            }
        }
        public void Append( PresentationLocator arg)
        {
            if ( arg.childLocatorsByHRef != null )
            {
                if ( this.childLocatorsByHRef == null )
                {
                    this.childLocatorsByHRef = new HybridDictionary();
                    this.childDisplayOrder = new HybridDictionary();

                }

                foreach( ChildPresentationLocator cpl in arg.childLocatorsByHRef.Values )
                {
                    ChildPresentationLocator orig = this.childLocatorsByHRef[cpl.HRef] as ChildPresentationLocator;

                    if( orig == null )
                    {

                        childLocatorsByHRef[cpl.HRef] = cpl;
                    }
                    else
                    {
                        foreach( LocatorRelationshipInfo lri in cpl.LocatorRelationshipInfos )
                        {
                            if ( orig.CanAddRelationship( lri ))
                            {
                                orig.AddRelationship(lri);
                            }
                        }
                    }

                }

            }

            if ( arg.parents != null && arg.parents.Count > 0 )
            {
                if ( parents == null )
                {
                    parents = arg.parents;
                }
                else
                {
                    // unique parents only please
                    foreach ( PresentationLocator parent in arg.Parents )
                    {
                        if ( !parents.Contains( parent ) )
                        {
                            parents.Add( parent );
                        }
                    }
                }
            }

            foreach ( string label in arg.labelArray )
            {
                AddLabel( label );
            }
        }
Beispiel #28
0
 public void AddChild(PresentationLocator childPl, float orderArg,
                      string prefLabel, string calculationWeight)
 {
     AddChild(childPl, childPl.Label, "0", orderArg, prefLabel, calculationWeight, false);
 }
Beispiel #29
0
        public virtual bool LoadLocator(XmlNode locNode)
        {
            string href = null;
            string label = null;

            if (!Common.GetAttribute(locNode, HREF_TAG, ref href, errorList) ||
                 !Common.GetAttribute(locNode, LABEL_TAG, ref label, errorList))
            {
                return false;
            }

            LocatorBase locator = CreateLocator(href);

            locator.ParseHRef(errorList);
            locator.AddLabel(label);

            LocatorBase oll = null;

            if (locators.ContainsKey(label))
            {
                oll = (LocatorBase)locators[label];

                // add a new one, pointing to the same locator
                if (!oll.LabelArray.Contains(label))
                {
                    // BUG 1610 - create a new presentation locator, since two arcs could have different
                    //		priorities.
                    PresentationLocator newPL = new PresentationLocator();
                    newPL.HRef = oll.HRef;
                    newPL.UnpartitionedHref = oll.UnpartitionedHref;
                    newPL.Xsd = oll.Xsd;

                    // Add the label to the new presentation locator.  This will differentiate the two locators.
                    newPL.AddLabel(label);

                    locators[label] = newPL;
                }
            }
            else
            {
                locators[label] = locator;
            }

            return true;
        }
Beispiel #30
0
        /// <summary>
        /// Add a new relationship between two locators...
        /// </summary>
        /// <param name="elementId"></param>
        /// <param name="parentElementId"></param>
        /// <param name="newLocatorRelationshipInfo"></param>
        /// <param name="taxonomy"></param>
        /// <returns></returns>
        public bool UpdateArc(string elementId, string parentElementId ,
            LocatorRelationshipInfo newLocatorRelationshipInfo, Taxonomy taxonomy  )
        {
            PresentationLocator parentLocator = locators[parentElementId] as PresentationLocator;

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

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

                locators[parentElementId] = parentLocator;

            }

            PresentationLocator childLocator = locators[elementId] as PresentationLocator;

            if (childLocator == null )
            {
                childLocator = new PresentationLocator();
                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();
                }
                ChildPresentationLocator cpl = parentLocator.childLocatorsByHRef[elementId] as ChildPresentationLocator;
                if (cpl != null)
                {
                    cpl.AddRelationship(newLocatorRelationshipInfo);
                }
                else
                {
                    cpl = new ChildPresentationLocator(elementId, newLocatorRelationshipInfo);
                    parentLocator.childLocatorsByHRef[elementId] = cpl;
                }

            }

            return true;
        }
        /// <summary>
        /// Constructs a new instance of <see cref="PresentationLocator"/>, initializing 
        /// properties from a parameter-supplied <see cref="PresentationLocator"/>.
        /// </summary>
        /// <param name="copy">The <see cref="PresentationLocator"/> from which the properties
        /// of the new <see cref="PresentationLocator"/> are to be initialized.</param>
        public PresentationLocator(PresentationLocator copy)
        {
            this.childLocatorsByHRef = copy.childLocatorsByHRef;
            this.childDisplayOrder = copy.childDisplayOrder;

            this.e = copy.e;
            this.HRef = copy.HRef;
            this.LabelArray = copy.LabelArray;
            this.e = copy.MyElement;
            this.parents = copy.parents;
            this.unpartitionedHref = copy.unpartitionedHref;
            this.xsd = copy.xsd;
        }
        internal void AddParent( PresentationLocator parent )
        {
            if ( parents == null )
            {
                parents = new ArrayList();
            }

            // BUG 1610 - don't add duplicate parents
            if ( !parents.Contains( parent ) )
            {
                parents.Add( parent );
            }
        }