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



public abstract class BaseILOJobTitle extends BaseBusinessClass
{
    // Reference instance for the object
    public static final ILOJobTitle REFERENCE_ILOJobTitle = new ILOJobTitle ();

    // Reference instance for the object
    public static final ILOJobTitle DUMMY_ILOJobTitle = new DummyILOJobTitle ();

    // Static constants corresponding to field names
    
    public static final String FIELD_JobTitle = "JobTitle";
    public static final String SINGLEREFERENCE_Occupation = "Occupation";

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

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

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

    // Private attributes corresponding to single references
    private SingleAssociation<ILOJobTitle, Occupation> _Occupation;
    

    // Private attributes corresponding to multiple references
    

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

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

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

            setupAssocMetaData_Occupation();
            FIELD_JobTitle_Validators = (AttributeValidator[])setupAttribMetaData_JobTitle(validatorMapping).toArray (new AttributeValidator[0]);
            

            REFERENCE_ILOJobTitle.initialiseReference ();
            DUMMY_ILOJobTitle.initialiseReference ();
            ILOJobTitle_BehaviourDecorators = BaseBusinessClass.getBBCBehaviours(ILOJobTitle.class).toArray(new ILOJobTitleBehaviourDecorator[0]);
        }
        catch (RuntimeException e)
        {
            LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR1, e, "Error initialising");
            throw e;
        }
    }

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

        metaInfo.put ("dbcol", "occupation_id");
        metaInfo.put ("name", "Occupation");
        metaInfo.put ("type", "Occupation");
        
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for ILOJobTitle.Occupation:", metaInfo);
        ATTRIBUTES_METADATA_ILOJobTitle.put (SINGLEREFERENCE_Occupation, Collections.unmodifiableMap (metaInfo));
    }
    
    
    // Meta Info setup
    private static List setupAttribMetaData_JobTitle(Map validatorMapping)
    {
        Map  metaInfo   = new HashMap ();

        metaInfo.put ("dbcol", "job_title");
        metaInfo.put ("length", "200");
        metaInfo.put ("name", "JobTitle");
        metaInfo.put ("type", "String");
        
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for ILOJobTitle.JobTitle:", metaInfo);
        ATTRIBUTES_METADATA_ILOJobTitle.put (FIELD_JobTitle, Collections.unmodifiableMap (metaInfo));

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

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


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


    


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

        
        _JobTitle = (String)(HELPER_JobTitle.initialise (_JobTitle));
    }


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

        _Occupation = new SingleAssociation<ILOJobTitle, Occupation> (this, SINGLEREFERENCE_Occupation, null, Occupation.REFERENCE_Occupation, "tl_ilo_job_title");
        
    }


    // Initialise the associations
    protected BaseBusinessClass initialiseReference ()
    {
        super.initialiseReference ();
        
        _Occupation = new SingleAssociation<ILOJobTitle, Occupation> (this, SINGLEREFERENCE_Occupation, null, Occupation.REFERENCE_Occupation, "tl_ilo_job_title");
        
        
        return this;
    }

    

    /**
     * Get the attribute JobTitle
     */
    public String getJobTitle ()
    {
        assertValid();
        String valToReturn = _JobTitle;

            for (ILOJobTitleBehaviourDecorator bhd : ILOJobTitle_BehaviourDecorators)
            {
                valToReturn = bhd.getJobTitle ((ILOJobTitle)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 preJobTitleChange (String newJobTitle) 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 postJobTitleChange () throws FieldException
    {
    }

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

    /**
     * Set the attribute JobTitle.  Checks to ensure a new value
     * has been supplied.  If so, marks the field as altered and sets the attribute.
     */
    public void setJobTitle (String newJobTitle) throws FieldException
    {
        boolean oldAndNewIdentical = HELPER_JobTitle.compare (_JobTitle, newJobTitle);
        
        try
        {
            for (ILOJobTitleBehaviourDecorator bhd : ILOJobTitle_BehaviourDecorators)
            {
                newJobTitle = bhd.setJobTitle ((ILOJobTitle)this, newJobTitle);
                oldAndNewIdentical = HELPER_JobTitle.compare (_JobTitle, newJobTitle);
            }

            

            if (FIELD_JobTitle_Validators.length > 0)
            {
                Object newJobTitleObj = HELPER_JobTitle.toObject (newJobTitle);

                if (newJobTitleObj != null)
                {
                    int     loopMax = FIELD_JobTitle_Validators.length;
                    Map     metadata = (Map)ATTRIBUTES_METADATA_ILOJobTitle.get (FIELD_JobTitle);

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

        if (!oldAndNewIdentical)
        {
            assertValid();
            Debug.assertion (getWriteability_JobTitle () != FieldWriteability.FALSE, "Field  JobTitle is not writeable");
            preJobTitleChange (newJobTitle);
            markFieldChange (FIELD_JobTitle);
            _JobTitle = newJobTitle;            
            postFieldChange (FIELD_JobTitle);
            postJobTitleChange ();
        }
    }



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

        
        result.add("Occupation");
        

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


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


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


    public Long getSingleAssocID (String assocName) throws StorageException
    {
        if (assocName == null)
        {
            throw new RuntimeException ("Game over == null!");
        }
        else if (assocName.equals (SINGLEREFERENCE_Occupation))
        {
            return getOccupationID ();
        }
        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 if (assocName.equals (SINGLEREFERENCE_Occupation))
        {
            setOccupation ((Occupation)(newValue));
        }
        else
        {
            super.setSingleAssoc (assocName, newValue);
        }
    }



    /**
     * Get the reference Occupation
     */
    public Occupation getOccupation () throws StorageException
    {
        assertValid();
        
        try
        {
            return (Occupation)(_Occupation.get ());
        }
        catch (ClassCastException e)
        {
            LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR2, "Cache collision in ILOJobTitle:", this.getObjectID (), ", was trying to get Occupation:",  getOccupationID ());
            LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR2, "Instead I got:", _Occupation.get ().getClass ());
            throw e;
        }
    }


    /**
     * Get the object id for the referenced object.  Does not force a DB access.
     */
    public Occupation getOccupation (Get getType) throws StorageException
    {
        assertValid();
        return _Occupation.get(getType);
    }


    /**
     * Get the object id for the referenced object.  Does not force a DB access.
     */
    public Long getOccupationID ()
    {
        assertValid();
        
        if (_Occupation == null)
        {
            return null;
        }
        else
        {
            return _Occupation.getID ();
        }
    }

    /**
     * Called prior to the assoc 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 preOccupationChange (Occupation newOccupation) throws FieldException
    {
    }


    /**
     * Called after the assoc changes.
     * If a field exception is thrown, the value is still changed, however it 
     * may lead to the TX being rolled back
     */
    protected void postOccupationChange () throws FieldException
    {
    }



    
    public FieldWriteability getWriteability_Occupation ()
    {
        return getFieldWritabilityUtil (FieldWriteability.TRUE);
    }
    
    
    /**
     * Set the reference Occupation.  Checks to ensure a new value
     * has been supplied.  If so, marks the reference as altered and sets it.
     */
    public void setOccupation (Occupation newOccupation) throws StorageException, FieldException
    {
        

        if (_Occupation.wouldReferencedChange (newOccupation))
        {
            assertValid();
            Debug.assertion (getWriteability_Occupation () != FieldWriteability.FALSE, "Assoc Occupation is not writeable");
            preOccupationChange (newOccupation);
            
                    _Occupation.set (newOccupation);
                
            postOccupationChange ();
        }
    }

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


    public ILOJobTitle referenceInstance ()
    {
        return REFERENCE_ILOJobTitle;
    }


    public ILOJobTitle getInTransaction (ObjectTransaction t) throws StorageException
    {
        return getILOJobTitleByID (t, getObjectID());
    }
    
    
    public BaseBusinessClass dummyInstance ()
    {
        return DUMMY_ILOJobTitle;
    }


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





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

        tl_ilo_job_titlePSet.setAttrib (FIELD_ObjectID, myID);
        tl_ilo_job_titlePSet.setAttrib (FIELD_JobTitle, HELPER_JobTitle.toObject (_JobTitle)); //
        _Occupation.getPersistentSets (allSets);
        
    }


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

        
        PersistentSet   tl_ilo_job_titlePSet = allSets.getPersistentSet (objectID, "tl_ilo_job_title");

        _JobTitle = (String)(HELPER_JobTitle.fromObject (_JobTitle, tl_ilo_job_titlePSet.getAttrib (FIELD_JobTitle))); //
        _Occupation.setFromPersistentSets (objectID, allSets);
        
    }





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

        if (other instanceof ILOJobTitle)
        {
            ILOJobTitle otherILOJobTitle = (ILOJobTitle)other;
            
            try
            {
                setJobTitle (otherILOJobTitle.getJobTitle ());
            }
            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 BaseILOJobTitle)
        {
            BaseILOJobTitle sourceILOJobTitle = (BaseILOJobTitle)(source);

            _JobTitle = sourceILOJobTitle._JobTitle;
            
        }
    }


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

            _Occupation.copyFrom (sourceILOJobTitle._Occupation, linkToGhosts);
            
        }
    }


    /**
     * 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 BaseILOJobTitle)
        {
            BaseILOJobTitle sourceILOJobTitle = (BaseILOJobTitle)(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);

        _JobTitle = (String)(HELPER_JobTitle.readExternal (_JobTitle, vals.get(FIELD_JobTitle))); //
        _Occupation.readExternalData(vals.get(SINGLEREFERENCE_Occupation));
        
    }


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

        vals.put (FIELD_JobTitle, HELPER_JobTitle.writeExternal (_JobTitle));
        vals.put (SINGLEREFERENCE_Occupation, _Occupation.writeExternalData());
        
    }


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

        if (other instanceof BaseILOJobTitle)
        {
            BaseILOJobTitle otherILOJobTitle = (BaseILOJobTitle)(other);

            
            if (!HELPER_JobTitle.compare(this._JobTitle, otherILOJobTitle._JobTitle))
            {
                listener.notifyFieldChange(this, other, FIELD_JobTitle, HELPER_JobTitle.toObject(this._JobTitle), HELPER_JobTitle.toObject(otherILOJobTitle._JobTitle));
            }

            // Compare single assocs
            _Occupation.compare (otherILOJobTitle._Occupation, listener);
            

            // 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_JobTitle, HELPER_JobTitle.toObject(getJobTitle()));
        visitor.visitAssociation (_Occupation);
        
    }


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

        if (scope.includes (_Occupation))
        {
            visitor.visit (_Occupation);
        }
        
    }


    public static ILOJobTitle createILOJobTitle (ObjectTransaction transaction) throws StorageException
    {
        ILOJobTitle     result = new ILOJobTitle ();

        result.initialiseNewObject (transaction);

        return result;
    }


    public static ILOJobTitle getILOJobTitleByID (ObjectTransaction transaction, Long objectID) throws StorageException
    {
        return (ILOJobTitle)(transaction.getObjectByID (REFERENCE_ILOJobTitle, objectID));
    }

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


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

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

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

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

            
            public SearchAll andJobTitle (QueryFilter<String> filter)
            {
                filter.addFilter (context, "tl_ilo_job_title.job_title", "JobTitle");
                return this;
            }
            
            public SearchAll andOccupation (QueryFilter<Occupation> filter)
            {
                filter.addFilter (context, "tl_ilo_job_title.occupation_id", "Occupation");
                return this;
            }
            
                public ILOJobTitle[]
             search (ObjectTransaction transaction) throws StorageException
        {
            
            
            BaseBusinessClass[]     results = super.search (transaction, REFERENCE_ILOJobTitle, SEARCH_All, criteria);
            Set<ILOJobTitle>   typedResults = new LinkedHashSet <ILOJobTitle> ();
            for (BaseBusinessClass bbcResult : results)
            {
                ILOJobTitle aResult = (ILOJobTitle)bbcResult;
                
                typedResults.add (aResult);
            }
            
                    return ObjstoreUtils.removeDeleted(transaction, typedResults).toArray (new ILOJobTitle[0]);
                            
        }
    }

        
                public static ILOJobTitle[]
             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_JobTitle))
        {
            return HELPER_JobTitle.toObject (getJobTitle ());
        }
        else
        {
            return super.getAttribute (attribName);
        }
    }


    public AttributeHelper getAttributeHelper (String attribName)
    {
        if (false)
        {
            throw new RuntimeException ("Game over man!!");
        }
        else if (attribName.equals (FIELD_JobTitle))
        {
            return HELPER_JobTitle;
        }
        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_JobTitle))
        {
            setJobTitle ((String)(HELPER_JobTitle.fromObject (_JobTitle, 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_JobTitle))
        {
            return getWriteability_JobTitle ();
        }
        else if (fieldName.equals (SINGLEREFERENCE_Occupation))
        {
            return getWriteability_Occupation ();
        }
        else
        {
            return super.getWriteable (fieldName);
        }
    }


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

        super.putUnwriteable (fields);
    }

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

        
        result.add(HELPER_JobTitle.getAttribObject (getClass (), _JobTitle, false, FIELD_JobTitle));

        return result;
    }


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


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

    /**
     * Get the attribute JobTitle
     */
    public String getJobTitle (ILOJobTitle obj, String original)
    {
        return original;
    }

    /**
     * Change the value set for attribute JobTitle.
     * May modify the field beforehand
     * Occurs before validation.
     */
    public String setJobTitle (ILOJobTitle obj, String newJobTitle) throws FieldException
    {
        return newJobTitle;
    }

    }

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

        public ILOJobTitlePipeLineFactory (Collection<From> seed)
        {
            super(seed);
        }
        
        
        public PipeLine<From, ? extends Object> to(String name)
        {
            if (name.equals ("JobTitle"))
            {
                return toJobTitle ();
            }                
            if (name.equals ("Occupation"))
            {
                return toOccupation ();
            }                
            
            
            return super.to(name);
        }
        
        
        public PipeLine<From, String> toJobTitle () { return pipe(new ORMAttributePipe<Me, String>(FIELD_JobTitle));  }
        public Occupation.OccupationPipeLineFactory<From, Occupation> toOccupation () { return toOccupation (Filter.ALL); }

        public Occupation.OccupationPipeLineFactory<From, Occupation> toOccupation (Filter<Occupation> filter) 
        { 
            return Occupation.REFERENCE_Occupation.new OccupationPipeLineFactory<From, Occupation> (this, new ORMSingleAssocPipe<Me, Occupation>(SINGLEREFERENCE_Occupation, filter)); 
        }
        
    }
    
    public boolean isTransientAttrib(String attribName)
    {
        

        return super.isTransientAttrib(attribName);
    }

    public boolean isTransientSingleReference(String assocName)
    {
        

        return super.isTransientSingleReference(assocName);
    }
}

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

    public void assertValid ()
    {
    }


    public Occupation getOccupation () throws StorageException
    {
        return (Occupation)(Occupation.DUMMY_Occupation);
    }


    /**
     * Get the object id for the referenced object.  Does not force a DB access.
     */
    public Long getOccupationID ()
    {
        return Occupation.DUMMY_Occupation.getObjectID();
    }

}

