Пример #1
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);
        }
Пример #2
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);
        }
Пример #3
0
        ///
        ///	 <summary> * get refElements
        ///	 *  </summary>
        ///	 * <param name="vDoneRefs"> used internally for recursion </param>
        ///	 * <param name="bRecurse"> if true, also return recursively linked IDs </param>
        ///	 * <returns> HashSet: the vector of referenced resource IDs </returns>
        ///
        public override SupportClass.HashSetSupport getAllRefs(SupportClass.HashSetSupport vDoneRefs, bool bRecurse)
        {
            SupportClass.HashSetSupport vDoneRefsLocal = vDoneRefs;

            VElement vResources = getPoolChildren(null, null, null);
            int      size       = vResources.Count;

            for (int i = 0; i < size; i++)
            {
                JDFResource r = (JDFResource)vResources[i];
                vDoneRefsLocal = r.getResourceRoot().getAllRefs(vDoneRefsLocal, bRecurse);
            }

            return(vDoneRefsLocal);
        }
Пример #4
0
        ///
        ///	 <summary> * heuristics to check which version an element of a Layout is in: 1.3 or
        ///	 * 1.2
        ///	 *
        ///	 * Note that this routine is static since it must be used on all sheets,
        ///	 * surfaces etc.
        ///	 *  </summary>
        ///	 * <param name="sheet">
        ///	 *            the Sheet, Surface, Signature or Layout to check </param>
        ///	 * <returns> true if this is a new, i.e. partitioned Layout
        ///	 *  </returns>
        ///
        public static bool isNewLayout(JDFResource sheet)
        {
            // not one of Layout, Signature, Sheet or Surface
            if (!(sheet is JDFLayout))
            {
                return(false);
            }

            // either Signature, Sheet or Surface --> old
            if (!sheet.LocalName.Equals(ElementName.LAYOUT))
            {
                return(false);
            }

            // it's a layout the only allowed (old) element is a signature , if it
            // exists --> old
            if (sheet.getElement_KElement(ElementName.SIGNATURE, null, 0) != null)
            {
                return(false);
            }
            // it is a layout and it has no subelements and it is partitioned -->
            // new
            JDFResource resourceRoot = sheet.getResourceRoot();

            if (resourceRoot.hasAttribute(AttributeName.PARTIDKEYS))
            {
                return(true);
            }
            // it is a non partitioned layout and it has palacedobjects --> new
            if (resourceRoot.hasChildElement(ElementName.CONTENTOBJECT, null) || resourceRoot.hasChildElement(ElementName.MARKOBJECT, null))
            {
                return(true);
            }

            // now I'm ready to punt - no partition and no subelements --> assume
            // that version tags are correct
            EnumVersion v = sheet.getVersion(true);

            // no version, we are 1.3 --> assume 1.3
            if (v == null)
            {
                return(true);
            }

            return(v.getValue() >= EnumVersion.Version_1_3.getValue());
        }
Пример #5
0
        private bool fitsPath(KElement e, string xPath, KElement reportRoot)
        {
            bool     b       = false;
            KElement attr    = null;
            string   newPath = null;

            int posAt  = xPath.LastIndexOf("@");
            int posAtI = posAt > 0 ? xPath.LastIndexOf("[@") : -1;

            if (posAt < 0 || posAt == posAtI + 1) // element
            {
                KElement pathElement = e.getXPathElement(xPath);
                b = fitsValue(pathElement);
                if (b)
                {
                    if (reportRoot != null)
                    {
                        if (pathElement != null)
                        {
                            newPath = pathElement.buildXPath(null, 1);
                        }
                        attr = reportRoot.appendElement("TestedElement");
                        attr.setAttribute("Name", StringUtil.token(xPath, -1, "/"));
                    }
                }
            }
            else
            // attribute
            {
                string attrVal = e.getXPathAttribute(xPath, null);
                b = fitsValue(attrVal);
                string   attName     = xPath.Substring(posAt + 1);
                KElement pathElement = e.getXPathElement(xPath.Substring(0, posAt));

                if (pathElement is JDFResource)
                {
                    JDFResource r    = (JDFResource)pathElement;
                    JDFResource root = r.getResourceRoot();
                    while (r != root)
                    {
                        if (!r.hasAttribute_KElement(attName, null, false))
                        {
                            r = (JDFResource)r.getParentNode_KElement();
                        }
                        else
                        {
                            break;
                        }
                    }
                    pathElement = r;
                    newPath     = pathElement.buildXPath(null, 1) + "/@" + attName;
                }
                if (newPath != null)
                {
                    attrVal = e.getXPathAttribute(newPath, null);
                }
                b = fitsValue(attrVal);
                if (reportRoot != null)
                {
                    attr = reportRoot.appendElement("TestedAttribute");
                    attr.setAttribute("Name", attName);
                    attr.setAttribute("Value", attrVal);
                }
            }

            if (attr != null)
            {
                attr.setAttribute("XPath", newPath);
            }
            return(b);
        }