public virtual object clone()
        {
            //if ( o_map == null ) o_map = new HashMap();

            BoqItemConditionTable obj = new BoqItemConditionTable();

            obj.ParamItemId        = ParamItemId;
            obj.BoqItemConditionId = BoqItemConditionId;
            obj.SelectedUnit       = SelectedUnit;
            obj.FinalQuantity      = FinalQuantity;
            obj.Factor1            = Factor1;
            obj.Factor2            = Factor2;
            obj.Sumup             = Sumup;
            obj.LastUpdate        = LastUpdate;
            obj.OverridenQuantity = OverridenQuantity;
            obj.OverridenUnit     = OverridenUnit;
            obj.ProjectId         = ProjectId;

            if (BoqItemTable != null)
            {
                obj.BoqItemTable = (BoqItemTable)BoqItemTable.clone();
            }

            if (ConditionTable != null)
            {
                obj.ConditionTable = (ConditionTable)ConditionTable.clone();
            }

            return(obj);
        }
        /*public Object valueForField(String field) {
         *      if ( field.equals("finalQuantity") ) {
         *              return DBFieldFormatUtil.formatObject(getFinalQuantity());
         *      }
         *      return DBFieldFormatUtil.formatObject(o_map.get(field));
         * }
         *
         * public Object scaledValueForField(String field) {
         *      if ( field.equals("finalQuantity") ) {
         *              return DBFieldFormatUtil.scaleAndFormatObject(getFinalQuantity());
         *      }
         *
         *      return DBFieldFormatUtil.scaleAndFormatObject(o_map.get(field));
         * }*/

        public virtual object clone(bool relations)
        {
            if (relations)
            {
                return(clone());
            }
            //if ( o_map == null ) o_map = new HashMap();

            BoqItemConditionTable obj = new BoqItemConditionTable();

            obj.ParamItemId        = ParamItemId;
            obj.BoqItemConditionId = BoqItemConditionId;
            obj.SelectedUnit       = SelectedUnit;
            obj.FinalQuantity      = FinalQuantity;
            obj.Factor1            = Factor1;
            obj.Factor2            = Factor2;
            obj.Sumup             = Sumup;
            obj.OverridenQuantity = OverridenQuantity;
            obj.OverridenUnit     = OverridenUnit;
            obj.LastUpdate        = LastUpdate;
            obj.ProjectId         = ProjectId;

            return(obj);
        }
Пример #3
0
        public virtual BoqItemTable convertToBoqItem(DateTime projectStartDate, long?code, ProjectDBUtil currentDBUtil, bool online, bool useProductivity, bool replaceQuantity)
        {
            BoqItemTable boqTable = BlankResourceInitializer.createBlankBoqItem(this, code, projectStartDate, useProductivity);

            Timestamp updateTime = new Timestamp(DateTimeHelper.CurrentUnixTimeMillis());

            boqTable.Title = Title;
            boqTable.Code  = code;
            //if ( useProductivity ) {
            //	boqTable.setCalculationType(BoqItemTable.s_PRODUCTIVITY_METHOD);
            //}
            //else {
            //	boqTable.setCalculationType(BoqItemTable.s_TOTAL_UNITS_METHOD);
            //}
            //boqTable.setProductivity(BigDecimalMath.ONE);
            //boqTable.setQuantity(BigDecimalMath.ONE);
            //boqTable.setDuration(BigDecimalMath.ONE);
            boqTable.LastUpdate = updateTime;
            boqTable.CreateDate = updateTime;

            boqTable.BoqItemAssemblySet      = new HashSet <object>();
            boqTable.BoqItemEquipmentSet     = new HashSet <object>();
            boqTable.BoqItemSubcontractorSet = new HashSet <object>();
            boqTable.BoqItemLaborSet         = new HashSet <object>();
            boqTable.BoqItemMaterialSet      = new HashSet <object>();
            boqTable.BoqItemConsumableSet    = new HashSet <object>();
            boqTable.BoqItemConditionSet     = new HashSet <object>();

            ConditionTable        conditionTable    = (ConditionTable)clone();
            BoqItemConditionTable boqConditionTable = new BoqItemConditionTable();

            boqConditionTable.Factor1         = BigDecimalMath.ONE;
            boqConditionTable.Factor2         = BigDecimalMath.ONE;
            boqConditionTable.Sumup           = BigDecimalMath.ZERO;
            boqConditionTable.QuantityPerUnit = BigDecimalMath.ONE;

            if (replaceQuantity)
            {
                if (conditionTable.DefaultQuantity == null || conditionTable.DefaultQuantity == 0 || conditionTable.DefaultQuantity == 1)
                {
                    boqTable.Quantity = conditionTable.Quantity1;
                }
                else if (conditionTable.DefaultQuantity == 2)
                {
                    boqTable.Quantity = conditionTable.Quantity2;
                }
                else if (conditionTable.DefaultQuantity == 3)
                {
                    boqTable.Quantity = conditionTable.Quantity3;
                }
            }
            if (conditionTable.DefaultQuantity == null || conditionTable.DefaultQuantity == 0 || conditionTable.DefaultQuantity == 1)
            {
                boqConditionTable.SelectedUnit = BoqItemConditionTable.SELECTED_UNIT1;
                boqTable.Quantity         = conditionTable.Quantity1;
                boqTable.MeasuredQuantity = conditionTable.Quantity1;
                //boqTable.setEstimatedQuantity(conditionTable.getQuantity1());
                boqTable.Unit       = conditionTable.Unit1;
                boqTable.SecondUnit = Unit1ToUnit2Util.Instance.getUnit2(conditionTable.Unit1);
                boqTable.UnitsDiv   = Unit1ToUnit2Util.Instance.getUnitDiv(conditionTable.Unit1);
            }
            else if (conditionTable.DefaultQuantity == 2)
            {
                boqConditionTable.SelectedUnit = BoqItemConditionTable.SELECTED_UNIT2;
                boqTable.Quantity         = conditionTable.Quantity2;
                boqTable.MeasuredQuantity = conditionTable.Quantity2;
                //boqTable.setEstimatedQuantity(conditionTable.getQuantity2());
                boqTable.Unit       = conditionTable.Unit2;
                boqTable.SecondUnit = Unit1ToUnit2Util.Instance.getUnit2(conditionTable.Unit2);
                boqTable.UnitsDiv   = Unit1ToUnit2Util.Instance.getUnitDiv(conditionTable.Unit2);
            }
            else if (conditionTable.DefaultQuantity == 3)
            {
                boqConditionTable.SelectedUnit = BoqItemConditionTable.SELECTED_UNIT3;
                boqTable.Quantity = conditionTable.Quantity3;
                //boqTable.setEstimatedQuantity(conditionTable.getQuantity3());
                boqTable.MeasuredQuantity = conditionTable.Quantity3;
                boqTable.Unit             = conditionTable.Unit3;
                boqTable.SecondUnit       = Unit1ToUnit2Util.Instance.getUnit2(conditionTable.Unit3);
                boqTable.UnitsDiv         = Unit1ToUnit2Util.Instance.getUnitDiv(conditionTable.Unit3);
            }

            boqConditionTable.LastUpdate = updateTime;

            boqConditionTable.ConditionTable = conditionTable;
            boqConditionTable.BoqItemTable   = boqTable;

            boqTable.BoqItemConditionSet.Add(boqConditionTable);

            boqTable.recalculate();

            return(boqTable);
        }