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

    // Reference instance for the object
    public static final MessageEngine DUMMY_MessageEngine = new DummyMessageEngine ();

    // 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
    

    // Static constants corresponding to attribute helpers
    private static final DefaultAttributeHelper<MessageEngine> HELPER_Subject = DefaultAttributeHelper.INSTANCE;
    private static final EnumeratedAttributeHelper<MessageEngine, ApplicationStatus> HELPER_ApplicationStatus =  new EnumeratedAttributeHelper<MessageEngine, ApplicationStatus> (ApplicationStatus.FACTORY_ApplicationStatus);
    private static final DefaultAttributeHelper<MessageEngine> HELPER_Delay = DefaultAttributeHelper.INSTANCE;
    private static final DefaultAttributeHelper<MessageEngine> HELPER_Variance = DefaultAttributeHelper.INSTANCE;
    private static final DefaultAttributeHelper<MessageEngine> HELPER_BusinessHoursOnly = DefaultAttributeHelper.INSTANCE;
    private static final DefaultAttributeHelper<MessageEngine> 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_MessageEngine = 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 MessageEngineBehaviourDecorator[] MessageEngine_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_MessageEngine.initialiseReference ();
            DUMMY_MessageEngine.initialiseReference ();
            MessageEngine_BehaviourDecorators = BaseBusinessClass.getBBCBehaviours(MessageEngine.class).toArray(new MessageEngineBehaviourDecorator[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 MessageEngine.Subject:", metaInfo);
        ATTRIBUTES_METADATA_MessageEngine.put (FIELD_Subject, Collections.unmodifiableMap (metaInfo));

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

        List validators = BaseBusinessClass.getAttribValidators(MessageEngine.class, "ApplicationStatus", metaInfo, validatorMapping);
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for MessageEngine.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 MessageEngine.Delay:", metaInfo);
        ATTRIBUTES_METADATA_MessageEngine.put (FIELD_Delay, Collections.unmodifiableMap (metaInfo));

        List validators = BaseBusinessClass.getAttribValidators(MessageEngine.class, "Delay", metaInfo, validatorMapping);
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for MessageEngine.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 MessageEngine.Variance:", metaInfo);
        ATTRIBUTES_METADATA_MessageEngine.put (FIELD_Variance, Collections.unmodifiableMap (metaInfo));

        List validators = BaseBusinessClass.getAttribValidators(MessageEngine.class, "Variance", metaInfo, validatorMapping);
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for MessageEngine.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 MessageEngine.BusinessHoursOnly:", metaInfo);
        ATTRIBUTES_METADATA_MessageEngine.put (FIELD_BusinessHoursOnly, Collections.unmodifiableMap (metaInfo));

        List validators = BaseBusinessClass.getAttribValidators(MessageEngine.class, "BusinessHoursOnly", metaInfo, validatorMapping);
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for MessageEngine.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 MessageEngine.MessageContent:", metaInfo);
        ATTRIBUTES_METADATA_MessageEngine.put (FIELD_MessageContent, Collections.unmodifiableMap (metaInfo));

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

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


    protected BBCBehaviourDecorator[] getBehaviours()
    {
        return MessageEngine_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 (MessageEngineBehaviourDecorator bhd : MessageEngine_BehaviourDecorators)
            {
                valToReturn = bhd.getSubject ((MessageEngine)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 (MessageEngineBehaviourDecorator bhd : MessageEngine_BehaviourDecorators)
            {
                newSubject = bhd.setSubject ((MessageEngine)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_MessageEngine.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 (MessageEngineBehaviourDecorator bhd : MessageEngine_BehaviourDecorators)
            {
                valToReturn = bhd.getApplicationStatus ((MessageEngine)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 (MessageEngineBehaviourDecorator bhd : MessageEngine_BehaviourDecorators)
            {
                newApplicationStatus = bhd.setApplicationStatus ((MessageEngine)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_MessageEngine.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 (MessageEngineBehaviourDecorator bhd : MessageEngine_BehaviourDecorators)
            {
                valToReturn = bhd.getDelay ((MessageEngine)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 (MessageEngineBehaviourDecorator bhd : MessageEngine_BehaviourDecorators)
            {
                newDelay = bhd.setDelay ((MessageEngine)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_MessageEngine.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 (MessageEngineBehaviourDecorator bhd : MessageEngine_BehaviourDecorators)
            {
                valToReturn = bhd.getVariance ((MessageEngine)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 (MessageEngineBehaviourDecorator bhd : MessageEngine_BehaviourDecorators)
            {
                newVariance = bhd.setVariance ((MessageEngine)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_MessageEngine.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 (MessageEngineBehaviourDecorator bhd : MessageEngine_BehaviourDecorators)
            {
                valToReturn = bhd.getBusinessHoursOnly ((MessageEngine)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 (MessageEngineBehaviourDecorator bhd : MessageEngine_BehaviourDecorators)
            {
                newBusinessHoursOnly = bhd.setBusinessHoursOnly ((MessageEngine)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_MessageEngine.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 (MessageEngineBehaviourDecorator bhd : MessageEngine_BehaviourDecorators)
            {
                valToReturn = bhd.getMessageContent ((MessageEngine)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 (MessageEngineBehaviourDecorator bhd : MessageEngine_BehaviourDecorators)
            {
                newMessageContent = bhd.setMessageContent ((MessageEngine)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_MessageEngine.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 MessageEngine newInstance ()
    {
        return new MessageEngine ();
    }


    public MessageEngine referenceInstance ()
    {
        return REFERENCE_MessageEngine;
    }


    public MessageEngine getInTransaction (ObjectTransaction t) throws StorageException
    {
        return getMessageEngineByID (t, getObjectID());
    }
    
    
    public BaseBusinessClass dummyInstance ()
    {
        return DUMMY_MessageEngine;
    }


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





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

        tl_message_enginePSet.setAttrib (FIELD_ObjectID, myID);
        tl_message_enginePSet.setAttrib (FIELD_Subject, HELPER_Subject.toObject (_Subject)); //
        tl_message_enginePSet.setAttrib (FIELD_ApplicationStatus, HELPER_ApplicationStatus.toObject (_ApplicationStatus)); //
        tl_message_enginePSet.setAttrib (FIELD_Delay, HELPER_Delay.toObject (_Delay)); //
        tl_message_enginePSet.setAttrib (FIELD_Variance, HELPER_Variance.toObject (_Variance)); //
        tl_message_enginePSet.setAttrib (FIELD_BusinessHoursOnly, HELPER_BusinessHoursOnly.toObject (_BusinessHoursOnly)); //
        tl_message_enginePSet.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_enginePSet = allSets.getPersistentSet (objectID, "tl_message_engine");

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





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

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

            _Subject = sourceMessageEngine._Subject;
            _ApplicationStatus = sourceMessageEngine._ApplicationStatus;
            _Delay = sourceMessageEngine._Delay;
            _Variance = sourceMessageEngine._Variance;
            _BusinessHoursOnly = sourceMessageEngine._BusinessHoursOnly;
            _MessageContent = sourceMessageEngine._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 BaseMessageEngine)
        {
            BaseMessageEngine sourceMessageEngine = (BaseMessageEngine)(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 BaseMessageEngine)
        {
            BaseMessageEngine sourceMessageEngine = (BaseMessageEngine)(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 BaseMessageEngine)
        {
            BaseMessageEngine otherMessageEngine = (BaseMessageEngine)(other);

            
            if (!HELPER_Subject.compare(this._Subject, otherMessageEngine._Subject))
            {
                listener.notifyFieldChange(this, other, FIELD_Subject, HELPER_Subject.toObject(this._Subject), HELPER_Subject.toObject(otherMessageEngine._Subject));
            }
            if (!HELPER_ApplicationStatus.compare(this._ApplicationStatus, otherMessageEngine._ApplicationStatus))
            {
                listener.notifyFieldChange(this, other, FIELD_ApplicationStatus, HELPER_ApplicationStatus.toObject(this._ApplicationStatus), HELPER_ApplicationStatus.toObject(otherMessageEngine._ApplicationStatus));
            }
            if (!HELPER_Delay.compare(this._Delay, otherMessageEngine._Delay))
            {
                listener.notifyFieldChange(this, other, FIELD_Delay, HELPER_Delay.toObject(this._Delay), HELPER_Delay.toObject(otherMessageEngine._Delay));
            }
            if (!HELPER_Variance.compare(this._Variance, otherMessageEngine._Variance))
            {
                listener.notifyFieldChange(this, other, FIELD_Variance, HELPER_Variance.toObject(this._Variance), HELPER_Variance.toObject(otherMessageEngine._Variance));
            }
            if (!HELPER_BusinessHoursOnly.compare(this._BusinessHoursOnly, otherMessageEngine._BusinessHoursOnly))
            {
                listener.notifyFieldChange(this, other, FIELD_BusinessHoursOnly, HELPER_BusinessHoursOnly.toObject(this._BusinessHoursOnly), HELPER_BusinessHoursOnly.toObject(otherMessageEngine._BusinessHoursOnly));
            }
            if (!HELPER_MessageContent.compare(this._MessageContent, otherMessageEngine._MessageContent))
            {
                listener.notifyFieldChange(this, other, FIELD_MessageContent, HELPER_MessageContent.toObject(this._MessageContent), HELPER_MessageContent.toObject(otherMessageEngine._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 MessageEngine createMessageEngine (ObjectTransaction transaction) throws StorageException
    {
        MessageEngine     result = new MessageEngine ();

        result.initialiseNewObject (transaction);

        return result;
    }


    public static MessageEngine getMessageEngineByID (ObjectTransaction transaction, Long objectID) throws StorageException
    {
        return (MessageEngine)(transaction.getObjectByID (REFERENCE_MessageEngine, 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 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_MessageEngine.containsKey (attribute))
        {
            return (Map)ATTRIBUTES_METADATA_MessageEngine.get (attribute);
        }
        else
        {
            return super.getAttributeMetadata (attribute);
        }
    }


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

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

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

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

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

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

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

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

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

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

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

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

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

    }

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

        public MessageEnginePipeLineFactory (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 DummyMessageEngine extends MessageEngine
{
    // Default constructor primarily to support Externalisable
    public DummyMessageEngine()
    {
        super();
    }

    public void assertValid ()
    {
    }


}

