예제 #1
0
        public virtual void testGetChildElementVector()
        {
            _setUp();
            VElement velem = m_jdfRoot.getChildElementVector(null, null, null, true, 0, false);

            Assert.AreEqual(5, velem.Count);
            KElement elem = velem[0];

            Assert.AreEqual("AuditPool", elem.Name);
            velem = m_jdfRoot.getChildElementVector(null, null, null, true, 3, false);
            Assert.AreEqual(3, velem.Count);
        }
예제 #2
0
        ///
        ///	 <summary> * gets the matching elements in node that match this devcap
        ///	 *  </summary>
        ///	 * <param name="node">
        ///	 *            the node to search in </param>
        ///	 * <returns> VElement - the element vector of matching elements,
        ///	 *         <code>null</code> if none were found </returns>
        ///
        private VElement getMatchingElementsFromNode(JDFNode node)
        {
            VElement vElem = new VElement();

            string              nam         = getName();
            EnumContext         context     = getContext();
            JDFResourceLinkPool resLinkPool = node.getResourceLinkPool();

            if (context.Equals(EnumContext.Element))
            { // vElem - for a common return type in all cases
                if (nam.Equals(ElementName.JDF))
                {
                    vElem.Add(node);
                }
                else
                {
                    vElem = node.getChildElementVector(nam, null, null, true, 0, false);
                }
            }
            else if (context.Equals(EnumContext.Link) || context.Equals(EnumContext.Resource))
            {
                if (resLinkPool != null)
                {
                    EnumUsage linkUsage  = getLinkUsage();
                    string    procUsage  = getProcessUsage();
                    bool      bLink      = context.Equals(EnumContext.Link);
                    VElement  vElemLinks = resLinkPool.getInOutLinks(linkUsage, true, nam, null);
                    if (vElemLinks != null)
                    {
                        int linkSize = vElemLinks.Count - 1;
                        for (int j = linkSize; j >= 0; j--)
                        {
                            JDFResourceLink rl             = (JDFResourceLink)vElemLinks[j];
                            string          rlProcessUsage = rl.getProcessUsage();
                            if (!rlProcessUsage.Equals(procUsage))
                            {
                                vElemLinks.RemoveAt(j);
                            }
                        }
                    }

                    if (!bLink)
                    {
                        vElem = JDFResourceLinkPool.resourceVector(vElemLinks, null);
                    }
                    else
                    {
                        vElem = vElemLinks;
                    }
                }
            }
            else if (context.Equals(EnumContext.JMF))
            {
                // TODO __Lena__ ...
            }
            else
            { // Context_Unknown
                throw new JDFException("JDFDevCaps wrong attribute Context value");
            }

            if (vElem != null && vElem.Count == 0)
            {
                vElem = null;
            }

            return(vElem);
        }
예제 #3
0
        ///
        ///	 <summary> * Copy all data from parentNode into the ancestor elements of this
        ///	 *  </summary>
        ///	 * <param name="parentNode"> the closest parent Node that contains the information to be copied </param>
        ///	 * <param name="bCopyNodeInfo"> if true, also copy the NodeInfo into the ancestor </param>
        ///	 * <param name="bCopyCustomerInfo"> if true, also copy the CustomerInfo into the ancestor </param>
        ///	 * <param name="bCopyComments"> if true, also copy the comments into the ancestor
        ///	 * @default copyNodeData(parentNode, false, false, false); </param>
        ///
        public virtual void copyNodeData(JDFNode parentNode, bool bCopyNodeInfo, bool bCopyCustomerInfo, bool bCopyComments)
        {
            VElement vAncestors = getPoolChildren(null);
            JDFNode  node       = parentNode;

            JDFNode thisParentNode = getParentJDF();

            int i;

            for (i = vAncestors.Count - 1; i >= 0; i--)
            {
                JDFAncestor ancestor = (JDFAncestor)vAncestors[i];
                if (!node.getID().Equals(ancestor.getNodeID()))
                {
                    throw new JDFException("JDFAncestorPool::CopyNodeData: Invalid pairing");
                }

                ancestor.setAttributes(node);
                ancestor.removeAttribute(AttributeName.XSITYPE);
                ancestor.renameAttribute(AttributeName.ID, AttributeName.NODEID, null, null);
                // only copy nodeinfo and customerinfo in real parent nodes, not in
                // this of partitioned spawns
                if (!thisParentNode.getID().Equals(node.getID()))
                {
                    if (bCopyNodeInfo)
                    {
                        JDFNodeInfo nodeInfo = node.getNodeInfo();
                        if (nodeInfo != null)
                        {
                            if (nodeInfo.getParentNode_KElement() is JDFResourcePool)
                            {
                                // add a low level refelement, the copying takes
                                // place inaddspawnedresources
                                JDFRefElement re = (JDFRefElement)ancestor.appendElement(ElementName.NODEINFO + JDFConstants.REF);
                                re.setrRef(nodeInfo.getID());
                                re.setPartMap(nodeInfo.getPartMap());
                            }
                            else
                            {
                                ancestor.copyElement(nodeInfo, null);
                            }
                        }
                    }

                    if (bCopyCustomerInfo)
                    {
                        JDFCustomerInfo customerInfo = node.getCustomerInfo();
                        if (customerInfo != null)
                        {
                            if (customerInfo.getParentNode_KElement() is JDFResourcePool)
                            {
                                // add a low level refelement, the copying takes
                                // place inaddspawnedresources
                                JDFRefElement re = (JDFRefElement)ancestor.appendElement(ElementName.CUSTOMERINFO + JDFConstants.REF);
                                re.setrRef(customerInfo.getID());
                                re.setPartMap(customerInfo.getPartMap());
                            }
                            else
                            {
                                ancestor.copyElement(customerInfo, null);
                            }
                        }
                    }

                    if (bCopyComments)
                    {
                        VElement v = node.getChildElementVector(ElementName.COMMENT, null, null, true, 0, false);
                        for (int j = 0; j < v.Count; j++)
                        {
                            ancestor.copyElement(v[j], null);
                        }
                    }
                }

                JDFNode node2 = node.getParentJDF();

                // 100602 RP added i--
                if (node2 == null)
                {
                    i--;
                    break;
                }
                node = node2;
            }

            // the original node was already spawned --> also copy the elements of
            // the original nodes Ancestorpool
            if (i >= 0)
            {
                VElement parentAncestors    = node.getAncestorPool().getPoolChildren(null);
                int      parentAncestorSize = parentAncestors.Count;
                if (parentAncestorSize < i + 1)
                {
                    throw new JDFException("JDFAncestorPool.CopyNodeData: Invalid AncestorPool pairing");
                }

                // now copy the ancestorpool elements that have not yet been added
                // from the original nodes
                for (; i >= 0; i--)
                {
                    JDFAncestor ancestor       = (JDFAncestor)vAncestors[i];
                    JDFAncestor parentAncestor = (JDFAncestor)parentAncestors[i];
                    ancestor.mergeElement(parentAncestor, false);
                }
            }
        }