package oracle.fodemo.storefront.entities;

import oracle.jbo.AttributeList;
import oracle.jbo.Key;
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 AddressEOImpl extends EntityImpl {
    public static final int SHAREDCOUNTRIES = 18;
    private static EntityDefImpl mDefinitionObject;

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

            public void put(AddressEOImpl obj, Object value) {
                obj.setAddressId((DBSequence)value);
            }
        }
        ,
        Address1 {
            public Object get(AddressEOImpl obj) {
                return obj.getAddress1();
            }

            public void put(AddressEOImpl obj, Object value) {
                obj.setAddress1((String)value);
            }
        }
        ,
        Address2 {
            public Object get(AddressEOImpl obj) {
                return obj.getAddress2();
            }

            public void put(AddressEOImpl obj, Object value) {
                obj.setAddress2((String)value);
            }
        }
        ,
        City {
            public Object get(AddressEOImpl obj) {
                return obj.getCity();
            }

            public void put(AddressEOImpl obj, Object value) {
                obj.setCity((String)value);
            }
        }
        ,
        PostalCode {
            public Object get(AddressEOImpl obj) {
                return obj.getPostalCode();
            }

            public void put(AddressEOImpl obj, Object value) {
                obj.setPostalCode((String)value);
            }
        }
        ,
        StateProvince {
            public Object get(AddressEOImpl obj) {
                return obj.getStateProvince();
            }

            public void put(AddressEOImpl obj, Object value) {
                obj.setStateProvince((String)value);
            }
        }
        ,
        CountryId {
            public Object get(AddressEOImpl obj) {
                return obj.getCountryId();
            }

            public void put(AddressEOImpl obj, Object value) {
                obj.setCountryId((String)value);
            }
        }
        ,
        Longitude {
            public Object get(AddressEOImpl obj) {
                return obj.getLongitude();
            }

            public void put(AddressEOImpl obj, Object value) {
                obj.setLongitude((Number)value);
            }
        }
        ,
        Latitude {
            public Object get(AddressEOImpl obj) {
                return obj.getLatitude();
            }

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

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

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

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

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

            public void put(AddressEOImpl obj, Object value) {
                obj.setAttributeInternal(index(), value);
            }
        }
        ,
        AddressUsage {
            public Object get(AddressEOImpl obj) {
                return obj.getAddressUsage();
            }

            public void put(AddressEOImpl obj, Object value) {
                obj.setAttributeInternal(index(), value);
            }
        }
        ,
        Order {
            public Object get(AddressEOImpl obj) {
                return obj.getOrder();
            }

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

            public void put(AddressEOImpl obj, Object value) {
                obj.setAttributeInternal(index(), value);
            }
        }
        ,
        Warehouse {
            public Object get(AddressEOImpl obj) {
                return obj.getWarehouse();
            }

            public void put(AddressEOImpl obj, Object value) {
                obj.setAttributeInternal(index(), value);
            }
        }
        ,
        CountryCodeEO {
            public Object get(AddressEOImpl obj) {
                return obj.getCountryCodeEO();
            }

            public void put(AddressEOImpl obj, Object value) {
                obj.setCountryCodeEO((EntityImpl)value);
            }
        }
        ,
        SharedCountriesVA {
            public Object get(AddressEOImpl obj) {
                return obj.getSharedCountriesVA();
            }

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

        public abstract Object get(AddressEOImpl object);

        public abstract void put(AddressEOImpl 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 final int ADDRESSID = AttributesEnum.AddressId.index();
    public static final int ADDRESS1 = AttributesEnum.Address1.index();
    public static final int ADDRESS2 = AttributesEnum.Address2.index();
    public static final int CITY = AttributesEnum.City.index();
    public static final int POSTALCODE = AttributesEnum.PostalCode.index();
    public static final int STATEPROVINCE = AttributesEnum.StateProvince.index();
    public static final int COUNTRYID = AttributesEnum.CountryId.index();
    public static final int LONGITUDE = AttributesEnum.Longitude.index();
    public static final int LATITUDE = AttributesEnum.Latitude.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 ADDRESSUSAGE = AttributesEnum.AddressUsage.index();
    public static final int ORDER = AttributesEnum.Order.index();
    public static final int PERSON = AttributesEnum.Person.index();
    public static final int WAREHOUSE = AttributesEnum.Warehouse.index();
    public static final int COUNTRYCODEEO = AttributesEnum.CountryCodeEO.index();
    public static final int SHAREDCOUNTRIESVA = AttributesEnum.SharedCountriesVA.index();


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


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

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

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

    /**Gets the attribute value for Address1, using the alias name Address1.
     */
    public String getAddress1() {
        return (String)getAttributeInternal(ADDRESS1);
    }

    /**Sets <code>value</code> as the attribute value for Address1.
     */
    public void setAddress1(String value) {
        setAttributeInternal(ADDRESS1, value);
    }

    /**Gets the attribute value for Address2, using the alias name Address2.
     */
    public String getAddress2() {
        return (String)getAttributeInternal(ADDRESS2);
    }

    /**Sets <code>value</code> as the attribute value for Address2.
     */
    public void setAddress2(String value) {
        setAttributeInternal(ADDRESS2, value);
    }

    /**Gets the attribute value for City, using the alias name City.
     */
    public String getCity() {
        return (String)getAttributeInternal(CITY);
    }

    /**Sets <code>value</code> as the attribute value for City.
     */
    public void setCity(String value) {
        setAttributeInternal(CITY, value);
    }

    /**Gets the attribute value for PostalCode, using the alias name PostalCode.
     */
    public String getPostalCode() {
        return (String)getAttributeInternal(POSTALCODE);
    }

    /**Sets <code>value</code> as the attribute value for PostalCode.
     */
    public void setPostalCode(String value) {
        setAttributeInternal(POSTALCODE, value);
    }

    /**Gets the attribute value for StateProvince, using the alias name StateProvince.
     */
    public String getStateProvince() {
        return (String)getAttributeInternal(STATEPROVINCE);
    }

    /**Sets <code>value</code> as the attribute value for StateProvince.
     */
    public void setStateProvince(String value) {
        setAttributeInternal(STATEPROVINCE, value);
    }

    /**Gets the attribute value for CountryId, using the alias name CountryId.
     */
    public String getCountryId() {
        return (String)getAttributeInternal(COUNTRYID);
    }

    /**Sets <code>value</code> as the attribute value for CountryId.
     */
    public void setCountryId(String value) {
        setAttributeInternal(COUNTRYID, value);
    }

    /**Gets the attribute value for Longitude, using the alias name Longitude.
     */
    public Number getLongitude() {
        return (Number)getAttributeInternal(LONGITUDE);
    }

    /**Sets <code>value</code> as the attribute value for Longitude.
     */
    public void setLongitude(Number value) {
        setAttributeInternal(LONGITUDE, value);
    }

    /**Gets the attribute value for Latitude, using the alias name Latitude.
     */
    public Number getLatitude() {
        return (Number)getAttributeInternal(LATITUDE);
    }

    /**Sets <code>value</code> as the attribute value for Latitude.
     */
    public void setLatitude(Number value) {
        setAttributeInternal(LATITUDE, 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);
    }


    /**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);
    }

    @Override
    public void postChanges(TransactionEvent transactionEvent) {
        /* Only bother to update references if Address is a new one */
        if (this.getPostState() == STATUS_NEW) {
            newAddressBeforePost = (RowSet)this.getAddressUsage();
        }
        super.postChanges(transactionEvent);
    }

    RowSet newAddressBeforePost = null;

    @Override
    protected void refreshFKInNewContainees() {
        if (newAddressBeforePost != null) {
            Number newAddressId = getAddressId().getSequenceNumber();
            while (newAddressBeforePost.hasNext()) {
                AddressUsageEOImpl usages = 
                    (AddressUsageEOImpl)newAddressBeforePost.next();
                usages.setAddressId(newAddressId);
            }
            newAddressBeforePost.closeRowSetIterator(); 
        }
    }



    /**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 oracle.jbo.RowIterator.
     */
    public RowIterator getAddressUsage() {
        return (RowIterator)getAttributeInternal(ADDRESSUSAGE);
    }

    /**Gets the associated entity oracle.jbo.RowIterator.
     */
    public RowIterator getOrder() {
        return (RowIterator)getAttributeInternal(ORDER);
    }

    /**Gets the associated entity oracle.jbo.RowIterator.
     */
    public RowIterator getPerson() {
        return (RowIterator)getAttributeInternal(PERSON);
    }

    /**Gets the associated entity oracle.jbo.RowIterator.
     */
    public RowIterator getWarehouse() {
        return (RowIterator)getAttributeInternal(WAREHOUSE);
    }


    /**Gets the view accessor <code>RowSet</code> SharedCountriesVA
     */
    public RowSet getSharedCountriesVA() {
        return (RowSet)getAttributeInternal(SHAREDCOUNTRIESVA);
    }


    /**
     * @param addressId key constituent

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

    /**Gets the associated entity oracle.jbo.server.EntityImpl.
     */
    public EntityImpl getCountryCodeEO() {
        return (EntityImpl)getAttributeInternal(COUNTRYCODEEO);
    }

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


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

}
