/*
 * 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.*;



public abstract class BaseCultureCriteriaTemplate extends BaseBusinessClass
{
    // Reference instance for the object
    public static final CultureCriteriaTemplate REFERENCE_CultureCriteriaTemplate = new CultureCriteriaTemplate ();

    // Reference instance for the object
    public static final CultureCriteriaTemplate DUMMY_CultureCriteriaTemplate = new DummyCultureCriteriaTemplate ();

    // Static constants corresponding to field names
    
    public static final String FIELD_TemplateName = "TemplateName";
    public static final String FIELD_CultureStatement = "CultureStatement";
    public static final String SINGLEREFERENCE_Client = "Client";
    public static final String SINGLEREFERENCE_HiringTeam = "HiringTeam";
    public static final String SINGLEREFERENCE_CompanyUser = "CompanyUser";
    public static final String MULTIPLEREFERENCE_CultureCriterias = "CultureCriterias";
    public static final String BACKREF_CultureCriterias = "";

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

    // Static constants corresponding to attribute helpers
    private static final DefaultAttributeHelper<CultureCriteriaTemplate> HELPER_TemplateName = DefaultAttributeHelper.INSTANCE;
    private static final DefaultAttributeHelper<CultureCriteriaTemplate> HELPER_CultureStatement = DefaultAttributeHelper.INSTANCE;
    

    // Private attributes corresponding to business object data
    private String _TemplateName;
    private String _CultureStatement;
    

    // Private attributes corresponding to single references
    private SingleAssociation<CultureCriteriaTemplate, Client> _Client;
    private SingleAssociation<CultureCriteriaTemplate, HiringTeam> _HiringTeam;
    private SingleAssociation<CultureCriteriaTemplate, CompanyUser> _CompanyUser;
    

    // Private attributes corresponding to multiple references
    private MultipleAssociation<CultureCriteriaTemplate, CultureCriteria> _CultureCriterias;
    

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

    // Arrays of validators for each attribute
    private static final AttributeValidator[] FIELD_TemplateName_Validators;
    private static final AttributeValidator[] FIELD_CultureStatement_Validators;
    

    // Arrays of behaviour decorators
    private static final CultureCriteriaTemplateBehaviourDecorator[] CultureCriteriaTemplate_BehaviourDecorators;
    
    static
    {
        try
        {
            
            String tmp_CultureCriterias = CultureCriteria.BACKREF_Template;
            
            Map  validatorMapping = ((Map)ConfigMgr.getConfigObject ("CONFIG.ORMVALIDATOR", "ValidatorMapping"));

            setupAssocMetaData_CultureCriterias();
            setupAssocMetaData_Client();
            setupAssocMetaData_HiringTeam();
            setupAssocMetaData_CompanyUser();
            FIELD_TemplateName_Validators = (AttributeValidator[])setupAttribMetaData_TemplateName(validatorMapping).toArray (new AttributeValidator[0]);
            FIELD_CultureStatement_Validators = (AttributeValidator[])setupAttribMetaData_CultureStatement(validatorMapping).toArray (new AttributeValidator[0]);
            

            REFERENCE_CultureCriteriaTemplate.initialiseReference ();
            DUMMY_CultureCriteriaTemplate.initialiseReference ();
            CultureCriteriaTemplate_BehaviourDecorators = BaseBusinessClass.getBBCBehaviours(CultureCriteriaTemplate.class).toArray(new CultureCriteriaTemplateBehaviourDecorator[0]);
        }
        catch (RuntimeException e)
        {
            LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR1, e, "Error initialising");
            throw e;
        }
    }

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

        metaInfo.put ("backreferenceName", "Template");
        metaInfo.put ("name", "CultureCriterias");
        metaInfo.put ("type", "CultureCriteria");
        
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for CultureCriteriaTemplate.CultureCriterias:", metaInfo);
        ATTRIBUTES_METADATA_CultureCriteriaTemplate.put (MULTIPLEREFERENCE_CultureCriterias, Collections.unmodifiableMap (metaInfo));
    }
    
    
    // Meta Info setup
    private static void setupAssocMetaData_Client()
    {
        Map metaInfo = new HashMap ();

        metaInfo.put ("dbcol", "client_id");
        metaInfo.put ("name", "Client");
        metaInfo.put ("type", "Client");
        
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for CultureCriteriaTemplate.Client:", metaInfo);
        ATTRIBUTES_METADATA_CultureCriteriaTemplate.put (SINGLEREFERENCE_Client, Collections.unmodifiableMap (metaInfo));
    }
    
    
    // Meta Info setup
    private static void setupAssocMetaData_HiringTeam()
    {
        Map metaInfo = new HashMap ();

        metaInfo.put ("dbcol", "hiring_team_id");
        metaInfo.put ("name", "HiringTeam");
        metaInfo.put ("type", "HiringTeam");
        metaInfo.put ("uniqueGroup", "TemplateID");
        
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for CultureCriteriaTemplate.HiringTeam:", metaInfo);
        ATTRIBUTES_METADATA_CultureCriteriaTemplate.put (SINGLEREFERENCE_HiringTeam, Collections.unmodifiableMap (metaInfo));
    }
    
    
    // Meta Info setup
    private static void setupAssocMetaData_CompanyUser()
    {
        Map metaInfo = new HashMap ();

        metaInfo.put ("dbcol", "company_user_id");
        metaInfo.put ("name", "CompanyUser");
        metaInfo.put ("type", "CompanyUser");
        metaInfo.put ("uniqueGroup", "TemplateID");
        
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for CultureCriteriaTemplate.CompanyUser:", metaInfo);
        ATTRIBUTES_METADATA_CultureCriteriaTemplate.put (SINGLEREFERENCE_CompanyUser, Collections.unmodifiableMap (metaInfo));
    }
    
    
    // Meta Info setup
    private static List setupAttribMetaData_TemplateName(Map validatorMapping)
    {
        Map  metaInfo   = new HashMap ();

        metaInfo.put ("dbcol", "template_name");
        metaInfo.put ("length", "100");
        metaInfo.put ("name", "TemplateName");
        metaInfo.put ("type", "String");
        metaInfo.put ("uniqueGroup", "TemplateID");
        
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for CultureCriteriaTemplate.TemplateName:", metaInfo);
        ATTRIBUTES_METADATA_CultureCriteriaTemplate.put (FIELD_TemplateName, Collections.unmodifiableMap (metaInfo));

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

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

        metaInfo.put ("dbcol", "culture_statement");
        metaInfo.put ("length", "2000");
        metaInfo.put ("name", "CultureStatement");
        metaInfo.put ("type", "String");
        
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for CultureCriteriaTemplate.CultureStatement:", metaInfo);
        ATTRIBUTES_METADATA_CultureCriteriaTemplate.put (FIELD_CultureStatement, Collections.unmodifiableMap (metaInfo));

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

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


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


    


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

        
        _TemplateName = (String)(HELPER_TemplateName.initialise (_TemplateName));
        _CultureStatement = (String)(HELPER_CultureStatement.initialise (_CultureStatement));
    }


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

        _Client = new SingleAssociation<CultureCriteriaTemplate, Client> (this, SINGLEREFERENCE_Client, null, Client.REFERENCE_Client, "tl_culture_template");
        _HiringTeam = new SingleAssociation<CultureCriteriaTemplate, HiringTeam> (this, SINGLEREFERENCE_HiringTeam, null, HiringTeam.REFERENCE_HiringTeam, "tl_culture_template");
        _CompanyUser = new SingleAssociation<CultureCriteriaTemplate, CompanyUser> (this, SINGLEREFERENCE_CompanyUser, null, CompanyUser.REFERENCE_CompanyUser, "tl_culture_template");
        _CultureCriterias = new MultipleAssociation<CultureCriteriaTemplate, CultureCriteria> (this, MULTIPLEREFERENCE_CultureCriterias, CultureCriteria.SINGLEREFERENCE_Template, CultureCriteria.REFERENCE_CultureCriteria);
        
    }


    // Initialise the associations
    protected BaseBusinessClass initialiseReference ()
    {
        super.initialiseReference ();
        
        _Client = new SingleAssociation<CultureCriteriaTemplate, Client> (this, SINGLEREFERENCE_Client, null, Client.REFERENCE_Client, "tl_culture_template");
        _HiringTeam = new SingleAssociation<CultureCriteriaTemplate, HiringTeam> (this, SINGLEREFERENCE_HiringTeam, null, HiringTeam.REFERENCE_HiringTeam, "tl_culture_template");
        _CompanyUser = new SingleAssociation<CultureCriteriaTemplate, CompanyUser> (this, SINGLEREFERENCE_CompanyUser, null, CompanyUser.REFERENCE_CompanyUser, "tl_culture_template");
        _CultureCriterias = new MultipleAssociation<CultureCriteriaTemplate, CultureCriteria> (this, MULTIPLEREFERENCE_CultureCriterias, CultureCriteria.SINGLEREFERENCE_Template, CultureCriteria.REFERENCE_CultureCriteria);
        
        
        return this;
    }

    

    /**
     * Get the attribute TemplateName
     */
    public String getTemplateName ()
    {
        assertValid();
        String valToReturn = _TemplateName;

            for (CultureCriteriaTemplateBehaviourDecorator bhd : CultureCriteriaTemplate_BehaviourDecorators)
            {
                valToReturn = bhd.getTemplateName ((CultureCriteriaTemplate)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 preTemplateNameChange (String newTemplateName) 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 postTemplateNameChange () throws FieldException
    {
    }

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

    /**
     * Set the attribute TemplateName.  Checks to ensure a new value
     * has been supplied.  If so, marks the field as altered and sets the attribute.
     */
    public void setTemplateName (String newTemplateName) throws FieldException
    {
        boolean oldAndNewIdentical = HELPER_TemplateName.compare (_TemplateName, newTemplateName);
        
        try
        {
            for (CultureCriteriaTemplateBehaviourDecorator bhd : CultureCriteriaTemplate_BehaviourDecorators)
            {
                newTemplateName = bhd.setTemplateName ((CultureCriteriaTemplate)this, newTemplateName);
                oldAndNewIdentical = HELPER_TemplateName.compare (_TemplateName, newTemplateName);
            }

            

            if (FIELD_TemplateName_Validators.length > 0)
            {
                Object newTemplateNameObj = HELPER_TemplateName.toObject (newTemplateName);

                if (newTemplateNameObj != null)
                {
                    int     loopMax = FIELD_TemplateName_Validators.length;
                    Map     metadata = (Map)ATTRIBUTES_METADATA_CultureCriteriaTemplate.get (FIELD_TemplateName);

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

        if (!oldAndNewIdentical)
        {
            assertValid();
            Debug.assertion (getWriteability_TemplateName () != FieldWriteability.FALSE, "Field  TemplateName is not writeable");
            preTemplateNameChange (newTemplateName);
            markFieldChange (FIELD_TemplateName);
            _TemplateName = newTemplateName;            
            postFieldChange (FIELD_TemplateName);
            postTemplateNameChange ();
        }
    }

    /**
     * Get the attribute CultureStatement
     */
    public String getCultureStatement ()
    {
        assertValid();
        String valToReturn = _CultureStatement;

            for (CultureCriteriaTemplateBehaviourDecorator bhd : CultureCriteriaTemplate_BehaviourDecorators)
            {
                valToReturn = bhd.getCultureStatement ((CultureCriteriaTemplate)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 preCultureStatementChange (String newCultureStatement) 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 postCultureStatementChange () throws FieldException
    {
    }

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

    /**
     * Set the attribute CultureStatement.  Checks to ensure a new value
     * has been supplied.  If so, marks the field as altered and sets the attribute.
     */
    public void setCultureStatement (String newCultureStatement) throws FieldException
    {
        boolean oldAndNewIdentical = HELPER_CultureStatement.compare (_CultureStatement, newCultureStatement);
        
        try
        {
            for (CultureCriteriaTemplateBehaviourDecorator bhd : CultureCriteriaTemplate_BehaviourDecorators)
            {
                newCultureStatement = bhd.setCultureStatement ((CultureCriteriaTemplate)this, newCultureStatement);
                oldAndNewIdentical = HELPER_CultureStatement.compare (_CultureStatement, newCultureStatement);
            }

            

            if (FIELD_CultureStatement_Validators.length > 0)
            {
                Object newCultureStatementObj = HELPER_CultureStatement.toObject (newCultureStatement);

                if (newCultureStatementObj != null)
                {
                    int     loopMax = FIELD_CultureStatement_Validators.length;
                    Map     metadata = (Map)ATTRIBUTES_METADATA_CultureCriteriaTemplate.get (FIELD_CultureStatement);

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

        if (!oldAndNewIdentical)
        {
            assertValid();
            Debug.assertion (getWriteability_CultureStatement () != FieldWriteability.FALSE, "Field  CultureStatement is not writeable");
            preCultureStatementChange (newCultureStatement);
            markFieldChange (FIELD_CultureStatement);
            _CultureStatement = newCultureStatement;            
            postFieldChange (FIELD_CultureStatement);
            postCultureStatementChange ();
        }
    }



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

        
        result.add("Client");
        
        result.add("HiringTeam");
        
        result.add("CompanyUser");
        

        return result;
    }
    
    
    public BaseBusinessClass getSingleAssocReferenceInstance (String assocName)
    {
        if (assocName == null)
        {
            throw new RuntimeException ("Game over == null!");
        }
        else if (assocName.equals (SINGLEREFERENCE_Client))
        {
            return _Client.getReferencedType ();
        }else if (assocName.equals (SINGLEREFERENCE_HiringTeam))
        {
            return _HiringTeam.getReferencedType ();
        }else if (assocName.equals (SINGLEREFERENCE_CompanyUser))
        {
            return _CompanyUser.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_Client))
        {
            return null ;
        }else if (assocName.equals (SINGLEREFERENCE_HiringTeam))
        {
            return null ;
        }else if (assocName.equals (SINGLEREFERENCE_CompanyUser))
        {
            return null ;
        }
        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_Client))
        {
            return getClient ();
        }else if (assocName.equals (SINGLEREFERENCE_HiringTeam))
        {
            return getHiringTeam ();
        }else if (assocName.equals (SINGLEREFERENCE_CompanyUser))
        {
            return getCompanyUser ();
        }
        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_Client))
        {
            return getClient (getType);
        }else if (assocName.equals (SINGLEREFERENCE_HiringTeam))
        {
            return getHiringTeam (getType);
        }else if (assocName.equals (SINGLEREFERENCE_CompanyUser))
        {
            return getCompanyUser (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_Client))
        {
            return getClientID ();
        }else if (assocName.equals (SINGLEREFERENCE_HiringTeam))
        {
            return getHiringTeamID ();
        }else if (assocName.equals (SINGLEREFERENCE_CompanyUser))
        {
            return getCompanyUserID ();
        }
        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_Client))
        {
            setClient ((Client)(newValue));
        }else if (assocName.equals (SINGLEREFERENCE_HiringTeam))
        {
            setHiringTeam ((HiringTeam)(newValue));
        }else if (assocName.equals (SINGLEREFERENCE_CompanyUser))
        {
            setCompanyUser ((CompanyUser)(newValue));
        }
        else
        {
            super.setSingleAssoc (assocName, newValue);
        }
    }



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


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


    /**
     * Get the object id for the referenced object.  Does not force a DB access.
     */
    public Long getClientID ()
    {
        assertValid();
        
        if (_Client == null)
        {
            return null;
        }
        else
        {
            return _Client.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 preClientChange (Client newClient) 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 postClientChange () throws FieldException
    {
    }



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

        if (_Client.wouldReferencedChange (newClient))
        {
            assertValid();
            Debug.assertion (getWriteability_Client () != FieldWriteability.FALSE, "Assoc Client is not writeable");
            preClientChange (newClient);
            
                    _Client.set (newClient);
                
            postClientChange ();
        }
    }

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


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


    /**
     * Get the object id for the referenced object.  Does not force a DB access.
     */
    public Long getHiringTeamID ()
    {
        assertValid();
        
        if (_HiringTeam == null)
        {
            return null;
        }
        else
        {
            return _HiringTeam.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 preHiringTeamChange (HiringTeam newHiringTeam) 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 postHiringTeamChange () throws FieldException
    {
    }



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

        if (_HiringTeam.wouldReferencedChange (newHiringTeam))
        {
            assertValid();
            Debug.assertion (getWriteability_HiringTeam () != FieldWriteability.FALSE, "Assoc HiringTeam is not writeable");
            preHiringTeamChange (newHiringTeam);
            
                    _HiringTeam.set (newHiringTeam);
                
            postHiringTeamChange ();
        }
    }

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


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


    /**
     * Get the object id for the referenced object.  Does not force a DB access.
     */
    public Long getCompanyUserID ()
    {
        assertValid();
        
        if (_CompanyUser == null)
        {
            return null;
        }
        else
        {
            return _CompanyUser.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 preCompanyUserChange (CompanyUser newCompanyUser) 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 postCompanyUserChange () throws FieldException
    {
    }



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

        if (_CompanyUser.wouldReferencedChange (newCompanyUser))
        {
            assertValid();
            Debug.assertion (getWriteability_CompanyUser () != FieldWriteability.FALSE, "Assoc CompanyUser is not writeable");
            preCompanyUserChange (newCompanyUser);
            
                    _CompanyUser.set (newCompanyUser);
                
            postCompanyUserChange ();
        }
    }

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

        
        result.add("CultureCriterias");
        

        return result;
    }


    /**
     * Get the reference instance for the multi assoc name.
     */
    public BaseBusinessClass getMultiAssocReferenceInstance(String attribName)
    {
        
        if (MULTIPLEREFERENCE_CultureCriterias.equals(attribName))
        {
            return CultureCriteria.REFERENCE_CultureCriteria ;
        }
        

        return super.getMultiAssocReferenceInstance(attribName);
    }


    public String getMultiAssocBackReference(String attribName)
    {
        
        if (MULTIPLEREFERENCE_CultureCriterias.equals(attribName))
        {
            return CultureCriteria.SINGLEREFERENCE_Template ;
        }
        

        return super.getMultiAssocBackReference(attribName);
    }


    /**
     * Get the assoc count for the multi assoc name.
     */
    public int getMultiAssocCount(String attribName) throws StorageException
    {
        
        if (MULTIPLEREFERENCE_CultureCriterias.equals(attribName))
        {
            return this.getCultureCriteriasCount();
        }
        

        return super.getMultiAssocCount(attribName);
    }


    /**
     * Get the assoc at a particular index
     */
    public BaseBusinessClass getMultiAssocAt(String attribName, int index) throws StorageException
    {
        
        if (MULTIPLEREFERENCE_CultureCriterias.equals(attribName))
        {
            return this.getCultureCriteriasAt(index);
        }
        

        return super.getMultiAssocAt(attribName, index);
    }


    /**
     * Add to a multi assoc by attribute name
     */
    public void addToMultiAssoc(String attribName, BaseBusinessClass newElement) throws StorageException
    {
        
        if (MULTIPLEREFERENCE_CultureCriterias.equals(attribName))
        {
            addToCultureCriterias((CultureCriteria)newElement);

            return;
        }
        

        super.addToMultiAssoc(attribName, newElement);
    }

    /**
     * Remove from a multi assoc by attribute name
     */
    public void removeFromMultiAssoc(String attribName, BaseBusinessClass oldElement) throws StorageException
    {
        
        if (MULTIPLEREFERENCE_CultureCriterias.equals(attribName))
        {
            removeFromCultureCriterias((CultureCriteria)oldElement);

            return;
        }
        

        super.removeFromMultiAssoc(attribName, oldElement);
    }


    protected void __loadMultiAssoc (String attribName, BaseBusinessClass[] elements)
    {
        
        if (MULTIPLEREFERENCE_CultureCriterias.equals(attribName))
        {
            _CultureCriterias.__loadAssociation (elements);
            return;
        }
        

        super.__loadMultiAssoc(attribName, elements);
    }


    protected boolean __isMultiAssocLoaded (String attribName)
    {
        
        if (MULTIPLEREFERENCE_CultureCriterias.equals(attribName))
        {
            return _CultureCriterias.isLoaded ();
        }
        

        return super.__isMultiAssocLoaded(attribName);
    }

    

    public FieldWriteability getWriteability_CultureCriterias ()
    {
        return getFieldWritabilityUtil (FieldWriteability.TRUE);
    }
    
    
    public int getCultureCriteriasCount () throws StorageException
    {
        assertValid();
        return _CultureCriterias.getReferencedObjectsCount ();
    }


    public void addToCultureCriterias (CultureCriteria newElement) throws StorageException
    {
        if (_CultureCriterias.wouldAddChange (newElement))
        {
            assertValid();
            Debug.assertion (getWriteability_CultureCriterias () != FieldWriteability.FALSE, "MultiAssoc CultureCriterias is not writeable (add)");
            _CultureCriterias.appendElement (newElement);

            try
            {
                if (newElement.getTemplate () != this)
                {
                    newElement.setTemplate ((CultureCriteriaTemplate)(this));
                }
            }
            catch (Exception e)
            {
                throw NestedException.wrap(e);
            }
        }
    }


    public void removeFromCultureCriterias (CultureCriteria elementToRemove) throws StorageException
    {
        if (_CultureCriterias.wouldRemoveChange (elementToRemove))
        {
            assertValid();
            Debug.assertion (getWriteability_CultureCriterias () != FieldWriteability.FALSE, "MultiAssoc CultureCriterias is not writeable (remove)");
            _CultureCriterias.removeElement (elementToRemove);
            try
            {
                if (elementToRemove.getTemplate () != null)
                {
                    elementToRemove.setTemplate (null);
                }
            }
            catch (Exception e)
            {
                throw NestedException.wrap(e);
            }
        }
    }


    public CultureCriteria getCultureCriteriasAt (int index) throws StorageException
    {
        return (CultureCriteria)(_CultureCriterias.getElementAt (index));
    }


    public SortedSet<CultureCriteria> getCultureCriteriasSet () throws StorageException
    {
        return _CultureCriterias.getSet ();
    }



    public void onDelete ()
    {
        try 
        {
            for(CultureCriteria referenced : CollectionUtils.reverse(getCultureCriteriasSet()))
            { 
                LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Setting backreference to null Template from ", getObjectID (), " to ", referenced.getObjectID ());
                referenced.setTemplate(null);
            }

        }
        catch (Exception e)
        {
            throw NestedException.wrap(e);
        }

        super.onDelete ();
    }


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


    public CultureCriteriaTemplate referenceInstance ()
    {
        return REFERENCE_CultureCriteriaTemplate;
    }


    public CultureCriteriaTemplate getInTransaction (ObjectTransaction t) throws StorageException
    {
        return getCultureCriteriaTemplateByID (t, getObjectID());
    }
    
    
    public BaseBusinessClass dummyInstance ()
    {
        return DUMMY_CultureCriteriaTemplate;
    }


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





    /**
     * 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   tl_culture_templatePSet = allSets.getPersistentSet (myID, "tl_culture_template", myPSetStatus);

        tl_culture_templatePSet.setAttrib (FIELD_ObjectID, myID);
        tl_culture_templatePSet.setAttrib (FIELD_TemplateName, HELPER_TemplateName.toObject (_TemplateName)); //
        tl_culture_templatePSet.setAttrib (FIELD_CultureStatement, HELPER_CultureStatement.toObject (_CultureStatement)); //
        _Client.getPersistentSets (allSets);
        _HiringTeam.getPersistentSets (allSets);
        _CompanyUser.getPersistentSets (allSets);
        
    }


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

        
        PersistentSet   tl_culture_templatePSet = allSets.getPersistentSet (objectID, "tl_culture_template");

        _TemplateName = (String)(HELPER_TemplateName.fromObject (_TemplateName, tl_culture_templatePSet.getAttrib (FIELD_TemplateName))); //
        _CultureStatement = (String)(HELPER_CultureStatement.fromObject (_CultureStatement, tl_culture_templatePSet.getAttrib (FIELD_CultureStatement))); //
        _Client.setFromPersistentSets (objectID, allSets);
        _HiringTeam.setFromPersistentSets (objectID, allSets);
        _CompanyUser.setFromPersistentSets (objectID, allSets);
        
    }





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

        if (other instanceof CultureCriteriaTemplate)
        {
            CultureCriteriaTemplate otherCultureCriteriaTemplate = (CultureCriteriaTemplate)other;
            
            try
            {
                setTemplateName (otherCultureCriteriaTemplate.getTemplateName ());
            }
            catch (FieldException ex)
            {
                e.addException (ex);
            }
            
            try
            {
                setCultureStatement (otherCultureCriteriaTemplate.getCultureStatement ());
            }
            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 BaseCultureCriteriaTemplate)
        {
            BaseCultureCriteriaTemplate sourceCultureCriteriaTemplate = (BaseCultureCriteriaTemplate)(source);

            _TemplateName = sourceCultureCriteriaTemplate._TemplateName;
            _CultureStatement = sourceCultureCriteriaTemplate._CultureStatement;
            
        }
    }


    /**
     * 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 BaseCultureCriteriaTemplate)
        {
            BaseCultureCriteriaTemplate sourceCultureCriteriaTemplate = (BaseCultureCriteriaTemplate)(source);

            _Client.copyFrom (sourceCultureCriteriaTemplate._Client, linkToGhosts);
            _HiringTeam.copyFrom (sourceCultureCriteriaTemplate._HiringTeam, linkToGhosts);
            _CompanyUser.copyFrom (sourceCultureCriteriaTemplate._CompanyUser, 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 BaseCultureCriteriaTemplate)
        {
            BaseCultureCriteriaTemplate sourceCultureCriteriaTemplate = (BaseCultureCriteriaTemplate)(source);

            _CultureCriterias.copyFrom (sourceCultureCriteriaTemplate._CultureCriterias, linkToGhosts);
            
        }
    }


    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);

        _TemplateName = (String)(HELPER_TemplateName.readExternal (_TemplateName, vals.get(FIELD_TemplateName))); //
        _CultureStatement = (String)(HELPER_CultureStatement.readExternal (_CultureStatement, vals.get(FIELD_CultureStatement))); //
        _Client.readExternalData(vals.get(SINGLEREFERENCE_Client));
        _HiringTeam.readExternalData(vals.get(SINGLEREFERENCE_HiringTeam));
        _CompanyUser.readExternalData(vals.get(SINGLEREFERENCE_CompanyUser));
        _CultureCriterias.readExternalData(vals.get(MULTIPLEREFERENCE_CultureCriterias));
        
    }


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

        vals.put (FIELD_TemplateName, HELPER_TemplateName.writeExternal (_TemplateName));
        vals.put (FIELD_CultureStatement, HELPER_CultureStatement.writeExternal (_CultureStatement));
        vals.put (SINGLEREFERENCE_Client, _Client.writeExternalData());
        vals.put (SINGLEREFERENCE_HiringTeam, _HiringTeam.writeExternalData());
        vals.put (SINGLEREFERENCE_CompanyUser, _CompanyUser.writeExternalData());
        vals.put (MULTIPLEREFERENCE_CultureCriterias, _CultureCriterias.writeExternalData());
        
    }


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

        if (other instanceof BaseCultureCriteriaTemplate)
        {
            BaseCultureCriteriaTemplate otherCultureCriteriaTemplate = (BaseCultureCriteriaTemplate)(other);

            
            if (!HELPER_TemplateName.compare(this._TemplateName, otherCultureCriteriaTemplate._TemplateName))
            {
                listener.notifyFieldChange(this, other, FIELD_TemplateName, HELPER_TemplateName.toObject(this._TemplateName), HELPER_TemplateName.toObject(otherCultureCriteriaTemplate._TemplateName));
            }
            if (!HELPER_CultureStatement.compare(this._CultureStatement, otherCultureCriteriaTemplate._CultureStatement))
            {
                listener.notifyFieldChange(this, other, FIELD_CultureStatement, HELPER_CultureStatement.toObject(this._CultureStatement), HELPER_CultureStatement.toObject(otherCultureCriteriaTemplate._CultureStatement));
            }

            // Compare single assocs
            _Client.compare (otherCultureCriteriaTemplate._Client, listener);
            _HiringTeam.compare (otherCultureCriteriaTemplate._HiringTeam, listener);
            _CompanyUser.compare (otherCultureCriteriaTemplate._CompanyUser, listener);
            

            // Compare multiple assocs
            _CultureCriterias.compare (otherCultureCriteriaTemplate._CultureCriterias, listener);
            
        }
    }


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

        
    }


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

        visitor.visitField(this, FIELD_TemplateName, HELPER_TemplateName.toObject(getTemplateName()));
        visitor.visitField(this, FIELD_CultureStatement, HELPER_CultureStatement.toObject(getCultureStatement()));
        visitor.visitAssociation (_Client);
        visitor.visitAssociation (_HiringTeam);
        visitor.visitAssociation (_CompanyUser);
        visitor.visitAssociation (_CultureCriterias);
        
    }


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

        if (scope.includes (_Client))
        {
            visitor.visit (_Client);
        }
        if (scope.includes (_HiringTeam))
        {
            visitor.visit (_HiringTeam);
        }
        if (scope.includes (_CompanyUser))
        {
            visitor.visit (_CompanyUser);
        }
        if (scope.includes (_CultureCriterias))
        {
            visitor.visit (_CultureCriterias);
        }
        
    }


    public static CultureCriteriaTemplate createCultureCriteriaTemplate (ObjectTransaction transaction) throws StorageException
    {
        CultureCriteriaTemplate     result = new CultureCriteriaTemplate ();

        result.initialiseNewObject (transaction);

        return result;
    }


    public static CultureCriteriaTemplate getCultureCriteriaTemplateByID (ObjectTransaction transaction, Long objectID) throws StorageException
    {
        return (CultureCriteriaTemplate)(transaction.getObjectByID (REFERENCE_CultureCriteriaTemplate, objectID));
    }

    public boolean testFilter (String attribName, QueryFilter filter) throws StorageException
    {
        if (false)
        {
            throw new RuntimeException ("Game over man!!");
        }
        else if (attribName.equals (FIELD_TemplateName))
        {
            return filter.matches (getTemplateName ());
        }
        else if (attribName.equals (FIELD_CultureStatement))
        {
            return filter.matches (getCultureStatement ());
        }
        else if (attribName.equals (SINGLEREFERENCE_Client))
        {
            return filter.matches (getClient ());
        }
        else if (attribName.equals (SINGLEREFERENCE_HiringTeam))
        {
            return filter.matches (getHiringTeam ());
        }
        else if (attribName.equals (SINGLEREFERENCE_CompanyUser))
        {
            return filter.matches (getCompanyUser ());
        }
        else
        {
            return super.testFilter (attribName, filter);
        }
    }


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

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

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

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

            
            public SearchAll andTemplateName (QueryFilter<String> filter)
            {
                filter.addFilter (context, "tl_culture_template.template_name", "TemplateName");
                return this;
            }
            
            public SearchAll andCultureStatement (QueryFilter<String> filter)
            {
                filter.addFilter (context, "tl_culture_template.culture_statement", "CultureStatement");
                return this;
            }
            
            public SearchAll andClient (QueryFilter<Client> filter)
            {
                filter.addFilter (context, "tl_culture_template.client_id", "Client");
                return this;
            }
            
            public SearchAll andHiringTeam (QueryFilter<HiringTeam> filter)
            {
                filter.addFilter (context, "tl_culture_template.hiring_team_id", "HiringTeam");
                return this;
            }
            
            public SearchAll andCompanyUser (QueryFilter<CompanyUser> filter)
            {
                filter.addFilter (context, "tl_culture_template.company_user_id", "CompanyUser");
                return this;
            }
            
                public CultureCriteriaTemplate[]
             search (ObjectTransaction transaction) throws StorageException
        {
            
            
            BaseBusinessClass[]     results = super.search (transaction, REFERENCE_CultureCriteriaTemplate, SEARCH_All, criteria);
            Set<CultureCriteriaTemplate>   typedResults = new LinkedHashSet <CultureCriteriaTemplate> ();
            for (BaseBusinessClass bbcResult : results)
            {
                CultureCriteriaTemplate aResult = (CultureCriteriaTemplate)bbcResult;
                
                typedResults.add (aResult);
            }
            
                    return ObjstoreUtils.removeDeleted(transaction, typedResults).toArray (new CultureCriteriaTemplate[0]);
                            
        }
    }

        
                public static CultureCriteriaTemplate[]
             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_TemplateName))
        {
            return HELPER_TemplateName.toObject (getTemplateName ());
        }
        else if (attribName.equals (FIELD_CultureStatement))
        {
            return HELPER_CultureStatement.toObject (getCultureStatement ());
        }
        else
        {
            return super.getAttribute (attribName);
        }
    }


    public AttributeHelper getAttributeHelper (String attribName)
    {
        if (false)
        {
            throw new RuntimeException ("Game over man!!");
        }
        else if (attribName.equals (FIELD_TemplateName))
        {
            return HELPER_TemplateName;
        }
        else if (attribName.equals (FIELD_CultureStatement))
        {
            return HELPER_CultureStatement;
        }
        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_TemplateName))
        {
            setTemplateName ((String)(HELPER_TemplateName.fromObject (_TemplateName, attribValue)));            
        }
        else if (attribName.equals (FIELD_CultureStatement))
        {
            setCultureStatement ((String)(HELPER_CultureStatement.fromObject (_CultureStatement, 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_TemplateName))
        {
            return getWriteability_TemplateName ();
        }
        else if (fieldName.equals (FIELD_CultureStatement))
        {
            return getWriteability_CultureStatement ();
        }
        else if (fieldName.equals (MULTIPLEREFERENCE_CultureCriterias))
        {
            return getWriteability_CultureCriterias ();
        }
        else if (fieldName.equals (SINGLEREFERENCE_Client))
        {
            return getWriteability_Client ();
        }
        else if (fieldName.equals (SINGLEREFERENCE_HiringTeam))
        {
            return getWriteability_HiringTeam ();
        }
        else if (fieldName.equals (SINGLEREFERENCE_CompanyUser))
        {
            return getWriteability_CompanyUser ();
        }
        else
        {
            return super.getWriteable (fieldName);
        }
    }


    public void putUnwriteable (Set<String> fields)
    {
        
            if (getWriteability_TemplateName () != FieldWriteability.TRUE)
            {
                fields.add (FIELD_TemplateName);
            }
        
            if (getWriteability_CultureStatement () != FieldWriteability.TRUE)
            {
                fields.add (FIELD_CultureStatement);
            }
        

        super.putUnwriteable (fields);
    }

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

        
        result.add(HELPER_TemplateName.getAttribObject (getClass (), _TemplateName, false, FIELD_TemplateName));
        result.add(HELPER_CultureStatement.getAttribObject (getClass (), _CultureStatement, false, FIELD_CultureStatement));

        return result;
    }


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


    public Object getAttributeMetadata (String attribute, String metadata)
    {
        if (ATTRIBUTES_METADATA_CultureCriteriaTemplate.containsKey (attribute))
        {
            return ((Map)ATTRIBUTES_METADATA_CultureCriteriaTemplate.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 CultureCriteriaTemplateBehaviourDecorator extends BaseBusinessClass.BBCBehaviourDecorator<CultureCriteriaTemplate>
    {

    /**
     * Get the attribute TemplateName
     */
    public String getTemplateName (CultureCriteriaTemplate obj, String original)
    {
        return original;
    }

    /**
     * Change the value set for attribute TemplateName.
     * May modify the field beforehand
     * Occurs before validation.
     */
    public String setTemplateName (CultureCriteriaTemplate obj, String newTemplateName) throws FieldException
    {
        return newTemplateName;
    }

    /**
     * Get the attribute CultureStatement
     */
    public String getCultureStatement (CultureCriteriaTemplate obj, String original)
    {
        return original;
    }

    /**
     * Change the value set for attribute CultureStatement.
     * May modify the field beforehand
     * Occurs before validation.
     */
    public String setCultureStatement (CultureCriteriaTemplate obj, String newCultureStatement) throws FieldException
    {
        return newCultureStatement;
    }

    }

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

        public CultureCriteriaTemplatePipeLineFactory (Collection<From> seed)
        {
            super(seed);
        }
        
        
        public PipeLine<From, ? extends Object> to(String name)
        {
            if (name.equals ("CultureCriterias"))
            {
                return toCultureCriterias ();
            }                
            if (name.equals ("TemplateName"))
            {
                return toTemplateName ();
            }                
            if (name.equals ("CultureStatement"))
            {
                return toCultureStatement ();
            }                
            if (name.equals ("Client"))
            {
                return toClient ();
            }                
            if (name.equals ("HiringTeam"))
            {
                return toHiringTeam ();
            }                
            if (name.equals ("CompanyUser"))
            {
                return toCompanyUser ();
            }                
            
            
            return super.to(name);
        }
        
        
        public PipeLine<From, String> toTemplateName () { return pipe(new ORMAttributePipe<Me, String>(FIELD_TemplateName));  }
        
        public PipeLine<From, String> toCultureStatement () { return pipe(new ORMAttributePipe<Me, String>(FIELD_CultureStatement));  }
        public Client.ClientPipeLineFactory<From, Client> toClient () { return toClient (Filter.ALL); }

        public Client.ClientPipeLineFactory<From, Client> toClient (Filter<Client> filter) 
        { 
            return Client.REFERENCE_Client.new ClientPipeLineFactory<From, Client> (this, new ORMSingleAssocPipe<Me, Client>(SINGLEREFERENCE_Client, filter)); 
        }
        public HiringTeam.HiringTeamPipeLineFactory<From, HiringTeam> toHiringTeam () { return toHiringTeam (Filter.ALL); }

        public HiringTeam.HiringTeamPipeLineFactory<From, HiringTeam> toHiringTeam (Filter<HiringTeam> filter) 
        { 
            return HiringTeam.REFERENCE_HiringTeam.new HiringTeamPipeLineFactory<From, HiringTeam> (this, new ORMSingleAssocPipe<Me, HiringTeam>(SINGLEREFERENCE_HiringTeam, filter)); 
        }
        public CompanyUser.CompanyUserPipeLineFactory<From, CompanyUser> toCompanyUser () { return toCompanyUser (Filter.ALL); }

        public CompanyUser.CompanyUserPipeLineFactory<From, CompanyUser> toCompanyUser (Filter<CompanyUser> filter) 
        { 
            return CompanyUser.REFERENCE_CompanyUser.new CompanyUserPipeLineFactory<From, CompanyUser> (this, new ORMSingleAssocPipe<Me, CompanyUser>(SINGLEREFERENCE_CompanyUser, filter)); 
        }
        public CultureCriteria.CultureCriteriaPipeLineFactory<From, CultureCriteria> toCultureCriterias () { return toCultureCriterias(Filter.ALL); }        

        public CultureCriteria.CultureCriteriaPipeLineFactory<From, CultureCriteria> toCultureCriterias (Filter<CultureCriteria> filter)
        {
            return CultureCriteria.REFERENCE_CultureCriteria.new CultureCriteriaPipeLineFactory<From, CultureCriteria> (this, new ORMMultiAssocPipe<Me, CultureCriteria>(MULTIPLEREFERENCE_CultureCriterias, filter)); 
        }
        
    }
    
    public boolean isTransientAttrib(String attribName)
    {
        

        return super.isTransientAttrib(attribName);
    }

    public boolean isTransientSingleReference(String assocName)
    {
        

        return super.isTransientSingleReference(assocName);
    }
}

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

    public void assertValid ()
    {
    }


    public Client getClient () throws StorageException
    {
        return (Client)(Client.DUMMY_Client);
    }


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

    public HiringTeam getHiringTeam () throws StorageException
    {
        return (HiringTeam)(HiringTeam.DUMMY_HiringTeam);
    }


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

    public CompanyUser getCompanyUser () throws StorageException
    {
        return (CompanyUser)(CompanyUser.DUMMY_CompanyUser);
    }


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

    public int getCultureCriteriasCount () throws StorageException
    {
        return 0;
    }


    public CultureCriteria getCultureCriteriasAt (int index) throws StorageException
    {
        throw new RuntimeException ("No elements in a dummy object in association CultureCriterias");
    }


    public SortedSet getCultureCriteriasSet () throws StorageException
    {
        return new TreeSet();
    }

}

    
