/// /// <summary> * sets all relevant parameters of this to the values specified in resourceLink or its linked resource or JDF node /// * </summary> /// * <param name="resourceLink"> the resourceLink to extract the information from </param> /// * <param name="rqp"> parameters </param> /// public virtual void setLink(JDFResourceLink resourceLink, JDFResourceQuParams rqp) { if (resourceLink == null) { return; } JDFAmountPool ap = resourceLink.getAmountPool(); if (ap != null) { copyElement(ap, null); } else { if (resourceLink.hasAttribute(AttributeName.ACTUALAMOUNT)) { setActualAmount(resourceLink.getActualAmount(null)); } if (resourceLink.hasAttribute(AttributeName.AMOUNT)) { setAmount(resourceLink.getAmount(null)); } } setProcessUsage(resourceLink.getEnumProcessUsage()); JDFResource r = resourceLink.getTarget(); if (r == null && rqp != null) { rqp.setExact(false); } bool bExact = rqp == null ? false : rqp.getExact(); if (!bExact || r == null) // if we do not have a resource let's limp // along and provide as much as we have { setResourceName(resourceLink.getLinkedResourceName()); setAttribute(AttributeName.RESOURCEID, resourceLink.getrRef()); EnumUsage usage = resourceLink.getUsage(); if (usage != null) { setAttribute(AttributeName.USAGE, usage.getName()); } if (r != null && r.hasAttribute(AttributeName.PRODUCTID)) { setProductID(r.getProductID()); } } else { // create a copy of the resource in the original jdf JDFResource rr = (JDFResource)r.getParentNode_KElement().copyElement(r, null); rr.inlineRefElements(null, null, true); // move resource copy from the original node into this document moveElement(rr, null); } }
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); }