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

import performa.orm.*;



public abstract class BaseMessageTemplate extends BaseBusinessClass
{
    // Reference instance for the object
    public static final MessageTemplate REFERENCE_MessageTemplate = new MessageTemplate ();

    // Reference instance for the object
    public static final MessageTemplate DUMMY_MessageTemplate = new DummyMessageTemplate ();

    // Static constants corresponding to field names
    
    public static final String FIELD_Subject = "Subject";
    public static final String FIELD_ApplicationStatus = "ApplicationStatus";
    public static final String FIELD_Delay = "Delay";
    public static final String FIELD_Variance = "Variance";
    public static final String FIELD_BusinessHoursOnly = "BusinessHoursOnly";
    public static final String FIELD_MessageContent = "MessageContent";

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

    // Static constants corresponding to attribute helpers
    private static final DefaultAttributeHelper<MessageTemplate> HELPER_Subject = DefaultAttributeHelper.INSTANCE;
    private static final EnumeratedAttributeHelper<MessageTemplate, ApplicationStatus> HELPER_ApplicationStatus =  new EnumeratedAttributeHelper<MessageTemplate, ApplicationStatus> (ApplicationStatus.FACTORY_ApplicationStatus);
    private static final DefaultAttributeHelper<MessageTemplate> HELPER_Delay = DefaultAttributeHelper.INSTANCE;
    private static final DefaultAttributeHelper<MessageTemplate> HELPER_Variance = DefaultAttributeHelper.INSTANCE;
    private static final DefaultAttributeHelper<MessageTemplate> HELPER_BusinessHoursOnly = DefaultAttributeHelper.INSTANCE;
    private static final DefaultAttributeHelper<MessageTemplate> HELPER_MessageContent = DefaultAttributeHelper.INSTANCE;
    

    // Private attributes corresponding to business object data
    private String _Subject;
    private ApplicationStatus _ApplicationStatus;
    private Double _Delay;
    private Integer _Variance;
    private Boolean _BusinessHoursOnly;
    private String _MessageContent;
    

    // Private attributes corresponding to single references
    

    // Private attributes corresponding to multiple references
    

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

    // Arrays of validators for each attribute
    private static final AttributeValidator[] FIELD_Subject_Validators;
    private static final AttributeValidator[] FIELD_ApplicationStatus_Validators;
    private static final AttributeValidator[] FIELD_Delay_Validators;
    private static final AttributeValidator[] FIELD_Variance_Validators;
    private static final AttributeValidator[] FIELD_BusinessHoursOnly_Validators;
    private static final AttributeValidator[] FIELD_MessageContent_Validators;
    

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

            FIELD_Subject_Validators = (AttributeValidator[])setupAttribMetaData_Subject(validatorMapping).toArray (new AttributeValidator[0]);
            FIELD_ApplicationStatus_Validators = (AttributeValidator[])setupAttribMetaData_ApplicationStatus(validatorMapping).toArray (new AttributeValidator[0]);
            FIELD_Delay_Validators = (AttributeValidator[])setupAttribMetaData_Delay(validatorMapping).toArray (new AttributeValidator[0]);
            FIELD_Variance_Validators = (AttributeValidator[])setupAttribMetaData_Variance(validatorMapping).toArray (new AttributeValidator[0]);
            FIELD_BusinessHoursOnly_Validators = (AttributeValidator[])setupAttribMetaData_BusinessHoursOnly(validatorMapping).toArray (new AttributeValidator[0]);
            FIELD_MessageContent_Validators = (AttributeValidator[])setupAttribMetaData_MessageContent(validatorMapping).toArray (new AttributeValidator[0]);
            

            REFERENCE_MessageTemplate.initialiseReference ();
            DUMMY_MessageTemplate.initialiseReference ();
            MessageTemplate_BehaviourDecorators = BaseBusinessClass.getBBCBehaviours(MessageTemplate.class).toArray(new MessageTemplateBehaviourDecorator[0]);
        }
        catch (RuntimeException e)
        {
            LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR1, e, "Error initialising");
            throw e;
        }
    }

    
    // Meta Info setup
    private static List setupAttribMetaData_Subject(Map validatorMapping)
    {
        Map  metaInfo   = new HashMap ();

        metaInfo.put ("dbcol", "subject");
        metaInfo.put ("length", "200");
        metaInfo.put ("mandatory", "false");
        metaInfo.put ("name", "Subject");
        metaInfo.put ("type", "String");
        
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for MessageTemplate.Subject:", metaInfo);
        ATTRIBUTES_METADATA_MessageTemplate.put (FIELD_Subject, Collections.unmodifiableMap (metaInfo));

        List validators = BaseBusinessClass.getAttribValidators(MessageTemplate.class, "Subject", metaInfo, validatorMapping);
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for MessageTemplate.Subject:", 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", "false");
        metaInfo.put ("name", "ApplicationStatus");
        metaInfo.put ("type", "ApplicationStatus");
        
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for MessageTemplate.ApplicationStatus:", metaInfo);
        ATTRIBUTES_METADATA_MessageTemplate.put (FIELD_ApplicationStatus, Collections.unmodifiableMap (metaInfo));

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

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

        metaInfo.put ("dbcol", "delay");
        metaInfo.put ("mandatory", "false");
        metaInfo.put ("name", "Delay");
        metaInfo.put ("type", "Double");
        
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for MessageTemplate.Delay:", metaInfo);
        ATTRIBUTES_METADATA_MessageTemplate.put (FIELD_Delay, Collections.unmodifiableMap (metaInfo));

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

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

        metaInfo.put ("dbcol", "variance");
        metaInfo.put ("mandatory", "false");
        metaInfo.put ("name", "Variance");
        metaInfo.put ("type", "Integer");
        
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for MessageTemplate.Variance:", metaInfo);
        ATTRIBUTES_METADATA_MessageTemplate.put (FIELD_Variance, Collections.unmodifiableMap (metaInfo));

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

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

        metaInfo.put ("dbcol", "business_hours_only");
        metaInfo.put ("mandatory", "false");
        metaInfo.put ("name", "BusinessHoursOnly");
        metaInfo.put ("type", "Boolean");
        
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for MessageTemplate.BusinessHoursOnly:", metaInfo);
        ATTRIBUTES_METADATA_MessageTemplate.put (FIELD_BusinessHoursOnly, Collections.unmodifiableMap (metaInfo));

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

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

        metaInfo.put ("dbcol", "message_content");
        metaInfo.put ("mandatory", "false");
        metaInfo.put ("name", "MessageContent");
        metaInfo.put ("type", "String");
        
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for MessageTemplate.MessageContent:", metaInfo);
        ATTRIBUTES_METADATA_MessageTemplate.put (FIELD_MessageContent, Collections.unmodifiableMap (metaInfo));

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

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


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


    


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

        
        _Subject = (String)(HELPER_Subject.initialise (_Subject));
        _ApplicationStatus = (ApplicationStatus)(ApplicationStatus.DRAFT);
        _Delay = (Double)(HELPER_Delay.initialise (_Delay));
        _Variance = (Integer)(HELPER_Variance.initialise (_Variance));
        _BusinessHoursOnly = (Boolean)(HELPER_BusinessHoursOnly.initialise (_BusinessHoursOnly));
        _MessageContent = (String)(HELPER_MessageContent.initialise (_MessageContent));
    }


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

        
    }


    // Initialise the associations
    protected BaseBusinessClass initialiseReference ()
    {
        super.initialiseReference ();
        
        
        
        return this;
    }

    

    /**
     * Get the attribute Subject
     */
    public String getSubject ()
    {
        assertValid();
        String valToReturn = _Subject;

            for (MessageTemplateBehaviourDecorator bhd : MessageTemplate_BehaviourDecorators)
            {
                valToReturn = bhd.getSubject ((MessageTemplate)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 preSubjectChange (String newSubject) 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 postSubjectChange () throws FieldException
    {
    }

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

    /**
     * Set the attribute Subject.  Checks to ensure a new value
     * has been supplied.  If so, marks the field as altered and sets the attribute.
     */
    public void setSubject (String newSubject) throws FieldException
    {
        boolean oldAndNewIdentical = HELPER_Subject.compare (_Subject, newSubject);
        
        try
        {
            for (MessageTemplateBehaviourDecorator bhd : MessageTemplate_BehaviourDecorators)
            {
                newSubject = bhd.setSubject ((MessageTemplate)this, newSubject);
                oldAndNewIdentical = HELPER_Subject.compare (_Subject, newSubject);
            }

            

            if (FIELD_Subject_Validators.length > 0)
            {
                Object newSubjectObj = HELPER_Subject.toObject (newSubject);

                if (newSubjectObj != null)
                {
                    int     loopMax = FIELD_Subject_Validators.length;
                    Map     metadata = (Map)ATTRIBUTES_METADATA_MessageTemplate.get (FIELD_Subject);

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

        if (!oldAndNewIdentical)
        {
            assertValid();
            Debug.assertion (getWriteability_Subject () != FieldWriteability.FALSE, "Field  Subject is not writeable");
            preSubjectChange (newSubject);
            markFieldChange (FIELD_Subject);
            _Subject = newSubject;            
            postFieldChange (FIELD_Subject);
            postSubjectChange ();
        }
    }

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

            for (MessageTemplateBehaviourDecorator bhd : MessageTemplate_BehaviourDecorators)
            {
                valToReturn = bhd.getApplicationStatus ((MessageTemplate)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 (MessageTemplateBehaviourDecorator bhd : MessageTemplate_BehaviourDecorators)
            {
                newApplicationStatus = bhd.setApplicationStatus ((MessageTemplate)this, newApplicationStatus);
                oldAndNewIdentical = HELPER_ApplicationStatus.compare (_ApplicationStatus, newApplicationStatus);
            }

            

            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_MessageTemplate.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 Delay
     */
    public Double getDelay ()
    {
        assertValid();
        Double valToReturn = _Delay;

            for (MessageTemplateBehaviourDecorator bhd : MessageTemplate_BehaviourDecorators)
            {
                valToReturn = bhd.getDelay ((MessageTemplate)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 preDelayChange (Double newDelay) 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 postDelayChange () throws FieldException
    {
    }

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

    /**
     * Set the attribute Delay.  Checks to ensure a new value
     * has been supplied.  If so, marks the field as altered and sets the attribute.
     */
    public void setDelay (Double newDelay) throws FieldException
    {
        boolean oldAndNewIdentical = HELPER_Delay.compare (_Delay, newDelay);
        
        try
        {
            for (MessageTemplateBehaviourDecorator bhd : MessageTemplate_BehaviourDecorators)
            {
                newDelay = bhd.setDelay ((MessageTemplate)this, newDelay);
                oldAndNewIdentical = HELPER_Delay.compare (_Delay, newDelay);
            }

            

            if (FIELD_Delay_Validators.length > 0)
            {
                Object newDelayObj = HELPER_Delay.toObject (newDelay);

                if (newDelayObj != null)
                {
                    int     loopMax = FIELD_Delay_Validators.length;
                    Map     metadata = (Map)ATTRIBUTES_METADATA_MessageTemplate.get (FIELD_Delay);

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

        if (!oldAndNewIdentical)
        {
            assertValid();
            Debug.assertion (getWriteability_Delay () != FieldWriteability.FALSE, "Field  Delay is not writeable");
            preDelayChange (newDelay);
            markFieldChange (FIELD_Delay);
            _Delay = newDelay;            
            postFieldChange (FIELD_Delay);
            postDelayChange ();
        }
    }

    /**
     * Get the attribute Variance
     */
    public Integer getVariance ()
    {
        assertValid();
        Integer valToReturn = _Variance;

            for (MessageTemplateBehaviourDecorator bhd : MessageTemplate_BehaviourDecorators)
            {
                valToReturn = bhd.getVariance ((MessageTemplate)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 preVarianceChange (Integer newVariance) 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 postVarianceChange () throws FieldException
    {
    }

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

    /**
     * Set the attribute Variance.  Checks to ensure a new value
     * has been supplied.  If so, marks the field as altered and sets the attribute.
     */
    public void setVariance (Integer newVariance) throws FieldException
    {
        boolean oldAndNewIdentical = HELPER_Variance.compare (_Variance, newVariance);
        
        try
        {
            for (MessageTemplateBehaviourDecorator bhd : MessageTemplate_BehaviourDecorators)
            {
                newVariance = bhd.setVariance ((MessageTemplate)this, newVariance);
                oldAndNewIdentical = HELPER_Variance.compare (_Variance, newVariance);
            }

            

            if (FIELD_Variance_Validators.length > 0)
            {
                Object newVarianceObj = HELPER_Variance.toObject (newVariance);

                if (newVarianceObj != null)
                {
                    int     loopMax = FIELD_Variance_Validators.length;
                    Map     metadata = (Map)ATTRIBUTES_METADATA_MessageTemplate.get (FIELD_Variance);

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

        if (!oldAndNewIdentical)
        {
            assertValid();
            Debug.assertion (getWriteability_Variance () != FieldWriteability.FALSE, "Field  Variance is not writeable");
            preVarianceChange (newVariance);
            markFieldChange (FIELD_Variance);
            _Variance = newVariance;            
            postFieldChange (FIELD_Variance);
            postVarianceChange ();
        }
    }

    /**
     * Get the attribute BusinessHoursOnly
     */
    public Boolean getBusinessHoursOnly ()
    {
        assertValid();
        Boolean valToReturn = _BusinessHoursOnly;

            for (MessageTemplateBehaviourDecorator bhd : MessageTemplate_BehaviourDecorators)
            {
                valToReturn = bhd.getBusinessHoursOnly ((MessageTemplate)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 preBusinessHoursOnlyChange (Boolean newBusinessHoursOnly) 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 postBusinessHoursOnlyChange () throws FieldException
    {
    }

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

    /**
     * Set the attribute BusinessHoursOnly.  Checks to ensure a new value
     * has been supplied.  If so, marks the field as altered and sets the attribute.
     */
    public void setBusinessHoursOnly (Boolean newBusinessHoursOnly) throws FieldException
    {
        boolean oldAndNewIdentical = HELPER_BusinessHoursOnly.compare (_BusinessHoursOnly, newBusinessHoursOnly);
        
        try
        {
            for (MessageTemplateBehaviourDecorator bhd : MessageTemplate_BehaviourDecorators)
            {
                newBusinessHoursOnly = bhd.setBusinessHoursOnly ((MessageTemplate)this, newBusinessHoursOnly);
                oldAndNewIdentical = HELPER_BusinessHoursOnly.compare (_BusinessHoursOnly, newBusinessHoursOnly);
            }

            

            if (FIELD_BusinessHoursOnly_Validators.length > 0)
            {
                Object newBusinessHoursOnlyObj = HELPER_BusinessHoursOnly.toObject (newBusinessHoursOnly);

                if (newBusinessHoursOnlyObj != null)
                {
                    int     loopMax = FIELD_BusinessHoursOnly_Validators.length;
                    Map     metadata = (Map)ATTRIBUTES_METADATA_MessageTemplate.get (FIELD_BusinessHoursOnly);

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

        if (!oldAndNewIdentical)
        {
            assertValid();
            Debug.assertion (getWriteability_BusinessHoursOnly () != FieldWriteability.FALSE, "Field  BusinessHoursOnly is not writeable");
            preBusinessHoursOnlyChange (newBusinessHoursOnly);
            markFieldChange (FIELD_BusinessHoursOnly);
            _BusinessHoursOnly = newBusinessHoursOnly;            
            postFieldChange (FIELD_BusinessHoursOnly);
            postBusinessHoursOnlyChange ();
        }
    }

    /**
     * Get the attribute MessageContent
     */
    public String getMessageContent ()
    {
        assertValid();
        String valToReturn = _MessageContent;

            for (MessageTemplateBehaviourDecorator bhd : MessageTemplate_BehaviourDecorators)
            {
                valToReturn = bhd.getMessageContent ((MessageTemplate)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 preMessageContentChange (String newMessageContent) 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 postMessageContentChange () throws FieldException
    {
    }

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

    /**
     * Set the attribute MessageContent.  Checks to ensure a new value
     * has been supplied.  If so, marks the field as altered and sets the attribute.
     */
    public void setMessageContent (String newMessageContent) throws FieldException
    {
        boolean oldAndNewIdentical = HELPER_MessageContent.compare (_MessageContent, newMessageContent);
        
        try
        {
            for (MessageTemplateBehaviourDecorator bhd : MessageTemplate_BehaviourDecorators)
            {
                newMessageContent = bhd.setMessageContent ((MessageTemplate)this, newMessageContent);
                oldAndNewIdentical = HELPER_MessageContent.compare (_MessageContent, newMessageContent);
            }

            

            if (FIELD_MessageContent_Validators.length > 0)
            {
                Object newMessageContentObj = HELPER_MessageContent.toObject (newMessageContent);

                if (newMessageContentObj != null)
                {
                    int     loopMax = FIELD_MessageContent_Validators.length;
                    Map     metadata = (Map)ATTRIBUTES_METADATA_MessageTemplate.get (FIELD_MessageContent);

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

        if (!oldAndNewIdentical)
        {
            assertValid();
            Debug.assertion (getWriteability_MessageContent () != FieldWriteability.FALSE, "Field  MessageContent is not writeable");
            preMessageContentChange (newMessageContent);
            markFieldChange (FIELD_MessageContent);
            _MessageContent = newMessageContent;            
            postFieldChange (FIELD_MessageContent);
            postMessageContentChange ();
        }
    }



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

        

        return result;
    }


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

        return super.getMultiAssocReferenceInstance(attribName);
    }


    public String getMultiAssocBackReference(String attribName)
    {
        

        return super.getMultiAssocBackReference(attribName);
    }


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

        return super.getMultiAssocCount(attribName);
    }


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

        return super.getMultiAssocAt(attribName, index);
    }


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

        super.addToMultiAssoc(attribName, newElement);
    }

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

        super.removeFromMultiAssoc(attribName, oldElement);
    }


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

        super.__loadMultiAssoc(attribName, elements);
    }


    protected boolean __isMultiAssocLoaded (String attribName)
    {
        

        return super.__isMultiAssocLoaded(attribName);
    }

    



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

        super.onDelete ();
    }


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


    public MessageTemplate referenceInstance ()
    {
        return REFERENCE_MessageTemplate;
    }


    public MessageTemplate getInTransaction (ObjectTransaction t) throws StorageException
    {
        return getMessageTemplateByID (t, getObjectID());
    }
    
    
    public BaseBusinessClass dummyInstance ()
    {
        return DUMMY_MessageTemplate;
    }


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





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

        tl_message_templatePSet.setAttrib (FIELD_ObjectID, myID);
        tl_message_templatePSet.setAttrib (FIELD_Subject, HELPER_Subject.toObject (_Subject)); //
        tl_message_templatePSet.setAttrib (FIELD_ApplicationStatus, HELPER_ApplicationStatus.toObject (_ApplicationStatus)); //
        tl_message_templatePSet.setAttrib (FIELD_Delay, HELPER_Delay.toObject (_Delay)); //
        tl_message_templatePSet.setAttrib (FIELD_Variance, HELPER_Variance.toObject (_Variance)); //
        tl_message_templatePSet.setAttrib (FIELD_BusinessHoursOnly, HELPER_BusinessHoursOnly.toObject (_BusinessHoursOnly)); //
        tl_message_templatePSet.setAttrib (FIELD_MessageContent, HELPER_MessageContent.toObject (_MessageContent)); //
        
    }


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

        
        PersistentSet   tl_message_templatePSet = allSets.getPersistentSet (objectID, "tl_message_template");

        _Subject = (String)(HELPER_Subject.fromObject (_Subject, tl_message_templatePSet.getAttrib (FIELD_Subject))); //
        _ApplicationStatus = (ApplicationStatus)(HELPER_ApplicationStatus.fromObject (_ApplicationStatus, tl_message_templatePSet.getAttrib (FIELD_ApplicationStatus))); //
        _Delay = (Double)(HELPER_Delay.fromObject (_Delay, tl_message_templatePSet.getAttrib (FIELD_Delay))); //
        _Variance = (Integer)(HELPER_Variance.fromObject (_Variance, tl_message_templatePSet.getAttrib (FIELD_Variance))); //
        _BusinessHoursOnly = (Boolean)(HELPER_BusinessHoursOnly.fromObject (_BusinessHoursOnly, tl_message_templatePSet.getAttrib (FIELD_BusinessHoursOnly))); //
        _MessageContent = (String)(HELPER_MessageContent.fromObject (_MessageContent, tl_message_templatePSet.getAttrib (FIELD_MessageContent))); //
        
    }





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

        if (other instanceof MessageTemplate)
        {
            MessageTemplate otherMessageTemplate = (MessageTemplate)other;
            
            try
            {
                setSubject (otherMessageTemplate.getSubject ());
            }
            catch (FieldException ex)
            {
                e.addException (ex);
            }
            
            try
            {
                setApplicationStatus (otherMessageTemplate.getApplicationStatus ());
            }
            catch (FieldException ex)
            {
                e.addException (ex);
            }
            
            try
            {
                setDelay (otherMessageTemplate.getDelay ());
            }
            catch (FieldException ex)
            {
                e.addException (ex);
            }
            
            try
            {
                setVariance (otherMessageTemplate.getVariance ());
            }
            catch (FieldException ex)
            {
                e.addException (ex);
            }
            
            try
            {
                setBusinessHoursOnly (otherMessageTemplate.getBusinessHoursOnly ());
            }
            catch (FieldException ex)
            {
                e.addException (ex);
            }
            
            try
            {
                setMessageContent (otherMessageTemplate.getMessageContent ());
            }
            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 BaseMessageTemplate)
        {
            BaseMessageTemplate sourceMessageTemplate = (BaseMessageTemplate)(source);

            _Subject = sourceMessageTemplate._Subject;
            _ApplicationStatus = sourceMessageTemplate._ApplicationStatus;
            _Delay = sourceMessageTemplate._Delay;
            _Variance = sourceMessageTemplate._Variance;
            _BusinessHoursOnly = sourceMessageTemplate._BusinessHoursOnly;
            _MessageContent = sourceMessageTemplate._MessageContent;
            
        }
    }


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

            
        }
    }


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

        
    }


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

        _Subject = (String)(HELPER_Subject.readExternal (_Subject, vals.get(FIELD_Subject))); //
        _ApplicationStatus = (ApplicationStatus)(HELPER_ApplicationStatus.readExternal (_ApplicationStatus, vals.get(FIELD_ApplicationStatus))); //
        _Delay = (Double)(HELPER_Delay.readExternal (_Delay, vals.get(FIELD_Delay))); //
        _Variance = (Integer)(HELPER_Variance.readExternal (_Variance, vals.get(FIELD_Variance))); //
        _BusinessHoursOnly = (Boolean)(HELPER_BusinessHoursOnly.readExternal (_BusinessHoursOnly, vals.get(FIELD_BusinessHoursOnly))); //
        _MessageContent = (String)(HELPER_MessageContent.readExternal (_MessageContent, vals.get(FIELD_MessageContent))); //
        
    }


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

        vals.put (FIELD_Subject, HELPER_Subject.writeExternal (_Subject));
        vals.put (FIELD_ApplicationStatus, HELPER_ApplicationStatus.writeExternal (_ApplicationStatus));
        vals.put (FIELD_Delay, HELPER_Delay.writeExternal (_Delay));
        vals.put (FIELD_Variance, HELPER_Variance.writeExternal (_Variance));
        vals.put (FIELD_BusinessHoursOnly, HELPER_BusinessHoursOnly.writeExternal (_BusinessHoursOnly));
        vals.put (FIELD_MessageContent, HELPER_MessageContent.writeExternal (_MessageContent));
        
    }


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

        if (other instanceof BaseMessageTemplate)
        {
            BaseMessageTemplate otherMessageTemplate = (BaseMessageTemplate)(other);

            
            if (!HELPER_Subject.compare(this._Subject, otherMessageTemplate._Subject))
            {
                listener.notifyFieldChange(this, other, FIELD_Subject, HELPER_Subject.toObject(this._Subject), HELPER_Subject.toObject(otherMessageTemplate._Subject));
            }
            if (!HELPER_ApplicationStatus.compare(this._ApplicationStatus, otherMessageTemplate._ApplicationStatus))
            {
                listener.notifyFieldChange(this, other, FIELD_ApplicationStatus, HELPER_ApplicationStatus.toObject(this._ApplicationStatus), HELPER_ApplicationStatus.toObject(otherMessageTemplate._ApplicationStatus));
            }
            if (!HELPER_Delay.compare(this._Delay, otherMessageTemplate._Delay))
            {
                listener.notifyFieldChange(this, other, FIELD_Delay, HELPER_Delay.toObject(this._Delay), HELPER_Delay.toObject(otherMessageTemplate._Delay));
            }
            if (!HELPER_Variance.compare(this._Variance, otherMessageTemplate._Variance))
            {
                listener.notifyFieldChange(this, other, FIELD_Variance, HELPER_Variance.toObject(this._Variance), HELPER_Variance.toObject(otherMessageTemplate._Variance));
            }
            if (!HELPER_BusinessHoursOnly.compare(this._BusinessHoursOnly, otherMessageTemplate._BusinessHoursOnly))
            {
                listener.notifyFieldChange(this, other, FIELD_BusinessHoursOnly, HELPER_BusinessHoursOnly.toObject(this._BusinessHoursOnly), HELPER_BusinessHoursOnly.toObject(otherMessageTemplate._BusinessHoursOnly));
            }
            if (!HELPER_MessageContent.compare(this._MessageContent, otherMessageTemplate._MessageContent))
            {
                listener.notifyFieldChange(this, other, FIELD_MessageContent, HELPER_MessageContent.toObject(this._MessageContent), HELPER_MessageContent.toObject(otherMessageTemplate._MessageContent));
            }

            // Compare single assocs
            

            // Compare multiple assocs
            
        }
    }


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

        
    }


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

        visitor.visitField(this, FIELD_Subject, HELPER_Subject.toObject(getSubject()));
        visitor.visitField(this, FIELD_ApplicationStatus, HELPER_ApplicationStatus.toObject(getApplicationStatus()));
        visitor.visitField(this, FIELD_Delay, HELPER_Delay.toObject(getDelay()));
        visitor.visitField(this, FIELD_Variance, HELPER_Variance.toObject(getVariance()));
        visitor.visitField(this, FIELD_BusinessHoursOnly, HELPER_BusinessHoursOnly.toObject(getBusinessHoursOnly()));
        visitor.visitField(this, FIELD_MessageContent, HELPER_MessageContent.toObject(getMessageContent()));
        
    }


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

        
    }


    public static MessageTemplate createMessageTemplate (ObjectTransaction transaction) throws StorageException
    {
        MessageTemplate     result = new MessageTemplate ();

        result.initialiseNewObject (transaction);

        return result;
    }


    public static MessageTemplate getMessageTemplateByID (ObjectTransaction transaction, Long objectID) throws StorageException
    {
        return (MessageTemplate)(transaction.getObjectByID (REFERENCE_MessageTemplate, objectID));
    }

    public boolean testFilter (String attribName, QueryFilter filter) throws StorageException
    {
        if (false)
        {
            throw new RuntimeException ("Game over man!!");
        }
        else if (attribName.equals (FIELD_Subject))
        {
            return filter.matches (getSubject ());
        }
        else if (attribName.equals (FIELD_ApplicationStatus))
        {
            return filter.matches (getApplicationStatus ());
        }
        else if (attribName.equals (FIELD_Delay))
        {
            return filter.matches (getDelay ());
        }
        else if (attribName.equals (FIELD_Variance))
        {
            return filter.matches (getVariance ());
        }
        else if (attribName.equals (FIELD_BusinessHoursOnly))
        {
            return filter.matches (getBusinessHoursOnly ());
        }
        else if (attribName.equals (FIELD_MessageContent))
        {
            return filter.matches (getMessageContent ());
        }
        else
        {
            return super.testFilter (attribName, filter);
        }
    }


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

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

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

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

            
            public SearchAll andSubject (QueryFilter<String> filter)
            {
                filter.addFilter (context, "tl_message_template.subject", "Subject");
                return this;
            }
            
            public SearchAll andApplicationStatus (QueryFilter<ApplicationStatus> filter)
            {
                filter.addFilter (context, "tl_message_template.application_status", "ApplicationStatus");
                return this;
            }
            
            public SearchAll andDelay (QueryFilter<Double> filter)
            {
                filter.addFilter (context, "tl_message_template.delay", "Delay");
                return this;
            }
            
            public SearchAll andVariance (QueryFilter<Integer> filter)
            {
                filter.addFilter (context, "tl_message_template.variance", "Variance");
                return this;
            }
            
            public SearchAll andBusinessHoursOnly (QueryFilter<Boolean> filter)
            {
                filter.addFilter (context, "tl_message_template.business_hours_only", "BusinessHoursOnly");
                return this;
            }
            
            public SearchAll andMessageContent (QueryFilter<String> filter)
            {
                filter.addFilter (context, "tl_message_template.message_content", "MessageContent");
                return this;
            }
            
                public MessageTemplate[]
             search (ObjectTransaction transaction) throws StorageException
        {
            
            
            BaseBusinessClass[]     results = super.search (transaction, REFERENCE_MessageTemplate, SEARCH_All, criteria);
            Set<MessageTemplate>   typedResults = new LinkedHashSet <MessageTemplate> ();
            for (BaseBusinessClass bbcResult : results)
            {
                MessageTemplate aResult = (MessageTemplate)bbcResult;
                
                typedResults.add (aResult);
            }
            
                    return ObjstoreUtils.removeDeleted(transaction, typedResults).toArray (new MessageTemplate[0]);
                            
        }
    }

        
                public static MessageTemplate[]
             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_Subject))
        {
            return HELPER_Subject.toObject (getSubject ());
        }
        else if (attribName.equals (FIELD_ApplicationStatus))
        {
            return HELPER_ApplicationStatus.toObject (getApplicationStatus ());
        }
        else if (attribName.equals (FIELD_Delay))
        {
            return HELPER_Delay.toObject (getDelay ());
        }
        else if (attribName.equals (FIELD_Variance))
        {
            return HELPER_Variance.toObject (getVariance ());
        }
        else if (attribName.equals (FIELD_BusinessHoursOnly))
        {
            return HELPER_BusinessHoursOnly.toObject (getBusinessHoursOnly ());
        }
        else if (attribName.equals (FIELD_MessageContent))
        {
            return HELPER_MessageContent.toObject (getMessageContent ());
        }
        else
        {
            return super.getAttribute (attribName);
        }
    }


    public AttributeHelper getAttributeHelper (String attribName)
    {
        if (false)
        {
            throw new RuntimeException ("Game over man!!");
        }
        else if (attribName.equals (FIELD_Subject))
        {
            return HELPER_Subject;
        }
        else if (attribName.equals (FIELD_ApplicationStatus))
        {
            return HELPER_ApplicationStatus;
        }
        else if (attribName.equals (FIELD_Delay))
        {
            return HELPER_Delay;
        }
        else if (attribName.equals (FIELD_Variance))
        {
            return HELPER_Variance;
        }
        else if (attribName.equals (FIELD_BusinessHoursOnly))
        {
            return HELPER_BusinessHoursOnly;
        }
        else if (attribName.equals (FIELD_MessageContent))
        {
            return HELPER_MessageContent;
        }
        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_Subject))
        {
            setSubject ((String)(HELPER_Subject.fromObject (_Subject, attribValue)));            
        }
        else if (attribName.equals (FIELD_ApplicationStatus))
        {
            setApplicationStatus ((ApplicationStatus)(HELPER_ApplicationStatus.fromObject (_ApplicationStatus, attribValue)));            
        }
        else if (attribName.equals (FIELD_Delay))
        {
            setDelay ((Double)(HELPER_Delay.fromObject (_Delay, attribValue)));            
        }
        else if (attribName.equals (FIELD_Variance))
        {
            setVariance ((Integer)(HELPER_Variance.fromObject (_Variance, attribValue)));            
        }
        else if (attribName.equals (FIELD_BusinessHoursOnly))
        {
            setBusinessHoursOnly ((Boolean)(HELPER_BusinessHoursOnly.fromObject (_BusinessHoursOnly, attribValue)));            
        }
        else if (attribName.equals (FIELD_MessageContent))
        {
            setMessageContent ((String)(HELPER_MessageContent.fromObject (_MessageContent, 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_Subject))
        {
            return getWriteability_Subject ();
        }
        else if (fieldName.equals (FIELD_ApplicationStatus))
        {
            return getWriteability_ApplicationStatus ();
        }
        else if (fieldName.equals (FIELD_Delay))
        {
            return getWriteability_Delay ();
        }
        else if (fieldName.equals (FIELD_Variance))
        {
            return getWriteability_Variance ();
        }
        else if (fieldName.equals (FIELD_BusinessHoursOnly))
        {
            return getWriteability_BusinessHoursOnly ();
        }
        else if (fieldName.equals (FIELD_MessageContent))
        {
            return getWriteability_MessageContent ();
        }
        else
        {
            return super.getWriteable (fieldName);
        }
    }


    public void putUnwriteable (Set<String> fields)
    {
        
            if (getWriteability_Subject () != FieldWriteability.TRUE)
            {
                fields.add (FIELD_Subject);
            }
        
            if (getWriteability_ApplicationStatus () != FieldWriteability.TRUE)
            {
                fields.add (FIELD_ApplicationStatus);
            }
        
            if (getWriteability_Delay () != FieldWriteability.TRUE)
            {
                fields.add (FIELD_Delay);
            }
        
            if (getWriteability_Variance () != FieldWriteability.TRUE)
            {
                fields.add (FIELD_Variance);
            }
        
            if (getWriteability_BusinessHoursOnly () != FieldWriteability.TRUE)
            {
                fields.add (FIELD_BusinessHoursOnly);
            }
        
            if (getWriteability_MessageContent () != FieldWriteability.TRUE)
            {
                fields.add (FIELD_MessageContent);
            }
        

        super.putUnwriteable (fields);
    }

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

        
        result.add(HELPER_Subject.getAttribObject (getClass (), _Subject, false, FIELD_Subject));
        result.add(HELPER_ApplicationStatus.getAttribObject (getClass (), _ApplicationStatus, false, FIELD_ApplicationStatus));
        result.add(HELPER_Delay.getAttribObject (getClass (), _Delay, false, FIELD_Delay));
        result.add(HELPER_Variance.getAttribObject (getClass (), _Variance, false, FIELD_Variance));
        result.add(HELPER_BusinessHoursOnly.getAttribObject (getClass (), _BusinessHoursOnly, false, FIELD_BusinessHoursOnly));
        result.add(HELPER_MessageContent.getAttribObject (getClass (), _MessageContent, false, FIELD_MessageContent));

        return result;
    }


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


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

    /**
     * Get the attribute Subject
     */
    public String getSubject (MessageTemplate obj, String original)
    {
        return original;
    }

    /**
     * Change the value set for attribute Subject.
     * May modify the field beforehand
     * Occurs before validation.
     */
    public String setSubject (MessageTemplate obj, String newSubject) throws FieldException
    {
        return newSubject;
    }

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

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

    /**
     * Get the attribute Delay
     */
    public Double getDelay (MessageTemplate obj, Double original)
    {
        return original;
    }

    /**
     * Change the value set for attribute Delay.
     * May modify the field beforehand
     * Occurs before validation.
     */
    public Double setDelay (MessageTemplate obj, Double newDelay) throws FieldException
    {
        return newDelay;
    }

    /**
     * Get the attribute Variance
     */
    public Integer getVariance (MessageTemplate obj, Integer original)
    {
        return original;
    }

    /**
     * Change the value set for attribute Variance.
     * May modify the field beforehand
     * Occurs before validation.
     */
    public Integer setVariance (MessageTemplate obj, Integer newVariance) throws FieldException
    {
        return newVariance;
    }

    /**
     * Get the attribute BusinessHoursOnly
     */
    public Boolean getBusinessHoursOnly (MessageTemplate obj, Boolean original)
    {
        return original;
    }

    /**
     * Change the value set for attribute BusinessHoursOnly.
     * May modify the field beforehand
     * Occurs before validation.
     */
    public Boolean setBusinessHoursOnly (MessageTemplate obj, Boolean newBusinessHoursOnly) throws FieldException
    {
        return newBusinessHoursOnly;
    }

    /**
     * Get the attribute MessageContent
     */
    public String getMessageContent (MessageTemplate obj, String original)
    {
        return original;
    }

    /**
     * Change the value set for attribute MessageContent.
     * May modify the field beforehand
     * Occurs before validation.
     */
    public String setMessageContent (MessageTemplate obj, String newMessageContent) throws FieldException
    {
        return newMessageContent;
    }

    }

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

        public MessageTemplatePipeLineFactory (Collection<From> seed)
        {
            super(seed);
        }
        
        
        public PipeLine<From, ? extends Object> to(String name)
        {
            if (name.equals ("Subject"))
            {
                return toSubject ();
            }                
            if (name.equals ("ApplicationStatus"))
            {
                return toApplicationStatus ();
            }                
            if (name.equals ("Delay"))
            {
                return toDelay ();
            }                
            if (name.equals ("Variance"))
            {
                return toVariance ();
            }                
            if (name.equals ("BusinessHoursOnly"))
            {
                return toBusinessHoursOnly ();
            }                
            if (name.equals ("MessageContent"))
            {
                return toMessageContent ();
            }                
            
            
            return super.to(name);
        }
        
        
        public PipeLine<From, String> toSubject () { return pipe(new ORMAttributePipe<Me, String>(FIELD_Subject));  }
        
        public PipeLine<From, ApplicationStatus> toApplicationStatus () { return pipe(new ORMAttributePipe<Me, ApplicationStatus>(FIELD_ApplicationStatus));  }
        
        public PipeLine<From, Double> toDelay () { return pipe(new ORMAttributePipe<Me, Double>(FIELD_Delay));  }
        
        public PipeLine<From, Integer> toVariance () { return pipe(new ORMAttributePipe<Me, Integer>(FIELD_Variance));  }
        
        public PipeLine<From, Boolean> toBusinessHoursOnly () { return pipe(new ORMAttributePipe<Me, Boolean>(FIELD_BusinessHoursOnly));  }
        
        public PipeLine<From, String> toMessageContent () { return pipe(new ORMAttributePipe<Me, String>(FIELD_MessageContent));  }
        
    }
    
    public boolean isTransientAttrib(String attribName)
    {
        

        return super.isTransientAttrib(attribName);
    }

    public boolean isTransientSingleReference(String assocName)
    {
        

        return super.isTransientSingleReference(assocName);
    }
}

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

    public void assertValid ()
    {
    }


}

