public virtual void testGetMatchingPartAmountVector() { JDFDoc d = JDFTestCaseBase.creatXMDoc(); JDFNode n = d.getJDFRoot(); JDFResourceLink xmLink = n.getLink(0, ElementName.EXPOSEDMEDIA, null, null); JDFAttributeMap mPart = new JDFAttributeMap("SignatureName", "Sig1"); mPart.put("SheetName", "S1"); mPart.put("Side", "Front"); mPart.put("Separation", "Black"); mPart.put("Condition", "Good"); xmLink.setAmount(2, mPart); mPart.put("Condition", "Waste"); xmLink.setAmount(1, mPart); JDFAmountPool aplocal = xmLink.getAmountPool(); Assert.IsNotNull(aplocal); mPart.Remove("Condition"); VElement v = aplocal.getMatchingPartAmountVector(mPart); Assert.AreEqual(2, v.Count); mPart.put("Side", "Moebius"); v = aplocal.getMatchingPartAmountVector(mPart); Assert.IsNull(v, "there certainly is no moebius side ..."); }
public virtual void testReducePartAmounts() { JDFDoc d = new JDFDoc("JDF"); JDFNode n = d.getJDFRoot(); n.setType(EnumType.ConventionalPrinting); JDFComponent comp = (JDFComponent)n.addResource("Component", null, EnumUsage.Output, null, null, null, null); JDFAttributeMap map = new JDFAttributeMap(EnumPartIDKey.SignatureName, "Sig1"); JDFResourceLink rl = n.getLink(comp, null); for (int i = 0; i < 5; i++) { map.put(EnumPartIDKey.SheetName, "Sheet" + i); comp.getCreatePartition(map, new VString("SignatureName SheetName", " ")); rl.setAmount(500 + i, map); JDFAttributeMap map2 = new JDFAttributeMap(map); map2.put("Condition", "Good"); rl.setActualAmount(500 + i, map2); map2.put("Condition", "Waste"); rl.setActualAmount(50 + i, map2); } VJDFAttributeMap v = new VJDFAttributeMap(); JDFAttributeMap testMap = new JDFAttributeMap(EnumPartIDKey.Condition, "Good"); v.Add(testMap); JDFAmountPool aplocal = rl.getAmountPool(); Assert.AreEqual(15, aplocal.numChildElements(ElementName.PARTAMOUNT, null), "15 pa entries"); aplocal.reducePartAmounts(v); Assert.AreEqual(5, aplocal.numChildElements(ElementName.PARTAMOUNT, null), "5 pa entries"); testMap.put("SheetName", "Sheet3"); aplocal.reducePartAmounts(v); Assert.AreEqual(1, aplocal.numChildElements(ElementName.PARTAMOUNT, null), "1 pa entries"); }
/// /// <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); } }