package oracle.fodemo.storefront.account.queries;


import oracle.fodemo.storefront.account.queries.common.CustomerAddressVO;

import oracle.jbo.Key;
import oracle.jbo.Row;
import oracle.jbo.domain.Number;
import oracle.jbo.server.EntityImpl;
import oracle.jbo.server.ViewObjectImpl;
import oracle.jbo.server.ViewRowImpl;
// ---------------------------------------------------------------------
// ---    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 CustomerAddressVOImpl extends ViewObjectImpl implements CustomerAddressVO {
    /**This is the default constructor (do not remove).
     */
    public CustomerAddressVOImpl() {
    }

    /**Gets the variable value for vcParamAssociatedOwnerId
     */
    public Number getvcParamAssociatedOwnerId() {
        return (Number)ensureVariableManager().getVariableValue("vcParamAssociatedOwnerId");
    }

    /**Sets <code>value</code> for variable vcParamAssociatedOwnerId
     */
    public void setvcParamAssociatedOwnerId(Number value) {
        ensureVariableManager().setVariableValue("vcParamAssociatedOwnerId", value);
    }

    /**
     * This method should be called whenever a newly created Row should be discarded
     */
    private void refreshRemoveNewRow(Row row){
        
        if (((ViewRowImpl) row).getNewRowState() == Row.STATUS_INITIALIZED){
            row.refresh(Row.REFRESH_UNDO_CHANGES + Row.REFRESH_REMOVE_NEW_ROWS);    
        } else {
            row.refresh(Row.REFRESH_UNDO_CHANGES + Row.REFRESH_FORGET_NEW_ROWS);                    
        }
    }
    
    /**
     * This method should be called whenever a newly created Row should be discarded
     */
    public void refreshAndDiscardChanges(){
        Row row = this.getCurrentRow();
        if (row != null){
            row.refresh(Row.REFRESH_UNDO_CHANGES);      
        }                              
    }
    
    private String getCurrentRowStatusAsString(){
        CustomerAddressVORowImpl addressRow = (CustomerAddressVORowImpl)this.getCurrentRow();
        
        byte status = addressRow.getAddressUsageEO().getEntityState();
        
        String statusDesc;
        switch (status){
        case Row.STATUS_INITIALIZED:
            statusDesc = "INIT";
            break;
        case Row.STATUS_NEW:
            statusDesc = "NEW";
            break;
        case EntityImpl.STATUS_MODIFIED:
            statusDesc = "MOD";
            break;
        case EntityImpl.STATUS_UNMODIFIED:
            statusDesc = "UNMOD";
            break;
        case EntityImpl.STATUS_DELETED:
            statusDesc = "DEL";
            break;        
        case EntityImpl.STATUS_DEAD:
            statusDesc = "DEAD";
            break;        
        default:
            statusDesc = "UNKNOWN: "+status;
        }
        
        return statusDesc;
    }
    public void refreshRemoveNewCurrentRow(){
        Row row = this.getCurrentRow();
        if (row != null){
            this.refreshRemoveNewRow(row);
        }
    }
    
    public void refreshRemoveNewRowByKey (Key pRowKey){
        Row[] rows = this.findByKey(pRowKey,1);
        
        if (rows != null && rows.length == 1){
            Row row = rows[0];
            this.refreshRemoveNewRow(row);
        }
    }

    @Override
    public Row createRow() {
        return super.createRow();
    }

    @Override
    public Row[] findByKey(Key key, int maxNumOfRows) {
        return super.findByKey(key, maxNumOfRows);
    }

    @Override
    public Row[] findByKey(Key key, int maxNumOfRows, boolean skipWhere) {
        return super.findByKey(key, maxNumOfRows, skipWhere);
    }

    @Override
    public boolean setCurrentRow(Row row) {
        return super.setCurrentRow(row);
    }

    @Override
    public boolean setCurrentRowAtRangeIndex(int index) {
        return super.setCurrentRowAtRangeIndex(index);
    }

    @Override
    public Row first() {
        return super.first();
    }

    public void refreshAndDiscardChanges(Row row) {
    }

    /**
     * Sample exportable method.
     */
    public void sampleCustomerAddressVOImplExportable() {
    }

    /**
     * Sample exportable method.
     */
    public void sampleCustomerAddressVOImplExportable2(String testParam1) {
    }
}
