Пример #1
0
        ///
        ///	 <summary> * } getAudits - get all audits with attributes and partMap
        ///	 *  </summary>
        ///	 * <param name="typ"> type of the audit to take </param>
        ///	 * <param name="mAttributes"> attribute map to filter the audits </param>
        ///	 * <param name="vParts"> the partmap vector - note that not all audits legally have parts </param>
        ///	 * <returns> VElement - all elements, that matches the filter
        ///	 *
        ///	 *         default: getAudits(null, null, null) </returns>
        ///
        public virtual VElement getAudits(JDFAudit.EnumAuditType typ, JDFAttributeMap mAttributes, VJDFAttributeMap vParts)
        {
            VJDFAttributeMap vPartsLocal  = vParts;
            string           strAuditType = null;

            if (typ != null)
            {
                strAuditType = typ.getName();
            }

            VElement vElem = getPoolChildrenGeneric(strAuditType, mAttributes, null);

            if (vPartsLocal != null && vPartsLocal.Count == 0)
            {
                vPartsLocal = null;
            }

            for (int i = vElem.Count - 1; i >= 0; i--)
            { // remove known comments - this would be aught in the next check but
                // we avoid the exception
                if (!(vElem[i] is JDFAudit))
                {
                    vElem.RemoveAt(i);
                    continue; // look at next element
                }

                JDFAudit audit = (JDFAudit)vElem[i];
                if (vPartsLocal != null && !vPartsLocal.Equals(audit.getPartMapVector()))
                {
                    vElem.RemoveAt(i);
                    continue; // look at next element
                }
            }
            return(vElem);
        }
Пример #2
0
        ///
        ///	 <summary> * Method getPoolChildren_JDFResourcePool<br>
        ///	 * Gets all children with the attributes <code>name, mAttrib, nameSpaceURI</code> from the pool
        ///	 *  </summary>
        ///	 * <param name="name"> name of the child </param>
        ///	 * <param name="mAttrib"> attribute to search for </param>
        ///	 * <param name="nameSpaceURI"> namespace to search in </param>
        ///	 * <returns> VElement - a vector with all elements in the pool matching the conditions </returns>
        ///
        private VElement getPoolChildren_JDFResourcePool(string strName, JDFAttributeMap mAttrib, string nameSpaceURI)
        {
            VElement v = getPoolChildrenGeneric(strName, mAttrib, nameSpaceURI);

            for (int i = v.Count - 1; i >= 0; i--)
            {
                if (!(v[i] is JDFResource))
                {
                    v.RemoveAt(i);
                }
            }
            return(v);
        }
Пример #3
0
        ///
        ///	 <summary> * Gets all children with the attributes <code>name, mAttrib, nameSpaceURI</code> from the pool
        ///	 * <p>
        ///	 * default: GetPoolChildrenGeneric (JDFConstants.EMPTYSTRING, new JDFAttributeMap(), JDFConstants.EMPTYSTRING)
        ///	 *  </summary>
        ///	 * <param name="name"> name of the Child </param>
        ///	 * <param name="mAttrib"> the attribute to search for </param>
        ///	 * <param name="nameSpaceURI"> nameSpaceURI to search in </param>
        ///	 * <returns> VElement: a vector with all elements in the pool matching the conditions </returns>
        ///
        protected internal virtual VElement getPoolChildrenGeneric(string strName, JDFAttributeMap mAttrib, string nameSpaceURI)
        {
            VElement v = getChildElementVector(strName, nameSpaceURI, mAttrib, true, 0, false);

            for (int i = v.Count - 1; i >= 0; i--)
            {
                if (v[i] is JDFComment)
                {
                    v.RemoveAt(i);
                }
            }
            return(v);
        }
Пример #4
0
        ///
        ///	 <summary> * get a list of all span resources
        ///	 *  </summary>
        ///	 * <returns> VElement all Span elements of this </returns>
        ///
        public virtual VElement getSpans()
        {
            VElement v = getChildElementVector(null, null, null, true, 0, false);

            for (int i = v.Count - 1; i >= 0; i--)
            {
                JDFElement e = (JDFElement)v[i];
                if (e is JDFComment)
                {
                    v.RemoveAt(i);
                }
            }
            return(v);
        }
Пример #5
0
        public VElement getResourceLinks(string nam, JDFAttributeMap mAttrib, string nameSpaceURI)
        {
            VElement v = getChildElementVector(nam, nameSpaceURI, mAttrib, true, 0, false);

            for (int i = v.Count - 1; i >= 0; i--)
            {
                JDFElement e = (JDFElement)v[i];
                if (!(e is JDFResourceLink))
                {
                    v.RemoveAt(i);
                }
            }
            return(v);
        }
Пример #6
0
        public virtual VElement getQueueEntryVector(JDFAttributeMap attMap, VJDFAttributeMap parts)
        {
            VElement v = getChildElementVector(ElementName.QUEUEENTRY, null, attMap, true, -1, true);

            if (parts != null)
            {
                for (int i = v.Count - 1; i >= 0; i--)
                {
                    JDFQueueEntry qe = (JDFQueueEntry)v[i];
                    if (!parts.Equals(qe.getPartMapVector()))
                    {
                        v.RemoveAt(i);
                    }
                }
            }
            return((v == null || v.Count == 0) ? null : v);
        }
Пример #7
0
        ///
        ///	 <summary> * get all completely unlinked resources
        ///	 *  </summary>
        ///	 * <returns> V the vector of unlinked resources. </returns>
        ///
        public virtual VElement getUnlinkedResources()
        {
            VElement v = getPoolChildren(null, null, null);

            if (v == null || v.Count == 0)
            {
                return(null);
            }
            for (int i = v.Count - 1; i >= 0; i--)
            {
                JDFResource r  = (JDFResource)v[i];
                VElement    v2 = r.getLinksAndRefs(true, true);
                if (v2 != null)
                {
                    v.RemoveAt(i);
                }
            }
            return(v.Count == 0 ? null : v);
        }
Пример #8
0
        public virtual VElement getQueueEntryVector(NodeIdentifier nid)
        {
            VElement v = getQueueEntryVector();

            if (nid == null || v == null)
            {
                return(v);
            }

            for (int i = v.Count - 1; i >= 0; i--)
            {
                JDFQueueEntry qe = (JDFQueueEntry)v[i];
                if (!qe.matchesNodeIdentifier(nid))
                {
                    v.RemoveAt(i);
                }
            }

            return((v.Count == 0) ? null : v);
        }
Пример #9
0
        ///
        ///	 <summary> * add a link to one of the resources
        ///	 *  </summary>
        ///	 * <param name="bNew"> new or original? </param>
        ///	 * <param name="r"> the resource that was valid before modification<br>
        ///	 *            if r is not specified, return the link that already exists </param>
        ///	 * <returns> the ResourceLink object in the ResourceAudit that points to r </returns>
        ///
        public virtual JDFResourceLink getNewOldLink(bool bNew)
        {
            VElement v    = getChildElementVector(null, null, null, true, 0, false);
            int      iNew = bNew ? 0 : 1;

            // remove any non-reslinks, e.g. comments
            for (int i = v.Count - 1; i >= 0; i--)
            {
                if (!(v[i] is JDFResourceLink))
                {
                    v.RemoveAt(i);
                }
            }

            if (v.Count < iNew)
            {
                return(null);
            }

            return((JDFResourceLink)v[iNew]);
        }
Пример #10
0
        ///
        ///	 <summary> * Method getInvalidElements
        ///	 * <p>
        ///	 * default: GetInvalidElements(level, true, 999999)
        ///	 *  </summary>
        ///	 * <param name="level"> validation level </param>
        ///	 * <param name="bIgnorePrivate"> </param>
        ///	 * <param name="nMax"> maximum number of elements to get
        ///	 *  </param>
        ///	 * <returns> VString - vector of names of invalid elements </returns>
        ///
        public override VString getInvalidElements(EnumValidationLevel level, bool bIgnorePrivate, int nMax)
        {
            VString s = getInvalidElements_JDFElement(level, bIgnorePrivate, nMax);

            if (s.Count > nMax || hasAttribute(AttributeName.RESOURCENAME)) // multiple
            // are
            // allowed
            // with
            // resourcename
            // set
            {
                return(s);
            }

            VElement v    = getChildElementVector(null, null, null, true, 0, false);
            int      size = v.Count;

            if (size > 1)
            {
                // remove anything but resources
                for (int i = size - 1; i >= 0; i--)
                {
                    if (!(v[i] is JDFResource))
                    {
                        v.RemoveAt(i);
                    }
                }
                size = v.Count; // must refresh size due to removes
                // more than one resource --> evil!
                if (size > 1)
                {
                    for (int j = 0; j < size; j++)
                    {
                        s.appendUnique(v.item(j).LocalName);
                    }
                }
            }
            return(s);
        }
Пример #11
0
        ///
        ///	 <summary> * add a link to one of the resources
        ///	 *  </summary>
        ///	 * <param name="bNew"> true - new link, false - original link </param>
        ///	 * <param name="r"> the resource that was valid before modification </param>
        ///	 * <param name="usage"> usage of the resource </param>
        ///	 * <returns> the ResourceLink object in the ResourceAudit that points to r </returns>
        ///

        public virtual JDFResourceLink addNewOldLink(bool bNew, JDFResource r, EnumUsage usage)
        {
            VElement v    = getChildElementVector(null, null, null, true, 0, false);
            int      iNew = bNew ? 0 : 1;

            for (int i = v.Count - 1; i >= 0; i--)
            {
                if (!(v[i] is JDFResourceLink))
                {
                    v.RemoveAt(i);
                }
            }

            if (v.Count != iNew)
            {
                throw new JDFException("JDFResourceLink::AddNewOldLink invalid  ResourceAudit");
            }
            JDFResourceLink l = (JDFResourceLink)appendElement(r.getLinkString(), JDFConstants.EMPTYSTRING);

            l.setTarget(r);
            l.setUsage(usage);
            return(l);
        }
Пример #12
0
        public virtual VElement flushQueue(JDFQueueFilter qf)
        {
            int siz = 0;

            VElement ve = getQueueEntryVector();

            if (ve != null)
            {
                siz = ve.Count;
                for (int i = siz - 1; i >= 0; i--)
                {
                    JDFQueueEntry qe = (JDFQueueEntry)ve[i];
                    if (qe.matchesQueueFilter(qf))
                    {
                        if (cleanupCallback != null)
                        {
                            cleanupCallback.cleanEntry(qe);
                        }

                        qe.deleteNode();
                    }
                    else
                    {
                        ve.RemoveAt(i);
                        siz--;
                    }
                }
            }

            if (automated)
            {
                setStatusFromEntries();
            }

            return(siz == 0 ? null : ve);
        }
Пример #13
0
        ///
        ///	 <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);
        }
Пример #14
0
        ///
        ///	 <summary> * gets the matching elements in node that match this devcap
        ///	 *  </summary>
        ///	 * <param name="node">
        ///	 *            the node to search in </param>
        ///	 * <returns> VElement - the element vector of matching elements,
        ///	 *         <code>null</code> if none were found </returns>
        ///
        private VElement getMatchingElementsFromNode(JDFNode node)
        {
            VElement vElem = new VElement();

            string              nam         = getName();
            EnumContext         context     = getContext();
            JDFResourceLinkPool resLinkPool = node.getResourceLinkPool();

            if (context.Equals(EnumContext.Element))
            { // vElem - for a common return type in all cases
                if (nam.Equals(ElementName.JDF))
                {
                    vElem.Add(node);
                }
                else
                {
                    vElem = node.getChildElementVector(nam, null, null, true, 0, false);
                }
            }
            else if (context.Equals(EnumContext.Link) || context.Equals(EnumContext.Resource))
            {
                if (resLinkPool != null)
                {
                    EnumUsage linkUsage  = getLinkUsage();
                    string    procUsage  = getProcessUsage();
                    bool      bLink      = context.Equals(EnumContext.Link);
                    VElement  vElemLinks = resLinkPool.getInOutLinks(linkUsage, true, nam, null);
                    if (vElemLinks != null)
                    {
                        int linkSize = vElemLinks.Count - 1;
                        for (int j = linkSize; j >= 0; j--)
                        {
                            JDFResourceLink rl             = (JDFResourceLink)vElemLinks[j];
                            string          rlProcessUsage = rl.getProcessUsage();
                            if (!rlProcessUsage.Equals(procUsage))
                            {
                                vElemLinks.RemoveAt(j);
                            }
                        }
                    }

                    if (!bLink)
                    {
                        vElem = JDFResourceLinkPool.resourceVector(vElemLinks, null);
                    }
                    else
                    {
                        vElem = vElemLinks;
                    }
                }
            }
            else if (context.Equals(EnumContext.JMF))
            {
                // TODO __Lena__ ...
            }
            else
            { // Context_Unknown
                throw new JDFException("JDFDevCaps wrong attribute Context value");
            }

            if (vElem != null && vElem.Count == 0)
            {
                vElem = null;
            }

            return(vElem);
        }