package oracle.fodemo.storefront.entities;

import java.sql.SQLException;

import oracle.jbo.AttributeList;
import oracle.jbo.Key;
import oracle.jbo.Row;
import oracle.jbo.RowIterator;
import oracle.jbo.RowSet;
import oracle.jbo.domain.DBSequence;
import oracle.jbo.domain.Date;
import oracle.jbo.domain.Number;
import oracle.jbo.server.AttributeDefImpl;
import oracle.jbo.server.EntityDefImpl;
import oracle.jbo.server.EntityImpl;
import oracle.jbo.server.TransactionEvent;
// ---------------------------------------------------------------------
// ---    File generated by Oracle ADF Business Components Design Time.
// ---    Custom code may be added to this class.
// ---    Warning: Do not modify method signatures of generated methods.
// ---------------------------------------------------------------------
public class OrderEOImpl extends EntityImpl {
    private static EntityDefImpl mDefinitionObject;

    /**
     * AttributesEnum: generated enum for identifying attributes and accessors. Do not modify.
     */
    public enum AttributesEnum {
        OrderId {
            public Object get(OrderEOImpl obj) {
                return obj.getOrderId();
            }

            public void put(OrderEOImpl obj, Object value) {
                obj.setOrderId((DBSequence)value);
            }
        }
        ,
        OrderDate {
            public Object get(OrderEOImpl obj) {
                return obj.getOrderDate();
            }

            public void put(OrderEOImpl obj, Object value) {
                obj.setOrderDate((Date)value);
            }
        }
        ,
        OrderShippedDate {
            public Object get(OrderEOImpl obj) {
                return obj.getOrderShippedDate();
            }

            public void put(OrderEOImpl obj, Object value) {
                obj.setOrderShippedDate((Date)value);
            }
        }
        ,
        OrderStatusCode {
            public Object get(OrderEOImpl obj) {
                return obj.getOrderStatusCode();
            }

            public void put(OrderEOImpl obj, Object value) {
                obj.setOrderStatusCode((String)value);
            }
        }
        ,
        OrderTotal {
            public Object get(OrderEOImpl obj) {
                return obj.getOrderTotal();
            }

            public void put(OrderEOImpl obj, Object value) {
                obj.setOrderTotal((Number)value);
            }
        }
        ,
        CustomerId {
            public Object get(OrderEOImpl obj) {
                return obj.getCustomerId();
            }

            public void put(OrderEOImpl obj, Object value) {
                obj.setCustomerId((Number)value);
            }
        }
        ,
        ShipToName {
            public Object get(OrderEOImpl obj) {
                return obj.getShipToName();
            }

            public void put(OrderEOImpl obj, Object value) {
                obj.setShipToName((String)value);
            }
        }
        ,
        ShipToAddressId {
            public Object get(OrderEOImpl obj) {
                return obj.getShipToAddressId();
            }

            public void put(OrderEOImpl obj, Object value) {
                obj.setShipToAddressId((Number)value);
            }
        }
        ,
        ShipToPhoneNumber {
            public Object get(OrderEOImpl obj) {
                return obj.getShipToPhoneNumber();
            }

            public void put(OrderEOImpl obj, Object value) {
                obj.setShipToPhoneNumber((String)value);
            }
        }
        ,
        ShippingOptionId {
            public Object get(OrderEOImpl obj) {
                return obj.getShippingOptionId();
            }

            public void put(OrderEOImpl obj, Object value) {
                obj.setShippingOptionId((Number)value);
            }
        }
        ,
        PaymentOptionId {
            public Object get(OrderEOImpl obj) {
                return obj.getPaymentOptionId();
            }

            public void put(OrderEOImpl obj, Object value) {
                obj.setPaymentOptionId((Number)value);
            }
        }
        ,
        DiscountId {
            public Object get(OrderEOImpl obj) {
                return obj.getDiscountId();
            }

            public void put(OrderEOImpl obj, Object value) {
                obj.setDiscountId((Number)value);
            }
        }
        ,
        CouponId {
            public Object get(OrderEOImpl obj) {
                return obj.getCouponId();
            }

            public void put(OrderEOImpl obj, Object value) {
                obj.setCouponId((Number)value);
            }
        }
        ,
        FreeShippingFlag {
            public Object get(OrderEOImpl obj) {
                return obj.getFreeShippingFlag();
            }

            public void put(OrderEOImpl obj, Object value) {
                obj.setFreeShippingFlag((String)value);
            }
        }
        ,
        CustomerCollectFlag {
            public Object get(OrderEOImpl obj) {
                return obj.getCustomerCollectFlag();
            }

            public void put(OrderEOImpl obj, Object value) {
                obj.setCustomerCollectFlag((String)value);
            }
        }
        ,
        CollectionWarehouseId {
            public Object get(OrderEOImpl obj) {
                return obj.getCollectionWarehouseId();
            }

            public void put(OrderEOImpl obj, Object value) {
                obj.setCollectionWarehouseId((Number)value);
            }
        }
        ,
        GiftwrapFlag {
            public Object get(OrderEOImpl obj) {
                return obj.getGiftwrapFlag();
            }

            public void put(OrderEOImpl obj, Object value) {
                obj.setGiftwrapFlag((String)value);
            }
        }
        ,
        GiftwrapMessage {
            public Object get(OrderEOImpl obj) {
                return obj.getGiftwrapMessage();
            }

            public void put(OrderEOImpl obj, Object value) {
                obj.setGiftwrapMessage((String)value);
            }
        }
        ,
        CreatedBy {
            public Object get(OrderEOImpl obj) {
                return obj.getCreatedBy();
            }

            public void put(OrderEOImpl obj, Object value) {
                obj.setCreatedBy((String)value);
            }
        }
        ,
        CreationDate {
            public Object get(OrderEOImpl obj) {
                return obj.getCreationDate();
            }

            public void put(OrderEOImpl obj, Object value) {
                obj.setAttributeInternal(index(), value);
            }
        }
        ,
        LastUpdatedBy {
            public Object get(OrderEOImpl obj) {
                return obj.getLastUpdatedBy();
            }

            public void put(OrderEOImpl obj, Object value) {
                obj.setLastUpdatedBy((String)value);
            }
        }
        ,
        LastUpdateDate {
            public Object get(OrderEOImpl obj) {
                return obj.getLastUpdateDate();
            }

            public void put(OrderEOImpl obj, Object value) {
                obj.setAttributeInternal(index(), value);
            }
        }
        ,
        ObjectVersionId {
            public Object get(OrderEOImpl obj) {
                return obj.getObjectVersionId();
            }

            public void put(OrderEOImpl obj, Object value) {
                obj.setAttributeInternal(index(), value);
            }
        }
        ,
        CalculatedOrderTotal {
            public Object get(OrderEOImpl obj) {
                return obj.getCalculatedOrderTotal();
            }

            public void put(OrderEOImpl obj, Object value) {
                obj.setCalculatedOrderTotal((Double)value);
            }
        }
        ,
        DiscountAmount {
            public Object get(OrderEOImpl obj) {
                return obj.getDiscountAmount();
            }

            public void put(OrderEOImpl obj, Object value) {
                obj.setDiscountAmount((Double)value);
            }
        }
        ,
        TypedCouponCode {
            public Object get(OrderEOImpl obj) {
                return obj.getTypedCouponCode();
            }

            public void put(OrderEOImpl obj, Object value) {
                obj.setTypedCouponCode((String)value);
            }
        }
        ,
        isPublishableEvent {
            public Object get(OrderEOImpl obj) {
                return obj.getisPublishableEvent();
            }

            public void put(OrderEOImpl obj, Object value) {
                obj.setisPublishableEvent((Boolean)value);
            }
        }
        ,
        isEventLaunched {
            public Object get(OrderEOImpl obj) {
                return obj.getisEventLaunched();
            }

            public void put(OrderEOImpl obj, Object value) {
                obj.setisEventLaunched((String)value);
            }
        }
        ,
        Address {
            public Object get(OrderEOImpl obj) {
                return obj.getAddress();
            }

            public void put(OrderEOImpl obj, Object value) {
                obj.setAddress((AddressEOImpl)value);
            }
        }
        ,
        DiscountBase {
            public Object get(OrderEOImpl obj) {
                return obj.getDiscountBase();
            }

            public void put(OrderEOImpl obj, Object value) {
                obj.setDiscountBase((EntityImpl)value);
            }
        }
        ,
        DiscountBase1 {
            public Object get(OrderEOImpl obj) {
                return obj.getDiscountBase1();
            }

            public void put(OrderEOImpl obj, Object value) {
                obj.setDiscountBase1((EntityImpl)value);
            }
        }
        ,
        CouponUsage {
            public Object get(OrderEOImpl obj) {
                return obj.getCouponUsage();
            }

            public void put(OrderEOImpl obj, Object value) {
                obj.setAttributeInternal(index(), value);
            }
        }
        ,
        OrderItem {
            public Object get(OrderEOImpl obj) {
                return obj.getOrderItem();
            }

            public void put(OrderEOImpl obj, Object value) {
                obj.setAttributeInternal(index(), value);
            }
        }
        ,
        PaymentOption {
            public Object get(OrderEOImpl obj) {
                return obj.getPaymentOption();
            }

            public void put(OrderEOImpl obj, Object value) {
                obj.setPaymentOption((PaymentOptionEOImpl)value);
            }
        }
        ,
        Person {
            public Object get(OrderEOImpl obj) {
                return obj.getPerson();
            }

            public void put(OrderEOImpl obj, Object value) {
                obj.setPerson((PersonEOImpl)value);
            }
        }
        ,
        ShippingOptionBase {
            public Object get(OrderEOImpl obj) {
                return obj.getShippingOptionBase();
            }

            public void put(OrderEOImpl obj, Object value) {
                obj.setShippingOptionBase((EntityImpl)value);
            }
        }
        ,
        Warehouse {
            public Object get(OrderEOImpl obj) {
                return obj.getWarehouse();
            }

            public void put(OrderEOImpl obj, Object value) {
                obj.setWarehouse((WarehouseEOImpl)value);
            }
        }
        ,
        OrdersVO {
            public Object get(OrderEOImpl obj) {
                return obj.getOrdersVO();
            }

            public void put(OrderEOImpl obj, Object value) {
                obj.setAttributeInternal(index(), value);
            }
        }
        ;
        private static AttributesEnum[] vals = null;
        private static int firstIndex = 0;

        /**
         * @param object
         * @return
         */
        public abstract Object get(OrderEOImpl object);

        /**
         * @param object
         * @param value
         */
        public abstract void put(OrderEOImpl object, Object value);

        /**
         * @return
         */
        public int index() {
            return AttributesEnum.firstIndex() + ordinal();
        }

        /**
         * @return
         */
        public static int firstIndex() {
            return firstIndex;
        }

        /**
         * @return
         */
        public static int count() {
            return AttributesEnum.firstIndex() + AttributesEnum.staticValues().length;
        }

        /**
         * @return
         */
        public static AttributesEnum[] staticValues() {
            if (vals == null) {
                vals = AttributesEnum.values();
            }
            return vals;
        }
    }
    public static int ORDERID = AttributesEnum.OrderId.index();
    public static int ORDERDATE = AttributesEnum.OrderDate.index();
    public static int ORDERSHIPPEDDATE = AttributesEnum.OrderShippedDate.index();
    public static int ORDERSTATUSCODE = AttributesEnum.OrderStatusCode.index();
    public static int ORDERTOTAL = AttributesEnum.OrderTotal.index();
    public static int CUSTOMERID = AttributesEnum.CustomerId.index();
    public static int SHIPTONAME = AttributesEnum.ShipToName.index();
    public static int SHIPTOADDRESSID = AttributesEnum.ShipToAddressId.index();
    public static int SHIPTOPHONENUMBER = AttributesEnum.ShipToPhoneNumber.index();
    public static int SHIPPINGOPTIONID = AttributesEnum.ShippingOptionId.index();
    public static int PAYMENTOPTIONID = AttributesEnum.PaymentOptionId.index();
    public static int DISCOUNTID = AttributesEnum.DiscountId.index();
    public static int COUPONID = AttributesEnum.CouponId.index();
    public static int FREESHIPPINGFLAG = AttributesEnum.FreeShippingFlag.index();
    public static int CUSTOMERCOLLECTFLAG = AttributesEnum.CustomerCollectFlag.index();
    public static int COLLECTIONWAREHOUSEID = AttributesEnum.CollectionWarehouseId.index();
    public static int GIFTWRAPFLAG = AttributesEnum.GiftwrapFlag.index();
    public static int GIFTWRAPMESSAGE = AttributesEnum.GiftwrapMessage.index();
    public static int CREATEDBY = AttributesEnum.CreatedBy.index();
    public static int CREATIONDATE = AttributesEnum.CreationDate.index();
    public static int LASTUPDATEDBY = AttributesEnum.LastUpdatedBy.index();
    public static int LASTUPDATEDATE = AttributesEnum.LastUpdateDate.index();
    public static int OBJECTVERSIONID = AttributesEnum.ObjectVersionId.index();
    public static int CALCULATEDORDERTOTAL = AttributesEnum.CalculatedOrderTotal.index();
    public static int DISCOUNTAMOUNT = AttributesEnum.DiscountAmount.index();
    public static int TYPEDCOUPONCODE = AttributesEnum.TypedCouponCode.index();
    public static int ADDRESS = AttributesEnum.Address.index();
    public static int DISCOUNTBASE = AttributesEnum.DiscountBase.index();
    public static int DISCOUNTBASE1 = AttributesEnum.DiscountBase1.index();
    public static int COUPONUSAGE = AttributesEnum.CouponUsage.index();
    public static int ORDERITEM = AttributesEnum.OrderItem.index();
    public static int PAYMENTOPTION = AttributesEnum.PaymentOption.index();
    public static int PERSON = AttributesEnum.Person.index();
    public static int SHIPPINGOPTIONBASE = AttributesEnum.ShippingOptionBase.index();
    public static int WAREHOUSE = AttributesEnum.Warehouse.index();


    public static final int ISPUBLISHABLEEVENT = AttributesEnum.isPublishableEvent.index();


    public static final int ISEVENTLAUNCHED = AttributesEnum.isEventLaunched.index();
    public static final int ORDERSVO = AttributesEnum.OrdersVO.index();

    /**This is the default constructor (do not remove).
     */
    public OrderEOImpl() {
        
    }


    /**
     * @return the definition object for this instance class.
     */
    public static synchronized EntityDefImpl getDefinitionObject() {
        if (mDefinitionObject == null) {
            mDefinitionObject = EntityDefImpl.findDefObject("oracle.fodemo.storefront.entities.OrderEO");
        }
        return mDefinitionObject;
    }

    /**Begin Custom Code *.
     * @param nameValuePair
     */
    protected void create(AttributeList nameValuePair) {
       super.create(nameValuePair);
       this.setOrderDate(new Date());
    }

    /**
     * @param dml
     * @param evt
     */
    protected void prepareForDML(int dml, TransactionEvent evt) {
            if (dml == DML_INSERT || dml == DML_UPDATE) {
                super.prepareForDML(dml,evt);
                init();
           }
    }

    public void init(){
        EntityImpl discountBase = this.getDiscountBase();
        if(discountBase != null){
            String flag = (String)discountBase.getAttribute("AddFreeShippingFlag");
            EntityImpl discountBase1 = this.getDiscountBase1();
            String flag1 = "N";
            if(discountBase1 != null){
                flag1 = (String)discountBase1.getAttribute("AddFreeShippingFlag");
                if(flag1 != null && (flag.equalsIgnoreCase("Y") || flag1.equalsIgnoreCase("Y"))){
                    this.setFreeShippingFlag("Y");
                } else {
                    this.setFreeShippingFlag("N");
                }
            }
            
            String message = this.getGiftwrapMessage();
            if(message != null && !message.equalsIgnoreCase("")){
                this.setGiftwrapFlag("Y");    
            }       
        }
    }

    /**
     * @return
     * @throws SQLException
     */
    public Number calculateDiscountAmount()throws SQLException{
        EntityImpl discount = this.getDiscountBase();    
        EntityImpl coupon = this.getDiscountBase1();
        Number discountAmount = processDiscount(discount);   
        Number couponAmount = processDiscount(coupon);
        return new Number(couponAmount.doubleValue() + discountAmount.doubleValue());
    }

    private  Number processDiscount(EntityImpl discount) throws SQLException {
        if(discount != null) {
            Number amount = (Number)discount.getAttribute("DiscountAmount");
            String isPercentage = (String)discount.getAttribute("ApplyAsPercentageFlag");
            if(isPercentage.equalsIgnoreCase("Y")){
                Double total = this.getCalculatedOrderTotal();
                amount = new Number(total*(amount.doubleValue()/100)); 
            }        
            return amount;
        } else {
            return new Number();
        }
    }

    /** End Custom Code **/

    /**Gets the attribute value for OrderId, using the alias name OrderId.
     * @return
     */
    public DBSequence getOrderId() {
        return (DBSequence)getAttributeInternal(ORDERID);
    }

    /**Sets <code>value</code> as the attribute value for OrderId.
     * @param value
     */
    public void setOrderId(DBSequence value) {
        setAttributeInternal(ORDERID, value);
    }

    /**Gets the attribute value for OrderDate, using the alias name OrderDate.
     * @return
     */
    public Date getOrderDate() {
        return (Date)getAttributeInternal(ORDERDATE);
    }

    /**Sets <code>value</code> as the attribute value for OrderDate.
     * @param value
     */
    public void setOrderDate(Date value) {
        setAttributeInternal(ORDERDATE, value);
    }

    /**Gets the attribute value for OrderShippedDate, using the alias name OrderShippedDate.
     * @return
     */
    public Date getOrderShippedDate() {
        return (Date)getAttributeInternal(ORDERSHIPPEDDATE);
    }

    /**Sets <code>value</code> as the attribute value for OrderShippedDate.
     * @param value
     */
    public void setOrderShippedDate(Date value) {
        setAttributeInternal(ORDERSHIPPEDDATE, value);
    }

    /**Gets the attribute value for OrderStatusCode, using the alias name OrderStatusCode.
     * @return
     */
    public String getOrderStatusCode() {
        return (String)getAttributeInternal(ORDERSTATUSCODE);
    }

    /**Sets <code>value</code> as the attribute value for OrderStatusCode.
     * @param value
     */
    public void setOrderStatusCode(String value) {
        setAttributeInternal(ORDERSTATUSCODE, value);
    }

    /**Gets the attribute value for OrderTotal, using the alias name OrderTotal.
     * @return
     */
    public Number getOrderTotal() {
        return (Number)getAttributeInternal(ORDERTOTAL);
    }

    /**Sets <code>value</code> as the attribute value for OrderTotal.
     * @param value
     */
    public void setOrderTotal(Number value) {
        setAttributeInternal(ORDERTOTAL, value);
    }

    /**Gets the attribute value for CustomerId, using the alias name CustomerId.
     * @return
     */
    public Number getCustomerId() {
        return (Number)getAttributeInternal(CUSTOMERID);
    }

    /**Sets <code>value</code> as the attribute value for CustomerId.
     * @param value
     */
    public void setCustomerId(Number value) {
        setAttributeInternal(CUSTOMERID, value);
    }

    /**Gets the attribute value for ShipToName, using the alias name ShipToName.
     * @return
     */
    public String getShipToName() {
        return (String)getAttributeInternal(SHIPTONAME);
    }

    /**Sets <code>value</code> as the attribute value for ShipToName.
     * @param value
     */
    public void setShipToName(String value) {
        setAttributeInternal(SHIPTONAME, value);
    }

    /**Gets the attribute value for ShipToAddressId, using the alias name ShipToAddressId.
     * @return
     */
    public Number getShipToAddressId() {
        return (Number)getAttributeInternal(SHIPTOADDRESSID);
    }

    /**Sets <code>value</code> as the attribute value for ShipToAddressId.
     * @param value
     */
    public void setShipToAddressId(Number value) {
        setAttributeInternal(SHIPTOADDRESSID, value);
    }

    /**Gets the attribute value for ShipToPhoneNumber, using the alias name ShipToPhoneNumber.
     * @return
     */
    public String getShipToPhoneNumber() {
        return (String)getAttributeInternal(SHIPTOPHONENUMBER);
    }

    /**Sets <code>value</code> as the attribute value for ShipToPhoneNumber.
     * @param value
     */
    public void setShipToPhoneNumber(String value) {
        setAttributeInternal(SHIPTOPHONENUMBER, value);
    }

    /**Gets the attribute value for ShippingOptionId, using the alias name ShippingOptionId.
     * @return
     */
    public Number getShippingOptionId() {
        return (Number)getAttributeInternal(SHIPPINGOPTIONID);
    }

    /**Sets <code>value</code> as the attribute value for ShippingOptionId.
     * @param value
     */
    public void setShippingOptionId(Number value) {
        setAttributeInternal(SHIPPINGOPTIONID, value);
    }

    /**Gets the attribute value for PaymentOptionId, using the alias name PaymentOptionId.
     * @return
     */
    public Number getPaymentOptionId() {
        return (Number)getAttributeInternal(PAYMENTOPTIONID);
    }

    /**Sets <code>value</code> as the attribute value for PaymentOptionId.
     * @param value
     */
    public void setPaymentOptionId(Number value) {
        setAttributeInternal(PAYMENTOPTIONID, value);
    }

    /**Gets the attribute value for DiscountId, using the alias name DiscountId.
     * @return
     */
    public Number getDiscountId() {
        return (Number)getAttributeInternal(DISCOUNTID);
    }

    /**Sets <code>value</code> as the attribute value for DiscountId.
     * @param value
     */
    public void setDiscountId(Number value) {
        setAttributeInternal(DISCOUNTID, value);
    }

    /**Gets the attribute value for CouponId, using the alias name CouponId.
     * @return
     */
    public Number getCouponId() {
        return (Number)getAttributeInternal(COUPONID);
    }

    /**Sets <code>value</code> as the attribute value for CouponId.
     * @param value
     */
    public void setCouponId(Number value) {
        setAttributeInternal(COUPONID, value);
    }

    /**Gets the attribute value for FreeShippingFlag, using the alias name FreeShippingFlag.
     * @return
     */
    public String getFreeShippingFlag() {
        return (String)getAttributeInternal(FREESHIPPINGFLAG);
    }

    /**Sets <code>value</code> as the attribute value for FreeShippingFlag.
     * @param value
     */
    public void setFreeShippingFlag(String value) {
        setAttributeInternal(FREESHIPPINGFLAG, value);
    }

    /**Gets the attribute value for CustomerCollectFlag, using the alias name CustomerCollectFlag.
     * @return
     */
    public String getCustomerCollectFlag() {
        return (String)getAttributeInternal(CUSTOMERCOLLECTFLAG);
    }

    /**Sets <code>value</code> as the attribute value for CustomerCollectFlag.
     * @param value
     */
    public void setCustomerCollectFlag(String value) {
        setAttributeInternal(CUSTOMERCOLLECTFLAG, value);
    }

    /**Gets the attribute value for CollectionWarehouseId, using the alias name CollectionWarehouseId.
     * @return
     */
    public Number getCollectionWarehouseId() {
        return (Number)getAttributeInternal(COLLECTIONWAREHOUSEID);
    }

    /**Sets <code>value</code> as the attribute value for CollectionWarehouseId.
     * @param value
     */
    public void setCollectionWarehouseId(Number value) {
        setAttributeInternal(COLLECTIONWAREHOUSEID, value);
    }

    /**Gets the attribute value for GiftwrapFlag, using the alias name GiftwrapFlag.
     * @return
     */
    public String getGiftwrapFlag() {
        return (String)getAttributeInternal(GIFTWRAPFLAG);
    }

    /**Sets <code>value</code> as the attribute value for GiftwrapFlag.
     * @param value
     */
    public void setGiftwrapFlag(String value) {
        setAttributeInternal(GIFTWRAPFLAG, value);
    }

    /**Gets the attribute value for GiftwrapMessage, using the alias name GiftwrapMessage.
     * @return
     */
    public String getGiftwrapMessage() {
        return (String)getAttributeInternal(GIFTWRAPMESSAGE);
    }

    /**Sets <code>value</code> as the attribute value for GiftwrapMessage.
     * @param value
     */
    public void setGiftwrapMessage(String value) {
        setAttributeInternal(GIFTWRAPMESSAGE, value);
    }

    /**Gets the attribute value for CreatedBy, using the alias name CreatedBy.
     * @return
     */
    public String getCreatedBy() {
        return (String)getAttributeInternal(CREATEDBY);
    }

    /**Sets <code>value</code> as the attribute value for CreatedBy.
     * @param value
     */
    public void setCreatedBy(String value) {
        setAttributeInternal(CREATEDBY, value);
    }

    /**Gets the attribute value for CreationDate, using the alias name CreationDate.
     * @return
     */
    public Date getCreationDate() {
        return (Date)getAttributeInternal(CREATIONDATE);
    }

    /**Gets the attribute value for LastUpdatedBy, using the alias name LastUpdatedBy.
     * @return
     */
    public String getLastUpdatedBy() {
        return (String)getAttributeInternal(LASTUPDATEDBY);
    }

    /**Sets <code>value</code> as the attribute value for LastUpdatedBy.
     * @param value
     */
    public void setLastUpdatedBy(String value) {
        setAttributeInternal(LASTUPDATEDBY, value);
    }

    /**Gets the attribute value for LastUpdateDate, using the alias name LastUpdateDate.
     * @return
     */
    public Date getLastUpdateDate() {
        return (Date)getAttributeInternal(LASTUPDATEDATE);
    }

    /**Gets the attribute value for ObjectVersionId, using the alias name ObjectVersionId.
     * @return
     */
    public Number getObjectVersionId() {
        return (Number)getAttributeInternal(OBJECTVERSIONID);
    }

    /**Gets the attribute value for CalculatedOrderTotal, using the alias name CalculatedOrderTotal.
     * @return
     */
    public Double getCalculatedOrderTotal() {
        RowIterator rowItr = this.getOrderItem();
        Double total = 0.0;
        while(rowItr.hasNext()){
            Row row = rowItr.next();
            Number unitPrice = (Number)row.getAttribute("ListPrice");
            Integer quantity = (Integer)row.getAttribute("Quantity");
            total += (unitPrice.doubleValue() * quantity.intValue());   
        }
        rowItr.reset();
        return total;
    }

    /**
     * Sets <code>value</code> as the attribute value for CalculatedOrderTotal.
     * @param value
     */
    public void setCalculatedOrderTotal(Double value) {
        setAttributeInternal(CALCULATEDORDERTOTAL, value);
    }

    /**Gets the attribute value for DiscountAmount, using the alias name DiscountAmount.
     * @return
     */
    public Double getDiscountAmount() {
        try {
            Number amount = calculateDiscountAmount();
            return amount.doubleValue();
        } catch (SQLException e){
            System.out.println("SQLException error");
        }
        return (Double)getAttributeInternal(DISCOUNTAMOUNT);
    }

    /**Sets <code>value</code> as the attribute value for DiscountAmount.
     * @param value
     */
    public void setDiscountAmount(Double value) {
        try {
            Number amount = calculateDiscountAmount();
            value = amount.doubleValue();
        } catch (SQLException e){
            System.out.println("SQLException error");
        }
        setAttributeInternal(DISCOUNTAMOUNT, value);
    }

    /**Gets the attribute value for TypedCouponCode, using the alias name TypedCouponCode.
     * @return
     */
    public String getTypedCouponCode() {
        return (String)getAttributeInternal(TYPEDCOUPONCODE);
    }

    /**Sets <code>value</code> as the attribute value for TypedCouponCode.
     * @param value
     */
    public void setTypedCouponCode(String value) {
        setAttributeInternal(TYPEDCOUPONCODE, value);
    }

    /**getAttrInvokeAccessor: generated method. Do not modify.
     * @param index
     * @param attrDef
     * @return
     * @throws Exception
     */
    protected Object getAttrInvokeAccessor(int index, 
                                           AttributeDefImpl attrDef) throws Exception {
        if ((index >= AttributesEnum.firstIndex()) && (index < AttributesEnum.count())) {
            return AttributesEnum.staticValues()[index - AttributesEnum.firstIndex()].get(this);
        }
        return super.getAttrInvokeAccessor(index, attrDef);
    }

    /**setAttrInvokeAccessor: generated method. Do not modify.
     * @param index
     * @param value
     * @param attrDef
     * @throws Exception
     */
    protected void setAttrInvokeAccessor(int index, Object value, 
                                         AttributeDefImpl attrDef) throws Exception {
        if ((index >= AttributesEnum.firstIndex()) && (index < AttributesEnum.count())) {
            AttributesEnum.staticValues()[index - AttributesEnum.firstIndex()].put(this, value);
            return;
        }
        super.setAttrInvokeAccessor(index, value, attrDef);
    }

    /**Gets the associated entity AddressEOImpl.
     * @return
     */
    public AddressEOImpl getAddress() {
        return (AddressEOImpl)getAttributeInternal(ADDRESS);
    }

    /**Sets <code>value</code> as the associated entity AddressEOImpl.
     * @param value
     */
    public void setAddress(AddressEOImpl value) {
        setAttributeInternal(ADDRESS, value);
    }

    /**Gets the associated entity oracle.jbo.server.EntityImpl.
     * @return
     */
    public EntityImpl getDiscountBase() {
        return (EntityImpl)getAttributeInternal(DISCOUNTBASE);
    }

    /**Sets <code>value</code> as the associated entity oracle.jbo.server.EntityImpl.
     * @param value
     */
    public void setDiscountBase(EntityImpl value) {
        setAttributeInternal(DISCOUNTBASE, value);
    }

    /**Gets the associated entity oracle.jbo.server.EntityImpl.
     * @return
     */
    public EntityImpl getDiscountBase1() {
        return (EntityImpl)getAttributeInternal(DISCOUNTBASE1);
    }

    /**Sets <code>value</code> as the associated entity oracle.jbo.server.EntityImpl.
     * @param value
     */
    public void setDiscountBase1(EntityImpl value) {
        setAttributeInternal(DISCOUNTBASE1, value);
    }

    /**Gets the associated entity oracle.jbo.RowIterator.
     * @return
     */
    public RowIterator getCouponUsage() {
        return (RowIterator)getAttributeInternal(COUPONUSAGE);
    }

    /**Gets the associated entity oracle.jbo.RowIterator.
     * @return
     */
    public RowIterator getOrderItem() {
        return (RowIterator)getAttributeInternal(ORDERITEM);
    }

    /**Gets the associated entity oracle.jbo.server.EntityImpl.
     * @return
     */
    public PaymentOptionEOImpl getPaymentOption() {
        return (PaymentOptionEOImpl)getAttributeInternal(PAYMENTOPTION);
    }

    /**Sets <code>value</code> as the associated entity oracle.jbo.server.EntityImpl.
     * @param value
     */
    public void setPaymentOption(PaymentOptionEOImpl value) {
        setAttributeInternal(PAYMENTOPTION, value);
    }

    /**Gets the associated entity PersonEOImpl.
     * @return
     */
    public PersonEOImpl getPerson() {
        return (PersonEOImpl)getAttributeInternal(PERSON);
    }

    /**Sets <code>value</code> as the associated entity PersonEOImpl.
     * @param value
     */
    public void setPerson(PersonEOImpl value) {
        setAttributeInternal(PERSON, value);
    }

    /**Gets the associated entity oracle.jbo.server.EntityImpl.
     * @return
     */
    public EntityImpl getShippingOptionBase() {
        return (EntityImpl)getAttributeInternal(SHIPPINGOPTIONBASE);
    }

    /**Sets <code>value</code> as the associated entity oracle.jbo.server.EntityImpl.
     * @param value
     */
    public void setShippingOptionBase(EntityImpl value) {
        setAttributeInternal(SHIPPINGOPTIONBASE, value);
    }

    /**Gets the associated entity oracle.jbo.server.EntityImpl.
     * @return
     */
    public WarehouseEOImpl getWarehouse() {
        return (WarehouseEOImpl)getAttributeInternal(WAREHOUSE);
    }

    /**Sets <code>value</code> as the associated entity oracle.jbo.server.EntityImpl.
     * @param value
     */
    public void setWarehouse(WarehouseEOImpl value) {
        setAttributeInternal(WAREHOUSE, value);
    }

    /**Gets the view accessor <code>RowSet</code> OrdersVO.
     * @return
     */
    public RowSet getOrdersVO() {
        return (RowSet)getAttributeInternal(ORDERSVO);
    }

    /**
     * @param orderId key constituent

     * @return a Key object based on given key constituents.
     */
    public static Key createPrimaryKey(DBSequence orderId) {
        return new Key(new Object[]{orderId});
    }

    /**
     * Gets the attribute value for isPublishableEvent, using the alias name isPublishableEvent.
     * @return the isPublishableEvent
     */
    public Boolean getisPublishableEvent() {
        return (Boolean)getAttributeInternal(ISPUBLISHABLEEVENT);
    }

    /**
     * Sets <code>value</code> as the attribute value for isPublishableEvent.
     * @param value value to set the isPublishableEvent
     */
    public void setisPublishableEvent(Boolean value) {
        setAttributeInternal(ISPUBLISHABLEEVENT, value);
    }

    /**
     * Gets the attribute value for isEventLaunched, using the alias name isEventLaunched.
     * @return the isEventLaunched
     */
    public String getisEventLaunched() {
        return (String)getAttributeInternal(ISEVENTLAUNCHED);
    }

    /**
     * Sets <code>value</code> as the attribute value for isEventLaunched.
     * @param value value to set the isEventLaunched
     */
    public void setisEventLaunched(String value) {
        setAttributeInternal(ISEVENTLAUNCHED, value);
    }

}
