package oracle.fodemo.storefront.entities;

import oracle.jbo.AttributeList;
import oracle.jbo.Key;
import oracle.jbo.RowIterator;
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.SequenceImpl;
// ---------------------------------------------------------------------
// ---    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 WarehouseEOImpl extends EntityImpl {
    public static final int WAREHOUSEID = 0;
    public static final int ADDRESSID = 1;
    public static final int WAREHOUSENAME = 2;
    public static final int CREATEDBY = 3;
    public static final int CREATIONDATE = 4;
    public static final int LASTUPDATEDBY = 5;
    public static final int LASTUPDATEDATE = 6;
    public static final int OBJECTVERSIONID = 7;
    public static final int ADDRESS = 8;
    public static final int ORDER = 9;
    public static final int WAREHOUSESTOCKLEVEL = 10;
    private static EntityDefImpl mDefinitionObject;

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

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

    /**Gets the attribute value for WarehouseId, using the alias name WarehouseId.
     * @return
     */
    public Number getWarehouseId() {
        return (Number)getAttributeInternal(WAREHOUSEID);
    }

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

    /**Gets the attribute value for AddressId, using the alias name AddressId.
     * @return
     */
    public Number getAddressId() {
        return (Number)getAttributeInternal(ADDRESSID);
    }

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

    /**Gets the attribute value for WarehouseName, using the alias name WarehouseName.
     * @return
     */
    public String getWarehouseName() {
        return (String)getAttributeInternal(WAREHOUSENAME);
    }

    /**Sets <code>value</code> as the attribute value for WarehouseName.
     * @param value
     */
    public void setWarehouseName(String value) {
        setAttributeInternal(WAREHOUSENAME, 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);
    }

    /**getAttrInvokeAccessor: generated method. Do not modify.
     * @param index
     * @param attrDef
     * @return
     * @throws Exception
     */
    protected Object getAttrInvokeAccessor(int index, 
                                           AttributeDefImpl attrDef) throws Exception {
        switch (index) {
        case WAREHOUSEID:
            return getWarehouseId();
        case ADDRESSID:
            return getAddressId();
        case WAREHOUSENAME:
            return getWarehouseName();
        case CREATEDBY:
            return getCreatedBy();
        case CREATIONDATE:
            return getCreationDate();
        case LASTUPDATEDBY:
            return getLastUpdatedBy();
        case LASTUPDATEDATE:
            return getLastUpdateDate();
        case OBJECTVERSIONID:
            return getObjectVersionId();
        case WAREHOUSESTOCKLEVEL:
            return getWarehouseStockLevel();
        case ORDER:
            return getOrder();
        case ADDRESS:
            return getAddress();
        default:
            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 {
        switch (index) {
        case WAREHOUSEID:
            setWarehouseId((Number)value);
            return;
        case ADDRESSID:
            setAddressId((Number)value);
            return;
        case WAREHOUSENAME:
            setWarehouseName((String)value);
            return;
        case CREATEDBY:
            setCreatedBy((String)value);
            return;
        case LASTUPDATEDBY:
            setLastUpdatedBy((String)value);
            return;
        default:
            super.setAttrInvokeAccessor(index, value, attrDef);
            return;
        }
    }

    /**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.RowIterator.
     * @return
     */
    public RowIterator getOrder() {
        return (RowIterator)getAttributeInternal(ORDER);
    }

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

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

    /**
     * @param attributeList
     */
    @Override
    protected void create(AttributeList attributeList) {
        super.create(attributeList);
        SequenceImpl sequence = new SequenceImpl("WAREHOUSE_SEQ",getDBTransaction());
        setWarehouseId(sequence.getSequenceNumber());
    }
}
