Exemplo n.º 1
0
            ///
            ///		 <summary> * get double attribute Amount, defaults to the value of Amount for the linked partition
            ///		 *  </summary>
            ///		 * <param name="mPart"> partition map to retrieve Amount for </param>
            ///		 * <returns> the amount, -1 if none is specified
            ///		 *
            ///		 * @default getAmount(null) </returns>
            ///
            public static double getAmount(IAmountPoolContainer poolParent, JDFAttributeMap mPart)
            {
                double d = getAmountPoolDouble(poolParent, AttributeName.AMOUNT, mPart);

                if (d == -1)
                {
                    JDFResource target = poolParent.getLinkRoot();
                    if (target != null)
                    {
                        target = target.getPartition(mPart, null);
                        if (target != null)
                        {
                            return(target.getAmount());
                        }
                    }
                }
                else
                {
                    return(d);
                }

                return(-1.0);
            }
Exemplo n.º 2
0
            ///

            ///
            ///		 <summary> * gets the sum of all matching tags, with the assumpzion that no condition defaults to good
            ///		 *  </summary>
            ///		 * <param name="poolParent">  </param>
            ///		 * <param name="attName">  </param>
            ///		 * <param name="vPart">  </param>
            ///		 * <returns> the sum
            ///		 *  </returns>
            ///
            public static double getAmountPoolSumDouble(IAmountPoolContainer poolParent, string attName, VJDFAttributeMap vPart)
            {
                VJDFAttributeMap vPartLocal = vPart;

                if (vPartLocal == null)
                {
                    vPartLocal = poolParent.getPartMapVector();
                }

                if (poolParent.hasAttribute(attName))
                {
                    return(poolParent.getRealAttribute(attName, null, 0));
                }

                VJDFAttributeMap vm       = vPartLocal == null ? null : new VJDFAttributeMap(vPartLocal);
                JDFResource      linkRoot = poolParent.getLinkRoot();

                if (linkRoot != null && vm != null)
                {
                    SupportClass.SetSupport <string> @set = linkRoot.getPartIDKeys().getSet();
                    @set.Add(AttributeName.CONDITION); // retain good / waste
                    vm.reduceMap(@set);
                }

                if (vm == null)
                {
                    vm = new VJDFAttributeMap();
                    vm.Add((JDFAttributeMap)null);
                }

                double        dd = 0;
                JDFAmountPool ap = poolParent.getAmountPool();

                if (ap == null)
                {
                    return(poolParent.getRealAttribute(attName, null, 0.0));
                }

                VElement vParts = ap.getChildElementVector(ElementName.PARTAMOUNT, null);

                if (vParts.IsEmpty())
                {
                    return(poolParent.getRealAttribute(attName, null, 0.0));
                }

                bool isWaste = vPartLocal != null && vPartLocal.subMap(new JDFAttributeMap(AttributeName.CONDITION, "Waste"));

                if (!isWaste && (vPartLocal == null || !vPartLocal.subMap(new JDFAttributeMap(AttributeName.CONDITION, "*"))))
                {
                    vPartLocal = new VJDFAttributeMap(vPartLocal);
                    vPartLocal.Add(new JDFAttributeMap(AttributeName.CONDITION, "Good"));
                }

                for (int j = 0; j < vParts.Count; j++)
                {
                    JDFPartAmount    pa            = (JDFPartAmount)vParts[j];
                    VJDFAttributeMap partMapVector = pa.getPartMapVector();
                    if (isWaste)
                    {
                        bool hasCondition = partMapVector.subMap(new JDFAttributeMap(AttributeName.CONDITION, "*"));
                        if (!hasCondition)
                        {
                            continue;
                        }
                    }

                    if (!partMapVector.overlapsMap(vm))
                    {
                        continue;
                    }

                    string ret = null;
                    ret = pa.getAttribute(attName, null, null);
                    if (ret == null)
                    {
                        ret = poolParent.getAttribute(attName, null, null);
                    }

                    dd += StringUtil.parseDouble(ret, 0.0);
                }

                return(dd);
            }