Example #1
0
        public virtual void testGetTarget()
        {
            JDFDoc          d     = JDFTestCaseBase.creatXMDoc();
            JDFNode         n     = d.getJDFRoot();
            JDFExposedMedia xm    = (JDFExposedMedia)n.getMatchingResource("ExposedMedia", JDFNode.EnumProcessUsage.AnyInput, null, 0);
            JDFAttributeMap mPart = new JDFAttributeMap("SignatureName", "Sig1");

            mPart.put("SignatureName", "S12234");
            mPart.put("SheetName", "S12");
            mPart.put("Side", "Front");
            JDFExposedMedia xmPart = (JDFExposedMedia)xm.getCreatePartition(mPart, null);
            JDFMedia        m      = xm.getMedia();

            m = (JDFMedia)m.makeRootResource(null, null, true);
            xmPart.refElement(m);
            Assert.AreEqual(xmPart.getMedia(), m);
            mPart.put("Side", "Back");
            xmPart = (JDFExposedMedia)xm.getCreatePartition(mPart, null);
            JDFMedia medPart = (JDFMedia)m.getCreatePartition(mPart, xm.getPartIDKeys());

            xmPart.refElement(medPart);
            Assert.AreEqual(xmPart.getMedia(), medPart);
            JDFRefElement re = (JDFRefElement)xmPart.getElement("MediaRef");

            Assert.AreEqual(re.getPartMap(), mPart);
        }
Example #2
0
        public virtual void testGetCreateRefElement()
        {
            JDFNode         n  = new JDFDoc("JDF").getJDFRoot();
            JDFMedia        m  = (JDFMedia)n.addResource("Media", null);
            JDFMedia        m1 = (JDFMedia)m.addPartition(EnumPartIDKey.Location, "T1");
            JDFMedia        m2 = (JDFMedia)m.addPartition(EnumPartIDKey.Location, "T2");
            JDFExposedMedia xm = (JDFExposedMedia)n.addResource("ExposedMedia", null);

            Assert.IsNull(xm.getRefElement(m1));
            for (int i = 0; i < 10; i++)
            {
                JDFRefElement re = xm.getCreateRefElement(m2);
                Assert.AreEqual(re, xm.getRefElement(m2));
                Assert.AreEqual(re, xm.getRefElement(m2));
                Assert.AreEqual(m2, xm.getMedia());
                Assert.IsNull(xm.getRefElement(m1));
                Assert.IsNull(xm.getRefElement(m));
                Assert.AreEqual(1, xm.numChildElements("MediaRef", null));
            }
            for (int i = 0; i < 10; i++)
            {
                JDFRefElement re = xm.getCreateRefElement(m2);
                Assert.AreEqual(re, xm.getRefElement(m2));
                Assert.AreEqual(re, xm.getCreateRefElement(m2));
                xm.getCreateRefElement(m);
                xm.getCreateRefElement(m1);
                Assert.AreEqual(3, xm.numChildElements("MediaRef", null));
            }
        }
Example #3
0
        public virtual void testInlineRefelement()
        {
            JDFDoc          d     = JDFTestCaseBase.creatXMDoc();
            JDFNode         n     = d.getJDFRoot();
            JDFExposedMedia xm    = (JDFExposedMedia)n.getMatchingResource("ExposedMedia", JDFNode.EnumProcessUsage.AnyInput, null, 0);
            JDFAttributeMap mPart = new JDFAttributeMap("SignatureName", "Sig1");

            mPart.put("SignatureName", "S12234");
            mPart.put("SheetName", "S12");
            mPart.put("Side", "Front");
            JDFExposedMedia xmPart = (JDFExposedMedia)xm.getCreatePartition(mPart, null);
            JDFMedia        m      = xm.getMedia();

            m = (JDFMedia)m.makeRootResource(null, null, true);
            m.setGrainDirection(EnumGrainDirection.XDirection);
            xmPart.refElement(m);
            Assert.AreEqual(xmPart.getMedia(), m);
            mPart.put("Side", "Back");
            xmPart = (JDFExposedMedia)xm.getCreatePartition(mPart, null);
            JDFMedia medPart = (JDFMedia)m.getCreatePartition(mPart, xm.getPartIDKeys());

            xmPart.refElement(medPart);
            Assert.AreEqual(xmPart.getMedia(), medPart);
            JDFRefElement re          = (JDFRefElement)xmPart.getElement("MediaRef");
            JDFMedia      inlineMedia = (JDFMedia)re.inlineRef();

            Assert.IsNull(xmPart.getElement_KElement("MediaRef", null, 0));
            Assert.AreEqual(EnumGrainDirection.XDirection, inlineMedia.getGrainDirection());
            Assert.AreEqual(xmPart.getMedia(), inlineMedia);
            Assert.IsFalse(inlineMedia.hasAttribute("ID"));
        }
Example #4
0
        ///
        ///	 <summary> * Get the linked resources matching some conditions
        ///	 *  </summary>
        ///	 * <param name="mResAtt"> map of Resource attributes to search for </param>
        ///	 * <param name="bFollowRefs"> true if internal references shall be followed </param>
        ///	 * <returns> vResource: vector with all elements matching the conditions default: GetLinkedResources(new
        ///	 *         JDFAttributeMap(), false) </returns>
        ///
        public virtual VElement getLinkedResources(JDFAttributeMap mResAtt, bool bFollowRefs)
        {
            VElement vChild = getChildElementVector(null, null, null, true, 0, false);
            VElement vElem  = new VElement();

            for (int i = 0; i < vChild.Count; i++)
            {
                if (!(vChild[i] is JDFRefElement))
                {
                    continue;
                }

                JDFRefElement l = (JDFRefElement)vChild[i];
                JDFResource   r = l.getTarget();
                r = r == null ? null : r.getResourceRoot();
                if (r != null && r.includesAttributes(mResAtt, true))
                {
                    vElem.Add(r); // vElem.push_back(r);
                    if (bFollowRefs)
                    {
                        vElem.appendUnique(r.getvHRefRes(bFollowRefs, true));
                    }
                }
            }
            return(vElem);
        }
Example #5
0
        ///
        ///	 <summary> * Get the linked resources matching some conditions
        ///	 *  </summary>
        ///	 * <param name="mResAtt"> map of Resource attributes to search for </param>
        ///	 * <param name="bFollowRefs"> true if internal references shall be followed
        ///	 *  </param>
        ///	 * <returns> VResource - vector with all elements matching the conditions
        ///	 *
        ///	 *         default: GetLinkedResources(new JDFAttributeMap(), false) </returns>
        ///
        public virtual VElement getLinkedResources(JDFAttributeMap mResAtt, bool bFollowRefs)
        {
            VElement v  = getChildElementVector(null, null, null, true, 0, false);
            VElement vL = new VElement();

            for (int i = 0; i < v.Count; i++)
            {
                if ((v[i]) is JDFRefElement)
                {
                    JDFRefElement l = (JDFRefElement)v[i];
                    JDFResource   r = l.getTarget();
                    r = r == null ? null : r.getResourceRoot();

                    if (r != null && r.includesAttributes(mResAtt, true))
                    {
                        vL.Add(r);
                        if (bFollowRefs)
                        {
                            vL.appendUnique(r.getvHRefRes(bFollowRefs, true));
                        }
                    }
                }
            }

            return(vL);
        }
Example #6
0
        public virtual void testGetRefElement()
        {
            JDFNode         n  = new JDFDoc("JDF").getJDFRoot();
            JDFMedia        m  = (JDFMedia)n.addResource("Media", null);
            JDFMedia        m1 = (JDFMedia)m.addPartition(EnumPartIDKey.Location, "T1");
            JDFMedia        m2 = (JDFMedia)m.addPartition(EnumPartIDKey.Location, "T2");
            JDFExposedMedia xm = (JDFExposedMedia)n.addResource("ExposedMedia", null);

            Assert.IsNull(xm.getRefElement(m1));
            JDFRefElement re = xm.refElement(m2);

            Assert.AreEqual(re, xm.getRefElement(m2));
            Assert.AreEqual(re, xm.getRefElement(m2));
            Assert.AreEqual(xm.getMedia(), m2);
            Assert.IsNull(xm.getRefElement(m1));
            Assert.IsNull(xm.getRefElement(m));
        }
Example #7
0
        public virtual void testMatchesPath()
        {
            JDFDoc  doc  = new JDFDoc(ElementName.JDF);
            JDFNode node = doc.getJDFRoot();

            node.setType("Product", true);
            node.setVersion(JDFElement.EnumVersion.Version_1_3);
            JDFNodeInfo ni = node.appendNodeInfo();

            ni = (JDFNodeInfo)ni.addPartition(EnumPartIDKey.Run, "R1");
            JDFContact c = (JDFContact)node.addResource(ElementName.CONTACT, null, null, null, null, null, null);

            ni.refElement(c);
            JDFComChannel cc = (JDFComChannel)node.addResource(ElementName.COMCHANNEL, null, null, null, null, null, null);

            c.refElement(cc);
            Assert.IsTrue(ni.getContact() == c, "contact");
            Assert.IsTrue(ni.hasChildElement(ElementName.CONTACT, null), "hasrefelement");
            JDFRefElement re = (JDFRefElement)ni.getElement("ContactRef");

            Assert.IsTrue(re.getTarget() == c, "refelementok");
            Assert.IsTrue(c.getComChannel(0) == cc, "comchannel");
            Assert.IsTrue(c.hasChildElement(ElementName.COMCHANNEL, null), "hasrefelement");
            JDFNode     n2  = node.addProduct();
            JDFNodeInfo ni2 = n2.appendNodeInfo();

            ni2.refElement(c);
            Assert.IsTrue(c.matchesPath("ResourcePool/NodeInfo/Contact", true), "follow refs in matchespath");
            Assert.IsTrue(cc.matchesPath("ResourcePool/NodeInfo/Contact/ComChannel", true), "follow refs in matchespath");
            Assert.IsTrue(cc.matchesPath("JDF/ResourcePool/NodeInfo/Contact/ComChannel", true), "follow refs in matchespath");
            Assert.IsTrue(cc.matchesPath("/JDF/ResourcePool/NodeInfo/Contact/ComChannel", true), "follow refs in matchespath");
            Assert.IsTrue(cc.matchesPath("JDF/JDF/ResourcePool/NodeInfo/Contact/ComChannel", true), "follow refs in matchespath");
            Assert.IsTrue(cc.matchesPath("/JDF/JDF/ResourcePool/NodeInfo/Contact/ComChannel", true), "follow refs in matchespath");
            Assert.IsTrue(cc.matchesPath("//JDF/ResourcePool/NodeInfo/Contact/ComChannel", true), "follow refs in matchespath");
            Assert.IsTrue(cc.matchesPath("/JDF/*/ResourcePool/NodeInfo/Contact/ComChannel", true), "follow * in matchespath");
            Assert.IsFalse(cc.matchesPath("JDF/JDF/JDF/ResourcePool/NodeInfo/Contact/ComChannel", true), "follow refs in matchespath");
            Assert.IsFalse(cc.matchesPath("JDF/JDF/JDF/ResourcePool/NodeInfo/Contact/ComChannel", true), "follow refs in matchespath");
            Assert.IsFalse(c.matchesPath("ResourcePool/NodeInfo/Contact/ComChannel", true), "follow refs in matchespath");
        }
Example #8
0
        public virtual void testRefElement()
        {
            JDFDoc  doc  = new JDFDoc(ElementName.JDF);
            JDFNode node = doc.getJDFRoot();

            node.setType("Product", true);
            node.setVersion(JDFElement.EnumVersion.Version_1_2);
            JDFNodeInfo ni = node.appendNodeInfo();

            ni.appendElement("foo:bar", "www.foo.com"); // want a non jdf ns element
            // to see if any class casts
            // occur
            JDFContact c       = (JDFContact)node.addResource(ElementName.CONTACT, null, null, null, null, null, null);
            VString    vCTypes = new VString();

            vCTypes.Add("Customer");
            c.setContactTypes(vCTypes);

            ni.refElement(c);
            JDFComChannel cc = (JDFComChannel)node.addResource(ElementName.COMCHANNEL, null, null, null, null, null, null);

            c.refElement(cc);

            Assert.AreEqual(c, ni.getChildWithMatchingAttribute(ElementName.CONTACT, "ContactTypes", null, "Customer", 0, true, null), "contact");
            Assert.AreEqual(c, ni.getParentJDF().getChildWithAttribute(ElementName.CONTACT, "ContactTypes", null, "Customer", 0, false), "contact");

            Assert.AreEqual(c, ni.getContact(), "contact");
            Assert.IsTrue(ni.hasChildElement(ElementName.CONTACT, null), "hasrefelement");
            JDFRefElement re = (JDFRefElement)ni.getElement("ContactRef");

            Assert.IsTrue(re.getTarget() == c, "refelementok");
            Assert.IsTrue(c.getComChannel(0) == cc, "comchannel");
            Assert.IsTrue(c.hasChildElement(ElementName.COMCHANNEL, null), "hasrefelement");
            JDFNode     n2  = node.addProduct();
            JDFNodeInfo ni2 = n2.appendNodeInfo();

            ni2.refElement(c);
            Assert.IsTrue(c.matchesPath("NodeInfo/Contact", true), "follow refs in matchespath");
            Assert.IsTrue(cc.matchesPath("NodeInfo/Contact/ComChannel", true), "follow refs in matchespath");
            Assert.IsFalse(c.matchesPath("NodeInfo/Contact/ComChannel", true), "follow refs in matchespath");

            Assert.IsTrue(ni2.getContact() == c, "contact 2");
            Assert.IsTrue(ni2.hasChildElement(ElementName.CONTACT, null), "hasrefelement 2");
            re = (JDFRefElement)ni2.getElement("ContactRef");
            Assert.IsTrue(re.getTarget() == c, "refelementok 2");

            ni2.inlineRefElements(null, null, true);
            Assert.IsNull(ni2.getElement("ContactRef"), "get ref post inline");
            Assert.IsNotNull(node.getResourcePool().getElement("Contact"), "refElement has been removed");
            Assert.IsTrue(ni2.hasChildElement(ElementName.CONTACT, null), "haselement 3");
            c  = ni2.getContact();
            re = (JDFRefElement)c.getElement("ComChannelRef");
            Assert.IsTrue(re.getTarget() == cc, "refelementok 2");
            ni2.inlineRefElements(null, null, false);
            Assert.IsNull(ni2.getElement("ComChannelRef"), "get ref post inline 2");
            Assert.IsTrue(c.hasChildElement(ElementName.COMCHANNEL, null), "haselement 4");

            ni.inlineRefElements(null, null, true);
            Assert.IsNull(ni.getElement("ContactRef"), "get ref post inline");
            Assert.IsNull(node.getResourcePool().getElement("Contact"), "refElement has been removed");
            Assert.IsTrue(ni.hasChildElement(ElementName.CONTACT, null), "haselement 3");

            c = ni.getContact();
            c.makeRootResource(null, null, true);
            re = (JDFRefElement)ni.getElement("ContactRef");
            re.deleteRef(true);
            Assert.IsNull(c.getElement("ContactRef"));
        }