package oracle.fodemo.storefront.store.queries;

import oracle.fodemo.storefront.store.queries.common.PersonsVO;

import oracle.jbo.Key;
import oracle.jbo.Row;
import oracle.jbo.RowIterator;
import oracle.jbo.domain.DBSequence;
import oracle.jbo.server.AttributeListImpl;
import oracle.jbo.server.ViewObjectImpl;
// ---------------------------------------------------------------------
// ---    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 PersonsVOImpl extends ViewObjectImpl implements PersonsVO {
    /**This is the default constructor (do not remove).
     */
    public PersonsVOImpl() {
    }

    public Long findCustomerIdByPrincipalName(String principalName){
        Long customerId = null;
        Key key = new Key(new Object[]{principalName});    
        RowIterator personsItr = this.findByAltKey("PrincipalName_AltKey", key , 1, false);
        Row row = personsItr.first();
        if(row != null){
            customerId = ((DBSequence)row.getAttribute("PersonId")).getValue();
        }
        return customerId;
    }


    /**Gets the variable value for userPrincipal.
     */
    public String getuserPrincipal() {
        return (String)ensureVariableManager().getVariableValue("userPrincipal");
    }

    /**Sets <code>value</code> for variable userPrincipal.
     */
    public void setuserPrincipal(String value) {
        ensureVariableManager().setVariableValue("userPrincipal", value);
    }

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

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