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


    package performa.orm;

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



public abstract class BaseFactor extends BaseBusinessClass
{
    // Reference instance for the object
    public static final Factor REFERENCE_Factor = new Factor ();

    // Reference instance for the object
    public static final Factor DUMMY_Factor = new DummyFactor ();

    // Static constants corresponding to field names
    
    public static final String FIELD_Description = "Description";
    public static final String MULTIPLEREFERENCE_Levels = "Levels";
    public static final String BACKREF_Levels = "";
    public static final String MULTIPLEREFERENCE_Questions = "Questions";
    public static final String BACKREF_Questions = "";
    public static final String MULTIPLEREFERENCE_Results = "Results";
    public static final String BACKREF_Results = "";
    public static final String MULTIPLEREFERENCE_HighLowQuestions = "HighLowQuestions";
    public static final String BACKREF_HighLowQuestions = "";
    public static final String MULTIPLEREFERENCE_LevelFactorTypes = "LevelFactorTypes";
    public static final String BACKREF_LevelFactorTypes = "";

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

    // Static constants corresponding to attribute helpers
    private static final DefaultAttributeHelper<Factor> HELPER_Description = DefaultAttributeHelper.INSTANCE;
    

    // Private attributes corresponding to business object data
    private String _Description;
    

    // Private attributes corresponding to single references
    

    // Private attributes corresponding to multiple references
    private MultipleAssociation<Factor, FactorLevelLink> _Levels;
    private MultipleAssociation<Factor, FactorQuestionLink> _Questions;
    private MultipleAssociation<Factor, FactorScoreResult> _Results;
    private MultipleAssociation<Factor, Question> _HighLowQuestions;
    private MultipleAssociation<Factor, LevelFactorType> _LevelFactorTypes;
    

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

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

    // Arrays of behaviour decorators
    private static final FactorBehaviourDecorator[] Factor_BehaviourDecorators;
    
    static
    {
        try
        {
            
            String tmp_Levels = FactorLevelLink.BACKREF_Factor;
            String tmp_Questions = FactorQuestionLink.BACKREF_Factor;
            String tmp_Results = FactorScoreResult.BACKREF_Factor;
            String tmp_HighLowQuestions = Question.BACKREF_HighLowFactor;
            String tmp_LevelFactorTypes = LevelFactorType.BACKREF_Factor;
            
            Map  validatorMapping = ((Map)ConfigMgr.getConfigObject ("CONFIG.ORMVALIDATOR", "ValidatorMapping"));

            setupAssocMetaData_Levels();
            setupAssocMetaData_Questions();
            setupAssocMetaData_Results();
            setupAssocMetaData_HighLowQuestions();
            setupAssocMetaData_LevelFactorTypes();
            FIELD_Description_Validators = (AttributeValidator[])setupAttribMetaData_Description(validatorMapping).toArray (new AttributeValidator[0]);
            

            REFERENCE_Factor.initialiseReference ();
            DUMMY_Factor.initialiseReference ();
            Factor_BehaviourDecorators = BaseBusinessClass.getBBCBehaviours(Factor.class).toArray(new FactorBehaviourDecorator[0]);
        }
        catch (RuntimeException e)
        {
            LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR1, e, "Error initialising");
            throw e;
        }
    }

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

        metaInfo.put ("backreferenceName", "Factor");
        metaInfo.put ("name", "Levels");
        metaInfo.put ("type", "FactorLevelLink");
        
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for Factor.Levels:", metaInfo);
        ATTRIBUTES_METADATA_Factor.put (MULTIPLEREFERENCE_Levels, Collections.unmodifiableMap (metaInfo));
    }
    
    
    // Meta Info setup
    private static void setupAssocMetaData_Questions()
    {
        Map metaInfo = new HashMap ();

        metaInfo.put ("backreferenceName", "Factor");
        metaInfo.put ("name", "Questions");
        metaInfo.put ("type", "FactorQuestionLink");
        
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for Factor.Questions:", metaInfo);
        ATTRIBUTES_METADATA_Factor.put (MULTIPLEREFERENCE_Questions, Collections.unmodifiableMap (metaInfo));
    }
    
    
    // Meta Info setup
    private static void setupAssocMetaData_Results()
    {
        Map metaInfo = new HashMap ();

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

        metaInfo.put ("backreferenceName", "HighLowFactor");
        metaInfo.put ("name", "HighLowQuestions");
        metaInfo.put ("type", "Question");
        
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for Factor.HighLowQuestions:", metaInfo);
        ATTRIBUTES_METADATA_Factor.put (MULTIPLEREFERENCE_HighLowQuestions, Collections.unmodifiableMap (metaInfo));
    }
    
    
    // Meta Info setup
    private static void setupAssocMetaData_LevelFactorTypes()
    {
        Map metaInfo = new HashMap ();

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

        metaInfo.put ("dbcol", "factor_hdr_desc");
        metaInfo.put ("length", "30");
        metaInfo.put ("name", "Description");
        metaInfo.put ("type", "String");
        
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for Factor.Description:", metaInfo);
        ATTRIBUTES_METADATA_Factor.put (FIELD_Description, Collections.unmodifiableMap (metaInfo));

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

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


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


    


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

        
        _Description = (String)(HELPER_Description.initialise (_Description));
    }


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

        _Levels = new MultipleAssociation<Factor, FactorLevelLink> (this, MULTIPLEREFERENCE_Levels, FactorLevelLink.SINGLEREFERENCE_Factor, FactorLevelLink.REFERENCE_FactorLevelLink);
        _Questions = new MultipleAssociation<Factor, FactorQuestionLink> (this, MULTIPLEREFERENCE_Questions, FactorQuestionLink.SINGLEREFERENCE_Factor, FactorQuestionLink.REFERENCE_FactorQuestionLink);
        _Results = new MultipleAssociation<Factor, FactorScoreResult> (this, MULTIPLEREFERENCE_Results, FactorScoreResult.SINGLEREFERENCE_Factor, FactorScoreResult.REFERENCE_FactorScoreResult);
        _HighLowQuestions = new MultipleAssociation<Factor, Question> (this, MULTIPLEREFERENCE_HighLowQuestions, Question.SINGLEREFERENCE_HighLowFactor, Question.REFERENCE_Question);
        _LevelFactorTypes = new MultipleAssociation<Factor, LevelFactorType> (this, MULTIPLEREFERENCE_LevelFactorTypes, LevelFactorType.SINGLEREFERENCE_Factor, LevelFactorType.REFERENCE_LevelFactorType);
        
    }


    // Initialise the associations
    protected BaseBusinessClass initialiseReference ()
    {
        super.initialiseReference ();
        
        _Levels = new MultipleAssociation<Factor, FactorLevelLink> (this, MULTIPLEREFERENCE_Levels, FactorLevelLink.SINGLEREFERENCE_Factor, FactorLevelLink.REFERENCE_FactorLevelLink);
        _Questions = new MultipleAssociation<Factor, FactorQuestionLink> (this, MULTIPLEREFERENCE_Questions, FactorQuestionLink.SINGLEREFERENCE_Factor, FactorQuestionLink.REFERENCE_FactorQuestionLink);
        _Results = new MultipleAssociation<Factor, FactorScoreResult> (this, MULTIPLEREFERENCE_Results, FactorScoreResult.SINGLEREFERENCE_Factor, FactorScoreResult.REFERENCE_FactorScoreResult);
        _HighLowQuestions = new MultipleAssociation<Factor, Question> (this, MULTIPLEREFERENCE_HighLowQuestions, Question.SINGLEREFERENCE_HighLowFactor, Question.REFERENCE_Question);
        _LevelFactorTypes = new MultipleAssociation<Factor, LevelFactorType> (this, MULTIPLEREFERENCE_LevelFactorTypes, LevelFactorType.SINGLEREFERENCE_Factor, LevelFactorType.REFERENCE_LevelFactorType);
        
        
        return this;
    }

    

    /**
     * Get the attribute Description
     */
    public String getDescription ()
    {
        assertValid();
        String valToReturn = _Description;

            for (FactorBehaviourDecorator bhd : Factor_BehaviourDecorators)
            {
                valToReturn = bhd.getDescription ((Factor)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 preDescriptionChange (String newDescription) 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 postDescriptionChange () throws FieldException
    {
    }

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

    /**
     * Set the attribute Description.  Checks to ensure a new value
     * has been supplied.  If so, marks the field as altered and sets the attribute.
     */
    public void setDescription (String newDescription) throws FieldException
    {
        boolean oldAndNewIdentical = HELPER_Description.compare (_Description, newDescription);
        
        try
        {
            for (FactorBehaviourDecorator bhd : Factor_BehaviourDecorators)
            {
                newDescription = bhd.setDescription ((Factor)this, newDescription);
                oldAndNewIdentical = HELPER_Description.compare (_Description, newDescription);
            }

            

            if (FIELD_Description_Validators.length > 0)
            {
                Object newDescriptionObj = HELPER_Description.toObject (newDescription);

                if (newDescriptionObj != null)
                {
                    int     loopMax = FIELD_Description_Validators.length;
                    Map     metadata = (Map)ATTRIBUTES_METADATA_Factor.get (FIELD_Description);

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

        if (!oldAndNewIdentical)
        {
            assertValid();
            Debug.assertion (getWriteability_Description () != FieldWriteability.FALSE, "Field  Description is not writeable");
            preDescriptionChange (newDescription);
            markFieldChange (FIELD_Description);
            _Description = newDescription;            
            postFieldChange (FIELD_Description);
            postDescriptionChange ();
        }
    }



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

        

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


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


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


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


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



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

        
        result.add("Levels");
        
        result.add("Questions");
        
        result.add("Results");
        
        result.add("HighLowQuestions");
        
        result.add("LevelFactorTypes");
        

        return result;
    }


    /**
     * Get the reference instance for the multi assoc name.
     */
    public BaseBusinessClass getMultiAssocReferenceInstance(String attribName)
    {
        
        if (MULTIPLEREFERENCE_Levels.equals(attribName))
        {
            return FactorLevelLink.REFERENCE_FactorLevelLink ;
        }
        
        if (MULTIPLEREFERENCE_Questions.equals(attribName))
        {
            return FactorQuestionLink.REFERENCE_FactorQuestionLink ;
        }
        
        if (MULTIPLEREFERENCE_Results.equals(attribName))
        {
            return FactorScoreResult.REFERENCE_FactorScoreResult ;
        }
        
        if (MULTIPLEREFERENCE_HighLowQuestions.equals(attribName))
        {
            return Question.REFERENCE_Question ;
        }
        
        if (MULTIPLEREFERENCE_LevelFactorTypes.equals(attribName))
        {
            return LevelFactorType.REFERENCE_LevelFactorType ;
        }
        

        return super.getMultiAssocReferenceInstance(attribName);
    }


    public String getMultiAssocBackReference(String attribName)
    {
        
        if (MULTIPLEREFERENCE_Levels.equals(attribName))
        {
            return FactorLevelLink.SINGLEREFERENCE_Factor ;
        }
        
        if (MULTIPLEREFERENCE_Questions.equals(attribName))
        {
            return FactorQuestionLink.SINGLEREFERENCE_Factor ;
        }
        
        if (MULTIPLEREFERENCE_Results.equals(attribName))
        {
            return FactorScoreResult.SINGLEREFERENCE_Factor ;
        }
        
        if (MULTIPLEREFERENCE_HighLowQuestions.equals(attribName))
        {
            return Question.SINGLEREFERENCE_HighLowFactor ;
        }
        
        if (MULTIPLEREFERENCE_LevelFactorTypes.equals(attribName))
        {
            return LevelFactorType.SINGLEREFERENCE_Factor ;
        }
        

        return super.getMultiAssocBackReference(attribName);
    }


    /**
     * Get the assoc count for the multi assoc name.
     */
    public int getMultiAssocCount(String attribName) throws StorageException
    {
        
        if (MULTIPLEREFERENCE_Levels.equals(attribName))
        {
            return this.getLevelsCount();
        }
        
        if (MULTIPLEREFERENCE_Questions.equals(attribName))
        {
            return this.getQuestionsCount();
        }
        
        if (MULTIPLEREFERENCE_Results.equals(attribName))
        {
            return this.getResultsCount();
        }
        
        if (MULTIPLEREFERENCE_HighLowQuestions.equals(attribName))
        {
            return this.getHighLowQuestionsCount();
        }
        
        if (MULTIPLEREFERENCE_LevelFactorTypes.equals(attribName))
        {
            return this.getLevelFactorTypesCount();
        }
        

        return super.getMultiAssocCount(attribName);
    }


    /**
     * Get the assoc at a particular index
     */
    public BaseBusinessClass getMultiAssocAt(String attribName, int index) throws StorageException
    {
        
        if (MULTIPLEREFERENCE_Levels.equals(attribName))
        {
            return this.getLevelsAt(index);
        }
        
        if (MULTIPLEREFERENCE_Questions.equals(attribName))
        {
            return this.getQuestionsAt(index);
        }
        
        if (MULTIPLEREFERENCE_Results.equals(attribName))
        {
            return this.getResultsAt(index);
        }
        
        if (MULTIPLEREFERENCE_HighLowQuestions.equals(attribName))
        {
            return this.getHighLowQuestionsAt(index);
        }
        
        if (MULTIPLEREFERENCE_LevelFactorTypes.equals(attribName))
        {
            return this.getLevelFactorTypesAt(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_Levels.equals(attribName))
        {
            addToLevels((FactorLevelLink)newElement);

            return;
        }
        
        if (MULTIPLEREFERENCE_Questions.equals(attribName))
        {
            addToQuestions((FactorQuestionLink)newElement);

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

            return;
        }
        
        if (MULTIPLEREFERENCE_HighLowQuestions.equals(attribName))
        {
            addToHighLowQuestions((Question)newElement);

            return;
        }
        
        if (MULTIPLEREFERENCE_LevelFactorTypes.equals(attribName))
        {
            addToLevelFactorTypes((LevelFactorType)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_Levels.equals(attribName))
        {
            removeFromLevels((FactorLevelLink)oldElement);

            return;
        }
        
        if (MULTIPLEREFERENCE_Questions.equals(attribName))
        {
            removeFromQuestions((FactorQuestionLink)oldElement);

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

            return;
        }
        
        if (MULTIPLEREFERENCE_HighLowQuestions.equals(attribName))
        {
            removeFromHighLowQuestions((Question)oldElement);

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

            return;
        }
        

        super.removeFromMultiAssoc(attribName, oldElement);
    }


    protected void __loadMultiAssoc (String attribName, BaseBusinessClass[] elements)
    {
        
        if (MULTIPLEREFERENCE_Levels.equals(attribName))
        {
            _Levels.__loadAssociation (elements);
            return;
        }
        
        if (MULTIPLEREFERENCE_Questions.equals(attribName))
        {
            _Questions.__loadAssociation (elements);
            return;
        }
        
        if (MULTIPLEREFERENCE_Results.equals(attribName))
        {
            _Results.__loadAssociation (elements);
            return;
        }
        
        if (MULTIPLEREFERENCE_HighLowQuestions.equals(attribName))
        {
            _HighLowQuestions.__loadAssociation (elements);
            return;
        }
        
        if (MULTIPLEREFERENCE_LevelFactorTypes.equals(attribName))
        {
            _LevelFactorTypes.__loadAssociation (elements);
            return;
        }
        

        super.__loadMultiAssoc(attribName, elements);
    }


    protected boolean __isMultiAssocLoaded (String attribName)
    {
        
        if (MULTIPLEREFERENCE_Levels.equals(attribName))
        {
            return _Levels.isLoaded ();
        }
        
        if (MULTIPLEREFERENCE_Questions.equals(attribName))
        {
            return _Questions.isLoaded ();
        }
        
        if (MULTIPLEREFERENCE_Results.equals(attribName))
        {
            return _Results.isLoaded ();
        }
        
        if (MULTIPLEREFERENCE_HighLowQuestions.equals(attribName))
        {
            return _HighLowQuestions.isLoaded ();
        }
        
        if (MULTIPLEREFERENCE_LevelFactorTypes.equals(attribName))
        {
            return _LevelFactorTypes.isLoaded ();
        }
        

        return super.__isMultiAssocLoaded(attribName);
    }

    

    public FieldWriteability getWriteability_Levels ()
    {
        return getFieldWritabilityUtil (FieldWriteability.TRUE);
    }
    
    
    public int getLevelsCount () throws StorageException
    {
        assertValid();
        return _Levels.getReferencedObjectsCount ();
    }


    public void addToLevels (FactorLevelLink newElement) throws StorageException
    {
        if (_Levels.wouldAddChange (newElement))
        {
            assertValid();
            Debug.assertion (getWriteability_Levels () != FieldWriteability.FALSE, "MultiAssoc Levels is not writeable (add)");
            _Levels.appendElement (newElement);

            try
            {
                if (newElement.getFactor () != this)
                {
                    newElement.setFactor ((Factor)(this));
                }
            }
            catch (Exception e)
            {
                throw NestedException.wrap(e);
            }
        }
    }


    public void removeFromLevels (FactorLevelLink elementToRemove) throws StorageException
    {
        if (_Levels.wouldRemoveChange (elementToRemove))
        {
            assertValid();
            Debug.assertion (getWriteability_Levels () != FieldWriteability.FALSE, "MultiAssoc Levels is not writeable (remove)");
            _Levels.removeElement (elementToRemove);
            try
            {
                if (elementToRemove.getFactor () != null)
                {
                    elementToRemove.setFactor (null);
                }
            }
            catch (Exception e)
            {
                throw NestedException.wrap(e);
            }
        }
    }


    public FactorLevelLink getLevelsAt (int index) throws StorageException
    {
        return (FactorLevelLink)(_Levels.getElementAt (index));
    }


    public SortedSet<FactorLevelLink> getLevelsSet () throws StorageException
    {
        return _Levels.getSet ();
    }

    public FieldWriteability getWriteability_Questions ()
    {
        return getFieldWritabilityUtil (FieldWriteability.TRUE);
    }
    
    
    public int getQuestionsCount () throws StorageException
    {
        assertValid();
        return _Questions.getReferencedObjectsCount ();
    }


    public void addToQuestions (FactorQuestionLink newElement) throws StorageException
    {
        if (_Questions.wouldAddChange (newElement))
        {
            assertValid();
            Debug.assertion (getWriteability_Questions () != FieldWriteability.FALSE, "MultiAssoc Questions is not writeable (add)");
            _Questions.appendElement (newElement);

            try
            {
                if (newElement.getFactor () != this)
                {
                    newElement.setFactor ((Factor)(this));
                }
            }
            catch (Exception e)
            {
                throw NestedException.wrap(e);
            }
        }
    }


    public void removeFromQuestions (FactorQuestionLink elementToRemove) throws StorageException
    {
        if (_Questions.wouldRemoveChange (elementToRemove))
        {
            assertValid();
            Debug.assertion (getWriteability_Questions () != FieldWriteability.FALSE, "MultiAssoc Questions is not writeable (remove)");
            _Questions.removeElement (elementToRemove);
            try
            {
                if (elementToRemove.getFactor () != null)
                {
                    elementToRemove.setFactor (null);
                }
            }
            catch (Exception e)
            {
                throw NestedException.wrap(e);
            }
        }
    }


    public FactorQuestionLink getQuestionsAt (int index) throws StorageException
    {
        return (FactorQuestionLink)(_Questions.getElementAt (index));
    }


    public SortedSet<FactorQuestionLink> getQuestionsSet () throws StorageException
    {
        return _Questions.getSet ();
    }

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


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

            try
            {
                if (newElement.getFactor () != this)
                {
                    newElement.setFactor ((Factor)(this));
                }
            }
            catch (Exception e)
            {
                throw NestedException.wrap(e);
            }
        }
    }


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


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


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

    public FieldWriteability getWriteability_HighLowQuestions ()
    {
        return getFieldWritabilityUtil (FieldWriteability.TRUE);
    }
    
    
    public int getHighLowQuestionsCount () throws StorageException
    {
        assertValid();
        return _HighLowQuestions.getReferencedObjectsCount ();
    }


    public void addToHighLowQuestions (Question newElement) throws StorageException
    {
        if (_HighLowQuestions.wouldAddChange (newElement))
        {
            assertValid();
            Debug.assertion (getWriteability_HighLowQuestions () != FieldWriteability.FALSE, "MultiAssoc HighLowQuestions is not writeable (add)");
            _HighLowQuestions.appendElement (newElement);

            try
            {
                if (newElement.getHighLowFactor () != this)
                {
                    newElement.setHighLowFactor ((Factor)(this));
                }
            }
            catch (Exception e)
            {
                throw NestedException.wrap(e);
            }
        }
    }


    public void removeFromHighLowQuestions (Question elementToRemove) throws StorageException
    {
        if (_HighLowQuestions.wouldRemoveChange (elementToRemove))
        {
            assertValid();
            Debug.assertion (getWriteability_HighLowQuestions () != FieldWriteability.FALSE, "MultiAssoc HighLowQuestions is not writeable (remove)");
            _HighLowQuestions.removeElement (elementToRemove);
            try
            {
                if (elementToRemove.getHighLowFactor () != null)
                {
                    elementToRemove.setHighLowFactor (null);
                }
            }
            catch (Exception e)
            {
                throw NestedException.wrap(e);
            }
        }
    }


    public Question getHighLowQuestionsAt (int index) throws StorageException
    {
        return (Question)(_HighLowQuestions.getElementAt (index));
    }


    public SortedSet<Question> getHighLowQuestionsSet () throws StorageException
    {
        return _HighLowQuestions.getSet ();
    }

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


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

            try
            {
                if (newElement.getFactor () != this)
                {
                    newElement.setFactor ((Factor)(this));
                }
            }
            catch (Exception e)
            {
                throw NestedException.wrap(e);
            }
        }
    }


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


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


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



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

            for(FactorQuestionLink referenced : CollectionUtils.reverse(getQuestionsSet()))
            { 
                LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Setting backreference to null Factor from ", getObjectID (), " to ", referenced.getObjectID ());
                referenced.setFactor(null);
            }

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

            for(Question referenced : CollectionUtils.reverse(getHighLowQuestionsSet()))
            { 
                LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Setting backreference to null HighLowFactor from ", getObjectID (), " to ", referenced.getObjectID ());
                referenced.setHighLowFactor(null);
            }

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

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

        super.onDelete ();
    }


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


    public Factor referenceInstance ()
    {
        return REFERENCE_Factor;
    }


    public Factor getInTransaction (ObjectTransaction t) throws StorageException
    {
        return getFactorByID (t, getObjectID());
    }
    
    
    public BaseBusinessClass dummyInstance ()
    {
        return DUMMY_Factor;
    }


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





    /**
     * This is where an object returns the Persistent sets that will
     * store it into the database.
     * The should be entered into allSets
     */
    public void getPersistentSets (PersistentSetCollection allSets)
    {
        ObjectStatus        myStatus = getStatus ();
        PersistentSetStatus myPSetStatus = myStatus.getPSetStatus();
        ObjectID            myID = getID();

        super.getPersistentSets (allSets);

        
        PersistentSet   tl_factorPSet = allSets.getPersistentSet (myID, "tl_factor", myPSetStatus);

        tl_factorPSet.setAttrib (FIELD_ObjectID, myID);
        tl_factorPSet.setAttrib (FIELD_Description, HELPER_Description.toObject (_Description)); //
        
    }


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

        
        PersistentSet   tl_factorPSet = allSets.getPersistentSet (objectID, "tl_factor");

        _Description = (String)(HELPER_Description.fromObject (_Description, tl_factorPSet.getAttrib (FIELD_Description))); //
        
    }





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

        if (other instanceof Factor)
        {
            Factor otherFactor = (Factor)other;
            
            try
            {
                setDescription (otherFactor.getDescription ());
            }
            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 BaseFactor)
        {
            BaseFactor sourceFactor = (BaseFactor)(source);

            _Description = sourceFactor._Description;
            
        }
    }


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

            
        }
    }


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

        if (source instanceof BaseFactor)
        {
            BaseFactor sourceFactor = (BaseFactor)(source);

            _Levels.copyFrom (sourceFactor._Levels, linkToGhosts);
            _Questions.copyFrom (sourceFactor._Questions, linkToGhosts);
            _Results.copyFrom (sourceFactor._Results, linkToGhosts);
            _HighLowQuestions.copyFrom (sourceFactor._HighLowQuestions, linkToGhosts);
            _LevelFactorTypes.copyFrom (sourceFactor._LevelFactorTypes, linkToGhosts);
            
        }
    }


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

        
    }


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

        _Description = (String)(HELPER_Description.readExternal (_Description, vals.get(FIELD_Description))); //
        _Levels.readExternalData(vals.get(MULTIPLEREFERENCE_Levels));
        _Questions.readExternalData(vals.get(MULTIPLEREFERENCE_Questions));
        _Results.readExternalData(vals.get(MULTIPLEREFERENCE_Results));
        _HighLowQuestions.readExternalData(vals.get(MULTIPLEREFERENCE_HighLowQuestions));
        _LevelFactorTypes.readExternalData(vals.get(MULTIPLEREFERENCE_LevelFactorTypes));
        
    }


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

        vals.put (FIELD_Description, HELPER_Description.writeExternal (_Description));
        vals.put (MULTIPLEREFERENCE_Levels, _Levels.writeExternalData());
        vals.put (MULTIPLEREFERENCE_Questions, _Questions.writeExternalData());
        vals.put (MULTIPLEREFERENCE_Results, _Results.writeExternalData());
        vals.put (MULTIPLEREFERENCE_HighLowQuestions, _HighLowQuestions.writeExternalData());
        vals.put (MULTIPLEREFERENCE_LevelFactorTypes, _LevelFactorTypes.writeExternalData());
        
    }


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

        if (other instanceof BaseFactor)
        {
            BaseFactor otherFactor = (BaseFactor)(other);

            
            if (!HELPER_Description.compare(this._Description, otherFactor._Description))
            {
                listener.notifyFieldChange(this, other, FIELD_Description, HELPER_Description.toObject(this._Description), HELPER_Description.toObject(otherFactor._Description));
            }

            // Compare single assocs
            

            // Compare multiple assocs
            _Levels.compare (otherFactor._Levels, listener);
            _Questions.compare (otherFactor._Questions, listener);
            _Results.compare (otherFactor._Results, listener);
            _HighLowQuestions.compare (otherFactor._HighLowQuestions, listener);
            _LevelFactorTypes.compare (otherFactor._LevelFactorTypes, listener);
            
        }
    }


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

        
    }


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

        visitor.visitField(this, FIELD_Description, HELPER_Description.toObject(getDescription()));
        visitor.visitAssociation (_Levels);
        visitor.visitAssociation (_Questions);
        visitor.visitAssociation (_Results);
        visitor.visitAssociation (_HighLowQuestions);
        visitor.visitAssociation (_LevelFactorTypes);
        
    }


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

        if (scope.includes (_Levels))
        {
            visitor.visit (_Levels);
        }
        if (scope.includes (_Questions))
        {
            visitor.visit (_Questions);
        }
        if (scope.includes (_Results))
        {
            visitor.visit (_Results);
        }
        if (scope.includes (_HighLowQuestions))
        {
            visitor.visit (_HighLowQuestions);
        }
        if (scope.includes (_LevelFactorTypes))
        {
            visitor.visit (_LevelFactorTypes);
        }
        
    }


    public static Factor createFactor (ObjectTransaction transaction) throws StorageException
    {
        Factor     result = new Factor ();

        result.initialiseNewObject (transaction);

        return result;
    }


    public static Factor getFactorByID (ObjectTransaction transaction, Long objectID) throws StorageException
    {
        return (Factor)(transaction.getObjectByID (REFERENCE_Factor, objectID));
    }

    public boolean testFilter (String attribName, QueryFilter filter) throws StorageException
    {
        if (false)
        {
            throw new RuntimeException ("Game over man!!");
        }
        else if (attribName.equals (FIELD_Description))
        {
            return filter.matches (getDescription ());
        }
        else
        {
            return super.testFilter (attribName, filter);
        }
    }


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

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

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

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

            
            public SearchAll andDescription (QueryFilter<String> filter)
            {
                filter.addFilter (context, "tl_factor.factor_hdr_desc", "Description");
                return this;
            }
            
                public Factor[]
             search (ObjectTransaction transaction) throws StorageException
        {
            
            
            BaseBusinessClass[]     results = super.search (transaction, REFERENCE_Factor, SEARCH_All, criteria);
            Set<Factor>   typedResults = new LinkedHashSet <Factor> ();
            for (BaseBusinessClass bbcResult : results)
            {
                Factor aResult = (Factor)bbcResult;
                
                typedResults.add (aResult);
            }
            
                    return ObjstoreUtils.removeDeleted(transaction, typedResults).toArray (new Factor[0]);
                            
        }
    }

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



    public Object getAttribute (String attribName)
    {
        if (false)
        {
            throw new RuntimeException ("Game over man!!");
        }
        else if (attribName.equals (FIELD_Description))
        {
            return HELPER_Description.toObject (getDescription ());
        }
        else
        {
            return super.getAttribute (attribName);
        }
    }


    public AttributeHelper getAttributeHelper (String attribName)
    {
        if (false)
        {
            throw new RuntimeException ("Game over man!!");
        }
        else if (attribName.equals (FIELD_Description))
        {
            return HELPER_Description;
        }
        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_Description))
        {
            setDescription ((String)(HELPER_Description.fromObject (_Description, 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_Description))
        {
            return getWriteability_Description ();
        }
        else if (fieldName.equals (MULTIPLEREFERENCE_Levels))
        {
            return getWriteability_Levels ();
        }
        else if (fieldName.equals (MULTIPLEREFERENCE_Questions))
        {
            return getWriteability_Questions ();
        }
        else if (fieldName.equals (MULTIPLEREFERENCE_Results))
        {
            return getWriteability_Results ();
        }
        else if (fieldName.equals (MULTIPLEREFERENCE_HighLowQuestions))
        {
            return getWriteability_HighLowQuestions ();
        }
        else if (fieldName.equals (MULTIPLEREFERENCE_LevelFactorTypes))
        {
            return getWriteability_LevelFactorTypes ();
        }
        else
        {
            return super.getWriteable (fieldName);
        }
    }


    public void putUnwriteable (Set<String> fields)
    {
        
            if (getWriteability_Description () != FieldWriteability.TRUE)
            {
                fields.add (FIELD_Description);
            }
        

        super.putUnwriteable (fields);
    }

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

        
        result.add(HELPER_Description.getAttribObject (getClass (), _Description, false, FIELD_Description));

        return result;
    }


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


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

    /**
     * Get the attribute Description
     */
    public String getDescription (Factor obj, String original)
    {
        return original;
    }

    /**
     * Change the value set for attribute Description.
     * May modify the field beforehand
     * Occurs before validation.
     */
    public String setDescription (Factor obj, String newDescription) throws FieldException
    {
        return newDescription;
    }

    }

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

        public FactorPipeLineFactory (Collection<From> seed)
        {
            super(seed);
        }
        
        
        public PipeLine<From, ? extends Object> to(String name)
        {
            if (name.equals ("Levels"))
            {
                return toLevels ();
            }                
            if (name.equals ("Questions"))
            {
                return toQuestions ();
            }                
            if (name.equals ("Results"))
            {
                return toResults ();
            }                
            if (name.equals ("HighLowQuestions"))
            {
                return toHighLowQuestions ();
            }                
            if (name.equals ("LevelFactorTypes"))
            {
                return toLevelFactorTypes ();
            }                
            if (name.equals ("Description"))
            {
                return toDescription ();
            }                
            
            
            return super.to(name);
        }
        
        
        public PipeLine<From, String> toDescription () { return pipe(new ORMAttributePipe<Me, String>(FIELD_Description));  }
        public FactorLevelLink.FactorLevelLinkPipeLineFactory<From, FactorLevelLink> toLevels () { return toLevels(Filter.ALL); }        

        public FactorLevelLink.FactorLevelLinkPipeLineFactory<From, FactorLevelLink> toLevels (Filter<FactorLevelLink> filter)
        {
            return FactorLevelLink.REFERENCE_FactorLevelLink.new FactorLevelLinkPipeLineFactory<From, FactorLevelLink> (this, new ORMMultiAssocPipe<Me, FactorLevelLink>(MULTIPLEREFERENCE_Levels, filter)); 
        }
        public FactorQuestionLink.FactorQuestionLinkPipeLineFactory<From, FactorQuestionLink> toQuestions () { return toQuestions(Filter.ALL); }        

        public FactorQuestionLink.FactorQuestionLinkPipeLineFactory<From, FactorQuestionLink> toQuestions (Filter<FactorQuestionLink> filter)
        {
            return FactorQuestionLink.REFERENCE_FactorQuestionLink.new FactorQuestionLinkPipeLineFactory<From, FactorQuestionLink> (this, new ORMMultiAssocPipe<Me, FactorQuestionLink>(MULTIPLEREFERENCE_Questions, filter)); 
        }
        public FactorScoreResult.FactorScoreResultPipeLineFactory<From, FactorScoreResult> toResults () { return toResults(Filter.ALL); }        

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

        public Question.QuestionPipeLineFactory<From, Question> toHighLowQuestions (Filter<Question> filter)
        {
            return Question.REFERENCE_Question.new QuestionPipeLineFactory<From, Question> (this, new ORMMultiAssocPipe<Me, Question>(MULTIPLEREFERENCE_HighLowQuestions, filter)); 
        }
        public LevelFactorType.LevelFactorTypePipeLineFactory<From, LevelFactorType> toLevelFactorTypes () { return toLevelFactorTypes(Filter.ALL); }        

        public LevelFactorType.LevelFactorTypePipeLineFactory<From, LevelFactorType> toLevelFactorTypes (Filter<LevelFactorType> filter)
        {
            return LevelFactorType.REFERENCE_LevelFactorType.new LevelFactorTypePipeLineFactory<From, LevelFactorType> (this, new ORMMultiAssocPipe<Me, LevelFactorType>(MULTIPLEREFERENCE_LevelFactorTypes, filter)); 
        }
        
    }
    
    public boolean isTransientAttrib(String attribName)
    {
        

        return super.isTransientAttrib(attribName);
    }

    public boolean isTransientSingleReference(String assocName)
    {
        

        return super.isTransientSingleReference(assocName);
    }
}

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

    public void assertValid ()
    {
    }


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


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


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

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


    public FactorQuestionLink getQuestionsAt (int index) throws StorageException
    {
        throw new RuntimeException ("No elements in a dummy object in association Questions");
    }


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

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


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


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

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


    public Question getHighLowQuestionsAt (int index) throws StorageException
    {
        throw new RuntimeException ("No elements in a dummy object in association HighLowQuestions");
    }


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

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


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


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

}

    
