public virtual void testGetTargetVectorNullPart() { JDFDoc d = JDFTestCaseBase.creatXMDoc(); JDFNode n = d.getJDFRoot(); JDFResourceLink rl = n.getMatchingLink("ExposedMedia", EnumProcessUsage.Plate, 0); rl.appendPart(); VElement v = rl.getTargetVector(0); Assert.AreEqual(1, v.Count, "The target vector is the node with two leaves"); JDFResource linkRoot = rl.getLinkRoot(); Assert.AreEqual(linkRoot, v[0], "The target vector is the node with two leaves"); linkRoot.setPartUsage(EnumPartUsage.Implicit); v = rl.getTargetVector(0); Assert.AreEqual(1, v.Count, "The target vector is the node with two leaves"); Assert.AreEqual(linkRoot, v[0], "The target vector is the node with two leaves"); linkRoot.setPartUsage(EnumPartUsage.Explicit); JDFAttributeMap mPart = new JDFAttributeMap("SignatureName", "Sig1"); mPart.put("SheetName", "S1"); rl.setPartMap(mPart); rl.appendPart(); v = rl.getTargetVector(0); Assert.AreEqual(2, v.Count, "The target vector is the node with two leaves"); Assert.IsTrue(v.Contains(linkRoot)); Assert.IsTrue(v.Contains(linkRoot.getPartition(mPart, null))); linkRoot.setPartUsage(EnumPartUsage.Implicit); v = rl.getTargetVector(0); Assert.IsTrue(v.Contains(linkRoot)); Assert.IsTrue(v.Contains(linkRoot.getPartition(mPart, null))); }
/// /// <summary> * get the referenced target resource /// * The resource's PartUsage is evaluated to correctly retrieve implicit or explicit partitions<br> /// * may return null /// * /// * overrides the deprecated method JDFElement.getTarget() /// * </summary> /// * <returns> JDFResource - the reference target partition </returns> /// public new JDFResource getTarget() { JDFResource targetRoot = getTargetRoot(); if (targetRoot == null) { return(null); } JDFAttributeMap partMap = getPartMap(); if (partMap == null) { return(targetRoot); } return(targetRoot.getPartition(partMap, null)); }
/// /// <summary> * get double attribute Amount, defaults to the value of Amount for the linked partition /// * </summary> /// * <param name="mPart"> partition map to retrieve Amount for </param> /// * <returns> the amount, -1 if none is specified /// * /// * @default getAmount(null) </returns> /// public static double getAmount(IAmountPoolContainer poolParent, JDFAttributeMap mPart) { double d = getAmountPoolDouble(poolParent, AttributeName.AMOUNT, mPart); if (d == -1) { JDFResource target = poolParent.getLinkRoot(); if (target != null) { target = target.getPartition(mPart, null); if (target != null) { return(target.getAmount()); } } } else { return(d); } return(-1.0); }
/// /// <summary> * apply the parameters in this to all appropriate resources in parentNode or one of parentNode's children /// * </summary> /// * <param name="parentNode"> the node to search in </param> /// internal virtual void applyResourceCommand(JDFNode parentNode) { if (parentNode == null) { return; } VElement vNodes = parentNode.getvJDFNode(null, null, false); int size = vNodes.Count; for (int i = 0; i < size; i++) { JDFNode node = (JDFNode)vNodes[i]; if (!matchesNode(node)) { continue; } JDFResource resCmd = enclosingInstance.getResource(null); if (resCmd == null) { continue; } bool isIncremental = (enclosingInstance.getUpdateMethod() == EnumUpdateMethod.Incremental); // commented out, statements have no effect // double dAmount = -1.0; // if (hasAttribute (AttributeName.PRODUCTIONAMOUNT)) // { // dAmount = getProductionAmount (); // TODO: set ProductionAmount // } // final String strProcessUsage = getProcessUsage(); // TODO: use // ProcessUsage // final JDFElement.EnumNodeStatus status = getStatus(); // TODO: // set Status VJDFAttributeMap vamParts = enclosingInstance.getPartMapVector(); JDFResource resTarget = getTargetResource(node); if (resTarget == null) { resTarget = createNewResource(node, resCmd); if (resTarget == null) { continue; } } // get the most granular list of partIDKeys from the cmd or resource VString vsPartIDKeys = resTarget.getPartIDKeys(); VString vsPartIDKeysCmd = resCmd.getPartIDKeys(); int sizTarget = vsPartIDKeys == null ? 0 : vsPartIDKeys.Count; int sizCmd = vsPartIDKeysCmd == null ? 0 : vsPartIDKeysCmd.Count; if (sizCmd > sizTarget) { vsPartIDKeys = vsPartIDKeysCmd; } int sizeParts = vamParts == null ? 1 : vamParts.Count; for (int j = 0; j < sizeParts; j++) { JDFAttributeMap amParts = vamParts == null ? null : vamParts[j]; JDFResource resTargetPart = resTarget.getCreatePartition(amParts, vsPartIDKeys); if (resTargetPart == null) { continue; } string id = resTargetPart.getID(); if (!isIncremental) { JDFAttributeMap map = resTargetPart.getPartMap(); resTargetPart.flush(); resTargetPart.setAttributes(map); } JDFResource resCmdPart = resCmd.getPartition(amParts, EnumPartUsage.Implicit); JDFAttributeMap map2 = resCmdPart.getAttributeMap(); VString keys = map2.getKeys(); if (keys != null) { int keySize = keys.Count; for (int k = 0; k < keySize; k++) { string key = keys[k]; string @value = map2.get(key); if (@value == null || JDFConstants.EMPTYSTRING.Equals(@value)) { resCmdPart.removeAttribute(key); resTargetPart.removeAttribute(key); } } } resTargetPart.mergeElement(resCmdPart, false); resTarget.setID(id); } if (sizeParts > 0 && resTarget is JDFNodeInfo) { fixNodeStatusFromNodeInfo(node, resTarget); } } }
public virtual VString copyResource(JDFResource r, JDFResource.EnumSpawnStatus copyStatus, VJDFAttributeMap vParts, string spawnID) { VString ss = getResIds(); VString v = new VString(); // r is not yet here copy r if (!ss.Contains(r.getID())) { JDFResource rNew = null; // if spawning, fix stati and locks if (copyStatus == JDFResource.EnumSpawnStatus.SpawnedRO) { // copy the complete resource as RO - no need to reduce // partitions r.appendSpawnIDs(spawnID); rNew = (JDFResource)copyElement(r, null); rNew.setLocked(true); r.setSpawnStatus(copyStatus); } else if (copyStatus == JDFResource.EnumSpawnStatus.SpawnedRW) { if (vParts.Count == 0) { // just copy the whole thing - no parts specified r.appendSpawnIDs(spawnID); rNew = (JDFResource)copyElement(r, null); r.setSpawnStatus(copyStatus); } else { rNew = (JDFResource)copyElement(r, null); rNew.reducePartitions(vParts); // reduce any unneeded leaves // loop over all part maps to get best matching resource for (int i = 0; i < vParts.Count; i++) { JDFResource pLeaf = r.getPartition(vParts[i], null); JDFResource pNewLeaf = rNew.getPartition(vParts[i], null); if (pLeaf != null) { pLeaf.setSpawnStatus(copyStatus); pLeaf.appendSpawnIDs(spawnID); } if (pNewLeaf != null) { pNewLeaf.appendSpawnIDs(spawnID); } } } } if (rNew != null) { v.Add(rNew.getID()); } } VString vs = r.getHRefs(null, false, true); // add recursively copied resources for (int i = 0; i < vs.Count; i++) { string id = vs[i]; // the referenced resource is in this pool - continue if (ss.Contains(id)) { continue; } // the referenced resource has already been merged in - continue if (v.Contains(id)) { continue; } JDFResource next = (JDFResource)getDocRoot().getTarget(id, AttributeName.ID); if (next == null) { // 071101 RP added r is by definition in the original document // which also contains the rrefs elements next = (JDFResource)r.getDocRoot().getTarget(id, AttributeName.ID); // and now all those interlinked resources VString vv = copyResource(next, copyStatus, vParts, spawnID); v.AddRange(vv); } } return(v); }