public virtual void testGetResource() { JDFDoc doc = new JDFDoc(ElementName.JMF); JDFJMF jmf = doc.getJMFRoot(); JDFCommand c = jmf.appendCommand(EnumType.PipePull); JDFPipeParams pp = c.appendPipeParams(); JDFExposedMedia xm = (JDFExposedMedia)pp.appendResource(ElementName.EXPOSEDMEDIA); Assert.AreEqual(EnumResourceClass.Handling, xm.getResourceClass()); JDFMedia m = (JDFMedia)pp.appendResource(ElementName.MEDIA); Assert.AreEqual(EnumResourceClass.Consumable, m.getResourceClass()); JDFRefElement rm = xm.refElement(m); Assert.AreEqual(m, rm.getTarget()); Assert.AreEqual(xm, pp.getResource(ElementName.EXPOSEDMEDIA)); Assert.AreEqual(xm, pp.getResource(null)); Assert.AreEqual(m, pp.getResource(ElementName.MEDIA)); try { Assert.IsNull(pp.getResource("MediaLink")); Assert.Fail(); } catch (JDFException) { // nop } JDFResourceLink rl = pp.appendResourceLink(ElementName.EXPOSEDMEDIA, true); rl.setrRef(xm.getID()); Assert.AreEqual(xm, pp.getResource(null)); Assert.AreEqual(rl.getTarget(), pp.getResource(null)); }
/// /// <summary> * Get the linked resources matching some conditions /// * </summary> /// * <param name="mResAtt"> map of Resource attributes to search for </param> /// * <param name="bFollowRefs"> true if internal references shall be followed </param> /// * <returns> vector with all elements matching the conditions default: GetLinkedResources(new JDFAttributeMap(), /// * false) </returns> /// public virtual VElement getLinkedResources(JDFAttributeMap mResAtt, bool bFollowRefs) { VElement vChild = getChildElementVector(null, null, null, true, 99999, false); VElement vElem = new VElement(); for (int i = 0; i < vChild.Count; i++) { JDFResource r = null; object elem = vChild[i]; if ((elem is JDFRefElement)) { JDFRefElement l = (JDFRefElement)elem; r = l.getLinkRoot(null); } else if (elem is JDFResource) { r = (JDFResource)elem; } if (r != null && r.includesAttributes(mResAtt, true)) { vElem.Add(r); // vElem.push_back(r); if (bFollowRefs) { vElem.appendUnique(r.getvHRefRes(bFollowRefs, true)); } } } return(vElem); }
public virtual void testMediaRef() { JDFDoc doc = new JDFDoc(ElementName.JMF); JDFJMF jmf = doc.getJMFRoot(); JDFSignal s = jmf.appendSignal(); jmf.setSenderID("DeviceSenderID"); s.setType(EnumType.Resource); JDFResourceQuParams rqp = s.appendResourceQuParams(); rqp.setJobID("JobID"); rqp.setJobPartID("JobPartID"); rqp.setResourceName(ElementName.EXPOSEDMEDIA); JDFResourceInfo ri = s.appendResourceInfo(); JDFExposedMedia xm = (JDFExposedMedia)ri.appendElement("ExposedMedia"); JDFResourceInfo ri2 = s.appendResourceInfo(); JDFMedia m = (JDFMedia)ri2.appendElement("Media"); JDFRefElement rm = xm.refElement(m); Assert.AreEqual(m, rm.getTarget(), "works initially "); Assert.AreEqual(m, rm.getTarget(), "also works with cache"); }
/// /// <summary> * delete this sourceResource and it's target /// * </summary> /// * <param name="bool"> /// * bCheckRefCount if true, check that no other element refers to /// * the target before deleting<br> /// * if bCheckRefCount=false, the target is force deleted </param> /// * <returns> JDFElement the deleted targeelement /// * @since 290620 </returns> /// public virtual JDFElement deleteRef(bool bCheckRefCount) { JDFRefElement refElement = getRefElement(); if (refElement != null) { return(refElement.deleteRef(bCheckRefCount)); } return(null); }
/// /// <summary> * return the NodeName of the referenced resource /// * </summary> /// * <returns> the nodename of the referenced resource </returns> /// public virtual string getSourcefNodeName() { JDFRefElement refElement = getRefElement(); if (refElement != null) { return(refElement.getRefNodeName()); } return(null); }
/// /// <summary> * overrides the deprecated method JDFElement.getTarget() /// * </summary> /// * <seealso cref= org.cip4.jdflib.core.JDFElement#getTarget() /// * @return </seealso> /// public new JDFResource getTarget() { JDFRefElement refElement = getRefElement(); JDFResource r = null; if (refElement != null) { r = refElement.getTarget(); } return(r); }
/// /// <summary> * gets the link of the linked route /// * /// * @return </summary> /// public virtual JDFResource getLinkRoot() { JDFRefElement refElement = getRefElement(); JDFResource r = null; if (refElement != null) { r = refElement.getLinkRoot(null); } return(r); }
/// /// <summary> * version fixing routine for JDF /// * /// * uses heuristics to modify this element and its children to be compatible /// * with a given version in general, it will be able to move from low to high /// * versions but potentially fail when attempting to move from higher to /// * lower versions /// * </summary> /// * <param name="version"> /// * : version that the resulting element should correspond to </param> /// * <returns> true if successful </returns> /// public override bool fixVersion(EnumVersion version) { bool bRet = true; if (version != null) { if (version.getValue() >= EnumVersion.Version_1_3.getValue()) { if (hasAttribute(AttributeName.SOURCESHEET)) { string sourceSheet = getSourceSheet(); JDFRefElement layoutRef = (JDFRefElement)getElement_KElement("LayoutRef", null, 0); if (layoutRef != null) { JDFLayout lo = (JDFLayout)layoutRef.getLinkRoot(layoutRef.getrRef()); if (lo != null) { lo.fixVersion(version); } layoutRef.setPartMap(new JDFAttributeMap(AttributeName.SHEETNAME, sourceSheet)); lo = (JDFLayout)layoutRef.getTarget(); layoutRef.setPartMap(lo.getPartMap()); } removeAttribute(AttributeName.SOURCESHEET); } } else { JDFLayout layout = getLayout(); if (layout != null) { string sourcesheet = layout.getSheetName(); setSourceSheet(sourcesheet); JDFRefElement layoutRef = (JDFRefElement)getElement_KElement("LayoutRef", null, 0); // JDF 1.2 layout should be unpartitioned if (layoutRef != null) { // JDF 1.2 layout should be unpartitioned layoutRef.removeChild(ElementName.PART, null, 0); } } } } return(base.fixVersion(version) && bRet); }
/// /// <summary> * Copy all data from parentNode into the ancestor elements of this /// * </summary> /// * <param name="parentNode"> the closest parent Node that contains the information to be copied </param> /// * <param name="bCopyNodeInfo"> if true, also copy the NodeInfo into the ancestor </param> /// * <param name="bCopyCustomerInfo"> if true, also copy the CustomerInfo into the ancestor </param> /// * <param name="bCopyComments"> if true, also copy the comments into the ancestor /// * @default copyNodeData(parentNode, false, false, false); </param> /// public virtual void copyNodeData(JDFNode parentNode, bool bCopyNodeInfo, bool bCopyCustomerInfo, bool bCopyComments) { VElement vAncestors = getPoolChildren(null); JDFNode node = parentNode; JDFNode thisParentNode = getParentJDF(); int i; for (i = vAncestors.Count - 1; i >= 0; i--) { JDFAncestor ancestor = (JDFAncestor)vAncestors[i]; if (!node.getID().Equals(ancestor.getNodeID())) { throw new JDFException("JDFAncestorPool::CopyNodeData: Invalid pairing"); } ancestor.setAttributes(node); ancestor.removeAttribute(AttributeName.XSITYPE); ancestor.renameAttribute(AttributeName.ID, AttributeName.NODEID, null, null); // only copy nodeinfo and customerinfo in real parent nodes, not in // this of partitioned spawns if (!thisParentNode.getID().Equals(node.getID())) { if (bCopyNodeInfo) { JDFNodeInfo nodeInfo = node.getNodeInfo(); if (nodeInfo != null) { if (nodeInfo.getParentNode_KElement() is JDFResourcePool) { // add a low level refelement, the copying takes // place inaddspawnedresources JDFRefElement re = (JDFRefElement)ancestor.appendElement(ElementName.NODEINFO + JDFConstants.REF); re.setrRef(nodeInfo.getID()); re.setPartMap(nodeInfo.getPartMap()); } else { ancestor.copyElement(nodeInfo, null); } } } if (bCopyCustomerInfo) { JDFCustomerInfo customerInfo = node.getCustomerInfo(); if (customerInfo != null) { if (customerInfo.getParentNode_KElement() is JDFResourcePool) { // add a low level refelement, the copying takes // place inaddspawnedresources JDFRefElement re = (JDFRefElement)ancestor.appendElement(ElementName.CUSTOMERINFO + JDFConstants.REF); re.setrRef(customerInfo.getID()); re.setPartMap(customerInfo.getPartMap()); } else { ancestor.copyElement(customerInfo, null); } } } if (bCopyComments) { VElement v = node.getChildElementVector(ElementName.COMMENT, null, null, true, 0, false); for (int j = 0; j < v.Count; j++) { ancestor.copyElement(v[j], null); } } } JDFNode node2 = node.getParentJDF(); // 100602 RP added i-- if (node2 == null) { i--; break; } node = node2; } // the original node was already spawned --> also copy the elements of // the original nodes Ancestorpool if (i >= 0) { VElement parentAncestors = node.getAncestorPool().getPoolChildren(null); int parentAncestorSize = parentAncestors.Count; if (parentAncestorSize < i + 1) { throw new JDFException("JDFAncestorPool.CopyNodeData: Invalid AncestorPool pairing"); } // now copy the ancestorpool elements that have not yet been added // from the original nodes for (; i >= 0; i--) { JDFAncestor ancestor = (JDFAncestor)vAncestors[i]; JDFAncestor parentAncestor = (JDFAncestor)parentAncestors[i]; ancestor.mergeElement(parentAncestor, false); } } }