Example #1
0
        ///
        ///	 <summary> * add a queueentry to a queue based on the parameters of this you can get the new queueentry by {@link}
        ///	 * getQueueEntry(0) on the response
        ///	 *  </summary>
        ///	 * <param name="theQueue"> the queue to submit to, note that the queue IS modified by this call </param>
        ///	 * <param name="responseIn"> the jmf that serves as a container for the new response
        ///	 *  </param>
        ///	 * <returns> the response jmf to the submission message </returns>
        ///
        public virtual JDFResponse addEntry(JDFQueue theQueue, JDFJMF responseIn)
        {
            JDFCommand  command = (JDFCommand)getParentNode_KElement();
            JDFJMF      jmf     = command.createResponse();
            JDFResponse resp    = jmf.getResponse(0);

            if (responseIn != null)
            {
                resp = (JDFResponse)responseIn.copyElement(resp, null);
            }
            if (theQueue == null)
            {
                resp.setErrorText("No Queue specified");
                resp.setReturnCode(2);
                return(resp);
            }

            if (!theQueue.canAccept())
            {
                resp.setReturnCode(112);
                resp.copyElement(theQueue, null);
                return(resp);
            }
            JDFQueueEntry qe = theQueue.createQueueEntry(getHold());

            string[] copyAtts = new string[] { AttributeName.GANGNAME, AttributeName.GANGPOLICY };

            for (int i = 0; i < copyAtts.Length; i++)
            {
                if (hasAttribute(copyAtts[i]))
                {
                    qe.copyAttribute(copyAtts[i], this, null, null, null);
                }
            }

            // TODO more attributes e.g prev. next...
            if (hasAttribute(AttributeName.PRIORITY))
            {
                qe.setPriority(getPriority()); // calls the automated function,
            }
            // therfore not in the list above

            resp.copyElement(theQueue, null);
            resp.copyElement(qe, null);

            return(resp);
        }
Example #2
0
        public virtual void testOpenClose()
        {
            q.setAutomated(true);
            q.setMaxRunningEntries(2);
            q.setMaxWaitingEntries(3);
            q.flushQueue(null);
            Assert.AreEqual(EnumQueueStatus.Waiting, q.openQueue());
            Assert.IsTrue(q.canAccept());
            Assert.IsTrue(q.canExecute());
            Assert.AreEqual(EnumQueueStatus.Closed, q.closeQueue());
            Assert.IsFalse(q.canAccept());
            Assert.IsTrue(q.canExecute());
            Assert.AreEqual(EnumQueueStatus.Waiting, q.openQueue());
            Assert.AreEqual(EnumQueueStatus.Held, q.holdQueue());
            Assert.IsTrue(q.canAccept());
            Assert.IsFalse(q.canExecute());
            Assert.AreEqual(EnumQueueStatus.Waiting, q.resumeQueue());
            Assert.AreEqual(EnumQueueStatus.Held, q.holdQueue());
            Assert.AreEqual(EnumQueueStatus.Blocked, q.closeQueue());
            Assert.IsFalse(q.canAccept());
            Assert.IsFalse(q.canExecute());
            Assert.AreEqual(EnumQueueStatus.Closed, q.resumeQueue());
            Assert.AreEqual(EnumQueueStatus.Waiting, q.openQueue());
            JDFQueueEntry qe = q.createQueueEntry(false);

            qe = q.createQueueEntry(false);
            Assert.IsTrue(q.canAccept());
            Assert.AreEqual(EnumQueueStatus.Waiting, q.getQueueStatus());
            qe = q.createQueueEntry(false);
            Assert.IsFalse(q.canAccept(), "max 3 waiting - see above ");
            Assert.AreEqual(EnumQueueStatus.Closed, q.getQueueStatus());
            qe.setQueueEntryStatus(EnumQueueEntryStatus.Running);
            Assert.IsTrue(q.canAccept(), "max 3 waiting - see above ");
            Assert.IsTrue(q.canExecute(), "max 3 waiting - see above ");
            Assert.AreEqual(EnumQueueStatus.Waiting, q.getQueueStatus());
            qe = q.createQueueEntry(false);
            qe.setQueueEntryStatus(EnumQueueEntryStatus.Running);
            Assert.AreEqual(EnumQueueStatus.Running, q.getQueueStatus());
            qe = q.createQueueEntry(false);
            Assert.AreEqual(EnumQueueStatus.Full, q.getQueueStatus());
        }