/*
 * IMPORTANT!!!! XSL Autogenerated class, DO NOT EDIT!!!!!
 * Template: Infrastructure9.0 [oneit.objstore.BusinessObjectTemplate.xsl]
 *   Vendor: Apache Software Foundation (Xalan XSLTC) (Version: 1.0)
 */
    
    
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.*;

// __#BUILD_NO_TABLE_NAME#: No table name == No persistence manager and scripts required.

public abstract class BaseSearchJob extends SearchExecutor
{
    // Reference instance for the object
    public static final SearchJob REFERENCE_SearchJob = new SearchJob ();

    // Reference instance for the object
    public static final SearchJob DUMMY_SearchJob = new DummySearchJob ();

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

    // Static constants corresponding to searches
    

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

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

    // Private attributes corresponding to single references
    

    // Private attributes corresponding to multiple references
    

    // Map of maps of metadata
    private static final Map ATTRIBUTES_METADATA_SearchJob = new LinkedHashMap ();

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

    // Arrays of AttributeDecorators for each attribute
    private static final AttributeDecorator<SearchJob, String>[] FIELD_Details_Decorators;
    
    
    // Arrays of SingleAssocDecorators for each attribute
    
    
    // Arrays of MultiAssocDecorators for each attribute
    

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

            FIELD_Details_Validators = (AttributeValidator[])setupAttribMetaData_Details(validatorMapping).toArray (new AttributeValidator[0]);
            FIELD_Details_Decorators = (AttributeDecorator[])AttributeDecoratorUtils.getAttributeDecorators(REFERENCE_SearchJob, FIELD_Details).toArray (new AttributeDecorator[0]);
            

            REFERENCE_SearchJob.initialiseReference ();
            DUMMY_SearchJob.initialiseReference ();
            SearchJob_BehaviourDecorators = BaseBusinessClass.getBBCBehaviours(SearchJob.class).toArray(new SearchJobBehaviourDecorator[0]);
        }
        catch (RuntimeException e)
        {
            LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR1, e, "Error initialising");
            throw e;
        }
    }

    
    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 SearchJob.Details:", metaInfo);
        ATTRIBUTES_METADATA_SearchJob.put (FIELD_Details, Collections.unmodifiableMap (metaInfo));

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

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


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

    


    protected void _initialiseNewObjAttributes (ObjectTransaction transaction) throws StorageException
    {
        super._initialiseNewObjAttributes (transaction);

        
        _Details = (String)(HELPER_Details.initialise (_Details));
    }


    protected void _initialiseAssociations ()
    {
        super._initialiseAssociations ();

        
    }


    protected BaseBusinessClass initialiseReference ()
    {
        super.initialiseReference ();
        
        
        
        return this;
    }


    /**
     * Attribute Details
     */
    public String getDetails ()
    {
        assertValid();
        String valToReturn = AttributeDecoratorUtils.getValue (FIELD_Details_Decorators, (SearchJob)this, FIELD_Details, _Details);

        
        for (SearchJobBehaviourDecorator bhd : SearchJob_BehaviourDecorators)
        {
            valToReturn = bhd.getDetails ((SearchJob)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
    {
        newDetails = AttributeDecoratorUtils.setValue (FIELD_Details_Decorators, (SearchJob)this, FIELD_Details, newDetails);

        boolean oldAndNewIdentical = HELPER_Details.compare (_Details, newDetails);
        
        try
        {
            for (SearchJobBehaviourDecorator bhd : SearchJob_BehaviourDecorators)
            {
                newDetails = bhd.setDetails ((SearchJob)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_SearchJob.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 (AttributeDecoratorUtils.getWriteability (FIELD_Details_Decorators, (SearchJob)this, FIELD_Details ,getWriteability_Details ()) != FieldWriteability.FALSE, "Field  Details is not writeable");
            preDetailsChange (newDetails);
            markFieldChange (FIELD_Details);
            _Details = newDetails;            
            postFieldChange (FIELD_Details);
            postDetailsChange ();
        }
    }



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


    public SearchJob referenceInstance ()
    {
        return REFERENCE_SearchJob;
    }


    public SearchJob getInTransaction (ObjectTransaction t) throws StorageException
    {
        return getSearchJobByID (t, getObjectID());
    }
    
    
    public BaseBusinessClass dummyInstance ()
    {
        return DUMMY_SearchJob;
    }


    public String getBaseSetName ()
    {
        return "";
    }



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

        PSet.setAttrib (FIELD_ObjectID, myID);
        PSet.setAttrib (FIELD_Details, HELPER_Details.toObject (_Details)); //
        
    }


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

        _Details = (String)(HELPER_Details.fromObject (_Details, PSet.getAttrib (FIELD_Details))); //
        
    }


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

        if (other instanceof SearchJob)
        {
            SearchJob otherSearchJob = (SearchJob)other;
            

            try
            {
                setDetails (otherSearchJob.getDetails ());
            }
            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 BaseSearchJob)
        {
            BaseSearchJob sourceSearchJob = (BaseSearchJob)(source);

            _Details = sourceSearchJob._Details;
            
        }
    }


    /**
     * 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 BaseSearchJob)
        {
            BaseSearchJob sourceSearchJob = (BaseSearchJob)(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 BaseSearchJob)
        {
            BaseSearchJob sourceSearchJob = (BaseSearchJob)(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))); //
        
    }


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


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

        if (other instanceof BaseSearchJob)
        {
            BaseSearchJob otherSearchJob = (BaseSearchJob)(other);

            
            if (!HELPER_Details.compare(this._Details, otherSearchJob._Details))
            {
                listener.notifyFieldChange(this, other, FIELD_Details, HELPER_Details.toObject(this._Details), HELPER_Details.toObject(otherSearchJob._Details));
            }

            // 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_Details, HELPER_Details.toObject(getDetails()));
        
    }


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

        
    }


    public static SearchJob createSearchJob (ObjectTransaction transaction) throws StorageException
    {
        SearchJob     result = new SearchJob ();

        result.initialiseNewObject (transaction);

        return result;
    }


    public static SearchJob getSearchJobByID (ObjectTransaction transaction, Long objectID) throws StorageException
    {
        return (SearchJob)(transaction.getObjectByID (REFERENCE_SearchJob, 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
        {
            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
        {
            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
        {
            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
        {
            super.setAttribute (attribName, attribValue);
        }
    }

    

    public boolean isWriteable (String fieldName)
    {        
        return getWriteable (fieldName) == FieldWriteability.TRUE;
    }

    public boolean isReadable ()
    {
        return super.isReadable();
    }

    public boolean isReadable (String fieldName)
    {
        return super.isReadable(fieldName);
    }


    public FieldWriteability getWriteable (String fieldName)
    {
        if (false)
        {
            throw new RuntimeException ("Game over man!!");
        }
        else if (fieldName.equals (FIELD_Details))
        {
            return getWriteability_Details ();
        }
        else
        {
            return super.getWriteable (fieldName);
        }
    }


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

        super.putUnwriteable (fields);
    }

    // This generally means there's no specific persistence manager and we don't read or write from a table
    public boolean hasNoTable()
    {
        return true;
    }


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

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

        return result;
    }


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


    public Object getAttributeMetadata (String attribute, String metadata)
    {
        if (ATTRIBUTES_METADATA_SearchJob.containsKey (attribute))
        {
            return ((Map)ATTRIBUTES_METADATA_SearchJob.get (attribute)).get(metadata);
        }
        else
        {
            return super.getAttributeMetadata (attribute, metadata);
        }
    }

    public void copyAllAttributeMetadata (Map copyInto)
    {
        super.copyAllAttributeMetadata(copyInto);

        copyInto.putAll(ATTRIBUTES_METADATA_SearchJob);
    }
            

    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 SearchJobBehaviourDecorator extends BaseBusinessClass.BBCBehaviourDecorator<SearchJob>
    {

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

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

    }

    @Override
    public ORMPipeLine pipes()
    {
        return new SearchJobPipeLineFactory<SearchJob, SearchJob> ((SearchJob)this);
    }

    @Override
    public ORMPipeLine pipes(Collection _items)
    {
        return pipesSearchJob(_items);
    }
      
    /**
     * Use this instead of pipes() to get rid of type casting.
     */  
    public SearchJobPipeLineFactory<SearchJob, SearchJob> pipelineSearchJob()
    {
        return (SearchJobPipeLineFactory<SearchJob, SearchJob>) pipes();
    }
    
    public static SearchJobPipeLineFactory<SearchJob, SearchJob> pipesSearchJob(Collection<SearchJob> items)
    {
        return REFERENCE_SearchJob.new SearchJobPipeLineFactory<SearchJob, SearchJob> (items);
    }
    
    public static SearchJobPipeLineFactory<SearchJob, SearchJob> pipesSearchJob(SearchJob[] _items)
    {
        return pipesSearchJob(Arrays.asList (_items));
    }
    
    public static SearchJobPipeLineFactory<SearchJob, SearchJob> pipesSearchJob()
    {
        return pipesSearchJob((Collection)null);
    }
    
    
    public class SearchJobPipeLineFactory<From extends BaseBusinessClass, Me extends SearchJob> extends SearchExecutorPipeLineFactory<From, Me>    
    {
        public <Prev> SearchJobPipeLineFactory (PipeLine<From, Prev> pipeLine, Pipe<Prev, Me> nextPipe)
        {
            super (pipeLine, nextPipe);
        }
        
        public SearchJobPipeLineFactory (From seed)
        {
            super(seed);
        }

        public SearchJobPipeLineFactory (Collection<From> seed)
        {
            super(seed);
        }
        
        
        public PipeLine<From, ? extends Object> to(String name)
        {
            if (name.equals ("Details"))
            {
                return toDetails ();
            }                
            
            
            return super.to(name);
        }
        
        
        public PipeLine<From, String> toDetails () { return pipe(new ORMAttributePipe<Me, String>(FIELD_Details));  }
    }
    
    public boolean isTransientAttrib(String attribName)
    {
        

        return super.isTransientAttrib(attribName);
    }

    public boolean isTransientSingleReference(String assocName)
    {
        

        return super.isTransientSingleReference(assocName);
    }
}

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

    public void assertValid ()
    {
    }


}

    
