/// /// <summary> * return all deviceCap elements that correspond to testRoot /// * </summary> /// * <param name="testRoot"> the JDF or JMF to test /// * </param> /// * <returns> VElement - the list of matching devicecap nodes, null if none found /// * </returns> /// public virtual VElement getMatchingDeviceCapVector(JDFNode testRoot, bool bLocal) { VElement vDeviceCap = getChildElementVector(ElementName.DEVICECAP, null, null, false, -1, false); if (vDeviceCap == null || vDeviceCap.IsEmpty()) { return(null); } VElement vRet = new VElement(); for (int i = 0; i < vDeviceCap.Count; i++) { JDFDeviceCap dc = (JDFDeviceCap)vDeviceCap[i]; if (dc.matchesType(testRoot, bLocal)) { vRet.Add(dc); } } return(vRet.IsEmpty() ? null : vRet); }
/// /// <summary> * test whether a given node has the corect Types and Type Attribute /// * </summary> /// * <param name="testRoot"> the JDF or JMF to test /// * </param> /// * <returns> VElement - the list of matching JDF nodes, null if none found /// * </returns> /// public virtual VElement getMatchingTypeNodeVector(JDFNode testRoot) { VElement vDeviceCap = getChildElementVector(ElementName.DEVICECAP, null, null, false, -1, false); if (vDeviceCap == null || vDeviceCap.IsEmpty()) { return(null); } VElement vRet = new VElement(); for (int i = 0; i < vDeviceCap.Count; i++) { VElement vMatch = ((JDFDeviceCap)vDeviceCap[i]).getMatchingTypeNodeVector(testRoot); if (vMatch != null) { vRet.addAll(vMatch); } } vRet.unify(); return(vRet.IsEmpty() ? null : vRet); }
/// /// <summary> * Gets of jdfRoot a vector of all executable nodes (jdf root or children nodes that this Device may execute) /// * </summary> /// * <param name="jdfRoot"> the node we 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 class. </param> /// * <param name="level"> validation level </param> /// * <returns> VElement - vector of executable JDFNodes </returns> /// public virtual VElement getExecutableJDF(JDFNode docRoot, EnumFitsValue testlists, EnumValidationLevel validationLevel) { VElement vDC = getChildElementVector(ElementName.DEVICECAP, null, null, true, -1, false); if (vDC == null || vDC.IsEmpty()) { return(null); } VElement vn = new VElement(); for (int i = 0; i < vDC.Count; i++) { JDFDeviceCap dc = (JDFDeviceCap)vDC[i]; VElement executableJDF = dc.getExecutableJDF(docRoot, testlists, validationLevel); if (executableJDF != null) { vn.addAll(executableJDF); } } vn.unify(); return(vn.IsEmpty() ? null : vn); }
/// /// <summary> * Composes a BugReport in XML form for the given JDFNode 'jdfRoot'. Gives a list of error messages for 'jdfRoot' /// * and every child rejected Node.<br> /// * Returns <code>null</code> if there are no errors. /// * </summary> /// * <param name="jdfRoot"> the node 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 class. </param> /// * <param name="level"> validation level </param> /// * <returns> XMLDoc - XMLDoc output of the error messages. If XMLDoc is null there are no errors. </returns> /// public XMLDoc getBadJDFInfo(JDFNode jdfRoot, EnumFitsValue testlists, EnumValidationLevel level) { VElement vDC = getChildElementVector(ElementName.DEVICECAP, null, null, true, -1, false); if (vDC == null || vDC.IsEmpty()) { return(null); } VElement vn = new VElement(); for (int i = 0; i < vDC.Count; i++) { JDFDeviceCap dc = (JDFDeviceCap)vDC[i]; XMLDoc bugReport = dc.getBadJDFInfo(jdfRoot, testlists, level); if (bugReport == null) { return(null); } vn.addAll(bugReport.getRoot().getChildElementVector(null, null, null, true, -1, false)); } int vnSize = vn.Count; if (vnSize == 0) { return(null); } XMLDoc bugReport2 = new XMLDoc("BugReport", null); KElement root = bugReport2.getRoot(); bool bFit = false; for (int i = 0; i < vnSize; i++) { KElement e = vn[i]; if (JDFConstants.TRUE.Equals(e.getAttribute(JDFDeviceCap.FITS_TYPE))) { bFit = true; } } if (bFit) { for (int i = 0; i < vnSize; i++) { KElement e = vn[i]; if (JDFConstants.FALSE.Equals(e.getAttribute(JDFDeviceCap.FITS_TYPE))) { vn[i] = null; } } } for (int i = 0; i < vnSize; i++) { if (vn[i] != null) { root.moveElement(vn.item(i), null); } } return(bugReport2); }
/// /// /// <summary> * gets the sum of all matching tags, with the assumpzion that no condition defaults to good /// * </summary> /// * <param name="poolParent"> </param> /// * <param name="attName"> </param> /// * <param name="vPart"> </param> /// * <returns> the sum /// * </returns> /// public static double getAmountPoolSumDouble(IAmountPoolContainer poolParent, string attName, VJDFAttributeMap vPart) { VJDFAttributeMap vPartLocal = vPart; if (vPartLocal == null) { vPartLocal = poolParent.getPartMapVector(); } if (poolParent.hasAttribute(attName)) { return(poolParent.getRealAttribute(attName, null, 0)); } VJDFAttributeMap vm = vPartLocal == null ? null : new VJDFAttributeMap(vPartLocal); JDFResource linkRoot = poolParent.getLinkRoot(); if (linkRoot != null && vm != null) { SupportClass.SetSupport <string> @set = linkRoot.getPartIDKeys().getSet(); @set.Add(AttributeName.CONDITION); // retain good / waste vm.reduceMap(@set); } if (vm == null) { vm = new VJDFAttributeMap(); vm.Add((JDFAttributeMap)null); } double dd = 0; JDFAmountPool ap = poolParent.getAmountPool(); if (ap == null) { return(poolParent.getRealAttribute(attName, null, 0.0)); } VElement vParts = ap.getChildElementVector(ElementName.PARTAMOUNT, null); if (vParts.IsEmpty()) { return(poolParent.getRealAttribute(attName, null, 0.0)); } bool isWaste = vPartLocal != null && vPartLocal.subMap(new JDFAttributeMap(AttributeName.CONDITION, "Waste")); if (!isWaste && (vPartLocal == null || !vPartLocal.subMap(new JDFAttributeMap(AttributeName.CONDITION, "*")))) { vPartLocal = new VJDFAttributeMap(vPartLocal); vPartLocal.Add(new JDFAttributeMap(AttributeName.CONDITION, "Good")); } for (int j = 0; j < vParts.Count; j++) { JDFPartAmount pa = (JDFPartAmount)vParts[j]; VJDFAttributeMap partMapVector = pa.getPartMapVector(); if (isWaste) { bool hasCondition = partMapVector.subMap(new JDFAttributeMap(AttributeName.CONDITION, "*")); if (!hasCondition) { continue; } } if (!partMapVector.overlapsMap(vm)) { continue; } string ret = null; ret = pa.getAttribute(attName, null, null); if (ret == null) { ret = poolParent.getAttribute(attName, null, null); } dd += StringUtil.parseDouble(ret, 0.0); } return(dd); }
/// /// <summary> * generate a JDF 1.2 compatible Layout from this (1.3) /// * </summary> /// * <returns> bool true if successful /// * </returns> /// public virtual bool fromNewLayout() { // TODO: fix content object placement VElement vLO = getChildElementVector_JDFElement(ElementName.LAYOUT, null, new JDFAttributeMap("SignatureName", ""), false, 0, false); VElement vSig = new VElement(); if (vLO.IsEmpty()) { JDFSignature signature = (JDFSignature)appendElement(ElementName.SIGNATURE); signature.setName("Sig_00"); vSig.Add(signature); moveElementsTo((JDFLayout)signature); } else { JDFSignature sig = null; for (int i = 0; i < vLO.Count; i++) { JDFElement lo = (JDFElement)vLO[i]; sig = null; if (lo.hasAttribute(AttributeName.SIGNATURENAME)) { lo.renameAttribute(AttributeName.SIGNATURENAME, AttributeName.NAME, null, null); sig = (JDFSignature)lo.renameElement(ElementName.SIGNATURE, null); sig.cleanResourceAttributes(); vSig.Add(sig); } else { if (vSig.IsEmpty()) { JDFSignature signature = (JDFSignature)appendElement(ElementName.SIGNATURE); signature.setName("Sig_00"); vSig.Add(sig); } } if (sig != null) { moveElement(sig, null); } } } int nSheet = 0; for (int iSig = 0; iSig < vSig.Count; iSig++) { JDFSignature sig = (JDFSignature)vSig[iSig]; vLO = sig.getChildElementVector_JDFElement(ElementName.LAYOUT, null, new JDFAttributeMap("SheetName", ""), false, 0, false); VElement vSheet = new VElement(); if (vLO.IsEmpty()) { nSheet++; JDFSheet sheet = (JDFSheet)sig.appendElement(ElementName.SHEET); sheet.setName("Sheet_" + Convert.ToString(nSheet)); vSheet.Add(sheet); ((JDFLayout)sig).moveElementsTo((JDFLayout)sheet); } else { JDFSheet sheet = null; for (int i = 0; i < vLO.Count; i++) { sheet = null; JDFElement lo = (JDFElement)vLO[i]; if (lo.hasAttribute(AttributeName.SHEETNAME)) { lo.renameAttribute(AttributeName.SHEETNAME, AttributeName.NAME, null, null); sheet = (JDFSheet)lo.renameElement(ElementName.SHEET, null); sheet.cleanResourceAttributes(); vSheet.Add(sheet); nSheet++; } else { if (vSheet.IsEmpty()) { nSheet++; sheet = (JDFSheet)sig.appendElement(ElementName.SHEET); sheet.setName("Sheet_" + Convert.ToString(nSheet)); vSheet.Add(sheet); } if (sheet != null) { sheet.moveElement(lo, null); } } } } for (int iSheet = 0; iSheet < vSheet.Count; iSheet++) { JDFSheet sheet = (JDFSheet)vSheet[iSheet]; vLO = sheet.getChildElementVector_JDFElement(ElementName.LAYOUT, null, new JDFAttributeMap("Side", ""), false, 0, false); if (vLO.IsEmpty()) { JDFSurface surf = (JDFSurface)sheet.appendElement(ElementName.SURFACE); surf.setSide(EnumSide.Front); ((JDFLayout)sheet).moveElementsTo((JDFLayout)surf); } else { for (int i = 0; i < vLO.Count; i++) { JDFSurface surface = (JDFSurface)vLO[i]; //C# renameElement only returns the renamed element. surface = (JDFSurface)surface.renameElement(ElementName.SURFACE, null); EnumSide sid = surface.getSide(); surface.cleanResourceAttributes(); surface.setSide(sid); } } } } removeFromAttribute(AttributeName.PARTIDKEYS, AttributeName.SIGNATURENAME, null, JDFConstants.BLANK, -1); removeFromAttribute(AttributeName.PARTIDKEYS, AttributeName.SHEETNAME, null, JDFConstants.BLANK, -1); removeFromAttribute(AttributeName.PARTIDKEYS, AttributeName.SIDE, null, JDFConstants.BLANK, -1); return(true); }