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



public abstract class BaseLevel extends BaseBusinessClass
{
    // Reference instance for the object
    public static final Level REFERENCE_Level = new Level ();

    // Reference instance for the object
    public static final Level DUMMY_Level = new DummyLevel ();

    // Static constants corresponding to field names
    
    public static final String FIELD_LevelDescription = "LevelDescription";
    public static final String FIELD_LevelNotes = "LevelNotes";
    public static final String FIELD_ReportHeader = "ReportHeader";
    public static final String FIELD_AppliedToExpress = "AppliedToExpress";
    public static final String FIELD_CSSClass = "CSSClass";
    public static final String FIELD_Enabled = "Enabled";
    public static final String MULTIPLEREFERENCE_Factors = "Factors";
    public static final String BACKREF_Factors = "";
    public static final String MULTIPLEREFERENCE_Results = "Results";
    public static final String BACKREF_Results = "";
    public static final String MULTIPLEREFERENCE_Narratives = "Narratives";
    public static final String BACKREF_Narratives = "";
    public static final String MULTIPLEREFERENCE_TestAnalysises = "TestAnalysises";
    public static final String BACKREF_TestAnalysises = "";
    public static final String MULTIPLEREFERENCE_LevelFactorTypes = "LevelFactorTypes";
    public static final String BACKREF_LevelFactorTypes = "";
    public static final String MULTIPLEREFERENCE_LevelClassCriterias = "LevelClassCriterias";
    public static final String BACKREF_LevelClassCriterias = "";
    public static final String MULTIPLEREFERENCE_LevelNormalisations = "LevelNormalisations";
    public static final String BACKREF_LevelNormalisations = "";
    public static final String MULTIPLEREFERENCE_ClassNormalisations = "ClassNormalisations";
    public static final String BACKREF_ClassNormalisations = "";

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

    // Static constants corresponding to attribute helpers
    private static final DefaultAttributeHelper<Level> HELPER_LevelDescription = DefaultAttributeHelper.INSTANCE;
    private static final DefaultAttributeHelper<Level> HELPER_LevelNotes = DefaultAttributeHelper.INSTANCE;
    private static final DefaultAttributeHelper<Level> HELPER_ReportHeader = DefaultAttributeHelper.INSTANCE;
    private static final DefaultAttributeHelper<Level> HELPER_AppliedToExpress = DefaultAttributeHelper.INSTANCE;
    private static final DefaultAttributeHelper<Level> HELPER_CSSClass = DefaultAttributeHelper.INSTANCE;
    private static final DefaultAttributeHelper<Level> HELPER_Enabled = DefaultAttributeHelper.INSTANCE;
    

    // Private attributes corresponding to business object data
    private String _LevelDescription;
    private String _LevelNotes;
    private String _ReportHeader;
    private Boolean _AppliedToExpress;
    private String _CSSClass;
    private Boolean _Enabled;
    

    // Private attributes corresponding to single references
    

    // Private attributes corresponding to multiple references
    private MultipleAssociation<Level, FactorLevelLink> _Factors;
    private MultipleAssociation<Level, FactorScoreResult> _Results;
    private MultipleAssociation<Level, Narrative> _Narratives;
    private MultipleAssociation<Level, TestAnalysis> _TestAnalysises;
    private MultipleAssociation<Level, LevelFactorType> _LevelFactorTypes;
    private MultipleAssociation<Level, LevelClassCriteria> _LevelClassCriterias;
    private MultipleAssociation<Level, LevelNormalisation> _LevelNormalisations;
    private MultipleAssociation<Level, ClassNormalisation> _ClassNormalisations;
    

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

    // Arrays of validators for each attribute
    private static final AttributeValidator[] FIELD_LevelDescription_Validators;
    private static final AttributeValidator[] FIELD_LevelNotes_Validators;
    private static final AttributeValidator[] FIELD_ReportHeader_Validators;
    private static final AttributeValidator[] FIELD_AppliedToExpress_Validators;
    private static final AttributeValidator[] FIELD_CSSClass_Validators;
    private static final AttributeValidator[] FIELD_Enabled_Validators;
    

    // Arrays of behaviour decorators
    private static final LevelBehaviourDecorator[] Level_BehaviourDecorators;
    
    static
    {
        try
        {
            
            String tmp_Factors = FactorLevelLink.BACKREF_Level;
            String tmp_Results = FactorScoreResult.BACKREF_Level;
            String tmp_Narratives = Narrative.BACKREF_Level;
            String tmp_TestAnalysises = TestAnalysis.BACKREF_Level;
            String tmp_LevelFactorTypes = LevelFactorType.BACKREF_Level;
            String tmp_LevelClassCriterias = LevelClassCriteria.BACKREF_Level;
            String tmp_LevelNormalisations = LevelNormalisation.BACKREF_Level;
            String tmp_ClassNormalisations = ClassNormalisation.BACKREF_Level;
            
            Map  validatorMapping = ((Map)ConfigMgr.getConfigObject ("CONFIG.ORMVALIDATOR", "ValidatorMapping"));

            setupAssocMetaData_Factors();
            setupAssocMetaData_Results();
            setupAssocMetaData_Narratives();
            setupAssocMetaData_TestAnalysises();
            setupAssocMetaData_LevelFactorTypes();
            setupAssocMetaData_LevelClassCriterias();
            setupAssocMetaData_LevelNormalisations();
            setupAssocMetaData_ClassNormalisations();
            FIELD_LevelDescription_Validators = (AttributeValidator[])setupAttribMetaData_LevelDescription(validatorMapping).toArray (new AttributeValidator[0]);
            FIELD_LevelNotes_Validators = (AttributeValidator[])setupAttribMetaData_LevelNotes(validatorMapping).toArray (new AttributeValidator[0]);
            FIELD_ReportHeader_Validators = (AttributeValidator[])setupAttribMetaData_ReportHeader(validatorMapping).toArray (new AttributeValidator[0]);
            FIELD_AppliedToExpress_Validators = (AttributeValidator[])setupAttribMetaData_AppliedToExpress(validatorMapping).toArray (new AttributeValidator[0]);
            FIELD_CSSClass_Validators = (AttributeValidator[])setupAttribMetaData_CSSClass(validatorMapping).toArray (new AttributeValidator[0]);
            FIELD_Enabled_Validators = (AttributeValidator[])setupAttribMetaData_Enabled(validatorMapping).toArray (new AttributeValidator[0]);
            

            REFERENCE_Level.initialiseReference ();
            DUMMY_Level.initialiseReference ();
            Level_BehaviourDecorators = BaseBusinessClass.getBBCBehaviours(Level.class).toArray(new LevelBehaviourDecorator[0]);
        }
        catch (RuntimeException e)
        {
            LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR1, e, "Error initialising");
            throw e;
        }
    }

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

        metaInfo.put ("backreferenceName", "Level");
        metaInfo.put ("name", "Factors");
        metaInfo.put ("type", "FactorLevelLink");
        
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for Level.Factors:", metaInfo);
        ATTRIBUTES_METADATA_Level.put (MULTIPLEREFERENCE_Factors, Collections.unmodifiableMap (metaInfo));
    }
    
    
    // Meta Info setup
    private static void setupAssocMetaData_Results()
    {
        Map metaInfo = new HashMap ();

        metaInfo.put ("backreferenceName", "Level");
        metaInfo.put ("name", "Results");
        metaInfo.put ("type", "FactorScoreResult");
        
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for Level.Results:", metaInfo);
        ATTRIBUTES_METADATA_Level.put (MULTIPLEREFERENCE_Results, Collections.unmodifiableMap (metaInfo));
    }
    
    
    // Meta Info setup
    private static void setupAssocMetaData_Narratives()
    {
        Map metaInfo = new HashMap ();

        metaInfo.put ("backreferenceName", "Level");
        metaInfo.put ("name", "Narratives");
        metaInfo.put ("type", "Narrative");
        
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for Level.Narratives:", metaInfo);
        ATTRIBUTES_METADATA_Level.put (MULTIPLEREFERENCE_Narratives, Collections.unmodifiableMap (metaInfo));
    }
    
    
    // Meta Info setup
    private static void setupAssocMetaData_TestAnalysises()
    {
        Map metaInfo = new HashMap ();

        metaInfo.put ("backreferenceName", "Level");
        metaInfo.put ("name", "TestAnalysises");
        metaInfo.put ("type", "TestAnalysis");
        
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for Level.TestAnalysises:", metaInfo);
        ATTRIBUTES_METADATA_Level.put (MULTIPLEREFERENCE_TestAnalysises, Collections.unmodifiableMap (metaInfo));
    }
    
    
    // Meta Info setup
    private static void setupAssocMetaData_LevelFactorTypes()
    {
        Map metaInfo = new HashMap ();

        metaInfo.put ("backreferenceName", "Level");
        metaInfo.put ("name", "LevelFactorTypes");
        metaInfo.put ("type", "LevelFactorType");
        
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for Level.LevelFactorTypes:", metaInfo);
        ATTRIBUTES_METADATA_Level.put (MULTIPLEREFERENCE_LevelFactorTypes, Collections.unmodifiableMap (metaInfo));
    }
    
    
    // Meta Info setup
    private static void setupAssocMetaData_LevelClassCriterias()
    {
        Map metaInfo = new HashMap ();

        metaInfo.put ("backreferenceName", "Level");
        metaInfo.put ("name", "LevelClassCriterias");
        metaInfo.put ("type", "LevelClassCriteria");
        
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for Level.LevelClassCriterias:", metaInfo);
        ATTRIBUTES_METADATA_Level.put (MULTIPLEREFERENCE_LevelClassCriterias, Collections.unmodifiableMap (metaInfo));
    }
    
    
    // Meta Info setup
    private static void setupAssocMetaData_LevelNormalisations()
    {
        Map metaInfo = new HashMap ();

        metaInfo.put ("backreferenceName", "Level");
        metaInfo.put ("name", "LevelNormalisations");
        metaInfo.put ("type", "LevelNormalisation");
        
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for Level.LevelNormalisations:", metaInfo);
        ATTRIBUTES_METADATA_Level.put (MULTIPLEREFERENCE_LevelNormalisations, Collections.unmodifiableMap (metaInfo));
    }
    
    
    // Meta Info setup
    private static void setupAssocMetaData_ClassNormalisations()
    {
        Map metaInfo = new HashMap ();

        metaInfo.put ("backreferenceName", "Level");
        metaInfo.put ("name", "ClassNormalisations");
        metaInfo.put ("type", "ClassNormalisation");
        
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for Level.ClassNormalisations:", metaInfo);
        ATTRIBUTES_METADATA_Level.put (MULTIPLEREFERENCE_ClassNormalisations, Collections.unmodifiableMap (metaInfo));
    }
    
    
    // Meta Info setup
    private static List setupAttribMetaData_LevelDescription(Map validatorMapping)
    {
        Map  metaInfo   = new HashMap ();

        metaInfo.put ("dbcol", "level_desc");
        metaInfo.put ("length", "30");
        metaInfo.put ("name", "LevelDescription");
        metaInfo.put ("type", "String");
        
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for Level.LevelDescription:", metaInfo);
        ATTRIBUTES_METADATA_Level.put (FIELD_LevelDescription, Collections.unmodifiableMap (metaInfo));

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

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

        metaInfo.put ("dbcol", "level_notes");
        metaInfo.put ("name", "LevelNotes");
        metaInfo.put ("type", "String");
        
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for Level.LevelNotes:", metaInfo);
        ATTRIBUTES_METADATA_Level.put (FIELD_LevelNotes, Collections.unmodifiableMap (metaInfo));

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

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

        metaInfo.put ("dbcol", "rpt_hdr");
        metaInfo.put ("name", "ReportHeader");
        metaInfo.put ("type", "String");
        
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for Level.ReportHeader:", metaInfo);
        ATTRIBUTES_METADATA_Level.put (FIELD_ReportHeader, Collections.unmodifiableMap (metaInfo));

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

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

        metaInfo.put ("dbcol", "applied_to_express");
        metaInfo.put ("defaultValue", "Boolean.FALSE");
        metaInfo.put ("name", "AppliedToExpress");
        metaInfo.put ("type", "Boolean");
        
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for Level.AppliedToExpress:", metaInfo);
        ATTRIBUTES_METADATA_Level.put (FIELD_AppliedToExpress, Collections.unmodifiableMap (metaInfo));

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

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

        metaInfo.put ("dbcol", "css_class");
        metaInfo.put ("length", "100");
        metaInfo.put ("name", "CSSClass");
        metaInfo.put ("type", "String");
        
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for Level.CSSClass:", metaInfo);
        ATTRIBUTES_METADATA_Level.put (FIELD_CSSClass, Collections.unmodifiableMap (metaInfo));

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

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

        metaInfo.put ("dbcol", "enabled");
        metaInfo.put ("defaultValue", "Boolean.FALSE");
        metaInfo.put ("name", "Enabled");
        metaInfo.put ("type", "Boolean");
        
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for Level.Enabled:", metaInfo);
        ATTRIBUTES_METADATA_Level.put (FIELD_Enabled, Collections.unmodifiableMap (metaInfo));

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

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


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


    


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

        
        _LevelDescription = (String)(HELPER_LevelDescription.initialise (_LevelDescription));
        _LevelNotes = (String)(HELPER_LevelNotes.initialise (_LevelNotes));
        _ReportHeader = (String)(HELPER_ReportHeader.initialise (_ReportHeader));
        _AppliedToExpress = (Boolean)(Boolean.FALSE);
        _CSSClass = (String)(HELPER_CSSClass.initialise (_CSSClass));
        _Enabled = (Boolean)(Boolean.FALSE);
    }


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

        _Factors = new MultipleAssociation<Level, FactorLevelLink> (this, MULTIPLEREFERENCE_Factors, FactorLevelLink.SINGLEREFERENCE_Level, FactorLevelLink.REFERENCE_FactorLevelLink);
        _Results = new MultipleAssociation<Level, FactorScoreResult> (this, MULTIPLEREFERENCE_Results, FactorScoreResult.SINGLEREFERENCE_Level, FactorScoreResult.REFERENCE_FactorScoreResult);
        _Narratives = new MultipleAssociation<Level, Narrative> (this, MULTIPLEREFERENCE_Narratives, Narrative.SINGLEREFERENCE_Level, Narrative.REFERENCE_Narrative);
        _TestAnalysises = new MultipleAssociation<Level, TestAnalysis> (this, MULTIPLEREFERENCE_TestAnalysises, TestAnalysis.SINGLEREFERENCE_Level, TestAnalysis.REFERENCE_TestAnalysis);
        _LevelFactorTypes = new MultipleAssociation<Level, LevelFactorType> (this, MULTIPLEREFERENCE_LevelFactorTypes, LevelFactorType.SINGLEREFERENCE_Level, LevelFactorType.REFERENCE_LevelFactorType);
        _LevelClassCriterias = new MultipleAssociation<Level, LevelClassCriteria> (this, MULTIPLEREFERENCE_LevelClassCriterias, LevelClassCriteria.SINGLEREFERENCE_Level, LevelClassCriteria.REFERENCE_LevelClassCriteria);
        _LevelNormalisations = new MultipleAssociation<Level, LevelNormalisation> (this, MULTIPLEREFERENCE_LevelNormalisations, LevelNormalisation.SINGLEREFERENCE_Level, LevelNormalisation.REFERENCE_LevelNormalisation);
        _ClassNormalisations = new MultipleAssociation<Level, ClassNormalisation> (this, MULTIPLEREFERENCE_ClassNormalisations, ClassNormalisation.SINGLEREFERENCE_Level, ClassNormalisation.REFERENCE_ClassNormalisation);
        
    }


    // Initialise the associations
    protected BaseBusinessClass initialiseReference ()
    {
        super.initialiseReference ();
        
        _Factors = new MultipleAssociation<Level, FactorLevelLink> (this, MULTIPLEREFERENCE_Factors, FactorLevelLink.SINGLEREFERENCE_Level, FactorLevelLink.REFERENCE_FactorLevelLink);
        _Results = new MultipleAssociation<Level, FactorScoreResult> (this, MULTIPLEREFERENCE_Results, FactorScoreResult.SINGLEREFERENCE_Level, FactorScoreResult.REFERENCE_FactorScoreResult);
        _Narratives = new MultipleAssociation<Level, Narrative> (this, MULTIPLEREFERENCE_Narratives, Narrative.SINGLEREFERENCE_Level, Narrative.REFERENCE_Narrative);
        _TestAnalysises = new MultipleAssociation<Level, TestAnalysis> (this, MULTIPLEREFERENCE_TestAnalysises, TestAnalysis.SINGLEREFERENCE_Level, TestAnalysis.REFERENCE_TestAnalysis);
        _LevelFactorTypes = new MultipleAssociation<Level, LevelFactorType> (this, MULTIPLEREFERENCE_LevelFactorTypes, LevelFactorType.SINGLEREFERENCE_Level, LevelFactorType.REFERENCE_LevelFactorType);
        _LevelClassCriterias = new MultipleAssociation<Level, LevelClassCriteria> (this, MULTIPLEREFERENCE_LevelClassCriterias, LevelClassCriteria.SINGLEREFERENCE_Level, LevelClassCriteria.REFERENCE_LevelClassCriteria);
        _LevelNormalisations = new MultipleAssociation<Level, LevelNormalisation> (this, MULTIPLEREFERENCE_LevelNormalisations, LevelNormalisation.SINGLEREFERENCE_Level, LevelNormalisation.REFERENCE_LevelNormalisation);
        _ClassNormalisations = new MultipleAssociation<Level, ClassNormalisation> (this, MULTIPLEREFERENCE_ClassNormalisations, ClassNormalisation.SINGLEREFERENCE_Level, ClassNormalisation.REFERENCE_ClassNormalisation);
        
        
        return this;
    }

    

    /**
     * Get the attribute LevelDescription
     */
    public String getLevelDescription ()
    {
        assertValid();
        String valToReturn = _LevelDescription;

            for (LevelBehaviourDecorator bhd : Level_BehaviourDecorators)
            {
                valToReturn = bhd.getLevelDescription ((Level)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 preLevelDescriptionChange (String newLevelDescription) 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 postLevelDescriptionChange () throws FieldException
    {
    }

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

    /**
     * Set the attribute LevelDescription.  Checks to ensure a new value
     * has been supplied.  If so, marks the field as altered and sets the attribute.
     */
    public void setLevelDescription (String newLevelDescription) throws FieldException
    {
        boolean oldAndNewIdentical = HELPER_LevelDescription.compare (_LevelDescription, newLevelDescription);
        
        try
        {
            for (LevelBehaviourDecorator bhd : Level_BehaviourDecorators)
            {
                newLevelDescription = bhd.setLevelDescription ((Level)this, newLevelDescription);
                oldAndNewIdentical = HELPER_LevelDescription.compare (_LevelDescription, newLevelDescription);
            }

            

            if (FIELD_LevelDescription_Validators.length > 0)
            {
                Object newLevelDescriptionObj = HELPER_LevelDescription.toObject (newLevelDescription);

                if (newLevelDescriptionObj != null)
                {
                    int     loopMax = FIELD_LevelDescription_Validators.length;
                    Map     metadata = (Map)ATTRIBUTES_METADATA_Level.get (FIELD_LevelDescription);

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

        if (!oldAndNewIdentical)
        {
            assertValid();
            Debug.assertion (getWriteability_LevelDescription () != FieldWriteability.FALSE, "Field  LevelDescription is not writeable");
            preLevelDescriptionChange (newLevelDescription);
            markFieldChange (FIELD_LevelDescription);
            _LevelDescription = newLevelDescription;            
            postFieldChange (FIELD_LevelDescription);
            postLevelDescriptionChange ();
        }
    }

    /**
     * Get the attribute LevelNotes
     */
    public String getLevelNotes ()
    {
        assertValid();
        String valToReturn = _LevelNotes;

            for (LevelBehaviourDecorator bhd : Level_BehaviourDecorators)
            {
                valToReturn = bhd.getLevelNotes ((Level)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 preLevelNotesChange (String newLevelNotes) 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 postLevelNotesChange () throws FieldException
    {
    }

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

    /**
     * Set the attribute LevelNotes.  Checks to ensure a new value
     * has been supplied.  If so, marks the field as altered and sets the attribute.
     */
    public void setLevelNotes (String newLevelNotes) throws FieldException
    {
        boolean oldAndNewIdentical = HELPER_LevelNotes.compare (_LevelNotes, newLevelNotes);
        
        try
        {
            for (LevelBehaviourDecorator bhd : Level_BehaviourDecorators)
            {
                newLevelNotes = bhd.setLevelNotes ((Level)this, newLevelNotes);
                oldAndNewIdentical = HELPER_LevelNotes.compare (_LevelNotes, newLevelNotes);
            }

            

            if (FIELD_LevelNotes_Validators.length > 0)
            {
                Object newLevelNotesObj = HELPER_LevelNotes.toObject (newLevelNotes);

                if (newLevelNotesObj != null)
                {
                    int     loopMax = FIELD_LevelNotes_Validators.length;
                    Map     metadata = (Map)ATTRIBUTES_METADATA_Level.get (FIELD_LevelNotes);

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

        if (!oldAndNewIdentical)
        {
            assertValid();
            Debug.assertion (getWriteability_LevelNotes () != FieldWriteability.FALSE, "Field  LevelNotes is not writeable");
            preLevelNotesChange (newLevelNotes);
            markFieldChange (FIELD_LevelNotes);
            _LevelNotes = newLevelNotes;            
            postFieldChange (FIELD_LevelNotes);
            postLevelNotesChange ();
        }
    }

    /**
     * Get the attribute ReportHeader
     */
    public String getReportHeader ()
    {
        assertValid();
        String valToReturn = _ReportHeader;

            for (LevelBehaviourDecorator bhd : Level_BehaviourDecorators)
            {
                valToReturn = bhd.getReportHeader ((Level)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 preReportHeaderChange (String newReportHeader) 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 postReportHeaderChange () throws FieldException
    {
    }

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

    /**
     * Set the attribute ReportHeader.  Checks to ensure a new value
     * has been supplied.  If so, marks the field as altered and sets the attribute.
     */
    public void setReportHeader (String newReportHeader) throws FieldException
    {
        boolean oldAndNewIdentical = HELPER_ReportHeader.compare (_ReportHeader, newReportHeader);
        
        try
        {
            for (LevelBehaviourDecorator bhd : Level_BehaviourDecorators)
            {
                newReportHeader = bhd.setReportHeader ((Level)this, newReportHeader);
                oldAndNewIdentical = HELPER_ReportHeader.compare (_ReportHeader, newReportHeader);
            }

            

            if (FIELD_ReportHeader_Validators.length > 0)
            {
                Object newReportHeaderObj = HELPER_ReportHeader.toObject (newReportHeader);

                if (newReportHeaderObj != null)
                {
                    int     loopMax = FIELD_ReportHeader_Validators.length;
                    Map     metadata = (Map)ATTRIBUTES_METADATA_Level.get (FIELD_ReportHeader);

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

        if (!oldAndNewIdentical)
        {
            assertValid();
            Debug.assertion (getWriteability_ReportHeader () != FieldWriteability.FALSE, "Field  ReportHeader is not writeable");
            preReportHeaderChange (newReportHeader);
            markFieldChange (FIELD_ReportHeader);
            _ReportHeader = newReportHeader;            
            postFieldChange (FIELD_ReportHeader);
            postReportHeaderChange ();
        }
    }

    /**
     * Get the attribute AppliedToExpress
     */
    public Boolean getAppliedToExpress ()
    {
        assertValid();
        Boolean valToReturn = _AppliedToExpress;

            for (LevelBehaviourDecorator bhd : Level_BehaviourDecorators)
            {
                valToReturn = bhd.getAppliedToExpress ((Level)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 preAppliedToExpressChange (Boolean newAppliedToExpress) 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 postAppliedToExpressChange () throws FieldException
    {
    }

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

    /**
     * Set the attribute AppliedToExpress.  Checks to ensure a new value
     * has been supplied.  If so, marks the field as altered and sets the attribute.
     */
    public void setAppliedToExpress (Boolean newAppliedToExpress) throws FieldException
    {
        boolean oldAndNewIdentical = HELPER_AppliedToExpress.compare (_AppliedToExpress, newAppliedToExpress);
        
        try
        {
            for (LevelBehaviourDecorator bhd : Level_BehaviourDecorators)
            {
                newAppliedToExpress = bhd.setAppliedToExpress ((Level)this, newAppliedToExpress);
                oldAndNewIdentical = HELPER_AppliedToExpress.compare (_AppliedToExpress, newAppliedToExpress);
            }

            

            if (FIELD_AppliedToExpress_Validators.length > 0)
            {
                Object newAppliedToExpressObj = HELPER_AppliedToExpress.toObject (newAppliedToExpress);

                if (newAppliedToExpressObj != null)
                {
                    int     loopMax = FIELD_AppliedToExpress_Validators.length;
                    Map     metadata = (Map)ATTRIBUTES_METADATA_Level.get (FIELD_AppliedToExpress);

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

        if (!oldAndNewIdentical)
        {
            assertValid();
            Debug.assertion (getWriteability_AppliedToExpress () != FieldWriteability.FALSE, "Field  AppliedToExpress is not writeable");
            preAppliedToExpressChange (newAppliedToExpress);
            markFieldChange (FIELD_AppliedToExpress);
            _AppliedToExpress = newAppliedToExpress;            
            postFieldChange (FIELD_AppliedToExpress);
            postAppliedToExpressChange ();
        }
    }

    /**
     * Get the attribute CSSClass
     */
    public String getCSSClass ()
    {
        assertValid();
        String valToReturn = _CSSClass;

            for (LevelBehaviourDecorator bhd : Level_BehaviourDecorators)
            {
                valToReturn = bhd.getCSSClass ((Level)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 preCSSClassChange (String newCSSClass) 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 postCSSClassChange () throws FieldException
    {
    }

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

    /**
     * Set the attribute CSSClass.  Checks to ensure a new value
     * has been supplied.  If so, marks the field as altered and sets the attribute.
     */
    public void setCSSClass (String newCSSClass) throws FieldException
    {
        boolean oldAndNewIdentical = HELPER_CSSClass.compare (_CSSClass, newCSSClass);
        
        try
        {
            for (LevelBehaviourDecorator bhd : Level_BehaviourDecorators)
            {
                newCSSClass = bhd.setCSSClass ((Level)this, newCSSClass);
                oldAndNewIdentical = HELPER_CSSClass.compare (_CSSClass, newCSSClass);
            }

            

            if (FIELD_CSSClass_Validators.length > 0)
            {
                Object newCSSClassObj = HELPER_CSSClass.toObject (newCSSClass);

                if (newCSSClassObj != null)
                {
                    int     loopMax = FIELD_CSSClass_Validators.length;
                    Map     metadata = (Map)ATTRIBUTES_METADATA_Level.get (FIELD_CSSClass);

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

        if (!oldAndNewIdentical)
        {
            assertValid();
            Debug.assertion (getWriteability_CSSClass () != FieldWriteability.FALSE, "Field  CSSClass is not writeable");
            preCSSClassChange (newCSSClass);
            markFieldChange (FIELD_CSSClass);
            _CSSClass = newCSSClass;            
            postFieldChange (FIELD_CSSClass);
            postCSSClassChange ();
        }
    }

    /**
     * Get the attribute Enabled
     */
    public Boolean getEnabled ()
    {
        assertValid();
        Boolean valToReturn = _Enabled;

            for (LevelBehaviourDecorator bhd : Level_BehaviourDecorators)
            {
                valToReturn = bhd.getEnabled ((Level)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 preEnabledChange (Boolean newEnabled) 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 postEnabledChange () throws FieldException
    {
    }

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

    /**
     * Set the attribute Enabled.  Checks to ensure a new value
     * has been supplied.  If so, marks the field as altered and sets the attribute.
     */
    public void setEnabled (Boolean newEnabled) throws FieldException
    {
        boolean oldAndNewIdentical = HELPER_Enabled.compare (_Enabled, newEnabled);
        
        try
        {
            for (LevelBehaviourDecorator bhd : Level_BehaviourDecorators)
            {
                newEnabled = bhd.setEnabled ((Level)this, newEnabled);
                oldAndNewIdentical = HELPER_Enabled.compare (_Enabled, newEnabled);
            }

            

            if (FIELD_Enabled_Validators.length > 0)
            {
                Object newEnabledObj = HELPER_Enabled.toObject (newEnabled);

                if (newEnabledObj != null)
                {
                    int     loopMax = FIELD_Enabled_Validators.length;
                    Map     metadata = (Map)ATTRIBUTES_METADATA_Level.get (FIELD_Enabled);

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

        if (!oldAndNewIdentical)
        {
            assertValid();
            Debug.assertion (getWriteability_Enabled () != FieldWriteability.FALSE, "Field  Enabled is not writeable");
            preEnabledChange (newEnabled);
            markFieldChange (FIELD_Enabled);
            _Enabled = newEnabled;            
            postFieldChange (FIELD_Enabled);
            postEnabledChange ();
        }
    }



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

        

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


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


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


    public Long getSingleAssocID (String assocName) throws StorageException
    {
        if (assocName == null)
        {
            throw new RuntimeException ("Game over == null!");
        }
        
        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
        {
            super.setSingleAssoc (assocName, newValue);
        }
    }



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

        
        result.add("Factors");
        
        result.add("Results");
        
        result.add("Narratives");
        
        result.add("TestAnalysises");
        
        result.add("LevelFactorTypes");
        
        result.add("LevelClassCriterias");
        
        result.add("LevelNormalisations");
        
        result.add("ClassNormalisations");
        

        return result;
    }


    /**
     * Get the reference instance for the multi assoc name.
     */
    public BaseBusinessClass getMultiAssocReferenceInstance(String attribName)
    {
        
        if (MULTIPLEREFERENCE_Factors.equals(attribName))
        {
            return FactorLevelLink.REFERENCE_FactorLevelLink ;
        }
        
        if (MULTIPLEREFERENCE_Results.equals(attribName))
        {
            return FactorScoreResult.REFERENCE_FactorScoreResult ;
        }
        
        if (MULTIPLEREFERENCE_Narratives.equals(attribName))
        {
            return Narrative.REFERENCE_Narrative ;
        }
        
        if (MULTIPLEREFERENCE_TestAnalysises.equals(attribName))
        {
            return TestAnalysis.REFERENCE_TestAnalysis ;
        }
        
        if (MULTIPLEREFERENCE_LevelFactorTypes.equals(attribName))
        {
            return LevelFactorType.REFERENCE_LevelFactorType ;
        }
        
        if (MULTIPLEREFERENCE_LevelClassCriterias.equals(attribName))
        {
            return LevelClassCriteria.REFERENCE_LevelClassCriteria ;
        }
        
        if (MULTIPLEREFERENCE_LevelNormalisations.equals(attribName))
        {
            return LevelNormalisation.REFERENCE_LevelNormalisation ;
        }
        
        if (MULTIPLEREFERENCE_ClassNormalisations.equals(attribName))
        {
            return ClassNormalisation.REFERENCE_ClassNormalisation ;
        }
        

        return super.getMultiAssocReferenceInstance(attribName);
    }


    public String getMultiAssocBackReference(String attribName)
    {
        
        if (MULTIPLEREFERENCE_Factors.equals(attribName))
        {
            return FactorLevelLink.SINGLEREFERENCE_Level ;
        }
        
        if (MULTIPLEREFERENCE_Results.equals(attribName))
        {
            return FactorScoreResult.SINGLEREFERENCE_Level ;
        }
        
        if (MULTIPLEREFERENCE_Narratives.equals(attribName))
        {
            return Narrative.SINGLEREFERENCE_Level ;
        }
        
        if (MULTIPLEREFERENCE_TestAnalysises.equals(attribName))
        {
            return TestAnalysis.SINGLEREFERENCE_Level ;
        }
        
        if (MULTIPLEREFERENCE_LevelFactorTypes.equals(attribName))
        {
            return LevelFactorType.SINGLEREFERENCE_Level ;
        }
        
        if (MULTIPLEREFERENCE_LevelClassCriterias.equals(attribName))
        {
            return LevelClassCriteria.SINGLEREFERENCE_Level ;
        }
        
        if (MULTIPLEREFERENCE_LevelNormalisations.equals(attribName))
        {
            return LevelNormalisation.SINGLEREFERENCE_Level ;
        }
        
        if (MULTIPLEREFERENCE_ClassNormalisations.equals(attribName))
        {
            return ClassNormalisation.SINGLEREFERENCE_Level ;
        }
        

        return super.getMultiAssocBackReference(attribName);
    }


    /**
     * Get the assoc count for the multi assoc name.
     */
    public int getMultiAssocCount(String attribName) throws StorageException
    {
        
        if (MULTIPLEREFERENCE_Factors.equals(attribName))
        {
            return this.getFactorsCount();
        }
        
        if (MULTIPLEREFERENCE_Results.equals(attribName))
        {
            return this.getResultsCount();
        }
        
        if (MULTIPLEREFERENCE_Narratives.equals(attribName))
        {
            return this.getNarrativesCount();
        }
        
        if (MULTIPLEREFERENCE_TestAnalysises.equals(attribName))
        {
            return this.getTestAnalysisesCount();
        }
        
        if (MULTIPLEREFERENCE_LevelFactorTypes.equals(attribName))
        {
            return this.getLevelFactorTypesCount();
        }
        
        if (MULTIPLEREFERENCE_LevelClassCriterias.equals(attribName))
        {
            return this.getLevelClassCriteriasCount();
        }
        
        if (MULTIPLEREFERENCE_LevelNormalisations.equals(attribName))
        {
            return this.getLevelNormalisationsCount();
        }
        
        if (MULTIPLEREFERENCE_ClassNormalisations.equals(attribName))
        {
            return this.getClassNormalisationsCount();
        }
        

        return super.getMultiAssocCount(attribName);
    }


    /**
     * Get the assoc at a particular index
     */
    public BaseBusinessClass getMultiAssocAt(String attribName, int index) throws StorageException
    {
        
        if (MULTIPLEREFERENCE_Factors.equals(attribName))
        {
            return this.getFactorsAt(index);
        }
        
        if (MULTIPLEREFERENCE_Results.equals(attribName))
        {
            return this.getResultsAt(index);
        }
        
        if (MULTIPLEREFERENCE_Narratives.equals(attribName))
        {
            return this.getNarrativesAt(index);
        }
        
        if (MULTIPLEREFERENCE_TestAnalysises.equals(attribName))
        {
            return this.getTestAnalysisesAt(index);
        }
        
        if (MULTIPLEREFERENCE_LevelFactorTypes.equals(attribName))
        {
            return this.getLevelFactorTypesAt(index);
        }
        
        if (MULTIPLEREFERENCE_LevelClassCriterias.equals(attribName))
        {
            return this.getLevelClassCriteriasAt(index);
        }
        
        if (MULTIPLEREFERENCE_LevelNormalisations.equals(attribName))
        {
            return this.getLevelNormalisationsAt(index);
        }
        
        if (MULTIPLEREFERENCE_ClassNormalisations.equals(attribName))
        {
            return this.getClassNormalisationsAt(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_Factors.equals(attribName))
        {
            addToFactors((FactorLevelLink)newElement);

            return;
        }
        
        if (MULTIPLEREFERENCE_Results.equals(attribName))
        {
            addToResults((FactorScoreResult)newElement);

            return;
        }
        
        if (MULTIPLEREFERENCE_Narratives.equals(attribName))
        {
            addToNarratives((Narrative)newElement);

            return;
        }
        
        if (MULTIPLEREFERENCE_TestAnalysises.equals(attribName))
        {
            addToTestAnalysises((TestAnalysis)newElement);

            return;
        }
        
        if (MULTIPLEREFERENCE_LevelFactorTypes.equals(attribName))
        {
            addToLevelFactorTypes((LevelFactorType)newElement);

            return;
        }
        
        if (MULTIPLEREFERENCE_LevelClassCriterias.equals(attribName))
        {
            addToLevelClassCriterias((LevelClassCriteria)newElement);

            return;
        }
        
        if (MULTIPLEREFERENCE_LevelNormalisations.equals(attribName))
        {
            addToLevelNormalisations((LevelNormalisation)newElement);

            return;
        }
        
        if (MULTIPLEREFERENCE_ClassNormalisations.equals(attribName))
        {
            addToClassNormalisations((ClassNormalisation)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_Factors.equals(attribName))
        {
            removeFromFactors((FactorLevelLink)oldElement);

            return;
        }
        
        if (MULTIPLEREFERENCE_Results.equals(attribName))
        {
            removeFromResults((FactorScoreResult)oldElement);

            return;
        }
        
        if (MULTIPLEREFERENCE_Narratives.equals(attribName))
        {
            removeFromNarratives((Narrative)oldElement);

            return;
        }
        
        if (MULTIPLEREFERENCE_TestAnalysises.equals(attribName))
        {
            removeFromTestAnalysises((TestAnalysis)oldElement);

            return;
        }
        
        if (MULTIPLEREFERENCE_LevelFactorTypes.equals(attribName))
        {
            removeFromLevelFactorTypes((LevelFactorType)oldElement);

            return;
        }
        
        if (MULTIPLEREFERENCE_LevelClassCriterias.equals(attribName))
        {
            removeFromLevelClassCriterias((LevelClassCriteria)oldElement);

            return;
        }
        
        if (MULTIPLEREFERENCE_LevelNormalisations.equals(attribName))
        {
            removeFromLevelNormalisations((LevelNormalisation)oldElement);

            return;
        }
        
        if (MULTIPLEREFERENCE_ClassNormalisations.equals(attribName))
        {
            removeFromClassNormalisations((ClassNormalisation)oldElement);

            return;
        }
        

        super.removeFromMultiAssoc(attribName, oldElement);
    }


    protected void __loadMultiAssoc (String attribName, BaseBusinessClass[] elements)
    {
        
        if (MULTIPLEREFERENCE_Factors.equals(attribName))
        {
            _Factors.__loadAssociation (elements);
            return;
        }
        
        if (MULTIPLEREFERENCE_Results.equals(attribName))
        {
            _Results.__loadAssociation (elements);
            return;
        }
        
        if (MULTIPLEREFERENCE_Narratives.equals(attribName))
        {
            _Narratives.__loadAssociation (elements);
            return;
        }
        
        if (MULTIPLEREFERENCE_TestAnalysises.equals(attribName))
        {
            _TestAnalysises.__loadAssociation (elements);
            return;
        }
        
        if (MULTIPLEREFERENCE_LevelFactorTypes.equals(attribName))
        {
            _LevelFactorTypes.__loadAssociation (elements);
            return;
        }
        
        if (MULTIPLEREFERENCE_LevelClassCriterias.equals(attribName))
        {
            _LevelClassCriterias.__loadAssociation (elements);
            return;
        }
        
        if (MULTIPLEREFERENCE_LevelNormalisations.equals(attribName))
        {
            _LevelNormalisations.__loadAssociation (elements);
            return;
        }
        
        if (MULTIPLEREFERENCE_ClassNormalisations.equals(attribName))
        {
            _ClassNormalisations.__loadAssociation (elements);
            return;
        }
        

        super.__loadMultiAssoc(attribName, elements);
    }


    protected boolean __isMultiAssocLoaded (String attribName)
    {
        
        if (MULTIPLEREFERENCE_Factors.equals(attribName))
        {
            return _Factors.isLoaded ();
        }
        
        if (MULTIPLEREFERENCE_Results.equals(attribName))
        {
            return _Results.isLoaded ();
        }
        
        if (MULTIPLEREFERENCE_Narratives.equals(attribName))
        {
            return _Narratives.isLoaded ();
        }
        
        if (MULTIPLEREFERENCE_TestAnalysises.equals(attribName))
        {
            return _TestAnalysises.isLoaded ();
        }
        
        if (MULTIPLEREFERENCE_LevelFactorTypes.equals(attribName))
        {
            return _LevelFactorTypes.isLoaded ();
        }
        
        if (MULTIPLEREFERENCE_LevelClassCriterias.equals(attribName))
        {
            return _LevelClassCriterias.isLoaded ();
        }
        
        if (MULTIPLEREFERENCE_LevelNormalisations.equals(attribName))
        {
            return _LevelNormalisations.isLoaded ();
        }
        
        if (MULTIPLEREFERENCE_ClassNormalisations.equals(attribName))
        {
            return _ClassNormalisations.isLoaded ();
        }
        

        return super.__isMultiAssocLoaded(attribName);
    }

    

    public FieldWriteability getWriteability_Factors ()
    {
        return getFieldWritabilityUtil (FieldWriteability.TRUE);
    }
    
    
    public int getFactorsCount () throws StorageException
    {
        assertValid();
        return _Factors.getReferencedObjectsCount ();
    }


    public void addToFactors (FactorLevelLink newElement) throws StorageException
    {
        if (_Factors.wouldAddChange (newElement))
        {
            assertValid();
            Debug.assertion (getWriteability_Factors () != FieldWriteability.FALSE, "MultiAssoc Factors is not writeable (add)");
            _Factors.appendElement (newElement);

            try
            {
                if (newElement.getLevel () != this)
                {
                    newElement.setLevel ((Level)(this));
                }
            }
            catch (Exception e)
            {
                throw NestedException.wrap(e);
            }
        }
    }


    public void removeFromFactors (FactorLevelLink elementToRemove) throws StorageException
    {
        if (_Factors.wouldRemoveChange (elementToRemove))
        {
            assertValid();
            Debug.assertion (getWriteability_Factors () != FieldWriteability.FALSE, "MultiAssoc Factors is not writeable (remove)");
            _Factors.removeElement (elementToRemove);
            try
            {
                if (elementToRemove.getLevel () != null)
                {
                    elementToRemove.setLevel (null);
                }
            }
            catch (Exception e)
            {
                throw NestedException.wrap(e);
            }
        }
    }


    public FactorLevelLink getFactorsAt (int index) throws StorageException
    {
        return (FactorLevelLink)(_Factors.getElementAt (index));
    }


    public SortedSet<FactorLevelLink> getFactorsSet () throws StorageException
    {
        return _Factors.getSet ();
    }

    public FieldWriteability getWriteability_Results ()
    {
        return getFieldWritabilityUtil (FieldWriteability.TRUE);
    }
    
    
    public int getResultsCount () throws StorageException
    {
        assertValid();
        return _Results.getReferencedObjectsCount ();
    }


    public void addToResults (FactorScoreResult newElement) throws StorageException
    {
        if (_Results.wouldAddChange (newElement))
        {
            assertValid();
            Debug.assertion (getWriteability_Results () != FieldWriteability.FALSE, "MultiAssoc Results is not writeable (add)");
            _Results.appendElement (newElement);

            try
            {
                if (newElement.getLevel () != this)
                {
                    newElement.setLevel ((Level)(this));
                }
            }
            catch (Exception e)
            {
                throw NestedException.wrap(e);
            }
        }
    }


    public void removeFromResults (FactorScoreResult elementToRemove) throws StorageException
    {
        if (_Results.wouldRemoveChange (elementToRemove))
        {
            assertValid();
            Debug.assertion (getWriteability_Results () != FieldWriteability.FALSE, "MultiAssoc Results is not writeable (remove)");
            _Results.removeElement (elementToRemove);
            try
            {
                if (elementToRemove.getLevel () != null)
                {
                    elementToRemove.setLevel (null);
                }
            }
            catch (Exception e)
            {
                throw NestedException.wrap(e);
            }
        }
    }


    public FactorScoreResult getResultsAt (int index) throws StorageException
    {
        return (FactorScoreResult)(_Results.getElementAt (index));
    }


    public SortedSet<FactorScoreResult> getResultsSet () throws StorageException
    {
        return _Results.getSet ();
    }

    public FieldWriteability getWriteability_Narratives ()
    {
        return getFieldWritabilityUtil (FieldWriteability.TRUE);
    }
    
    
    public int getNarrativesCount () throws StorageException
    {
        assertValid();
        return _Narratives.getReferencedObjectsCount ();
    }


    public void addToNarratives (Narrative newElement) throws StorageException
    {
        if (_Narratives.wouldAddChange (newElement))
        {
            assertValid();
            Debug.assertion (getWriteability_Narratives () != FieldWriteability.FALSE, "MultiAssoc Narratives is not writeable (add)");
            _Narratives.appendElement (newElement);

            try
            {
                if (newElement.getLevel () != this)
                {
                    newElement.setLevel ((Level)(this));
                }
            }
            catch (Exception e)
            {
                throw NestedException.wrap(e);
            }
        }
    }


    public void removeFromNarratives (Narrative elementToRemove) throws StorageException
    {
        if (_Narratives.wouldRemoveChange (elementToRemove))
        {
            assertValid();
            Debug.assertion (getWriteability_Narratives () != FieldWriteability.FALSE, "MultiAssoc Narratives is not writeable (remove)");
            _Narratives.removeElement (elementToRemove);
            try
            {
                if (elementToRemove.getLevel () != null)
                {
                    elementToRemove.setLevel (null);
                }
            }
            catch (Exception e)
            {
                throw NestedException.wrap(e);
            }
        }
    }


    public Narrative getNarrativesAt (int index) throws StorageException
    {
        return (Narrative)(_Narratives.getElementAt (index));
    }


    public SortedSet<Narrative> getNarrativesSet () throws StorageException
    {
        return _Narratives.getSet ();
    }

    public FieldWriteability getWriteability_TestAnalysises ()
    {
        return getFieldWritabilityUtil (FieldWriteability.TRUE);
    }
    
    
    public int getTestAnalysisesCount () throws StorageException
    {
        assertValid();
        return _TestAnalysises.getReferencedObjectsCount ();
    }


    public void addToTestAnalysises (TestAnalysis newElement) throws StorageException
    {
        if (_TestAnalysises.wouldAddChange (newElement))
        {
            assertValid();
            Debug.assertion (getWriteability_TestAnalysises () != FieldWriteability.FALSE, "MultiAssoc TestAnalysises is not writeable (add)");
            _TestAnalysises.appendElement (newElement);

            try
            {
                if (newElement.getLevel () != this)
                {
                    newElement.setLevel ((Level)(this));
                }
            }
            catch (Exception e)
            {
                throw NestedException.wrap(e);
            }
        }
    }


    public void removeFromTestAnalysises (TestAnalysis elementToRemove) throws StorageException
    {
        if (_TestAnalysises.wouldRemoveChange (elementToRemove))
        {
            assertValid();
            Debug.assertion (getWriteability_TestAnalysises () != FieldWriteability.FALSE, "MultiAssoc TestAnalysises is not writeable (remove)");
            _TestAnalysises.removeElement (elementToRemove);
            try
            {
                if (elementToRemove.getLevel () != null)
                {
                    elementToRemove.setLevel (null);
                }
            }
            catch (Exception e)
            {
                throw NestedException.wrap(e);
            }
        }
    }


    public TestAnalysis getTestAnalysisesAt (int index) throws StorageException
    {
        return (TestAnalysis)(_TestAnalysises.getElementAt (index));
    }


    public SortedSet<TestAnalysis> getTestAnalysisesSet () throws StorageException
    {
        return _TestAnalysises.getSet ();
    }

    public FieldWriteability getWriteability_LevelFactorTypes ()
    {
        return getFieldWritabilityUtil (FieldWriteability.TRUE);
    }
    
    
    public int getLevelFactorTypesCount () throws StorageException
    {
        assertValid();
        return _LevelFactorTypes.getReferencedObjectsCount ();
    }


    public void addToLevelFactorTypes (LevelFactorType newElement) throws StorageException
    {
        if (_LevelFactorTypes.wouldAddChange (newElement))
        {
            assertValid();
            Debug.assertion (getWriteability_LevelFactorTypes () != FieldWriteability.FALSE, "MultiAssoc LevelFactorTypes is not writeable (add)");
            _LevelFactorTypes.appendElement (newElement);

            try
            {
                if (newElement.getLevel () != this)
                {
                    newElement.setLevel ((Level)(this));
                }
            }
            catch (Exception e)
            {
                throw NestedException.wrap(e);
            }
        }
    }


    public void removeFromLevelFactorTypes (LevelFactorType elementToRemove) throws StorageException
    {
        if (_LevelFactorTypes.wouldRemoveChange (elementToRemove))
        {
            assertValid();
            Debug.assertion (getWriteability_LevelFactorTypes () != FieldWriteability.FALSE, "MultiAssoc LevelFactorTypes is not writeable (remove)");
            _LevelFactorTypes.removeElement (elementToRemove);
            try
            {
                if (elementToRemove.getLevel () != null)
                {
                    elementToRemove.setLevel (null);
                }
            }
            catch (Exception e)
            {
                throw NestedException.wrap(e);
            }
        }
    }


    public LevelFactorType getLevelFactorTypesAt (int index) throws StorageException
    {
        return (LevelFactorType)(_LevelFactorTypes.getElementAt (index));
    }


    public SortedSet<LevelFactorType> getLevelFactorTypesSet () throws StorageException
    {
        return _LevelFactorTypes.getSet ();
    }

    public FieldWriteability getWriteability_LevelClassCriterias ()
    {
        return getFieldWritabilityUtil (FieldWriteability.TRUE);
    }
    
    
    public int getLevelClassCriteriasCount () throws StorageException
    {
        assertValid();
        return _LevelClassCriterias.getReferencedObjectsCount ();
    }


    public void addToLevelClassCriterias (LevelClassCriteria newElement) throws StorageException
    {
        if (_LevelClassCriterias.wouldAddChange (newElement))
        {
            assertValid();
            Debug.assertion (getWriteability_LevelClassCriterias () != FieldWriteability.FALSE, "MultiAssoc LevelClassCriterias is not writeable (add)");
            _LevelClassCriterias.appendElement (newElement);

            try
            {
                if (newElement.getLevel () != this)
                {
                    newElement.setLevel ((Level)(this));
                }
            }
            catch (Exception e)
            {
                throw NestedException.wrap(e);
            }
        }
    }


    public void removeFromLevelClassCriterias (LevelClassCriteria elementToRemove) throws StorageException
    {
        if (_LevelClassCriterias.wouldRemoveChange (elementToRemove))
        {
            assertValid();
            Debug.assertion (getWriteability_LevelClassCriterias () != FieldWriteability.FALSE, "MultiAssoc LevelClassCriterias is not writeable (remove)");
            _LevelClassCriterias.removeElement (elementToRemove);
            try
            {
                if (elementToRemove.getLevel () != null)
                {
                    elementToRemove.setLevel (null);
                }
            }
            catch (Exception e)
            {
                throw NestedException.wrap(e);
            }
        }
    }


    public LevelClassCriteria getLevelClassCriteriasAt (int index) throws StorageException
    {
        return (LevelClassCriteria)(_LevelClassCriterias.getElementAt (index));
    }


    public SortedSet<LevelClassCriteria> getLevelClassCriteriasSet () throws StorageException
    {
        return _LevelClassCriterias.getSet ();
    }

    public FieldWriteability getWriteability_LevelNormalisations ()
    {
        return getFieldWritabilityUtil (FieldWriteability.TRUE);
    }
    
    
    public int getLevelNormalisationsCount () throws StorageException
    {
        assertValid();
        return _LevelNormalisations.getReferencedObjectsCount ();
    }


    public void addToLevelNormalisations (LevelNormalisation newElement) throws StorageException
    {
        if (_LevelNormalisations.wouldAddChange (newElement))
        {
            assertValid();
            Debug.assertion (getWriteability_LevelNormalisations () != FieldWriteability.FALSE, "MultiAssoc LevelNormalisations is not writeable (add)");
            _LevelNormalisations.appendElement (newElement);

            try
            {
                if (newElement.getLevel () != this)
                {
                    newElement.setLevel ((Level)(this));
                }
            }
            catch (Exception e)
            {
                throw NestedException.wrap(e);
            }
        }
    }


    public void removeFromLevelNormalisations (LevelNormalisation elementToRemove) throws StorageException
    {
        if (_LevelNormalisations.wouldRemoveChange (elementToRemove))
        {
            assertValid();
            Debug.assertion (getWriteability_LevelNormalisations () != FieldWriteability.FALSE, "MultiAssoc LevelNormalisations is not writeable (remove)");
            _LevelNormalisations.removeElement (elementToRemove);
            try
            {
                if (elementToRemove.getLevel () != null)
                {
                    elementToRemove.setLevel (null);
                }
            }
            catch (Exception e)
            {
                throw NestedException.wrap(e);
            }
        }
    }


    public LevelNormalisation getLevelNormalisationsAt (int index) throws StorageException
    {
        return (LevelNormalisation)(_LevelNormalisations.getElementAt (index));
    }


    public SortedSet<LevelNormalisation> getLevelNormalisationsSet () throws StorageException
    {
        return _LevelNormalisations.getSet ();
    }

    public FieldWriteability getWriteability_ClassNormalisations ()
    {
        return getFieldWritabilityUtil (FieldWriteability.TRUE);
    }
    
    
    public int getClassNormalisationsCount () throws StorageException
    {
        assertValid();
        return _ClassNormalisations.getReferencedObjectsCount ();
    }


    public void addToClassNormalisations (ClassNormalisation newElement) throws StorageException
    {
        if (_ClassNormalisations.wouldAddChange (newElement))
        {
            assertValid();
            Debug.assertion (getWriteability_ClassNormalisations () != FieldWriteability.FALSE, "MultiAssoc ClassNormalisations is not writeable (add)");
            _ClassNormalisations.appendElement (newElement);

            try
            {
                if (newElement.getLevel () != this)
                {
                    newElement.setLevel ((Level)(this));
                }
            }
            catch (Exception e)
            {
                throw NestedException.wrap(e);
            }
        }
    }


    public void removeFromClassNormalisations (ClassNormalisation elementToRemove) throws StorageException
    {
        if (_ClassNormalisations.wouldRemoveChange (elementToRemove))
        {
            assertValid();
            Debug.assertion (getWriteability_ClassNormalisations () != FieldWriteability.FALSE, "MultiAssoc ClassNormalisations is not writeable (remove)");
            _ClassNormalisations.removeElement (elementToRemove);
            try
            {
                if (elementToRemove.getLevel () != null)
                {
                    elementToRemove.setLevel (null);
                }
            }
            catch (Exception e)
            {
                throw NestedException.wrap(e);
            }
        }
    }


    public ClassNormalisation getClassNormalisationsAt (int index) throws StorageException
    {
        return (ClassNormalisation)(_ClassNormalisations.getElementAt (index));
    }


    public SortedSet<ClassNormalisation> getClassNormalisationsSet () throws StorageException
    {
        return _ClassNormalisations.getSet ();
    }



    public void onDelete ()
    {
        try 
        {
            for(FactorLevelLink referenced : CollectionUtils.reverse(getFactorsSet()))
            { 
                LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Setting backreference to null Level from ", getObjectID (), " to ", referenced.getObjectID ());
                referenced.setLevel(null);
            }

            for(FactorScoreResult referenced : CollectionUtils.reverse(getResultsSet()))
            { 
                LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Setting backreference to null Level from ", getObjectID (), " to ", referenced.getObjectID ());
                referenced.setLevel(null);
            }

            for(Narrative referenced : CollectionUtils.reverse(getNarrativesSet()))
            { 
                LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Setting backreference to null Level from ", getObjectID (), " to ", referenced.getObjectID ());
                referenced.setLevel(null);
            }

            for(TestAnalysis referenced : CollectionUtils.reverse(getTestAnalysisesSet()))
            { 
                LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Setting backreference to null Level from ", getObjectID (), " to ", referenced.getObjectID ());
                referenced.setLevel(null);
            }

            for(LevelFactorType referenced : CollectionUtils.reverse(getLevelFactorTypesSet()))
            { 
                LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Setting backreference to null Level from ", getObjectID (), " to ", referenced.getObjectID ());
                referenced.setLevel(null);
            }

            for(LevelClassCriteria referenced : CollectionUtils.reverse(getLevelClassCriteriasSet()))
            { 
                LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Setting backreference to null Level from ", getObjectID (), " to ", referenced.getObjectID ());
                referenced.setLevel(null);
            }

            for(LevelNormalisation referenced : CollectionUtils.reverse(getLevelNormalisationsSet()))
            { 
                LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Setting backreference to null Level from ", getObjectID (), " to ", referenced.getObjectID ());
                referenced.setLevel(null);
            }

            for(ClassNormalisation referenced : CollectionUtils.reverse(getClassNormalisationsSet()))
            { 
                LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Setting backreference to null Level from ", getObjectID (), " to ", referenced.getObjectID ());
                referenced.setLevel(null);
            }

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

        super.onDelete ();
    }


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


    public Level referenceInstance ()
    {
        return REFERENCE_Level;
    }


    public Level getInTransaction (ObjectTransaction t) throws StorageException
    {
        return getLevelByID (t, getObjectID());
    }
    
    
    public BaseBusinessClass dummyInstance ()
    {
        return DUMMY_Level;
    }


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





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

        tl_levelPSet.setAttrib (FIELD_ObjectID, myID);
        tl_levelPSet.setAttrib (FIELD_LevelDescription, HELPER_LevelDescription.toObject (_LevelDescription)); //
        tl_levelPSet.setAttrib (FIELD_LevelNotes, HELPER_LevelNotes.toObject (_LevelNotes)); //
        tl_levelPSet.setAttrib (FIELD_ReportHeader, HELPER_ReportHeader.toObject (_ReportHeader)); //
        tl_levelPSet.setAttrib (FIELD_AppliedToExpress, HELPER_AppliedToExpress.toObject (_AppliedToExpress)); //
        tl_levelPSet.setAttrib (FIELD_CSSClass, HELPER_CSSClass.toObject (_CSSClass)); //
        tl_levelPSet.setAttrib (FIELD_Enabled, HELPER_Enabled.toObject (_Enabled)); //
        
    }


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

        
        PersistentSet   tl_levelPSet = allSets.getPersistentSet (objectID, "tl_level");

        _LevelDescription = (String)(HELPER_LevelDescription.fromObject (_LevelDescription, tl_levelPSet.getAttrib (FIELD_LevelDescription))); //
        _LevelNotes = (String)(HELPER_LevelNotes.fromObject (_LevelNotes, tl_levelPSet.getAttrib (FIELD_LevelNotes))); //
        _ReportHeader = (String)(HELPER_ReportHeader.fromObject (_ReportHeader, tl_levelPSet.getAttrib (FIELD_ReportHeader))); //
        _AppliedToExpress = (Boolean)(HELPER_AppliedToExpress.fromObject (_AppliedToExpress, tl_levelPSet.getAttrib (FIELD_AppliedToExpress))); //
        _CSSClass = (String)(HELPER_CSSClass.fromObject (_CSSClass, tl_levelPSet.getAttrib (FIELD_CSSClass))); //
        _Enabled = (Boolean)(HELPER_Enabled.fromObject (_Enabled, tl_levelPSet.getAttrib (FIELD_Enabled))); //
        
    }





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

        if (other instanceof Level)
        {
            Level otherLevel = (Level)other;
            
            try
            {
                setLevelDescription (otherLevel.getLevelDescription ());
            }
            catch (FieldException ex)
            {
                e.addException (ex);
            }
            
            try
            {
                setLevelNotes (otherLevel.getLevelNotes ());
            }
            catch (FieldException ex)
            {
                e.addException (ex);
            }
            
            try
            {
                setReportHeader (otherLevel.getReportHeader ());
            }
            catch (FieldException ex)
            {
                e.addException (ex);
            }
            
            try
            {
                setAppliedToExpress (otherLevel.getAppliedToExpress ());
            }
            catch (FieldException ex)
            {
                e.addException (ex);
            }
            
            try
            {
                setCSSClass (otherLevel.getCSSClass ());
            }
            catch (FieldException ex)
            {
                e.addException (ex);
            }
            
            try
            {
                setEnabled (otherLevel.getEnabled ());
            }
            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 BaseLevel)
        {
            BaseLevel sourceLevel = (BaseLevel)(source);

            _LevelDescription = sourceLevel._LevelDescription;
            _LevelNotes = sourceLevel._LevelNotes;
            _ReportHeader = sourceLevel._ReportHeader;
            _AppliedToExpress = sourceLevel._AppliedToExpress;
            _CSSClass = sourceLevel._CSSClass;
            _Enabled = sourceLevel._Enabled;
            
        }
    }


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

            
        }
    }


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

            _Factors.copyFrom (sourceLevel._Factors, linkToGhosts);
            _Results.copyFrom (sourceLevel._Results, linkToGhosts);
            _Narratives.copyFrom (sourceLevel._Narratives, linkToGhosts);
            _TestAnalysises.copyFrom (sourceLevel._TestAnalysises, linkToGhosts);
            _LevelFactorTypes.copyFrom (sourceLevel._LevelFactorTypes, linkToGhosts);
            _LevelClassCriterias.copyFrom (sourceLevel._LevelClassCriterias, linkToGhosts);
            _LevelNormalisations.copyFrom (sourceLevel._LevelNormalisations, linkToGhosts);
            _ClassNormalisations.copyFrom (sourceLevel._ClassNormalisations, 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);

        _LevelDescription = (String)(HELPER_LevelDescription.readExternal (_LevelDescription, vals.get(FIELD_LevelDescription))); //
        _LevelNotes = (String)(HELPER_LevelNotes.readExternal (_LevelNotes, vals.get(FIELD_LevelNotes))); //
        _ReportHeader = (String)(HELPER_ReportHeader.readExternal (_ReportHeader, vals.get(FIELD_ReportHeader))); //
        _AppliedToExpress = (Boolean)(HELPER_AppliedToExpress.readExternal (_AppliedToExpress, vals.get(FIELD_AppliedToExpress))); //
        _CSSClass = (String)(HELPER_CSSClass.readExternal (_CSSClass, vals.get(FIELD_CSSClass))); //
        _Enabled = (Boolean)(HELPER_Enabled.readExternal (_Enabled, vals.get(FIELD_Enabled))); //
        _Factors.readExternalData(vals.get(MULTIPLEREFERENCE_Factors));
        _Results.readExternalData(vals.get(MULTIPLEREFERENCE_Results));
        _Narratives.readExternalData(vals.get(MULTIPLEREFERENCE_Narratives));
        _TestAnalysises.readExternalData(vals.get(MULTIPLEREFERENCE_TestAnalysises));
        _LevelFactorTypes.readExternalData(vals.get(MULTIPLEREFERENCE_LevelFactorTypes));
        _LevelClassCriterias.readExternalData(vals.get(MULTIPLEREFERENCE_LevelClassCriterias));
        _LevelNormalisations.readExternalData(vals.get(MULTIPLEREFERENCE_LevelNormalisations));
        _ClassNormalisations.readExternalData(vals.get(MULTIPLEREFERENCE_ClassNormalisations));
        
    }


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

        vals.put (FIELD_LevelDescription, HELPER_LevelDescription.writeExternal (_LevelDescription));
        vals.put (FIELD_LevelNotes, HELPER_LevelNotes.writeExternal (_LevelNotes));
        vals.put (FIELD_ReportHeader, HELPER_ReportHeader.writeExternal (_ReportHeader));
        vals.put (FIELD_AppliedToExpress, HELPER_AppliedToExpress.writeExternal (_AppliedToExpress));
        vals.put (FIELD_CSSClass, HELPER_CSSClass.writeExternal (_CSSClass));
        vals.put (FIELD_Enabled, HELPER_Enabled.writeExternal (_Enabled));
        vals.put (MULTIPLEREFERENCE_Factors, _Factors.writeExternalData());
        vals.put (MULTIPLEREFERENCE_Results, _Results.writeExternalData());
        vals.put (MULTIPLEREFERENCE_Narratives, _Narratives.writeExternalData());
        vals.put (MULTIPLEREFERENCE_TestAnalysises, _TestAnalysises.writeExternalData());
        vals.put (MULTIPLEREFERENCE_LevelFactorTypes, _LevelFactorTypes.writeExternalData());
        vals.put (MULTIPLEREFERENCE_LevelClassCriterias, _LevelClassCriterias.writeExternalData());
        vals.put (MULTIPLEREFERENCE_LevelNormalisations, _LevelNormalisations.writeExternalData());
        vals.put (MULTIPLEREFERENCE_ClassNormalisations, _ClassNormalisations.writeExternalData());
        
    }


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

        if (other instanceof BaseLevel)
        {
            BaseLevel otherLevel = (BaseLevel)(other);

            
            if (!HELPER_LevelDescription.compare(this._LevelDescription, otherLevel._LevelDescription))
            {
                listener.notifyFieldChange(this, other, FIELD_LevelDescription, HELPER_LevelDescription.toObject(this._LevelDescription), HELPER_LevelDescription.toObject(otherLevel._LevelDescription));
            }
            if (!HELPER_LevelNotes.compare(this._LevelNotes, otherLevel._LevelNotes))
            {
                listener.notifyFieldChange(this, other, FIELD_LevelNotes, HELPER_LevelNotes.toObject(this._LevelNotes), HELPER_LevelNotes.toObject(otherLevel._LevelNotes));
            }
            if (!HELPER_ReportHeader.compare(this._ReportHeader, otherLevel._ReportHeader))
            {
                listener.notifyFieldChange(this, other, FIELD_ReportHeader, HELPER_ReportHeader.toObject(this._ReportHeader), HELPER_ReportHeader.toObject(otherLevel._ReportHeader));
            }
            if (!HELPER_AppliedToExpress.compare(this._AppliedToExpress, otherLevel._AppliedToExpress))
            {
                listener.notifyFieldChange(this, other, FIELD_AppliedToExpress, HELPER_AppliedToExpress.toObject(this._AppliedToExpress), HELPER_AppliedToExpress.toObject(otherLevel._AppliedToExpress));
            }
            if (!HELPER_CSSClass.compare(this._CSSClass, otherLevel._CSSClass))
            {
                listener.notifyFieldChange(this, other, FIELD_CSSClass, HELPER_CSSClass.toObject(this._CSSClass), HELPER_CSSClass.toObject(otherLevel._CSSClass));
            }
            if (!HELPER_Enabled.compare(this._Enabled, otherLevel._Enabled))
            {
                listener.notifyFieldChange(this, other, FIELD_Enabled, HELPER_Enabled.toObject(this._Enabled), HELPER_Enabled.toObject(otherLevel._Enabled));
            }

            // Compare single assocs
            

            // Compare multiple assocs
            _Factors.compare (otherLevel._Factors, listener);
            _Results.compare (otherLevel._Results, listener);
            _Narratives.compare (otherLevel._Narratives, listener);
            _TestAnalysises.compare (otherLevel._TestAnalysises, listener);
            _LevelFactorTypes.compare (otherLevel._LevelFactorTypes, listener);
            _LevelClassCriterias.compare (otherLevel._LevelClassCriterias, listener);
            _LevelNormalisations.compare (otherLevel._LevelNormalisations, listener);
            _ClassNormalisations.compare (otherLevel._ClassNormalisations, 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_LevelDescription, HELPER_LevelDescription.toObject(getLevelDescription()));
        visitor.visitField(this, FIELD_LevelNotes, HELPER_LevelNotes.toObject(getLevelNotes()));
        visitor.visitField(this, FIELD_ReportHeader, HELPER_ReportHeader.toObject(getReportHeader()));
        visitor.visitField(this, FIELD_AppliedToExpress, HELPER_AppliedToExpress.toObject(getAppliedToExpress()));
        visitor.visitField(this, FIELD_CSSClass, HELPER_CSSClass.toObject(getCSSClass()));
        visitor.visitField(this, FIELD_Enabled, HELPER_Enabled.toObject(getEnabled()));
        visitor.visitAssociation (_Factors);
        visitor.visitAssociation (_Results);
        visitor.visitAssociation (_Narratives);
        visitor.visitAssociation (_TestAnalysises);
        visitor.visitAssociation (_LevelFactorTypes);
        visitor.visitAssociation (_LevelClassCriterias);
        visitor.visitAssociation (_LevelNormalisations);
        visitor.visitAssociation (_ClassNormalisations);
        
    }


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

        if (scope.includes (_Factors))
        {
            visitor.visit (_Factors);
        }
        if (scope.includes (_Results))
        {
            visitor.visit (_Results);
        }
        if (scope.includes (_Narratives))
        {
            visitor.visit (_Narratives);
        }
        if (scope.includes (_TestAnalysises))
        {
            visitor.visit (_TestAnalysises);
        }
        if (scope.includes (_LevelFactorTypes))
        {
            visitor.visit (_LevelFactorTypes);
        }
        if (scope.includes (_LevelClassCriterias))
        {
            visitor.visit (_LevelClassCriterias);
        }
        if (scope.includes (_LevelNormalisations))
        {
            visitor.visit (_LevelNormalisations);
        }
        if (scope.includes (_ClassNormalisations))
        {
            visitor.visit (_ClassNormalisations);
        }
        
    }


    public static Level createLevel (ObjectTransaction transaction) throws StorageException
    {
        Level     result = new Level ();

        result.initialiseNewObject (transaction);

        return result;
    }


    public static Level getLevelByID (ObjectTransaction transaction, Long objectID) throws StorageException
    {
        return (Level)(transaction.getObjectByID (REFERENCE_Level, objectID));
    }

    public boolean testFilter (String attribName, QueryFilter filter) throws StorageException
    {
        if (false)
        {
            throw new RuntimeException ("Game over man!!");
        }
        else if (attribName.equals (FIELD_LevelDescription))
        {
            return filter.matches (getLevelDescription ());
        }
        else if (attribName.equals (FIELD_LevelNotes))
        {
            return filter.matches (getLevelNotes ());
        }
        else if (attribName.equals (FIELD_ReportHeader))
        {
            return filter.matches (getReportHeader ());
        }
        else if (attribName.equals (FIELD_AppliedToExpress))
        {
            return filter.matches (getAppliedToExpress ());
        }
        else if (attribName.equals (FIELD_CSSClass))
        {
            return filter.matches (getCSSClass ());
        }
        else if (attribName.equals (FIELD_Enabled))
        {
            return filter.matches (getEnabled ());
        }
        else
        {
            return super.testFilter (attribName, filter);
        }
    }


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

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

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

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

            
            public SearchAll andLevelDescription (QueryFilter<String> filter)
            {
                filter.addFilter (context, "tl_level.level_desc", "LevelDescription");
                return this;
            }
            
            public SearchAll andLevelNotes (QueryFilter<String> filter)
            {
                filter.addFilter (context, "tl_level.level_notes", "LevelNotes");
                return this;
            }
            
            public SearchAll andReportHeader (QueryFilter<String> filter)
            {
                filter.addFilter (context, "tl_level.rpt_hdr", "ReportHeader");
                return this;
            }
            
            public SearchAll andAppliedToExpress (QueryFilter<Boolean> filter)
            {
                filter.addFilter (context, "tl_level.applied_to_express", "AppliedToExpress");
                return this;
            }
            
            public SearchAll andCSSClass (QueryFilter<String> filter)
            {
                filter.addFilter (context, "tl_level.css_class", "CSSClass");
                return this;
            }
            
            public SearchAll andEnabled (QueryFilter<Boolean> filter)
            {
                filter.addFilter (context, "tl_level.enabled", "Enabled");
                return this;
            }
            
                public Level[]
             search (ObjectTransaction transaction) throws StorageException
        {
            
            
            BaseBusinessClass[]     results = super.search (transaction, REFERENCE_Level, SEARCH_All, criteria);
            Set<Level>   typedResults = new LinkedHashSet <Level> ();
            for (BaseBusinessClass bbcResult : results)
            {
                Level aResult = (Level)bbcResult;
                
                typedResults.add (aResult);
            }
            
                    return ObjstoreUtils.removeDeleted(transaction, typedResults).toArray (new Level[0]);
                            
        }
    }

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

    public static SearchName SearchByName () { return new SearchName (); }

    public static class SearchName extends SearchObject<Level>
    {
        
        public SearchName byName (String Name)
        {
            by ("Name", Name);
            return this;
        }
        
            public SearchName andObjectID (QueryFilter<Long> filter)
            {
                filter.addFilter (context, "tl_level.object_id", FIELD_ObjectID);
                return this;
            }

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

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

            
            public SearchName andLevelDescription (QueryFilter<String> filter)
            {
                filter.addFilter (context, "tl_level.level_desc", "LevelDescription");
                return this;
            }
            
            public SearchName andLevelNotes (QueryFilter<String> filter)
            {
                filter.addFilter (context, "tl_level.level_notes", "LevelNotes");
                return this;
            }
            
            public SearchName andReportHeader (QueryFilter<String> filter)
            {
                filter.addFilter (context, "tl_level.rpt_hdr", "ReportHeader");
                return this;
            }
            
            public SearchName andAppliedToExpress (QueryFilter<Boolean> filter)
            {
                filter.addFilter (context, "tl_level.applied_to_express", "AppliedToExpress");
                return this;
            }
            
            public SearchName andCSSClass (QueryFilter<String> filter)
            {
                filter.addFilter (context, "tl_level.css_class", "CSSClass");
                return this;
            }
            
            public SearchName andEnabled (QueryFilter<Boolean> filter)
            {
                filter.addFilter (context, "tl_level.enabled", "Enabled");
                return this;
            }
            
                public Level search (ObjectTransaction transaction) throws StorageException
        {
            
            
            BaseBusinessClass[]     results = super.search (transaction, REFERENCE_Level, SEARCH_Name, criteria);
            Set<Level>   typedResults = new LinkedHashSet <Level> ();
            for (BaseBusinessClass bbcResult : results)
            {
                Level aResult = (Level)bbcResult;
                
                typedResults.add (aResult);
            }
            
                    return (Level)singletonResult(ObjstoreUtils.removeDeleted(transaction, typedResults).toArray(new BaseBusinessClass[0]), "Level", "");
                            
        }
    }

        
                public static Level searchName (ObjectTransaction transaction, String Name) throws StorageException
        {
            return SearchByName ()
            .byName  (Name)
            .search (transaction);
        }



    public Object getAttribute (String attribName)
    {
        if (false)
        {
            throw new RuntimeException ("Game over man!!");
        }
        else if (attribName.equals (FIELD_LevelDescription))
        {
            return HELPER_LevelDescription.toObject (getLevelDescription ());
        }
        else if (attribName.equals (FIELD_LevelNotes))
        {
            return HELPER_LevelNotes.toObject (getLevelNotes ());
        }
        else if (attribName.equals (FIELD_ReportHeader))
        {
            return HELPER_ReportHeader.toObject (getReportHeader ());
        }
        else if (attribName.equals (FIELD_AppliedToExpress))
        {
            return HELPER_AppliedToExpress.toObject (getAppliedToExpress ());
        }
        else if (attribName.equals (FIELD_CSSClass))
        {
            return HELPER_CSSClass.toObject (getCSSClass ());
        }
        else if (attribName.equals (FIELD_Enabled))
        {
            return HELPER_Enabled.toObject (getEnabled ());
        }
        else
        {
            return super.getAttribute (attribName);
        }
    }


    public AttributeHelper getAttributeHelper (String attribName)
    {
        if (false)
        {
            throw new RuntimeException ("Game over man!!");
        }
        else if (attribName.equals (FIELD_LevelDescription))
        {
            return HELPER_LevelDescription;
        }
        else if (attribName.equals (FIELD_LevelNotes))
        {
            return HELPER_LevelNotes;
        }
        else if (attribName.equals (FIELD_ReportHeader))
        {
            return HELPER_ReportHeader;
        }
        else if (attribName.equals (FIELD_AppliedToExpress))
        {
            return HELPER_AppliedToExpress;
        }
        else if (attribName.equals (FIELD_CSSClass))
        {
            return HELPER_CSSClass;
        }
        else if (attribName.equals (FIELD_Enabled))
        {
            return HELPER_Enabled;
        }
        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_LevelDescription))
        {
            setLevelDescription ((String)(HELPER_LevelDescription.fromObject (_LevelDescription, attribValue)));            
        }
        else if (attribName.equals (FIELD_LevelNotes))
        {
            setLevelNotes ((String)(HELPER_LevelNotes.fromObject (_LevelNotes, attribValue)));            
        }
        else if (attribName.equals (FIELD_ReportHeader))
        {
            setReportHeader ((String)(HELPER_ReportHeader.fromObject (_ReportHeader, attribValue)));            
        }
        else if (attribName.equals (FIELD_AppliedToExpress))
        {
            setAppliedToExpress ((Boolean)(HELPER_AppliedToExpress.fromObject (_AppliedToExpress, attribValue)));            
        }
        else if (attribName.equals (FIELD_CSSClass))
        {
            setCSSClass ((String)(HELPER_CSSClass.fromObject (_CSSClass, attribValue)));            
        }
        else if (attribName.equals (FIELD_Enabled))
        {
            setEnabled ((Boolean)(HELPER_Enabled.fromObject (_Enabled, 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_LevelDescription))
        {
            return getWriteability_LevelDescription ();
        }
        else if (fieldName.equals (FIELD_LevelNotes))
        {
            return getWriteability_LevelNotes ();
        }
        else if (fieldName.equals (FIELD_ReportHeader))
        {
            return getWriteability_ReportHeader ();
        }
        else if (fieldName.equals (FIELD_AppliedToExpress))
        {
            return getWriteability_AppliedToExpress ();
        }
        else if (fieldName.equals (FIELD_CSSClass))
        {
            return getWriteability_CSSClass ();
        }
        else if (fieldName.equals (FIELD_Enabled))
        {
            return getWriteability_Enabled ();
        }
        else if (fieldName.equals (MULTIPLEREFERENCE_Factors))
        {
            return getWriteability_Factors ();
        }
        else if (fieldName.equals (MULTIPLEREFERENCE_Results))
        {
            return getWriteability_Results ();
        }
        else if (fieldName.equals (MULTIPLEREFERENCE_Narratives))
        {
            return getWriteability_Narratives ();
        }
        else if (fieldName.equals (MULTIPLEREFERENCE_TestAnalysises))
        {
            return getWriteability_TestAnalysises ();
        }
        else if (fieldName.equals (MULTIPLEREFERENCE_LevelFactorTypes))
        {
            return getWriteability_LevelFactorTypes ();
        }
        else if (fieldName.equals (MULTIPLEREFERENCE_LevelClassCriterias))
        {
            return getWriteability_LevelClassCriterias ();
        }
        else if (fieldName.equals (MULTIPLEREFERENCE_LevelNormalisations))
        {
            return getWriteability_LevelNormalisations ();
        }
        else if (fieldName.equals (MULTIPLEREFERENCE_ClassNormalisations))
        {
            return getWriteability_ClassNormalisations ();
        }
        else
        {
            return super.getWriteable (fieldName);
        }
    }


    public void putUnwriteable (Set<String> fields)
    {
        
            if (getWriteability_LevelDescription () != FieldWriteability.TRUE)
            {
                fields.add (FIELD_LevelDescription);
            }
        
            if (getWriteability_LevelNotes () != FieldWriteability.TRUE)
            {
                fields.add (FIELD_LevelNotes);
            }
        
            if (getWriteability_ReportHeader () != FieldWriteability.TRUE)
            {
                fields.add (FIELD_ReportHeader);
            }
        
            if (getWriteability_AppliedToExpress () != FieldWriteability.TRUE)
            {
                fields.add (FIELD_AppliedToExpress);
            }
        
            if (getWriteability_CSSClass () != FieldWriteability.TRUE)
            {
                fields.add (FIELD_CSSClass);
            }
        
            if (getWriteability_Enabled () != FieldWriteability.TRUE)
            {
                fields.add (FIELD_Enabled);
            }
        

        super.putUnwriteable (fields);
    }

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

        
        result.add(HELPER_LevelDescription.getAttribObject (getClass (), _LevelDescription, false, FIELD_LevelDescription));
        result.add(HELPER_LevelNotes.getAttribObject (getClass (), _LevelNotes, false, FIELD_LevelNotes));
        result.add(HELPER_ReportHeader.getAttribObject (getClass (), _ReportHeader, false, FIELD_ReportHeader));
        result.add(HELPER_AppliedToExpress.getAttribObject (getClass (), _AppliedToExpress, false, FIELD_AppliedToExpress));
        result.add(HELPER_CSSClass.getAttribObject (getClass (), _CSSClass, false, FIELD_CSSClass));
        result.add(HELPER_Enabled.getAttribObject (getClass (), _Enabled, false, FIELD_Enabled));

        return result;
    }


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


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

    /**
     * Get the attribute LevelDescription
     */
    public String getLevelDescription (Level obj, String original)
    {
        return original;
    }

    /**
     * Change the value set for attribute LevelDescription.
     * May modify the field beforehand
     * Occurs before validation.
     */
    public String setLevelDescription (Level obj, String newLevelDescription) throws FieldException
    {
        return newLevelDescription;
    }

    /**
     * Get the attribute LevelNotes
     */
    public String getLevelNotes (Level obj, String original)
    {
        return original;
    }

    /**
     * Change the value set for attribute LevelNotes.
     * May modify the field beforehand
     * Occurs before validation.
     */
    public String setLevelNotes (Level obj, String newLevelNotes) throws FieldException
    {
        return newLevelNotes;
    }

    /**
     * Get the attribute ReportHeader
     */
    public String getReportHeader (Level obj, String original)
    {
        return original;
    }

    /**
     * Change the value set for attribute ReportHeader.
     * May modify the field beforehand
     * Occurs before validation.
     */
    public String setReportHeader (Level obj, String newReportHeader) throws FieldException
    {
        return newReportHeader;
    }

    /**
     * Get the attribute AppliedToExpress
     */
    public Boolean getAppliedToExpress (Level obj, Boolean original)
    {
        return original;
    }

    /**
     * Change the value set for attribute AppliedToExpress.
     * May modify the field beforehand
     * Occurs before validation.
     */
    public Boolean setAppliedToExpress (Level obj, Boolean newAppliedToExpress) throws FieldException
    {
        return newAppliedToExpress;
    }

    /**
     * Get the attribute CSSClass
     */
    public String getCSSClass (Level obj, String original)
    {
        return original;
    }

    /**
     * Change the value set for attribute CSSClass.
     * May modify the field beforehand
     * Occurs before validation.
     */
    public String setCSSClass (Level obj, String newCSSClass) throws FieldException
    {
        return newCSSClass;
    }

    /**
     * Get the attribute Enabled
     */
    public Boolean getEnabled (Level obj, Boolean original)
    {
        return original;
    }

    /**
     * Change the value set for attribute Enabled.
     * May modify the field beforehand
     * Occurs before validation.
     */
    public Boolean setEnabled (Level obj, Boolean newEnabled) throws FieldException
    {
        return newEnabled;
    }

    }

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

        public LevelPipeLineFactory (Collection<From> seed)
        {
            super(seed);
        }
        
        
        public PipeLine<From, ? extends Object> to(String name)
        {
            if (name.equals ("Factors"))
            {
                return toFactors ();
            }                
            if (name.equals ("Results"))
            {
                return toResults ();
            }                
            if (name.equals ("Narratives"))
            {
                return toNarratives ();
            }                
            if (name.equals ("TestAnalysises"))
            {
                return toTestAnalysises ();
            }                
            if (name.equals ("LevelFactorTypes"))
            {
                return toLevelFactorTypes ();
            }                
            if (name.equals ("LevelClassCriterias"))
            {
                return toLevelClassCriterias ();
            }                
            if (name.equals ("LevelNormalisations"))
            {
                return toLevelNormalisations ();
            }                
            if (name.equals ("ClassNormalisations"))
            {
                return toClassNormalisations ();
            }                
            if (name.equals ("LevelDescription"))
            {
                return toLevelDescription ();
            }                
            if (name.equals ("LevelNotes"))
            {
                return toLevelNotes ();
            }                
            if (name.equals ("ReportHeader"))
            {
                return toReportHeader ();
            }                
            if (name.equals ("AppliedToExpress"))
            {
                return toAppliedToExpress ();
            }                
            if (name.equals ("CSSClass"))
            {
                return toCSSClass ();
            }                
            if (name.equals ("Enabled"))
            {
                return toEnabled ();
            }                
            
            
            return super.to(name);
        }
        
        
        public PipeLine<From, String> toLevelDescription () { return pipe(new ORMAttributePipe<Me, String>(FIELD_LevelDescription));  }
        
        public PipeLine<From, String> toLevelNotes () { return pipe(new ORMAttributePipe<Me, String>(FIELD_LevelNotes));  }
        
        public PipeLine<From, String> toReportHeader () { return pipe(new ORMAttributePipe<Me, String>(FIELD_ReportHeader));  }
        
        public PipeLine<From, Boolean> toAppliedToExpress () { return pipe(new ORMAttributePipe<Me, Boolean>(FIELD_AppliedToExpress));  }
        
        public PipeLine<From, String> toCSSClass () { return pipe(new ORMAttributePipe<Me, String>(FIELD_CSSClass));  }
        
        public PipeLine<From, Boolean> toEnabled () { return pipe(new ORMAttributePipe<Me, Boolean>(FIELD_Enabled));  }
        public FactorLevelLink.FactorLevelLinkPipeLineFactory<From, FactorLevelLink> toFactors () { return toFactors(Filter.ALL); }        

        public FactorLevelLink.FactorLevelLinkPipeLineFactory<From, FactorLevelLink> toFactors (Filter<FactorLevelLink> filter)
        {
            return FactorLevelLink.REFERENCE_FactorLevelLink.new FactorLevelLinkPipeLineFactory<From, FactorLevelLink> (this, new ORMMultiAssocPipe<Me, FactorLevelLink>(MULTIPLEREFERENCE_Factors, filter)); 
        }
        public FactorScoreResult.FactorScoreResultPipeLineFactory<From, FactorScoreResult> toResults () { return toResults(Filter.ALL); }        

        public FactorScoreResult.FactorScoreResultPipeLineFactory<From, FactorScoreResult> toResults (Filter<FactorScoreResult> filter)
        {
            return FactorScoreResult.REFERENCE_FactorScoreResult.new FactorScoreResultPipeLineFactory<From, FactorScoreResult> (this, new ORMMultiAssocPipe<Me, FactorScoreResult>(MULTIPLEREFERENCE_Results, filter)); 
        }
        public Narrative.NarrativePipeLineFactory<From, Narrative> toNarratives () { return toNarratives(Filter.ALL); }        

        public Narrative.NarrativePipeLineFactory<From, Narrative> toNarratives (Filter<Narrative> filter)
        {
            return Narrative.REFERENCE_Narrative.new NarrativePipeLineFactory<From, Narrative> (this, new ORMMultiAssocPipe<Me, Narrative>(MULTIPLEREFERENCE_Narratives, filter)); 
        }
        public TestAnalysis.TestAnalysisPipeLineFactory<From, TestAnalysis> toTestAnalysises () { return toTestAnalysises(Filter.ALL); }        

        public TestAnalysis.TestAnalysisPipeLineFactory<From, TestAnalysis> toTestAnalysises (Filter<TestAnalysis> filter)
        {
            return TestAnalysis.REFERENCE_TestAnalysis.new TestAnalysisPipeLineFactory<From, TestAnalysis> (this, new ORMMultiAssocPipe<Me, TestAnalysis>(MULTIPLEREFERENCE_TestAnalysises, filter)); 
        }
        public LevelFactorType.LevelFactorTypePipeLineFactory<From, LevelFactorType> toLevelFactorTypes () { return toLevelFactorTypes(Filter.ALL); }        

        public LevelFactorType.LevelFactorTypePipeLineFactory<From, LevelFactorType> toLevelFactorTypes (Filter<LevelFactorType> filter)
        {
            return LevelFactorType.REFERENCE_LevelFactorType.new LevelFactorTypePipeLineFactory<From, LevelFactorType> (this, new ORMMultiAssocPipe<Me, LevelFactorType>(MULTIPLEREFERENCE_LevelFactorTypes, filter)); 
        }
        public LevelClassCriteria.LevelClassCriteriaPipeLineFactory<From, LevelClassCriteria> toLevelClassCriterias () { return toLevelClassCriterias(Filter.ALL); }        

        public LevelClassCriteria.LevelClassCriteriaPipeLineFactory<From, LevelClassCriteria> toLevelClassCriterias (Filter<LevelClassCriteria> filter)
        {
            return LevelClassCriteria.REFERENCE_LevelClassCriteria.new LevelClassCriteriaPipeLineFactory<From, LevelClassCriteria> (this, new ORMMultiAssocPipe<Me, LevelClassCriteria>(MULTIPLEREFERENCE_LevelClassCriterias, filter)); 
        }
        public LevelNormalisation.LevelNormalisationPipeLineFactory<From, LevelNormalisation> toLevelNormalisations () { return toLevelNormalisations(Filter.ALL); }        

        public LevelNormalisation.LevelNormalisationPipeLineFactory<From, LevelNormalisation> toLevelNormalisations (Filter<LevelNormalisation> filter)
        {
            return LevelNormalisation.REFERENCE_LevelNormalisation.new LevelNormalisationPipeLineFactory<From, LevelNormalisation> (this, new ORMMultiAssocPipe<Me, LevelNormalisation>(MULTIPLEREFERENCE_LevelNormalisations, filter)); 
        }
        public ClassNormalisation.ClassNormalisationPipeLineFactory<From, ClassNormalisation> toClassNormalisations () { return toClassNormalisations(Filter.ALL); }        

        public ClassNormalisation.ClassNormalisationPipeLineFactory<From, ClassNormalisation> toClassNormalisations (Filter<ClassNormalisation> filter)
        {
            return ClassNormalisation.REFERENCE_ClassNormalisation.new ClassNormalisationPipeLineFactory<From, ClassNormalisation> (this, new ORMMultiAssocPipe<Me, ClassNormalisation>(MULTIPLEREFERENCE_ClassNormalisations, filter)); 
        }
        
    }
    
    public boolean isTransientAttrib(String attribName)
    {
        

        return super.isTransientAttrib(attribName);
    }

    public boolean isTransientSingleReference(String assocName)
    {
        

        return super.isTransientSingleReference(assocName);
    }
}

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

    public void assertValid ()
    {
    }


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


    public FactorLevelLink getFactorsAt (int index) throws StorageException
    {
        throw new RuntimeException ("No elements in a dummy object in association Factors");
    }


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

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


    public FactorScoreResult getResultsAt (int index) throws StorageException
    {
        throw new RuntimeException ("No elements in a dummy object in association Results");
    }


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

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


    public Narrative getNarrativesAt (int index) throws StorageException
    {
        throw new RuntimeException ("No elements in a dummy object in association Narratives");
    }


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

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


    public TestAnalysis getTestAnalysisesAt (int index) throws StorageException
    {
        throw new RuntimeException ("No elements in a dummy object in association TestAnalysises");
    }


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

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


    public LevelFactorType getLevelFactorTypesAt (int index) throws StorageException
    {
        throw new RuntimeException ("No elements in a dummy object in association LevelFactorTypes");
    }


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

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


    public LevelClassCriteria getLevelClassCriteriasAt (int index) throws StorageException
    {
        throw new RuntimeException ("No elements in a dummy object in association LevelClassCriterias");
    }


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

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


    public LevelNormalisation getLevelNormalisationsAt (int index) throws StorageException
    {
        throw new RuntimeException ("No elements in a dummy object in association LevelNormalisations");
    }


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

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


    public ClassNormalisation getClassNormalisationsAt (int index) throws StorageException
    {
        throw new RuntimeException ("No elements in a dummy object in association ClassNormalisations");
    }


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

}

    
