Ejemplo n.º 1
0
        public virtual void testConvertResponse()
        {
            JDFDoc      doc  = new JDFDoc(ElementName.JMF);
            JDFJMF      jmf  = doc.getJMFRoot();
            JDFDoc      doc2 = new JDFDoc(ElementName.JMF);
            JDFJMF      jmf2 = doc2.getJMFRoot();
            JDFSignal   s    = jmf.appendSignal();
            JDFResponse r    = jmf2.appendResponse();
            JDFQuery    q    = jmf.appendQuery();

            q.setType("KnownMessages");
            r.setQuery(q);
            Assert.AreEqual(q.getID(), r.getrefID(), "refID");

            JDFMessageService ms = r.appendMessageService();

            ms.setType("KnownMessages");
            s.convertResponse(r, q);
            Assert.AreEqual(r.getType(), s.getType(), "type");
            Assert.IsTrue(ms.isEqual(s.getMessageService(0)), "ms equal");
            s = jmf.appendSignal();
            s.convertResponse(r, null);
            Assert.AreEqual(r.getType(), s.getType(), "type");
            Assert.IsTrue(ms.isEqual(s.getMessageService(0)), "ms equal");
            Assert.IsTrue(s.getXSIType().StartsWith("Signal"));
        }
Ejemplo n.º 2
0
        ///
        ///	 <summary> * converts a response to a signal that can be sent individually
        ///	 *  </summary>
        ///	 * <param name="response"> the response to convert </param>
        ///	 * <returns> true if successful </returns>
        ///
        public virtual bool convertResponse(JDFResponse response, JDFQuery q)
        {
            if (response == null)
            {
                return(false);
            }
            setAttributes(response);
            VElement elements = response.getChildElementVector(null, null, null, true, 0, true);

            for (int i = 0; i < elements.Count; i++)
            {
                JDFElement element = (JDFElement)elements[i];
                copyElement(element, null);
            }
            if (q != null)
            {
                VElement v = q.getChildElementVector(null, null, null, true, 0, true);
                for (int i = 0; i < v.Count; i++)
                {
                    KElement item = v.item(i);
                    if (item is JDFSubscription)
                    {
                        continue;
                    }
                    copyElement(item, null);
                }
            }
            setType(response.getType()); // also fix xsi:type
            return(true);
        }
Ejemplo n.º 3
0
        public virtual void testGetIdentifier()
        {
            JDFDoc doc = new JDFDoc(ElementName.JMF);
            JDFJMF jmf = doc.getJMFRoot();

            JDFQuery c = jmf.appendQuery();

            jmf.setSenderID("MISSenderID");
            c.setType(EnumType.Resource);
            JDFResourceQuParams rqp = c.getCreateResourceQuParams(0);

            rqp.setJobID("J1");
            rqp.setJobPartID("p2");
            Assert.AreEqual(new NodeIdentifier("J1", "p2", null), rqp.getIdentifier());
        }
Ejemplo n.º 4
0
        public virtual void testConvertResponses()
        {
            JDFDoc      doc  = new JDFDoc(ElementName.JMF);
            JDFJMF      jmf  = doc.getJMFRoot();
            JDFDoc      doc2 = new JDFDoc(ElementName.JMF);
            JDFJMF      jmf2 = doc2.getJMFRoot();
            JDFResponse r    = jmf2.appendResponse();
            JDFQuery    q    = jmf.appendQuery();

            q.setType("KnownMessages");
            r.setQuery(q);
            Assert.AreEqual(q.getID(), r.getrefID(), "refID");

            jmf2.convertResponses(q);
            Assert.IsNull(jmf2.getResponse(0));
            Assert.AreEqual(q.getID(), jmf2.getSignal(0).getrefID());
        }
Ejemplo n.º 5
0
        public virtual void testResourceQuParams()
        {
            JDFDoc doc = new JDFDoc(ElementName.JMF);
            JDFJMF jmf = doc.getJMFRoot();

            JDFQuery c = jmf.appendQuery();

            jmf.setSenderID("MISSenderID");
            c.setType(EnumType.Resource);
            JDFResourceQuParams rqp      = c.getCreateResourceQuParams(0);
            List <ValuedEnum>   vClasses = new List <ValuedEnum>();

            vClasses.Add(EnumResourceClass.Consumable);
            vClasses.Add(EnumResourceClass.Handling);
            rqp.setClasses(vClasses);
            Assert.AreEqual(vClasses.ToString(), rqp.getClasses().ToString());
        }
Ejemplo n.º 6
0
        ///
        ///	 <summary> * convert all responses that match the query q to signals
        ///	 *  </summary>
        ///	 * <returns> the newly created JMF with multiple responses </returns>
        ///
        public virtual void convertResponses(JDFQuery q)
        {
            EnumType t   = q == null ? null : q.getEnumType();
            VElement v   = getMessageVector(EnumFamily.Response, t);
            string   qID = q == null ? null : q.getID();

            for (int i = 0; i < v.Count; i++)
            {
                JDFResponse r = (JDFResponse)v[i];
                if (qID == null || qID.Equals(r.getrefID()))
                {
                    JDFSignal s = appendSignal();
                    moveElement(s, r); // retain ordering
                    s.convertResponse(r, q);
                    r.deleteNode();
                }
            }
        }
Ejemplo n.º 7
0
        public virtual void testMediaCatalog()
        {
            JDFDoc doc = new JDFDoc(ElementName.JMF);
            JDFJMF jmf = doc.getJMFRoot();

            jmf.setSenderID("DeviceSenderID");

            JDFQuery q = jmf.appendQuery(EnumType.Resource);

            q.setXMLComment("This is the query for a catalog");

            JDFResourceQuParams rqp = q.appendResourceQuParams();

            rqp.setExact(true);
            rqp.setXMLComment("Scope=Allowed is a new attribute to describe that we want a complet list of all known resources");
            rqp.setResourceName(ElementName.MEDIA);
            //		rqp.setAttribute("Scope", "Allowed");

            JDFResponse r = q.createResponse().getResponse(0);

            r = (JDFResponse)jmf.moveElement(r, null);
            r.setXMLComment("This is the response to the query - generally it will be in it's own jmf...\nThe list of ResourceInfo + the ResourceQuParams could also be specified in a Signal.");

            for (int i = 1; i < 5; i++)
            {
                JDFResourceInfo ri = r.appendResourceInfo();
                ri.setResourceName("Media");
                JDFMedia m = (JDFMedia)ri.appendResource("Media");
                m.setDescriptiveName("Description of Media #" + i);
                m.setDimensionCM(new JDFXYPair(i * 10, 13 + i % 2 * 20));
                m.setBrand("Brand #" + i);
                m.setProductID("ProductID_" + i);
                m.setMediaType(EnumMediaType.Paper);
                m.setResStatus((i < 2 ? EnumResStatus.Available : EnumResStatus.Unavailable), false);
                ri.setXMLComment("More attributes can be added as needed; Available = loaded");
            }
            doc.write2File(sm_dirTestDataTemp + "MediaCatalog.jmf", 2, false);
            Assert.IsTrue(jmf.isValid(EnumValidationLevel.Complete));
        }