Exemplo n.º 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_2.getValue())
                {
                    if (hasAttribute(AttributeName.PRIORITY))
                    {
                        if (getPriority() == EnumPriority.Required)
                        {
                            setSettingsPolicy(EnumSettingsPolicy.MustHonor);
                        }
                        else
                        {
                            setSettingsPolicy(EnumSettingsPolicy.BestEffort);
                        }
                        removeAttribute(AttributeName.PRIORITY);
                    }
                }
                else
                {
                    if (getSettingsPolicy(true) == EnumSettingsPolicy.BestEffort)
                    {
                        setPriority(EnumPriority.Required);
                    }
                    else
                    {
                        setPriority(EnumPriority.Suggested);
                    }
                }
            }
            return(base.fixVersion(version) && bRet);
        }
Exemplo n.º 2
0
        ///
        ///	 <summary> * version fixing routine
        ///	 *
        ///	 * 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 (isResourceRoot() && version != null)
            {
                bool newLayout = isNewLayout(this);
                if (version.getValue() >= EnumVersion.Version_1_3.getValue() && !newLayout)
                {
                    bRet = toNewLayout();
                }
                else if (version.getValue() < EnumVersion.Version_1_3.getValue() && newLayout)
                {
                    bRet = fromNewLayout();
                }
            }
            return(base.fixVersion(version) && bRet);
        }
Exemplo n.º 3
0
 public override bool fixVersion(EnumVersion version)
 {
     if (version != null && version.getValue() >= EnumVersion.Version_1_3.getValue())
     {
         if (hasAttribute(AttributeName.TOOLID) && !hasAttribute(AttributeName.PRODUCTID))
         {
             setProductID(getToolID());
         }
         removeAttribute(AttributeName.TOOLID, null);
     }
     else if (version != null && version.getValue() < EnumVersion.Version_1_3.getValue())
     {
         if (hasAttribute(AttributeName.PRODUCTID) && !hasAttribute(AttributeName.TOOLID))
         {
             setToolID(getProductID());
         }
     }
     return(base.fixVersion(version));
 }
Exemplo n.º 4
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)
 {
     if (version.getValue() >= EnumVersion.Version_1_3.getValue())
     {
         appendAnchor(null);
     }
     else
     {
         removeAttribute(AttributeName.ID);
     }
     return(base.fixVersion(version));
 }
Exemplo n.º 5
0
        ///
        ///	 <summary> * init
        ///	 *  </summary>
        ///	 * <returns> boolean </returns>
        ///
        public override bool init()
        {
            EnumVersion auditVersion = getVersion(true);

            setAttributeNameTimeStamp(AttributeName.TIMESTAMP, null);
            if (auditVersion == null || auditVersion.getValue() >= EnumVersion.Version_1_2.getValue())
            {
                setAgentName(m_strAgentName);
                setAgentVersion(m_strAgentVersion);
            }
            if (m_strAuthor != null)
            {
                setAuthor(m_strAuthor);
            }

            if (auditVersion == null || auditVersion.getValue() >= EnumVersion.Version_1_3.getValue())
            {
                appendAnchor(null);
            }
            return(base.init());
        }
Exemplo n.º 6
0
        ///
        ///	 <summary> * init this comment by adding agentname, agentversion and id
        ///	 *  </summary>
        ///	 * <returns> boolean </returns>
        ///
        public override bool init()
        {
            EnumVersion v = getVersion(true);

            if (v.getValue() >= EnumVersion.Version_1_3.getValue() && LocalName.Equals(ElementName.COMMENT))
            {
                appendAnchor(null);
                setAgentName(JDFAudit.getStaticAgentName());
                setAgentVersion(JDFAudit.getStaticAgentVersion());
            }
            return(base.init());
        }
Exemplo n.º 7
0
        ///
        ///	 <summary> * fixes an ApprovalSuccess by moving the appropriate elements in and out of
        ///	 * ApprovalDetails elements
        ///	 *  </summary>
        ///	 * <seealso cref= org.cip4.jdflib.resource.JDFResource#fixVersion(org.cip4.jdflib.core.JDFElement.EnumVersion) </seealso>
        ///
        public override bool fixVersion(EnumVersion version)
        {
            bool bRet = true;

            if (version != null)
            {
                // create ApprovalDetails
                if (version.getValue() >= EnumVersion.Version_1_3.getValue())
                {
                    if (hasChildElement(ElementName.CONTACT, null) || hasChildElement(ElementName.FILESPEC, null))
                    {
                        JDFApprovalDetails ad = appendApprovalDetails();
                        ad.setApprovalState(EnumApprovalState.Approved);
                        ad.moveElement(getContact(), null);
                        ad.moveElement(getFileSpec(), null);
                    }
                }
                else
                { // remove ApprovalDetails
                    for (int i = 0; i < 99999; i++)
                    {
                        JDFApprovalDetails ad = getApprovalDetails(i);
                        int iAccept           = 0;
                        if (ad == null)
                        {
                            if (iAccept == 0)
                            {
                                setResStatus(EnumResStatus.Rejected, false);
                            }
                            break; // none left
                        }

                        if (ad.getApprovalState() == EnumApprovalState.Rejected)
                        {
                            bRet = false;
                            ad.deleteNode();
                            continue; // semantics of reject are not available in
                            // 1.2 and below ignore
                        }
                        iAccept++;
                        moveElement(ad.getContact(), null);
                        moveElement(ad.getFileSpec(), null);
                        ad.deleteNode();
                    }
                }
            }
            return(base.fixVersion(version) && bRet);
        }
Exemplo n.º 8
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)
            {
                setVersion(version);
                setMaxVersion(version);
                if (version.getValue() < EnumVersion.Version_1_3.getValue())
                {
                    inlineRefElements(null, null, true);
                }
            }

            return(base.fixVersion(version) && bRet);
        }
Exemplo n.º 9
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);
        }
Exemplo n.º 10
0
        ///
        ///	 <summary> * heuristics to check which version an element of a Layout is in: 1.3 or
        ///	 * 1.2
        ///	 *
        ///	 * Note that this routine is static since it must be used on all sheets,
        ///	 * surfaces etc.
        ///	 *  </summary>
        ///	 * <param name="sheet">
        ///	 *            the Sheet, Surface, Signature or Layout to check </param>
        ///	 * <returns> true if this is a new, i.e. partitioned Layout
        ///	 *  </returns>
        ///
        public static bool isNewLayout(JDFResource sheet)
        {
            // not one of Layout, Signature, Sheet or Surface
            if (!(sheet is JDFLayout))
            {
                return(false);
            }

            // either Signature, Sheet or Surface --> old
            if (!sheet.LocalName.Equals(ElementName.LAYOUT))
            {
                return(false);
            }

            // it's a layout the only allowed (old) element is a signature , if it
            // exists --> old
            if (sheet.getElement_KElement(ElementName.SIGNATURE, null, 0) != null)
            {
                return(false);
            }
            // it is a layout and it has no subelements and it is partitioned -->
            // new
            JDFResource resourceRoot = sheet.getResourceRoot();

            if (resourceRoot.hasAttribute(AttributeName.PARTIDKEYS))
            {
                return(true);
            }
            // it is a non partitioned layout and it has palacedobjects --> new
            if (resourceRoot.hasChildElement(ElementName.CONTENTOBJECT, null) || resourceRoot.hasChildElement(ElementName.MARKOBJECT, null))
            {
                return(true);
            }

            // now I'm ready to punt - no partition and no subelements --> assume
            // that version tags are correct
            EnumVersion v = sheet.getVersion(true);

            // no version, we are 1.3 --> assume 1.3
            if (v == null)
            {
                return(true);
            }

            return(v.getValue() >= EnumVersion.Version_1_3.getValue());
        }
Exemplo n.º 11
0
 ///
 ///	 <summary> * version fixing routine for JDF
 ///	 *
 ///	 * uses heuristics to modify this element and its children to be compatible with a given version<br>
 ///	 * 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)
 {
     if (version != null)
     {
         if (version.getValue() >= EnumVersion.Version_1_3.getValue() && LocalName.Equals(ElementName.COMMENT))
         {
             appendAnchor(null);
         }
         else
         {
             removeAttribute(AttributeName.ID);
             removeAttribute(AttributeName.AGENTNAME);
             removeAttribute(AttributeName.AGENTVERSION);
             removeAttribute(AttributeName.AUTHOR);
             removeAttribute(AttributeName.TIMESTAMP);
         }
     }
     return(base.fixVersion(version));
 }
Exemplo n.º 12
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)
        {
            if (version != null)
            {
                int @value = version.getValue();
                if (@value >= EnumVersion.Version_1_3.getValue())
                {
                    appendAnchor(null);
                }
                else
                {
                    removeAttribute(AttributeName.ID);
                    // TODO fix agentname and agentversion
                }
                string author = getAuthor();
                if (@value <= EnumVersion.Version_1_1.getValue())
                {
                    string tmp = getAgentName();
                    bool   b   = false;
                    if (tmp.Length != 0)
                    {
                        author += "_|_" + tmp;
                        b       = true;
                    }
                    tmp = getAgentVersion();
                    if (tmp.Length != 0)
                    {
                        if (!b)
                        {
                            author += "_|_ ";
                        }

                        author += "_|_" + tmp;
                        b       = true;
                    }
                    removeAttribute(AttributeName.AGENTNAME);
                    removeAttribute(AttributeName.AGENTVERSION);
                    if (b)
                    {
                        setAuthor(author);
                    }
                }
                else if (author.Length > 0) // version>=1.2 and has author
                {
                    VString tokens = new VString(StringUtil.tokenize(author, "_|_", false));
                    if (tokens.Count == 3)
                    { // it was previously fixed
                        string tmp = tokens.stringAt(0);
                        if (!tmp.Equals(JDFConstants.EMPTYSTRING) && !tmp.Equals(JDFConstants.BLANK))
                        {
                            setAuthor(tmp);
                        }
                        tmp = tokens.stringAt(1);
                        if (!tmp.Equals(JDFConstants.EMPTYSTRING) && !tmp.Equals(JDFConstants.BLANK))
                        {
                            setAgentName(tmp);
                        }
                        tmp = tokens.stringAt(2);
                        if (!tmp.Equals(JDFConstants.EMPTYSTRING) && !tmp.Equals(JDFConstants.BLANK))
                        {
                            setAgentVersion(tmp);
                        }
                    }
                }
            }
            return(base.fixVersion(version));
        }