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



public abstract class BaseCultureCriteria extends BaseBusinessClass
{
    // Reference instance for the object
    public static final CultureCriteria REFERENCE_CultureCriteria = new CultureCriteria ();

    // Reference instance for the object
    public static final CultureCriteria DUMMY_CultureCriteria = new DummyCultureCriteria ();

    // Static constants corresponding to field names
    
    public static final String FIELD_Importance = "Importance";
    public static final String FIELD_IsApplicable = "IsApplicable";
    public static final String SINGLEREFERENCE_CultureElement = "CultureElement";
    public static final String SINGLEREFERENCE_CultureElementRating = "CultureElementRating";
    public static final String SINGLEREFERENCE_Job = "Job";
    public static final String BACKREF_Job = "";
    public static final String SINGLEREFERENCE_Template = "Template";
    public static final String BACKREF_Template = "";

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

    // Static constants corresponding to attribute helpers
    private static final EnumeratedAttributeHelper<CultureCriteria, Importance> HELPER_Importance =  new EnumeratedAttributeHelper<CultureCriteria, Importance> (Importance.FACTORY_Importance);
    private static final DefaultAttributeHelper<CultureCriteria> HELPER_IsApplicable = DefaultAttributeHelper.INSTANCE;
    

    // Private attributes corresponding to business object data
    private Importance _Importance;
    private Boolean _IsApplicable;
    

    // Private attributes corresponding to single references
    private SingleAssociation<CultureCriteria, CultureElement> _CultureElement;
    private SingleAssociation<CultureCriteria, CultureElementRating> _CultureElementRating;
    private SingleAssociation<CultureCriteria, Job> _Job;
    private SingleAssociation<CultureCriteria, CultureCriteriaTemplate> _Template;
    

    // Private attributes corresponding to multiple references
    

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

    // Arrays of validators for each attribute
    private static final AttributeValidator[] FIELD_Importance_Validators;
    private static final AttributeValidator[] FIELD_IsApplicable_Validators;
    

    // Arrays of behaviour decorators
    private static final CultureCriteriaBehaviourDecorator[] CultureCriteria_BehaviourDecorators;
    
    static
    {
        try
        {
            
            String tmp_Job = Job.BACKREF_CultureCriterias;
            String tmp_Template = CultureCriteriaTemplate.BACKREF_CultureCriterias;
            
            Map  validatorMapping = ((Map)ConfigMgr.getConfigObject ("CONFIG.ORMVALIDATOR", "ValidatorMapping"));

            setupAssocMetaData_CultureElement();
            setupAssocMetaData_CultureElementRating();
            setupAssocMetaData_Job();
            setupAssocMetaData_Template();
            FIELD_Importance_Validators = (AttributeValidator[])setupAttribMetaData_Importance(validatorMapping).toArray (new AttributeValidator[0]);
            FIELD_IsApplicable_Validators = (AttributeValidator[])setupAttribMetaData_IsApplicable(validatorMapping).toArray (new AttributeValidator[0]);
            

            REFERENCE_CultureCriteria.initialiseReference ();
            DUMMY_CultureCriteria.initialiseReference ();
            CultureCriteria_BehaviourDecorators = BaseBusinessClass.getBBCBehaviours(CultureCriteria.class).toArray(new CultureCriteriaBehaviourDecorator[0]);
        }
        catch (RuntimeException e)
        {
            LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR1, e, "Error initialising");
            throw e;
        }
    }

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

        metaInfo.put ("dbcol", "culture_element_id");
        metaInfo.put ("mandatory", "true");
        metaInfo.put ("name", "CultureElement");
        metaInfo.put ("type", "CultureElement");
        
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for CultureCriteria.CultureElement:", metaInfo);
        ATTRIBUTES_METADATA_CultureCriteria.put (SINGLEREFERENCE_CultureElement, Collections.unmodifiableMap (metaInfo));
    }
    
    
    // Meta Info setup
    private static void setupAssocMetaData_CultureElementRating()
    {
        Map metaInfo = new HashMap ();

        metaInfo.put ("dbcol", "culture_element_rating_id");
        metaInfo.put ("mandatory", "false");
        metaInfo.put ("name", "CultureElementRating");
        metaInfo.put ("type", "CultureElementRating");
        
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for CultureCriteria.CultureElementRating:", metaInfo);
        ATTRIBUTES_METADATA_CultureCriteria.put (SINGLEREFERENCE_CultureElementRating, Collections.unmodifiableMap (metaInfo));
    }
    
    
    // Meta Info setup
    private static void setupAssocMetaData_Job()
    {
        Map metaInfo = new HashMap ();

        metaInfo.put ("backreferenceName", "CultureCriterias");
        metaInfo.put ("dbcol", "job_id");
        metaInfo.put ("name", "Job");
        metaInfo.put ("type", "Job");
        
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for CultureCriteria.Job:", metaInfo);
        ATTRIBUTES_METADATA_CultureCriteria.put (SINGLEREFERENCE_Job, Collections.unmodifiableMap (metaInfo));
    }
    
    
    // Meta Info setup
    private static void setupAssocMetaData_Template()
    {
        Map metaInfo = new HashMap ();

        metaInfo.put ("backreferenceName", "CultureCriterias");
        metaInfo.put ("dbcol", "template_id");
        metaInfo.put ("name", "Template");
        metaInfo.put ("type", "CultureCriteriaTemplate");
        
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for CultureCriteria.Template:", metaInfo);
        ATTRIBUTES_METADATA_CultureCriteria.put (SINGLEREFERENCE_Template, Collections.unmodifiableMap (metaInfo));
    }
    
    
    // Meta Info setup
    private static List setupAttribMetaData_Importance(Map validatorMapping)
    {
        Map  metaInfo   = new HashMap ();

        metaInfo.put ("attribHelper", "EnumeratedAttributeHelper");
        metaInfo.put ("dbcol", "importance");
        metaInfo.put ("name", "Importance");
        metaInfo.put ("type", "Importance");
        
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for CultureCriteria.Importance:", metaInfo);
        ATTRIBUTES_METADATA_CultureCriteria.put (FIELD_Importance, Collections.unmodifiableMap (metaInfo));

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

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

        metaInfo.put ("dbcol", "is_applicable");
        metaInfo.put ("defaultValue", "Boolean.TRUE");
        metaInfo.put ("name", "IsApplicable");
        metaInfo.put ("type", "Boolean");
        
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for CultureCriteria.IsApplicable:", metaInfo);
        ATTRIBUTES_METADATA_CultureCriteria.put (FIELD_IsApplicable, Collections.unmodifiableMap (metaInfo));

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

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


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


    


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

        
        _Importance = (Importance)(HELPER_Importance.initialise (_Importance));
        _IsApplicable = (Boolean)(Boolean.TRUE);
    }


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

        _CultureElement = new SingleAssociation<CultureCriteria, CultureElement> (this, SINGLEREFERENCE_CultureElement, null, CultureElement.REFERENCE_CultureElement, "tl_culture_criteria");
        _CultureElementRating = new SingleAssociation<CultureCriteria, CultureElementRating> (this, SINGLEREFERENCE_CultureElementRating, null, CultureElementRating.REFERENCE_CultureElementRating, "tl_culture_criteria");
        _Job = new SingleAssociation<CultureCriteria, Job> (this, SINGLEREFERENCE_Job, Job.MULTIPLEREFERENCE_CultureCriterias, Job.REFERENCE_Job, "tl_culture_criteria");
        _Template = new SingleAssociation<CultureCriteria, CultureCriteriaTemplate> (this, SINGLEREFERENCE_Template, CultureCriteriaTemplate.MULTIPLEREFERENCE_CultureCriterias, CultureCriteriaTemplate.REFERENCE_CultureCriteriaTemplate, "tl_culture_criteria");
        
    }


    // Initialise the associations
    protected BaseBusinessClass initialiseReference ()
    {
        super.initialiseReference ();
        
        _CultureElement = new SingleAssociation<CultureCriteria, CultureElement> (this, SINGLEREFERENCE_CultureElement, null, CultureElement.REFERENCE_CultureElement, "tl_culture_criteria");
        _CultureElementRating = new SingleAssociation<CultureCriteria, CultureElementRating> (this, SINGLEREFERENCE_CultureElementRating, null, CultureElementRating.REFERENCE_CultureElementRating, "tl_culture_criteria");
        _Job = new SingleAssociation<CultureCriteria, Job> (this, SINGLEREFERENCE_Job, Job.MULTIPLEREFERENCE_CultureCriterias, Job.REFERENCE_Job, "tl_culture_criteria");
        _Template = new SingleAssociation<CultureCriteria, CultureCriteriaTemplate> (this, SINGLEREFERENCE_Template, CultureCriteriaTemplate.MULTIPLEREFERENCE_CultureCriterias, CultureCriteriaTemplate.REFERENCE_CultureCriteriaTemplate, "tl_culture_criteria");
        
        
        return this;
    }

    

    /**
     * Get the attribute Importance
     */
    public Importance getImportance ()
    {
        assertValid();
        Importance valToReturn = _Importance;

            for (CultureCriteriaBehaviourDecorator bhd : CultureCriteria_BehaviourDecorators)
            {
                valToReturn = bhd.getImportance ((CultureCriteria)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 preImportanceChange (Importance newImportance) 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 postImportanceChange () throws FieldException
    {
    }

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

    /**
     * Set the attribute Importance.  Checks to ensure a new value
     * has been supplied.  If so, marks the field as altered and sets the attribute.
     */
    public void setImportance (Importance newImportance) throws FieldException
    {
        boolean oldAndNewIdentical = HELPER_Importance.compare (_Importance, newImportance);
        
        try
        {
            for (CultureCriteriaBehaviourDecorator bhd : CultureCriteria_BehaviourDecorators)
            {
                newImportance = bhd.setImportance ((CultureCriteria)this, newImportance);
                oldAndNewIdentical = HELPER_Importance.compare (_Importance, newImportance);
            }

            

            if (FIELD_Importance_Validators.length > 0)
            {
                Object newImportanceObj = HELPER_Importance.toObject (newImportance);

                if (newImportanceObj != null)
                {
                    int     loopMax = FIELD_Importance_Validators.length;
                    Map     metadata = (Map)ATTRIBUTES_METADATA_CultureCriteria.get (FIELD_Importance);

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

        if (!oldAndNewIdentical)
        {
            assertValid();
            Debug.assertion (getWriteability_Importance () != FieldWriteability.FALSE, "Field  Importance is not writeable");
            preImportanceChange (newImportance);
            markFieldChange (FIELD_Importance);
            _Importance = newImportance;            
            postFieldChange (FIELD_Importance);
            postImportanceChange ();
        }
    }

    /**
     * Get the attribute IsApplicable
     */
    public Boolean getIsApplicable ()
    {
        assertValid();
        Boolean valToReturn = _IsApplicable;

            for (CultureCriteriaBehaviourDecorator bhd : CultureCriteria_BehaviourDecorators)
            {
                valToReturn = bhd.getIsApplicable ((CultureCriteria)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 preIsApplicableChange (Boolean newIsApplicable) 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 postIsApplicableChange () throws FieldException
    {
    }

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

    /**
     * Set the attribute IsApplicable.  Checks to ensure a new value
     * has been supplied.  If so, marks the field as altered and sets the attribute.
     */
    public void setIsApplicable (Boolean newIsApplicable) throws FieldException
    {
        boolean oldAndNewIdentical = HELPER_IsApplicable.compare (_IsApplicable, newIsApplicable);
        
        try
        {
            for (CultureCriteriaBehaviourDecorator bhd : CultureCriteria_BehaviourDecorators)
            {
                newIsApplicable = bhd.setIsApplicable ((CultureCriteria)this, newIsApplicable);
                oldAndNewIdentical = HELPER_IsApplicable.compare (_IsApplicable, newIsApplicable);
            }

            

            if (FIELD_IsApplicable_Validators.length > 0)
            {
                Object newIsApplicableObj = HELPER_IsApplicable.toObject (newIsApplicable);

                if (newIsApplicableObj != null)
                {
                    int     loopMax = FIELD_IsApplicable_Validators.length;
                    Map     metadata = (Map)ATTRIBUTES_METADATA_CultureCriteria.get (FIELD_IsApplicable);

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

        if (!oldAndNewIdentical)
        {
            assertValid();
            Debug.assertion (getWriteability_IsApplicable () != FieldWriteability.FALSE, "Field  IsApplicable is not writeable");
            preIsApplicableChange (newIsApplicable);
            markFieldChange (FIELD_IsApplicable);
            _IsApplicable = newIsApplicable;            
            postFieldChange (FIELD_IsApplicable);
            postIsApplicableChange ();
        }
    }



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

        
        result.add("CultureElement");
        
        result.add("CultureElementRating");
        
        result.add("Job");
        
        result.add("Template");
        

        return result;
    }
    
    
    public BaseBusinessClass getSingleAssocReferenceInstance (String assocName)
    {
        if (assocName == null)
        {
            throw new RuntimeException ("Game over == null!");
        }
        else if (assocName.equals (SINGLEREFERENCE_CultureElement))
        {
            return _CultureElement.getReferencedType ();
        }else if (assocName.equals (SINGLEREFERENCE_CultureElementRating))
        {
            return _CultureElementRating.getReferencedType ();
        }else if (assocName.equals (SINGLEREFERENCE_Job))
        {
            return _Job.getReferencedType ();
        }else if (assocName.equals (SINGLEREFERENCE_Template))
        {
            return _Template.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_CultureElement))
        {
            return null ;
        }else if (assocName.equals (SINGLEREFERENCE_CultureElementRating))
        {
            return null ;
        }else if (assocName.equals (SINGLEREFERENCE_Job))
        {
            return Job.MULTIPLEREFERENCE_CultureCriterias ;
        }else if (assocName.equals (SINGLEREFERENCE_Template))
        {
            return CultureCriteriaTemplate.MULTIPLEREFERENCE_CultureCriterias ;
        }
        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_CultureElement))
        {
            return getCultureElement ();
        }else if (assocName.equals (SINGLEREFERENCE_CultureElementRating))
        {
            return getCultureElementRating ();
        }else if (assocName.equals (SINGLEREFERENCE_Job))
        {
            return getJob ();
        }else if (assocName.equals (SINGLEREFERENCE_Template))
        {
            return getTemplate ();
        }
        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_CultureElement))
        {
            return getCultureElement (getType);
        }else if (assocName.equals (SINGLEREFERENCE_CultureElementRating))
        {
            return getCultureElementRating (getType);
        }else if (assocName.equals (SINGLEREFERENCE_Job))
        {
            return getJob (getType);
        }else if (assocName.equals (SINGLEREFERENCE_Template))
        {
            return getTemplate (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_CultureElement))
        {
            return getCultureElementID ();
        }else if (assocName.equals (SINGLEREFERENCE_CultureElementRating))
        {
            return getCultureElementRatingID ();
        }else if (assocName.equals (SINGLEREFERENCE_Job))
        {
            return getJobID ();
        }else if (assocName.equals (SINGLEREFERENCE_Template))
        {
            return getTemplateID ();
        }
        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_CultureElement))
        {
            setCultureElement ((CultureElement)(newValue));
        }else if (assocName.equals (SINGLEREFERENCE_CultureElementRating))
        {
            setCultureElementRating ((CultureElementRating)(newValue));
        }else if (assocName.equals (SINGLEREFERENCE_Job))
        {
            setJob ((Job)(newValue));
        }else if (assocName.equals (SINGLEREFERENCE_Template))
        {
            setTemplate ((CultureCriteriaTemplate)(newValue));
        }
        else
        {
            super.setSingleAssoc (assocName, newValue);
        }
    }



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


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


    /**
     * Get the object id for the referenced object.  Does not force a DB access.
     */
    public Long getCultureElementID ()
    {
        assertValid();
        
        if (_CultureElement == null)
        {
            return null;
        }
        else
        {
            return _CultureElement.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 preCultureElementChange (CultureElement newCultureElement) 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 postCultureElementChange () throws FieldException
    {
    }



    
    public FieldWriteability getWriteability_CultureElement ()
    {
        return getFieldWritabilityUtil (FieldWriteability.TRUE);
    }
    
    
    /**
     * Set the reference CultureElement.  Checks to ensure a new value
     * has been supplied.  If so, marks the reference as altered and sets it.
     */
    public void setCultureElement (CultureElement newCultureElement) throws StorageException, FieldException
    {
        BusinessObjectParser.assertFieldCondition (newCultureElement != null, this, SINGLEREFERENCE_CultureElement, "mandatory");
        

        if (_CultureElement.wouldReferencedChange (newCultureElement))
        {
            assertValid();
            Debug.assertion (getWriteability_CultureElement () != FieldWriteability.FALSE, "Assoc CultureElement is not writeable");
            preCultureElementChange (newCultureElement);
            
                    _CultureElement.set (newCultureElement);
                
            postCultureElementChange ();
        }
    }

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


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


    /**
     * Get the object id for the referenced object.  Does not force a DB access.
     */
    public Long getCultureElementRatingID ()
    {
        assertValid();
        
        if (_CultureElementRating == null)
        {
            return null;
        }
        else
        {
            return _CultureElementRating.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 preCultureElementRatingChange (CultureElementRating newCultureElementRating) 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 postCultureElementRatingChange () throws FieldException
    {
    }



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

        if (_CultureElementRating.wouldReferencedChange (newCultureElementRating))
        {
            assertValid();
            Debug.assertion (getWriteability_CultureElementRating () != FieldWriteability.FALSE, "Assoc CultureElementRating is not writeable");
            preCultureElementRatingChange (newCultureElementRating);
            
                    _CultureElementRating.set (newCultureElementRating);
                
            postCultureElementRatingChange ();
        }
    }

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


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


    /**
     * Get the object id for the referenced object.  Does not force a DB access.
     */
    public Long getJobID ()
    {
        assertValid();
        
        if (_Job == null)
        {
            return null;
        }
        else
        {
            return _Job.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 preJobChange (Job newJob) 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 postJobChange () throws FieldException
    {
    }



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

        if (_Job.wouldReferencedChange (newJob))
        {
            assertValid();
            Debug.assertion (getWriteability_Job () != FieldWriteability.FALSE, "Assoc Job is not writeable");
            preJobChange (newJob);
            Job oldJob = getJob ();

                    if (oldJob != null)
                    {
                        // This is to stop validation from triggering when we are removed
                        _Job.set (null);
                        oldJob.removeFromCultureCriterias ((CultureCriteria)(this));
                    }

                    _Job.set (newJob);

                    if (newJob != null)
                    {
                        newJob.addToCultureCriterias ((CultureCriteria)(this));
                    }
                
            postJobChange ();
        }
    }

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


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


    /**
     * Get the object id for the referenced object.  Does not force a DB access.
     */
    public Long getTemplateID ()
    {
        assertValid();
        
        if (_Template == null)
        {
            return null;
        }
        else
        {
            return _Template.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 preTemplateChange (CultureCriteriaTemplate newTemplate) 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 postTemplateChange () throws FieldException
    {
    }



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

        if (_Template.wouldReferencedChange (newTemplate))
        {
            assertValid();
            Debug.assertion (getWriteability_Template () != FieldWriteability.FALSE, "Assoc Template is not writeable");
            preTemplateChange (newTemplate);
            CultureCriteriaTemplate oldTemplate = getTemplate ();

                    if (oldTemplate != null)
                    {
                        // This is to stop validation from triggering when we are removed
                        _Template.set (null);
                        oldTemplate.removeFromCultureCriterias ((CultureCriteria)(this));
                    }

                    _Template.set (newTemplate);

                    if (newTemplate != null)
                    {
                        newTemplate.addToCultureCriterias ((CultureCriteria)(this));
                    }
                
            postTemplateChange ();
        }
    }

    /**
     * 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 (_Job.isLoaded () || getTransaction ().isObjectLoaded (_Job.getReferencedType (), getJobID ()))
            {
                Job  referenced = getJob ();

                if (referenced != null)
                {
                    // Stop the callback
                    LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Setting backreference to null CultureCriterias from ", getObjectID (), " to ", referenced.getObjectID ());
                    _Job.set (null);
                    referenced.removeFromCultureCriterias ((CultureCriteria)this);
                }
            }
        
            // Ensure we are removed from any loaded multi-associations that aren't mandatory
            if (_Template.isLoaded () || getTransaction ().isObjectLoaded (_Template.getReferencedType (), getTemplateID ()))
            {
                CultureCriteriaTemplate  referenced = getTemplate ();

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

        super.onDelete ();
    }


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


    public CultureCriteria referenceInstance ()
    {
        return REFERENCE_CultureCriteria;
    }


    public CultureCriteria getInTransaction (ObjectTransaction t) throws StorageException
    {
        return getCultureCriteriaByID (t, getObjectID());
    }
    
    
    public BaseBusinessClass dummyInstance ()
    {
        return DUMMY_CultureCriteria;
    }


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





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

        tl_culture_criteriaPSet.setAttrib (FIELD_ObjectID, myID);
        tl_culture_criteriaPSet.setAttrib (FIELD_Importance, HELPER_Importance.toObject (_Importance)); //
        tl_culture_criteriaPSet.setAttrib (FIELD_IsApplicable, HELPER_IsApplicable.toObject (_IsApplicable)); //
        _CultureElement.getPersistentSets (allSets);
        _CultureElementRating.getPersistentSets (allSets);
        _Job.getPersistentSets (allSets);
        _Template.getPersistentSets (allSets);
        
    }


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

        
        PersistentSet   tl_culture_criteriaPSet = allSets.getPersistentSet (objectID, "tl_culture_criteria");

        _Importance = (Importance)(HELPER_Importance.fromObject (_Importance, tl_culture_criteriaPSet.getAttrib (FIELD_Importance))); //
        _IsApplicable = (Boolean)(HELPER_IsApplicable.fromObject (_IsApplicable, tl_culture_criteriaPSet.getAttrib (FIELD_IsApplicable))); //
        _CultureElement.setFromPersistentSets (objectID, allSets);
        _CultureElementRating.setFromPersistentSets (objectID, allSets);
        _Job.setFromPersistentSets (objectID, allSets);
        _Template.setFromPersistentSets (objectID, allSets);
        
    }





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

        if (other instanceof CultureCriteria)
        {
            CultureCriteria otherCultureCriteria = (CultureCriteria)other;
            
            try
            {
                setImportance (otherCultureCriteria.getImportance ());
            }
            catch (FieldException ex)
            {
                e.addException (ex);
            }
            
            try
            {
                setIsApplicable (otherCultureCriteria.getIsApplicable ());
            }
            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 BaseCultureCriteria)
        {
            BaseCultureCriteria sourceCultureCriteria = (BaseCultureCriteria)(source);

            _Importance = sourceCultureCriteria._Importance;
            _IsApplicable = sourceCultureCriteria._IsApplicable;
            
        }
    }


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

            _CultureElement.copyFrom (sourceCultureCriteria._CultureElement, linkToGhosts);
            _CultureElementRating.copyFrom (sourceCultureCriteria._CultureElementRating, linkToGhosts);
            _Job.copyFrom (sourceCultureCriteria._Job, linkToGhosts);
            _Template.copyFrom (sourceCultureCriteria._Template, 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 BaseCultureCriteria)
        {
            BaseCultureCriteria sourceCultureCriteria = (BaseCultureCriteria)(source);

            
        }
    }


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

        
        context.check (getCultureElementID() != null, this, SINGLEREFERENCE_CultureElement, "mandatory");
        
    }


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

        _Importance = (Importance)(HELPER_Importance.readExternal (_Importance, vals.get(FIELD_Importance))); //
        _IsApplicable = (Boolean)(HELPER_IsApplicable.readExternal (_IsApplicable, vals.get(FIELD_IsApplicable))); //
        _CultureElement.readExternalData(vals.get(SINGLEREFERENCE_CultureElement));
        _CultureElementRating.readExternalData(vals.get(SINGLEREFERENCE_CultureElementRating));
        _Job.readExternalData(vals.get(SINGLEREFERENCE_Job));
        _Template.readExternalData(vals.get(SINGLEREFERENCE_Template));
        
    }


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

        vals.put (FIELD_Importance, HELPER_Importance.writeExternal (_Importance));
        vals.put (FIELD_IsApplicable, HELPER_IsApplicable.writeExternal (_IsApplicable));
        vals.put (SINGLEREFERENCE_CultureElement, _CultureElement.writeExternalData());
        vals.put (SINGLEREFERENCE_CultureElementRating, _CultureElementRating.writeExternalData());
        vals.put (SINGLEREFERENCE_Job, _Job.writeExternalData());
        vals.put (SINGLEREFERENCE_Template, _Template.writeExternalData());
        
    }


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

        if (other instanceof BaseCultureCriteria)
        {
            BaseCultureCriteria otherCultureCriteria = (BaseCultureCriteria)(other);

            
            if (!HELPER_Importance.compare(this._Importance, otherCultureCriteria._Importance))
            {
                listener.notifyFieldChange(this, other, FIELD_Importance, HELPER_Importance.toObject(this._Importance), HELPER_Importance.toObject(otherCultureCriteria._Importance));
            }
            if (!HELPER_IsApplicable.compare(this._IsApplicable, otherCultureCriteria._IsApplicable))
            {
                listener.notifyFieldChange(this, other, FIELD_IsApplicable, HELPER_IsApplicable.toObject(this._IsApplicable), HELPER_IsApplicable.toObject(otherCultureCriteria._IsApplicable));
            }

            // Compare single assocs
            _CultureElement.compare (otherCultureCriteria._CultureElement, listener);
            _CultureElementRating.compare (otherCultureCriteria._CultureElementRating, listener);
            _Job.compare (otherCultureCriteria._Job, listener);
            _Template.compare (otherCultureCriteria._Template, 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_Importance, HELPER_Importance.toObject(getImportance()));
        visitor.visitField(this, FIELD_IsApplicable, HELPER_IsApplicable.toObject(getIsApplicable()));
        visitor.visitAssociation (_CultureElement);
        visitor.visitAssociation (_CultureElementRating);
        visitor.visitAssociation (_Job);
        visitor.visitAssociation (_Template);
        
    }


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

        if (scope.includes (_CultureElement))
        {
            visitor.visit (_CultureElement);
        }
        if (scope.includes (_CultureElementRating))
        {
            visitor.visit (_CultureElementRating);
        }
        if (scope.includes (_Job))
        {
            visitor.visit (_Job);
        }
        if (scope.includes (_Template))
        {
            visitor.visit (_Template);
        }
        
    }


    public static CultureCriteria createCultureCriteria (ObjectTransaction transaction) throws StorageException
    {
        CultureCriteria     result = new CultureCriteria ();

        result.initialiseNewObject (transaction);

        return result;
    }


    public static CultureCriteria getCultureCriteriaByID (ObjectTransaction transaction, Long objectID) throws StorageException
    {
        return (CultureCriteria)(transaction.getObjectByID (REFERENCE_CultureCriteria, objectID));
    }

    public boolean testFilter (String attribName, QueryFilter filter) throws StorageException
    {
        if (false)
        {
            throw new RuntimeException ("Game over man!!");
        }
        else if (attribName.equals (FIELD_Importance))
        {
            return filter.matches (getImportance ());
        }
        else if (attribName.equals (FIELD_IsApplicable))
        {
            return filter.matches (getIsApplicable ());
        }
        else if (attribName.equals (SINGLEREFERENCE_CultureElement))
        {
            return filter.matches (getCultureElement ());
        }
        else if (attribName.equals (SINGLEREFERENCE_CultureElementRating))
        {
            return filter.matches (getCultureElementRating ());
        }
        else if (attribName.equals (SINGLEREFERENCE_Job))
        {
            return filter.matches (getJob ());
        }
        else if (attribName.equals (SINGLEREFERENCE_Template))
        {
            return filter.matches (getTemplate ());
        }
        else
        {
            return super.testFilter (attribName, filter);
        }
    }


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

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

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

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

            
            public SearchAll andImportance (QueryFilter<Importance> filter)
            {
                filter.addFilter (context, "tl_culture_criteria.importance", "Importance");
                return this;
            }
            
            public SearchAll andIsApplicable (QueryFilter<Boolean> filter)
            {
                filter.addFilter (context, "tl_culture_criteria.is_applicable", "IsApplicable");
                return this;
            }
            
            public SearchAll andCultureElement (QueryFilter<CultureElement> filter)
            {
                filter.addFilter (context, "tl_culture_criteria.culture_element_id", "CultureElement");
                return this;
            }
            
            public SearchAll andCultureElementRating (QueryFilter<CultureElementRating> filter)
            {
                filter.addFilter (context, "tl_culture_criteria.culture_element_rating_id", "CultureElementRating");
                return this;
            }
            
            public SearchAll andJob (QueryFilter<Job> filter)
            {
                filter.addFilter (context, "tl_culture_criteria.job_id", "Job");
                return this;
            }
            
            public SearchAll andTemplate (QueryFilter<CultureCriteriaTemplate> filter)
            {
                filter.addFilter (context, "tl_culture_criteria.template_id", "Template");
                return this;
            }
            
                public CultureCriteria[]
             search (ObjectTransaction transaction) throws StorageException
        {
            
            
            BaseBusinessClass[]     results = super.search (transaction, REFERENCE_CultureCriteria, SEARCH_All, criteria);
            Set<CultureCriteria>   typedResults = new LinkedHashSet <CultureCriteria> ();
            for (BaseBusinessClass bbcResult : results)
            {
                CultureCriteria aResult = (CultureCriteria)bbcResult;
                
                typedResults.add (aResult);
            }
            
                    return ObjstoreUtils.removeDeleted(transaction, typedResults).toArray (new CultureCriteria[0]);
                            
        }
    }

        
                public static CultureCriteria[]
             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_Importance))
        {
            return HELPER_Importance.toObject (getImportance ());
        }
        else if (attribName.equals (FIELD_IsApplicable))
        {
            return HELPER_IsApplicable.toObject (getIsApplicable ());
        }
        else
        {
            return super.getAttribute (attribName);
        }
    }


    public AttributeHelper getAttributeHelper (String attribName)
    {
        if (false)
        {
            throw new RuntimeException ("Game over man!!");
        }
        else if (attribName.equals (FIELD_Importance))
        {
            return HELPER_Importance;
        }
        else if (attribName.equals (FIELD_IsApplicable))
        {
            return HELPER_IsApplicable;
        }
        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_Importance))
        {
            setImportance ((Importance)(HELPER_Importance.fromObject (_Importance, attribValue)));            
        }
        else if (attribName.equals (FIELD_IsApplicable))
        {
            setIsApplicable ((Boolean)(HELPER_IsApplicable.fromObject (_IsApplicable, 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_Importance))
        {
            return getWriteability_Importance ();
        }
        else if (fieldName.equals (FIELD_IsApplicable))
        {
            return getWriteability_IsApplicable ();
        }
        else if (fieldName.equals (SINGLEREFERENCE_CultureElement))
        {
            return getWriteability_CultureElement ();
        }
        else if (fieldName.equals (SINGLEREFERENCE_CultureElementRating))
        {
            return getWriteability_CultureElementRating ();
        }
        else if (fieldName.equals (SINGLEREFERENCE_Job))
        {
            return getWriteability_Job ();
        }
        else if (fieldName.equals (SINGLEREFERENCE_Template))
        {
            return getWriteability_Template ();
        }
        else
        {
            return super.getWriteable (fieldName);
        }
    }


    public void putUnwriteable (Set<String> fields)
    {
        
            if (getWriteability_Importance () != FieldWriteability.TRUE)
            {
                fields.add (FIELD_Importance);
            }
        
            if (getWriteability_IsApplicable () != FieldWriteability.TRUE)
            {
                fields.add (FIELD_IsApplicable);
            }
        

        super.putUnwriteable (fields);
    }

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

        
        result.add(HELPER_Importance.getAttribObject (getClass (), _Importance, false, FIELD_Importance));
        result.add(HELPER_IsApplicable.getAttribObject (getClass (), _IsApplicable, false, FIELD_IsApplicable));

        return result;
    }


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


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

    /**
     * Get the attribute Importance
     */
    public Importance getImportance (CultureCriteria obj, Importance original)
    {
        return original;
    }

    /**
     * Change the value set for attribute Importance.
     * May modify the field beforehand
     * Occurs before validation.
     */
    public Importance setImportance (CultureCriteria obj, Importance newImportance) throws FieldException
    {
        return newImportance;
    }

    /**
     * Get the attribute IsApplicable
     */
    public Boolean getIsApplicable (CultureCriteria obj, Boolean original)
    {
        return original;
    }

    /**
     * Change the value set for attribute IsApplicable.
     * May modify the field beforehand
     * Occurs before validation.
     */
    public Boolean setIsApplicable (CultureCriteria obj, Boolean newIsApplicable) throws FieldException
    {
        return newIsApplicable;
    }

    }

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

        public CultureCriteriaPipeLineFactory (Collection<From> seed)
        {
            super(seed);
        }
        
        
        public PipeLine<From, ? extends Object> to(String name)
        {
            if (name.equals ("Importance"))
            {
                return toImportance ();
            }                
            if (name.equals ("IsApplicable"))
            {
                return toIsApplicable ();
            }                
            if (name.equals ("CultureElement"))
            {
                return toCultureElement ();
            }                
            if (name.equals ("CultureElementRating"))
            {
                return toCultureElementRating ();
            }                
            if (name.equals ("Job"))
            {
                return toJob ();
            }                
            if (name.equals ("Template"))
            {
                return toTemplate ();
            }                
            
            
            return super.to(name);
        }
        
        
        public PipeLine<From, Importance> toImportance () { return pipe(new ORMAttributePipe<Me, Importance>(FIELD_Importance));  }
        
        public PipeLine<From, Boolean> toIsApplicable () { return pipe(new ORMAttributePipe<Me, Boolean>(FIELD_IsApplicable));  }
        public CultureElement.CultureElementPipeLineFactory<From, CultureElement> toCultureElement () { return toCultureElement (Filter.ALL); }

        public CultureElement.CultureElementPipeLineFactory<From, CultureElement> toCultureElement (Filter<CultureElement> filter) 
        { 
            return CultureElement.REFERENCE_CultureElement.new CultureElementPipeLineFactory<From, CultureElement> (this, new ORMSingleAssocPipe<Me, CultureElement>(SINGLEREFERENCE_CultureElement, filter)); 
        }
        public CultureElementRating.CultureElementRatingPipeLineFactory<From, CultureElementRating> toCultureElementRating () { return toCultureElementRating (Filter.ALL); }

        public CultureElementRating.CultureElementRatingPipeLineFactory<From, CultureElementRating> toCultureElementRating (Filter<CultureElementRating> filter) 
        { 
            return CultureElementRating.REFERENCE_CultureElementRating.new CultureElementRatingPipeLineFactory<From, CultureElementRating> (this, new ORMSingleAssocPipe<Me, CultureElementRating>(SINGLEREFERENCE_CultureElementRating, filter)); 
        }
        public Job.JobPipeLineFactory<From, Job> toJob () { return toJob (Filter.ALL); }

        public Job.JobPipeLineFactory<From, Job> toJob (Filter<Job> filter) 
        { 
            return Job.REFERENCE_Job.new JobPipeLineFactory<From, Job> (this, new ORMSingleAssocPipe<Me, Job>(SINGLEREFERENCE_Job, filter)); 
        }
        public CultureCriteriaTemplate.CultureCriteriaTemplatePipeLineFactory<From, CultureCriteriaTemplate> toTemplate () { return toTemplate (Filter.ALL); }

        public CultureCriteriaTemplate.CultureCriteriaTemplatePipeLineFactory<From, CultureCriteriaTemplate> toTemplate (Filter<CultureCriteriaTemplate> filter) 
        { 
            return CultureCriteriaTemplate.REFERENCE_CultureCriteriaTemplate.new CultureCriteriaTemplatePipeLineFactory<From, CultureCriteriaTemplate> (this, new ORMSingleAssocPipe<Me, CultureCriteriaTemplate>(SINGLEREFERENCE_Template, filter)); 
        }
        
    }
    
    public boolean isTransientAttrib(String attribName)
    {
        

        return super.isTransientAttrib(attribName);
    }

    public boolean isTransientSingleReference(String assocName)
    {
        

        return super.isTransientSingleReference(assocName);
    }
}

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

    public void assertValid ()
    {
    }


    public CultureElement getCultureElement () throws StorageException
    {
        return (CultureElement)(CultureElement.DUMMY_CultureElement);
    }


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

    public CultureElementRating getCultureElementRating () throws StorageException
    {
        return (CultureElementRating)(CultureElementRating.DUMMY_CultureElementRating);
    }


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

    public Job getJob () throws StorageException
    {
        return (Job)(Job.DUMMY_Job);
    }


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

    public CultureCriteriaTemplate getTemplate () throws StorageException
    {
        return (CultureCriteriaTemplate)(CultureCriteriaTemplate.DUMMY_CultureCriteriaTemplate);
    }


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

}

    
