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

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 oneit.servlets.orm.*;

import performa.orm.*;

import performa.orm.types.*;



public abstract class BaseSearchApplicant extends SearchExecutor
{
    // Reference instance for the object
    public static final SearchApplicant REFERENCE_SearchApplicant = new SearchApplicant ();

    // Reference instance for the object
    public static final SearchApplicant DUMMY_SearchApplicant = new DummySearchApplicant ();

    // Static constants corresponding to field names
    
    public static final String FIELD_Details = "Details";
    public static final String FIELD_Filter = "Filter";
    public static final String SINGLEREFERENCE_Job = "Job";

    // Static constants corresponding to searches
    

    // Static constants corresponding to attribute helpers
    private static final DefaultAttributeHelper<SearchApplicant> HELPER_Details = DefaultAttributeHelper.INSTANCE;
    private static final DelimitedEnumsAttributeHelper HELPER_Filter = new DelimitedEnumsAttributeHelper (AppFilter.FACTORY_AppFilter);
    

    // Private attributes corresponding to business object data
    private String _Details;
    private Set<AppFilter> _Filter;
    

    // Private attributes corresponding to single references
    private SingleAssociation<SearchApplicant, Job> _Job;
    

    // Private attributes corresponding to multiple references
    

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

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

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

            setupAssocMetaData_Job();
            FIELD_Details_Validators = (AttributeValidator[])setupAttribMetaData_Details(validatorMapping).toArray (new AttributeValidator[0]);
            FIELD_Filter_Validators = (AttributeValidator[])setupAttribMetaData_Filter(validatorMapping).toArray (new AttributeValidator[0]);
            

            REFERENCE_SearchApplicant.initialiseReference ();
            DUMMY_SearchApplicant.initialiseReference ();
            SearchApplicant_BehaviourDecorators = BaseBusinessClass.getBBCBehaviours(SearchApplicant.class).toArray(new SearchApplicantBehaviourDecorator[0]);
        }
        catch (RuntimeException e)
        {
            LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR1, e, "Error initialising");
            throw e;
        }
    }

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

        metaInfo.put ("dbcol", "xxxx");
        metaInfo.put ("name", "Job");
        metaInfo.put ("type", "Job");
        
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for SearchApplicant.Job:", metaInfo);
        ATTRIBUTES_METADATA_SearchApplicant.put (SINGLEREFERENCE_Job, Collections.unmodifiableMap (metaInfo));
    }
    
    
    // Meta Info setup
    private static List setupAttribMetaData_Details(Map validatorMapping)
    {
        Map  metaInfo   = new HashMap ();

        metaInfo.put ("dbcol", "xxxx");
        metaInfo.put ("name", "Details");
        metaInfo.put ("type", "String");
        
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for SearchApplicant.Details:", metaInfo);
        ATTRIBUTES_METADATA_SearchApplicant.put (FIELD_Details, Collections.unmodifiableMap (metaInfo));

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

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

        metaInfo.put ("attribHelper", "DelimitedEnumsAttributeHelper");
        metaInfo.put ("attribHelperInstance", "new DelimitedEnumsAttributeHelper (AppFilter.FACTORY_AppFilter)");
        metaInfo.put ("dbcol", "xxxx");
        metaInfo.put ("name", "Filter");
        metaInfo.put ("type", "Set<AppFilter>");
        
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for SearchApplicant.Filter:", metaInfo);
        ATTRIBUTES_METADATA_SearchApplicant.put (FIELD_Filter, Collections.unmodifiableMap (metaInfo));

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

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


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


    


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

        
        _Details = (String)(HELPER_Details.initialise (_Details));
        _Filter = (Set<AppFilter>)(HELPER_Filter.initialise (_Filter));
    }


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

        _Job = new SingleAssociation<SearchApplicant, Job> (this, SINGLEREFERENCE_Job, null, Job.REFERENCE_Job, "it_does_not_matter");
        
    }


    // Initialise the associations
    protected BaseBusinessClass initialiseReference ()
    {
        super.initialiseReference ();
        
        _Job = new SingleAssociation<SearchApplicant, Job> (this, SINGLEREFERENCE_Job, null, Job.REFERENCE_Job, "it_does_not_matter");
        
        
        return this;
    }

    

    /**
     * Get the attribute Details
     */
    public String getDetails ()
    {
        assertValid();
        String valToReturn = _Details;

            for (SearchApplicantBehaviourDecorator bhd : SearchApplicant_BehaviourDecorators)
            {
                valToReturn = bhd.getDetails ((SearchApplicant)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 preDetailsChange (String newDetails) 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 postDetailsChange () throws FieldException
    {
    }

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

    /**
     * Set the attribute Details.  Checks to ensure a new value
     * has been supplied.  If so, marks the field as altered and sets the attribute.
     */
    public void setDetails (String newDetails) throws FieldException
    {
        boolean oldAndNewIdentical = HELPER_Details.compare (_Details, newDetails);
        
        try
        {
            for (SearchApplicantBehaviourDecorator bhd : SearchApplicant_BehaviourDecorators)
            {
                newDetails = bhd.setDetails ((SearchApplicant)this, newDetails);
                oldAndNewIdentical = HELPER_Details.compare (_Details, newDetails);
            }

            

            if (FIELD_Details_Validators.length > 0)
            {
                Object newDetailsObj = HELPER_Details.toObject (newDetails);

                if (newDetailsObj != null)
                {
                    int     loopMax = FIELD_Details_Validators.length;
                    Map     metadata = (Map)ATTRIBUTES_METADATA_SearchApplicant.get (FIELD_Details);

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

        if (!oldAndNewIdentical)
        {
            assertValid();
            Debug.assertion (getWriteability_Details () != FieldWriteability.FALSE, "Field  Details is not writeable");
            preDetailsChange (newDetails);
            markFieldChange (FIELD_Details);
            _Details = newDetails;            
            postFieldChange (FIELD_Details);
            postDetailsChange ();
        }
    }

    /**
     * Get the attribute Filter
     */
    public Set<AppFilter> getFilter ()
    {
        assertValid();
        Set<AppFilter> valToReturn = _Filter;

            for (SearchApplicantBehaviourDecorator bhd : SearchApplicant_BehaviourDecorators)
            {
                valToReturn = bhd.getFilter ((SearchApplicant)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 preFilterChange (Set<AppFilter> newFilter) 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 postFilterChange () throws FieldException
    {
    }

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

    /**
     * Set the attribute Filter.  Checks to ensure a new value
     * has been supplied.  If so, marks the field as altered and sets the attribute.
     */
    public void setFilter (Set<AppFilter> newFilter) throws FieldException
    {
        boolean oldAndNewIdentical = HELPER_Filter.compare (_Filter, newFilter);
        
        try
        {
            for (SearchApplicantBehaviourDecorator bhd : SearchApplicant_BehaviourDecorators)
            {
                newFilter = bhd.setFilter ((SearchApplicant)this, newFilter);
                oldAndNewIdentical = HELPER_Filter.compare (_Filter, newFilter);
            }

            

            if (FIELD_Filter_Validators.length > 0)
            {
                Object newFilterObj = HELPER_Filter.toObject (newFilter);

                if (newFilterObj != null)
                {
                    int     loopMax = FIELD_Filter_Validators.length;
                    Map     metadata = (Map)ATTRIBUTES_METADATA_SearchApplicant.get (FIELD_Filter);

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

        if (!oldAndNewIdentical)
        {
            assertValid();
            Debug.assertion (getWriteability_Filter () != FieldWriteability.FALSE, "Field  Filter is not writeable");
            preFilterChange (newFilter);
            markFieldChange (FIELD_Filter);
            _Filter = newFilter;            
            postFieldChange (FIELD_Filter);
            postFilterChange ();
        }
    }



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

        
        result.add("Job");
        

        return result;
    }
    
    
    public BaseBusinessClass getSingleAssocReferenceInstance (String assocName)
    {
        if (assocName == null)
        {
            throw new RuntimeException ("Game over == null!");
        }
        else if (assocName.equals (SINGLEREFERENCE_Job))
        {
            return _Job.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_Job))
        {
            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_Job))
        {
            return getJob ();
        }
        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_Job))
        {
            return getJob (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_Job))
        {
            return getJobID ();
        }
        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_Job))
        {
            setJob ((Job)(newValue));
        }
        else
        {
            super.setSingleAssoc (assocName, newValue);
        }
    }



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


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


    /**
     * Get the object id for the referenced object.  Does not force a DB access.
     */
    public Long getJobID ()
    {
        assertValid();
        
        if (_Job == null)
        {
            return null;
        }
        else
        {
            return _Job.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 preJobChange (Job newJob) 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 postJobChange () throws FieldException
    {
    }



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

        if (_Job.wouldReferencedChange (newJob))
        {
            assertValid();
            Debug.assertion (getWriteability_Job () != FieldWriteability.FALSE, "Assoc Job is not writeable");
            preJobChange (newJob);
            
                    _Job.set (newJob);
                
            postJobChange ();
        }
    }

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


    public SearchApplicant referenceInstance ()
    {
        return REFERENCE_SearchApplicant;
    }


    public SearchApplicant getInTransaction (ObjectTransaction t) throws StorageException
    {
        return getSearchApplicantByID (t, getObjectID());
    }
    
    
    public BaseBusinessClass dummyInstance ()
    {
        return DUMMY_SearchApplicant;
    }


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





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

        it_does_not_matterPSet.setAttrib (FIELD_ObjectID, myID);
        it_does_not_matterPSet.setAttrib (FIELD_Details, HELPER_Details.toObject (_Details)); //
        it_does_not_matterPSet.setAttrib (FIELD_Filter, HELPER_Filter.toObject (_Filter)); //
        _Job.getPersistentSets (allSets);
        
    }


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

        
        PersistentSet   it_does_not_matterPSet = allSets.getPersistentSet (objectID, "it_does_not_matter");

        _Details = (String)(HELPER_Details.fromObject (_Details, it_does_not_matterPSet.getAttrib (FIELD_Details))); //
        _Filter = (Set<AppFilter>)(HELPER_Filter.fromObject (_Filter, it_does_not_matterPSet.getAttrib (FIELD_Filter))); //
        _Job.setFromPersistentSets (objectID, allSets);
        
    }





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

        if (other instanceof SearchApplicant)
        {
            SearchApplicant otherSearchApplicant = (SearchApplicant)other;
            
            try
            {
                setDetails (otherSearchApplicant.getDetails ());
            }
            catch (FieldException ex)
            {
                e.addException (ex);
            }
            
            try
            {
                setFilter (otherSearchApplicant.getFilter ());
            }
            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 BaseSearchApplicant)
        {
            BaseSearchApplicant sourceSearchApplicant = (BaseSearchApplicant)(source);

            _Details = sourceSearchApplicant._Details;
            _Filter = sourceSearchApplicant._Filter;
            
        }
    }


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

            _Job.copyFrom (sourceSearchApplicant._Job, 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 BaseSearchApplicant)
        {
            BaseSearchApplicant sourceSearchApplicant = (BaseSearchApplicant)(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);

        _Details = (String)(HELPER_Details.readExternal (_Details, vals.get(FIELD_Details))); //
        _Filter = (Set<AppFilter>)(HELPER_Filter.readExternal (_Filter, vals.get(FIELD_Filter))); //
        _Job.readExternalData(vals.get(SINGLEREFERENCE_Job));
        
    }


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

        vals.put (FIELD_Details, HELPER_Details.writeExternal (_Details));
        vals.put (FIELD_Filter, HELPER_Filter.writeExternal (_Filter));
        vals.put (SINGLEREFERENCE_Job, _Job.writeExternalData());
        
    }


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

        if (other instanceof BaseSearchApplicant)
        {
            BaseSearchApplicant otherSearchApplicant = (BaseSearchApplicant)(other);

            
            if (!HELPER_Details.compare(this._Details, otherSearchApplicant._Details))
            {
                listener.notifyFieldChange(this, other, FIELD_Details, HELPER_Details.toObject(this._Details), HELPER_Details.toObject(otherSearchApplicant._Details));
            }
            if (!HELPER_Filter.compare(this._Filter, otherSearchApplicant._Filter))
            {
                listener.notifyFieldChange(this, other, FIELD_Filter, HELPER_Filter.toObject(this._Filter), HELPER_Filter.toObject(otherSearchApplicant._Filter));
            }

            // Compare single assocs
            _Job.compare (otherSearchApplicant._Job, 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_Details, HELPER_Details.toObject(getDetails()));
        visitor.visitField(this, FIELD_Filter, HELPER_Filter.toObject(getFilter()));
        visitor.visitAssociation (_Job);
        
    }


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

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


    public static SearchApplicant createSearchApplicant (ObjectTransaction transaction) throws StorageException
    {
        SearchApplicant     result = new SearchApplicant ();

        result.initialiseNewObject (transaction);

        return result;
    }


    public static SearchApplicant getSearchApplicantByID (ObjectTransaction transaction, Long objectID) throws StorageException
    {
        return (SearchApplicant)(transaction.getObjectByID (REFERENCE_SearchApplicant, objectID));
    }

    public boolean testFilter (String attribName, QueryFilter filter) throws StorageException
    {
        if (false)
        {
            throw new RuntimeException ("Game over man!!");
        }
        else if (attribName.equals (FIELD_Details))
        {
            return filter.matches (getDetails ());
        }
        else if (attribName.equals (FIELD_Filter))
        {
            return filter.matches (getFilter ());
        }
        else if (attribName.equals (SINGLEREFERENCE_Job))
        {
            return filter.matches (getJob ());
        }
        else
        {
            return super.testFilter (attribName, filter);
        }
    }




    public Object getAttribute (String attribName)
    {
        if (false)
        {
            throw new RuntimeException ("Game over man!!");
        }
        else if (attribName.equals (FIELD_Details))
        {
            return HELPER_Details.toObject (getDetails ());
        }
        else if (attribName.equals (FIELD_Filter))
        {
            return HELPER_Filter.toObject (getFilter ());
        }
        else
        {
            return super.getAttribute (attribName);
        }
    }


    public AttributeHelper getAttributeHelper (String attribName)
    {
        if (false)
        {
            throw new RuntimeException ("Game over man!!");
        }
        else if (attribName.equals (FIELD_Details))
        {
            return HELPER_Details;
        }
        else if (attribName.equals (FIELD_Filter))
        {
            return HELPER_Filter;
        }
        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_Details))
        {
            setDetails ((String)(HELPER_Details.fromObject (_Details, attribValue)));            
        }
        else if (attribName.equals (FIELD_Filter))
        {
            setFilter ((Set<AppFilter>)(HELPER_Filter.fromObject (_Filter, 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_Details))
        {
            return getWriteability_Details ();
        }
        else if (fieldName.equals (FIELD_Filter))
        {
            return getWriteability_Filter ();
        }
        else if (fieldName.equals (SINGLEREFERENCE_Job))
        {
            return getWriteability_Job ();
        }
        else
        {
            return super.getWriteable (fieldName);
        }
    }


    public void putUnwriteable (Set<String> fields)
    {
        
            if (getWriteability_Details () != FieldWriteability.TRUE)
            {
                fields.add (FIELD_Details);
            }
        
            if (getWriteability_Filter () != FieldWriteability.TRUE)
            {
                fields.add (FIELD_Filter);
            }
        

        super.putUnwriteable (fields);
    }

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

        
        result.add(HELPER_Details.getAttribObject (getClass (), _Details, false, FIELD_Details));
        result.add(HELPER_Filter.getAttribObject (getClass (), _Filter, false, FIELD_Filter));

        return result;
    }


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


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

    /**
     * Get the attribute Details
     */
    public String getDetails (SearchApplicant obj, String original)
    {
        return original;
    }

    /**
     * Change the value set for attribute Details.
     * May modify the field beforehand
     * Occurs before validation.
     */
    public String setDetails (SearchApplicant obj, String newDetails) throws FieldException
    {
        return newDetails;
    }

    /**
     * Get the attribute Filter
     */
    public Set<AppFilter> getFilter (SearchApplicant obj, Set<AppFilter> original)
    {
        return original;
    }

    /**
     * Change the value set for attribute Filter.
     * May modify the field beforehand
     * Occurs before validation.
     */
    public Set<AppFilter> setFilter (SearchApplicant obj, Set<AppFilter> newFilter) throws FieldException
    {
        return newFilter;
    }

    }

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

        public SearchApplicantPipeLineFactory (Collection<From> seed)
        {
            super(seed);
        }
        
        
        public PipeLine<From, ? extends Object> to(String name)
        {
            if (name.equals ("Details"))
            {
                return toDetails ();
            }                
            if (name.equals ("Filter"))
            {
                return toFilter ();
            }                
            if (name.equals ("Job"))
            {
                return toJob ();
            }                
            
            
            return super.to(name);
        }
        
        
        public PipeLine<From, String> toDetails () { return pipe(new ORMAttributePipe<Me, String>(FIELD_Details));  }
        
        public PipeLine<From, Set<AppFilter>> toFilter () { return pipe(new ORMAttributePipe<Me, Set<AppFilter>>(FIELD_Filter));  }
        public Job.JobPipeLineFactory<From, Job> toJob () { return toJob (Filter.ALL); }

        public Job.JobPipeLineFactory<From, Job> toJob (Filter<Job> filter) 
        { 
            return Job.REFERENCE_Job.new JobPipeLineFactory<From, Job> (this, new ORMSingleAssocPipe<Me, Job>(SINGLEREFERENCE_Job, filter)); 
        }
        
    }
    
    public boolean isTransientAttrib(String attribName)
    {
        

        return super.isTransientAttrib(attribName);
    }

    public boolean isTransientSingleReference(String assocName)
    {
        

        return super.isTransientSingleReference(assocName);
    }
}

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

    public void assertValid ()
    {
    }


    public Job getJob () throws StorageException
    {
        return (Job)(Job.DUMMY_Job);
    }


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

}

    
