Commit 82dc9710 by Nilu

search applicant added

parent e1456be0
<?xml version="1.0" encoding="UTF-8"?>
<!-- @AutoRun -->
<OBJECTS name="" xmlns:oneit="http://www.1iT.com.au"><NODE name="Script" factory="Vector">
<NODE name="DDL" factory="Participant" class="oneit.sql.transfer.DefineTableOperation">
<tableName factory="String">it_does_not_matter</tableName>
<column name="object_id" type="Long" nullable="false" length="11"/>
<column name="object_last_updated_date" type="Date" nullable="false" length="22"/>
<column name="object_created_date" type="Date" nullable="false" length="22"/>
<column name="xxxx" type="CLOB" nullable="true"/>
<column name="xxxx" type="Long" length="11" nullable="true"/>
</NODE>
</NODE></OBJECTS>
\ No newline at end of file
-- DROP TABLE it_does_not_matter;
CREATE TABLE it_does_not_matter (
object_id int NOT NULL ,
object_last_updated_date datetime DEFAULT getdate() NOT NULL ,
object_created_date datetime DEFAULT getdate() NOT NULL
,
xxxx text NULL,
xxxx numeric(12) NULL
);
ALTER TABLE it_does_not_matter ADD
CONSTRAINT PK_it_does_not_matter PRIMARY KEY
(
object_id
) ;
\ No newline at end of file
-- DROP TABLE it_does_not_matter;
CREATE TABLE it_does_not_matter (
object_id number(12) NOT NULL ,
object_last_updated_date date DEFAULT SYSDATE NOT NULL ,
object_created_date date DEFAULT SYSDATE NOT NULL
,
xxxx clob NULL,
xxxx number(12) NULL
);
ALTER TABLE it_does_not_matter ADD
CONSTRAINT PK_it_does_not_matter PRIMARY KEY
(
object_id
) ;
\ No newline at end of file
-- @AutoRun
-- drop table it_does_not_matter;
CREATE TABLE it_does_not_matter (
object_id numeric(12) NOT NULL ,
object_last_updated_date timestamp DEFAULT NOW() NOT NULL ,
object_created_date timestamp DEFAULT NOW() NOT NULL
,
xxxx text NULL,
xxxx numeric(12) NULL
);
ALTER TABLE it_does_not_matter ADD
CONSTRAINT pk_it_does_not_matter PRIMARY KEY
(
object_id
) ;
\ No newline at end of file
/*
* 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.*;
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 SINGLEREFERENCE_Job = "Job";
// Static constants corresponding to searches
// Static constants corresponding to attribute helpers
private static final DefaultAttributeHelper<SearchApplicant> HELPER_Details = DefaultAttributeHelper.INSTANCE;
// Private attributes corresponding to business object data
private String _Details;
// 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;
// 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]);
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;
}
// 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));
}
// 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 ();
}
}
/**
* 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)); //
_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))); //
_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);
}
}
}
/**
* 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;
}
}
/**
* 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))); //
_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 (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));
}
// 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.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 (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
{
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 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 (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);
}
super.putUnwriteable (fields);
}
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_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;
}
}
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 ("Job"))
{
return toJob ();
}
return super.to(name);
}
public PipeLine<From, String> toDetails () { return pipe(new ORMAttributePipe<Me, String>(FIELD_Details)); }
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();
}
}
package performa.search;
import oneit.objstore.BaseBusinessClass;
import oneit.objstore.rdbms.filters.EqualsFilter;
import performa.orm.JobApplication;
public class SearchApplicant extends BaseSearchApplicant
{
private static final long serialVersionUID = 0L;
// This constructor should not be called
public SearchApplicant ()
{
// Do not add any code to this, always put it in initialiseNewObject
}
@Override
public BaseBusinessClass[] doSearch()
{
return JobApplication.SearchByDetails()
.byName(getDetails())
.andJob(new EqualsFilter<>(getJob()))
.search(getTransaction());
}
}
\ No newline at end of file
package performa.search;
import java.io.*;
import java.util.*;
import java.sql.ResultSet;
import java.sql.SQLException;
import oneit.logging.*;
import oneit.objstore.*;
import oneit.objstore.assocs.*;
import oneit.objstore.rdbms.*;
import oneit.objstore.utils.*;
import oneit.sql.*;
import oneit.utils.resource.*;
import oneit.utils.*;
import oneit.utils.threading.*;
import oneit.servlets.orm.*;
import performa.orm.*;
/**
* IMPORTANT!!!! Autogenerated class, DO NOT EDIT!!!!!
* Template: Infrastructure8.2[oneit.objstore.PersistenceMgrTemplate.xsl]
*/
public class SearchApplicantPersistenceMgr extends SearchExecutorPersistenceMgr
{
private static final LoggingArea SearchApplicantPersistence = LoggingArea.createLoggingArea(ObjectPersistenceMgr.OBJECT_PERSISTENCE, "SearchApplicant");
// Private attributes corresponding to business object data
private String dummyDetails;
// Static constants corresponding to attribute helpers
private static final DefaultAttributeHelper HELPER_Details = DefaultAttributeHelper.INSTANCE;
public SearchApplicantPersistenceMgr ()
{
dummyDetails = (String)(HELPER_Details.initialise (dummyDetails));
}
private String SELECT_COLUMNS = "{PREFIX}it_does_not_matter.object_id as id, {PREFIX}it_does_not_matter.object_LAST_UPDATED_DATE as LAST_UPDATED_DATE, {PREFIX}it_does_not_matter.object_CREATED_DATE as CREATED_DATE, {PREFIX}it_does_not_matter.xxxx, {PREFIX}it_does_not_matter.xxxx, 1 AS commasafe ";
private String SELECT_JOINS = "";
public BaseBusinessClass fetchByID(ObjectID id, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException
{
Set<BaseBusinessClass> resultByIDs = fetchByIDs(Collections.singleton (id), allPSets, context, sqlMgr);
if (resultByIDs.isEmpty ())
{
return null;
}
else if (resultByIDs.size () > 1)
{
throw new StorageException ("Multiple results for id:" + id);
}
else
{
return resultByIDs.iterator ().next ();
}
}
public Set<BaseBusinessClass> fetchByIDs(Set<ObjectID> ids, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException
{
Set<BaseBusinessClass> results = new HashSet ();
Set<Long> idsToFetch = new HashSet ();
for (ObjectID id : ids)
{
if (context.containsObject(id)) // Check for cached version
{
BaseBusinessClass objectToReturn = context.getObjectToReplace(id, SearchApplicant.REFERENCE_SearchApplicant);
if (objectToReturn instanceof SearchApplicant)
{
LogMgr.log (SearchApplicantPersistence, LogLevel.TRACE, "Cache hit for id:", id);
results.add (objectToReturn);
}
else
{
throw new StorageException ("Cache collision for id:" + id + " with object " + objectToReturn + "while fetching a SearchApplicant");
}
}
PersistentSet it_does_not_matterPSet = allPSets.getPersistentSet(id, "it_does_not_matter", PersistentSetStatus.FETCHED);
// Check for persistent sets already prefetched
if (false || !it_does_not_matterPSet.containsAttrib(BaseBusinessClass.FIELD_ObjectLastModified) ||
!it_does_not_matterPSet.containsAttrib(SearchApplicant.FIELD_Details)||
!it_does_not_matterPSet.containsAttrib(SearchApplicant.SINGLEREFERENCE_Job))
{
// We will need to retrieve it
idsToFetch.add (id.longValue());
}
else
{
LogMgr.log (SearchApplicantPersistence, LogLevel.DEBUG2, "Persistent set preloaded id:", id);
/* Non Polymorphic */
SearchApplicant result = new SearchApplicant ();
result.setFromPersistentSets(id, allPSets);
context.addRetrievedObject(result);
results.add (result);
}
}
if (idsToFetch.size () > 0)
{
String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}it_does_not_matter " +
"WHERE " + SELECT_JOINS + "{PREFIX}it_does_not_matter.object_id IN ?";
BaseBusinessClass[] resultsFetched = loadQuery (allPSets, sqlMgr, context, query, new Object[] { idsToFetch }, null, false);
for (BaseBusinessClass objFetched : resultsFetched)
{
results.add (objFetched);
}
}
return results;
}
public BaseBusinessClass[] getReferencedObjects(ObjectID _objectID, String refName, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException
{
if (false)
{
throw new RuntimeException ();
}
else
{
throw new IllegalArgumentException ("Illegal reference type:" + refName);
}
}
public void update(BaseBusinessClass obj, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, ConcurrentUpdateConflictException, StorageException
{
EqualityResult test = EqualityResult.compare (obj, obj.getBackup ());
ObjectID objectID = obj.getID ();
if (!test.areAttributesEqual () || !test.areSingleAssocsEqual () || obj.getForcedSave())
{
PersistentSet it_does_not_matterPSet = allPSets.getPersistentSet(objectID, "it_does_not_matter");
if (it_does_not_matterPSet.getStatus () != PersistentSetStatus.PROCESSED &&
it_does_not_matterPSet.getStatus () != PersistentSetStatus.DEFERRED)
{
int rowsUpdated = executeStatement (sqlMgr,
"UPDATE {PREFIX}it_does_not_matter " +
"SET xxxx = ?, xxxx = ? , object_LAST_UPDATED_DATE = " + sqlMgr.getPortabilityServices ().getTimestampExpression () + " " +
"WHERE it_does_not_matter.object_id = ? AND " + getConcurrencyCheck (sqlMgr, "object_LAST_UPDATED_DATE", obj.getObjectLastModified ()) + " ",
CollectionUtils.listEntry (HELPER_Details.getForSQL(dummyDetails, it_does_not_matterPSet.getAttrib (SearchApplicant.FIELD_Details))).listEntry (SQLManager.CheckNull((Long)(it_does_not_matterPSet.getAttrib (SearchApplicant.SINGLEREFERENCE_Job)))).listEntry (objectID.longID ()).listEntry (obj.getObjectLastModified ()).toList().toArray());
if (rowsUpdated != 1)
{
// Error, either a concurrency error or a not-exists error
ResultSet r = executeQuery (sqlMgr,
"SELECT object_id, object_LAST_UPDATED_DATE FROM {PREFIX}it_does_not_matter WHERE object_id = ?",
new Object[] { objectID.longID () });
if (r.next ())
{
Date d = new java.util.Date (r.getTimestamp (2).getTime());
String errorMsg = QueryBuilder.buildQueryString ("Concurrent update error:[?] for row:[?] objDate:[?] dbDate:[?]",
new Object[] { "it_does_not_matter", objectID.longID (), obj.getObjectLastModified (), d },
sqlMgr.getPortabilityServices ());
LogMgr.log (SearchApplicantPersistence, LogLevel.BUSINESS1, errorMsg);
throw new ConcurrentUpdateConflictException (obj, "it_does_not_matter");
}
else
{
String errorMsg = "Attempt to update nonexistent row in table:it_does_not_matter for row:" + objectID + " objDate:" + obj.getObjectLastModified ();
LogMgr.log (SearchApplicantPersistence, LogLevel.BUSINESS1, errorMsg);
throw new RuntimeException (errorMsg);
}
}
it_does_not_matterPSet.setStatus (PersistentSetStatus.PROCESSED);
}
}
else
{
LogMgr.log (SearchApplicantPersistence, LogLevel.DEBUG1, "Skipping update since no attribs or simple assocs changed on ", objectID);
}
}
public void delete(BaseBusinessClass obj, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, ConcurrentUpdateConflictException, StorageException
{
ObjectID objectID = obj.getID ();
PersistentSet it_does_not_matterPSet = allPSets.getPersistentSet(objectID, "it_does_not_matter");
LogMgr.log (SearchApplicantPersistence, LogLevel.DEBUG2, "Deleting:", objectID);
if (it_does_not_matterPSet.getStatus () != PersistentSetStatus.PROCESSED &&
it_does_not_matterPSet.getStatus () != PersistentSetStatus.DEFERRED)
{
int rowsDeleted = executeStatement (sqlMgr,
"DELETE " +
"FROM {PREFIX}it_does_not_matter " +
"WHERE it_does_not_matter.object_id = ? AND " + sqlMgr.getPortabilityServices ().getTruncatedTimestampColumn ("object_LAST_UPDATED_DATE") + " = " + sqlMgr.getPortabilityServices ().getTruncatedTimestampParam("?") + " ",
new Object[] { objectID.longID(), obj.getObjectLastModified () });
if (rowsDeleted != 1)
{
// Error, either a concurrency error or a not-exists error
ResultSet r = executeQuery (sqlMgr,
"SELECT object_id FROM {PREFIX}it_does_not_matter WHERE object_id = ?",
new Object[] { objectID.longID() });
if (r.next ())
{
throw new ConcurrentUpdateConflictException (obj, "it_does_not_matter");
}
else
{
String errorMsg = "Attempt to delete nonexistent row in table:it_does_not_matter for row:" + objectID;
LogMgr.log (SearchApplicantPersistence, LogLevel.SYSTEMERROR1, errorMsg);
throw new RuntimeException (errorMsg);
}
}
it_does_not_matterPSet.setStatus (PersistentSetStatus.PROCESSED);
}
}
public BaseBusinessClass[] loadQuery (PersistentSetCollection allPSets, SQLManager sqlMgr, RDBMSPersistenceContext context, String query, Object[] params, Integer maxRows, boolean truncateExtra) throws SQLException, StorageException
{
LinkedHashMap<ObjectID, SearchApplicant> results = new LinkedHashMap ();
ResultSet r = executeQuery (sqlMgr, query, params);
while (r.next())
{
ThreadUtils.checkInterrupted ();
ObjectID objectID = new ObjectID (SearchApplicant.REFERENCE_SearchApplicant.getObjectIDSpace (), r.getLong ("id"));
SearchApplicant resultElement;
if (maxRows != null && !results.containsKey (objectID) && results.size () >= maxRows)
{
if (truncateExtra)
{
break;
}
else
{
throw new SearchRowsExceededException ("Maximum rows exceeded:" + maxRows);
}
}
if (context.containsObject(objectID))
{
BaseBusinessClass cachedElement = context.getObjectToReplace(objectID, SearchApplicant.REFERENCE_SearchApplicant);
if (cachedElement instanceof SearchApplicant)
{
LogMgr.log (SearchApplicantPersistence, LogLevel.TRACE, "Cache hit for id:", objectID);
resultElement = (SearchApplicant)cachedElement;
}
else
{
throw new StorageException ("Cache collision for id:" + objectID + " with object " + cachedElement + "while fetching a SearchApplicant");
}
}
else
{
PersistentSet it_does_not_matterPSet = allPSets.getPersistentSet(objectID, "it_does_not_matter", PersistentSetStatus.FETCHED);
createPersistentSetFromRS(allPSets, r, objectID);
resultElement = new SearchApplicant ();
resultElement.setFromPersistentSets(objectID, allPSets);
context.addRetrievedObject(resultElement);
}
results.put (objectID, resultElement);
}
BaseBusinessClass[] resultsArr = new BaseBusinessClass[results.size ()];
return results.values ().toArray (resultsArr);
}
public BaseBusinessClass[] find(String searchType, PersistentSetCollection allPSets, Hashtable criteria, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException
{
LogMgr.log (SearchApplicantPersistence, LogLevel.DEBUG2, "Search executing:", searchType, " criteria:", criteria);
String customParamFilter = (String)criteria.get (SEARCH_CustomFilter);
String customOrderBy = (String)criteria.get (SEARCH_OrderBy);
String customTables = (String)criteria.get (SEARCH_CustomExtraTables);
Boolean noCommaBeforeCustomExtraTables = (Boolean)criteria.get (SEARCH_CustomExtraTablesNoComma);
if (searchType.equals (SEARCH_CustomSQL))
{
Set<ObjectID> processedIDs = new HashSet();
SearchParamTransform tx = new SearchParamTransform (criteria);
Object[] searchParams;
customParamFilter = StringUtils.replaceParams (customParamFilter, tx);
searchParams = tx.getParamsArray();
if (customOrderBy != null)
{
customOrderBy = " ORDER BY " + customOrderBy;
}
else
{
customOrderBy = "";
}
ResultSet r;
String concatCustomTableWith = CollectionUtils.equals(noCommaBeforeCustomExtraTables, true) ? " " : ", ";
String tables = StringUtils.subBlanks(customTables) == null ? " " : concatCustomTableWith + customTables + " ";
String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}it_does_not_matter " + tables +
"WHERE " + SELECT_JOINS + " " + customParamFilter + customOrderBy;
BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, searchParams, null, false);
return results;
}
else
{
BaseBusinessClass[] resultsArray = super.find(searchType, allPSets, criteria, context, sqlMgr);
Vector results = new Vector ();
for (int x = 0 ; x < resultsArray.length ; ++x)
{
if (resultsArray[x] instanceof SearchApplicant)
{
results.add (resultsArray[x]);
}
else
{
// Ignore
}
}
resultsArray = new BaseBusinessClass[results.size ()];
results.copyInto (resultsArray);
return resultsArray;
}
}
private void createPersistentSetFromRS(PersistentSetCollection allPSets, ResultSet r, ObjectID objectID) throws SQLException
{
PersistentSet it_does_not_matterPSet = allPSets.getPersistentSet(objectID, "it_does_not_matter", PersistentSetStatus.FETCHED);
// Object Modified
it_does_not_matterPSet.setAttrib(BaseBusinessClass.FIELD_ObjectLastModified, r.getTimestamp ("LAST_UPDATED_DATE"));
// Object Created
it_does_not_matterPSet.setAttrib(BaseBusinessClass.FIELD_ObjectCreated, r.getTimestamp ("CREATED_DATE"));
it_does_not_matterPSet.setAttrib(SearchApplicant.FIELD_Details, HELPER_Details.getFromRS(dummyDetails, r, "xxxx"));
it_does_not_matterPSet.setAttrib(SearchApplicant.SINGLEREFERENCE_Job, r.getObject ("xxxx"));
}
public void create(BaseBusinessClass obj, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException
{
ObjectID objectID = obj.getID ();
PersistentSet it_does_not_matterPSet = allPSets.getPersistentSet(objectID, "it_does_not_matter");
if (it_does_not_matterPSet.getStatus () != PersistentSetStatus.PROCESSED &&
it_does_not_matterPSet.getStatus () != PersistentSetStatus.DEFERRED)
{
executeStatement (sqlMgr,
"INSERT INTO {PREFIX}it_does_not_matter " +
" (xxxx, xxxx, object_id, object_LAST_UPDATED_DATE, object_CREATED_DATE) " +
"VALUES " +
" (?, ?, ?, " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ", " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ")",
CollectionUtils.listEntry (HELPER_Details.getForSQL(dummyDetails, it_does_not_matterPSet.getAttrib (SearchApplicant.FIELD_Details))) .listEntry (SQLManager.CheckNull((Long)(it_does_not_matterPSet.getAttrib (SearchApplicant.SINGLEREFERENCE_Job)))) .listEntry (objectID.longID ()).toList().toArray());
it_does_not_matterPSet.setStatus (PersistentSetStatus.PROCESSED);
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment