Exemplo n.º 1
0
        ///
        ///	 <summary> * Gets typesafe enumerated attribute Availability
        ///	 *  </summary>
        ///	 * <returns> EnumAvailability: the enumeration value of the attribute </returns>
        ///
        public virtual EnumAvailability getAvailability()
        {
            EnumAvailability avail = EnumAvailability.getEnum(getAttribute(AttributeName.AVAILABILITY, null, null));

            if (avail == null)
            {
                JDFDevCap par = getParentDevCap();
                if (par != null)
                {
                    avail = par.getAvailability();
                }
            }
            return(avail == null ? EnumAvailability.Installed : avail);
        }
Exemplo n.º 2
0
        private string getParentPath()
        {
            string   namePath = null;
            KElement parent   = getParentNode_KElement();

            if (parent is JDFDevCap)
            {
                JDFDevCap devCap = getParentDevCap();
                namePath = devCap.getNamePath(true);
            }
            else if (parent is JDFDeviceCap)
            {
                namePath = "JDF";
            }
            else if (parent is JDFMessageService)
            {
                namePath = "JMF";
            }
            return(namePath);
        }
Exemplo n.º 3
0
        ///
        ///	 <summary> * sets default elements and adds them, if there are less than minOccurs
        ///	 *  </summary>
        ///	 * <param name="node">
        ///	 *            the node to set </param>
        ///	 * <param name="bAll">
        ///	 *            if false, only add if minOccurs>=1 and required=true or a
        ///	 *            default exists, if true, always create one
        ///	 *  </param>
        ///	 * <returns> boolean true if a default element was created, else false </returns>
        ///
        public virtual bool setDefaultsFromCaps(JDFNode node, bool bAll)
        {
            bool modified = false;

            JDFDevCap dc = getDevCap();

            if (dc != null)
            {
                VElement v = getMatchingElementsFromNode(node);
                if (v != null)
                {
                    int size = v.Count;
                    for (int i = 0; i < size; i++)
                    {
                        modified = dc.setDefaultsFromCaps(v.item(i), bAll) || modified;
                    }
                }
            }

            return(modified);
        }
Exemplo n.º 4
0
        ///
        ///	 <summary> * return the highest maxOccurs of all devCap elements
        ///	 *  </summary>
        ///	 * <returns> int - the highest maxOccurs of all devCap elements </returns>
        ///
        public virtual int getMaxOccurs()
        {
            int m = 0;

            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.getMaxOccurs())
                    {
                        m = dc.getMaxOccurs();
                    }
                }
            }

            return(m);
        }
Exemplo n.º 5
0
        //
        //	 * (non-Javadoc)
        //	 *
        //	 * @see
        //	 * org.cip4.jdflib.core.JDFElement#getInvalidAttributes(org.cip4.jdflib.
        //	 * core.KElement.EnumValidationLevel, boolean, int)
        //
        public override VString getInvalidAttributes(EnumValidationLevel level, bool bIgnorePrivate, int nMax)
        {
            VString vs = base.getInvalidAttributes(level, bIgnorePrivate, nMax);

            if (nMax > 0 && vs.Count > nMax)
            {
                return(vs);
            }
            if (!EnumValidationLevel.RecursiveComplete.Equals(level) && !EnumValidationLevel.RecursiveIncomplete.Equals(level))
            {
                return(vs);
            }
            if (vs.Contains(AttributeName.DEVCAPREF))
            {
                return(vs);
            }

            if (hasAttribute(AttributeName.DEVCAPREF))
            {
                JDFDevCapPool devCapPool = getDevCapPool();
                if (devCapPool == null)
                {
                    vs.Add(AttributeName.DEVCAPREF);
                    return(vs);
                }
                VString idRefs = getDevCapRef();
                for (int i = 0; i < idRefs.Count; i++)
                {
                    JDFDevCap devCap = devCapPool.getDevCap(idRefs.stringAt(i));
                    if (devCap == null)
                    {
                        vs.Add(AttributeName.DEVCAPREF);
                        return(vs);
                    }
                }
            }
            return(vs);
        }
Exemplo n.º 6
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);
        }
Exemplo n.º 7
0
        ///
        ///	 <summary> * gets the XPath to the attributes of a given JDF node
        ///	 *  </summary>
        ///	 * <param name="jdf">
        ///	 *            JDF node to test </param>
        ///	 * <returns> String - the XPath to the attributes </returns>
        ///
        protected internal virtual string getEvalXPath(KElement jdf)
        {
            ICapabilityElement stateDC = getRefTarget();

            if (stateDC == null)
            {
                return(null);
            }

            VString vPath    = null;
            bool    bElement = false;
            string  attName  = null;

            if (stateDC is JDFDevCap)
            {
                if (!(this is JDFIsPresentEvaluation)) // only ispresent may
                // reference a
                // devcap, all
                // others must
                // reference a state
                {
                    return(null);
                }
                bElement = true;
                JDFDevCap dc = (JDFDevCap)stateDC;
                vPath = dc.getNamePathVector(true);
                // fix up for the fact that ispresent for a resource is actually a
                // link
                if (vPath != null)
                {
                    for (int i = 0; i < vPath.Count; i++)
                    {
                        string  path   = vPath.stringAt(i);
                        VString tokens = new VString(StringUtil.tokenize(path, "/", false));
                        if (tokens.Count == 3 && tokens.stringAt(1).Equals(ElementName.RESOURCEPOOL))
                        {
                            tokens[1] = ElementName.RESOURCELINKPOOL;
                            tokens[2] = tokens.stringAt(2) + "Link";
                            vPath[i]  = StringUtil.setvString(tokens, "/", null, null);
                        }
                    }
                }
            }
            else if (stateDC is JDFDevCaps)
            {
                if (!(this is JDFIsPresentEvaluation)) // only ispresent may
                // reference a
                // devcap, all
                // others must
                // reference a state
                {
                    return(null);
                }
                bElement = true;
                JDFDevCaps dc = (JDFDevCaps)stateDC;
                vPath = dc.getNamePathVector();
                // fix up for the fact that ispresent for a resource is actually a
                // link
                if (vPath != null)
                {
                    for (int i = 0; i < vPath.Count; i++)
                    {
                        string  path   = vPath.stringAt(i);
                        VString tokens = new VString(StringUtil.tokenize(path, "/", false));
                        if (tokens.Count == 3 && tokens.stringAt(1).Equals(ElementName.RESOURCEPOOL))
                        {
                            tokens[1] = ElementName.RESOURCELINKPOOL;
                            string    link = tokens.stringAt(2) + "Link";
                            EnumUsage lu   = dc.getLinkUsage();
                            if (lu != null)
                            {
                                link += "[@Usage=\"" + lu.getName() + "\"]";
                            }
                            tokens[2] = link;
                            vPath[i]  = StringUtil.setvString(tokens, "/", null, null);
                        }
                    }
                }
            }
            else
            {
                // we have found our state -> take its xPath and look for
                // corresponding elem in JDFNode, we test

                JDFAbstractState state = (JDFAbstractState)stateDC;
                if (state.getListType().Equals(EnumListType.Span))
                {
                    vPath    = state.getNamePathVector(true);
                    bElement = true;
                }
                else
                {
                    KElement kdc = state.getParentNode_KElement();
                    if (kdc is IDeviceCapable)
                    {
                        vPath = ((IDeviceCapable)kdc).getNamePathVector();
                    }
                    else if (kdc is ICapabilityElement)
                    {
                        vPath = ((ICapabilityElement)kdc).getNamePathVector();
                    }
                    attName = state.getName();
                }
            }
            if (vPath != null)
            {
                for (int i = 0; i < vPath.Count; i++)
                {
                    string xPath  = vPath.stringAt(i);
                    int    slash  = xPath.Length;
                    string finalS = null;
                    do
                    {
                        string xPath2 = xPath.Substring(0, slash);
                        if (jdf.matchesPath(xPath2, true))
                        {
                            finalS = "." + xPath.Substring(slash);
                        }
                        slash = xPath2.LastIndexOf("/");
                    } while (slash >= 0 && finalS == null);

                    if (finalS != null && !bElement)
                    {
                        finalS += "/@" + attName;
                    }
                    if (finalS != null)
                    {
                        return(finalS);
                    }
                }
            }
            return(null);
        }