Ejemplo n.º 1
0
        ///
        ///	 <summary> * get a specific layout element
        ///	 *  </summary>
        ///	 * <param name="layout"> </param>
        ///	 * <param name="elementName"> </param>
        ///	 * <param name="partitionKeyName"> </param>
        ///	 * <param name="iSkip"> the index of the element, negative values count backwards from the end </param>
        ///	 * <returns> JDFLayout: the element </returns>
        ///
        protected internal static JDFLayout getLayoutElement(JDFResource layout, string elementName, string partitionKeyName, int iSkip)
        {
            int iSkipLocal = iSkip;

            JDFLayout s = null;

            if (JDFLayout.isNewLayout(layout))
            {
                VElement v  = layout.getLeaves(true);
                VElement v2 = new VElement();
                for (int i = 0; i < v.Count; i++)
                {
                    if (v[i].hasAttribute_KElement(partitionKeyName, null, false))
                    {
                        v2.Add(v[i]);
                    }
                }
                v = v2;
                if (iSkipLocal < 0)
                {
                    iSkipLocal = v.Count + iSkipLocal;
                }

                if (iSkipLocal >= 0 && v.Count > iSkipLocal)
                {
                    s = (JDFLayout)v[iSkipLocal];
                }
            }
            else
            {
                s = (JDFLayout)layout.getElement(elementName, null, iSkipLocal);
            }
            return(s);
        }
Ejemplo n.º 2
0
 ///
 ///	 <summary> * (31) create inter-resource link to refTarget
 ///	 *  </summary>
 ///	 * <param name="JDFSurface">
 ///	 *            refTarget the element that is referenced </param>
 ///
 public virtual void refSurface(JDFSurface refTarget)
 {
     if (JDFLayout.isNewLayout(this))
     {
         throw new JDFException("refSheet: attempting to reference a partition");
     }
     refElement(refTarget);
 }
Ejemplo n.º 3
0
 ///
 ///	 <summary> * get the leaves of a layout, either pre 1.2 or post 1.3
 ///	 *  </summary>
 ///	 * <returns> VElement the layout leaves, i.e. partition leaves(1.3+) or explicit surfaces(1.2-) </returns>
 ///
 public virtual VElement getLayoutLeaves(bool bAll)
 {
     if (JDFLayout.isNewLayout(this))
     {
         return(getLeaves(bAll));
     }
     return(getChildrenByTagName(ElementName.SURFACE, null, null, false, true, -1));
 }
Ejemplo n.º 4
0
 ///
 ///	 <summary> * get a vector of specific layout elements
 ///	 *  </summary>
 ///	 * <param name="layout"> </param>
 ///	 * <param name="elementName"> </param>
 ///	 * <param name="partitionKeyName"> </param>
 ///	 * <returns> VElement: the vector of elements </returns>
 ///
 protected internal static VElement getLayoutElementVector(JDFResource layout, string elementName, string partitionKeyName)
 {
     if (JDFLayout.isNewLayout(layout))
     {
         return(layout.getChildElementVector_JDFElement(ElementName.LAYOUT, null, new JDFAttributeMap(partitionKeyName, (string)null), true, 0, true));
     }
     return(layout.getChildElementVector_JDFElement(elementName, null, null, true, 0, true));
 }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
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);
        }
Ejemplo n.º 7
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));
        }
Ejemplo n.º 8
0
        public virtual void testIsNewLayout()
        {
            Assert.AreEqual(EnumVersion.Version_1_3, n.getVersion(false), "version ok");
            JDFLayout lo = (JDFLayout)n.appendMatchingResource(ElementName.LAYOUT, EnumProcessUsage.AnyInput, null);

            Assert.IsTrue(JDFLayout.isNewLayout(lo), "lo 1.3");
            n.setVersion(EnumVersion.Version_1_2);
            Assert.IsFalse(JDFLayout.isNewLayout(lo), "lo 1.3");
            lo.addPartition(EnumPartIDKey.SheetName, "Sheet1");
            Assert.IsTrue(JDFLayout.isNewLayout(lo), "lo 1.3");
            Assert.IsFalse(JDFLayout.isNewLayout(rl), "l no layout");
        }
Ejemplo n.º 9
0
        ///
        ///	 <summary> * get a specific layout element by name
        ///	 *  </summary>
        ///	 * <param name="layout"> </param>
        ///	 * <param name="elementName"> </param>
        ///	 * <param name="partitionKeyName"> </param>
        ///	 * <param name="objectName">  </param>
        ///	 * <returns> JDFLayout: the element </returns>
        ///
        protected internal static JDFLayout getLayoutElement(JDFResource layout, string elementName, string partitionKeyName, string objectName)
        {
            JDFLayout s = null;

            if (JDFLayout.isNewLayout(layout))
            {
                s = (JDFLayout)layout.getPartition(new JDFAttributeMap(partitionKeyName, objectName), null);
            }
            else
            {
                s = (JDFLayout)layout.getChildWithAttribute(elementName, AttributeName.NAME, null, objectName, 0, true);
            }
            return(s);
        }
Ejemplo n.º 10
0
        ///
        ///	 <summary> * appends a signature in both old and new Layouts if old: a <code>< Signature></code> element if new: a
        ///	 * SignatureName partition leaf </summary>
        ///	 * <param name="layout">  </param>
        ///	 * <param name="elementName">  </param>
        ///	 * <param name="partitionKeyName">
        ///	 *  </param>
        ///	 * <returns> JDFLayout </returns>
        ///	 * <exception cref="JDFException">  </exception>
        ///
        protected internal static JDFLayout appendLayoutElement(JDFResource layout, string elementName, string partitionKeyName)
        {
            JDFLayout s = null;

            if (JDFLayout.isNewLayout(layout))
            {
                int n = 1 + numLayoutElements(layout, elementName, partitionKeyName);
                s = (JDFLayout)layout.addPartition(EnumPartIDKey.getEnum(partitionKeyName), partitionKeyName + Convert.ToString(n));
            }
            else
            {
                s = (JDFLayout)layout.appendElement(elementName);
            }
            return(s);
        }
Ejemplo n.º 11
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));
        }
Ejemplo n.º 12
0
        ///
        ///	 <summary> * get a specific layout element by name, creates it if it does not exist
        ///	 *  </summary>
        ///	 * <param name="layout"> </param>
        ///	 * <param name="elementName"> </param>
        ///	 * <param name="partitionKeyName"> </param>
        ///	 * <param name="objectName">  </param>
        ///	 * <returns> JDFLayout: the element </returns>
        ///	 * <exception cref="JDFException"> if the location of a newly created element is not well defined  </exception>
        ///
        protected internal static JDFLayout getCreateLayoutElement(JDFResource layout, string elementName, string partitionKeyName, string objectName)
        {
            JDFLayout s = getLayoutElement(layout, elementName, partitionKeyName, objectName);

            if (s != null)
            {
                return(s);
            }
            if (JDFLayout.isNewLayout(layout))
            {
                s = (JDFLayout)layout.addPartition(EnumPartIDKey.getEnum(partitionKeyName), objectName);
            }
            else
            {
                s = (JDFLayout)layout.appendElement(elementName);
                s.setName(objectName);
            }
            return(s);
        }
Ejemplo n.º 13
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);
        }