Beispiel #1
0
        public virtual void testValidName()
        {
            JDFDoc              d    = new JDFDoc(ElementName.JDF);
            JDFNode             n    = d.getJDFRoot();
            JDFResourceLinkPool rlp  = n.appendResourceLinkPool();
            JDFResourceLink     rl   = (JDFResourceLink)rlp.appendElement("FooLink");
            JDFResource         rBar = n.addResource("Bar", EnumResourceClass.Parameter, EnumUsage.Input, null, null, null, null);

            rl.setrRef(rBar.getID());
            Assert.IsFalse((rl.isValid(null)));
            rl = n.getLink(rBar, null);
            Assert.IsNotNull(rl);
            Assert.IsTrue((rl.isValid(null)));
        }
Beispiel #2
0
        ///
        ///	 <summary> * if a Resource is available, return it's ID
        ///	 *  </summary>
        ///	 * <seealso cref= org.cip4.jdflib.auto.JDFAutoResourceInfo#getResourceID() </seealso>
        ///
        public override string getResourceID()
        {
            string _name = base.getResourceID();

            if (isWildCard(_name))
            {
                JDFResource r = getResource(null);
                if (r == null)
                {
                    return(null);
                }
                _name = r.getID();
            }
            return(_name);
        }
Beispiel #3
0
            public override bool walk(KElement e)
            {
                JDFResource r  = (JDFResource)e;
                string      id = r.getID();

                if (EnclosingInstance.ld.doneSet.Contains(id))
                {
                    return(true);
                }
                if (EnclosingInstance.ld.refSet.Contains(id))
                {
                    EnclosingInstance.ld.doneSet.Add(id);
                    EnclosingInstance.ld.refSet.Remove(id);
                    return(true);
                }
                EnclosingInstance.ld.resMap.Add(id, r);
                return(true);
            }
Beispiel #4
0
        ///
        ///	 <summary> * sets all relevant parameters of <code>this</code> to the values specified in resourceLink or its linked resource
        ///	 * or JDF node
        ///	 *  </summary>
        ///	 * <param name="resourceLink"> the resourceLink to extract the information from </param>
        ///
        public virtual void setLink(JDFResourceLink resourceLink)
        {
            if (resourceLink == null)
            {
                return;
            }
            JDFResource r = resourceLink.getTarget();

            JDFNode parentJDF = resourceLink.getParentJDF();

            setJDF(parentJDF);
            setProcessUsage(resourceLink.getEnumProcessUsage());

            if (r.hasAttribute(AttributeName.PRODUCTID))
            {
                setProductID(r.getProductID());
            }
            setResourceID(r.getID());
            setResourceName(r.LocalName);
            setUsage(resourceLink.getUsage());
            setPartMapVector(resourceLink.getPartMapVector());
        }
Beispiel #5
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);
                    }
                }
            }
Beispiel #6
0
        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);
        }