/*
 * 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_MessageID = "MessageID";
    public static final String FIELD_TemplateName = "TemplateName";
    public static final String FIELD_Subject = "Subject";
    public static final String FIELD_ApplicationStatus = "ApplicationStatus";
    public static final String FIELD_DelayHrs = "DelayHrs";
    public static final String FIELD_DelayMin = "DelayMin";
    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_MessageID = DefaultAttributeHelper.INSTANCE;
    private static final DefaultAttributeHelper<MessageTemplate> HELPER_TemplateName = DefaultAttributeHelper.INSTANCE;
    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_DelayHrs = DefaultAttributeHelper.INSTANCE;
    private static final DefaultAttributeHelper<MessageTemplate> HELPER_DelayMin = 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 Integer _MessageID;
    private String _TemplateName;
    private String _Subject;
    private ApplicationStatus _ApplicationStatus;
    private Integer _DelayHrs;
    private Integer _DelayMin;
    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_MessageID_Validators;
    private static final AttributeValidator[] FIELD_TemplateName_Validators;
    private static final AttributeValidator[] FIELD_Subject_Validators;
    private static final AttributeValidator[] FIELD_ApplicationStatus_Validators;
    private static final AttributeValidator[] FIELD_DelayHrs_Validators;
    private static final AttributeValidator[] FIELD_DelayMin_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_MessageID_Validators = (AttributeValidator[])setupAttribMetaData_MessageID(validatorMapping).toArray (new AttributeValidator[0]);
            FIELD_TemplateName_Validators = (AttributeValidator[])setupAttribMetaData_TemplateName(validatorMapping).toArray (new AttributeValidator[0]);
            FIELD_Subject_Validators = (AttributeValidator[])setupAttribMetaData_Subject(validatorMapping).toArray (new AttributeValidator[0]);
            FIELD_ApplicationStatus_Validators = (AttributeValidator[])setupAttribMetaData_ApplicationStatus(validatorMapping).toArray (new AttributeValidator[0]);
            FIELD_DelayHrs_Validators = (AttributeValidator[])setupAttribMetaData_DelayHrs(validatorMapping).toArray (new AttributeValidator[0]);
            FIELD_DelayMin_Validators = (AttributeValidator[])setupAttribMetaData_DelayMin(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_MessageID(Map validatorMapping)
    {
        Map  metaInfo   = new HashMap ();

        metaInfo.put ("dbcol", "message_id");
        metaInfo.put ("defaultValue", "1");
        metaInfo.put ("mandatory", "true");
        metaInfo.put ("name", "MessageID");
        metaInfo.put ("type", "Integer");
        
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for MessageTemplate.MessageID:", metaInfo);
        ATTRIBUTES_METADATA_MessageTemplate.put (FIELD_MessageID, Collections.unmodifiableMap (metaInfo));

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

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

        metaInfo.put ("dbcol", "template_name");
        metaInfo.put ("length", "200");
        metaInfo.put ("mandatory", "true");
        metaInfo.put ("name", "TemplateName");
        metaInfo.put ("type", "String");
        
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for MessageTemplate.TemplateName:", metaInfo);
        ATTRIBUTES_METADATA_MessageTemplate.put (FIELD_TemplateName, Collections.unmodifiableMap (metaInfo));

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

        return validators;
    }
    
    // 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", "true");
        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", "true");
        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_DelayHrs(Map validatorMapping)
    {
        Map  metaInfo   = new HashMap ();

        metaInfo.put ("dbcol", "delay_hrs");
        metaInfo.put ("defaultValue", "0");
        metaInfo.put ("mandatory", "false");
        metaInfo.put ("name", "DelayHrs");
        metaInfo.put ("type", "Integer");
        
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for MessageTemplate.DelayHrs:", metaInfo);
        ATTRIBUTES_METADATA_MessageTemplate.put (FIELD_DelayHrs, Collections.unmodifiableMap (metaInfo));

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

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

        metaInfo.put ("dbcol", "delay_min");
        metaInfo.put ("defaultValue", "0");
        metaInfo.put ("mandatory", "false");
        metaInfo.put ("name", "DelayMin");
        metaInfo.put ("type", "Integer");
        
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for MessageTemplate.DelayMin:", metaInfo);
        ATTRIBUTES_METADATA_MessageTemplate.put (FIELD_DelayMin, Collections.unmodifiableMap (metaInfo));

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

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

        metaInfo.put ("dbcol", "variance");
        metaInfo.put ("defaultValue", "0");
        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 ("defaultValue", "Boolean.FALSE");
        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", "true");
        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);

        
        _MessageID = (Integer)(1);
        _TemplateName = (String)(HELPER_TemplateName.initialise (_TemplateName));
        _Subject = (String)(HELPER_Subject.initialise (_Subject));
        _ApplicationStatus = (ApplicationStatus)(ApplicationStatus.DRAFT);
        _DelayHrs = (Integer)(0);
        _DelayMin = (Integer)(0);
        _Variance = (Integer)(0);
        _BusinessHoursOnly = (Boolean)(Boolean.FALSE);
        _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 MessageID
     */
    public Integer getMessageID ()
    {
        assertValid();
        Integer valToReturn = _MessageID;

            for (MessageTemplateBehaviourDecorator bhd : MessageTemplate_BehaviourDecorators)
            {
                valToReturn = bhd.getMessageID ((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 preMessageIDChange (Integer newMessageID) 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 postMessageIDChange () throws FieldException
    {
    }

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

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

            BusinessObjectParser.assertFieldCondition (newMessageID != null, this, FIELD_MessageID, "mandatory");
            

            if (FIELD_MessageID_Validators.length > 0)
            {
                Object newMessageIDObj = HELPER_MessageID.toObject (newMessageID);

                if (newMessageIDObj != null)
                {
                    int     loopMax = FIELD_MessageID_Validators.length;
                    Map     metadata = (Map)ATTRIBUTES_METADATA_MessageTemplate.get (FIELD_MessageID);

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

        if (!oldAndNewIdentical)
        {
            assertValid();
            Debug.assertion (getWriteability_MessageID () != FieldWriteability.FALSE, "Field  MessageID is not writeable");
            preMessageIDChange (newMessageID);
            markFieldChange (FIELD_MessageID);
            _MessageID = newMessageID;            
            postFieldChange (FIELD_MessageID);
            postMessageIDChange ();
        }
    }

    /**
     * Get the attribute TemplateName
     */
    public String getTemplateName ()
    {
        assertValid();
        String valToReturn = _TemplateName;

            for (MessageTemplateBehaviourDecorator bhd : MessageTemplate_BehaviourDecorators)
            {
                valToReturn = bhd.getTemplateName ((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 preTemplateNameChange (String newTemplateName) 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 postTemplateNameChange () throws FieldException
    {
    }

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

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

            BusinessObjectParser.assertFieldCondition (newTemplateName != null, this, FIELD_TemplateName, "mandatory");
            

            if (FIELD_TemplateName_Validators.length > 0)
            {
                Object newTemplateNameObj = HELPER_TemplateName.toObject (newTemplateName);

                if (newTemplateNameObj != null)
                {
                    int     loopMax = FIELD_TemplateName_Validators.length;
                    Map     metadata = (Map)ATTRIBUTES_METADATA_MessageTemplate.get (FIELD_TemplateName);

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

        if (!oldAndNewIdentical)
        {
            assertValid();
            Debug.assertion (getWriteability_TemplateName () != FieldWriteability.FALSE, "Field  TemplateName is not writeable");
            preTemplateNameChange (newTemplateName);
            markFieldChange (FIELD_TemplateName);
            _TemplateName = newTemplateName;            
            postFieldChange (FIELD_TemplateName);
            postTemplateNameChange ();
        }
    }

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

            BusinessObjectParser.assertFieldCondition (newSubject != null, this, FIELD_Subject, "mandatory");
            

            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);
            }

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

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

                if (newApplicationStatusObj != null)
                {
                    int     loopMax = FIELD_ApplicationStatus_Validators.length;
                    Map     metadata = (Map)ATTRIBUTES_METADATA_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 DelayHrs
     */
    public Integer getDelayHrs ()
    {
        assertValid();
        Integer valToReturn = _DelayHrs;

            for (MessageTemplateBehaviourDecorator bhd : MessageTemplate_BehaviourDecorators)
            {
                valToReturn = bhd.getDelayHrs ((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 preDelayHrsChange (Integer newDelayHrs) 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 postDelayHrsChange () throws FieldException
    {
    }

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

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

            

            if (FIELD_DelayHrs_Validators.length > 0)
            {
                Object newDelayHrsObj = HELPER_DelayHrs.toObject (newDelayHrs);

                if (newDelayHrsObj != null)
                {
                    int     loopMax = FIELD_DelayHrs_Validators.length;
                    Map     metadata = (Map)ATTRIBUTES_METADATA_MessageTemplate.get (FIELD_DelayHrs);

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

        if (!oldAndNewIdentical)
        {
            assertValid();
            Debug.assertion (getWriteability_DelayHrs () != FieldWriteability.FALSE, "Field  DelayHrs is not writeable");
            preDelayHrsChange (newDelayHrs);
            markFieldChange (FIELD_DelayHrs);
            _DelayHrs = newDelayHrs;            
            postFieldChange (FIELD_DelayHrs);
            postDelayHrsChange ();
        }
    }

    /**
     * Get the attribute DelayMin
     */
    public Integer getDelayMin ()
    {
        assertValid();
        Integer valToReturn = _DelayMin;

            for (MessageTemplateBehaviourDecorator bhd : MessageTemplate_BehaviourDecorators)
            {
                valToReturn = bhd.getDelayMin ((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 preDelayMinChange (Integer newDelayMin) 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 postDelayMinChange () throws FieldException
    {
    }

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

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

            

            if (FIELD_DelayMin_Validators.length > 0)
            {
                Object newDelayMinObj = HELPER_DelayMin.toObject (newDelayMin);

                if (newDelayMinObj != null)
                {
                    int     loopMax = FIELD_DelayMin_Validators.length;
                    Map     metadata = (Map)ATTRIBUTES_METADATA_MessageTemplate.get (FIELD_DelayMin);

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

        if (!oldAndNewIdentical)
        {
            assertValid();
            Debug.assertion (getWriteability_DelayMin () != FieldWriteability.FALSE, "Field  DelayMin is not writeable");
            preDelayMinChange (newDelayMin);
            markFieldChange (FIELD_DelayMin);
            _DelayMin = newDelayMin;            
            postFieldChange (FIELD_DelayMin);
            postDelayMinChange ();
        }
    }

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

            BusinessObjectParser.assertFieldCondition (newMessageContent != null, this, FIELD_MessageContent, "mandatory");
            

            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_MessageID, HELPER_MessageID.toObject (_MessageID)); //
        tl_message_templatePSet.setAttrib (FIELD_TemplateName, HELPER_TemplateName.toObject (_TemplateName)); //
        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_DelayHrs, HELPER_DelayHrs.toObject (_DelayHrs)); //
        tl_message_templatePSet.setAttrib (FIELD_DelayMin, HELPER_DelayMin.toObject (_DelayMin)); //
        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");

        _MessageID = (Integer)(HELPER_MessageID.fromObject (_MessageID, tl_message_templatePSet.getAttrib (FIELD_MessageID))); //
        _TemplateName = (String)(HELPER_TemplateName.fromObject (_TemplateName, tl_message_templatePSet.getAttrib (FIELD_TemplateName))); //
        _Subject = (String)(HELPER_Subject.fromObject (_Subject, tl_message_templatePSet.getAttrib (FIELD_Subject))); //
        _ApplicationStatus = (ApplicationStatus)(HELPER_ApplicationStatus.fromObject (_ApplicationStatus, tl_message_templatePSet.getAttrib (FIELD_ApplicationStatus))); //
        _DelayHrs = (Integer)(HELPER_DelayHrs.fromObject (_DelayHrs, tl_message_templatePSet.getAttrib (FIELD_DelayHrs))); //
        _DelayMin = (Integer)(HELPER_DelayMin.fromObject (_DelayMin, tl_message_templatePSet.getAttrib (FIELD_DelayMin))); //
        _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
            {
                setMessageID (otherMessageTemplate.getMessageID ());
            }
            catch (FieldException ex)
            {
                e.addException (ex);
            }
            
            try
            {
                setTemplateName (otherMessageTemplate.getTemplateName ());
            }
            catch (FieldException ex)
            {
                e.addException (ex);
            }
            
            try
            {
                setSubject (otherMessageTemplate.getSubject ());
            }
            catch (FieldException ex)
            {
                e.addException (ex);
            }
            
            try
            {
                setApplicationStatus (otherMessageTemplate.getApplicationStatus ());
            }
            catch (FieldException ex)
            {
                e.addException (ex);
            }
            
            try
            {
                setDelayHrs (otherMessageTemplate.getDelayHrs ());
            }
            catch (FieldException ex)
            {
                e.addException (ex);
            }
            
            try
            {
                setDelayMin (otherMessageTemplate.getDelayMin ());
            }
            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);

            _MessageID = sourceMessageTemplate._MessageID;
            _TemplateName = sourceMessageTemplate._TemplateName;
            _Subject = sourceMessageTemplate._Subject;
            _ApplicationStatus = sourceMessageTemplate._ApplicationStatus;
            _DelayHrs = sourceMessageTemplate._DelayHrs;
            _DelayMin = sourceMessageTemplate._DelayMin;
            _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);

        _MessageID = (Integer)(HELPER_MessageID.readExternal (_MessageID, vals.get(FIELD_MessageID))); //
        _TemplateName = (String)(HELPER_TemplateName.readExternal (_TemplateName, vals.get(FIELD_TemplateName))); //
        _Subject = (String)(HELPER_Subject.readExternal (_Subject, vals.get(FIELD_Subject))); //
        _ApplicationStatus = (ApplicationStatus)(HELPER_ApplicationStatus.readExternal (_ApplicationStatus, vals.get(FIELD_ApplicationStatus))); //
        _DelayHrs = (Integer)(HELPER_DelayHrs.readExternal (_DelayHrs, vals.get(FIELD_DelayHrs))); //
        _DelayMin = (Integer)(HELPER_DelayMin.readExternal (_DelayMin, vals.get(FIELD_DelayMin))); //
        _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_MessageID, HELPER_MessageID.writeExternal (_MessageID));
        vals.put (FIELD_TemplateName, HELPER_TemplateName.writeExternal (_TemplateName));
        vals.put (FIELD_Subject, HELPER_Subject.writeExternal (_Subject));
        vals.put (FIELD_ApplicationStatus, HELPER_ApplicationStatus.writeExternal (_ApplicationStatus));
        vals.put (FIELD_DelayHrs, HELPER_DelayHrs.writeExternal (_DelayHrs));
        vals.put (FIELD_DelayMin, HELPER_DelayMin.writeExternal (_DelayMin));
        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_MessageID.compare(this._MessageID, otherMessageTemplate._MessageID))
            {
                listener.notifyFieldChange(this, other, FIELD_MessageID, HELPER_MessageID.toObject(this._MessageID), HELPER_MessageID.toObject(otherMessageTemplate._MessageID));
            }
            if (!HELPER_TemplateName.compare(this._TemplateName, otherMessageTemplate._TemplateName))
            {
                listener.notifyFieldChange(this, other, FIELD_TemplateName, HELPER_TemplateName.toObject(this._TemplateName), HELPER_TemplateName.toObject(otherMessageTemplate._TemplateName));
            }
            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_DelayHrs.compare(this._DelayHrs, otherMessageTemplate._DelayHrs))
            {
                listener.notifyFieldChange(this, other, FIELD_DelayHrs, HELPER_DelayHrs.toObject(this._DelayHrs), HELPER_DelayHrs.toObject(otherMessageTemplate._DelayHrs));
            }
            if (!HELPER_DelayMin.compare(this._DelayMin, otherMessageTemplate._DelayMin))
            {
                listener.notifyFieldChange(this, other, FIELD_DelayMin, HELPER_DelayMin.toObject(this._DelayMin), HELPER_DelayMin.toObject(otherMessageTemplate._DelayMin));
            }
            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_MessageID, HELPER_MessageID.toObject(getMessageID()));
        visitor.visitField(this, FIELD_TemplateName, HELPER_TemplateName.toObject(getTemplateName()));
        visitor.visitField(this, FIELD_Subject, HELPER_Subject.toObject(getSubject()));
        visitor.visitField(this, FIELD_ApplicationStatus, HELPER_ApplicationStatus.toObject(getApplicationStatus()));
        visitor.visitField(this, FIELD_DelayHrs, HELPER_DelayHrs.toObject(getDelayHrs()));
        visitor.visitField(this, FIELD_DelayMin, HELPER_DelayMin.toObject(getDelayMin()));
        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_MessageID))
        {
            return filter.matches (getMessageID ());
        }
        else if (attribName.equals (FIELD_TemplateName))
        {
            return filter.matches (getTemplateName ());
        }
        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_DelayHrs))
        {
            return filter.matches (getDelayHrs ());
        }
        else if (attribName.equals (FIELD_DelayMin))
        {
            return filter.matches (getDelayMin ());
        }
        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 andMessageID (QueryFilter<Integer> filter)
            {
                filter.addFilter (context, "tl_message_template.message_id", "MessageID");
                return this;
            }
            
            public SearchAll andTemplateName (QueryFilter<String> filter)
            {
                filter.addFilter (context, "tl_message_template.template_name", "TemplateName");
                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 andDelayHrs (QueryFilter<Integer> filter)
            {
                filter.addFilter (context, "tl_message_template.delay_hrs", "DelayHrs");
                return this;
            }
            
            public SearchAll andDelayMin (QueryFilter<Integer> filter)
            {
                filter.addFilter (context, "tl_message_template.delay_min", "DelayMin");
                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_MessageID))
        {
            return HELPER_MessageID.toObject (getMessageID ());
        }
        else if (attribName.equals (FIELD_TemplateName))
        {
            return HELPER_TemplateName.toObject (getTemplateName ());
        }
        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_DelayHrs))
        {
            return HELPER_DelayHrs.toObject (getDelayHrs ());
        }
        else if (attribName.equals (FIELD_DelayMin))
        {
            return HELPER_DelayMin.toObject (getDelayMin ());
        }
        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_MessageID))
        {
            return HELPER_MessageID;
        }
        else if (attribName.equals (FIELD_TemplateName))
        {
            return HELPER_TemplateName;
        }
        else if (attribName.equals (FIELD_Subject))
        {
            return HELPER_Subject;
        }
        else if (attribName.equals (FIELD_ApplicationStatus))
        {
            return HELPER_ApplicationStatus;
        }
        else if (attribName.equals (FIELD_DelayHrs))
        {
            return HELPER_DelayHrs;
        }
        else if (attribName.equals (FIELD_DelayMin))
        {
            return HELPER_DelayMin;
        }
        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_MessageID))
        {
            setMessageID ((Integer)(HELPER_MessageID.fromObject (_MessageID, attribValue)));            
        }
        else if (attribName.equals (FIELD_TemplateName))
        {
            setTemplateName ((String)(HELPER_TemplateName.fromObject (_TemplateName, attribValue)));            
        }
        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_DelayHrs))
        {
            setDelayHrs ((Integer)(HELPER_DelayHrs.fromObject (_DelayHrs, attribValue)));            
        }
        else if (attribName.equals (FIELD_DelayMin))
        {
            setDelayMin ((Integer)(HELPER_DelayMin.fromObject (_DelayMin, 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_MessageID))
        {
            return getWriteability_MessageID ();
        }
        else if (fieldName.equals (FIELD_TemplateName))
        {
            return getWriteability_TemplateName ();
        }
        else if (fieldName.equals (FIELD_Subject))
        {
            return getWriteability_Subject ();
        }
        else if (fieldName.equals (FIELD_ApplicationStatus))
        {
            return getWriteability_ApplicationStatus ();
        }
        else if (fieldName.equals (FIELD_DelayHrs))
        {
            return getWriteability_DelayHrs ();
        }
        else if (fieldName.equals (FIELD_DelayMin))
        {
            return getWriteability_DelayMin ();
        }
        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_MessageID () != FieldWriteability.TRUE)
            {
                fields.add (FIELD_MessageID);
            }
        
            if (getWriteability_TemplateName () != FieldWriteability.TRUE)
            {
                fields.add (FIELD_TemplateName);
            }
        
            if (getWriteability_Subject () != FieldWriteability.TRUE)
            {
                fields.add (FIELD_Subject);
            }
        
            if (getWriteability_ApplicationStatus () != FieldWriteability.TRUE)
            {
                fields.add (FIELD_ApplicationStatus);
            }
        
            if (getWriteability_DelayHrs () != FieldWriteability.TRUE)
            {
                fields.add (FIELD_DelayHrs);
            }
        
            if (getWriteability_DelayMin () != FieldWriteability.TRUE)
            {
                fields.add (FIELD_DelayMin);
            }
        
            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_MessageID.getAttribObject (getClass (), _MessageID, true, FIELD_MessageID));
        result.add(HELPER_TemplateName.getAttribObject (getClass (), _TemplateName, true, FIELD_TemplateName));
        result.add(HELPER_Subject.getAttribObject (getClass (), _Subject, true, FIELD_Subject));
        result.add(HELPER_ApplicationStatus.getAttribObject (getClass (), _ApplicationStatus, true, FIELD_ApplicationStatus));
        result.add(HELPER_DelayHrs.getAttribObject (getClass (), _DelayHrs, false, FIELD_DelayHrs));
        result.add(HELPER_DelayMin.getAttribObject (getClass (), _DelayMin, false, FIELD_DelayMin));
        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, true, 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 MessageID
     */
    public Integer getMessageID (MessageTemplate obj, Integer original)
    {
        return original;
    }

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

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

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

    /**
     * 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 DelayHrs
     */
    public Integer getDelayHrs (MessageTemplate obj, Integer original)
    {
        return original;
    }

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

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

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

    /**
     * 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 ("MessageID"))
            {
                return toMessageID ();
            }                
            if (name.equals ("TemplateName"))
            {
                return toTemplateName ();
            }                
            if (name.equals ("Subject"))
            {
                return toSubject ();
            }                
            if (name.equals ("ApplicationStatus"))
            {
                return toApplicationStatus ();
            }                
            if (name.equals ("DelayHrs"))
            {
                return toDelayHrs ();
            }                
            if (name.equals ("DelayMin"))
            {
                return toDelayMin ();
            }                
            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, Integer> toMessageID () { return pipe(new ORMAttributePipe<Me, Integer>(FIELD_MessageID));  }
        
        public PipeLine<From, String> toTemplateName () { return pipe(new ORMAttributePipe<Me, String>(FIELD_TemplateName));  }
        
        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, Integer> toDelayHrs () { return pipe(new ORMAttributePipe<Me, Integer>(FIELD_DelayHrs));  }
        
        public PipeLine<From, Integer> toDelayMin () { return pipe(new ORMAttributePipe<Me, Integer>(FIELD_DelayMin));  }
        
        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 ()
    {
    }


}

