package oracle.fodemo.storefront.entities;

import oracle.jbo.AttributeList;
import oracle.jbo.Key;
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 OrderItemEOImpl extends EntityImpl {
    private static EntityDefImpl mDefinitionObject;

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

            public void put(OrderItemEOImpl obj, Object value) {
                obj.setOrderId((Number)value);
            }
        }
        ,
        LineItemId {
            public Object get(OrderItemEOImpl obj) {
                return obj.getLineItemId();
            }

            public void put(OrderItemEOImpl obj, Object value) {
                obj.setLineItemId((DBSequence)value);
            }
        }
        ,
        ProductId {
            public Object get(OrderItemEOImpl obj) {
                return obj.getProductId();
            }

            public void put(OrderItemEOImpl obj, Object value) {
                obj.setProductId((Number)value);
            }
        }
        ,
        Quantity {
            public Object get(OrderItemEOImpl obj) {
                return obj.getQuantity();
            }

            public void put(OrderItemEOImpl obj, Object value) {
                obj.setQuantity((Integer)value);
            }
        }
        ,
        UnitPrice {
            public Object get(OrderItemEOImpl obj) {
                return obj.getUnitPrice();
            }

            public void put(OrderItemEOImpl obj, Object value) {
                obj.setUnitPrice((Number)value);
            }
        }
        ,
        CreatedBy {
            public Object get(OrderItemEOImpl obj) {
                return obj.getCreatedBy();
            }

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

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

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

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

            public void put(OrderItemEOImpl obj, Object value) {
                obj.setAttributeInternal(index(), value);
            }
        }
        ,
        LineItemTotal {
            public Object get(OrderItemEOImpl obj) {
                return obj.getLineItemTotal();
            }

            public void put(OrderItemEOImpl obj, Object value) {
                obj.setLineItemTotal((Number)value);
            }
        }
        ,
        ListPrice {
            public Object get(OrderItemEOImpl obj) {
                return obj.getListPrice();
            }

            public void put(OrderItemEOImpl obj, Object value) {
                obj.setListPrice((Number)value);
            }
        }
        ,
        ShippingCost {
            public Object get(OrderItemEOImpl obj) {
                return obj.getShippingCost();
            }

            public void put(OrderItemEOImpl obj, Object value) {
                obj.setShippingCost((Number)value);
            }
        }
        ,
        Order {
            public Object get(OrderItemEOImpl obj) {
                return obj.getOrder();
            }

            public void put(OrderItemEOImpl obj, Object value) {
                obj.setOrder((OrderEOImpl)value);
            }
        }
        ,
        ProductBase {
            public Object get(OrderItemEOImpl obj) {
                return obj.getProductBase();
            }

            public void put(OrderItemEOImpl obj, Object value) {
                obj.setProductBase((ProductBaseEOImpl)value);
            }
        }
        ,
        ProductQuantitiesVO {
            public Object get(OrderItemEOImpl obj) {
                return obj.getProductQuantitiesVO();
            }

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

        public abstract Object get(OrderItemEOImpl object);

        public abstract void put(OrderItemEOImpl object, Object value);

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

        public static int firstIndex() {
            return firstIndex;
        }

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

        public static AttributesEnum[] staticValues() {
            if (vals == null) {
                vals = AttributesEnum.values();
            }
            return vals;
        }
    }
    public static int ORDERID = AttributesEnum.OrderId.index();
    public static int LINEITEMID = AttributesEnum.LineItemId.index();
    public static int PRODUCTID = AttributesEnum.ProductId.index();
    public static int QUANTITY = AttributesEnum.Quantity.index();
    public static int UNITPRICE = AttributesEnum.UnitPrice.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 LINEITEMTOTAL = AttributesEnum.LineItemTotal.index();
    public static int LISTPRICE = AttributesEnum.ListPrice.index();
    public static int SHIPPINGCOST = AttributesEnum.ShippingCost.index();
    public static int ORDER = AttributesEnum.Order.index();
    public static int PRODUCTBASE = AttributesEnum.ProductBase.index();
    public static int PRODUCTQUANTITIESVO = AttributesEnum.ProductQuantitiesVO.index();

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


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

    /** Begin Custom Code **/
    protected void create(AttributeList nameValuePair) {
       super.create(nameValuePair);
    }

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

    public void init(){
      ProductBaseEOImpl productBaseEO = this.getProductBase();
      // add logic for special pricing
      if(productBaseEO != null){
        Number listPrice = productBaseEO.getListPrice();
        this.setUnitPrice(listPrice);
      }
    }

    /** End Custom Code **/


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

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

    /**Gets the attribute value for LineItemId, using the alias name LineItemId.
     */
    public DBSequence getLineItemId() {
        return (DBSequence)getAttributeInternal(LINEITEMID);
    }

    /**Sets <code>value</code> as the attribute value for LineItemId.
     */
    public void setLineItemId(DBSequence value) {
        setAttributeInternal(LINEITEMID, value);
    }

    /**Gets the attribute value for ProductId, using the alias name ProductId.
     */
    public Number getProductId() {
        return (Number)getAttributeInternal(PRODUCTID);
    }

    /**Sets <code>value</code> as the attribute value for ProductId.
     */
    public void setProductId(Number value) {
        setAttributeInternal(PRODUCTID, value);
    }

    /**Gets the attribute value for Quantity, using the alias name Quantity.
     */
    public Integer getQuantity() {
        return (Integer)getAttributeInternal(QUANTITY);
    }

    /**Sets <code>value</code> as the attribute value for Quantity.
     */
    public void setQuantity(Integer value) {
        setAttributeInternal(QUANTITY, value);
    }

    /**Gets the attribute value for UnitPrice, using the alias name UnitPrice.
     */
    public Number getUnitPrice() {
        return (Number)getAttributeInternal(UNITPRICE);
    }

    /**Sets <code>value</code> as the attribute value for UnitPrice.
     */
    public void setUnitPrice(Number value) {
        setAttributeInternal(UNITPRICE, value);
    }

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

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

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

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

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

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

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

    /**Gets the attribute value for LineItemTotal, using the alias name LineItemTotal.
     */
    public Number getLineItemTotal() {
        return (Number)getAttributeInternal(LINEITEMTOTAL);
    }

    /**Sets <code>value</code> as the attribute value for LineItemTotal.
     */
    public void setLineItemTotal(Number value) {
        setAttributeInternal(LINEITEMTOTAL, value);
    }

    /**Gets the attribute value for ListPrice, using the alias name ListPrice.
     */
    public Number getListPrice() {
        return (Number)getAttributeInternal(LISTPRICE);
    }

    /**Sets <code>value</code> as the attribute value for ListPrice.
     */
    public void setListPrice(Number value) {
        setAttributeInternal(LISTPRICE, value);
    }

    /**getAttrInvokeAccessor: generated method. Do not modify.
     */
    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.
     */
    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 OrderEOImpl.
     */
    public OrderEOImpl getOrder() {
        return (OrderEOImpl)getAttributeInternal(ORDER);
    }

    /**Sets <code>value</code> as the associated entity OrderEOImpl.
     */
    public void setOrder(OrderEOImpl value) {
        setAttributeInternal(ORDER, value);
    }

    /**Gets the associated entity ProductBaseEOImpl.
     */
    public ProductBaseEOImpl getProductBase() {
        return (ProductBaseEOImpl)getAttributeInternal(PRODUCTBASE);
    }

    /**Sets <code>value</code> as the associated entity ProductBaseEOImpl.
     */
    public void setProductBase(ProductBaseEOImpl value) {
        setAttributeInternal(PRODUCTBASE, value);
    }

    /**Gets the view accessor <code>RowSet</code> ProductQuantitiesVO
     */
    public RowSet getProductQuantitiesVO() {
        return (RowSet)getAttributeInternal(PRODUCTQUANTITIESVO);
    }


    /**
     * @param orderId key constituent
     * @param lineItemId key constituent
     * @param productId key constituent

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

    /**Gets the attribute value for ShippingCost, using the alias name ShippingCost.
     */
    public Number getShippingCost() {
        return (Number)getAttributeInternal(SHIPPINGCOST);
    }

    /**Sets <code>value</code> as the attribute value for ShippingCost.
     */
    public void setShippingCost(Number value) {
        setAttributeInternal(SHIPPINGCOST, value);
    }

}
