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

    // Reference instance for the object
    public static final NotificationTemplate DUMMY_NotificationTemplate = new DummyNotificationTemplate ();

    // Static constants corresponding to field names
    
    public static final String FIELD_NotificationType = "NotificationType";
    public static final String FIELD_DaysAfter = "DaysAfter";
    public static final String FIELD_NotificationContent = "NotificationContent";

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

    // Static constants corresponding to attribute helpers
    private static final EnumeratedAttributeHelper<NotificationTemplate, NotificationType> HELPER_NotificationType =  new EnumeratedAttributeHelper<NotificationTemplate, NotificationType> (NotificationType.FACTORY_NotificationType);
    private static final DefaultAttributeHelper<NotificationTemplate> HELPER_DaysAfter = DefaultAttributeHelper.INSTANCE;
    private static final DefaultAttributeHelper<NotificationTemplate> HELPER_NotificationContent = DefaultAttributeHelper.INSTANCE;
    

    // Private attributes corresponding to business object data
    private NotificationType _NotificationType;
    private Integer _DaysAfter;
    private String _NotificationContent;
    

    // Private attributes corresponding to single references
    

    // Private attributes corresponding to multiple references
    

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

    // Arrays of validators for each attribute
    private static final AttributeValidator[] FIELD_NotificationType_Validators;
    private static final AttributeValidator[] FIELD_DaysAfter_Validators;
    private static final AttributeValidator[] FIELD_NotificationContent_Validators;
    

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

            FIELD_NotificationType_Validators = (AttributeValidator[])setupAttribMetaData_NotificationType(validatorMapping).toArray (new AttributeValidator[0]);
            FIELD_DaysAfter_Validators = (AttributeValidator[])setupAttribMetaData_DaysAfter(validatorMapping).toArray (new AttributeValidator[0]);
            FIELD_NotificationContent_Validators = (AttributeValidator[])setupAttribMetaData_NotificationContent(validatorMapping).toArray (new AttributeValidator[0]);
            

            REFERENCE_NotificationTemplate.initialiseReference ();
            DUMMY_NotificationTemplate.initialiseReference ();
            NotificationTemplate_BehaviourDecorators = BaseBusinessClass.getBBCBehaviours(NotificationTemplate.class).toArray(new NotificationTemplateBehaviourDecorator[0]);
        }
        catch (RuntimeException e)
        {
            LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR1, e, "Error initialising");
            throw e;
        }
    }

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

        metaInfo.put ("attribHelper", "EnumeratedAttributeHelper");
        metaInfo.put ("dbcol", "notification_type");
        metaInfo.put ("defaultValue", "NotificationType.TRIAL");
        metaInfo.put ("mandatory", "true");
        metaInfo.put ("name", "NotificationType");
        metaInfo.put ("type", "NotificationType");
        
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for NotificationTemplate.NotificationType:", metaInfo);
        ATTRIBUTES_METADATA_NotificationTemplate.put (FIELD_NotificationType, Collections.unmodifiableMap (metaInfo));

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

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

        metaInfo.put ("dbcol", "days_after");
        metaInfo.put ("defaultValue", "0");
        metaInfo.put ("mandatory", "true");
        metaInfo.put ("name", "DaysAfter");
        metaInfo.put ("type", "Integer");
        
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for NotificationTemplate.DaysAfter:", metaInfo);
        ATTRIBUTES_METADATA_NotificationTemplate.put (FIELD_DaysAfter, Collections.unmodifiableMap (metaInfo));

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

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

        metaInfo.put ("dbcol", "notification_content");
        metaInfo.put ("mandatory", "true");
        metaInfo.put ("name", "NotificationContent");
        metaInfo.put ("type", "String");
        
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for NotificationTemplate.NotificationContent:", metaInfo);
        ATTRIBUTES_METADATA_NotificationTemplate.put (FIELD_NotificationContent, Collections.unmodifiableMap (metaInfo));

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

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


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


    


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

        
        _NotificationType = (NotificationType)(NotificationType.TRIAL);
        _DaysAfter = (Integer)(0);
        _NotificationContent = (String)(HELPER_NotificationContent.initialise (_NotificationContent));
    }


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

        
    }


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

    

    /**
     * Get the attribute NotificationType
     */
    public NotificationType getNotificationType ()
    {
        assertValid();
        NotificationType valToReturn = _NotificationType;

            for (NotificationTemplateBehaviourDecorator bhd : NotificationTemplate_BehaviourDecorators)
            {
                valToReturn = bhd.getNotificationType ((NotificationTemplate)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 preNotificationTypeChange (NotificationType newNotificationType) 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 postNotificationTypeChange () throws FieldException
    {
    }

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

    /**
     * Set the attribute NotificationType.  Checks to ensure a new value
     * has been supplied.  If so, marks the field as altered and sets the attribute.
     */
    public void setNotificationType (NotificationType newNotificationType) throws FieldException
    {
        boolean oldAndNewIdentical = HELPER_NotificationType.compare (_NotificationType, newNotificationType);
        
        try
        {
            for (NotificationTemplateBehaviourDecorator bhd : NotificationTemplate_BehaviourDecorators)
            {
                newNotificationType = bhd.setNotificationType ((NotificationTemplate)this, newNotificationType);
                oldAndNewIdentical = HELPER_NotificationType.compare (_NotificationType, newNotificationType);
            }

            BusinessObjectParser.assertFieldCondition (newNotificationType != null, this, FIELD_NotificationType, "mandatory");
            

            if (FIELD_NotificationType_Validators.length > 0)
            {
                Object newNotificationTypeObj = HELPER_NotificationType.toObject (newNotificationType);

                if (newNotificationTypeObj != null)
                {
                    int     loopMax = FIELD_NotificationType_Validators.length;
                    Map     metadata = (Map)ATTRIBUTES_METADATA_NotificationTemplate.get (FIELD_NotificationType);

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

        if (!oldAndNewIdentical)
        {
            assertValid();
            Debug.assertion (getWriteability_NotificationType () != FieldWriteability.FALSE, "Field  NotificationType is not writeable");
            preNotificationTypeChange (newNotificationType);
            markFieldChange (FIELD_NotificationType);
            _NotificationType = newNotificationType;            
            postFieldChange (FIELD_NotificationType);
            postNotificationTypeChange ();
        }
    }

    /**
     * Get the attribute DaysAfter
     */
    public Integer getDaysAfter ()
    {
        assertValid();
        Integer valToReturn = _DaysAfter;

            for (NotificationTemplateBehaviourDecorator bhd : NotificationTemplate_BehaviourDecorators)
            {
                valToReturn = bhd.getDaysAfter ((NotificationTemplate)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 preDaysAfterChange (Integer newDaysAfter) 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 postDaysAfterChange () throws FieldException
    {
    }

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

    /**
     * Set the attribute DaysAfter.  Checks to ensure a new value
     * has been supplied.  If so, marks the field as altered and sets the attribute.
     */
    public void setDaysAfter (Integer newDaysAfter) throws FieldException
    {
        boolean oldAndNewIdentical = HELPER_DaysAfter.compare (_DaysAfter, newDaysAfter);
        
        try
        {
            for (NotificationTemplateBehaviourDecorator bhd : NotificationTemplate_BehaviourDecorators)
            {
                newDaysAfter = bhd.setDaysAfter ((NotificationTemplate)this, newDaysAfter);
                oldAndNewIdentical = HELPER_DaysAfter.compare (_DaysAfter, newDaysAfter);
            }

            BusinessObjectParser.assertFieldCondition (newDaysAfter != null, this, FIELD_DaysAfter, "mandatory");
            

            if (FIELD_DaysAfter_Validators.length > 0)
            {
                Object newDaysAfterObj = HELPER_DaysAfter.toObject (newDaysAfter);

                if (newDaysAfterObj != null)
                {
                    int     loopMax = FIELD_DaysAfter_Validators.length;
                    Map     metadata = (Map)ATTRIBUTES_METADATA_NotificationTemplate.get (FIELD_DaysAfter);

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

        if (!oldAndNewIdentical)
        {
            assertValid();
            Debug.assertion (getWriteability_DaysAfter () != FieldWriteability.FALSE, "Field  DaysAfter is not writeable");
            preDaysAfterChange (newDaysAfter);
            markFieldChange (FIELD_DaysAfter);
            _DaysAfter = newDaysAfter;            
            postFieldChange (FIELD_DaysAfter);
            postDaysAfterChange ();
        }
    }

    /**
     * Get the attribute NotificationContent
     */
    public String getNotificationContent ()
    {
        assertValid();
        String valToReturn = _NotificationContent;

            for (NotificationTemplateBehaviourDecorator bhd : NotificationTemplate_BehaviourDecorators)
            {
                valToReturn = bhd.getNotificationContent ((NotificationTemplate)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 preNotificationContentChange (String newNotificationContent) 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 postNotificationContentChange () throws FieldException
    {
    }

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

    /**
     * Set the attribute NotificationContent.  Checks to ensure a new value
     * has been supplied.  If so, marks the field as altered and sets the attribute.
     */
    public void setNotificationContent (String newNotificationContent) throws FieldException
    {
        boolean oldAndNewIdentical = HELPER_NotificationContent.compare (_NotificationContent, newNotificationContent);
        
        try
        {
            for (NotificationTemplateBehaviourDecorator bhd : NotificationTemplate_BehaviourDecorators)
            {
                newNotificationContent = bhd.setNotificationContent ((NotificationTemplate)this, newNotificationContent);
                oldAndNewIdentical = HELPER_NotificationContent.compare (_NotificationContent, newNotificationContent);
            }

            BusinessObjectParser.assertFieldCondition (newNotificationContent != null, this, FIELD_NotificationContent, "mandatory");
            

            if (FIELD_NotificationContent_Validators.length > 0)
            {
                Object newNotificationContentObj = HELPER_NotificationContent.toObject (newNotificationContent);

                if (newNotificationContentObj != null)
                {
                    int     loopMax = FIELD_NotificationContent_Validators.length;
                    Map     metadata = (Map)ATTRIBUTES_METADATA_NotificationTemplate.get (FIELD_NotificationContent);

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

        if (!oldAndNewIdentical)
        {
            assertValid();
            Debug.assertion (getWriteability_NotificationContent () != FieldWriteability.FALSE, "Field  NotificationContent is not writeable");
            preNotificationContentChange (newNotificationContent);
            markFieldChange (FIELD_NotificationContent);
            _NotificationContent = newNotificationContent;            
            postFieldChange (FIELD_NotificationContent);
            postNotificationContentChange ();
        }
    }



    /**
     * 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 NotificationTemplate newInstance ()
    {
        return new NotificationTemplate ();
    }


    public NotificationTemplate referenceInstance ()
    {
        return REFERENCE_NotificationTemplate;
    }


    public NotificationTemplate getInTransaction (ObjectTransaction t) throws StorageException
    {
        return getNotificationTemplateByID (t, getObjectID());
    }
    
    
    public BaseBusinessClass dummyInstance ()
    {
        return DUMMY_NotificationTemplate;
    }


    public String getBaseSetName ()
    {
        return "tl_notification_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_notification_templatePSet = allSets.getPersistentSet (myID, "tl_notification_template", myPSetStatus);

        tl_notification_templatePSet.setAttrib (FIELD_ObjectID, myID);
        tl_notification_templatePSet.setAttrib (FIELD_NotificationType, HELPER_NotificationType.toObject (_NotificationType)); //
        tl_notification_templatePSet.setAttrib (FIELD_DaysAfter, HELPER_DaysAfter.toObject (_DaysAfter)); //
        tl_notification_templatePSet.setAttrib (FIELD_NotificationContent, HELPER_NotificationContent.toObject (_NotificationContent)); //
        
    }


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

        
        PersistentSet   tl_notification_templatePSet = allSets.getPersistentSet (objectID, "tl_notification_template");

        _NotificationType = (NotificationType)(HELPER_NotificationType.fromObject (_NotificationType, tl_notification_templatePSet.getAttrib (FIELD_NotificationType))); //
        _DaysAfter = (Integer)(HELPER_DaysAfter.fromObject (_DaysAfter, tl_notification_templatePSet.getAttrib (FIELD_DaysAfter))); //
        _NotificationContent = (String)(HELPER_NotificationContent.fromObject (_NotificationContent, tl_notification_templatePSet.getAttrib (FIELD_NotificationContent))); //
        
    }





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

        if (other instanceof NotificationTemplate)
        {
            NotificationTemplate otherNotificationTemplate = (NotificationTemplate)other;
            
            try
            {
                setNotificationType (otherNotificationTemplate.getNotificationType ());
            }
            catch (FieldException ex)
            {
                e.addException (ex);
            }
            
            try
            {
                setDaysAfter (otherNotificationTemplate.getDaysAfter ());
            }
            catch (FieldException ex)
            {
                e.addException (ex);
            }
            
            try
            {
                setNotificationContent (otherNotificationTemplate.getNotificationContent ());
            }
            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 BaseNotificationTemplate)
        {
            BaseNotificationTemplate sourceNotificationTemplate = (BaseNotificationTemplate)(source);

            _NotificationType = sourceNotificationTemplate._NotificationType;
            _DaysAfter = sourceNotificationTemplate._DaysAfter;
            _NotificationContent = sourceNotificationTemplate._NotificationContent;
            
        }
    }


    /**
     * 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 BaseNotificationTemplate)
        {
            BaseNotificationTemplate sourceNotificationTemplate = (BaseNotificationTemplate)(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 BaseNotificationTemplate)
        {
            BaseNotificationTemplate sourceNotificationTemplate = (BaseNotificationTemplate)(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);

        _NotificationType = (NotificationType)(HELPER_NotificationType.readExternal (_NotificationType, vals.get(FIELD_NotificationType))); //
        _DaysAfter = (Integer)(HELPER_DaysAfter.readExternal (_DaysAfter, vals.get(FIELD_DaysAfter))); //
        _NotificationContent = (String)(HELPER_NotificationContent.readExternal (_NotificationContent, vals.get(FIELD_NotificationContent))); //
        
    }


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

        vals.put (FIELD_NotificationType, HELPER_NotificationType.writeExternal (_NotificationType));
        vals.put (FIELD_DaysAfter, HELPER_DaysAfter.writeExternal (_DaysAfter));
        vals.put (FIELD_NotificationContent, HELPER_NotificationContent.writeExternal (_NotificationContent));
        
    }


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

        if (other instanceof BaseNotificationTemplate)
        {
            BaseNotificationTemplate otherNotificationTemplate = (BaseNotificationTemplate)(other);

            
            if (!HELPER_NotificationType.compare(this._NotificationType, otherNotificationTemplate._NotificationType))
            {
                listener.notifyFieldChange(this, other, FIELD_NotificationType, HELPER_NotificationType.toObject(this._NotificationType), HELPER_NotificationType.toObject(otherNotificationTemplate._NotificationType));
            }
            if (!HELPER_DaysAfter.compare(this._DaysAfter, otherNotificationTemplate._DaysAfter))
            {
                listener.notifyFieldChange(this, other, FIELD_DaysAfter, HELPER_DaysAfter.toObject(this._DaysAfter), HELPER_DaysAfter.toObject(otherNotificationTemplate._DaysAfter));
            }
            if (!HELPER_NotificationContent.compare(this._NotificationContent, otherNotificationTemplate._NotificationContent))
            {
                listener.notifyFieldChange(this, other, FIELD_NotificationContent, HELPER_NotificationContent.toObject(this._NotificationContent), HELPER_NotificationContent.toObject(otherNotificationTemplate._NotificationContent));
            }

            // 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_NotificationType, HELPER_NotificationType.toObject(getNotificationType()));
        visitor.visitField(this, FIELD_DaysAfter, HELPER_DaysAfter.toObject(getDaysAfter()));
        visitor.visitField(this, FIELD_NotificationContent, HELPER_NotificationContent.toObject(getNotificationContent()));
        
    }


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

        
    }


    public static NotificationTemplate createNotificationTemplate (ObjectTransaction transaction) throws StorageException
    {
        NotificationTemplate     result = new NotificationTemplate ();

        result.initialiseNewObject (transaction);

        return result;
    }


    public static NotificationTemplate getNotificationTemplateByID (ObjectTransaction transaction, Long objectID) throws StorageException
    {
        return (NotificationTemplate)(transaction.getObjectByID (REFERENCE_NotificationTemplate, objectID));
    }

    public boolean testFilter (String attribName, QueryFilter filter) throws StorageException
    {
        if (false)
        {
            throw new RuntimeException ("Game over man!!");
        }
        else if (attribName.equals (FIELD_NotificationType))
        {
            return filter.matches (getNotificationType ());
        }
        else if (attribName.equals (FIELD_DaysAfter))
        {
            return filter.matches (getDaysAfter ());
        }
        else if (attribName.equals (FIELD_NotificationContent))
        {
            return filter.matches (getNotificationContent ());
        }
        else
        {
            return super.testFilter (attribName, filter);
        }
    }


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

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

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

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

            
            public SearchAll andNotificationType (QueryFilter<NotificationType> filter)
            {
                filter.addFilter (context, "tl_notification_template.notification_type", "NotificationType");
                return this;
            }
            
            public SearchAll andDaysAfter (QueryFilter<Integer> filter)
            {
                filter.addFilter (context, "tl_notification_template.days_after", "DaysAfter");
                return this;
            }
            
            public SearchAll andNotificationContent (QueryFilter<String> filter)
            {
                filter.addFilter (context, "tl_notification_template.notification_content", "NotificationContent");
                return this;
            }
            
                public NotificationTemplate[]
             search (ObjectTransaction transaction) throws StorageException
        {
            
            
            BaseBusinessClass[]     results = super.search (transaction, REFERENCE_NotificationTemplate, SEARCH_All, criteria);
            Set<NotificationTemplate>   typedResults = new LinkedHashSet <NotificationTemplate> ();
            for (BaseBusinessClass bbcResult : results)
            {
                NotificationTemplate aResult = (NotificationTemplate)bbcResult;
                
                typedResults.add (aResult);
            }
            
                    return ObjstoreUtils.removeDeleted(transaction, typedResults).toArray (new NotificationTemplate[0]);
                            
        }
    }

        
                public static NotificationTemplate[]
             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_NotificationType))
        {
            return HELPER_NotificationType.toObject (getNotificationType ());
        }
        else if (attribName.equals (FIELD_DaysAfter))
        {
            return HELPER_DaysAfter.toObject (getDaysAfter ());
        }
        else if (attribName.equals (FIELD_NotificationContent))
        {
            return HELPER_NotificationContent.toObject (getNotificationContent ());
        }
        else
        {
            return super.getAttribute (attribName);
        }
    }


    public AttributeHelper getAttributeHelper (String attribName)
    {
        if (false)
        {
            throw new RuntimeException ("Game over man!!");
        }
        else if (attribName.equals (FIELD_NotificationType))
        {
            return HELPER_NotificationType;
        }
        else if (attribName.equals (FIELD_DaysAfter))
        {
            return HELPER_DaysAfter;
        }
        else if (attribName.equals (FIELD_NotificationContent))
        {
            return HELPER_NotificationContent;
        }
        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_NotificationType))
        {
            setNotificationType ((NotificationType)(HELPER_NotificationType.fromObject (_NotificationType, attribValue)));            
        }
        else if (attribName.equals (FIELD_DaysAfter))
        {
            setDaysAfter ((Integer)(HELPER_DaysAfter.fromObject (_DaysAfter, attribValue)));            
        }
        else if (attribName.equals (FIELD_NotificationContent))
        {
            setNotificationContent ((String)(HELPER_NotificationContent.fromObject (_NotificationContent, 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_NotificationType))
        {
            return getWriteability_NotificationType ();
        }
        else if (fieldName.equals (FIELD_DaysAfter))
        {
            return getWriteability_DaysAfter ();
        }
        else if (fieldName.equals (FIELD_NotificationContent))
        {
            return getWriteability_NotificationContent ();
        }
        else
        {
            return super.getWriteable (fieldName);
        }
    }


    public void putUnwriteable (Set<String> fields)
    {
        
            if (getWriteability_NotificationType () != FieldWriteability.TRUE)
            {
                fields.add (FIELD_NotificationType);
            }
        
            if (getWriteability_DaysAfter () != FieldWriteability.TRUE)
            {
                fields.add (FIELD_DaysAfter);
            }
        
            if (getWriteability_NotificationContent () != FieldWriteability.TRUE)
            {
                fields.add (FIELD_NotificationContent);
            }
        

        super.putUnwriteable (fields);
    }

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

        
        result.add(HELPER_NotificationType.getAttribObject (getClass (), _NotificationType, true, FIELD_NotificationType));
        result.add(HELPER_DaysAfter.getAttribObject (getClass (), _DaysAfter, true, FIELD_DaysAfter));
        result.add(HELPER_NotificationContent.getAttribObject (getClass (), _NotificationContent, true, FIELD_NotificationContent));

        return result;
    }


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


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

    /**
     * Get the attribute NotificationType
     */
    public NotificationType getNotificationType (NotificationTemplate obj, NotificationType original)
    {
        return original;
    }

    /**
     * Change the value set for attribute NotificationType.
     * May modify the field beforehand
     * Occurs before validation.
     */
    public NotificationType setNotificationType (NotificationTemplate obj, NotificationType newNotificationType) throws FieldException
    {
        return newNotificationType;
    }

    /**
     * Get the attribute DaysAfter
     */
    public Integer getDaysAfter (NotificationTemplate obj, Integer original)
    {
        return original;
    }

    /**
     * Change the value set for attribute DaysAfter.
     * May modify the field beforehand
     * Occurs before validation.
     */
    public Integer setDaysAfter (NotificationTemplate obj, Integer newDaysAfter) throws FieldException
    {
        return newDaysAfter;
    }

    /**
     * Get the attribute NotificationContent
     */
    public String getNotificationContent (NotificationTemplate obj, String original)
    {
        return original;
    }

    /**
     * Change the value set for attribute NotificationContent.
     * May modify the field beforehand
     * Occurs before validation.
     */
    public String setNotificationContent (NotificationTemplate obj, String newNotificationContent) throws FieldException
    {
        return newNotificationContent;
    }

    }

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

        public NotificationTemplatePipeLineFactory (Collection<From> seed)
        {
            super(seed);
        }
        
        
        public PipeLine<From, ? extends Object> to(String name)
        {
            if (name.equals ("NotificationType"))
            {
                return toNotificationType ();
            }                
            if (name.equals ("DaysAfter"))
            {
                return toDaysAfter ();
            }                
            if (name.equals ("NotificationContent"))
            {
                return toNotificationContent ();
            }                
            
            
            return super.to(name);
        }
        
        
        public PipeLine<From, NotificationType> toNotificationType () { return pipe(new ORMAttributePipe<Me, NotificationType>(FIELD_NotificationType));  }
        
        public PipeLine<From, Integer> toDaysAfter () { return pipe(new ORMAttributePipe<Me, Integer>(FIELD_DaysAfter));  }
        
        public PipeLine<From, String> toNotificationContent () { return pipe(new ORMAttributePipe<Me, String>(FIELD_NotificationContent));  }
        
    }
    
    public boolean isTransientAttrib(String attribName)
    {
        

        return super.isTransientAttrib(attribName);
    }

    public boolean isTransientSingleReference(String assocName)
    {
        

        return super.isTransientSingleReference(assocName);
    }
}

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

    public void assertValid ()
    {
    }


}

