Пример #1
0
        ///
        ///	 <summary> * checks wheter the node with <code>strID</code> is dirty
        ///	 *  </summary>
        ///	 * <param name="strID"> the id of the node to be checked </param>
        ///	 * <returns> bool true if the node with ID=<code>strID</code> is dirty </returns>
        ///
        public virtual bool isDirty(string strID)
        {
            if (dirtyPolicy == EnumDirtyPolicy.ID)
            {
                if (strID == null)
                {
                    return(m_vDirtyID.Count > 0);
                }
                return(m_vDirtyID.Contains(strID)); // was in C++.hasString(id);
            }
            else if (dirtyPolicy == EnumDirtyPolicy.XPath)
            {
                int size = m_vDirtyID.Count;
                if (strID == null)
                {
                    return(size > 0);
                }

                for (int i = 0; i < size; i++)
                {
                    string s = m_vDirtyID[i];
                    if (strID.StartsWith(s)) // we have a dirty parent, do nothing
                    {
                        return(true);
                    }
                    else if (strID.CompareTo(s) > 0) // sorted
                    {
                        break;
                    }
                }
                return(false);
            }
            return(globalDirty);
        }
Пример #2
0
        ///
        ///	 <summary> * get a list of contacts with at least one contacttype set
        ///	 *  </summary>
        ///	 * <param name="contactType"> the contatcttype to look for </param>
        ///	 * <returns> VElement the vector of matching JDFContacts, null if none are found </returns>
        ///
        public virtual VElement getContactVectorWithContactType(string contactType)
        {
            VElement v   = getChildElementVector(ElementName.CONTACT, null, null, true, 0, true);
            VElement v2  = new VElement();
            int      siz = v.Count;

            for (int i = 0; i < siz; i++)
            {
                JDFContact contact      = (JDFContact)v[i];
                VString    contactTypes = contact.getContactTypes();
                if (contactTypes.Contains(contactType))
                {
                    v2.Add(contact);
                }
            }
            return(v2.Count > 0 ? v2 : null);
        }
Пример #3
0
        ///
        ///     <summary> * removeStrings - remove all occurrences of a string
        ///     * </summary>
        ///     * <param name="v">    the vector of strings to remove from <code>this</code> </param>
        ///     * <param name="nMax"> the max number of strings to remove </param>
        ///
        public virtual void removeStrings(VString v, int nMax)
        {
            int nMaxLocal = nMax;

            if (v == null)
            {
                return;
            }

            for (int i = this.Count - 1; i >= 0 && nMaxLocal > 0; i--)
            {
                if (v.Contains(this[i]))
                {
                    this.RemoveAt(i);
                    nMaxLocal--;
                }
            }
        }
Пример #4
0
        public virtual void testDirtyIDs()
        {
            // -i bookintent.jdf -o spawned.jdf -p 4
            string xmlFile   = "bookintent.jdf";
            string outFile   = "spawned.jdf";
            string strPartID = "4";

            JDFParser p        = new JDFParser();
            JDFDoc    jdfDocIn = p.parseFile(sm_dirTestData + xmlFile);

            Assert.IsTrue(jdfDocIn != null);
            if (jdfDocIn == null)
            {
                return; // soothe findbugs ;)
            }

            XMLDocUserData xmlUserData = jdfDocIn.getCreateXMLDocUserData();

            xmlUserData.setDirtyPolicy(XMLDocUserData.EnumDirtyPolicy.ID);

            JDFNode rootIn = (JDFNode)jdfDocIn.getRoot();

            JDFNode nodeToSpawn;

            if (strPartID.Equals(""))
            {
                nodeToSpawn = rootIn;
            }
            else
            {
                nodeToSpawn = rootIn.getJobPart(strPartID, "");
            }

            if (nodeToSpawn == null)
            {
                Assert.Fail("No such JobPartID: " + strPartID);
            }
            else
            {
                ArrayList vRWResources = new ArrayList();
                vRWResources.Add("Component");
                vRWResources.Add("RunList");

                VJDFAttributeMap vSpawnParts = new VJDFAttributeMap();
                JDFSpawn         spawn       = new JDFSpawn(nodeToSpawn);

                JDFNode node = spawn.spawn(xmlFile, outFile, vRWResources, vSpawnParts, false, false, false, false);

                // neu gespawntes FileInfo rausschreiben
                JDFNode rootOut = node;
                XMLDoc  docOut  = rootOut.getOwnerDocument_KElement();
                docOut.write2File(sm_dirTestDataTemp + outFile, 0, true);

                // verändertes Ausgangsfile rausschreiben
                string strOutXMLFile = "_" + xmlFile;
                rootIn.eraseEmptyNodes(true);
                jdfDocIn.write2File(sm_dirTestDataTemp + strOutXMLFile, 0, true);
                Assert.IsTrue(true, "SpawnJDF ok");

                // test, if all changed nodes are in our list

                // Java to C# Conversion - Java version indicated there should be 5 Dirty IDs, but it only checks for 4.
                //                         C# version returns 4 Dirty IDs.  Set it to 4 for now.
                VString vstrDirtyIDs = jdfDocIn.getDirtyIDs();
                Assert.AreEqual(4, vstrDirtyIDs.Count);
                Assert.IsTrue(vstrDirtyIDs.Contains("n0014")); // audit pool was added
                Assert.IsTrue(vstrDirtyIDs.Contains("n0016")); // status changed:
                // waiting --> spawned
                Assert.IsTrue(vstrDirtyIDs.Contains("r0017")); //SpawnStatus="SpawnedRW"
                // added
                Assert.IsTrue(vstrDirtyIDs.Contains("r0018")); // SizeIntent added
            }
        }