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


    package performa.orm;

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

import performa.orm.types.*;



public abstract class BaseFactorScoreResult extends BaseBusinessClass
{
    // Reference instance for the object
    public static final FactorScoreResult REFERENCE_FactorScoreResult = new FactorScoreResult ();

    // Reference instance for the object
    public static final FactorScoreResult DUMMY_FactorScoreResult = new DummyFactorScoreResult ();

    // Static constants corresponding to field names
    
    public static final String FIELD_FromScore = "FromScore";
    public static final String FIELD_ToScore = "ToScore";
    public static final String FIELD_NarrativeCode = "NarrativeCode";
    public static final String FIELD_ColorCode = "ColorCode";
    public static final String SINGLEREFERENCE_Factor = "Factor";
    public static final String SINGLEREFERENCE_Level = "Level";

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

    // Static constants corresponding to attribute helpers
    private static final DefaultAttributeHelper<FactorScoreResult> HELPER_FromScore = DefaultAttributeHelper.INSTANCE;
    private static final DefaultAttributeHelper<FactorScoreResult> HELPER_ToScore = DefaultAttributeHelper.INSTANCE;
    private static final DefaultAttributeHelper<FactorScoreResult> HELPER_NarrativeCode = DefaultAttributeHelper.INSTANCE;
    private static final EnumeratedAttributeHelper<FactorScoreResult, ColorCode> HELPER_ColorCode =  new EnumeratedAttributeHelper<FactorScoreResult, ColorCode> (ColorCode.FACTORY_ColorCode);
    

    // Private attributes corresponding to business object data
    private Integer _FromScore;
    private Integer _ToScore;
    private String _NarrativeCode;
    private ColorCode _ColorCode;
    

    // Private attributes corresponding to single references
    private SingleAssociation<FactorScoreResult, Factor> _Factor;
    private SingleAssociation<FactorScoreResult, Level> _Level;
    

    // Private attributes corresponding to multiple references
    

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

    // Arrays of validators for each attribute
    private static final AttributeValidator[] FIELD_FromScore_Validators;
    private static final AttributeValidator[] FIELD_ToScore_Validators;
    private static final AttributeValidator[] FIELD_NarrativeCode_Validators;
    private static final AttributeValidator[] FIELD_ColorCode_Validators;
    

    // Arrays of behaviour decorators
    private static final FactorScoreResultBehaviourDecorator[] FactorScoreResult_BehaviourDecorators;
    
    static
    {
        try
        {
            
            
            Map  validatorMapping = ((Map)ConfigMgr.getConfigObject ("CONFIG.ORMVALIDATOR", "ValidatorMapping"));

            setupAssocMetaData_Factor();
            setupAssocMetaData_Level();
            FIELD_FromScore_Validators = (AttributeValidator[])setupAttribMetaData_FromScore(validatorMapping).toArray (new AttributeValidator[0]);
            FIELD_ToScore_Validators = (AttributeValidator[])setupAttribMetaData_ToScore(validatorMapping).toArray (new AttributeValidator[0]);
            FIELD_NarrativeCode_Validators = (AttributeValidator[])setupAttribMetaData_NarrativeCode(validatorMapping).toArray (new AttributeValidator[0]);
            FIELD_ColorCode_Validators = (AttributeValidator[])setupAttribMetaData_ColorCode(validatorMapping).toArray (new AttributeValidator[0]);
            

            REFERENCE_FactorScoreResult.initialiseReference ();
            DUMMY_FactorScoreResult.initialiseReference ();
            FactorScoreResult_BehaviourDecorators = BaseBusinessClass.getBBCBehaviours(FactorScoreResult.class).toArray(new FactorScoreResultBehaviourDecorator[0]);
        }
        catch (RuntimeException e)
        {
            LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR1, e, "Error initialising");
            throw e;
        }
    }

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

        metaInfo.put ("dbcol", "factor_number");
        metaInfo.put ("name", "Factor");
        metaInfo.put ("type", "Factor");
        
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for FactorScoreResult.Factor:", metaInfo);
        ATTRIBUTES_METADATA_FactorScoreResult.put (SINGLEREFERENCE_Factor, Collections.unmodifiableMap (metaInfo));
    }
    
    
    // Meta Info setup
    private static void setupAssocMetaData_Level()
    {
        Map metaInfo = new HashMap ();

        metaInfo.put ("dbcol", "level_number");
        metaInfo.put ("name", "Level");
        metaInfo.put ("type", "Level");
        
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for FactorScoreResult.Level:", metaInfo);
        ATTRIBUTES_METADATA_FactorScoreResult.put (SINGLEREFERENCE_Level, Collections.unmodifiableMap (metaInfo));
    }
    
    
    // Meta Info setup
    private static List setupAttribMetaData_FromScore(Map validatorMapping)
    {
        Map  metaInfo   = new HashMap ();

        metaInfo.put ("dbcol", "from_score");
        metaInfo.put ("name", "FromScore");
        metaInfo.put ("type", "Integer");
        
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for FactorScoreResult.FromScore:", metaInfo);
        ATTRIBUTES_METADATA_FactorScoreResult.put (FIELD_FromScore, Collections.unmodifiableMap (metaInfo));

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

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

        metaInfo.put ("dbcol", "to_score");
        metaInfo.put ("name", "ToScore");
        metaInfo.put ("type", "Integer");
        
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for FactorScoreResult.ToScore:", metaInfo);
        ATTRIBUTES_METADATA_FactorScoreResult.put (FIELD_ToScore, Collections.unmodifiableMap (metaInfo));

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

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

        metaInfo.put ("dbcol", "narrative_code");
        metaInfo.put ("length", "15");
        metaInfo.put ("name", "NarrativeCode");
        metaInfo.put ("type", "String");
        
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for FactorScoreResult.NarrativeCode:", metaInfo);
        ATTRIBUTES_METADATA_FactorScoreResult.put (FIELD_NarrativeCode, Collections.unmodifiableMap (metaInfo));

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

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

        metaInfo.put ("attribHelper", "EnumeratedAttributeHelper");
        metaInfo.put ("dbcol", "color_code");
        metaInfo.put ("name", "ColorCode");
        metaInfo.put ("type", "ColorCode");
        
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for FactorScoreResult.ColorCode:", metaInfo);
        ATTRIBUTES_METADATA_FactorScoreResult.put (FIELD_ColorCode, Collections.unmodifiableMap (metaInfo));

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

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


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


    


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

        
        _FromScore = (Integer)(HELPER_FromScore.initialise (_FromScore));
        _ToScore = (Integer)(HELPER_ToScore.initialise (_ToScore));
        _NarrativeCode = (String)(HELPER_NarrativeCode.initialise (_NarrativeCode));
        _ColorCode = (ColorCode)(HELPER_ColorCode.initialise (_ColorCode));
    }


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

        _Factor = new SingleAssociation<FactorScoreResult, Factor> (this, SINGLEREFERENCE_Factor, null, Factor.REFERENCE_Factor, "level_factor");
        _Level = new SingleAssociation<FactorScoreResult, Level> (this, SINGLEREFERENCE_Level, null, Level.REFERENCE_Level, "level_factor");
        
    }


    // Initialise the associations
    protected BaseBusinessClass initialiseReference ()
    {
        super.initialiseReference ();
        
        _Factor = new SingleAssociation<FactorScoreResult, Factor> (this, SINGLEREFERENCE_Factor, null, Factor.REFERENCE_Factor, "level_factor");
        _Level = new SingleAssociation<FactorScoreResult, Level> (this, SINGLEREFERENCE_Level, null, Level.REFERENCE_Level, "level_factor");
        
        
        return this;
    }

    

    /**
     * Get the attribute FromScore
     */
    public Integer getFromScore ()
    {
        assertValid();
        Integer valToReturn = _FromScore;

            for (FactorScoreResultBehaviourDecorator bhd : FactorScoreResult_BehaviourDecorators)
            {
                valToReturn = bhd.getFromScore ((FactorScoreResult)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 preFromScoreChange (Integer newFromScore) 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 postFromScoreChange () throws FieldException
    {
    }

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

    /**
     * Set the attribute FromScore.  Checks to ensure a new value
     * has been supplied.  If so, marks the field as altered and sets the attribute.
     */
    public void setFromScore (Integer newFromScore) throws FieldException
    {
        boolean oldAndNewIdentical = HELPER_FromScore.compare (_FromScore, newFromScore);
        
        try
        {
            for (FactorScoreResultBehaviourDecorator bhd : FactorScoreResult_BehaviourDecorators)
            {
                newFromScore = bhd.setFromScore ((FactorScoreResult)this, newFromScore);
                oldAndNewIdentical = HELPER_FromScore.compare (_FromScore, newFromScore);
            }

            

            if (FIELD_FromScore_Validators.length > 0)
            {
                Object newFromScoreObj = HELPER_FromScore.toObject (newFromScore);

                if (newFromScoreObj != null)
                {
                    int     loopMax = FIELD_FromScore_Validators.length;
                    Map     metadata = (Map)ATTRIBUTES_METADATA_FactorScoreResult.get (FIELD_FromScore);

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

        if (!oldAndNewIdentical)
        {
            assertValid();
            Debug.assertion (getWriteability_FromScore () != FieldWriteability.FALSE, "Field  FromScore is not writeable");
            preFromScoreChange (newFromScore);
            markFieldChange (FIELD_FromScore);
            _FromScore = newFromScore;            
            postFieldChange (FIELD_FromScore);
            postFromScoreChange ();
        }
    }

    /**
     * Get the attribute ToScore
     */
    public Integer getToScore ()
    {
        assertValid();
        Integer valToReturn = _ToScore;

            for (FactorScoreResultBehaviourDecorator bhd : FactorScoreResult_BehaviourDecorators)
            {
                valToReturn = bhd.getToScore ((FactorScoreResult)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 preToScoreChange (Integer newToScore) 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 postToScoreChange () throws FieldException
    {
    }

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

    /**
     * Set the attribute ToScore.  Checks to ensure a new value
     * has been supplied.  If so, marks the field as altered and sets the attribute.
     */
    public void setToScore (Integer newToScore) throws FieldException
    {
        boolean oldAndNewIdentical = HELPER_ToScore.compare (_ToScore, newToScore);
        
        try
        {
            for (FactorScoreResultBehaviourDecorator bhd : FactorScoreResult_BehaviourDecorators)
            {
                newToScore = bhd.setToScore ((FactorScoreResult)this, newToScore);
                oldAndNewIdentical = HELPER_ToScore.compare (_ToScore, newToScore);
            }

            

            if (FIELD_ToScore_Validators.length > 0)
            {
                Object newToScoreObj = HELPER_ToScore.toObject (newToScore);

                if (newToScoreObj != null)
                {
                    int     loopMax = FIELD_ToScore_Validators.length;
                    Map     metadata = (Map)ATTRIBUTES_METADATA_FactorScoreResult.get (FIELD_ToScore);

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

        if (!oldAndNewIdentical)
        {
            assertValid();
            Debug.assertion (getWriteability_ToScore () != FieldWriteability.FALSE, "Field  ToScore is not writeable");
            preToScoreChange (newToScore);
            markFieldChange (FIELD_ToScore);
            _ToScore = newToScore;            
            postFieldChange (FIELD_ToScore);
            postToScoreChange ();
        }
    }

    /**
     * Get the attribute NarrativeCode
     */
    public String getNarrativeCode ()
    {
        assertValid();
        String valToReturn = _NarrativeCode;

            for (FactorScoreResultBehaviourDecorator bhd : FactorScoreResult_BehaviourDecorators)
            {
                valToReturn = bhd.getNarrativeCode ((FactorScoreResult)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 preNarrativeCodeChange (String newNarrativeCode) 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 postNarrativeCodeChange () throws FieldException
    {
    }

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

    /**
     * Set the attribute NarrativeCode.  Checks to ensure a new value
     * has been supplied.  If so, marks the field as altered and sets the attribute.
     */
    public void setNarrativeCode (String newNarrativeCode) throws FieldException
    {
        boolean oldAndNewIdentical = HELPER_NarrativeCode.compare (_NarrativeCode, newNarrativeCode);
        
        try
        {
            for (FactorScoreResultBehaviourDecorator bhd : FactorScoreResult_BehaviourDecorators)
            {
                newNarrativeCode = bhd.setNarrativeCode ((FactorScoreResult)this, newNarrativeCode);
                oldAndNewIdentical = HELPER_NarrativeCode.compare (_NarrativeCode, newNarrativeCode);
            }

            

            if (FIELD_NarrativeCode_Validators.length > 0)
            {
                Object newNarrativeCodeObj = HELPER_NarrativeCode.toObject (newNarrativeCode);

                if (newNarrativeCodeObj != null)
                {
                    int     loopMax = FIELD_NarrativeCode_Validators.length;
                    Map     metadata = (Map)ATTRIBUTES_METADATA_FactorScoreResult.get (FIELD_NarrativeCode);

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

        if (!oldAndNewIdentical)
        {
            assertValid();
            Debug.assertion (getWriteability_NarrativeCode () != FieldWriteability.FALSE, "Field  NarrativeCode is not writeable");
            preNarrativeCodeChange (newNarrativeCode);
            markFieldChange (FIELD_NarrativeCode);
            _NarrativeCode = newNarrativeCode;            
            postFieldChange (FIELD_NarrativeCode);
            postNarrativeCodeChange ();
        }
    }

    /**
     * Get the attribute ColorCode
     */
    public ColorCode getColorCode ()
    {
        assertValid();
        ColorCode valToReturn = _ColorCode;

            for (FactorScoreResultBehaviourDecorator bhd : FactorScoreResult_BehaviourDecorators)
            {
                valToReturn = bhd.getColorCode ((FactorScoreResult)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 preColorCodeChange (ColorCode newColorCode) 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 postColorCodeChange () throws FieldException
    {
    }

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

    /**
     * Set the attribute ColorCode.  Checks to ensure a new value
     * has been supplied.  If so, marks the field as altered and sets the attribute.
     */
    public void setColorCode (ColorCode newColorCode) throws FieldException
    {
        boolean oldAndNewIdentical = HELPER_ColorCode.compare (_ColorCode, newColorCode);
        
        try
        {
            for (FactorScoreResultBehaviourDecorator bhd : FactorScoreResult_BehaviourDecorators)
            {
                newColorCode = bhd.setColorCode ((FactorScoreResult)this, newColorCode);
                oldAndNewIdentical = HELPER_ColorCode.compare (_ColorCode, newColorCode);
            }

            

            if (FIELD_ColorCode_Validators.length > 0)
            {
                Object newColorCodeObj = HELPER_ColorCode.toObject (newColorCode);

                if (newColorCodeObj != null)
                {
                    int     loopMax = FIELD_ColorCode_Validators.length;
                    Map     metadata = (Map)ATTRIBUTES_METADATA_FactorScoreResult.get (FIELD_ColorCode);

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

        if (!oldAndNewIdentical)
        {
            assertValid();
            Debug.assertion (getWriteability_ColorCode () != FieldWriteability.FALSE, "Field  ColorCode is not writeable");
            preColorCodeChange (newColorCode);
            markFieldChange (FIELD_ColorCode);
            _ColorCode = newColorCode;            
            postFieldChange (FIELD_ColorCode);
            postColorCodeChange ();
        }
    }



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

        
        result.add("Factor");
        
        result.add("Level");
        

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


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


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


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


    public void setSingleAssoc (String assocName, BaseBusinessClass newValue) throws StorageException, FieldException
    {
        if (assocName == null)
        {
            throw new RuntimeException ("Game over == null!");
        }
        else if (assocName.equals (SINGLEREFERENCE_Factor))
        {
            setFactor ((Factor)(newValue));
        }else if (assocName.equals (SINGLEREFERENCE_Level))
        {
            setLevel ((Level)(newValue));
        }
        else
        {
            super.setSingleAssoc (assocName, newValue);
        }
    }



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


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


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

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


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



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

        if (_Factor.wouldReferencedChange (newFactor))
        {
            assertValid();
            Debug.assertion (getWriteability_Factor () != FieldWriteability.FALSE, "Assoc Factor is not writeable");
            preFactorChange (newFactor);
            
                    _Factor.set (newFactor);
                
            postFactorChange ();
        }
    }

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


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


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

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


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



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

        if (_Level.wouldReferencedChange (newLevel))
        {
            assertValid();
            Debug.assertion (getWriteability_Level () != FieldWriteability.FALSE, "Assoc Level is not writeable");
            preLevelChange (newLevel);
            
                    _Level.set (newLevel);
                
            postLevelChange ();
        }
    }

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

        

        return result;
    }


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

        return super.getMultiAssocReferenceInstance(attribName);
    }


    public String getMultiAssocBackReference(String attribName)
    {
        

        return super.getMultiAssocBackReference(attribName);
    }


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

        return super.getMultiAssocCount(attribName);
    }


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

        return super.getMultiAssocAt(attribName, index);
    }


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

        super.addToMultiAssoc(attribName, newElement);
    }

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

        super.removeFromMultiAssoc(attribName, oldElement);
    }


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

        super.__loadMultiAssoc(attribName, elements);
    }


    protected boolean __isMultiAssocLoaded (String attribName)
    {
        

        return super.__isMultiAssocLoaded(attribName);
    }

    



    public void onDelete ()
    {
        try 
        {
        }
        catch (Exception e)
        {
            throw NestedException.wrap(e);
        }

        super.onDelete ();
    }


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


    public FactorScoreResult referenceInstance ()
    {
        return REFERENCE_FactorScoreResult;
    }


    public FactorScoreResult getInTransaction (ObjectTransaction t) throws StorageException
    {
        return getFactorScoreResultByID (t, getObjectID());
    }
    
    
    public BaseBusinessClass dummyInstance ()
    {
        return DUMMY_FactorScoreResult;
    }


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





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

        level_factorPSet.setAttrib (FIELD_ObjectID, myID);
        level_factorPSet.setAttrib (FIELD_FromScore, HELPER_FromScore.toObject (_FromScore)); //
        level_factorPSet.setAttrib (FIELD_ToScore, HELPER_ToScore.toObject (_ToScore)); //
        level_factorPSet.setAttrib (FIELD_NarrativeCode, HELPER_NarrativeCode.toObject (_NarrativeCode)); //
        level_factorPSet.setAttrib (FIELD_ColorCode, HELPER_ColorCode.toObject (_ColorCode)); //
        _Factor.getPersistentSets (allSets);
        _Level.getPersistentSets (allSets);
        
    }


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

        
        PersistentSet   level_factorPSet = allSets.getPersistentSet (objectID, "level_factor");

        _FromScore = (Integer)(HELPER_FromScore.fromObject (_FromScore, level_factorPSet.getAttrib (FIELD_FromScore))); //
        _ToScore = (Integer)(HELPER_ToScore.fromObject (_ToScore, level_factorPSet.getAttrib (FIELD_ToScore))); //
        _NarrativeCode = (String)(HELPER_NarrativeCode.fromObject (_NarrativeCode, level_factorPSet.getAttrib (FIELD_NarrativeCode))); //
        _ColorCode = (ColorCode)(HELPER_ColorCode.fromObject (_ColorCode, level_factorPSet.getAttrib (FIELD_ColorCode))); //
        _Factor.setFromPersistentSets (objectID, allSets);
        _Level.setFromPersistentSets (objectID, allSets);
        
    }





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

        if (other instanceof FactorScoreResult)
        {
            FactorScoreResult otherFactorScoreResult = (FactorScoreResult)other;
            
            try
            {
                setFromScore (otherFactorScoreResult.getFromScore ());
            }
            catch (FieldException ex)
            {
                e.addException (ex);
            }
            
            try
            {
                setToScore (otherFactorScoreResult.getToScore ());
            }
            catch (FieldException ex)
            {
                e.addException (ex);
            }
            
            try
            {
                setNarrativeCode (otherFactorScoreResult.getNarrativeCode ());
            }
            catch (FieldException ex)
            {
                e.addException (ex);
            }
            
            try
            {
                setColorCode (otherFactorScoreResult.getColorCode ());
            }
            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 BaseFactorScoreResult)
        {
            BaseFactorScoreResult sourceFactorScoreResult = (BaseFactorScoreResult)(source);

            _FromScore = sourceFactorScoreResult._FromScore;
            _ToScore = sourceFactorScoreResult._ToScore;
            _NarrativeCode = sourceFactorScoreResult._NarrativeCode;
            _ColorCode = sourceFactorScoreResult._ColorCode;
            
        }
    }


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

            _Factor.copyFrom (sourceFactorScoreResult._Factor, linkToGhosts);
            _Level.copyFrom (sourceFactorScoreResult._Level, linkToGhosts);
            
        }
    }


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

        if (source instanceof BaseFactorScoreResult)
        {
            BaseFactorScoreResult sourceFactorScoreResult = (BaseFactorScoreResult)(source);

            
        }
    }


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

        
    }


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

        _FromScore = (Integer)(HELPER_FromScore.readExternal (_FromScore, vals.get(FIELD_FromScore))); //
        _ToScore = (Integer)(HELPER_ToScore.readExternal (_ToScore, vals.get(FIELD_ToScore))); //
        _NarrativeCode = (String)(HELPER_NarrativeCode.readExternal (_NarrativeCode, vals.get(FIELD_NarrativeCode))); //
        _ColorCode = (ColorCode)(HELPER_ColorCode.readExternal (_ColorCode, vals.get(FIELD_ColorCode))); //
        _Factor.readExternalData(vals.get(SINGLEREFERENCE_Factor));
        _Level.readExternalData(vals.get(SINGLEREFERENCE_Level));
        
    }


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

        vals.put (FIELD_FromScore, HELPER_FromScore.writeExternal (_FromScore));
        vals.put (FIELD_ToScore, HELPER_ToScore.writeExternal (_ToScore));
        vals.put (FIELD_NarrativeCode, HELPER_NarrativeCode.writeExternal (_NarrativeCode));
        vals.put (FIELD_ColorCode, HELPER_ColorCode.writeExternal (_ColorCode));
        vals.put (SINGLEREFERENCE_Factor, _Factor.writeExternalData());
        vals.put (SINGLEREFERENCE_Level, _Level.writeExternalData());
        
    }


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

        if (other instanceof BaseFactorScoreResult)
        {
            BaseFactorScoreResult otherFactorScoreResult = (BaseFactorScoreResult)(other);

            
            if (!HELPER_FromScore.compare(this._FromScore, otherFactorScoreResult._FromScore))
            {
                listener.notifyFieldChange(this, other, FIELD_FromScore, HELPER_FromScore.toObject(this._FromScore), HELPER_FromScore.toObject(otherFactorScoreResult._FromScore));
            }
            if (!HELPER_ToScore.compare(this._ToScore, otherFactorScoreResult._ToScore))
            {
                listener.notifyFieldChange(this, other, FIELD_ToScore, HELPER_ToScore.toObject(this._ToScore), HELPER_ToScore.toObject(otherFactorScoreResult._ToScore));
            }
            if (!HELPER_NarrativeCode.compare(this._NarrativeCode, otherFactorScoreResult._NarrativeCode))
            {
                listener.notifyFieldChange(this, other, FIELD_NarrativeCode, HELPER_NarrativeCode.toObject(this._NarrativeCode), HELPER_NarrativeCode.toObject(otherFactorScoreResult._NarrativeCode));
            }
            if (!HELPER_ColorCode.compare(this._ColorCode, otherFactorScoreResult._ColorCode))
            {
                listener.notifyFieldChange(this, other, FIELD_ColorCode, HELPER_ColorCode.toObject(this._ColorCode), HELPER_ColorCode.toObject(otherFactorScoreResult._ColorCode));
            }

            // Compare single assocs
            _Factor.compare (otherFactorScoreResult._Factor, listener);
            _Level.compare (otherFactorScoreResult._Level, listener);
            

            // Compare multiple assocs
            
        }
    }


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

        
    }


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

        visitor.visitField(this, FIELD_FromScore, HELPER_FromScore.toObject(getFromScore()));
        visitor.visitField(this, FIELD_ToScore, HELPER_ToScore.toObject(getToScore()));
        visitor.visitField(this, FIELD_NarrativeCode, HELPER_NarrativeCode.toObject(getNarrativeCode()));
        visitor.visitField(this, FIELD_ColorCode, HELPER_ColorCode.toObject(getColorCode()));
        visitor.visitAssociation (_Factor);
        visitor.visitAssociation (_Level);
        
    }


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

        if (scope.includes (_Factor))
        {
            visitor.visit (_Factor);
        }
        if (scope.includes (_Level))
        {
            visitor.visit (_Level);
        }
        
    }


    public static FactorScoreResult createFactorScoreResult (ObjectTransaction transaction) throws StorageException
    {
        FactorScoreResult     result = new FactorScoreResult ();

        result.initialiseNewObject (transaction);

        return result;
    }


    public static FactorScoreResult getFactorScoreResultByID (ObjectTransaction transaction, Long objectID) throws StorageException
    {
        return (FactorScoreResult)(transaction.getObjectByID (REFERENCE_FactorScoreResult, objectID));
    }

    public boolean testFilter (String attribName, QueryFilter filter) throws StorageException
    {
        if (false)
        {
            throw new RuntimeException ("Game over man!!");
        }
        else if (attribName.equals (FIELD_FromScore))
        {
            return filter.matches (getFromScore ());
        }
        else if (attribName.equals (FIELD_ToScore))
        {
            return filter.matches (getToScore ());
        }
        else if (attribName.equals (FIELD_NarrativeCode))
        {
            return filter.matches (getNarrativeCode ());
        }
        else if (attribName.equals (FIELD_ColorCode))
        {
            return filter.matches (getColorCode ());
        }
        else if (attribName.equals (SINGLEREFERENCE_Factor))
        {
            return filter.matches (getFactor ());
        }
        else if (attribName.equals (SINGLEREFERENCE_Level))
        {
            return filter.matches (getLevel ());
        }
        else
        {
            return super.testFilter (attribName, filter);
        }
    }


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

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

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

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

            
            public SearchAll andFromScore (QueryFilter<Integer> filter)
            {
                filter.addFilter (context, "level_factor.from_score", "FromScore");
                return this;
            }
            
            public SearchAll andToScore (QueryFilter<Integer> filter)
            {
                filter.addFilter (context, "level_factor.to_score", "ToScore");
                return this;
            }
            
            public SearchAll andNarrativeCode (QueryFilter<String> filter)
            {
                filter.addFilter (context, "level_factor.narrative_code", "NarrativeCode");
                return this;
            }
            
            public SearchAll andColorCode (QueryFilter<ColorCode> filter)
            {
                filter.addFilter (context, "level_factor.color_code", "ColorCode");
                return this;
            }
            
            public SearchAll andFactor (QueryFilter<Factor> filter)
            {
                filter.addFilter (context, "level_factor.factor_number", "Factor");
                return this;
            }
            
            public SearchAll andLevel (QueryFilter<Level> filter)
            {
                filter.addFilter (context, "level_factor.level_number", "Level");
                return this;
            }
            
                public FactorScoreResult[]
             search (ObjectTransaction transaction) throws StorageException
        {
            
            
            BaseBusinessClass[]     results = super.search (transaction, REFERENCE_FactorScoreResult, SEARCH_All, criteria);
            Set<FactorScoreResult>   typedResults = new LinkedHashSet <FactorScoreResult> ();
            for (BaseBusinessClass bbcResult : results)
            {
                FactorScoreResult aResult = (FactorScoreResult)bbcResult;
                
                typedResults.add (aResult);
            }
            
                    return ObjstoreUtils.removeDeleted(transaction, typedResults).toArray (new FactorScoreResult[0]);
                            
        }
    }

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

    public static SearchFactorScore SearchByFactorScore () { return new SearchFactorScore (); }

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

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

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

            
            public SearchFactorScore andFromScore (QueryFilter<Integer> filter)
            {
                filter.addFilter (context, "level_factor.from_score", "FromScore");
                return this;
            }
            
            public SearchFactorScore andToScore (QueryFilter<Integer> filter)
            {
                filter.addFilter (context, "level_factor.to_score", "ToScore");
                return this;
            }
            
            public SearchFactorScore andNarrativeCode (QueryFilter<String> filter)
            {
                filter.addFilter (context, "level_factor.narrative_code", "NarrativeCode");
                return this;
            }
            
            public SearchFactorScore andColorCode (QueryFilter<ColorCode> filter)
            {
                filter.addFilter (context, "level_factor.color_code", "ColorCode");
                return this;
            }
            
            public SearchFactorScore andFactor (QueryFilter<Factor> filter)
            {
                filter.addFilter (context, "level_factor.factor_number", "Factor");
                return this;
            }
            
            public SearchFactorScore andLevel (QueryFilter<Level> filter)
            {
                filter.addFilter (context, "level_factor.level_number", "Level");
                return this;
            }
            
                public FactorScoreResult search (ObjectTransaction transaction) throws StorageException
        {
            
            
            BaseBusinessClass[]     results = super.search (transaction, REFERENCE_FactorScoreResult, SEARCH_FactorScore, criteria);
            Set<FactorScoreResult>   typedResults = new LinkedHashSet <FactorScoreResult> ();
            for (BaseBusinessClass bbcResult : results)
            {
                FactorScoreResult aResult = (FactorScoreResult)bbcResult;
                
                typedResults.add (aResult);
            }
            
                    return (FactorScoreResult)singletonResult(ObjstoreUtils.removeDeleted(transaction, typedResults).toArray(new BaseBusinessClass[0]), "FactorScoreResult", "");
                            
        }
    }

        
                public static FactorScoreResult searchFactorScore (ObjectTransaction transaction) throws StorageException
        {
            return SearchByFactorScore ()
            .search (transaction);
        }



    public Object getAttribute (String attribName)
    {
        if (false)
        {
            throw new RuntimeException ("Game over man!!");
        }
        else if (attribName.equals (FIELD_FromScore))
        {
            return HELPER_FromScore.toObject (getFromScore ());
        }
        else if (attribName.equals (FIELD_ToScore))
        {
            return HELPER_ToScore.toObject (getToScore ());
        }
        else if (attribName.equals (FIELD_NarrativeCode))
        {
            return HELPER_NarrativeCode.toObject (getNarrativeCode ());
        }
        else if (attribName.equals (FIELD_ColorCode))
        {
            return HELPER_ColorCode.toObject (getColorCode ());
        }
        else
        {
            return super.getAttribute (attribName);
        }
    }


    public AttributeHelper getAttributeHelper (String attribName)
    {
        if (false)
        {
            throw new RuntimeException ("Game over man!!");
        }
        else if (attribName.equals (FIELD_FromScore))
        {
            return HELPER_FromScore;
        }
        else if (attribName.equals (FIELD_ToScore))
        {
            return HELPER_ToScore;
        }
        else if (attribName.equals (FIELD_NarrativeCode))
        {
            return HELPER_NarrativeCode;
        }
        else if (attribName.equals (FIELD_ColorCode))
        {
            return HELPER_ColorCode;
        }
        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_FromScore))
        {
            setFromScore ((Integer)(HELPER_FromScore.fromObject (_FromScore, attribValue)));            
        }
        else if (attribName.equals (FIELD_ToScore))
        {
            setToScore ((Integer)(HELPER_ToScore.fromObject (_ToScore, attribValue)));            
        }
        else if (attribName.equals (FIELD_NarrativeCode))
        {
            setNarrativeCode ((String)(HELPER_NarrativeCode.fromObject (_NarrativeCode, attribValue)));            
        }
        else if (attribName.equals (FIELD_ColorCode))
        {
            setColorCode ((ColorCode)(HELPER_ColorCode.fromObject (_ColorCode, 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_FromScore))
        {
            return getWriteability_FromScore ();
        }
        else if (fieldName.equals (FIELD_ToScore))
        {
            return getWriteability_ToScore ();
        }
        else if (fieldName.equals (FIELD_NarrativeCode))
        {
            return getWriteability_NarrativeCode ();
        }
        else if (fieldName.equals (FIELD_ColorCode))
        {
            return getWriteability_ColorCode ();
        }
        else if (fieldName.equals (SINGLEREFERENCE_Factor))
        {
            return getWriteability_Factor ();
        }
        else if (fieldName.equals (SINGLEREFERENCE_Level))
        {
            return getWriteability_Level ();
        }
        else
        {
            return super.getWriteable (fieldName);
        }
    }


    public void putUnwriteable (Set<String> fields)
    {
        
            if (getWriteability_FromScore () != FieldWriteability.TRUE)
            {
                fields.add (FIELD_FromScore);
            }
        
            if (getWriteability_ToScore () != FieldWriteability.TRUE)
            {
                fields.add (FIELD_ToScore);
            }
        
            if (getWriteability_NarrativeCode () != FieldWriteability.TRUE)
            {
                fields.add (FIELD_NarrativeCode);
            }
        
            if (getWriteability_ColorCode () != FieldWriteability.TRUE)
            {
                fields.add (FIELD_ColorCode);
            }
        

        super.putUnwriteable (fields);
    }

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

        
        result.add(HELPER_FromScore.getAttribObject (getClass (), _FromScore, false, FIELD_FromScore));
        result.add(HELPER_ToScore.getAttribObject (getClass (), _ToScore, false, FIELD_ToScore));
        result.add(HELPER_NarrativeCode.getAttribObject (getClass (), _NarrativeCode, false, FIELD_NarrativeCode));
        result.add(HELPER_ColorCode.getAttribObject (getClass (), _ColorCode, false, FIELD_ColorCode));

        return result;
    }


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


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

    /**
     * Get the attribute FromScore
     */
    public Integer getFromScore (FactorScoreResult obj, Integer original)
    {
        return original;
    }

    /**
     * Change the value set for attribute FromScore.
     * May modify the field beforehand
     * Occurs before validation.
     */
    public Integer setFromScore (FactorScoreResult obj, Integer newFromScore) throws FieldException
    {
        return newFromScore;
    }

    /**
     * Get the attribute ToScore
     */
    public Integer getToScore (FactorScoreResult obj, Integer original)
    {
        return original;
    }

    /**
     * Change the value set for attribute ToScore.
     * May modify the field beforehand
     * Occurs before validation.
     */
    public Integer setToScore (FactorScoreResult obj, Integer newToScore) throws FieldException
    {
        return newToScore;
    }

    /**
     * Get the attribute NarrativeCode
     */
    public String getNarrativeCode (FactorScoreResult obj, String original)
    {
        return original;
    }

    /**
     * Change the value set for attribute NarrativeCode.
     * May modify the field beforehand
     * Occurs before validation.
     */
    public String setNarrativeCode (FactorScoreResult obj, String newNarrativeCode) throws FieldException
    {
        return newNarrativeCode;
    }

    /**
     * Get the attribute ColorCode
     */
    public ColorCode getColorCode (FactorScoreResult obj, ColorCode original)
    {
        return original;
    }

    /**
     * Change the value set for attribute ColorCode.
     * May modify the field beforehand
     * Occurs before validation.
     */
    public ColorCode setColorCode (FactorScoreResult obj, ColorCode newColorCode) throws FieldException
    {
        return newColorCode;
    }

    }

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

        public FactorScoreResultPipeLineFactory (Collection<From> seed)
        {
            super(seed);
        }
        
        
        public PipeLine<From, ? extends Object> to(String name)
        {
            if (name.equals ("FromScore"))
            {
                return toFromScore ();
            }                
            if (name.equals ("ToScore"))
            {
                return toToScore ();
            }                
            if (name.equals ("NarrativeCode"))
            {
                return toNarrativeCode ();
            }                
            if (name.equals ("ColorCode"))
            {
                return toColorCode ();
            }                
            if (name.equals ("Factor"))
            {
                return toFactor ();
            }                
            if (name.equals ("Level"))
            {
                return toLevel ();
            }                
            
            
            return super.to(name);
        }
        
        
        public PipeLine<From, Integer> toFromScore () { return pipe(new ORMAttributePipe<Me, Integer>(FIELD_FromScore));  }
        
        public PipeLine<From, Integer> toToScore () { return pipe(new ORMAttributePipe<Me, Integer>(FIELD_ToScore));  }
        
        public PipeLine<From, String> toNarrativeCode () { return pipe(new ORMAttributePipe<Me, String>(FIELD_NarrativeCode));  }
        
        public PipeLine<From, ColorCode> toColorCode () { return pipe(new ORMAttributePipe<Me, ColorCode>(FIELD_ColorCode));  }
        public Factor.FactorPipeLineFactory<From, Factor> toFactor () { return toFactor (Filter.ALL); }

        public Factor.FactorPipeLineFactory<From, Factor> toFactor (Filter<Factor> filter) 
        { 
            return Factor.REFERENCE_Factor.new FactorPipeLineFactory<From, Factor> (this, new ORMSingleAssocPipe<Me, Factor>(SINGLEREFERENCE_Factor, filter)); 
        }
        public Level.LevelPipeLineFactory<From, Level> toLevel () { return toLevel (Filter.ALL); }

        public Level.LevelPipeLineFactory<From, Level> toLevel (Filter<Level> filter) 
        { 
            return Level.REFERENCE_Level.new LevelPipeLineFactory<From, Level> (this, new ORMSingleAssocPipe<Me, Level>(SINGLEREFERENCE_Level, filter)); 
        }
        
    }
    
    public boolean isTransientAttrib(String attribName)
    {
        

        return super.isTransientAttrib(attribName);
    }

    public boolean isTransientSingleReference(String assocName)
    {
        

        return super.isTransientSingleReference(assocName);
    }
}

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

    public void assertValid ()
    {
    }


    public Factor getFactor () throws StorageException
    {
        return (Factor)(Factor.DUMMY_Factor);
    }


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

    public Level getLevel () throws StorageException
    {
        return (Level)(Level.DUMMY_Level);
    }


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

}

    
