コード例 #1
0
        ///
        ///	 <summary> * devCapReport - tests if the elements in vElem fit any (logical OR) DevCap
        ///	 * element that DevCaps consists of. Composes a detailed report in XML form
        ///	 * of the errors found. If XMLDoc is null there are no errors.<br>
        ///	 *
        ///	 * DevCaps will be checked if they are direct children of <code>this</code>
        ///	 * and referenced in DevCapPool.
        ///	 *  </summary>
        ///	 * <param name="vElem">
        ///	 *            vector of the elements to test </param>
        ///	 * <param name="testlists">
        ///	 *            testlists that are specified for the State elements
        ///	 *            (FitsValue_Allowed or FitsValue_Present)<br>
        ///	 *            Will be used in fitsValue method of the State element. </param>
        ///	 * <param name="level">
        ///	 *            validation level </param>
        ///	 * <returns> XMLDoc - XMLDoc output of the error messages.<br>
        ///	 *         If XMLDoc is null there are no errors, every element of vElem
        ///	 *         fits any DevCap element of <code>this</code>. </returns>
        ///	 * <exception cref="JDFException">
        ///	 *             if DevCaps/@DevCapRef refers to the DevCap elements in a
        ///	 *             non-existent DevCapPool </exception>
        ///	 * <exception cref="JDFException">
        ///	 *             if DevCaps/@DevCapRef refers to the non-existent DevCap </exception>
        ///
        public KElement devCapReport(KElement elem, EnumFitsValue testlists, EnumValidationLevel level, bool ignoreExtensions, KElement parentReport)
        {
            if (elem == null)
            {
                return(null);
            }
            VElement dcV = getDevCapVector();

            if (dcV == null || dcV.Count == 0)
            {
                throw new JDFException("JDFDevCaps.devCapReport: Invalid DeviceCap: DevCaps/@DevCapRef refers to the non-existent DevCap: " + getDevCapRef());
            }

            KElement r = parentReport.appendElement("Invalid" + getContext().getName());

            for (int i = 0; i < dcV.Count; i++)
            {
                JDFDevCap dc = (JDFDevCap)dcV[i];
                KElement  stateTestResult = dc.stateReport(elem, testlists, level, ignoreExtensions, true, r);
                if (stateTestResult == null)
                {
                    r.deleteNode();
                    return(null); // first DevCap that fits found -> erase all error
                    // messages
                }
                r.setAttribute("XPath", elem.buildXPath(null, 1));
                r.setAttribute("Name", getContextName());
                r.setAttribute("CapXPath", dc.getName());
            }

            correction_Static(r);
            return(r);
        }
コード例 #2
0
ファイル: JDFAuditPool.cs プロジェクト: cip4/JDFLibNet
        ///
        ///	 <summary> * Append a Deleted audit element
        ///	 *  </summary>
        ///	 * <param name="by"> the author keyword </param>
        ///	 * <param name="modifiedElem"> the modified element </param>
        ///	 * <returns> JDFDeleted the newly created Modified audit
        ///	 *
        ///	 *         default: AddDeleted(null, null) </returns>
        ///
        public virtual JDFDeleted addDeleted(string by, KElement deletedElem)
        {
            JDFDeleted deleted = (JDFDeleted)addAudit(JDFAudit.EnumAuditType.Deleted, by);

            if (deletedElem != null)
            {
                string xpath = deletedElem.buildXPath(getParentJDF().buildXPath(null, 1), 1);
                deleted.setXPath(xpath);
            }

            return(deleted);
        }
コード例 #3
0
ファイル: JDFAuditPool.cs プロジェクト: cip4/JDFLibNet
        ///
        ///	 <summary> * Append a Modified audit element
        ///	 *  </summary>
        ///	 * <param name="by"> the author keyword </param>
        ///	 * <param name="modifiedElem"> the modified element
        ///	 *
        ///	 *            default: AddModified(by, null) </param>
        ///
        public virtual JDFModified addModified(string by, KElement modifiedElem)
        {
            JDFModified modified = (JDFModified)addAudit(JDFAudit.EnumAuditType.Modified, by);

            if (modifiedElem != null)
            {
                string xpath = modifiedElem.buildXPath(getParentJDF().buildXPath(null, 1), 1);
                modified.setXPath(xpath);
            }

            return(modified);
        }
コード例 #4
0
ファイル: JDFAuditPool.cs プロジェクト: cip4/JDFLibNet
        ///
        ///	 <summary> * Append a Created audit element, if createdElem==null only add if it is not yet there
        ///	 *  </summary>
        ///	 * <param name="by"> the author keyword </param>
        ///	 * <param name="createdElem"> the created element </param>
        ///	 * <returns> the newly created Created audit
        ///	 *
        ///	 *         default: AddCreated(by, null) </returns>
        ///
        public virtual JDFCreated addCreated(string by, KElement createdElem)
        {
            JDFCreated created = (JDFCreated)addAudit(JDFAudit.EnumAuditType.Created, by);

            if (createdElem != null)
            {
                string xpath = createdElem.buildXPath(getParentJDF().buildXPath(null, 1), 1);
                created.setXPath(xpath);
            }

            return(created);
        }
コード例 #5
0
        ///
        ///	 * <param name="testRoot"> </param>
        ///	 * <param name="testlists"> </param>
        ///	 * <param name="level"> </param>
        ///	 * <param name="mrp"> </param>
        ///	 * <param name="irp"> </param>
        ///	 * <param name="resLinkPool"> </param>
        ///	 * <param name="goodElems"> </param>
        ///	 * <param name="badElems"> </param>
        ///	 * <param name="devCaps">
        ///	 * @return </param>
        ///
        public virtual void analyzeDevCaps(KElement testRoot, EnumFitsValue testlists, EnumValidationLevel level, KElement mrp, KElement irp, SupportClass.HashSetSupport goodElems, Hashtable badElems, bool ignoreExtensions)
        {
            EnumAvailability av             = getModuleAvailability();
            KElement         xpathRoot      = testRoot;
            VElement         vElemResources = null;

            if (testRoot is JDFNode)
            {
                JDFNode jdfNode = (JDFNode)testRoot;
                vElemResources = getMatchingElementsFromNode(jdfNode);
                xpathRoot      = jdfNode.getResourceLinkPool();
                if (xpathRoot == null)
                {
                    xpathRoot = testRoot;
                }
            }
            else
            {
                vElemResources = getMatchingElementsFromJMF((JDFMessage)testRoot);
            }

            int svElemResources = vElemResources == null ? 0 : vElemResources.Count;

            EnumContext context = getContext();
            KElement    r       = null;

            if (EnumValidationLevel.isRequired(level) && svElemResources < getMinOccurs() && EnumAvailability.Installed.Equals(av))
            {
                if (EnumContext.Element.Equals(context) || EnumContext.JMF.Equals(context))
                {
                    r = mrp.appendElement("MissingElement");
                    r.setAttribute("XPath", xpathRoot.buildXPath(null, 1) + "/" + getName());
                }
                else
                {
                    EnumUsage linkUsage = getLinkUsage();
                    string    procUsage = getProcessUsage();
                    r = mrp.appendElement("MissingResourceLink");
                    if (linkUsage != null)
                    {
                        r.setAttribute("Usage", linkUsage.getName());
                    }
                    if (procUsage != null && procUsage.Length > 0)
                    {
                        r.setAttribute("ProcessUsage", procUsage);
                    }
                    r.setAttribute("XPath", xpathRoot.buildXPath(null, 1) + "/" + getName());
                }
                r.setAttribute("Name", getName());
                r.setAttribute("CapXPath", getName());
                r.setAttribute("Occurrences", svElemResources, null);
                r.setAttribute("MinOccurs", getMinOccurs(), null);
            }
            else if (svElemResources > getMaxOccurs() || !EnumAvailability.Installed.Equals(av))
            {
                if (context.Equals(EnumContext.Element) || context.Equals(EnumContext.JMF))
                {
                    r = irp.appendElement("ManyElement");
                    r.setAttribute("XPath", testRoot.buildXPath(null, 1) + "/" + getName());
                }
                else
                {
                    EnumUsage linkUsage = getLinkUsage();
                    string    procUsage = getProcessUsage();
                    r = irp.appendElement("ManyResourceLink");
                    if (linkUsage != null)
                    {
                        r.setAttribute("Usage", linkUsage.getName());
                    }

                    if (procUsage != null && procUsage.Length > 0)
                    {
                        r.setAttribute("ProcessUsage", procUsage);
                    }

                    r.setAttribute("XPath", xpathRoot.buildXPath(null, 1) + "/" + getName());
                }

                r.setAttribute("Name", getName());
                r.setAttribute("CapXPath", getName());
                r.setAttribute("Occurrences", svElemResources, null);
                r.setAttribute("MaxOccurs", getMaxOccurs(), null);
                r.setAttribute("Availability", av == null ? "None" : av.getName());
            }

            if (vElemResources != null)
            {
                for (int j = 0; j < svElemResources; j++)
                {
                    KElement elem = vElemResources.item(j);
                    if (!goodElems.Contains(elem))
                    {
                        KElement report = devCapReport(elem, testlists, level, ignoreExtensions, irp); // InvalidResources
                        if (report == null)
                        {
                            goodElems.Add(elem);
                            KElement badReport = (KElement)badElems[elem];
                            if (badReport != null)
                            {
                                badReport.deleteNode();
                            }
                        }
                        else
                        {
                            badElems.Add(elem, report);
                        }
                    }
                }
            }
        }
コード例 #6
0
ファイル: JDFEvaluation.cs プロジェクト: cip4/JDFLibNet
        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);
        }