コード例 #1
0
        ///
        ///	 <summary> * version fixing routine for JDF
        ///	 *
        ///	 * uses heuristics to modify this element and its children to be compatible
        ///	 * with a given version in general, it will be able to move from low to high
        ///	 * versions but potentially fail when attempting to move from higher to
        ///	 * lower versions
        ///	 *  </summary>
        ///	 * <param name="version">
        ///	 *            : version that the resulting element should correspond to </param>
        ///	 * <returns> true if successful </returns>
        ///
        public override bool fixVersion(EnumVersion version)
        {
            bool bRet = true;

            if (version != null)
            {
                if (version.getValue() >= EnumVersion.Version_1_3.getValue())
                {
                    if (hasAttribute(AttributeName.SOURCESHEET))
                    {
                        string sourceSheet = getSourceSheet();

                        JDFRefElement layoutRef = (JDFRefElement)getElement_KElement("LayoutRef", null, 0);
                        if (layoutRef != null)
                        {
                            JDFLayout lo = (JDFLayout)layoutRef.getLinkRoot(layoutRef.getrRef());
                            if (lo != null)
                            {
                                lo.fixVersion(version);
                            }

                            layoutRef.setPartMap(new JDFAttributeMap(AttributeName.SHEETNAME, sourceSheet));
                            lo = (JDFLayout)layoutRef.getTarget();
                            layoutRef.setPartMap(lo.getPartMap());
                        }
                        removeAttribute(AttributeName.SOURCESHEET);
                    }
                }
                else
                {
                    JDFLayout layout = getLayout();
                    if (layout != null)
                    {
                        string sourcesheet = layout.getSheetName();
                        setSourceSheet(sourcesheet);
                        JDFRefElement layoutRef = (JDFRefElement)getElement_KElement("LayoutRef", null, 0);
                        // JDF 1.2 layout should be unpartitioned
                        if (layoutRef != null)
                        {
                            // JDF 1.2 layout should be unpartitioned
                            layoutRef.removeChild(ElementName.PART, null, 0);
                        }
                    }
                }
            }
            return(base.fixVersion(version) && bRet);
        }
コード例 #2
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);
                }
            }
        }