Example #1
0
        public virtual void testGetSignatureVector_Old()
        {
            testBuildOldLayout();
            JDFLayout    lo  = (JDFLayout)n.getMatchingResource(ElementName.LAYOUT, EnumProcessUsage.AnyInput, null, 0);
            VElement     v   = lo.getSignatureVector();
            JDFSignature sig = (JDFSignature)v[0];

            Assert.AreEqual(sig.getName(), sig.getSignatureName());
            Assert.AreEqual("Sig1", sig.getSignatureName());
            JDFSignature sig2 = (JDFSignature)v[1];

            Assert.AreEqual(sig2.getName(), sig2.getSignatureName());
            Assert.AreEqual("Sig2", sig2.getSignatureName());
            VElement vSheet = sig2.getSheetVector();
            JDFSheet s1     = (JDFSheet)vSheet[1]; // don't try 0 it will

            // fail because it is
            // referenced...
            Assert.AreEqual("Sig2", s1.getSignatureName());
            Assert.AreEqual("Sheet2_2", s1.getSheetName());
            JDFSurface su = s1.getCreateBackSurface();

            Assert.AreEqual("Sig2", su.getSignatureName());
            Assert.AreEqual("Sheet2_2", su.getSheetName());
            Assert.AreEqual(su, s1.getSurfaceVector()[0]);
        }
Example #2
0
 public virtual void testGetSignatureByName()
 {
     for (int i = 0; i < 2; i++)
     {
         if (i == 0)
         {
             testBuildNewLayout();
         }
         else
         {
             testBuildOldLayout();
             JDFLayout lo = (JDFLayout)n.getMatchingResource(ElementName.LAYOUT, EnumProcessUsage.AnyInput, null, 0);
             lo.getSignature(0).setName("SignatureName1");
             lo.getSignature(1).setName("SignatureName2");
             lo.getSignature(1).getSheet(0).setName("SheetName1");
         }
         JDFLayout lo_1 = (JDFLayout)n.getMatchingResource(ElementName.LAYOUT, EnumProcessUsage.AnyInput, null, 0);
         Assert.IsNull(lo_1.getSignature("fooBar"));
         Assert.AreEqual(lo_1.getSignature("SignatureName1"), lo_1.getSignature(0));
         Assert.AreEqual(lo_1.getSheet("SheetName1"), lo_1.getSheet(0));
         JDFSignature signature2 = lo_1.getSignature("SignatureName2");
         Assert.AreEqual(signature2.getSheet("SheetName1"), lo_1.getSignature(1).getSheet(0));
         Assert.AreEqual(lo_1.getCreateSignature("fooBar"), lo_1.getSignature(-1));
     }
 }
Example #3
0
 ///
 ///	 <summary> * if this is a new layout, return the partition key signaturename else return Signature/@Name of this or its
 ///	 * appropriate parent
 ///	 *  </summary>
 ///	 * <returns> the name of the signature </returns>
 ///
 public override string getSignatureName()
 {
     if (LocalName.Equals(ElementName.SIGNATURE))
     {
         return(getName());
     }
     if (LocalName.Equals(ElementName.SHEET))
     {
         KElement parentNode = getParentNode_KElement();
         if (parentNode is JDFSignature)
         {
             JDFSignature sig = (JDFSignature)parentNode;
             return(sig.getSignatureName());
         }
     }
     else if (LocalName.Equals(ElementName.SURFACE))
     {
         KElement parentNode = getParentNode_KElement().getParentNode_KElement();
         if (parentNode is JDFSignature)
         {
             JDFSignature sig = (JDFSignature)parentNode;
             return(sig.getSignatureName());
         }
     }
     return(base.getSignatureName());
 }
Example #4
0
        public virtual void testBuildNewLayout()
        {
            reset();

            JDFLayout lo = (JDFLayout)n.appendMatchingResource(ElementName.LAYOUT, EnumProcessUsage.AnyInput, null);

            Assert.IsTrue(JDFLayout.isNewLayout(lo), "lo 1.3");
            JDFSignature si = lo.appendSignature();

            Assert.AreEqual(ElementName.LAYOUT, si.LocalName, "signature name");
            si = lo.appendSignature();
            Assert.AreEqual(2, lo.numSignatures(), "num sigs");
            Assert.AreEqual(ElementName.LAYOUT, si.LocalName, "signature name");

            JDFSheet sh = si.appendSheet();

            sh = si.appendSheet();
            Assert.AreEqual(2, si.numSheets(), "num sheets");
            Assert.AreEqual(ElementName.LAYOUT, sh.LocalName, "sheet name");
            sh = si.getCreateSheet(4);
            Assert.AreEqual(3, si.numSheets(), "num sheets");
            Assert.AreEqual(ElementName.LAYOUT, sh.LocalName, "sheet name");
            sh = si.getSheet(2);
            Assert.AreEqual(3, si.numSheets(), "num sheets");
            Assert.AreEqual(ElementName.LAYOUT, sh.LocalName, "sheet name");

            JDFSurface su = sh.appendFrontSurface();

            Assert.AreEqual(1, sh.numSurfaces(), "num surfaces");
            Assert.AreEqual(ElementName.LAYOUT, su.LocalName, "sheet name");
            Assert.IsTrue(sh.hasFrontSurface(), "hasfrontSurface");

            su = sh.appendBackSurface();
            Assert.AreEqual(2, sh.numSurfaces(), "num surfaces");
            Assert.AreEqual(ElementName.LAYOUT, su.LocalName, "sheet name");

            try
            {
                sh.appendBackSurface();
                Assert.Fail("no two back surfaces");
            }
            catch (JDFException)
            { // nop
            }

            si = lo.getCreateSignature(4);
            Assert.AreEqual(3, lo.numSignatures(), "num sigs");
            Assert.AreEqual(ElementName.LAYOUT, si.LocalName, "signature name");
            si = lo.getSignature(2);
            Assert.AreEqual(3, lo.numSignatures(), "num sigs");
            Assert.AreEqual(ElementName.LAYOUT, si.LocalName, "signature name");
            si = lo.getSignature(5);
            Assert.IsNull(si, "si null");
            Assert.IsTrue(lo.isValid(EnumValidationLevel.Complete), "layout valid");
            Assert.AreEqual(lo.numSignatures(), lo.getSignatureVector().Count);
        }
Example #5
0
        public virtual void testFixFromNewLayout()
        {
            testBuildNewLayout();
            n.fixVersion(EnumVersion.Version_1_2);
            JDFLayout lo = (JDFLayout)n.getMatchingResource(ElementName.LAYOUT, EnumProcessUsage.AnyInput, null, 0);

            Assert.IsFalse(JDFLayout.isNewLayout(lo));
            JDFSignature si = lo.getSignature(0);

            Assert.AreEqual(ElementName.SIGNATURE, si.LocalName);
        }
Example #6
0
        public virtual void testFixToNewLayout()
        {
            testBuildOldLayout();
            n.fixVersion(EnumVersion.Version_1_3);
            JDFLayout lo = (JDFLayout)n.getMatchingResource(ElementName.LAYOUT, EnumProcessUsage.AnyInput, null, 0);

            Assert.IsTrue(JDFLayout.isNewLayout(lo));
            JDFSignature si = lo.getSignature(0);

            Assert.AreEqual("Sig1", si.getSignatureName());
            Assert.IsFalse(si.hasAttribute(AttributeName.CLASS));
        }
Example #7
0
        public virtual void testGetLayoutLeavesNew()
        {
            testBuildNewLayout();

            JDFLayout lo     = (JDFLayout)n.getMatchingResource(ElementName.LAYOUT, EnumProcessUsage.AnyInput, null, 0);
            VElement  leaves = lo.getLayoutLeaves(false);

            Assert.AreEqual(6, leaves.Count, "2 Sigs, 2 sheets, 2 surfaces");
            JDFSignature si = lo.getSignature(1);

            leaves = si.getLayoutLeaves(false);
            Assert.AreEqual(4, leaves.Count, "2 sheets, 2 surfaces");
            JDFSheet sh = si.getSheet(2);

            leaves = sh.getLayoutLeaves(false);
            Assert.AreEqual(2, leaves.Count, "2 surfaces");
        }
Example #8
0
        public virtual void testFixFromFlatNewLayout()
        {
            n.setVersion(EnumVersion.Version_1_3);
            JDFLayout        loNew = (JDFLayout)n.appendMatchingResource(ElementName.LAYOUT, EnumProcessUsage.AnyInput, null);
            JDFContentObject co1   = loNew.appendContentObject();

            n.fixVersion(EnumVersion.Version_1_2);
            JDFLayout lo = (JDFLayout)n.getMatchingResource(ElementName.LAYOUT, EnumProcessUsage.AnyInput, null, 0);

            Assert.IsFalse(JDFLayout.isNewLayout(lo));
            JDFSignature si = lo.getSignature(0);

            Assert.AreEqual(ElementName.SIGNATURE, si.LocalName);
            JDFSheet   sh = si.getSheet(0);
            JDFSurface su = sh.getSurface(EnumSide.Front);

            Assert.AreEqual(co1, su.getContentObject(0));
        }
Example #9
0
        public virtual void testGetSignatureName_New()
        {
            testBuildNewLayout();
            JDFLayout    lo  = (JDFLayout)n.getMatchingResource(ElementName.LAYOUT, EnumProcessUsage.AnyInput, null, 0);
            JDFSignature sig = lo.getSignature(0);

            Assert.AreEqual("SignatureName1", sig.getSignatureName());
            JDFSignature sig2 = lo.getSignature(1);

            Assert.AreEqual("SignatureName2", sig2.getSignatureName());
            JDFSheet s1 = sig2.getSheet(1); // don't try 0 it will fail because it

            // is referenced...
            Assert.AreEqual("SignatureName2", s1.getSignatureName());
            Assert.AreEqual("SheetName2", s1.getSheetName());
            JDFSurface su = s1.getCreateBackSurface();

            Assert.AreEqual("SignatureName2", su.getSignatureName());
            Assert.AreEqual("SheetName2", su.getSheetName());
        }
Example #10
0
        public virtual void testBuildOldLayout()
        {
            reset();

            n.setVersion(EnumVersion.Version_1_2);
            JDFLayout lo = (JDFLayout)n.appendMatchingResource(ElementName.LAYOUT, EnumProcessUsage.AnyInput, null);

            Assert.IsFalse(JDFLayout.isNewLayout(lo), "lo 1.3");
            JDFSignature si = lo.appendSignature();

            si.setName("Sig1");
            Assert.AreEqual(ElementName.SIGNATURE, si.LocalName, "signature name");
            Assert.IsFalse(si.hasAttribute(AttributeName.CLASS));
            si = lo.appendSignature();
            si.setName("Sig2");
            Assert.AreEqual(2, lo.numSignatures(), "num sigs");
            Assert.AreEqual(ElementName.SIGNATURE, si.LocalName, "signature name");

            JDFSheet sh = si.appendSheet();

            sh.setName("Sheet2_1");
            sh.makeRootResource(null, null, true); // see what happens with
            // refelements
            sh = si.appendSheet();
            sh.setName("Sheet2_2");
            Assert.AreEqual(2, si.numSheets(), "num sheets");
            Assert.AreEqual(ElementName.SHEET, sh.LocalName, "sheet name");
            sh = si.getCreateSheet(4);
            Assert.AreEqual(3, si.numSheets(), "num sheets");
            Assert.AreEqual(ElementName.SHEET, sh.LocalName, "sheet name");
            sh = si.getSheet(2);
            Assert.AreEqual(3, si.numSheets(), "num sheets");
            Assert.AreEqual(ElementName.SHEET, sh.LocalName, "sheet name");

            JDFSurface su = sh.appendFrontSurface();

            Assert.AreEqual(1, sh.numSurfaces(), "num surfaces");
            Assert.AreEqual(ElementName.SURFACE, su.LocalName, "sheet name");
            Assert.IsTrue(sh.hasFrontSurface(), "hasfrontSurface");
            su.appendContentObject();
            su.appendMarkObject();
            su.appendContentObject();
            su.appendContentObject();

            su = sh.appendBackSurface();
            su.makeRootResource(null, null, true);
            su.appendContentObject();
            su.appendMarkObject();
            su.appendContentObject();
            su.appendContentObject();
            su.appendMarkObject();
            Assert.AreEqual(2, sh.numSurfaces(), "num surfaces");
            Assert.AreEqual(ElementName.SURFACE, su.LocalName, "sheet name");
            Assert.IsTrue(sh.hasBackSurface(), "hasBackSurface");

            try
            {
                sh.appendBackSurface();
                Assert.Fail("append second surface");
            }
            catch (JDFException)
            { // nop
            }

            si = lo.getCreateSignature(4);
            Assert.AreEqual(3, lo.numSignatures(), "num sigs");
            Assert.AreEqual(ElementName.SIGNATURE, si.LocalName, "signature name");
            si = lo.getSignature(2);
            Assert.AreEqual(3, lo.numSignatures(), "num sigs");
            Assert.AreEqual(ElementName.SIGNATURE, si.LocalName, "signature name");
            si = lo.getSignature(5);
            Assert.IsNull(si, "si null");
            Assert.AreEqual(lo.numSignatures(), lo.getSignatureVector().Count);
        }