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 AddressUsageEOImpl extends EntityImpl {
    public static final int SHAREDADDRESSUSAGETYPES = 14;
    public static final int SHAREDADDRESSOWNERTYPES = 15;
    private static EntityDefImpl mDefinitionObject;

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

            public void put(AddressUsageEOImpl obj, Object value) {
                obj.setAddressUsagesId((DBSequence)value);
            }
        }
        ,
        AssociatedOwnerId {
            public Object get(AddressUsageEOImpl obj) {
                return obj.getAssociatedOwnerId();
            }

            public void put(AddressUsageEOImpl obj, Object value) {
                obj.setAssociatedOwnerId((Number)value);
            }
        }
        ,
        OwnerTypeCode {
            public Object get(AddressUsageEOImpl obj) {
                return obj.getOwnerTypeCode();
            }

            public void put(AddressUsageEOImpl obj, Object value) {
                obj.setOwnerTypeCode((String)value);
            }
        }
        ,
        AddressId {
            public Object get(AddressUsageEOImpl obj) {
                return obj.getAddressId();
            }

            public void put(AddressUsageEOImpl obj, Object value) {
                obj.setAddressId((Number)value);
            }
        }
        ,
        UsageTypeCode {
            public Object get(AddressUsageEOImpl obj) {
                return obj.getUsageTypeCode();
            }

            public void put(AddressUsageEOImpl obj, Object value) {
                obj.setUsageTypeCode((String)value);
            }
        }
        ,
        ExpiredFlag {
            public Object get(AddressUsageEOImpl obj) {
                return obj.getExpiredFlag();
            }

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

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

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

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

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

            public void put(AddressUsageEOImpl obj, Object value) {
                obj.setAttributeInternal(index(), value);
            }
        }
        ,
        Address {
            public Object get(AddressUsageEOImpl obj) {
                return obj.getAddress();
            }

            public void put(AddressUsageEOImpl obj, Object value) {
                obj.setAddress((AddressEOImpl)value);
            }
        }
        ,
        Person {
            public Object get(AddressUsageEOImpl obj) {
                return obj.getPerson();
            }

            public void put(AddressUsageEOImpl obj, Object value) {
                obj.setPerson((PersonEOImpl)value);
            }
        }
        ,
        Supplier {
            public Object get(AddressUsageEOImpl obj) {
                return obj.getSupplier();
            }

            public void put(AddressUsageEOImpl obj, Object value) {
                obj.setSupplier((EntityImpl)value);
            }
        }
        ,
        LookupCodeEO {
            public Object get(AddressUsageEOImpl obj) {
                return obj.getLookupCodeEO();
            }

            public void put(AddressUsageEOImpl obj, Object value) {
                obj.setLookupCodeEO((EntityImpl)value);
            }
        }
        ,
        AddressOwnerTypesVA {
            public Object get(AddressUsageEOImpl obj) {
                return obj.getAddressOwnerTypesVA();
            }

            public void put(AddressUsageEOImpl obj, Object value) {
                obj.setAttributeInternal(index(), value);
            }
        }
        ,
        AddressUsageTypesVA {
            public Object get(AddressUsageEOImpl obj) {
                return obj.getAddressUsageTypesVA();
            }

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

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

        /**
         * @param object
         * @param value
         */
        public abstract void put(AddressUsageEOImpl 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 final int ADDRESSUSAGESID = AttributesEnum.AddressUsagesId.index();
    public static final int ASSOCIATEDOWNERID = AttributesEnum.AssociatedOwnerId.index();
    public static final int OWNERTYPECODE = AttributesEnum.OwnerTypeCode.index();
    public static final int ADDRESSID = AttributesEnum.AddressId.index();
    public static final int USAGETYPECODE = AttributesEnum.UsageTypeCode.index();
    public static final int EXPIREDFLAG = AttributesEnum.ExpiredFlag.index();
    public static final int CREATEDBY = AttributesEnum.CreatedBy.index();
    public static final int CREATIONDATE = AttributesEnum.CreationDate.index();
    public static final int LASTUPDATEDBY = AttributesEnum.LastUpdatedBy.index();
    public static final int LASTUPDATEDATE = AttributesEnum.LastUpdateDate.index();
    public static final int OBJECTVERSIONID = AttributesEnum.ObjectVersionId.index();
    public static final int ADDRESS = AttributesEnum.Address.index();
    public static final int PERSON = AttributesEnum.Person.index();
    public static final int SUPPLIER = AttributesEnum.Supplier.index();
    public static final int LOOKUPCODEEO = AttributesEnum.LookupCodeEO.index();
    public static final int ADDRESSOWNERTYPESVA = AttributesEnum.AddressOwnerTypesVA.index();
    public static final int ADDRESSUSAGETYPESVA = AttributesEnum.AddressUsageTypesVA.index();

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


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

    /**Gets the attribute value for AddressUsagesId, using the alias name AddressUsagesId.
     * @return
     */
    public DBSequence getAddressUsagesId() {
        return (DBSequence)getAttributeInternal(ADDRESSUSAGESID);
    }

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

    /**Gets the attribute value for AssociatedOwnerId, using the alias name AssociatedOwnerId.
     * @return
     */
    public Number getAssociatedOwnerId() {
        return (Number)getAttributeInternal(ASSOCIATEDOWNERID);
    }

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

    /**Gets the attribute value for OwnerTypeCode, using the alias name OwnerTypeCode.
     * @return
     */
    public String getOwnerTypeCode() {
        return (String)getAttributeInternal(OWNERTYPECODE);
    }

    /**Sets <code>value</code> as the attribute value for OwnerTypeCode.
     * @param value
     */
    public void setOwnerTypeCode(String value) {
        setAttributeInternal(OWNERTYPECODE, 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 UsageTypeCode, using the alias name UsageTypeCode.
     * @return
     */
    public String getUsageTypeCode() {
        return (String)getAttributeInternal(USAGETYPECODE);
    }

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

    /**Gets the attribute value for ExpiredFlag, using the alias name ExpiredFlag.
     * @return
     */
    public String getExpiredFlag() {
        return (String)getAttributeInternal(EXPIREDFLAG);
    }

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


    /**
     * @param transactionEvent
     */
    @Override
    public void postChanges(TransactionEvent transactionEvent) {
        /* If current entity is new or modified */
       if (getPostState() == STATUS_NEW || 
            getPostState() == STATUS_MODIFIED) {
            /* Get the associated Address for the Address Usage */
            AddressEOImpl address = getAddress();
            PersonEOImpl person = getPerson();

            /* If there is an associated product */
            if (address != null) {
                /* And if it's post-status is NEW */
                byte addressPostState = address.getPostState();                
                if (addressPostState == STATUS_NEW) {
                    /*
                     * Post the Address first, before posting this
                     * entity by calling super below
                     */
                    address.postChanges(transactionEvent);
                }
            }
            if (person != null) {
                if (person.getPostState() == STATUS_NEW){
                    /*
                    * Post the person first, before posting this
                    * entity by calling super below
                    */
                    person.postChanges(transactionEvent);
                }
            }
        }
        super.postChanges(transactionEvent);
    }
    /**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 PersonEOImpl getPerson() {
        return (PersonEOImpl)getAttributeInternal(PERSON);
    }

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

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

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

    /**Gets the view accessor <code>RowSet</code> SharedAddressUsageTypes.
     * @return
     */
    public RowSet getSharedAddressUsageTypes() {
        return (RowSet)getAttributeInternal(SHAREDADDRESSUSAGETYPES);
    }

    /**Gets the view accessor <code>RowSet</code> SharedAddressOwnerTypes.
     * @return
     */
    public RowSet getSharedAddressOwnerTypes() {
        return (RowSet)getAttributeInternal(SHAREDADDRESSOWNERTYPES);
    }


    /**
     * @param attributeList
     */
    @Override
    public void create(AttributeList attributeList) {
        super.create(attributeList);
    }

    /**Gets the view accessor <code>RowSet</code> AddressOwnerTypesVA.
     * @return
     */
    public RowSet getAddressOwnerTypesVA() {
        return (RowSet)getAttributeInternal(ADDRESSOWNERTYPESVA);
    }

    /**Gets the view accessor <code>RowSet</code> AddressUsageTypesVA.
     * @return
     */
    public RowSet getAddressUsageTypesVA() {
        return (RowSet)getAttributeInternal(ADDRESSUSAGETYPESVA);
    }


    /**
     * @param addressUsagesId key constituent

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

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

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

}
