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

    // Reference instance for the object
    public static final JobApplication DUMMY_JobApplication = new DummyJobApplication ();

    // Static constants corresponding to field names
    
    public static final String FIELD_CV = "CV";
    public static final String FIELD_ApplicationStatus = "ApplicationStatus";
    public static final String FIELD_SubmittedDate = "SubmittedDate";
    public static final String FIELD_AppProcessOption = "AppProcessOption";
    public static final String FIELD_OverallSuitability = "OverallSuitability";
    public static final String SINGLEREFERENCE_Candidate = "Candidate";
    public static final String BACKREF_Candidate = "";
    public static final String SINGLEREFERENCE_Job = "Job";
    public static final String BACKREF_Job = "";
    public static final String MULTIPLEREFERENCE_AssessmentCriteriaAnswers = "AssessmentCriteriaAnswers";
    public static final String BACKREF_AssessmentCriteriaAnswers = "";

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

    // Static constants corresponding to attribute helpers
    private static final BLOBAttributeHelper HELPER_CV = BLOBAttributeHelper.INSTANCE;
    private static final EnumeratedAttributeHelper<JobApplication, ApplicationStatus> HELPER_ApplicationStatus =  new EnumeratedAttributeHelper<JobApplication, ApplicationStatus> (ApplicationStatus.FACTORY_ApplicationStatus);
    private static final DefaultAttributeHelper<JobApplication> HELPER_SubmittedDate = DefaultAttributeHelper.INSTANCE;
    private static final EnumeratedAttributeHelper<JobApplication, AppProcessOption> HELPER_AppProcessOption =  new EnumeratedAttributeHelper<JobApplication, AppProcessOption> (AppProcessOption.FACTORY_AppProcessOption);
    private static final DefaultAttributeHelper<JobApplication> HELPER_OverallSuitability = DefaultAttributeHelper.INSTANCE;
    

    // Private attributes corresponding to business object data
    private BinaryContent _CV;
    private ApplicationStatus _ApplicationStatus;
    private Date _SubmittedDate;
    private AppProcessOption _AppProcessOption;
    private Integer _OverallSuitability;
    

    // Private attributes corresponding to single references
    private SingleAssociation<JobApplication, Candidate> _Candidate;
    private SingleAssociation<JobApplication, Job> _Job;
    

    // Private attributes corresponding to multiple references
    private MultipleAssociation<JobApplication, AssessmentCriteriaAnswer> _AssessmentCriteriaAnswers;
    

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

    // Arrays of validators for each attribute
    private static final AttributeValidator[] FIELD_AppProcessOption_Validators;
    private static final AttributeValidator[] FIELD_OverallSuitability_Validators;
    private static final AttributeValidator[] FIELD_CV_Validators;
    private static final AttributeValidator[] FIELD_ApplicationStatus_Validators;
    private static final AttributeValidator[] FIELD_SubmittedDate_Validators;
    

    // Arrays of behaviour decorators
    private static final JobApplicationBehaviourDecorator[] JobApplication_BehaviourDecorators;
    
    static
    {
        try
        {
            
            String tmp_AssessmentCriteriaAnswers = AssessmentCriteriaAnswer.BACKREF_JobApplication;
            String tmp_Candidate = Candidate.BACKREF_JobApplications;
            String tmp_Job = Job.BACKREF_JobApplications;
            
            Map  validatorMapping = ((Map)ConfigMgr.getConfigObject ("CONFIG.ORMVALIDATOR", "ValidatorMapping"));

            setupAssocMetaData_AssessmentCriteriaAnswers();
            setupAssocMetaData_Candidate();
            setupAssocMetaData_Job();
            FIELD_AppProcessOption_Validators = (AttributeValidator[])setupAttribMetaData_AppProcessOption(validatorMapping).toArray (new AttributeValidator[0]);
            FIELD_OverallSuitability_Validators = (AttributeValidator[])setupAttribMetaData_OverallSuitability(validatorMapping).toArray (new AttributeValidator[0]);
            FIELD_CV_Validators = (AttributeValidator[])setupAttribMetaData_CV(validatorMapping).toArray (new AttributeValidator[0]);
            FIELD_ApplicationStatus_Validators = (AttributeValidator[])setupAttribMetaData_ApplicationStatus(validatorMapping).toArray (new AttributeValidator[0]);
            FIELD_SubmittedDate_Validators = (AttributeValidator[])setupAttribMetaData_SubmittedDate(validatorMapping).toArray (new AttributeValidator[0]);
            

            REFERENCE_JobApplication.initialiseReference ();
            DUMMY_JobApplication.initialiseReference ();
            JobApplication_BehaviourDecorators = BaseBusinessClass.getBBCBehaviours(JobApplication.class).toArray(new JobApplicationBehaviourDecorator[0]);
        }
        catch (RuntimeException e)
        {
            LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR1, e, "Error initialising");
            throw e;
        }
    }

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

        metaInfo.put ("backreferenceName", "JobApplication");
        metaInfo.put ("name", "AssessmentCriteriaAnswers");
        metaInfo.put ("type", "AssessmentCriteriaAnswer");
        
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for JobApplication.AssessmentCriteriaAnswers:", metaInfo);
        ATTRIBUTES_METADATA_JobApplication.put (MULTIPLEREFERENCE_AssessmentCriteriaAnswers, Collections.unmodifiableMap (metaInfo));
    }
    
    
    // Meta Info setup
    private static void setupAssocMetaData_Candidate()
    {
        Map metaInfo = new HashMap ();

        metaInfo.put ("backreferenceName", "JobApplications");
        metaInfo.put ("dbcol", "candidate_id");
        metaInfo.put ("mandatory", "true");
        metaInfo.put ("name", "Candidate");
        metaInfo.put ("type", "Candidate");
        
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for JobApplication.Candidate:", metaInfo);
        ATTRIBUTES_METADATA_JobApplication.put (SINGLEREFERENCE_Candidate, Collections.unmodifiableMap (metaInfo));
    }
    
    
    // Meta Info setup
    private static void setupAssocMetaData_Job()
    {
        Map metaInfo = new HashMap ();

        metaInfo.put ("backreferenceName", "JobApplications");
        metaInfo.put ("dbcol", "job_id");
        metaInfo.put ("mandatory", "true");
        metaInfo.put ("name", "Job");
        metaInfo.put ("type", "Job");
        
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for JobApplication.Job:", metaInfo);
        ATTRIBUTES_METADATA_JobApplication.put (SINGLEREFERENCE_Job, Collections.unmodifiableMap (metaInfo));
    }
    
    
    // Meta Info setup
    private static List setupAttribMetaData_AppProcessOption(Map validatorMapping)
    {
        Map  metaInfo   = new HashMap ();

        metaInfo.put ("attribHelper", "EnumeratedAttributeHelper");
        metaInfo.put ("name", "AppProcessOption");
        metaInfo.put ("type", "AppProcessOption");
        
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for JobApplication.AppProcessOption:", metaInfo);
        ATTRIBUTES_METADATA_JobApplication.put (FIELD_AppProcessOption, Collections.unmodifiableMap (metaInfo));

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

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

        metaInfo.put ("name", "OverallSuitability");
        metaInfo.put ("type", "Integer");
        
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for JobApplication.OverallSuitability:", metaInfo);
        ATTRIBUTES_METADATA_JobApplication.put (FIELD_OverallSuitability, Collections.unmodifiableMap (metaInfo));

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

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

        metaInfo.put ("attribHelper", "BLOBAttributeHelper");
        metaInfo.put ("attribHelperInstance", "BLOBAttributeHelper.INSTANCE");
        metaInfo.put ("binaryHandler", "loggedin");
        metaInfo.put ("dbcol", "cv");
        metaInfo.put ("mandatory", "false");
        metaInfo.put ("name", "CV");
        metaInfo.put ("type", "BinaryContent");
        
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for JobApplication.CV:", metaInfo);
        ATTRIBUTES_METADATA_JobApplication.put (FIELD_CV, Collections.unmodifiableMap (metaInfo));

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

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

        metaInfo.put ("attribHelper", "EnumeratedAttributeHelper");
        metaInfo.put ("dbcol", "application_status");
        metaInfo.put ("defaultValue", "ApplicationStatus.DRAFT");
        metaInfo.put ("mandatory", "true");
        metaInfo.put ("name", "ApplicationStatus");
        metaInfo.put ("type", "ApplicationStatus");
        
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for JobApplication.ApplicationStatus:", metaInfo);
        ATTRIBUTES_METADATA_JobApplication.put (FIELD_ApplicationStatus, Collections.unmodifiableMap (metaInfo));

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

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

        metaInfo.put ("dbcol", "submitted_date");
        metaInfo.put ("name", "SubmittedDate");
        metaInfo.put ("type", "Date");
        
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for JobApplication.SubmittedDate:", metaInfo);
        ATTRIBUTES_METADATA_JobApplication.put (FIELD_SubmittedDate, Collections.unmodifiableMap (metaInfo));

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

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


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


    


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

        
        _CV = (BinaryContent)(HELPER_CV.initialise (_CV));
        _ApplicationStatus = (ApplicationStatus)(ApplicationStatus.DRAFT);
        _SubmittedDate = (Date)(HELPER_SubmittedDate.initialise (_SubmittedDate));
        _AppProcessOption = (AppProcessOption)(HELPER_AppProcessOption.initialise (_AppProcessOption));
        _OverallSuitability = (Integer)(HELPER_OverallSuitability.initialise (_OverallSuitability));
    }


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

        _Candidate = new SingleAssociation<JobApplication, Candidate> (this, SINGLEREFERENCE_Candidate, Candidate.MULTIPLEREFERENCE_JobApplications, Candidate.REFERENCE_Candidate, "tl_job_application");
        _Job = new SingleAssociation<JobApplication, Job> (this, SINGLEREFERENCE_Job, Job.MULTIPLEREFERENCE_JobApplications, Job.REFERENCE_Job, "tl_job_application");
        _AssessmentCriteriaAnswers = new MultipleAssociation<JobApplication, AssessmentCriteriaAnswer> (this, MULTIPLEREFERENCE_AssessmentCriteriaAnswers, AssessmentCriteriaAnswer.SINGLEREFERENCE_JobApplication, AssessmentCriteriaAnswer.REFERENCE_AssessmentCriteriaAnswer);
        
    }


    // Initialise the associations
    protected BaseBusinessClass initialiseReference ()
    {
        super.initialiseReference ();
        
        _Candidate = new SingleAssociation<JobApplication, Candidate> (this, SINGLEREFERENCE_Candidate, Candidate.MULTIPLEREFERENCE_JobApplications, Candidate.REFERENCE_Candidate, "tl_job_application");
        _Job = new SingleAssociation<JobApplication, Job> (this, SINGLEREFERENCE_Job, Job.MULTIPLEREFERENCE_JobApplications, Job.REFERENCE_Job, "tl_job_application");
        _AssessmentCriteriaAnswers = new MultipleAssociation<JobApplication, AssessmentCriteriaAnswer> (this, MULTIPLEREFERENCE_AssessmentCriteriaAnswers, AssessmentCriteriaAnswer.SINGLEREFERENCE_JobApplication, AssessmentCriteriaAnswer.REFERENCE_AssessmentCriteriaAnswer);
        
        
        return this;
    }

    

    /**
     * Get the attribute CV
     */
    public BinaryContent getCV ()
    {
        assertValid();
        BinaryContent valToReturn = _CV;

            for (JobApplicationBehaviourDecorator bhd : JobApplication_BehaviourDecorators)
            {
                valToReturn = bhd.getCV ((JobApplication)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 preCVChange (BinaryContent newCV) 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 postCVChange () throws FieldException
    {
    }

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

    /**
     * Set the attribute CV.  Checks to ensure a new value
     * has been supplied.  If so, marks the field as altered and sets the attribute.
     */
    public void setCV (BinaryContent newCV) throws FieldException
    {
        boolean oldAndNewIdentical = HELPER_CV.compare (_CV, newCV);
        
        try
        {
            for (JobApplicationBehaviourDecorator bhd : JobApplication_BehaviourDecorators)
            {
                newCV = bhd.setCV ((JobApplication)this, newCV);
                oldAndNewIdentical = HELPER_CV.compare (_CV, newCV);
            }

            

            if (FIELD_CV_Validators.length > 0)
            {
                Object newCVObj = HELPER_CV.toObject (newCV);

                if (newCVObj != null)
                {
                    int     loopMax = FIELD_CV_Validators.length;
                    Map     metadata = (Map)ATTRIBUTES_METADATA_JobApplication.get (FIELD_CV);

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

        if (!oldAndNewIdentical)
        {
            assertValid();
            Debug.assertion (getWriteability_CV () != FieldWriteability.FALSE, "Field  CV is not writeable");
            preCVChange (newCV);
            markFieldChange (FIELD_CV);
            _CV = newCV;            
            postFieldChange (FIELD_CV);
            postCVChange ();
        }
    }

    /**
     * Get the attribute ApplicationStatus
     */
    public ApplicationStatus getApplicationStatus ()
    {
        assertValid();
        ApplicationStatus valToReturn = _ApplicationStatus;

            for (JobApplicationBehaviourDecorator bhd : JobApplication_BehaviourDecorators)
            {
                valToReturn = bhd.getApplicationStatus ((JobApplication)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 preApplicationStatusChange (ApplicationStatus newApplicationStatus) 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 postApplicationStatusChange () throws FieldException
    {
    }

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

    /**
     * Set the attribute ApplicationStatus.  Checks to ensure a new value
     * has been supplied.  If so, marks the field as altered and sets the attribute.
     */
    public void setApplicationStatus (ApplicationStatus newApplicationStatus) throws FieldException
    {
        boolean oldAndNewIdentical = HELPER_ApplicationStatus.compare (_ApplicationStatus, newApplicationStatus);
        
        try
        {
            for (JobApplicationBehaviourDecorator bhd : JobApplication_BehaviourDecorators)
            {
                newApplicationStatus = bhd.setApplicationStatus ((JobApplication)this, newApplicationStatus);
                oldAndNewIdentical = HELPER_ApplicationStatus.compare (_ApplicationStatus, newApplicationStatus);
            }

            BusinessObjectParser.assertFieldCondition (newApplicationStatus != null, this, FIELD_ApplicationStatus, "mandatory");
            

            if (FIELD_ApplicationStatus_Validators.length > 0)
            {
                Object newApplicationStatusObj = HELPER_ApplicationStatus.toObject (newApplicationStatus);

                if (newApplicationStatusObj != null)
                {
                    int     loopMax = FIELD_ApplicationStatus_Validators.length;
                    Map     metadata = (Map)ATTRIBUTES_METADATA_JobApplication.get (FIELD_ApplicationStatus);

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

        if (!oldAndNewIdentical)
        {
            assertValid();
            Debug.assertion (getWriteability_ApplicationStatus () != FieldWriteability.FALSE, "Field  ApplicationStatus is not writeable");
            preApplicationStatusChange (newApplicationStatus);
            markFieldChange (FIELD_ApplicationStatus);
            _ApplicationStatus = newApplicationStatus;            
            postFieldChange (FIELD_ApplicationStatus);
            postApplicationStatusChange ();
        }
    }

    /**
     * Get the attribute SubmittedDate
     */
    public Date getSubmittedDate ()
    {
        assertValid();
        Date valToReturn = _SubmittedDate;

            for (JobApplicationBehaviourDecorator bhd : JobApplication_BehaviourDecorators)
            {
                valToReturn = bhd.getSubmittedDate ((JobApplication)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 preSubmittedDateChange (Date newSubmittedDate) 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 postSubmittedDateChange () throws FieldException
    {
    }

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

    /**
     * Set the attribute SubmittedDate.  Checks to ensure a new value
     * has been supplied.  If so, marks the field as altered and sets the attribute.
     */
    public void setSubmittedDate (Date newSubmittedDate) throws FieldException
    {
        boolean oldAndNewIdentical = HELPER_SubmittedDate.compare (_SubmittedDate, newSubmittedDate);
        
        try
        {
            for (JobApplicationBehaviourDecorator bhd : JobApplication_BehaviourDecorators)
            {
                newSubmittedDate = bhd.setSubmittedDate ((JobApplication)this, newSubmittedDate);
                oldAndNewIdentical = HELPER_SubmittedDate.compare (_SubmittedDate, newSubmittedDate);
            }

            

            if (FIELD_SubmittedDate_Validators.length > 0)
            {
                Object newSubmittedDateObj = HELPER_SubmittedDate.toObject (newSubmittedDate);

                if (newSubmittedDateObj != null)
                {
                    int     loopMax = FIELD_SubmittedDate_Validators.length;
                    Map     metadata = (Map)ATTRIBUTES_METADATA_JobApplication.get (FIELD_SubmittedDate);

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

        if (!oldAndNewIdentical)
        {
            assertValid();
            Debug.assertion (getWriteability_SubmittedDate () != FieldWriteability.FALSE, "Field  SubmittedDate is not writeable");
            preSubmittedDateChange (newSubmittedDate);
            markFieldChange (FIELD_SubmittedDate);
            _SubmittedDate = newSubmittedDate;            
            postFieldChange (FIELD_SubmittedDate);
            postSubmittedDateChange ();
        }
    }

    /**
     * Get the attribute AppProcessOption
     */
    public AppProcessOption getAppProcessOption ()
    {
        assertValid();
        AppProcessOption valToReturn = _AppProcessOption;

            for (JobApplicationBehaviourDecorator bhd : JobApplication_BehaviourDecorators)
            {
                valToReturn = bhd.getAppProcessOption ((JobApplication)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 preAppProcessOptionChange (AppProcessOption newAppProcessOption) 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 postAppProcessOptionChange () throws FieldException
    {
    }

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

    /**
     * Set the attribute AppProcessOption.  Checks to ensure a new value
     * has been supplied.  If so, marks the field as altered and sets the attribute.
     */
    public void setAppProcessOption (AppProcessOption newAppProcessOption) throws FieldException
    {
        boolean oldAndNewIdentical = HELPER_AppProcessOption.compare (_AppProcessOption, newAppProcessOption);
        
        try
        {
            for (JobApplicationBehaviourDecorator bhd : JobApplication_BehaviourDecorators)
            {
                newAppProcessOption = bhd.setAppProcessOption ((JobApplication)this, newAppProcessOption);
                oldAndNewIdentical = HELPER_AppProcessOption.compare (_AppProcessOption, newAppProcessOption);
            }

            

            if (FIELD_AppProcessOption_Validators.length > 0)
            {
                Object newAppProcessOptionObj = HELPER_AppProcessOption.toObject (newAppProcessOption);

                if (newAppProcessOptionObj != null)
                {
                    int     loopMax = FIELD_AppProcessOption_Validators.length;
                    Map     metadata = (Map)ATTRIBUTES_METADATA_JobApplication.get (FIELD_AppProcessOption);

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

        if (!oldAndNewIdentical)
        {
            assertValid();
            Debug.assertion (getWriteability_AppProcessOption () != FieldWriteability.FALSE, "Field  AppProcessOption is not writeable");
            preAppProcessOptionChange (newAppProcessOption);
            markFieldChange (FIELD_AppProcessOption);
            _AppProcessOption = newAppProcessOption;            
            postFieldChange (FIELD_AppProcessOption);
            postAppProcessOptionChange ();
        }
    }

    /**
     * Get the attribute OverallSuitability
     */
    public Integer getOverallSuitability ()
    {
        assertValid();
        Integer valToReturn = _OverallSuitability;

            for (JobApplicationBehaviourDecorator bhd : JobApplication_BehaviourDecorators)
            {
                valToReturn = bhd.getOverallSuitability ((JobApplication)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 preOverallSuitabilityChange (Integer newOverallSuitability) 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 postOverallSuitabilityChange () throws FieldException
    {
    }

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

    /**
     * Set the attribute OverallSuitability.  Checks to ensure a new value
     * has been supplied.  If so, marks the field as altered and sets the attribute.
     */
    public void setOverallSuitability (Integer newOverallSuitability) throws FieldException
    {
        boolean oldAndNewIdentical = HELPER_OverallSuitability.compare (_OverallSuitability, newOverallSuitability);
        
        try
        {
            for (JobApplicationBehaviourDecorator bhd : JobApplication_BehaviourDecorators)
            {
                newOverallSuitability = bhd.setOverallSuitability ((JobApplication)this, newOverallSuitability);
                oldAndNewIdentical = HELPER_OverallSuitability.compare (_OverallSuitability, newOverallSuitability);
            }

            

            if (FIELD_OverallSuitability_Validators.length > 0)
            {
                Object newOverallSuitabilityObj = HELPER_OverallSuitability.toObject (newOverallSuitability);

                if (newOverallSuitabilityObj != null)
                {
                    int     loopMax = FIELD_OverallSuitability_Validators.length;
                    Map     metadata = (Map)ATTRIBUTES_METADATA_JobApplication.get (FIELD_OverallSuitability);

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

        if (!oldAndNewIdentical)
        {
            assertValid();
            Debug.assertion (getWriteability_OverallSuitability () != FieldWriteability.FALSE, "Field  OverallSuitability is not writeable");
            preOverallSuitabilityChange (newOverallSuitability);
            markFieldChange (FIELD_OverallSuitability);
            _OverallSuitability = newOverallSuitability;            
            postFieldChange (FIELD_OverallSuitability);
            postOverallSuitabilityChange ();
        }
    }



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

        
        result.add("Candidate");
        
        result.add("Job");
        

        return result;
    }
    
    
    public BaseBusinessClass getSingleAssocReferenceInstance (String assocName)
    {
        if (assocName == null)
        {
            throw new RuntimeException ("Game over == null!");
        }
        else if (assocName.equals (SINGLEREFERENCE_Candidate))
        {
            return _Candidate.getReferencedType ();
        }else if (assocName.equals (SINGLEREFERENCE_Job))
        {
            return _Job.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_Candidate))
        {
            return Candidate.MULTIPLEREFERENCE_JobApplications ;
        }else if (assocName.equals (SINGLEREFERENCE_Job))
        {
            return Job.MULTIPLEREFERENCE_JobApplications ;
        }
        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_Candidate))
        {
            return getCandidate ();
        }else if (assocName.equals (SINGLEREFERENCE_Job))
        {
            return getJob ();
        }
        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_Candidate))
        {
            return getCandidate (getType);
        }else if (assocName.equals (SINGLEREFERENCE_Job))
        {
            return getJob (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_Candidate))
        {
            return getCandidateID ();
        }else if (assocName.equals (SINGLEREFERENCE_Job))
        {
            return getJobID ();
        }
        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_Candidate))
        {
            setCandidate ((Candidate)(newValue));
        }else if (assocName.equals (SINGLEREFERENCE_Job))
        {
            setJob ((Job)(newValue));
        }
        else
        {
            super.setSingleAssoc (assocName, newValue);
        }
    }



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


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


    /**
     * Get the object id for the referenced object.  Does not force a DB access.
     */
    public Long getCandidateID ()
    {
        assertValid();
        
        if (_Candidate == null)
        {
            return null;
        }
        else
        {
            return _Candidate.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 preCandidateChange (Candidate newCandidate) 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 postCandidateChange () throws FieldException
    {
    }



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

        if (_Candidate.wouldReferencedChange (newCandidate))
        {
            assertValid();
            Debug.assertion (getWriteability_Candidate () != FieldWriteability.FALSE, "Assoc Candidate is not writeable");
            preCandidateChange (newCandidate);
            Candidate oldCandidate = getCandidate ();

                    if (oldCandidate != null)
                    {
                        // This is to stop validation from triggering when we are removed
                        _Candidate.set (null);
                        oldCandidate.removeFromJobApplications ((JobApplication)(this));
                    }

                    _Candidate.set (newCandidate);

                    if (newCandidate != null)
                    {
                        newCandidate.addToJobApplications ((JobApplication)(this));
                    }
                
            postCandidateChange ();
        }
    }

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


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


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

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


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



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

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

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

                    _Job.set (newJob);

                    if (newJob != null)
                    {
                        newJob.addToJobApplications ((JobApplication)(this));
                    }
                
            postJobChange ();
        }
    }

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

        
        result.add("AssessmentCriteriaAnswers");
        

        return result;
    }


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

        return super.getMultiAssocReferenceInstance(attribName);
    }


    public String getMultiAssocBackReference(String attribName)
    {
        
        if (MULTIPLEREFERENCE_AssessmentCriteriaAnswers.equals(attribName))
        {
            return AssessmentCriteriaAnswer.SINGLEREFERENCE_JobApplication ;
        }
        

        return super.getMultiAssocBackReference(attribName);
    }


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

        return super.getMultiAssocCount(attribName);
    }


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

        return super.getMultiAssocAt(attribName, index);
    }


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

            return;
        }
        

        super.addToMultiAssoc(attribName, newElement);
    }

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

            return;
        }
        

        super.removeFromMultiAssoc(attribName, oldElement);
    }


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

        super.__loadMultiAssoc(attribName, elements);
    }


    protected boolean __isMultiAssocLoaded (String attribName)
    {
        
        if (MULTIPLEREFERENCE_AssessmentCriteriaAnswers.equals(attribName))
        {
            return _AssessmentCriteriaAnswers.isLoaded ();
        }
        

        return super.__isMultiAssocLoaded(attribName);
    }

    

    public FieldWriteability getWriteability_AssessmentCriteriaAnswers ()
    {
        return getFieldWritabilityUtil (FieldWriteability.TRUE);
    }
    
    
    public int getAssessmentCriteriaAnswersCount () throws StorageException
    {
        assertValid();
        return _AssessmentCriteriaAnswers.getReferencedObjectsCount ();
    }


    public void addToAssessmentCriteriaAnswers (AssessmentCriteriaAnswer newElement) throws StorageException
    {
        if (_AssessmentCriteriaAnswers.wouldAddChange (newElement))
        {
            assertValid();
            Debug.assertion (getWriteability_AssessmentCriteriaAnswers () != FieldWriteability.FALSE, "MultiAssoc AssessmentCriteriaAnswers is not writeable (add)");
            _AssessmentCriteriaAnswers.appendElement (newElement);

            try
            {
                if (newElement.getJobApplication () != this)
                {
                    newElement.setJobApplication ((JobApplication)(this));
                }
            }
            catch (Exception e)
            {
                throw NestedException.wrap(e);
            }
        }
    }


    public void removeFromAssessmentCriteriaAnswers (AssessmentCriteriaAnswer elementToRemove) throws StorageException
    {
        if (_AssessmentCriteriaAnswers.wouldRemoveChange (elementToRemove))
        {
            assertValid();
            Debug.assertion (getWriteability_AssessmentCriteriaAnswers () != FieldWriteability.FALSE, "MultiAssoc AssessmentCriteriaAnswers is not writeable (remove)");
            _AssessmentCriteriaAnswers.removeElement (elementToRemove);
            try
            {
                if (elementToRemove.getJobApplication () != null)
                {
                    elementToRemove.setJobApplication (null);
                }
            }
            catch (Exception e)
            {
                throw NestedException.wrap(e);
            }
        }
    }


    public AssessmentCriteriaAnswer getAssessmentCriteriaAnswersAt (int index) throws StorageException
    {
        return (AssessmentCriteriaAnswer)(_AssessmentCriteriaAnswers.getElementAt (index));
    }


    public SortedSet<AssessmentCriteriaAnswer> getAssessmentCriteriaAnswersSet () throws StorageException
    {
        return _AssessmentCriteriaAnswers.getSet ();
    }



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

                if (referenced != null)
                {
                    // Stop the callback
                    LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Setting backreference to null JobApplications from ", getObjectID (), " to ", referenced.getObjectID ());
                    _Candidate.set (null);
                    referenced.removeFromJobApplications ((JobApplication)this);
                }
            }
        
            // Ensure we are removed from any loaded multi-associations that aren't mandatory
            if (_Job.isLoaded () || getTransaction ().isObjectLoaded (_Job.getReferencedType (), getJobID ()))
            {
                Job  referenced = getJob ();

                if (referenced != null)
                {
                    // Stop the callback
                    LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Setting backreference to null JobApplications from ", getObjectID (), " to ", referenced.getObjectID ());
                    _Job.set (null);
                    referenced.removeFromJobApplications ((JobApplication)this);
                }
            }
        
            for(AssessmentCriteriaAnswer referenced : CollectionUtils.reverse(getAssessmentCriteriaAnswersSet()))
            { 
                LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Setting backreference to null JobApplication from ", getObjectID (), " to ", referenced.getObjectID ());
                referenced.setJobApplication(null);
            }

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

        super.onDelete ();
    }


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


    public JobApplication referenceInstance ()
    {
        return REFERENCE_JobApplication;
    }


    public JobApplication getInTransaction (ObjectTransaction t) throws StorageException
    {
        return getJobApplicationByID (t, getObjectID());
    }
    
    
    public BaseBusinessClass dummyInstance ()
    {
        return DUMMY_JobApplication;
    }


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





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

        tl_job_applicationPSet.setAttrib (FIELD_ObjectID, myID);
        tl_job_applicationPSet.setAttrib (FIELD_CV, HELPER_CV.toObject (_CV)); //
        tl_job_applicationPSet.setAttrib (FIELD_ApplicationStatus, HELPER_ApplicationStatus.toObject (_ApplicationStatus)); //
        tl_job_applicationPSet.setAttrib (FIELD_SubmittedDate, HELPER_SubmittedDate.toObject (_SubmittedDate)); //
        _Candidate.getPersistentSets (allSets);
        _Job.getPersistentSets (allSets);
        
    }


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

        
        PersistentSet   tl_job_applicationPSet = allSets.getPersistentSet (objectID, "tl_job_application");

        _CV = (BinaryContent)(HELPER_CV.fromObject (_CV, tl_job_applicationPSet.getAttrib (FIELD_CV))); //
        _ApplicationStatus = (ApplicationStatus)(HELPER_ApplicationStatus.fromObject (_ApplicationStatus, tl_job_applicationPSet.getAttrib (FIELD_ApplicationStatus))); //
        _SubmittedDate = (Date)(HELPER_SubmittedDate.fromObject (_SubmittedDate, tl_job_applicationPSet.getAttrib (FIELD_SubmittedDate))); //
        _Candidate.setFromPersistentSets (objectID, allSets);
        _Job.setFromPersistentSets (objectID, allSets);
        
    }





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

        if (other instanceof JobApplication)
        {
            JobApplication otherJobApplication = (JobApplication)other;
            
            try
            {
                setCV (otherJobApplication.getCV ());
            }
            catch (FieldException ex)
            {
                e.addException (ex);
            }
            
            try
            {
                setApplicationStatus (otherJobApplication.getApplicationStatus ());
            }
            catch (FieldException ex)
            {
                e.addException (ex);
            }
            
            try
            {
                setSubmittedDate (otherJobApplication.getSubmittedDate ());
            }
            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 BaseJobApplication)
        {
            BaseJobApplication sourceJobApplication = (BaseJobApplication)(source);

            _CV = sourceJobApplication._CV;
            _ApplicationStatus = sourceJobApplication._ApplicationStatus;
            _SubmittedDate = sourceJobApplication._SubmittedDate;
            _AppProcessOption = sourceJobApplication._AppProcessOption;
            _OverallSuitability = sourceJobApplication._OverallSuitability;
            
        }
    }


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

            _Candidate.copyFrom (sourceJobApplication._Candidate, linkToGhosts);
            _Job.copyFrom (sourceJobApplication._Job, 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 BaseJobApplication)
        {
            BaseJobApplication sourceJobApplication = (BaseJobApplication)(source);

            _AssessmentCriteriaAnswers.copyFrom (sourceJobApplication._AssessmentCriteriaAnswers, linkToGhosts);
            
        }
    }


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

        
        context.check (getCandidateID() != null, this, SINGLEREFERENCE_Candidate, "mandatory");
        
        context.check (getJobID() != null, this, SINGLEREFERENCE_Job, "mandatory");
        
    }


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

        _CV = (BinaryContent)(HELPER_CV.readExternal (_CV, vals.get(FIELD_CV))); //
        _ApplicationStatus = (ApplicationStatus)(HELPER_ApplicationStatus.readExternal (_ApplicationStatus, vals.get(FIELD_ApplicationStatus))); //
        _SubmittedDate = (Date)(HELPER_SubmittedDate.readExternal (_SubmittedDate, vals.get(FIELD_SubmittedDate))); //
        _AppProcessOption = (AppProcessOption)(HELPER_AppProcessOption.readExternal (_AppProcessOption, vals.get(FIELD_AppProcessOption))); //
        _OverallSuitability = (Integer)(HELPER_OverallSuitability.readExternal (_OverallSuitability, vals.get(FIELD_OverallSuitability))); //
        _Candidate.readExternalData(vals.get(SINGLEREFERENCE_Candidate));
        _Job.readExternalData(vals.get(SINGLEREFERENCE_Job));
        _AssessmentCriteriaAnswers.readExternalData(vals.get(MULTIPLEREFERENCE_AssessmentCriteriaAnswers));
        
    }


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

        vals.put (FIELD_CV, HELPER_CV.writeExternal (_CV));
        vals.put (FIELD_ApplicationStatus, HELPER_ApplicationStatus.writeExternal (_ApplicationStatus));
        vals.put (FIELD_SubmittedDate, HELPER_SubmittedDate.writeExternal (_SubmittedDate));
        vals.put (FIELD_AppProcessOption, HELPER_AppProcessOption.writeExternal (_AppProcessOption));
        vals.put (FIELD_OverallSuitability, HELPER_OverallSuitability.writeExternal (_OverallSuitability));
        vals.put (SINGLEREFERENCE_Candidate, _Candidate.writeExternalData());
        vals.put (SINGLEREFERENCE_Job, _Job.writeExternalData());
        vals.put (MULTIPLEREFERENCE_AssessmentCriteriaAnswers, _AssessmentCriteriaAnswers.writeExternalData());
        
    }


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

        if (other instanceof BaseJobApplication)
        {
            BaseJobApplication otherJobApplication = (BaseJobApplication)(other);

            
            if (!HELPER_CV.compare(this._CV, otherJobApplication._CV))
            {
                listener.notifyFieldChange(this, other, FIELD_CV, HELPER_CV.toObject(this._CV), HELPER_CV.toObject(otherJobApplication._CV));
            }
            if (!HELPER_ApplicationStatus.compare(this._ApplicationStatus, otherJobApplication._ApplicationStatus))
            {
                listener.notifyFieldChange(this, other, FIELD_ApplicationStatus, HELPER_ApplicationStatus.toObject(this._ApplicationStatus), HELPER_ApplicationStatus.toObject(otherJobApplication._ApplicationStatus));
            }
            if (!HELPER_SubmittedDate.compare(this._SubmittedDate, otherJobApplication._SubmittedDate))
            {
                listener.notifyFieldChange(this, other, FIELD_SubmittedDate, HELPER_SubmittedDate.toObject(this._SubmittedDate), HELPER_SubmittedDate.toObject(otherJobApplication._SubmittedDate));
            }

            // Compare single assocs
            _Candidate.compare (otherJobApplication._Candidate, listener);
            _Job.compare (otherJobApplication._Job, listener);
            

            // Compare multiple assocs
            _AssessmentCriteriaAnswers.compare (otherJobApplication._AssessmentCriteriaAnswers, listener);
            
        }
    }


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

        visitor.visitField(this, FIELD_AppProcessOption, HELPER_AppProcessOption.toObject(getAppProcessOption()));
        visitor.visitField(this, FIELD_OverallSuitability, HELPER_OverallSuitability.toObject(getOverallSuitability()));
        
    }


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

        visitor.visitField(this, FIELD_CV, HELPER_CV.toObject(getCV()));
        visitor.visitField(this, FIELD_ApplicationStatus, HELPER_ApplicationStatus.toObject(getApplicationStatus()));
        visitor.visitField(this, FIELD_SubmittedDate, HELPER_SubmittedDate.toObject(getSubmittedDate()));
        visitor.visitAssociation (_Candidate);
        visitor.visitAssociation (_Job);
        visitor.visitAssociation (_AssessmentCriteriaAnswers);
        
    }


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

        if (scope.includes (_Candidate))
        {
            visitor.visit (_Candidate);
        }
        if (scope.includes (_Job))
        {
            visitor.visit (_Job);
        }
        if (scope.includes (_AssessmentCriteriaAnswers))
        {
            visitor.visit (_AssessmentCriteriaAnswers);
        }
        
    }


    public static JobApplication createJobApplication (ObjectTransaction transaction) throws StorageException
    {
        JobApplication     result = new JobApplication ();

        result.initialiseNewObject (transaction);

        return result;
    }


    public static JobApplication getJobApplicationByID (ObjectTransaction transaction, Long objectID) throws StorageException
    {
        return (JobApplication)(transaction.getObjectByID (REFERENCE_JobApplication, objectID));
    }

    public boolean testFilter (String attribName, QueryFilter filter) throws StorageException
    {
        if (false)
        {
            throw new RuntimeException ("Game over man!!");
        }
        else if (attribName.equals (FIELD_CV))
        {
            return filter.matches (getCV ());
        }
        else if (attribName.equals (FIELD_ApplicationStatus))
        {
            return filter.matches (getApplicationStatus ());
        }
        else if (attribName.equals (FIELD_SubmittedDate))
        {
            return filter.matches (getSubmittedDate ());
        }
        else if (attribName.equals (SINGLEREFERENCE_Candidate))
        {
            return filter.matches (getCandidate ());
        }
        else if (attribName.equals (SINGLEREFERENCE_Job))
        {
            return filter.matches (getJob ());
        }
        else
        {
            return super.testFilter (attribName, filter);
        }
    }


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

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

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

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

            
            public SearchAll andCV (QueryFilter<BinaryContent> filter)
            {
                filter.addFilter (context, "tl_job_application.cv", "CV");
                return this;
            }
            
            public SearchAll andApplicationStatus (QueryFilter<ApplicationStatus> filter)
            {
                filter.addFilter (context, "tl_job_application.application_status", "ApplicationStatus");
                return this;
            }
            
            public SearchAll andSubmittedDate (QueryFilter<Date> filter)
            {
                filter.addFilter (context, "tl_job_application.submitted_date", "SubmittedDate");
                return this;
            }
            
            public SearchAll andCandidate (QueryFilter<Candidate> filter)
            {
                filter.addFilter (context, "tl_job_application.candidate_id", "Candidate");
                return this;
            }
            
            public SearchAll andJob (QueryFilter<Job> filter)
            {
                filter.addFilter (context, "tl_job_application.job_id", "Job");
                return this;
            }
            
                public JobApplication[]
             search (ObjectTransaction transaction) throws StorageException
        {
            
            
            BaseBusinessClass[]     results = super.search (transaction, REFERENCE_JobApplication, SEARCH_All, criteria);
            Set<JobApplication>   typedResults = new LinkedHashSet <JobApplication> ();
            for (BaseBusinessClass bbcResult : results)
            {
                JobApplication aResult = (JobApplication)bbcResult;
                
                typedResults.add (aResult);
            }
            
                    return ObjstoreUtils.removeDeleted(transaction, typedResults).toArray (new JobApplication[0]);
                            
        }
    }

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

    public static SearchCandidateJob SearchByCandidateJob () { return new SearchCandidateJob (); }

    public static class SearchCandidateJob extends SearchObject<JobApplication>
    {
        
        public SearchCandidateJob byCandidate (Candidate Candidate)
        {
            by ("Candidate", Candidate);
            return this;
        }
        
        public SearchCandidateJob byJob (Job Job)
        {
            by ("Job", Job);
            return this;
        }
        
            public SearchCandidateJob andObjectID (QueryFilter<Long> filter)
            {
                filter.addFilter (context, "tl_job_application.object_id", FIELD_ObjectID);
                return this;
            }

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

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

            
            public SearchCandidateJob andCV (QueryFilter<BinaryContent> filter)
            {
                filter.addFilter (context, "tl_job_application.cv", "CV");
                return this;
            }
            
            public SearchCandidateJob andApplicationStatus (QueryFilter<ApplicationStatus> filter)
            {
                filter.addFilter (context, "tl_job_application.application_status", "ApplicationStatus");
                return this;
            }
            
            public SearchCandidateJob andSubmittedDate (QueryFilter<Date> filter)
            {
                filter.addFilter (context, "tl_job_application.submitted_date", "SubmittedDate");
                return this;
            }
            
            public SearchCandidateJob andCandidate (QueryFilter<Candidate> filter)
            {
                filter.addFilter (context, "tl_job_application.candidate_id", "Candidate");
                return this;
            }
            
            public SearchCandidateJob andJob (QueryFilter<Job> filter)
            {
                filter.addFilter (context, "tl_job_application.job_id", "Job");
                return this;
            }
            
                public JobApplication search (ObjectTransaction transaction) throws StorageException
        {
            
            
            BaseBusinessClass[]     results = super.search (transaction, REFERENCE_JobApplication, SEARCH_CandidateJob, criteria);
            Set<JobApplication>   typedResults = new LinkedHashSet <JobApplication> ();
            for (BaseBusinessClass bbcResult : results)
            {
                JobApplication aResult = (JobApplication)bbcResult;
                
                typedResults.add (aResult);
            }
            
                    return (JobApplication)singletonResult(ObjstoreUtils.removeDeleted(transaction, typedResults).toArray(new BaseBusinessClass[0]), "JobApplication", "");
                            
        }
    }

        
                public static JobApplication searchCandidateJob (ObjectTransaction transaction, Candidate Candidate, Job Job) throws StorageException
        {
            return SearchByCandidateJob ()
            .byCandidate  (Candidate)
            .byJob  (Job)
            .search (transaction);
        }



    public Object getAttribute (String attribName)
    {
        if (false)
        {
            throw new RuntimeException ("Game over man!!");
        }
        else if (attribName.equals (FIELD_CV))
        {
            return HELPER_CV.toObject (getCV ());
        }
        else if (attribName.equals (FIELD_ApplicationStatus))
        {
            return HELPER_ApplicationStatus.toObject (getApplicationStatus ());
        }
        else if (attribName.equals (FIELD_SubmittedDate))
        {
            return HELPER_SubmittedDate.toObject (getSubmittedDate ());
        }
        else if (attribName.equals (FIELD_AppProcessOption))
        {
            return HELPER_AppProcessOption.toObject (getAppProcessOption ());
        }
        else if (attribName.equals (FIELD_OverallSuitability))
        {
            return HELPER_OverallSuitability.toObject (getOverallSuitability ());
        }
        else
        {
            return super.getAttribute (attribName);
        }
    }


    public AttributeHelper getAttributeHelper (String attribName)
    {
        if (false)
        {
            throw new RuntimeException ("Game over man!!");
        }
        else if (attribName.equals (FIELD_CV))
        {
            return HELPER_CV;
        }
        else if (attribName.equals (FIELD_ApplicationStatus))
        {
            return HELPER_ApplicationStatus;
        }
        else if (attribName.equals (FIELD_SubmittedDate))
        {
            return HELPER_SubmittedDate;
        }
        else if (attribName.equals (FIELD_AppProcessOption))
        {
            return HELPER_AppProcessOption;
        }
        else if (attribName.equals (FIELD_OverallSuitability))
        {
            return HELPER_OverallSuitability;
        }
        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_CV))
        {
            setCV ((BinaryContent)(HELPER_CV.fromObject (_CV, attribValue)));            
        }
        else if (attribName.equals (FIELD_ApplicationStatus))
        {
            setApplicationStatus ((ApplicationStatus)(HELPER_ApplicationStatus.fromObject (_ApplicationStatus, attribValue)));            
        }
        else if (attribName.equals (FIELD_SubmittedDate))
        {
            setSubmittedDate ((Date)(HELPER_SubmittedDate.fromObject (_SubmittedDate, attribValue)));            
        }
        else if (attribName.equals (FIELD_AppProcessOption))
        {
            setAppProcessOption ((AppProcessOption)(HELPER_AppProcessOption.fromObject (_AppProcessOption, attribValue)));            
        }
        else if (attribName.equals (FIELD_OverallSuitability))
        {
            setOverallSuitability ((Integer)(HELPER_OverallSuitability.fromObject (_OverallSuitability, 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_CV))
        {
            return getWriteability_CV ();
        }
        else if (fieldName.equals (FIELD_ApplicationStatus))
        {
            return getWriteability_ApplicationStatus ();
        }
        else if (fieldName.equals (FIELD_SubmittedDate))
        {
            return getWriteability_SubmittedDate ();
        }
        else if (fieldName.equals (MULTIPLEREFERENCE_AssessmentCriteriaAnswers))
        {
            return getWriteability_AssessmentCriteriaAnswers ();
        }
        else if (fieldName.equals (SINGLEREFERENCE_Candidate))
        {
            return getWriteability_Candidate ();
        }
        else if (fieldName.equals (SINGLEREFERENCE_Job))
        {
            return getWriteability_Job ();
        }
        else if (fieldName.equals (FIELD_AppProcessOption))
        {
            return getWriteability_AppProcessOption ();
        }
        else if (fieldName.equals (FIELD_OverallSuitability))
        {
            return getWriteability_OverallSuitability ();
        }
        else
        {
            return super.getWriteable (fieldName);
        }
    }


    public void putUnwriteable (Set<String> fields)
    {
        
            if (getWriteability_CV () != FieldWriteability.TRUE)
            {
                fields.add (FIELD_CV);
            }
        
            if (getWriteability_ApplicationStatus () != FieldWriteability.TRUE)
            {
                fields.add (FIELD_ApplicationStatus);
            }
        
            if (getWriteability_SubmittedDate () != FieldWriteability.TRUE)
            {
                fields.add (FIELD_SubmittedDate);
            }
        
            if (getWriteability_AppProcessOption () != FieldWriteability.TRUE)
            {
                fields.add (FIELD_AppProcessOption);
            }
        
            if (getWriteability_OverallSuitability () != FieldWriteability.TRUE)
            {
                fields.add (FIELD_OverallSuitability);
            }
        

        super.putUnwriteable (fields);
    }

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

        
        result.add(HELPER_CV.getAttribObject (getClass (), _CV, false, FIELD_CV));
        result.add(HELPER_ApplicationStatus.getAttribObject (getClass (), _ApplicationStatus, true, FIELD_ApplicationStatus));
        result.add(HELPER_SubmittedDate.getAttribObject (getClass (), _SubmittedDate, false, FIELD_SubmittedDate));
        result.add(HELPER_AppProcessOption.getAttribObject (getClass (), _AppProcessOption, false, FIELD_AppProcessOption));
        result.add(HELPER_OverallSuitability.getAttribObject (getClass (), _OverallSuitability, false, FIELD_OverallSuitability));

        return result;
    }


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


    public Object getAttributeMetadata (String attribute, String metadata)
    {
        if (ATTRIBUTES_METADATA_JobApplication.containsKey (attribute))
        {
            return ((Map)ATTRIBUTES_METADATA_JobApplication.get (attribute)).get(metadata);
        }
        else
        {
            return super.getAttributeMetadata (attribute, metadata);
        }
    }

    public void preCommit (boolean willBeStored) throws Exception
    {
        super.preCommit(willBeStored);
        
        if(willBeStored)
        {
        
          {  
            oneit.servlets.objstore.binary.BinaryContentHandler bchandler = oneit.servlets.objstore.binary.BinaryContentServlet.getHandler("loggedin");
              
            if(bchandler != null)
            {
                bchandler.preCommit(willBeStored, this, "CV");
            }
            else
            {
                LogMgr.log(BUSINESS_OBJECTS, LogLevel.SYSTEMWARNING, "Unknown BinaryContentHandler loggedin on attribute CV");
            }
          }
          
        }
    }

    public oneit.servlets.objstore.binary.BinaryContentHandler getBinaryContentHandler(String attribName)
    {
        
        if(CollectionUtils.equals(attribName, "CV"))      
        {  
            return oneit.servlets.objstore.binary.BinaryContentServlet.getHandler("loggedin");
        }     
          
        
        return super.getBinaryContentHandler(attribName);
    }

    public static class JobApplicationBehaviourDecorator extends BaseBusinessClass.BBCBehaviourDecorator<JobApplication>
    {

    /**
     * Get the attribute CV
     */
    public BinaryContent getCV (JobApplication obj, BinaryContent original)
    {
        return original;
    }

    /**
     * Change the value set for attribute CV.
     * May modify the field beforehand
     * Occurs before validation.
     */
    public BinaryContent setCV (JobApplication obj, BinaryContent newCV) throws FieldException
    {
        return newCV;
    }

    /**
     * Get the attribute ApplicationStatus
     */
    public ApplicationStatus getApplicationStatus (JobApplication obj, ApplicationStatus original)
    {
        return original;
    }

    /**
     * Change the value set for attribute ApplicationStatus.
     * May modify the field beforehand
     * Occurs before validation.
     */
    public ApplicationStatus setApplicationStatus (JobApplication obj, ApplicationStatus newApplicationStatus) throws FieldException
    {
        return newApplicationStatus;
    }

    /**
     * Get the attribute SubmittedDate
     */
    public Date getSubmittedDate (JobApplication obj, Date original)
    {
        return original;
    }

    /**
     * Change the value set for attribute SubmittedDate.
     * May modify the field beforehand
     * Occurs before validation.
     */
    public Date setSubmittedDate (JobApplication obj, Date newSubmittedDate) throws FieldException
    {
        return newSubmittedDate;
    }

    /**
     * Get the attribute AppProcessOption
     */
    public AppProcessOption getAppProcessOption (JobApplication obj, AppProcessOption original)
    {
        return original;
    }

    /**
     * Change the value set for attribute AppProcessOption.
     * May modify the field beforehand
     * Occurs before validation.
     */
    public AppProcessOption setAppProcessOption (JobApplication obj, AppProcessOption newAppProcessOption) throws FieldException
    {
        return newAppProcessOption;
    }

    /**
     * Get the attribute OverallSuitability
     */
    public Integer getOverallSuitability (JobApplication obj, Integer original)
    {
        return original;
    }

    /**
     * Change the value set for attribute OverallSuitability.
     * May modify the field beforehand
     * Occurs before validation.
     */
    public Integer setOverallSuitability (JobApplication obj, Integer newOverallSuitability) throws FieldException
    {
        return newOverallSuitability;
    }

    }

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

        public JobApplicationPipeLineFactory (Collection<From> seed)
        {
            super(seed);
        }
        
        
        public PipeLine<From, ? extends Object> to(String name)
        {
            if (name.equals ("AssessmentCriteriaAnswers"))
            {
                return toAssessmentCriteriaAnswers ();
            }                
            if (name.equals ("AppProcessOption"))
            {
                return toAppProcessOption ();
            }                
            if (name.equals ("OverallSuitability"))
            {
                return toOverallSuitability ();
            }                
            if (name.equals ("CV"))
            {
                return toCV ();
            }                
            if (name.equals ("ApplicationStatus"))
            {
                return toApplicationStatus ();
            }                
            if (name.equals ("SubmittedDate"))
            {
                return toSubmittedDate ();
            }                
            if (name.equals ("Candidate"))
            {
                return toCandidate ();
            }                
            if (name.equals ("Job"))
            {
                return toJob ();
            }                
            
            
            return super.to(name);
        }
        
        
        public PipeLine<From, AppProcessOption> toAppProcessOption () { return pipe(new ORMAttributePipe<Me, AppProcessOption>(FIELD_AppProcessOption));  }
        
        public PipeLine<From, Integer> toOverallSuitability () { return pipe(new ORMAttributePipe<Me, Integer>(FIELD_OverallSuitability));  }
        
        public PipeLine<From, BinaryContent> toCV () { return pipe(new ORMAttributePipe<Me, BinaryContent>(FIELD_CV));  }
        
        public PipeLine<From, ApplicationStatus> toApplicationStatus () { return pipe(new ORMAttributePipe<Me, ApplicationStatus>(FIELD_ApplicationStatus));  }
        
        public PipeLine<From, Date> toSubmittedDate () { return pipe(new ORMAttributePipe<Me, Date>(FIELD_SubmittedDate));  }
        public Candidate.CandidatePipeLineFactory<From, Candidate> toCandidate () { return toCandidate (Filter.ALL); }

        public Candidate.CandidatePipeLineFactory<From, Candidate> toCandidate (Filter<Candidate> filter) 
        { 
            return Candidate.REFERENCE_Candidate.new CandidatePipeLineFactory<From, Candidate> (this, new ORMSingleAssocPipe<Me, Candidate>(SINGLEREFERENCE_Candidate, filter)); 
        }
        public Job.JobPipeLineFactory<From, Job> toJob () { return toJob (Filter.ALL); }

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

        public AssessmentCriteriaAnswer.AssessmentCriteriaAnswerPipeLineFactory<From, AssessmentCriteriaAnswer> toAssessmentCriteriaAnswers (Filter<AssessmentCriteriaAnswer> filter)
        {
            return AssessmentCriteriaAnswer.REFERENCE_AssessmentCriteriaAnswer.new AssessmentCriteriaAnswerPipeLineFactory<From, AssessmentCriteriaAnswer> (this, new ORMMultiAssocPipe<Me, AssessmentCriteriaAnswer>(MULTIPLEREFERENCE_AssessmentCriteriaAnswers, filter)); 
        }
        
    }
    
    public boolean isTransientAttrib(String attribName)
    {
        
        if(CollectionUtils.equals(attribName, "AppProcessOption"))
        {
            return true;
        }
        
        if(CollectionUtils.equals(attribName, "OverallSuitability"))
        {
            return true;
        }
        

        return super.isTransientAttrib(attribName);
    }

    public boolean isTransientSingleReference(String assocName)
    {
        

        return super.isTransientSingleReference(assocName);
    }
}

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

    public void assertValid ()
    {
    }


    public Candidate getCandidate () throws StorageException
    {
        return (Candidate)(Candidate.DUMMY_Candidate);
    }


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

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


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

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


    public AssessmentCriteriaAnswer getAssessmentCriteriaAnswersAt (int index) throws StorageException
    {
        throw new RuntimeException ("No elements in a dummy object in association AssessmentCriteriaAnswers");
    }


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

}

    
