/*
 * IMPORTANT!!!! XSL Autogenerated class, DO NOT EDIT!!!!!
 * Template: Infrastructure8.2 rev3 [oneit.objstore.BusinessObjectTemplate.xsl]
 *
 *   Version: 1.0
 *   Vendor: Apache Software Foundation (Xalan XSLTC)
 *   Vendor URL: http://xml.apache.org/xalan-j
 */


    package performa.orm;

import java.io.*;
import java.util.*;
import oneit.appservices.config.*;
import oneit.logging.*;
import oneit.objstore.*;
import oneit.objstore.assocs.*;
import oneit.objstore.attributes.*;
import oneit.objstore.rdbms.filters.*;
import oneit.objstore.parser.*;
import oneit.objstore.validator.*;
import oneit.objstore.utils.*;
import oneit.utils.*;
import oneit.utils.filter.Filter;
import oneit.utils.transform.*;
import oneit.utils.parsers.FieldException;

import oneit.security.*;

import performa.orm.types.*;



public abstract class BaseCompanyUser extends SecUserExtension
{
    // Reference instance for the object
    public static final CompanyUser REFERENCE_CompanyUser = new CompanyUser ();

    // Reference instance for the object
    public static final CompanyUser DUMMY_CompanyUser = new DummyCompanyUser ();

    // Static constants corresponding to field names
    
    public static final String FIELD_ForgotPasswordMailSendDate = "ForgotPasswordMailSendDate";
    public static final String FIELD_ForgotPasswordKey = "ForgotPasswordKey";
    public static final String FIELD_Role = "Role";
    public static final String FIELD_Phone = "Phone";
    public static final String SINGLEREFERENCE_Company = "Company";
    public static final String BACKREF_Company = "";

    // Static constants corresponding to searches
    public static final String SEARCH_All = "All";
    

    // Static constants corresponding to attribute helpers
    private static final DefaultAttributeHelper<CompanyUser> HELPER_ForgotPasswordMailSendDate = DefaultAttributeHelper.INSTANCE;
    private static final DefaultAttributeHelper<CompanyUser> HELPER_ForgotPasswordKey = DefaultAttributeHelper.INSTANCE;
    private static final EnumeratedAttributeHelper<CompanyUser, RoleType> HELPER_Role =  new EnumeratedAttributeHelper<CompanyUser, RoleType> (RoleType.FACTORY_RoleType);
    private static final DefaultAttributeHelper<CompanyUser> HELPER_Phone = DefaultAttributeHelper.INSTANCE;
    

    // Private attributes corresponding to business object data
    private Date _ForgotPasswordMailSendDate;
    private String _ForgotPasswordKey;
    private RoleType _Role;
    private String _Phone;
    

    // Private attributes corresponding to single references
    private SingleAssociation<CompanyUser, Company> _Company;
    

    // Private attributes corresponding to multiple references
    

    // Map of maps of metadata
    private static final Map ATTRIBUTES_METADATA_CompanyUser = new HashMap ();

    // Arrays of validators for each attribute
    private static final AttributeValidator[] FIELD_ForgotPasswordMailSendDate_Validators;
    private static final AttributeValidator[] FIELD_ForgotPasswordKey_Validators;
    private static final AttributeValidator[] FIELD_Role_Validators;
    private static final AttributeValidator[] FIELD_Phone_Validators;
    

    // Arrays of behaviour decorators
    private static final CompanyUserBehaviourDecorator[] CompanyUser_BehaviourDecorators;
    
    static
    {
        try
        {
            
            String tmp_Company = Company.BACKREF_Users;
            
            Map  validatorMapping = ((Map)ConfigMgr.getConfigObject ("CONFIG.ORMVALIDATOR", "ValidatorMapping"));

            setupAssocMetaData_Company();
            FIELD_ForgotPasswordMailSendDate_Validators = (AttributeValidator[])setupAttribMetaData_ForgotPasswordMailSendDate(validatorMapping).toArray (new AttributeValidator[0]);
            FIELD_ForgotPasswordKey_Validators = (AttributeValidator[])setupAttribMetaData_ForgotPasswordKey(validatorMapping).toArray (new AttributeValidator[0]);
            FIELD_Role_Validators = (AttributeValidator[])setupAttribMetaData_Role(validatorMapping).toArray (new AttributeValidator[0]);
            FIELD_Phone_Validators = (AttributeValidator[])setupAttribMetaData_Phone(validatorMapping).toArray (new AttributeValidator[0]);
            

            REFERENCE_CompanyUser.initialiseReference ();
            DUMMY_CompanyUser.initialiseReference ();
            CompanyUser_BehaviourDecorators = BaseBusinessClass.getBBCBehaviours(CompanyUser.class).toArray(new CompanyUserBehaviourDecorator[0]);
        }
        catch (RuntimeException e)
        {
            LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR1, e, "Error initialising");
            throw e;
        }
    }

    
    // Meta Info setup
    private static void setupAssocMetaData_Company()
    {
        Map metaInfo = new HashMap ();

        metaInfo.put ("backreferenceName", "Users");
        metaInfo.put ("dbcol", "company_id");
        metaInfo.put ("name", "Company");
        metaInfo.put ("type", "Company");
        
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for CompanyUser.Company:", metaInfo);
        ATTRIBUTES_METADATA_CompanyUser.put (SINGLEREFERENCE_Company, Collections.unmodifiableMap (metaInfo));
    }
    
    
    // Meta Info setup
    private static List setupAttribMetaData_ForgotPasswordMailSendDate(Map validatorMapping)
    {
        Map  metaInfo   = new HashMap ();

        metaInfo.put ("dbcol", "forgot_password_mail_send_date");
        metaInfo.put ("name", "ForgotPasswordMailSendDate");
        metaInfo.put ("type", "Date");
        
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for CompanyUser.ForgotPasswordMailSendDate:", metaInfo);
        ATTRIBUTES_METADATA_CompanyUser.put (FIELD_ForgotPasswordMailSendDate, Collections.unmodifiableMap (metaInfo));

        List validators = BaseBusinessClass.getAttribValidators(CompanyUser.class, "ForgotPasswordMailSendDate", metaInfo, validatorMapping);
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for CompanyUser.ForgotPasswordMailSendDate:", validators);        

        return validators;
    }
    
    // Meta Info setup
    private static List setupAttribMetaData_ForgotPasswordKey(Map validatorMapping)
    {
        Map  metaInfo   = new HashMap ();

        metaInfo.put ("dbcol", "forgot_password_key");
        metaInfo.put ("length", "10");
        metaInfo.put ("name", "ForgotPasswordKey");
        metaInfo.put ("type", "String");
        
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for CompanyUser.ForgotPasswordKey:", metaInfo);
        ATTRIBUTES_METADATA_CompanyUser.put (FIELD_ForgotPasswordKey, Collections.unmodifiableMap (metaInfo));

        List validators = BaseBusinessClass.getAttribValidators(CompanyUser.class, "ForgotPasswordKey", metaInfo, validatorMapping);
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for CompanyUser.ForgotPasswordKey:", validators);        

        return validators;
    }
    
    // Meta Info setup
    private static List setupAttribMetaData_Role(Map validatorMapping)
    {
        Map  metaInfo   = new HashMap ();

        metaInfo.put ("attribHelper", "EnumeratedAttributeHelper");
        metaInfo.put ("dbcol", "role_type");
        metaInfo.put ("mandatory", "false");
        metaInfo.put ("name", "Role");
        metaInfo.put ("type", "RoleType");
        
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for CompanyUser.Role:", metaInfo);
        ATTRIBUTES_METADATA_CompanyUser.put (FIELD_Role, Collections.unmodifiableMap (metaInfo));

        List validators = BaseBusinessClass.getAttribValidators(CompanyUser.class, "Role", metaInfo, validatorMapping);
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for CompanyUser.Role:", validators);        

        return validators;
    }
    
    // Meta Info setup
    private static List setupAttribMetaData_Phone(Map validatorMapping)
    {
        Map  metaInfo   = new HashMap ();

        metaInfo.put ("dbcol", "phone");
        metaInfo.put ("length", "30");
        metaInfo.put ("mandatory", "false");
        metaInfo.put ("name", "Phone");
        metaInfo.put ("type", "String");
        
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for CompanyUser.Phone:", metaInfo);
        ATTRIBUTES_METADATA_CompanyUser.put (FIELD_Phone, Collections.unmodifiableMap (metaInfo));

        List validators = BaseBusinessClass.getAttribValidators(CompanyUser.class, "Phone", metaInfo, validatorMapping);
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for CompanyUser.Phone:", validators);        

        return validators;
    }
    
    // END OF STATIC METADATA DEFINITION    
    
    
    
    // This constructor should not be called
    protected BaseCompanyUser ()
    {
    }


    protected BBCBehaviourDecorator[] getBehaviours()
    {
        return CompanyUser_BehaviourDecorators;
    }
    
    


    


    // Initialise the attributes
    protected void _initialiseNewObjAttributes (ObjectTransaction transaction) throws StorageException
    {
        super._initialiseNewObjAttributes (transaction);

        
        _ForgotPasswordMailSendDate = (Date)(HELPER_ForgotPasswordMailSendDate.initialise (_ForgotPasswordMailSendDate));
        _ForgotPasswordKey = (String)(HELPER_ForgotPasswordKey.initialise (_ForgotPasswordKey));
        _Role = (RoleType)(HELPER_Role.initialise (_Role));
        _Phone = (String)(HELPER_Phone.initialise (_Phone));
    }


    // Initialise the associations
    protected void _initialiseAssociations ()
    {
        super._initialiseAssociations ();

        _Company = new SingleAssociation<CompanyUser, Company> (this, SINGLEREFERENCE_Company, Company.MULTIPLEREFERENCE_Users, Company.REFERENCE_Company, "oneit_sec_user_extension");
        
    }


    // Initialise the associations
    protected BaseBusinessClass initialiseReference ()
    {
        super.initialiseReference ();
        
        _Company = new SingleAssociation<CompanyUser, Company> (this, SINGLEREFERENCE_Company, Company.MULTIPLEREFERENCE_Users, Company.REFERENCE_Company, "oneit_sec_user_extension");
        
        
        return this;
    }

    

    /**
     * Get the attribute ForgotPasswordMailSendDate
     */
    public Date getForgotPasswordMailSendDate ()
    {
        assertValid();
        Date valToReturn = _ForgotPasswordMailSendDate;

            for (CompanyUserBehaviourDecorator bhd : CompanyUser_BehaviourDecorators)
            {
                valToReturn = bhd.getForgotPasswordMailSendDate ((CompanyUser)this, valToReturn);
            }
            
            return valToReturn;
        
    }


    /**
     * Called prior to the attribute changing.  Subclasses need not call super.  If a field exception
     * is thrown, the attribute change will fail.  The new value is different to the old value.
     */
    protected void preForgotPasswordMailSendDateChange (Date newForgotPasswordMailSendDate) throws FieldException
    {
    }


    /**
     * Called after the attribute changes.
     * If a field exception is thrown, the value is still changed, however it 
     * may lead to the TX being rolled back
     */
    protected void postForgotPasswordMailSendDateChange () throws FieldException
    {
    }

    
    public FieldWriteability getWriteability_ForgotPasswordMailSendDate ()
    {
        return getFieldWritabilityUtil (FieldWriteability.TRUE);
    }

    /**
     * Set the attribute ForgotPasswordMailSendDate.  Checks to ensure a new value
     * has been supplied.  If so, marks the field as altered and sets the attribute.
     */
    public void setForgotPasswordMailSendDate (Date newForgotPasswordMailSendDate) throws FieldException
    {
        boolean oldAndNewIdentical = HELPER_ForgotPasswordMailSendDate.compare (_ForgotPasswordMailSendDate, newForgotPasswordMailSendDate);
        
        try
        {
            for (CompanyUserBehaviourDecorator bhd : CompanyUser_BehaviourDecorators)
            {
                newForgotPasswordMailSendDate = bhd.setForgotPasswordMailSendDate ((CompanyUser)this, newForgotPasswordMailSendDate);
                oldAndNewIdentical = HELPER_ForgotPasswordMailSendDate.compare (_ForgotPasswordMailSendDate, newForgotPasswordMailSendDate);
            }

            

            if (FIELD_ForgotPasswordMailSendDate_Validators.length > 0)
            {
                Object newForgotPasswordMailSendDateObj = HELPER_ForgotPasswordMailSendDate.toObject (newForgotPasswordMailSendDate);

                if (newForgotPasswordMailSendDateObj != null)
                {
                    int     loopMax = FIELD_ForgotPasswordMailSendDate_Validators.length;
                    Map     metadata = (Map)ATTRIBUTES_METADATA_CompanyUser.get (FIELD_ForgotPasswordMailSendDate);

                    for (int v = 0 ; v < loopMax ; ++v)
                    {
                        FIELD_ForgotPasswordMailSendDate_Validators[v].checkAttribute (this, FIELD_ForgotPasswordMailSendDate, metadata, newForgotPasswordMailSendDateObj);
                    }
                }
            }
        }
        catch (FieldException e)
        {
            if (!oldAndNewIdentical)
            {
                e.setWouldModify ();
            }
            
            throw e;
        }

        if (!oldAndNewIdentical)
        {
            assertValid();
            Debug.assertion (getWriteability_ForgotPasswordMailSendDate () != FieldWriteability.FALSE, "Field  ForgotPasswordMailSendDate is not writeable");
            preForgotPasswordMailSendDateChange (newForgotPasswordMailSendDate);
            markFieldChange (FIELD_ForgotPasswordMailSendDate);
            _ForgotPasswordMailSendDate = newForgotPasswordMailSendDate;            
            postFieldChange (FIELD_ForgotPasswordMailSendDate);
            postForgotPasswordMailSendDateChange ();
        }
    }

    /**
     * Get the attribute ForgotPasswordKey
     */
    public String getForgotPasswordKey ()
    {
        assertValid();
        String valToReturn = _ForgotPasswordKey;

            for (CompanyUserBehaviourDecorator bhd : CompanyUser_BehaviourDecorators)
            {
                valToReturn = bhd.getForgotPasswordKey ((CompanyUser)this, valToReturn);
            }
            
            return valToReturn;
        
    }


    /**
     * Called prior to the attribute changing.  Subclasses need not call super.  If a field exception
     * is thrown, the attribute change will fail.  The new value is different to the old value.
     */
    protected void preForgotPasswordKeyChange (String newForgotPasswordKey) throws FieldException
    {
    }


    /**
     * Called after the attribute changes.
     * If a field exception is thrown, the value is still changed, however it 
     * may lead to the TX being rolled back
     */
    protected void postForgotPasswordKeyChange () throws FieldException
    {
    }

    
    public FieldWriteability getWriteability_ForgotPasswordKey ()
    {
        return getFieldWritabilityUtil (FieldWriteability.TRUE);
    }

    /**
     * Set the attribute ForgotPasswordKey.  Checks to ensure a new value
     * has been supplied.  If so, marks the field as altered and sets the attribute.
     */
    public void setForgotPasswordKey (String newForgotPasswordKey) throws FieldException
    {
        boolean oldAndNewIdentical = HELPER_ForgotPasswordKey.compare (_ForgotPasswordKey, newForgotPasswordKey);
        
        try
        {
            for (CompanyUserBehaviourDecorator bhd : CompanyUser_BehaviourDecorators)
            {
                newForgotPasswordKey = bhd.setForgotPasswordKey ((CompanyUser)this, newForgotPasswordKey);
                oldAndNewIdentical = HELPER_ForgotPasswordKey.compare (_ForgotPasswordKey, newForgotPasswordKey);
            }

            

            if (FIELD_ForgotPasswordKey_Validators.length > 0)
            {
                Object newForgotPasswordKeyObj = HELPER_ForgotPasswordKey.toObject (newForgotPasswordKey);

                if (newForgotPasswordKeyObj != null)
                {
                    int     loopMax = FIELD_ForgotPasswordKey_Validators.length;
                    Map     metadata = (Map)ATTRIBUTES_METADATA_CompanyUser.get (FIELD_ForgotPasswordKey);

                    for (int v = 0 ; v < loopMax ; ++v)
                    {
                        FIELD_ForgotPasswordKey_Validators[v].checkAttribute (this, FIELD_ForgotPasswordKey, metadata, newForgotPasswordKeyObj);
                    }
                }
            }
        }
        catch (FieldException e)
        {
            if (!oldAndNewIdentical)
            {
                e.setWouldModify ();
            }
            
            throw e;
        }

        if (!oldAndNewIdentical)
        {
            assertValid();
            Debug.assertion (getWriteability_ForgotPasswordKey () != FieldWriteability.FALSE, "Field  ForgotPasswordKey is not writeable");
            preForgotPasswordKeyChange (newForgotPasswordKey);
            markFieldChange (FIELD_ForgotPasswordKey);
            _ForgotPasswordKey = newForgotPasswordKey;            
            postFieldChange (FIELD_ForgotPasswordKey);
            postForgotPasswordKeyChange ();
        }
    }

    /**
     * Get the attribute Role
     */
    public RoleType getRole ()
    {
        assertValid();
        RoleType valToReturn = _Role;

            for (CompanyUserBehaviourDecorator bhd : CompanyUser_BehaviourDecorators)
            {
                valToReturn = bhd.getRole ((CompanyUser)this, valToReturn);
            }
            
            return valToReturn;
        
    }


    /**
     * Called prior to the attribute changing.  Subclasses need not call super.  If a field exception
     * is thrown, the attribute change will fail.  The new value is different to the old value.
     */
    protected void preRoleChange (RoleType newRole) throws FieldException
    {
    }


    /**
     * Called after the attribute changes.
     * If a field exception is thrown, the value is still changed, however it 
     * may lead to the TX being rolled back
     */
    protected void postRoleChange () throws FieldException
    {
    }

    
    public FieldWriteability getWriteability_Role ()
    {
        return getFieldWritabilityUtil (FieldWriteability.TRUE);
    }

    /**
     * Set the attribute Role.  Checks to ensure a new value
     * has been supplied.  If so, marks the field as altered and sets the attribute.
     */
    public void setRole (RoleType newRole) throws FieldException
    {
        boolean oldAndNewIdentical = HELPER_Role.compare (_Role, newRole);
        
        try
        {
            for (CompanyUserBehaviourDecorator bhd : CompanyUser_BehaviourDecorators)
            {
                newRole = bhd.setRole ((CompanyUser)this, newRole);
                oldAndNewIdentical = HELPER_Role.compare (_Role, newRole);
            }

            

            if (FIELD_Role_Validators.length > 0)
            {
                Object newRoleObj = HELPER_Role.toObject (newRole);

                if (newRoleObj != null)
                {
                    int     loopMax = FIELD_Role_Validators.length;
                    Map     metadata = (Map)ATTRIBUTES_METADATA_CompanyUser.get (FIELD_Role);

                    for (int v = 0 ; v < loopMax ; ++v)
                    {
                        FIELD_Role_Validators[v].checkAttribute (this, FIELD_Role, metadata, newRoleObj);
                    }
                }
            }
        }
        catch (FieldException e)
        {
            if (!oldAndNewIdentical)
            {
                e.setWouldModify ();
            }
            
            throw e;
        }

        if (!oldAndNewIdentical)
        {
            assertValid();
            Debug.assertion (getWriteability_Role () != FieldWriteability.FALSE, "Field  Role is not writeable");
            preRoleChange (newRole);
            markFieldChange (FIELD_Role);
            _Role = newRole;            
            postFieldChange (FIELD_Role);
            postRoleChange ();
        }
    }

    /**
     * Get the attribute Phone
     */
    public String getPhone ()
    {
        assertValid();
        String valToReturn = _Phone;

            for (CompanyUserBehaviourDecorator bhd : CompanyUser_BehaviourDecorators)
            {
                valToReturn = bhd.getPhone ((CompanyUser)this, valToReturn);
            }
            
            return valToReturn;
        
    }


    /**
     * Called prior to the attribute changing.  Subclasses need not call super.  If a field exception
     * is thrown, the attribute change will fail.  The new value is different to the old value.
     */
    protected void prePhoneChange (String newPhone) throws FieldException
    {
    }


    /**
     * Called after the attribute changes.
     * If a field exception is thrown, the value is still changed, however it 
     * may lead to the TX being rolled back
     */
    protected void postPhoneChange () throws FieldException
    {
    }

    
    public FieldWriteability getWriteability_Phone ()
    {
        return getFieldWritabilityUtil (FieldWriteability.TRUE);
    }

    /**
     * Set the attribute Phone.  Checks to ensure a new value
     * has been supplied.  If so, marks the field as altered and sets the attribute.
     */
    public void setPhone (String newPhone) throws FieldException
    {
        boolean oldAndNewIdentical = HELPER_Phone.compare (_Phone, newPhone);
        
        try
        {
            for (CompanyUserBehaviourDecorator bhd : CompanyUser_BehaviourDecorators)
            {
                newPhone = bhd.setPhone ((CompanyUser)this, newPhone);
                oldAndNewIdentical = HELPER_Phone.compare (_Phone, newPhone);
            }

            

            if (FIELD_Phone_Validators.length > 0)
            {
                Object newPhoneObj = HELPER_Phone.toObject (newPhone);

                if (newPhoneObj != null)
                {
                    int     loopMax = FIELD_Phone_Validators.length;
                    Map     metadata = (Map)ATTRIBUTES_METADATA_CompanyUser.get (FIELD_Phone);

                    for (int v = 0 ; v < loopMax ; ++v)
                    {
                        FIELD_Phone_Validators[v].checkAttribute (this, FIELD_Phone, metadata, newPhoneObj);
                    }
                }
            }
        }
        catch (FieldException e)
        {
            if (!oldAndNewIdentical)
            {
                e.setWouldModify ();
            }
            
            throw e;
        }

        if (!oldAndNewIdentical)
        {
            assertValid();
            Debug.assertion (getWriteability_Phone () != FieldWriteability.FALSE, "Field  Phone is not writeable");
            prePhoneChange (newPhone);
            markFieldChange (FIELD_Phone);
            _Phone = newPhone;            
            postFieldChange (FIELD_Phone);
            postPhoneChange ();
        }
    }



    /**
     * A list of multi assoc names e.g. list of strings.
     */
    public List<String> getSingleAssocs()
    {
        List result = super.getSingleAssocs ();

        
        result.add("Company");
        

        return result;
    }
    
    
    public BaseBusinessClass getSingleAssocReferenceInstance (String assocName)
    {
        if (assocName == null)
        {
            throw new RuntimeException ("Game over == null!");
        }
        else if (assocName.equals (SINGLEREFERENCE_Company))
        {
            return _Company.getReferencedType ();
        }
        else
        {
            return super.getSingleAssocReferenceInstance (assocName);
        }
    }


    public String getSingleAssocBackReference(String assocName)
    {
        if (assocName == null)
        {
            throw new RuntimeException ("Game over == null!");
        }
        else if (assocName.equals (SINGLEREFERENCE_Company))
        {
            return Company.MULTIPLEREFERENCE_Users ;
        }
        else
        {
            return super.getSingleAssocBackReference (assocName);
        }
    }
    
    
    public BaseBusinessClass getSingleAssoc (String assocName) throws StorageException
    {
        if (assocName == null)
        {
            throw new RuntimeException ("Game over == null!");
        }
        else if (assocName.equals (SINGLEREFERENCE_Company))
        {
            return getCompany ();
        }
        else
        {
            return super.getSingleAssoc (assocName);
        }
    }


    public BaseBusinessClass getSingleAssoc (String assocName, Get getType) throws StorageException
    {
        if (assocName == null)
        {
            throw new RuntimeException ("Game over == null!");
        }
        else if (assocName.equals (SINGLEREFERENCE_Company))
        {
            return getCompany (getType);
        }
        else
        {
            return super.getSingleAssoc (assocName, getType);
        }
    }


    public Long getSingleAssocID (String assocName) throws StorageException
    {
        if (assocName == null)
        {
            throw new RuntimeException ("Game over == null!");
        }
        else if (assocName.equals (SINGLEREFERENCE_Company))
        {
            return getCompanyID ();
        }
        else
        {
            return super.getSingleAssocID (assocName);
        }
    }


    public void setSingleAssoc (String assocName, BaseBusinessClass newValue) throws StorageException, FieldException
    {
        if (assocName == null)
        {
            throw new RuntimeException ("Game over == null!");
        }
        else if (assocName.equals (SINGLEREFERENCE_Company))
        {
            setCompany ((Company)(newValue));
        }
        else
        {
            super.setSingleAssoc (assocName, newValue);
        }
    }



    /**
     * Get the reference Company
     */
    public Company getCompany () throws StorageException
    {
        assertValid();
        
        try
        {
            return (Company)(_Company.get ());
        }
        catch (ClassCastException e)
        {
            LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR2, "Cache collision in CompanyUser:", this.getObjectID (), ", was trying to get Company:",  getCompanyID ());
            LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR2, "Instead I got:", _Company.get ().getClass ());
            throw e;
        }
    }


    /**
     * Get the object id for the referenced object.  Does not force a DB access.
     */
    public Company getCompany (Get getType) throws StorageException
    {
        assertValid();
        return _Company.get(getType);
    }


    /**
     * Get the object id for the referenced object.  Does not force a DB access.
     */
    public Long getCompanyID ()
    {
        assertValid();
        
        if (_Company == null)
        {
            return null;
        }
        else
        {
            return _Company.getID ();
        }
    }

    /**
     * Called prior to the assoc changing.  Subclasses need not call super.  If a field exception
     * is thrown, the attribute change will fail.  The new value is different to the old value.
     */
    protected void preCompanyChange (Company newCompany) throws FieldException
    {
    }


    /**
     * Called after the assoc changes.
     * If a field exception is thrown, the value is still changed, however it 
     * may lead to the TX being rolled back
     */
    protected void postCompanyChange () throws FieldException
    {
    }



    
    public FieldWriteability getWriteability_Company ()
    {
        return getFieldWritabilityUtil (FieldWriteability.TRUE);
    }
    
    
    /**
     * Set the reference Company.  Checks to ensure a new value
     * has been supplied.  If so, marks the reference as altered and sets it.
     */
    public void setCompany (Company newCompany) throws StorageException, FieldException
    {
        

        if (_Company.wouldReferencedChange (newCompany))
        {
            assertValid();
            Debug.assertion (getWriteability_Company () != FieldWriteability.FALSE, "Assoc Company is not writeable");
            preCompanyChange (newCompany);
            Company oldCompany = getCompany ();

                    if (oldCompany != null)
                    {
                        // This is to stop validation from triggering when we are removed
                        _Company.set (null);
                        oldCompany.removeFromUsers ((CompanyUser)(this));
                    }

                    _Company.set (newCompany);

                    if (newCompany != null)
                    {
                        newCompany.addToUsers ((CompanyUser)(this));
                    }
                
            postCompanyChange ();
        }
    }

    /**
     * A list of multi assoc names e.g. list of strings.
     */
    public List<String> getMultiAssocs()
    {
        List result = super.getMultiAssocs ();

        

        return result;
    }


    /**
     * Get the reference instance for the multi assoc name.
     */
    public BaseBusinessClass getMultiAssocReferenceInstance(String attribName)
    {
        

        return super.getMultiAssocReferenceInstance(attribName);
    }


    public String getMultiAssocBackReference(String attribName)
    {
        

        return super.getMultiAssocBackReference(attribName);
    }


    /**
     * Get the assoc count for the multi assoc name.
     */
    public int getMultiAssocCount(String attribName) throws StorageException
    {
        

        return super.getMultiAssocCount(attribName);
    }


    /**
     * Get the assoc at a particular index
     */
    public BaseBusinessClass getMultiAssocAt(String attribName, int index) throws StorageException
    {
        

        return super.getMultiAssocAt(attribName, index);
    }


    /**
     * Add to a multi assoc by attribute name
     */
    public void addToMultiAssoc(String attribName, BaseBusinessClass newElement) throws StorageException
    {
        

        super.addToMultiAssoc(attribName, newElement);
    }

    /**
     * Remove from a multi assoc by attribute name
     */
    public void removeFromMultiAssoc(String attribName, BaseBusinessClass oldElement) throws StorageException
    {
        

        super.removeFromMultiAssoc(attribName, oldElement);
    }


    protected void __loadMultiAssoc (String attribName, BaseBusinessClass[] elements)
    {
        

        super.__loadMultiAssoc(attribName, elements);
    }


    protected boolean __isMultiAssocLoaded (String attribName)
    {
        

        return super.__isMultiAssocLoaded(attribName);
    }

    



    public void onDelete ()
    {
        try 
        {
            // Ensure we are removed from any loaded multi-associations that aren't mandatory
            if (_Company.isLoaded () || getTransaction ().isObjectLoaded (_Company.getReferencedType (), getCompanyID ()))
            {
                Company  referenced = getCompany ();

                if (referenced != null)
                {
                    // Stop the callback
                    LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Setting backreference to null Users from ", getObjectID (), " to ", referenced.getObjectID ());
                    _Company.set (null);
                    referenced.removeFromUsers ((CompanyUser)this);
                }
            }
        
        }
        catch (Exception e)
        {
            throw NestedException.wrap(e);
        }

        super.onDelete ();
    }


    public CompanyUser newInstance ()
    {
        return new CompanyUser ();
    }


    public CompanyUser referenceInstance ()
    {
        return REFERENCE_CompanyUser;
    }


    public CompanyUser getInTransaction (ObjectTransaction t) throws StorageException
    {
        return getCompanyUserByID (t, getObjectID());
    }
    
    
    public BaseBusinessClass dummyInstance ()
    {
        return DUMMY_CompanyUser;
    }


    public String getBaseSetName ()
    {
        return "oneit_sec_user_extension";
    }





    /**
     * This is where an object returns the Persistent sets that will
     * store it into the database.
     * The should be entered into allSets
     */
    public void getPersistentSets (PersistentSetCollection allSets)
    {
        ObjectStatus        myStatus = getStatus ();
        PersistentSetStatus myPSetStatus = myStatus.getPSetStatus();
        ObjectID            myID = getID();

        super.getPersistentSets (allSets);

        
        PersistentSet   oneit_sec_user_extensionPSet = allSets.getPersistentSet (myID, "oneit_sec_user_extension", myPSetStatus);

        oneit_sec_user_extensionPSet.setAttrib (FIELD_ObjectID, myID);
        oneit_sec_user_extensionPSet.setAttrib (FIELD_ForgotPasswordMailSendDate, HELPER_ForgotPasswordMailSendDate.toObject (_ForgotPasswordMailSendDate)); //
        oneit_sec_user_extensionPSet.setAttrib (FIELD_ForgotPasswordKey, HELPER_ForgotPasswordKey.toObject (_ForgotPasswordKey)); //
        oneit_sec_user_extensionPSet.setAttrib (FIELD_Role, HELPER_Role.toObject (_Role)); //
        oneit_sec_user_extensionPSet.setAttrib (FIELD_Phone, HELPER_Phone.toObject (_Phone)); //
        _Company.getPersistentSets (allSets);
        
    }


    /**
     * Sets the objects state based on Persistent sets.
     */
    public void setFromPersistentSets (ObjectID objectID, PersistentSetCollection allSets)
    {
        super.setFromPersistentSets (objectID, allSets);

        
        PersistentSet   oneit_sec_user_extensionPSet = allSets.getPersistentSet (objectID, "oneit_sec_user_extension");

        _ForgotPasswordMailSendDate = (Date)(HELPER_ForgotPasswordMailSendDate.fromObject (_ForgotPasswordMailSendDate, oneit_sec_user_extensionPSet.getAttrib (FIELD_ForgotPasswordMailSendDate))); //
        _ForgotPasswordKey = (String)(HELPER_ForgotPasswordKey.fromObject (_ForgotPasswordKey, oneit_sec_user_extensionPSet.getAttrib (FIELD_ForgotPasswordKey))); //
        _Role = (RoleType)(HELPER_Role.fromObject (_Role, oneit_sec_user_extensionPSet.getAttrib (FIELD_Role))); //
        _Phone = (String)(HELPER_Phone.fromObject (_Phone, oneit_sec_user_extensionPSet.getAttrib (FIELD_Phone))); //
        _Company.setFromPersistentSets (objectID, allSets);
        
    }





    public void setAttributesFrom (BaseBusinessClass other, MultiException e)
    {
        super.setAttributesFrom (other, e);

        if (other instanceof CompanyUser)
        {
            CompanyUser otherCompanyUser = (CompanyUser)other;
            
            try
            {
                setForgotPasswordMailSendDate (otherCompanyUser.getForgotPasswordMailSendDate ());
            }
            catch (FieldException ex)
            {
                e.addException (ex);
            }
            
            try
            {
                setForgotPasswordKey (otherCompanyUser.getForgotPasswordKey ());
            }
            catch (FieldException ex)
            {
                e.addException (ex);
            }
            
            try
            {
                setRole (otherCompanyUser.getRole ());
            }
            catch (FieldException ex)
            {
                e.addException (ex);
            }
            
            try
            {
                setPhone (otherCompanyUser.getPhone ());
            }
            catch (FieldException ex)
            {
                e.addException (ex);
            }
            
        }
    }


    /**
     * Set the attributes in this to copies of the attributes in source.
     */
    public void copyAttributesFrom (BaseBusinessClass source)
    {
        super.copyAttributesFrom (source);

        if (source instanceof BaseCompanyUser)
        {
            BaseCompanyUser sourceCompanyUser = (BaseCompanyUser)(source);

            _ForgotPasswordMailSendDate = sourceCompanyUser._ForgotPasswordMailSendDate;
            _ForgotPasswordKey = sourceCompanyUser._ForgotPasswordKey;
            _Role = sourceCompanyUser._Role;
            _Phone = sourceCompanyUser._Phone;
            
        }
    }


    /**
     * Set the associations in this to copies of the attributes in source.
     */
    public void copySingleAssociationsFrom (BaseBusinessClass source, boolean linkToGhosts)
    {
        super.copySingleAssociationsFrom (source, linkToGhosts);

        if (source instanceof BaseCompanyUser)
        {
            BaseCompanyUser sourceCompanyUser = (BaseCompanyUser)(source);

            _Company.copyFrom (sourceCompanyUser._Company, linkToGhosts);
            
        }
    }


    /**
     * Set the associations in this to copies of the attributes in source.
     */
    public void copyAssociationsFrom (BaseBusinessClass source, boolean linkToGhosts)
    {
        super.copyAssociationsFrom (source, linkToGhosts);

        if (source instanceof BaseCompanyUser)
        {
            BaseCompanyUser sourceCompanyUser = (BaseCompanyUser)(source);

            
        }
    }


    public void validate (ValidationContext context)
    {
        super.validate (context);

        
    }


    /**
     * Subclasses must override this to read in their attributes
     */
    protected void readExternalData(Map<String, Object> vals) throws IOException, ClassNotFoundException
    {
        super.readExternalData(vals);

        _ForgotPasswordMailSendDate = (Date)(HELPER_ForgotPasswordMailSendDate.readExternal (_ForgotPasswordMailSendDate, vals.get(FIELD_ForgotPasswordMailSendDate))); //
        _ForgotPasswordKey = (String)(HELPER_ForgotPasswordKey.readExternal (_ForgotPasswordKey, vals.get(FIELD_ForgotPasswordKey))); //
        _Role = (RoleType)(HELPER_Role.readExternal (_Role, vals.get(FIELD_Role))); //
        _Phone = (String)(HELPER_Phone.readExternal (_Phone, vals.get(FIELD_Phone))); //
        _Company.readExternalData(vals.get(SINGLEREFERENCE_Company));
        
    }


    /**
     * Subclasses must override this to write out their attributes
     */
    protected void writeExternalData(Map<String, Object> vals) throws IOException
    {
        super.writeExternalData(vals);

        vals.put (FIELD_ForgotPasswordMailSendDate, HELPER_ForgotPasswordMailSendDate.writeExternal (_ForgotPasswordMailSendDate));
        vals.put (FIELD_ForgotPasswordKey, HELPER_ForgotPasswordKey.writeExternal (_ForgotPasswordKey));
        vals.put (FIELD_Role, HELPER_Role.writeExternal (_Role));
        vals.put (FIELD_Phone, HELPER_Phone.writeExternal (_Phone));
        vals.put (SINGLEREFERENCE_Company, _Company.writeExternalData());
        
    }


    public void compare (BaseBusinessClass other, AttributeChangeListener listener) throws StorageException
    {
        super.compare (other, listener);

        if (other instanceof BaseCompanyUser)
        {
            BaseCompanyUser otherCompanyUser = (BaseCompanyUser)(other);

            
            if (!HELPER_ForgotPasswordMailSendDate.compare(this._ForgotPasswordMailSendDate, otherCompanyUser._ForgotPasswordMailSendDate))
            {
                listener.notifyFieldChange(this, other, FIELD_ForgotPasswordMailSendDate, HELPER_ForgotPasswordMailSendDate.toObject(this._ForgotPasswordMailSendDate), HELPER_ForgotPasswordMailSendDate.toObject(otherCompanyUser._ForgotPasswordMailSendDate));
            }
            if (!HELPER_ForgotPasswordKey.compare(this._ForgotPasswordKey, otherCompanyUser._ForgotPasswordKey))
            {
                listener.notifyFieldChange(this, other, FIELD_ForgotPasswordKey, HELPER_ForgotPasswordKey.toObject(this._ForgotPasswordKey), HELPER_ForgotPasswordKey.toObject(otherCompanyUser._ForgotPasswordKey));
            }
            if (!HELPER_Role.compare(this._Role, otherCompanyUser._Role))
            {
                listener.notifyFieldChange(this, other, FIELD_Role, HELPER_Role.toObject(this._Role), HELPER_Role.toObject(otherCompanyUser._Role));
            }
            if (!HELPER_Phone.compare(this._Phone, otherCompanyUser._Phone))
            {
                listener.notifyFieldChange(this, other, FIELD_Phone, HELPER_Phone.toObject(this._Phone), HELPER_Phone.toObject(otherCompanyUser._Phone));
            }

            // Compare single assocs
            _Company.compare (otherCompanyUser._Company, listener);
            

            // Compare multiple assocs
            
        }
    }


    public void visitTransients (AttributeVisitor visitor) throws StorageException
    {
        super.visitAttributes (visitor);

        
    }


    public void visitAttributes (AttributeVisitor visitor) throws StorageException
    {
        super.visitAttributes (visitor);

        visitor.visitField(this, FIELD_ForgotPasswordMailSendDate, HELPER_ForgotPasswordMailSendDate.toObject(getForgotPasswordMailSendDate()));
        visitor.visitField(this, FIELD_ForgotPasswordKey, HELPER_ForgotPasswordKey.toObject(getForgotPasswordKey()));
        visitor.visitField(this, FIELD_Role, HELPER_Role.toObject(getRole()));
        visitor.visitField(this, FIELD_Phone, HELPER_Phone.toObject(getPhone()));
        visitor.visitAssociation (_Company);
        
    }


    public void visitAssociations (AssociationVisitor visitor, AssociatedScope scope) throws StorageException
    {
        super.visitAssociations (visitor, scope);

        if (scope.includes (_Company))
        {
            visitor.visit (_Company);
        }
        
    }


    public static CompanyUser createCompanyUser (ObjectTransaction transaction) throws StorageException
    {
        CompanyUser     result = new CompanyUser ();

        result.initialiseNewObject (transaction);

        return result;
    }


    public static CompanyUser getCompanyUserByID (ObjectTransaction transaction, Long objectID) throws StorageException
    {
        return (CompanyUser)(transaction.getObjectByID (REFERENCE_CompanyUser, objectID));
    }

    public boolean testFilter (String attribName, QueryFilter filter) throws StorageException
    {
        if (false)
        {
            throw new RuntimeException ("Game over man!!");
        }
        else if (attribName.equals (FIELD_ForgotPasswordMailSendDate))
        {
            return filter.matches (getForgotPasswordMailSendDate ());
        }
        else if (attribName.equals (FIELD_ForgotPasswordKey))
        {
            return filter.matches (getForgotPasswordKey ());
        }
        else if (attribName.equals (FIELD_Role))
        {
            return filter.matches (getRole ());
        }
        else if (attribName.equals (FIELD_Phone))
        {
            return filter.matches (getPhone ());
        }
        else if (attribName.equals (SINGLEREFERENCE_Company))
        {
            return filter.matches (getCompany ());
        }
        else
        {
            return super.testFilter (attribName, filter);
        }
    }


    public static SearchAll SearchByAll () { return new SearchAll (); }

    public static class SearchAll extends SearchObject<CompanyUser>
    {
        
            public SearchAll andObjectID (QueryFilter<Long> filter)
            {
                filter.addFilter (context, "oneit_sec_user_extension.object_id", FIELD_ObjectID);
                return this;
            }

            public SearchAll andObjectCreated (QueryFilter<Date> filter)
            {
                filter.addFilter (context, "oneit_sec_user_extension.object_created_date", FIELD_ObjectCreated);
                return this;
            }

            public SearchAll andObjectLastModified (QueryFilter<Date> filter)
            {
                filter.addFilter (context, "oneit_sec_user_extension.object_last_updated_date", FIELD_ObjectLastModified);
                return this;
            }

            
            public SearchAll andForgotPasswordMailSendDate (QueryFilter<Date> filter)
            {
                filter.addFilter (context, "oneit_sec_user_extension.forgot_password_mail_send_date", "ForgotPasswordMailSendDate");
                return this;
            }
            
            public SearchAll andForgotPasswordKey (QueryFilter<String> filter)
            {
                filter.addFilter (context, "oneit_sec_user_extension.forgot_password_key", "ForgotPasswordKey");
                return this;
            }
            
            public SearchAll andRole (QueryFilter<RoleType> filter)
            {
                filter.addFilter (context, "oneit_sec_user_extension.role_type", "Role");
                return this;
            }
            
            public SearchAll andPhone (QueryFilter<String> filter)
            {
                filter.addFilter (context, "oneit_sec_user_extension.phone", "Phone");
                return this;
            }
            
            public SearchAll andUser (QueryFilter<SecUser> filter)
            {
                filter.addFilter (context, "oneit_sec_user_extension.user_id", "User");
                return this;
            }
            
            public SearchAll andCompany (QueryFilter<Company> filter)
            {
                filter.addFilter (context, "oneit_sec_user_extension.company_id", "Company");
                return this;
            }
            
                public CompanyUser[]
             search (ObjectTransaction transaction) throws StorageException
        {
            
            
            BaseBusinessClass[]     results = super.search (transaction, REFERENCE_CompanyUser, SEARCH_All, criteria);
            Set<CompanyUser>   typedResults = new LinkedHashSet <CompanyUser> ();
            for (BaseBusinessClass bbcResult : results)
            {
                CompanyUser aResult = (CompanyUser)bbcResult;
                
                typedResults.add (aResult);
            }
            
                    return ObjstoreUtils.removeDeleted(transaction, typedResults).toArray (new CompanyUser[0]);
                            
        }
    }

        
                public static CompanyUser[]
             searchAll (ObjectTransaction transaction) throws StorageException
        {
            return SearchByAll ()
            .search (transaction);
        }



    public Object getAttribute (String attribName)
    {
        if (false)
        {
            throw new RuntimeException ("Game over man!!");
        }
        else if (attribName.equals (FIELD_ForgotPasswordMailSendDate))
        {
            return HELPER_ForgotPasswordMailSendDate.toObject (getForgotPasswordMailSendDate ());
        }
        else if (attribName.equals (FIELD_ForgotPasswordKey))
        {
            return HELPER_ForgotPasswordKey.toObject (getForgotPasswordKey ());
        }
        else if (attribName.equals (FIELD_Role))
        {
            return HELPER_Role.toObject (getRole ());
        }
        else if (attribName.equals (FIELD_Phone))
        {
            return HELPER_Phone.toObject (getPhone ());
        }
        else
        {
            return super.getAttribute (attribName);
        }
    }


    public AttributeHelper getAttributeHelper (String attribName)
    {
        if (false)
        {
            throw new RuntimeException ("Game over man!!");
        }
        else if (attribName.equals (FIELD_ForgotPasswordMailSendDate))
        {
            return HELPER_ForgotPasswordMailSendDate;
        }
        else if (attribName.equals (FIELD_ForgotPasswordKey))
        {
            return HELPER_ForgotPasswordKey;
        }
        else if (attribName.equals (FIELD_Role))
        {
            return HELPER_Role;
        }
        else if (attribName.equals (FIELD_Phone))
        {
            return HELPER_Phone;
        }
        else
        {
            return super.getAttributeHelper (attribName);
        }
    }


    public void setAttribute (String attribName, Object attribValue) throws FieldException
    {
        if (false)
        {
            throw new RuntimeException ("Game over man!!");
        }
        else if (attribName.equals (FIELD_ForgotPasswordMailSendDate))
        {
            setForgotPasswordMailSendDate ((Date)(HELPER_ForgotPasswordMailSendDate.fromObject (_ForgotPasswordMailSendDate, attribValue)));            
        }
        else if (attribName.equals (FIELD_ForgotPasswordKey))
        {
            setForgotPasswordKey ((String)(HELPER_ForgotPasswordKey.fromObject (_ForgotPasswordKey, attribValue)));            
        }
        else if (attribName.equals (FIELD_Role))
        {
            setRole ((RoleType)(HELPER_Role.fromObject (_Role, attribValue)));            
        }
        else if (attribName.equals (FIELD_Phone))
        {
            setPhone ((String)(HELPER_Phone.fromObject (_Phone, attribValue)));            
        }
        else
        {
            super.setAttribute (attribName, attribValue);
        }
    }



    public boolean isWriteable (String fieldName)
    {
        return getWriteable (fieldName) == FieldWriteability.TRUE;
    }


    public FieldWriteability getWriteable (String fieldName)
    {
        if (false)
        {
            throw new RuntimeException ("Game over man!!");
        }
        else if (fieldName.equals (FIELD_ForgotPasswordMailSendDate))
        {
            return getWriteability_ForgotPasswordMailSendDate ();
        }
        else if (fieldName.equals (FIELD_ForgotPasswordKey))
        {
            return getWriteability_ForgotPasswordKey ();
        }
        else if (fieldName.equals (FIELD_Role))
        {
            return getWriteability_Role ();
        }
        else if (fieldName.equals (FIELD_Phone))
        {
            return getWriteability_Phone ();
        }
        else if (fieldName.equals (SINGLEREFERENCE_Company))
        {
            return getWriteability_Company ();
        }
        else
        {
            return super.getWriteable (fieldName);
        }
    }


    public void putUnwriteable (Set<String> fields)
    {
        
            if (getWriteability_ForgotPasswordMailSendDate () != FieldWriteability.TRUE)
            {
                fields.add (FIELD_ForgotPasswordMailSendDate);
            }
        
            if (getWriteability_ForgotPasswordKey () != FieldWriteability.TRUE)
            {
                fields.add (FIELD_ForgotPasswordKey);
            }
        
            if (getWriteability_Role () != FieldWriteability.TRUE)
            {
                fields.add (FIELD_Role);
            }
        
            if (getWriteability_Phone () != FieldWriteability.TRUE)
            {
                fields.add (FIELD_Phone);
            }
        

        super.putUnwriteable (fields);
    }

    public List<AbstractAttribute> getAttributes ()
    {
        List result = super.getAttributes ();

        
        result.add(HELPER_ForgotPasswordMailSendDate.getAttribObject (getClass (), _ForgotPasswordMailSendDate, false, FIELD_ForgotPasswordMailSendDate));
        result.add(HELPER_ForgotPasswordKey.getAttribObject (getClass (), _ForgotPasswordKey, false, FIELD_ForgotPasswordKey));
        result.add(HELPER_Role.getAttribObject (getClass (), _Role, false, FIELD_Role));
        result.add(HELPER_Phone.getAttribObject (getClass (), _Phone, false, FIELD_Phone));

        return result;
    }


    public Map getAttributeMetadata (String attribute)
    {
        if (ATTRIBUTES_METADATA_CompanyUser.containsKey (attribute))
        {
            return (Map)ATTRIBUTES_METADATA_CompanyUser.get (attribute);
        }
        else
        {
            return super.getAttributeMetadata (attribute);
        }
    }


    public Object getAttributeMetadata (String attribute, String metadata)
    {
        if (ATTRIBUTES_METADATA_CompanyUser.containsKey (attribute))
        {
            return ((Map)ATTRIBUTES_METADATA_CompanyUser.get (attribute)).get(metadata);
        }
        else
        {
            return super.getAttributeMetadata (attribute, metadata);
        }
    }

    public void preCommit (boolean willBeStored) throws Exception
    {
        super.preCommit(willBeStored);
        
        if(willBeStored)
        {
        
        }
    }

    public oneit.servlets.objstore.binary.BinaryContentHandler getBinaryContentHandler(String attribName)
    {
        
        
        return super.getBinaryContentHandler(attribName);
    }

    public static class CompanyUserBehaviourDecorator extends BaseBusinessClass.BBCBehaviourDecorator<CompanyUser>
    {

    /**
     * Get the attribute ForgotPasswordMailSendDate
     */
    public Date getForgotPasswordMailSendDate (CompanyUser obj, Date original)
    {
        return original;
    }

    /**
     * Change the value set for attribute ForgotPasswordMailSendDate.
     * May modify the field beforehand
     * Occurs before validation.
     */
    public Date setForgotPasswordMailSendDate (CompanyUser obj, Date newForgotPasswordMailSendDate) throws FieldException
    {
        return newForgotPasswordMailSendDate;
    }

    /**
     * Get the attribute ForgotPasswordKey
     */
    public String getForgotPasswordKey (CompanyUser obj, String original)
    {
        return original;
    }

    /**
     * Change the value set for attribute ForgotPasswordKey.
     * May modify the field beforehand
     * Occurs before validation.
     */
    public String setForgotPasswordKey (CompanyUser obj, String newForgotPasswordKey) throws FieldException
    {
        return newForgotPasswordKey;
    }

    /**
     * Get the attribute Role
     */
    public RoleType getRole (CompanyUser obj, RoleType original)
    {
        return original;
    }

    /**
     * Change the value set for attribute Role.
     * May modify the field beforehand
     * Occurs before validation.
     */
    public RoleType setRole (CompanyUser obj, RoleType newRole) throws FieldException
    {
        return newRole;
    }

    /**
     * Get the attribute Phone
     */
    public String getPhone (CompanyUser obj, String original)
    {
        return original;
    }

    /**
     * Change the value set for attribute Phone.
     * May modify the field beforehand
     * Occurs before validation.
     */
    public String setPhone (CompanyUser obj, String newPhone) throws FieldException
    {
        return newPhone;
    }

    }

    
    public ORMPipeLine pipes()
    {
        return new CompanyUserPipeLineFactory<CompanyUser, CompanyUser> ((CompanyUser)this);
    }
      
    /**
     * Use this instead of pipes() to get rid of type casting.
     */  
    public CompanyUserPipeLineFactory<CompanyUser, CompanyUser> pipelineCompanyUser()
    {
        return (CompanyUserPipeLineFactory<CompanyUser, CompanyUser>) pipes();
    }
    
    public static CompanyUserPipeLineFactory<CompanyUser, CompanyUser> pipesCompanyUser(Collection<CompanyUser> items)
    {
        return REFERENCE_CompanyUser.new CompanyUserPipeLineFactory<CompanyUser, CompanyUser> (items);
    }
    
    public static CompanyUserPipeLineFactory<CompanyUser, CompanyUser> pipesCompanyUser(CompanyUser[] _items)
    {
        return pipesCompanyUser(Arrays.asList (_items));
    }
    
    public static CompanyUserPipeLineFactory<CompanyUser, CompanyUser> pipesCompanyUser()
    {
        return pipesCompanyUser((Collection)null);
    }
    
    
    public class CompanyUserPipeLineFactory<From extends BaseBusinessClass, Me extends CompanyUser> extends SecUserExtensionPipeLineFactory<From, Me>    
    {
        public <Prev> CompanyUserPipeLineFactory (PipeLine<From, Prev> pipeLine, Pipe<Prev, Me> nextPipe)
        {
            super (pipeLine, nextPipe);
        }
        
        public CompanyUserPipeLineFactory (From seed)
        {
            super(seed);
        }

        public CompanyUserPipeLineFactory (Collection<From> seed)
        {
            super(seed);
        }
        
        
        public PipeLine<From, ? extends Object> to(String name)
        {
            if (name.equals ("ForgotPasswordMailSendDate"))
            {
                return toForgotPasswordMailSendDate ();
            }                
            if (name.equals ("ForgotPasswordKey"))
            {
                return toForgotPasswordKey ();
            }                
            if (name.equals ("Role"))
            {
                return toRole ();
            }                
            if (name.equals ("Phone"))
            {
                return toPhone ();
            }                
            if (name.equals ("Company"))
            {
                return toCompany ();
            }                
            
            
            return super.to(name);
        }
        
        
        public PipeLine<From, Date> toForgotPasswordMailSendDate () { return pipe(new ORMAttributePipe<Me, Date>(FIELD_ForgotPasswordMailSendDate));  }
        
        public PipeLine<From, String> toForgotPasswordKey () { return pipe(new ORMAttributePipe<Me, String>(FIELD_ForgotPasswordKey));  }
        
        public PipeLine<From, RoleType> toRole () { return pipe(new ORMAttributePipe<Me, RoleType>(FIELD_Role));  }
        
        public PipeLine<From, String> toPhone () { return pipe(new ORMAttributePipe<Me, String>(FIELD_Phone));  }
        public Company.CompanyPipeLineFactory<From, Company> toCompany () { return toCompany (Filter.ALL); }

        public Company.CompanyPipeLineFactory<From, Company> toCompany (Filter<Company> filter) 
        { 
            return Company.REFERENCE_Company.new CompanyPipeLineFactory<From, Company> (this, new ORMSingleAssocPipe<Me, Company>(SINGLEREFERENCE_Company, filter)); 
        }
        
    }
    
    public boolean isTransientAttrib(String attribName)
    {
        

        return super.isTransientAttrib(attribName);
    }

    public boolean isTransientSingleReference(String assocName)
    {
        

        return super.isTransientSingleReference(assocName);
    }
}

class DummyCompanyUser extends CompanyUser
{
    // Default constructor primarily to support Externalisable
    public DummyCompanyUser()
    {
        super();
    }

    public void assertValid ()
    {
    }


    public Company getCompany () throws StorageException
    {
        return (Company)(Company.DUMMY_Company);
    }


    /**
     * Get the object id for the referenced object.  Does not force a DB access.
     */
    public Long getCompanyID ()
    {
        return Company.DUMMY_Company.getObjectID();
    }

}

    
