/// /// <summary> * return the lowest minOccurs of all devCap elements /// * </summary> /// * <returns> int - the lowest minOccurs of all devCap elements </returns> /// public virtual int getMinOccurs() { int m = int.MaxValue; VElement vDC = getDevCapVector(); if (vDC != null) { int svDC = vDC.Count; for (int i = 0; i < svDC; i++) { JDFDevCap dc = (JDFDevCap)vDC[i]; if (m > dc.getMinOccurs()) { m = dc.getMinOccurs(); } } } if (m <= 0 && getRequired()) { m = 1; } return(m); }
/// /// <summary> * append elements to the node that match this DevCap, if they do not exist /// * yet /// * </summary> /// * <param name="node"> /// * the node to append the elements to </param> /// * <param name="bAll"> /// * if false, only add if minOccurs>=1 and required=true or a /// * default exists /// * </param> /// * <returns> KElement - the last element that was appended </returns> /// public virtual KElement appendMatchingElementsToNode(JDFNode node, bool bAll, org.cip4.jdflib.util.VectorMap <int, JDFResource> indexResMap, bool bLink) { KElement e = null; EnumContext context = getContext(); if (!bLink && EnumContext.Link.Equals(context)) { return(null); } if (bLink && !EnumContext.Link.Equals(context)) { return(null); } JDFDevCap devCap = getDevCap(); if (devCap == null) { return(null); } int minOcc = devCap.getMinOccurs(); if (minOcc == 0 && bAll) { minOcc = 1; } string nam = getName(); for (int i = 0; i < minOcc; i++) { if (context.Equals(EnumContext.Element)) { // vElem - for a common return type in all cases if (nam.Equals(ElementName.JDF)) { // nop - should actually never get here } else { e = node.getCreateElement(nam, getDevNS(), i); } } else if (context.Equals(EnumContext.Resource) || context.Equals(EnumContext.Link)) { EnumUsage linkUsage = getLinkUsage(); string procUsage = getProcessUsage(); JDFAttributeMap map = new JDFAttributeMap(); EnumProcessUsage pu = null; if (procUsage != null && procUsage.Length > 0) { map.put(AttributeName.PROCESSUSAGE, procUsage); pu = EnumProcessUsage.getEnum(procUsage); } if (linkUsage != null) { map.put(AttributeName.USAGE, linkUsage.getName()); } VElement links = node.getResourceLinks(nam, map, null); // now look for the correct combinedprocessindex - remove all // non-matching JDFIntegerRangeList tocNum = getTypeOccurrenceNum(); JDFIntegerList tocNum2 = tocNum == null ? null : tocNum.getIntegerList(); if (links != null && tocNum != null) { for (int ll = links.Count - 1; ll >= 0; ll--) { JDFResourceLink rl = (JDFResourceLink)links[ll]; JDFIntegerList il = rl.getCombinedProcessIndex(); if (il == null || !il.Contains(tocNum2)) { links.RemoveAt(ll); } } } if (links == null || links.Count <= i) { JDFResource r = null; // get a link hook for the matching combinedprocessindex if (bLink) { int kk = (tocNum2 == null || tocNum2.Count == 0) ? -1 : tocNum2.getInt(0); if (EnumUsage.Input.Equals(linkUsage)) { kk--; } List <JDFResource> v = null; indexResMap.TryGetValue(kk, out v); if (v != null) { int sv = v.Count; for (int kkk = 0; kkk < sv; kkk++) { JDFResource rr = v[kkk]; if (rr.LocalName.Equals(nam)) { r = rr; break; } } } } // we found no matching existing res - make a new one if (r == null) { r = node.addResource(nam, null, linkUsage, pu, null, getDevNS(), null); string id = devCap.getAttribute(AttributeName.ID, null, null); if (id != null) { JDFResourceLink rl = node.getLink(r, linkUsage); r.setID(id); if (rl != null) { rl.setrRef(id); } } if (tocNum2 == null || tocNum2.Count == 0) { indexResMap.putOne(-1, r); //(new int(-1), r); } else { indexResMap.putOne((int)tocNum2.elementAt(0), r); // only } // support // 1 // now } else // preexisting resource - just link it { e = node.linkResource(r, linkUsage, pu); } e = node.getLink(r, linkUsage); if (e != null) { JDFResourceLink rl = (JDFResourceLink)e; rl.setCombinedProcessIndex(tocNum2); } // update partititons JDFEnumerationState pidKeys = devCap.getEnumerationState(AttributeName.PARTIDKEYS); if (pidKeys != null) { VString keys = pidKeys.getAllowedValueList(); if (keys != null && keys.Count > 0) { JDFAttributeMap keyMap = new JDFAttributeMap(); for (int k = 0; k < keys.Count; k++) { string sk = "PartKey" + k; string key = keys.stringAt(k); if (key.Equals("RunIndex")) { sk = "0~-1"; } keyMap.put(key, sk); } r.getCreatePartition(keyMap, keys); } } } } else if (context.Equals(EnumContext.JMF)) { // TODO __Lena__ ... } } return(e); }