/*
 * 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 BaseAssessmentCriteriaAnswer extends BaseBusinessClass
{
    // Reference instance for the object
    public static final AssessmentCriteriaAnswer REFERENCE_AssessmentCriteriaAnswer = new AssessmentCriteriaAnswer ();

    // Reference instance for the object
    public static final AssessmentCriteriaAnswer DUMMY_AssessmentCriteriaAnswer = new DummyAssessmentCriteriaAnswer ();

    // Static constants corresponding to field names
    
    public static final String FIELD_Answer = "Answer";
    public static final String FIELD_Notes = "Notes";
    public static final String SINGLEREFERENCE_AssessmentCriteria = "AssessmentCriteria";
    public static final String BACKREF_AssessmentCriteria = "";
    public static final String SINGLEREFERENCE_JobApplication = "JobApplication";
    public static final String BACKREF_JobApplication = "";

    // Static constants corresponding to searches
    public static final String SEARCH_All = "All";
    public static final String SEARCH_CriteriaType = "CriteriaType";
    public static final String SEARCH_CriteriaApplication = "CriteriaApplication";
    

    // Static constants corresponding to attribute helpers
    private static final DefaultAttributeHelper<AssessmentCriteriaAnswer> HELPER_Answer = DefaultAttributeHelper.INSTANCE;
    private static final DefaultAttributeHelper<AssessmentCriteriaAnswer> HELPER_Notes = DefaultAttributeHelper.INSTANCE;
    

    // Private attributes corresponding to business object data
    private Boolean _Answer;
    private String _Notes;
    

    // Private attributes corresponding to single references
    private SingleAssociation<AssessmentCriteriaAnswer, AssessmentCriteria> _AssessmentCriteria;
    private SingleAssociation<AssessmentCriteriaAnswer, JobApplication> _JobApplication;
    

    // Private attributes corresponding to multiple references
    

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

    // Arrays of validators for each attribute
    private static final AttributeValidator[] FIELD_Answer_Validators;
    private static final AttributeValidator[] FIELD_Notes_Validators;
    

    // Arrays of behaviour decorators
    private static final AssessmentCriteriaAnswerBehaviourDecorator[] AssessmentCriteriaAnswer_BehaviourDecorators;
    
    static
    {
        try
        {
            
            String tmp_AssessmentCriteria = AssessmentCriteria.BACKREF_Answers;
            String tmp_JobApplication = JobApplication.BACKREF_AssessmentCriteriaAnswers;
            
            Map  validatorMapping = ((Map)ConfigMgr.getConfigObject ("CONFIG.ORMVALIDATOR", "ValidatorMapping"));

            setupAssocMetaData_AssessmentCriteria();
            setupAssocMetaData_JobApplication();
            FIELD_Answer_Validators = (AttributeValidator[])setupAttribMetaData_Answer(validatorMapping).toArray (new AttributeValidator[0]);
            FIELD_Notes_Validators = (AttributeValidator[])setupAttribMetaData_Notes(validatorMapping).toArray (new AttributeValidator[0]);
            

            REFERENCE_AssessmentCriteriaAnswer.initialiseReference ();
            DUMMY_AssessmentCriteriaAnswer.initialiseReference ();
            AssessmentCriteriaAnswer_BehaviourDecorators = BaseBusinessClass.getBBCBehaviours(AssessmentCriteriaAnswer.class).toArray(new AssessmentCriteriaAnswerBehaviourDecorator[0]);
        }
        catch (RuntimeException e)
        {
            LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR1, e, "Error initialising");
            throw e;
        }
    }

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

        metaInfo.put ("backreferenceName", "Answers");
        metaInfo.put ("dbcol", "assessment_criteria_id");
        metaInfo.put ("mandatory", "true");
        metaInfo.put ("name", "AssessmentCriteria");
        metaInfo.put ("type", "AssessmentCriteria");
        
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for AssessmentCriteriaAnswer.AssessmentCriteria:", metaInfo);
        ATTRIBUTES_METADATA_AssessmentCriteriaAnswer.put (SINGLEREFERENCE_AssessmentCriteria, Collections.unmodifiableMap (metaInfo));
    }
    
    
    // Meta Info setup
    private static void setupAssocMetaData_JobApplication()
    {
        Map metaInfo = new HashMap ();

        metaInfo.put ("backreferenceName", "AssessmentCriteriaAnswers");
        metaInfo.put ("dbcol", "job_application_id");
        metaInfo.put ("mandatory", "true");
        metaInfo.put ("name", "JobApplication");
        metaInfo.put ("type", "JobApplication");
        
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for AssessmentCriteriaAnswer.JobApplication:", metaInfo);
        ATTRIBUTES_METADATA_AssessmentCriteriaAnswer.put (SINGLEREFERENCE_JobApplication, Collections.unmodifiableMap (metaInfo));
    }
    
    
    // Meta Info setup
    private static List setupAttribMetaData_Answer(Map validatorMapping)
    {
        Map  metaInfo   = new HashMap ();

        metaInfo.put ("dbcol", "answer");
        metaInfo.put ("mandatory", "true");
        metaInfo.put ("name", "Answer");
        metaInfo.put ("type", "Boolean");
        
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for AssessmentCriteriaAnswer.Answer:", metaInfo);
        ATTRIBUTES_METADATA_AssessmentCriteriaAnswer.put (FIELD_Answer, Collections.unmodifiableMap (metaInfo));

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

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

        metaInfo.put ("dbcol", "notes");
        metaInfo.put ("name", "Notes");
        metaInfo.put ("type", "String");
        
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for AssessmentCriteriaAnswer.Notes:", metaInfo);
        ATTRIBUTES_METADATA_AssessmentCriteriaAnswer.put (FIELD_Notes, Collections.unmodifiableMap (metaInfo));

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

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


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


    


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

        
        _Answer = (Boolean)(HELPER_Answer.initialise (_Answer));
        _Notes = (String)(HELPER_Notes.initialise (_Notes));
    }


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

        _AssessmentCriteria = new SingleAssociation<AssessmentCriteriaAnswer, AssessmentCriteria> (this, SINGLEREFERENCE_AssessmentCriteria, AssessmentCriteria.MULTIPLEREFERENCE_Answers, AssessmentCriteria.REFERENCE_AssessmentCriteria, "tl_assessment_criteria_answer");
        _JobApplication = new SingleAssociation<AssessmentCriteriaAnswer, JobApplication> (this, SINGLEREFERENCE_JobApplication, JobApplication.MULTIPLEREFERENCE_AssessmentCriteriaAnswers, JobApplication.REFERENCE_JobApplication, "tl_assessment_criteria_answer");
        
    }


    // Initialise the associations
    protected BaseBusinessClass initialiseReference ()
    {
        super.initialiseReference ();
        
        _AssessmentCriteria = new SingleAssociation<AssessmentCriteriaAnswer, AssessmentCriteria> (this, SINGLEREFERENCE_AssessmentCriteria, AssessmentCriteria.MULTIPLEREFERENCE_Answers, AssessmentCriteria.REFERENCE_AssessmentCriteria, "tl_assessment_criteria_answer");
        _JobApplication = new SingleAssociation<AssessmentCriteriaAnswer, JobApplication> (this, SINGLEREFERENCE_JobApplication, JobApplication.MULTIPLEREFERENCE_AssessmentCriteriaAnswers, JobApplication.REFERENCE_JobApplication, "tl_assessment_criteria_answer");
        
        
        return this;
    }

    

    /**
     * Get the attribute Answer
     */
    public Boolean getAnswer ()
    {
        assertValid();
        Boolean valToReturn = _Answer;

            for (AssessmentCriteriaAnswerBehaviourDecorator bhd : AssessmentCriteriaAnswer_BehaviourDecorators)
            {
                valToReturn = bhd.getAnswer ((AssessmentCriteriaAnswer)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 preAnswerChange (Boolean newAnswer) 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 postAnswerChange () throws FieldException
    {
    }

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

    /**
     * Set the attribute Answer.  Checks to ensure a new value
     * has been supplied.  If so, marks the field as altered and sets the attribute.
     */
    public void setAnswer (Boolean newAnswer) throws FieldException
    {
        boolean oldAndNewIdentical = HELPER_Answer.compare (_Answer, newAnswer);
        
        try
        {
            for (AssessmentCriteriaAnswerBehaviourDecorator bhd : AssessmentCriteriaAnswer_BehaviourDecorators)
            {
                newAnswer = bhd.setAnswer ((AssessmentCriteriaAnswer)this, newAnswer);
                oldAndNewIdentical = HELPER_Answer.compare (_Answer, newAnswer);
            }

            BusinessObjectParser.assertFieldCondition (newAnswer != null, this, FIELD_Answer, "mandatory");
            

            if (FIELD_Answer_Validators.length > 0)
            {
                Object newAnswerObj = HELPER_Answer.toObject (newAnswer);

                if (newAnswerObj != null)
                {
                    int     loopMax = FIELD_Answer_Validators.length;
                    Map     metadata = (Map)ATTRIBUTES_METADATA_AssessmentCriteriaAnswer.get (FIELD_Answer);

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

        if (!oldAndNewIdentical)
        {
            assertValid();
            Debug.assertion (getWriteability_Answer () != FieldWriteability.FALSE, "Field  Answer is not writeable");
            preAnswerChange (newAnswer);
            markFieldChange (FIELD_Answer);
            _Answer = newAnswer;            
            postFieldChange (FIELD_Answer);
            postAnswerChange ();
        }
    }

    /**
     * Get the attribute Notes
     */
    public String getNotes ()
    {
        assertValid();
        String valToReturn = _Notes;

            for (AssessmentCriteriaAnswerBehaviourDecorator bhd : AssessmentCriteriaAnswer_BehaviourDecorators)
            {
                valToReturn = bhd.getNotes ((AssessmentCriteriaAnswer)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 preNotesChange (String newNotes) 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 postNotesChange () throws FieldException
    {
    }

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

    /**
     * Set the attribute Notes.  Checks to ensure a new value
     * has been supplied.  If so, marks the field as altered and sets the attribute.
     */
    public void setNotes (String newNotes) throws FieldException
    {
        boolean oldAndNewIdentical = HELPER_Notes.compare (_Notes, newNotes);
        
        try
        {
            for (AssessmentCriteriaAnswerBehaviourDecorator bhd : AssessmentCriteriaAnswer_BehaviourDecorators)
            {
                newNotes = bhd.setNotes ((AssessmentCriteriaAnswer)this, newNotes);
                oldAndNewIdentical = HELPER_Notes.compare (_Notes, newNotes);
            }

            

            if (FIELD_Notes_Validators.length > 0)
            {
                Object newNotesObj = HELPER_Notes.toObject (newNotes);

                if (newNotesObj != null)
                {
                    int     loopMax = FIELD_Notes_Validators.length;
                    Map     metadata = (Map)ATTRIBUTES_METADATA_AssessmentCriteriaAnswer.get (FIELD_Notes);

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

        if (!oldAndNewIdentical)
        {
            assertValid();
            Debug.assertion (getWriteability_Notes () != FieldWriteability.FALSE, "Field  Notes is not writeable");
            preNotesChange (newNotes);
            markFieldChange (FIELD_Notes);
            _Notes = newNotes;            
            postFieldChange (FIELD_Notes);
            postNotesChange ();
        }
    }



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

        
        result.add("AssessmentCriteria");
        
        result.add("JobApplication");
        

        return result;
    }
    
    
    public BaseBusinessClass getSingleAssocReferenceInstance (String assocName)
    {
        if (assocName == null)
        {
            throw new RuntimeException ("Game over == null!");
        }
        else if (assocName.equals (SINGLEREFERENCE_AssessmentCriteria))
        {
            return _AssessmentCriteria.getReferencedType ();
        }else if (assocName.equals (SINGLEREFERENCE_JobApplication))
        {
            return _JobApplication.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_AssessmentCriteria))
        {
            return AssessmentCriteria.MULTIPLEREFERENCE_Answers ;
        }else if (assocName.equals (SINGLEREFERENCE_JobApplication))
        {
            return JobApplication.MULTIPLEREFERENCE_AssessmentCriteriaAnswers ;
        }
        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_AssessmentCriteria))
        {
            return getAssessmentCriteria ();
        }else if (assocName.equals (SINGLEREFERENCE_JobApplication))
        {
            return getJobApplication ();
        }
        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_AssessmentCriteria))
        {
            return getAssessmentCriteria (getType);
        }else if (assocName.equals (SINGLEREFERENCE_JobApplication))
        {
            return getJobApplication (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_AssessmentCriteria))
        {
            return getAssessmentCriteriaID ();
        }else if (assocName.equals (SINGLEREFERENCE_JobApplication))
        {
            return getJobApplicationID ();
        }
        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_AssessmentCriteria))
        {
            setAssessmentCriteria ((AssessmentCriteria)(newValue));
        }else if (assocName.equals (SINGLEREFERENCE_JobApplication))
        {
            setJobApplication ((JobApplication)(newValue));
        }
        else
        {
            super.setSingleAssoc (assocName, newValue);
        }
    }



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


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


    /**
     * Get the object id for the referenced object.  Does not force a DB access.
     */
    public Long getAssessmentCriteriaID ()
    {
        assertValid();
        
        if (_AssessmentCriteria == null)
        {
            return null;
        }
        else
        {
            return _AssessmentCriteria.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 preAssessmentCriteriaChange (AssessmentCriteria newAssessmentCriteria) 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 postAssessmentCriteriaChange () throws FieldException
    {
    }



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

        if (_AssessmentCriteria.wouldReferencedChange (newAssessmentCriteria))
        {
            assertValid();
            Debug.assertion (getWriteability_AssessmentCriteria () != FieldWriteability.FALSE, "Assoc AssessmentCriteria is not writeable");
            preAssessmentCriteriaChange (newAssessmentCriteria);
            AssessmentCriteria oldAssessmentCriteria = getAssessmentCriteria ();

                    if (oldAssessmentCriteria != null)
                    {
                        // This is to stop validation from triggering when we are removed
                        _AssessmentCriteria.set (null);
                        oldAssessmentCriteria.removeFromAnswers ((AssessmentCriteriaAnswer)(this));
                    }

                    _AssessmentCriteria.set (newAssessmentCriteria);

                    if (newAssessmentCriteria != null)
                    {
                        newAssessmentCriteria.addToAnswers ((AssessmentCriteriaAnswer)(this));
                    }
                
            postAssessmentCriteriaChange ();
        }
    }

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


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


    /**
     * Get the object id for the referenced object.  Does not force a DB access.
     */
    public Long getJobApplicationID ()
    {
        assertValid();
        
        if (_JobApplication == null)
        {
            return null;
        }
        else
        {
            return _JobApplication.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 preJobApplicationChange (JobApplication newJobApplication) 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 postJobApplicationChange () throws FieldException
    {
    }



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

        if (_JobApplication.wouldReferencedChange (newJobApplication))
        {
            assertValid();
            Debug.assertion (getWriteability_JobApplication () != FieldWriteability.FALSE, "Assoc JobApplication is not writeable");
            preJobApplicationChange (newJobApplication);
            JobApplication oldJobApplication = getJobApplication ();

                    if (oldJobApplication != null)
                    {
                        // This is to stop validation from triggering when we are removed
                        _JobApplication.set (null);
                        oldJobApplication.removeFromAssessmentCriteriaAnswers ((AssessmentCriteriaAnswer)(this));
                    }

                    _JobApplication.set (newJobApplication);

                    if (newJobApplication != null)
                    {
                        newJobApplication.addToAssessmentCriteriaAnswers ((AssessmentCriteriaAnswer)(this));
                    }
                
            postJobApplicationChange ();
        }
    }

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

        

        return result;
    }


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

        return super.getMultiAssocReferenceInstance(attribName);
    }


    public String getMultiAssocBackReference(String attribName)
    {
        

        return super.getMultiAssocBackReference(attribName);
    }


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

        return super.getMultiAssocCount(attribName);
    }


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

        return super.getMultiAssocAt(attribName, index);
    }


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

        super.addToMultiAssoc(attribName, newElement);
    }

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

        super.removeFromMultiAssoc(attribName, oldElement);
    }


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

        super.__loadMultiAssoc(attribName, elements);
    }


    protected boolean __isMultiAssocLoaded (String attribName)
    {
        

        return super.__isMultiAssocLoaded(attribName);
    }

    



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

                if (referenced != null)
                {
                    // Stop the callback
                    LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Setting backreference to null Answers from ", getObjectID (), " to ", referenced.getObjectID ());
                    _AssessmentCriteria.set (null);
                    referenced.removeFromAnswers ((AssessmentCriteriaAnswer)this);
                }
            }
        
            // Ensure we are removed from any loaded multi-associations that aren't mandatory
            if (_JobApplication.isLoaded () || getTransaction ().isObjectLoaded (_JobApplication.getReferencedType (), getJobApplicationID ()))
            {
                JobApplication  referenced = getJobApplication ();

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

        super.onDelete ();
    }


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


    public AssessmentCriteriaAnswer referenceInstance ()
    {
        return REFERENCE_AssessmentCriteriaAnswer;
    }


    public AssessmentCriteriaAnswer getInTransaction (ObjectTransaction t) throws StorageException
    {
        return getAssessmentCriteriaAnswerByID (t, getObjectID());
    }
    
    
    public BaseBusinessClass dummyInstance ()
    {
        return DUMMY_AssessmentCriteriaAnswer;
    }


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





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

        tl_assessment_criteria_answerPSet.setAttrib (FIELD_ObjectID, myID);
        tl_assessment_criteria_answerPSet.setAttrib (FIELD_Answer, HELPER_Answer.toObject (_Answer)); //
        tl_assessment_criteria_answerPSet.setAttrib (FIELD_Notes, HELPER_Notes.toObject (_Notes)); //
        _AssessmentCriteria.getPersistentSets (allSets);
        _JobApplication.getPersistentSets (allSets);
        
    }


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

        
        PersistentSet   tl_assessment_criteria_answerPSet = allSets.getPersistentSet (objectID, "tl_assessment_criteria_answer");

        _Answer = (Boolean)(HELPER_Answer.fromObject (_Answer, tl_assessment_criteria_answerPSet.getAttrib (FIELD_Answer))); //
        _Notes = (String)(HELPER_Notes.fromObject (_Notes, tl_assessment_criteria_answerPSet.getAttrib (FIELD_Notes))); //
        _AssessmentCriteria.setFromPersistentSets (objectID, allSets);
        _JobApplication.setFromPersistentSets (objectID, allSets);
        
    }





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

        if (other instanceof AssessmentCriteriaAnswer)
        {
            AssessmentCriteriaAnswer otherAssessmentCriteriaAnswer = (AssessmentCriteriaAnswer)other;
            
            try
            {
                setAnswer (otherAssessmentCriteriaAnswer.getAnswer ());
            }
            catch (FieldException ex)
            {
                e.addException (ex);
            }
            
            try
            {
                setNotes (otherAssessmentCriteriaAnswer.getNotes ());
            }
            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 BaseAssessmentCriteriaAnswer)
        {
            BaseAssessmentCriteriaAnswer sourceAssessmentCriteriaAnswer = (BaseAssessmentCriteriaAnswer)(source);

            _Answer = sourceAssessmentCriteriaAnswer._Answer;
            _Notes = sourceAssessmentCriteriaAnswer._Notes;
            
        }
    }


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

            _AssessmentCriteria.copyFrom (sourceAssessmentCriteriaAnswer._AssessmentCriteria, linkToGhosts);
            _JobApplication.copyFrom (sourceAssessmentCriteriaAnswer._JobApplication, 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 BaseAssessmentCriteriaAnswer)
        {
            BaseAssessmentCriteriaAnswer sourceAssessmentCriteriaAnswer = (BaseAssessmentCriteriaAnswer)(source);

            
        }
    }


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

        
        context.check (getAssessmentCriteriaID() != null, this, SINGLEREFERENCE_AssessmentCriteria, "mandatory");
        
        context.check (getJobApplicationID() != null, this, SINGLEREFERENCE_JobApplication, "mandatory");
        
    }


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

        _Answer = (Boolean)(HELPER_Answer.readExternal (_Answer, vals.get(FIELD_Answer))); //
        _Notes = (String)(HELPER_Notes.readExternal (_Notes, vals.get(FIELD_Notes))); //
        _AssessmentCriteria.readExternalData(vals.get(SINGLEREFERENCE_AssessmentCriteria));
        _JobApplication.readExternalData(vals.get(SINGLEREFERENCE_JobApplication));
        
    }


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

        vals.put (FIELD_Answer, HELPER_Answer.writeExternal (_Answer));
        vals.put (FIELD_Notes, HELPER_Notes.writeExternal (_Notes));
        vals.put (SINGLEREFERENCE_AssessmentCriteria, _AssessmentCriteria.writeExternalData());
        vals.put (SINGLEREFERENCE_JobApplication, _JobApplication.writeExternalData());
        
    }


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

        if (other instanceof BaseAssessmentCriteriaAnswer)
        {
            BaseAssessmentCriteriaAnswer otherAssessmentCriteriaAnswer = (BaseAssessmentCriteriaAnswer)(other);

            
            if (!HELPER_Answer.compare(this._Answer, otherAssessmentCriteriaAnswer._Answer))
            {
                listener.notifyFieldChange(this, other, FIELD_Answer, HELPER_Answer.toObject(this._Answer), HELPER_Answer.toObject(otherAssessmentCriteriaAnswer._Answer));
            }
            if (!HELPER_Notes.compare(this._Notes, otherAssessmentCriteriaAnswer._Notes))
            {
                listener.notifyFieldChange(this, other, FIELD_Notes, HELPER_Notes.toObject(this._Notes), HELPER_Notes.toObject(otherAssessmentCriteriaAnswer._Notes));
            }

            // Compare single assocs
            _AssessmentCriteria.compare (otherAssessmentCriteriaAnswer._AssessmentCriteria, listener);
            _JobApplication.compare (otherAssessmentCriteriaAnswer._JobApplication, 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_Answer, HELPER_Answer.toObject(getAnswer()));
        visitor.visitField(this, FIELD_Notes, HELPER_Notes.toObject(getNotes()));
        visitor.visitAssociation (_AssessmentCriteria);
        visitor.visitAssociation (_JobApplication);
        
    }


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

        if (scope.includes (_AssessmentCriteria))
        {
            visitor.visit (_AssessmentCriteria);
        }
        if (scope.includes (_JobApplication))
        {
            visitor.visit (_JobApplication);
        }
        
    }


    public static AssessmentCriteriaAnswer createAssessmentCriteriaAnswer (ObjectTransaction transaction) throws StorageException
    {
        AssessmentCriteriaAnswer     result = new AssessmentCriteriaAnswer ();

        result.initialiseNewObject (transaction);

        return result;
    }


    public static AssessmentCriteriaAnswer getAssessmentCriteriaAnswerByID (ObjectTransaction transaction, Long objectID) throws StorageException
    {
        return (AssessmentCriteriaAnswer)(transaction.getObjectByID (REFERENCE_AssessmentCriteriaAnswer, objectID));
    }

    public boolean testFilter (String attribName, QueryFilter filter) throws StorageException
    {
        if (false)
        {
            throw new RuntimeException ("Game over man!!");
        }
        else if (attribName.equals (FIELD_Answer))
        {
            return filter.matches (getAnswer ());
        }
        else if (attribName.equals (FIELD_Notes))
        {
            return filter.matches (getNotes ());
        }
        else if (attribName.equals (SINGLEREFERENCE_AssessmentCriteria))
        {
            return filter.matches (getAssessmentCriteria ());
        }
        else if (attribName.equals (SINGLEREFERENCE_JobApplication))
        {
            return filter.matches (getJobApplication ());
        }
        else
        {
            return super.testFilter (attribName, filter);
        }
    }


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

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

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

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

            
            public SearchAll andAnswer (QueryFilter<Boolean> filter)
            {
                filter.addFilter (context, "tl_assessment_criteria_answer.answer", "Answer");
                return this;
            }
            
            public SearchAll andNotes (QueryFilter<String> filter)
            {
                filter.addFilter (context, "tl_assessment_criteria_answer.notes", "Notes");
                return this;
            }
            
            public SearchAll andAssessmentCriteria (QueryFilter<AssessmentCriteria> filter)
            {
                filter.addFilter (context, "tl_assessment_criteria_answer.assessment_criteria_id", "AssessmentCriteria");
                return this;
            }
            
            public SearchAll andJobApplication (QueryFilter<JobApplication> filter)
            {
                filter.addFilter (context, "tl_assessment_criteria_answer.job_application_id", "JobApplication");
                return this;
            }
            
                public AssessmentCriteriaAnswer[]
             search (ObjectTransaction transaction) throws StorageException
        {
            
            
            BaseBusinessClass[]     results = super.search (transaction, REFERENCE_AssessmentCriteriaAnswer, SEARCH_All, criteria);
            Set<AssessmentCriteriaAnswer>   typedResults = new LinkedHashSet <AssessmentCriteriaAnswer> ();
            for (BaseBusinessClass bbcResult : results)
            {
                AssessmentCriteriaAnswer aResult = (AssessmentCriteriaAnswer)bbcResult;
                
                typedResults.add (aResult);
            }
            
                    return ObjstoreUtils.removeDeleted(transaction, typedResults).toArray (new AssessmentCriteriaAnswer[0]);
                            
        }
    }

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

        public abstract boolean filterCriteriaType(CriteriaType CriteriaType) throws StorageException;
    
        public abstract boolean filterByCriteriaType(CriteriaType CriteriaType) throws StorageException;
    
    public static SearchCriteriaType SearchByCriteriaType () { return new SearchCriteriaType (); }

    public static class SearchCriteriaType extends SearchObject<AssessmentCriteriaAnswer>
    {
        
        public SearchCriteriaType byCriteriaType (CriteriaType CriteriaType)
        {
            by ("CriteriaType", CriteriaType);
            return this;
        }
        
            public SearchCriteriaType andObjectID (QueryFilter<Long> filter)
            {
                filter.addFilter (context, "tl_assessment_criteria_answer.object_id", FIELD_ObjectID);
                return this;
            }

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

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

            
            public SearchCriteriaType andAnswer (QueryFilter<Boolean> filter)
            {
                filter.addFilter (context, "tl_assessment_criteria_answer.answer", "Answer");
                return this;
            }
            
            public SearchCriteriaType andNotes (QueryFilter<String> filter)
            {
                filter.addFilter (context, "tl_assessment_criteria_answer.notes", "Notes");
                return this;
            }
            
            public SearchCriteriaType andAssessmentCriteria (QueryFilter<AssessmentCriteria> filter)
            {
                filter.addFilter (context, "tl_assessment_criteria_answer.assessment_criteria_id", "AssessmentCriteria");
                return this;
            }
            
            public SearchCriteriaType andJobApplication (QueryFilter<JobApplication> filter)
            {
                filter.addFilter (context, "tl_assessment_criteria_answer.job_application_id", "JobApplication");
                return this;
            }
            
                public AssessmentCriteriaAnswer[]
             search (ObjectTransaction transaction) throws StorageException
        {
            CriteriaType CriteriaType = (CriteriaType)criteria.get ("CriteriaType");
                
            
            BaseBusinessClass[]     results = super.search (transaction, REFERENCE_AssessmentCriteriaAnswer, SEARCH_CriteriaType, criteria);
            Set<AssessmentCriteriaAnswer>   typedResults = new LinkedHashSet <AssessmentCriteriaAnswer> ();
            for (BaseBusinessClass bbcResult : results)
            {
                AssessmentCriteriaAnswer aResult = (AssessmentCriteriaAnswer)bbcResult;
                
                    // Check in case in memory objects should be excluded
                    if (!aResult.filterCriteriaType(CriteriaType) || !filterAndsInMemory (aResult))
                    {
                        continue;
                    }
                
                typedResults.add (aResult);
            }
            
            // Check in memory objects for matches
            for (BaseBusinessClass bbcInMemory : transaction.getObjectsToStore ())
            {
                if (bbcInMemory instanceof AssessmentCriteriaAnswer)
                {
                    AssessmentCriteriaAnswer aInMemory = (AssessmentCriteriaAnswer)bbcInMemory;

                    if (!aInMemory.filterCriteriaType(CriteriaType) || !filterAndsInMemory (aInMemory))
                    {
                        continue;
                    }

                    typedResults.add (aInMemory);
                }
            }
            
                    return ObjstoreUtils.removeDeleted(transaction, typedResults).toArray (new AssessmentCriteriaAnswer[0]);
                            
        }

            @Override
            public boolean accept(AssessmentCriteriaAnswer objToAccept)
            {
                return super.accept(objToAccept) && objToAccept.filterByCriteriaType((CriteriaType)criteria.get ("CriteriaType"));
            }
        
    }

        
                public static AssessmentCriteriaAnswer[]
             searchCriteriaType (ObjectTransaction transaction, CriteriaType CriteriaType) throws StorageException
        {
            return SearchByCriteriaType ()
            .byCriteriaType  (CriteriaType)
            .search (transaction);
        }

    public static SearchCriteriaApplication SearchByCriteriaApplication () { return new SearchCriteriaApplication (); }

    public static class SearchCriteriaApplication extends SearchObject<AssessmentCriteriaAnswer>
    {
        
        public SearchCriteriaApplication byAssessmentCriteria (AssessmentCriteria AssessmentCriteria)
        {
            by ("AssessmentCriteria", AssessmentCriteria);
            return this;
        }
        
        public SearchCriteriaApplication byJobApplication (JobApplication JobApplication)
        {
            by ("JobApplication", JobApplication);
            return this;
        }
        
            public SearchCriteriaApplication andObjectID (QueryFilter<Long> filter)
            {
                filter.addFilter (context, "tl_assessment_criteria_answer.object_id", FIELD_ObjectID);
                return this;
            }

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

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

            
            public SearchCriteriaApplication andAnswer (QueryFilter<Boolean> filter)
            {
                filter.addFilter (context, "tl_assessment_criteria_answer.answer", "Answer");
                return this;
            }
            
            public SearchCriteriaApplication andNotes (QueryFilter<String> filter)
            {
                filter.addFilter (context, "tl_assessment_criteria_answer.notes", "Notes");
                return this;
            }
            
            public SearchCriteriaApplication andAssessmentCriteria (QueryFilter<AssessmentCriteria> filter)
            {
                filter.addFilter (context, "tl_assessment_criteria_answer.assessment_criteria_id", "AssessmentCriteria");
                return this;
            }
            
            public SearchCriteriaApplication andJobApplication (QueryFilter<JobApplication> filter)
            {
                filter.addFilter (context, "tl_assessment_criteria_answer.job_application_id", "JobApplication");
                return this;
            }
            
                public AssessmentCriteriaAnswer search (ObjectTransaction transaction) throws StorageException
        {
            
            
            BaseBusinessClass[]     results = super.search (transaction, REFERENCE_AssessmentCriteriaAnswer, SEARCH_CriteriaApplication, criteria);
            Set<AssessmentCriteriaAnswer>   typedResults = new LinkedHashSet <AssessmentCriteriaAnswer> ();
            for (BaseBusinessClass bbcResult : results)
            {
                AssessmentCriteriaAnswer aResult = (AssessmentCriteriaAnswer)bbcResult;
                
                typedResults.add (aResult);
            }
            
                    return (AssessmentCriteriaAnswer)singletonResult(ObjstoreUtils.removeDeleted(transaction, typedResults).toArray(new BaseBusinessClass[0]), "AssessmentCriteriaAnswer", "");
                            
        }
    }

        
                public static AssessmentCriteriaAnswer searchCriteriaApplication (ObjectTransaction transaction, AssessmentCriteria AssessmentCriteria, JobApplication JobApplication) throws StorageException
        {
            return SearchByCriteriaApplication ()
            .byAssessmentCriteria  (AssessmentCriteria)
            .byJobApplication  (JobApplication)
            .search (transaction);
        }



    public Object getAttribute (String attribName)
    {
        if (false)
        {
            throw new RuntimeException ("Game over man!!");
        }
        else if (attribName.equals (FIELD_Answer))
        {
            return HELPER_Answer.toObject (getAnswer ());
        }
        else if (attribName.equals (FIELD_Notes))
        {
            return HELPER_Notes.toObject (getNotes ());
        }
        else
        {
            return super.getAttribute (attribName);
        }
    }


    public AttributeHelper getAttributeHelper (String attribName)
    {
        if (false)
        {
            throw new RuntimeException ("Game over man!!");
        }
        else if (attribName.equals (FIELD_Answer))
        {
            return HELPER_Answer;
        }
        else if (attribName.equals (FIELD_Notes))
        {
            return HELPER_Notes;
        }
        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_Answer))
        {
            setAnswer ((Boolean)(HELPER_Answer.fromObject (_Answer, attribValue)));            
        }
        else if (attribName.equals (FIELD_Notes))
        {
            setNotes ((String)(HELPER_Notes.fromObject (_Notes, 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_Answer))
        {
            return getWriteability_Answer ();
        }
        else if (fieldName.equals (FIELD_Notes))
        {
            return getWriteability_Notes ();
        }
        else if (fieldName.equals (SINGLEREFERENCE_AssessmentCriteria))
        {
            return getWriteability_AssessmentCriteria ();
        }
        else if (fieldName.equals (SINGLEREFERENCE_JobApplication))
        {
            return getWriteability_JobApplication ();
        }
        else
        {
            return super.getWriteable (fieldName);
        }
    }


    public void putUnwriteable (Set<String> fields)
    {
        
            if (getWriteability_Answer () != FieldWriteability.TRUE)
            {
                fields.add (FIELD_Answer);
            }
        
            if (getWriteability_Notes () != FieldWriteability.TRUE)
            {
                fields.add (FIELD_Notes);
            }
        

        super.putUnwriteable (fields);
    }

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

        
        result.add(HELPER_Answer.getAttribObject (getClass (), _Answer, true, FIELD_Answer));
        result.add(HELPER_Notes.getAttribObject (getClass (), _Notes, false, FIELD_Notes));

        return result;
    }


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


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

    /**
     * Get the attribute Answer
     */
    public Boolean getAnswer (AssessmentCriteriaAnswer obj, Boolean original)
    {
        return original;
    }

    /**
     * Change the value set for attribute Answer.
     * May modify the field beforehand
     * Occurs before validation.
     */
    public Boolean setAnswer (AssessmentCriteriaAnswer obj, Boolean newAnswer) throws FieldException
    {
        return newAnswer;
    }

    /**
     * Get the attribute Notes
     */
    public String getNotes (AssessmentCriteriaAnswer obj, String original)
    {
        return original;
    }

    /**
     * Change the value set for attribute Notes.
     * May modify the field beforehand
     * Occurs before validation.
     */
    public String setNotes (AssessmentCriteriaAnswer obj, String newNotes) throws FieldException
    {
        return newNotes;
    }

    }

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

        public AssessmentCriteriaAnswerPipeLineFactory (Collection<From> seed)
        {
            super(seed);
        }
        
        
        public PipeLine<From, ? extends Object> to(String name)
        {
            if (name.equals ("Answer"))
            {
                return toAnswer ();
            }                
            if (name.equals ("Notes"))
            {
                return toNotes ();
            }                
            if (name.equals ("AssessmentCriteria"))
            {
                return toAssessmentCriteria ();
            }                
            if (name.equals ("JobApplication"))
            {
                return toJobApplication ();
            }                
            
            
            return super.to(name);
        }
        
        
        public PipeLine<From, Boolean> toAnswer () { return pipe(new ORMAttributePipe<Me, Boolean>(FIELD_Answer));  }
        
        public PipeLine<From, String> toNotes () { return pipe(new ORMAttributePipe<Me, String>(FIELD_Notes));  }
        public AssessmentCriteria.AssessmentCriteriaPipeLineFactory<From, AssessmentCriteria> toAssessmentCriteria () { return toAssessmentCriteria (Filter.ALL); }

        public AssessmentCriteria.AssessmentCriteriaPipeLineFactory<From, AssessmentCriteria> toAssessmentCriteria (Filter<AssessmentCriteria> filter) 
        { 
            return AssessmentCriteria.REFERENCE_AssessmentCriteria.new AssessmentCriteriaPipeLineFactory<From, AssessmentCriteria> (this, new ORMSingleAssocPipe<Me, AssessmentCriteria>(SINGLEREFERENCE_AssessmentCriteria, filter)); 
        }
        public JobApplication.JobApplicationPipeLineFactory<From, JobApplication> toJobApplication () { return toJobApplication (Filter.ALL); }

        public JobApplication.JobApplicationPipeLineFactory<From, JobApplication> toJobApplication (Filter<JobApplication> filter) 
        { 
            return JobApplication.REFERENCE_JobApplication.new JobApplicationPipeLineFactory<From, JobApplication> (this, new ORMSingleAssocPipe<Me, JobApplication>(SINGLEREFERENCE_JobApplication, filter)); 
        }
        
    }
    
    public boolean isTransientAttrib(String attribName)
    {
        

        return super.isTransientAttrib(attribName);
    }

    public boolean isTransientSingleReference(String assocName)
    {
        

        return super.isTransientSingleReference(assocName);
    }
}

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

    public void assertValid ()
    {
    }


    public AssessmentCriteria getAssessmentCriteria () throws StorageException
    {
        return (AssessmentCriteria)(AssessmentCriteria.DUMMY_AssessmentCriteria);
    }


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

    public JobApplication getJobApplication () throws StorageException
    {
        return (JobApplication)(JobApplication.DUMMY_JobApplication);
    }


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

}

    
