Пример #1
0
        public virtual void testApplyResourceCmd()
        {
            JDFDoc doc = new JDFDoc(ElementName.JMF);
            JDFJMF jmf = doc.getJMFRoot();

            JDFCommand c = jmf.appendCommand();

            jmf.setSenderID("DeviceSenderID");

            c.setType(EnumType.Resource);
            JDFResourceCmdParams rqp = c.appendResourceCmdParams();

            rqp.setJobID("JobID");
            rqp.setJobPartID("JobPartID");
            rqp.setResourceName("Media");
            JDFMedia mediaRQP = (JDFMedia)rqp.appendElement("Media");

            mediaRQP.setDimension(new JDFXYPair(20, 30));

            JDFDoc  docJDF = new JDFDoc(ElementName.JDF);
            JDFNode jdf    = docJDF.getJDFRoot();

            jdf.setType(org.cip4.jdflib.node.JDFNode.EnumType.ConventionalPrinting);
            JDFMedia mediaJDF = (JDFMedia)jdf.addResource("Media", null, EnumUsage.Input, null, null, null, null);

            mediaJDF.setDimension(new JDFXYPair(40, 60));
            rqp.setJobID(jdf.getJobID(true));
            rqp.setJobPartID(jdf.getJobPartID(true));

            rqp.applyResourceCommand(jdf);
            JDFMedia m2 = (JDFMedia)jdf.getMatchingResource("Media", EnumProcessUsage.AnyInput, null, 0);

            Assert.AreEqual(new JDFXYPair(20, 30), m2.getDimension());

            JDFAttributeMap sheetMap = new JDFAttributeMap("SheetName", "S1");

            rqp.setPartMap(sheetMap);
            mediaRQP.setDimension(new JDFXYPair(200, 300));

            JDFMedia m2Sheet = (JDFMedia)m2.addPartition(EnumPartIDKey.SheetName, "S1");

            rqp.applyResourceCommand(jdf);
            Assert.AreEqual(new JDFXYPair(20, 30), m2.getDimension(), "retained root dimension");
            Assert.AreEqual(new JDFXYPair(200, 300), m2Sheet.getDimension(), "overwrote leaf root dimension");

            sheetMap.put(EnumPartIDKey.SheetName, "S2");
            rqp.setPartMap(sheetMap);
            mediaRQP.setDimension(new JDFXYPair(300, 400));

            rqp.applyResourceCommand(jdf);
            JDFMedia m2Sheet2 = (JDFMedia)m2.getPartition(sheetMap, null);

            Assert.IsNotNull(m2Sheet2);
            Assert.AreEqual(new JDFXYPair(20, 30), m2.getDimension(), "retained root dimension");
            Assert.AreEqual(new JDFXYPair(300, 400), m2Sheet2.getDimension(), "overwrote leaf root dimension");

            JDFMedia mPartRQP = (JDFMedia)mediaRQP.addPartition(EnumPartIDKey.SheetName, "S3");

            sheetMap.put(EnumPartIDKey.SheetName, "S3");
            rqp.setPartMap(sheetMap);
            mPartRQP.setDimension(new JDFXYPair(400, 600));

            rqp.applyResourceCommand(jdf);
            JDFMedia m2Sheet3 = (JDFMedia)m2.getPartition(sheetMap, null);

            Assert.AreEqual(new JDFXYPair(20, 30), m2.getDimension(), "retained root dimension");
            Assert.AreEqual(new JDFXYPair(400, 600), m2Sheet3.getDimension(), "overwrote leaf root dimension");
            Assert.IsFalse(m2Sheet3.hasAttribute_KElement("ID", null, false));

            mPartRQP.setAttribute(AttributeName.DIMENSION, "");
            mediaRQP.removeAttribute(AttributeName.DIMENSION);
            rqp.applyResourceCommand(jdf);
            JDFMedia m2Sheet4 = (JDFMedia)m2.getPartition(sheetMap, null);

            Assert.AreEqual(new JDFXYPair(20, 30), m2.getDimension(), "retained root dimension");
            Assert.IsFalse(m2Sheet4.hasAttribute_KElement(AttributeName.DIMENSION, null, false), "removed leaf dimension");
        }