コード例 #1
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);
                    }
                }
            }