Commit 2cdf6b7c by Nilu

schedule message after job status change

parent f4fc03d9
......@@ -8,12 +8,13 @@
<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="subject" type="String" nullable="true" length="200"/>
<column name="application_status" type="String" nullable="true" length="200"/>
<column name="delay" type="Double" nullable="true"/>
<column name="subject" type="String" nullable="false" length="200"/>
<column name="application_status" type="String" nullable="false" length="200"/>
<column name="delay_hrs" type="Long" nullable="true"/>
<column name="delay_min" type="Long" nullable="true"/>
<column name="variance" type="Long" nullable="true"/>
<column name="business_hours_only" type="Boolean" nullable="true"/>
<column name="message_content" type="CLOB" nullable="true"/>
<column name="message_content" type="CLOB" nullable="false"/>
</NODE>
</NODE></OBJECTS>
\ No newline at end of file
<?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">tl_scheduled_email</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="subject" type="String" nullable="false" length="200"/>
<column name="scheduled_date" type="Date" nullable="false"/>
<column name="application_status" type="String" nullable="false" length="200"/>
<column name="message_content" type="CLOB" nullable="false"/>
<column name="job_application_id" type="Long" length="11" nullable="false"/>
<column name="message_template_id" type="Long" length="11" nullable="true"/>
</NODE>
<NODE name="INDEX" factory="Participant" class="oneit.sql.transfer.DefineIndexOperation" tableName="tl_scheduled_email" indexName="idx_tl_scheduled_email_job_application_id" isUnique="false"><column name="job_application_id"/></NODE>
</NODE></OBJECTS>
\ No newline at end of file
<?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">tl_sent_email</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="subject" type="String" nullable="false" length="200"/>
<column name="sent_date" type="Date" nullable="false"/>
<column name="application_status" type="String" nullable="false" length="200"/>
<column name="message_content" type="CLOB" nullable="false"/>
<column name="email_to" type="CLOB" nullable="false"/>
<column name="job_application_id" type="Long" length="11" nullable="false"/>
</NODE>
<NODE name="INDEX" factory="Participant" class="oneit.sql.transfer.DefineIndexOperation" tableName="tl_sent_email" indexName="idx_tl_sent_email_job_application_id" isUnique="false"><column name="job_application_id"/></NODE>
</NODE></OBJECTS>
\ No newline at end of file
......@@ -8,12 +8,13 @@ CREATE TABLE tl_message_template (
object_last_updated_date datetime DEFAULT getdate() NOT NULL ,
object_created_date datetime DEFAULT getdate() NOT NULL
,
subject varchar(200) NULL,
application_status varchar(200) NULL,
delay numeric(20,5) NULL,
subject varchar(200) NOT NULL,
application_status varchar(200) NOT NULL,
delay_hrs numeric(12) NULL,
delay_min numeric(12) NULL,
variance numeric(12) NULL,
business_hours_only char(1) NULL,
message_content text NULL
message_content text NOT NULL
);
......
-- DROP TABLE tl_scheduled_email;
CREATE TABLE tl_scheduled_email (
object_id int NOT NULL ,
object_last_updated_date datetime DEFAULT getdate() NOT NULL ,
object_created_date datetime DEFAULT getdate() NOT NULL
,
subject varchar(200) NOT NULL,
scheduled_date datetime NOT NULL,
application_status varchar(200) NOT NULL,
message_content text NOT NULL,
job_application_id numeric(12) NOT NULL,
message_template_id numeric(12) NULL
);
ALTER TABLE tl_scheduled_email ADD
CONSTRAINT PK_tl_scheduled_email PRIMARY KEY
(
object_id
) ;
CREATE INDEX idx_tl_scheduled_email_job_application_id
ON tl_scheduled_email (job_application_id);
-- DROP TABLE tl_sent_email;
CREATE TABLE tl_sent_email (
object_id int NOT NULL ,
object_last_updated_date datetime DEFAULT getdate() NOT NULL ,
object_created_date datetime DEFAULT getdate() NOT NULL
,
subject varchar(200) NOT NULL,
sent_date datetime NOT NULL,
application_status varchar(200) NOT NULL,
message_content text NOT NULL,
email_to text NOT NULL,
job_application_id numeric(12) NOT NULL
);
ALTER TABLE tl_sent_email ADD
CONSTRAINT PK_tl_sent_email PRIMARY KEY
(
object_id
) ;
CREATE INDEX idx_tl_sent_email_job_application_id
ON tl_sent_email (job_application_id);
......@@ -9,12 +9,13 @@ CREATE TABLE tl_message_template (
object_last_updated_date date DEFAULT SYSDATE NOT NULL ,
object_created_date date DEFAULT SYSDATE NOT NULL
,
subject varchar2(200) NULL,
application_status varchar2(200) NULL,
delay number(20,5) NULL,
subject varchar2(200) NOT NULL,
application_status varchar2(200) NOT NULL,
delay_hrs number(12) NULL,
delay_min number(12) NULL,
variance number(12) NULL,
business_hours_only char(1) NULL,
message_content clob NULL
message_content clob NOT NULL
);
......
-- DROP TABLE tl_scheduled_email;
CREATE TABLE tl_scheduled_email (
object_id number(12) NOT NULL ,
object_last_updated_date date DEFAULT SYSDATE NOT NULL ,
object_created_date date DEFAULT SYSDATE NOT NULL
,
subject varchar2(200) NOT NULL,
scheduled_date date NOT NULL,
application_status varchar2(200) NOT NULL,
message_content clob NOT NULL,
job_application_id number(12) NOT NULL,
message_template_id number(12) NULL
);
ALTER TABLE tl_scheduled_email ADD
CONSTRAINT PK_tl_scheduled_email PRIMARY KEY
(
object_id
) ;
CREATE INDEX idx_tl_scheduled_email_job_application_id
ON tl_scheduled_email (job_application_id);
-- DROP TABLE tl_sent_email;
CREATE TABLE tl_sent_email (
object_id number(12) NOT NULL ,
object_last_updated_date date DEFAULT SYSDATE NOT NULL ,
object_created_date date DEFAULT SYSDATE NOT NULL
,
subject varchar2(200) NOT NULL,
sent_date date NOT NULL,
application_status varchar2(200) NOT NULL,
message_content clob NOT NULL,
email_to clob NOT NULL,
job_application_id number(12) NOT NULL
);
ALTER TABLE tl_sent_email ADD
CONSTRAINT PK_tl_sent_email PRIMARY KEY
(
object_id
) ;
CREATE INDEX idx_tl_sent_email_job_application_id
ON tl_sent_email (job_application_id);
......@@ -9,12 +9,13 @@ CREATE TABLE tl_message_template (
object_last_updated_date timestamp DEFAULT NOW() NOT NULL ,
object_created_date timestamp DEFAULT NOW() NOT NULL
,
subject varchar(200) NULL,
application_status varchar(200) NULL,
delay numeric(20,5) NULL,
subject varchar(200) NOT NULL,
application_status varchar(200) NOT NULL,
delay_hrs numeric(12) NULL,
delay_min numeric(12) NULL,
variance numeric(12) NULL,
business_hours_only char(1) NULL,
message_content text NULL
message_content text NOT NULL
);
......
-- @AutoRun
-- drop table tl_scheduled_email;
CREATE TABLE tl_scheduled_email (
object_id numeric(12) NOT NULL ,
object_last_updated_date timestamp DEFAULT NOW() NOT NULL ,
object_created_date timestamp DEFAULT NOW() NOT NULL
,
subject varchar(200) NOT NULL,
scheduled_date timestamp NOT NULL,
application_status varchar(200) NOT NULL,
message_content text NOT NULL,
job_application_id numeric(12) NOT NULL,
message_template_id numeric(12) NULL
);
ALTER TABLE tl_scheduled_email ADD
CONSTRAINT pk_tl_scheduled_email PRIMARY KEY
(
object_id
) ;
CREATE INDEX idx_tl_scheduled_email_job_application_id
ON tl_scheduled_email (job_application_id);
-- @AutoRun
-- drop table tl_sent_email;
CREATE TABLE tl_sent_email (
object_id numeric(12) NOT NULL ,
object_last_updated_date timestamp DEFAULT NOW() NOT NULL ,
object_created_date timestamp DEFAULT NOW() NOT NULL
,
subject varchar(200) NOT NULL,
sent_date timestamp NOT NULL,
application_status varchar(200) NOT NULL,
message_content text NOT NULL,
email_to text NOT NULL,
job_application_id numeric(12) NOT NULL
);
ALTER TABLE tl_sent_email ADD
CONSTRAINT pk_tl_sent_email PRIMARY KEY
(
object_id
) ;
CREATE INDEX idx_tl_sent_email_job_application_id
ON tl_sent_email (job_application_id);
package performa.batch;
import java.util.Date;
import oneit.appservices.batch.ORMBatch;
import oneit.logging.LogLevel;
import oneit.logging.LogMgr;
import oneit.logging.LoggingArea;
import oneit.objstore.ObjectTransaction;
import oneit.objstore.StorageException;
import oneit.objstore.rdbms.filters.LessThanEqualFilter;
import oneit.utils.parsers.FieldException;
import performa.orm.ScheduledEmail;
public class MessagingEngineBatch extends ORMBatch
{
public static LoggingArea MESSAGING_ENGINE_BATCH = LoggingArea.createLoggingArea("MessagingEngineBatch");
@Override
public void run(ObjectTransaction ot) throws StorageException, FieldException
{
LogMgr.log (MESSAGING_ENGINE_BATCH, LogLevel.PROCESSING1, "RUNNING Messaging Engine Batch");
ScheduledEmail[] scheduledEmails = ScheduledEmail.SearchByAll().andScheduledDate(new LessThanEqualFilter<>(new Date())).search(ot);
for (ScheduledEmail scheduledEmail : scheduledEmails)
{
scheduledEmail.delete();
}
}
}
......@@ -63,6 +63,10 @@ public abstract class BaseJobApplication extends BaseBusinessClass
public static final String BACKREF_AssessmentCriteriaAnswers = "";
public static final String MULTIPLEREFERENCE_Notes = "Notes";
public static final String BACKREF_Notes = "";
public static final String MULTIPLEREFERENCE_ScheduledEmails = "ScheduledEmails";
public static final String BACKREF_ScheduledEmails = "";
public static final String MULTIPLEREFERENCE_SentEmails = "SentEmails";
public static final String BACKREF_SentEmails = "";
// Static constants corresponding to searches
public static final String SEARCH_All = "All";
......@@ -113,6 +117,8 @@ public abstract class BaseJobApplication extends BaseBusinessClass
// Private attributes corresponding to multiple references
private MultipleAssociation<JobApplication, AssessmentCriteriaAnswer> _AssessmentCriteriaAnswers;
private MultipleAssociation<JobApplication, Note> _Notes;
private MultipleAssociation<JobApplication, ScheduledEmail> _ScheduledEmails;
private MultipleAssociation<JobApplication, SentEmail> _SentEmails;
// Map of maps of metadata
......@@ -145,6 +151,8 @@ public abstract class BaseJobApplication extends BaseBusinessClass
String tmp_AssessmentCriteriaAnswers = AssessmentCriteriaAnswer.BACKREF_JobApplication;
String tmp_Notes = Note.BACKREF_JobApplication;
String tmp_ScheduledEmails = ScheduledEmail.BACKREF_JobApplication;
String tmp_SentEmails = SentEmail.BACKREF_JobApplication;
String tmp_Candidate = Candidate.BACKREF_JobApplications;
String tmp_Job = Job.BACKREF_JobApplications;
......@@ -152,6 +160,8 @@ public abstract class BaseJobApplication extends BaseBusinessClass
setupAssocMetaData_AssessmentCriteriaAnswers();
setupAssocMetaData_Notes();
setupAssocMetaData_ScheduledEmails();
setupAssocMetaData_SentEmails();
setupAssocMetaData_WorkFlow();
setupAssocMetaData_Candidate();
setupAssocMetaData_Job();
......@@ -212,6 +222,34 @@ public abstract class BaseJobApplication extends BaseBusinessClass
// Meta Info setup
private static void setupAssocMetaData_ScheduledEmails()
{
Map metaInfo = new HashMap ();
metaInfo.put ("backreferenceName", "JobApplication");
metaInfo.put ("name", "ScheduledEmails");
metaInfo.put ("type", "ScheduledEmail");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for JobApplication.ScheduledEmails:", metaInfo);
ATTRIBUTES_METADATA_JobApplication.put (MULTIPLEREFERENCE_ScheduledEmails, Collections.unmodifiableMap (metaInfo));
}
// Meta Info setup
private static void setupAssocMetaData_SentEmails()
{
Map metaInfo = new HashMap ();
metaInfo.put ("backreferenceName", "JobApplication");
metaInfo.put ("name", "SentEmails");
metaInfo.put ("type", "SentEmail");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for JobApplication.SentEmails:", metaInfo);
ATTRIBUTES_METADATA_JobApplication.put (MULTIPLEREFERENCE_SentEmails, Collections.unmodifiableMap (metaInfo));
}
// Meta Info setup
private static void setupAssocMetaData_WorkFlow()
{
Map metaInfo = new HashMap ();
......@@ -577,6 +615,8 @@ public abstract class BaseJobApplication extends BaseBusinessClass
_Job = new SingleAssociation<JobApplication, Job> (this, SINGLEREFERENCE_Job, Job.MULTIPLEREFERENCE_JobApplications, Job.REFERENCE_Job, "tl_job_application");
_AssessmentCriteriaAnswers = new MultipleAssociation<JobApplication, AssessmentCriteriaAnswer> (this, MULTIPLEREFERENCE_AssessmentCriteriaAnswers, AssessmentCriteriaAnswer.SINGLEREFERENCE_JobApplication, AssessmentCriteriaAnswer.REFERENCE_AssessmentCriteriaAnswer);
_Notes = new MultipleAssociation<JobApplication, Note> (this, MULTIPLEREFERENCE_Notes, Note.SINGLEREFERENCE_JobApplication, Note.REFERENCE_Note);
_ScheduledEmails = new MultipleAssociation<JobApplication, ScheduledEmail> (this, MULTIPLEREFERENCE_ScheduledEmails, ScheduledEmail.SINGLEREFERENCE_JobApplication, ScheduledEmail.REFERENCE_ScheduledEmail);
_SentEmails = new MultipleAssociation<JobApplication, SentEmail> (this, MULTIPLEREFERENCE_SentEmails, SentEmail.SINGLEREFERENCE_JobApplication, SentEmail.REFERENCE_SentEmail);
}
......@@ -591,6 +631,8 @@ public abstract class BaseJobApplication extends BaseBusinessClass
_Job = new SingleAssociation<JobApplication, Job> (this, SINGLEREFERENCE_Job, Job.MULTIPLEREFERENCE_JobApplications, Job.REFERENCE_Job, "tl_job_application");
_AssessmentCriteriaAnswers = new MultipleAssociation<JobApplication, AssessmentCriteriaAnswer> (this, MULTIPLEREFERENCE_AssessmentCriteriaAnswers, AssessmentCriteriaAnswer.SINGLEREFERENCE_JobApplication, AssessmentCriteriaAnswer.REFERENCE_AssessmentCriteriaAnswer);
_Notes = new MultipleAssociation<JobApplication, Note> (this, MULTIPLEREFERENCE_Notes, Note.SINGLEREFERENCE_JobApplication, Note.REFERENCE_Note);
_ScheduledEmails = new MultipleAssociation<JobApplication, ScheduledEmail> (this, MULTIPLEREFERENCE_ScheduledEmails, ScheduledEmail.SINGLEREFERENCE_JobApplication, ScheduledEmail.REFERENCE_ScheduledEmail);
_SentEmails = new MultipleAssociation<JobApplication, SentEmail> (this, MULTIPLEREFERENCE_SentEmails, SentEmail.SINGLEREFERENCE_JobApplication, SentEmail.REFERENCE_SentEmail);
return this;
......@@ -2450,6 +2492,10 @@ public abstract class BaseJobApplication extends BaseBusinessClass
result.add("Notes");
result.add("ScheduledEmails");
result.add("SentEmails");
return result;
}
......@@ -2471,6 +2517,16 @@ public abstract class BaseJobApplication extends BaseBusinessClass
return Note.REFERENCE_Note ;
}
if (MULTIPLEREFERENCE_ScheduledEmails.equals(attribName))
{
return ScheduledEmail.REFERENCE_ScheduledEmail ;
}
if (MULTIPLEREFERENCE_SentEmails.equals(attribName))
{
return SentEmail.REFERENCE_SentEmail ;
}
return super.getMultiAssocReferenceInstance(attribName);
}
......@@ -2489,6 +2545,16 @@ public abstract class BaseJobApplication extends BaseBusinessClass
return Note.SINGLEREFERENCE_JobApplication ;
}
if (MULTIPLEREFERENCE_ScheduledEmails.equals(attribName))
{
return ScheduledEmail.SINGLEREFERENCE_JobApplication ;
}
if (MULTIPLEREFERENCE_SentEmails.equals(attribName))
{
return SentEmail.SINGLEREFERENCE_JobApplication ;
}
return super.getMultiAssocBackReference(attribName);
}
......@@ -2510,6 +2576,16 @@ public abstract class BaseJobApplication extends BaseBusinessClass
return this.getNotesCount();
}
if (MULTIPLEREFERENCE_ScheduledEmails.equals(attribName))
{
return this.getScheduledEmailsCount();
}
if (MULTIPLEREFERENCE_SentEmails.equals(attribName))
{
return this.getSentEmailsCount();
}
return super.getMultiAssocCount(attribName);
}
......@@ -2531,6 +2607,16 @@ public abstract class BaseJobApplication extends BaseBusinessClass
return this.getNotesAt(index);
}
if (MULTIPLEREFERENCE_ScheduledEmails.equals(attribName))
{
return this.getScheduledEmailsAt(index);
}
if (MULTIPLEREFERENCE_SentEmails.equals(attribName))
{
return this.getSentEmailsAt(index);
}
return super.getMultiAssocAt(attribName, index);
}
......@@ -2556,6 +2642,20 @@ public abstract class BaseJobApplication extends BaseBusinessClass
return;
}
if (MULTIPLEREFERENCE_ScheduledEmails.equals(attribName))
{
addToScheduledEmails((ScheduledEmail)newElement);
return;
}
if (MULTIPLEREFERENCE_SentEmails.equals(attribName))
{
addToSentEmails((SentEmail)newElement);
return;
}
super.addToMultiAssoc(attribName, newElement);
}
......@@ -2580,6 +2680,20 @@ public abstract class BaseJobApplication extends BaseBusinessClass
return;
}
if (MULTIPLEREFERENCE_ScheduledEmails.equals(attribName))
{
removeFromScheduledEmails((ScheduledEmail)oldElement);
return;
}
if (MULTIPLEREFERENCE_SentEmails.equals(attribName))
{
removeFromSentEmails((SentEmail)oldElement);
return;
}
super.removeFromMultiAssoc(attribName, oldElement);
}
......@@ -2600,6 +2714,18 @@ public abstract class BaseJobApplication extends BaseBusinessClass
return;
}
if (MULTIPLEREFERENCE_ScheduledEmails.equals(attribName))
{
_ScheduledEmails.__loadAssociation (elements);
return;
}
if (MULTIPLEREFERENCE_SentEmails.equals(attribName))
{
_SentEmails.__loadAssociation (elements);
return;
}
super.__loadMultiAssoc(attribName, elements);
}
......@@ -2618,6 +2744,16 @@ public abstract class BaseJobApplication extends BaseBusinessClass
return _Notes.isLoaded ();
}
if (MULTIPLEREFERENCE_ScheduledEmails.equals(attribName))
{
return _ScheduledEmails.isLoaded ();
}
if (MULTIPLEREFERENCE_SentEmails.equals(attribName))
{
return _SentEmails.isLoaded ();
}
return super.__isMultiAssocLoaded(attribName);
}
......@@ -2762,6 +2898,144 @@ public abstract class BaseJobApplication extends BaseBusinessClass
return _Notes.getSet ();
}
public FieldWriteability getWriteability_ScheduledEmails ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
public int getScheduledEmailsCount () throws StorageException
{
assertValid();
return _ScheduledEmails.getReferencedObjectsCount ();
}
public void addToScheduledEmails (ScheduledEmail newElement) throws StorageException
{
if (_ScheduledEmails.wouldAddChange (newElement))
{
assertValid();
Debug.assertion (getWriteability_ScheduledEmails () != FieldWriteability.FALSE, "MultiAssoc ScheduledEmails is not writeable (add)");
_ScheduledEmails.appendElement (newElement);
try
{
if (newElement.getJobApplication () != this)
{
newElement.setJobApplication ((JobApplication)(this));
}
}
catch (Exception e)
{
throw NestedException.wrap(e);
}
}
}
public void removeFromScheduledEmails (ScheduledEmail elementToRemove) throws StorageException
{
if (_ScheduledEmails.wouldRemoveChange (elementToRemove))
{
assertValid();
Debug.assertion (getWriteability_ScheduledEmails () != FieldWriteability.FALSE, "MultiAssoc ScheduledEmails is not writeable (remove)");
_ScheduledEmails.removeElement (elementToRemove);
try
{
if (elementToRemove.getJobApplication () != null)
{
elementToRemove.setJobApplication (null);
}
}
catch (Exception e)
{
throw NestedException.wrap(e);
}
}
}
public ScheduledEmail getScheduledEmailsAt (int index) throws StorageException
{
return (ScheduledEmail)(_ScheduledEmails.getElementAt (index));
}
public SortedSet<ScheduledEmail> getScheduledEmailsSet () throws StorageException
{
return _ScheduledEmails.getSet ();
}
public FieldWriteability getWriteability_SentEmails ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
public int getSentEmailsCount () throws StorageException
{
assertValid();
return _SentEmails.getReferencedObjectsCount ();
}
public void addToSentEmails (SentEmail newElement) throws StorageException
{
if (_SentEmails.wouldAddChange (newElement))
{
assertValid();
Debug.assertion (getWriteability_SentEmails () != FieldWriteability.FALSE, "MultiAssoc SentEmails is not writeable (add)");
_SentEmails.appendElement (newElement);
try
{
if (newElement.getJobApplication () != this)
{
newElement.setJobApplication ((JobApplication)(this));
}
}
catch (Exception e)
{
throw NestedException.wrap(e);
}
}
}
public void removeFromSentEmails (SentEmail elementToRemove) throws StorageException
{
if (_SentEmails.wouldRemoveChange (elementToRemove))
{
assertValid();
Debug.assertion (getWriteability_SentEmails () != FieldWriteability.FALSE, "MultiAssoc SentEmails is not writeable (remove)");
_SentEmails.removeElement (elementToRemove);
try
{
if (elementToRemove.getJobApplication () != null)
{
elementToRemove.setJobApplication (null);
}
}
catch (Exception e)
{
throw NestedException.wrap(e);
}
}
}
public SentEmail getSentEmailsAt (int index) throws StorageException
{
return (SentEmail)(_SentEmails.getElementAt (index));
}
public SortedSet<SentEmail> getSentEmailsSet () throws StorageException
{
return _SentEmails.getSet ();
}
public void onDelete ()
......@@ -2808,6 +3082,18 @@ public abstract class BaseJobApplication extends BaseBusinessClass
referenced.setJobApplication(null);
}
for(ScheduledEmail referenced : CollectionUtils.reverse(getScheduledEmailsSet()))
{
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Setting backreference to null JobApplication from ", getObjectID (), " to ", referenced.getObjectID ());
referenced.setJobApplication(null);
}
for(SentEmail referenced : CollectionUtils.reverse(getSentEmailsSet()))
{
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Setting backreference to null JobApplication from ", getObjectID (), " to ", referenced.getObjectID ());
referenced.setJobApplication(null);
}
}
catch (Exception e)
{
......@@ -3044,6 +3330,8 @@ public abstract class BaseJobApplication extends BaseBusinessClass
_AssessmentCriteriaAnswers.copyFrom (sourceJobApplication._AssessmentCriteriaAnswers, linkToGhosts);
_Notes.copyFrom (sourceJobApplication._Notes, linkToGhosts);
_ScheduledEmails.copyFrom (sourceJobApplication._ScheduledEmails, linkToGhosts);
_SentEmails.copyFrom (sourceJobApplication._SentEmails, linkToGhosts);
}
}
......@@ -3087,6 +3375,8 @@ public abstract class BaseJobApplication extends BaseBusinessClass
_Job.readExternalData(vals.get(SINGLEREFERENCE_Job));
_AssessmentCriteriaAnswers.readExternalData(vals.get(MULTIPLEREFERENCE_AssessmentCriteriaAnswers));
_Notes.readExternalData(vals.get(MULTIPLEREFERENCE_Notes));
_ScheduledEmails.readExternalData(vals.get(MULTIPLEREFERENCE_ScheduledEmails));
_SentEmails.readExternalData(vals.get(MULTIPLEREFERENCE_SentEmails));
}
......@@ -3117,6 +3407,8 @@ public abstract class BaseJobApplication extends BaseBusinessClass
vals.put (SINGLEREFERENCE_Job, _Job.writeExternalData());
vals.put (MULTIPLEREFERENCE_AssessmentCriteriaAnswers, _AssessmentCriteriaAnswers.writeExternalData());
vals.put (MULTIPLEREFERENCE_Notes, _Notes.writeExternalData());
vals.put (MULTIPLEREFERENCE_ScheduledEmails, _ScheduledEmails.writeExternalData());
vals.put (MULTIPLEREFERENCE_SentEmails, _SentEmails.writeExternalData());
}
......@@ -3168,6 +3460,8 @@ public abstract class BaseJobApplication extends BaseBusinessClass
// Compare multiple assocs
_AssessmentCriteriaAnswers.compare (otherJobApplication._AssessmentCriteriaAnswers, listener);
_Notes.compare (otherJobApplication._Notes, listener);
_ScheduledEmails.compare (otherJobApplication._ScheduledEmails, listener);
_SentEmails.compare (otherJobApplication._SentEmails, listener);
}
}
......@@ -3204,6 +3498,8 @@ public abstract class BaseJobApplication extends BaseBusinessClass
visitor.visitAssociation (_Job);
visitor.visitAssociation (_AssessmentCriteriaAnswers);
visitor.visitAssociation (_Notes);
visitor.visitAssociation (_ScheduledEmails);
visitor.visitAssociation (_SentEmails);
}
......@@ -3232,6 +3528,14 @@ public abstract class BaseJobApplication extends BaseBusinessClass
{
visitor.visit (_Notes);
}
if (scope.includes (_ScheduledEmails))
{
visitor.visit (_ScheduledEmails);
}
if (scope.includes (_SentEmails))
{
visitor.visit (_SentEmails);
}
}
......@@ -3918,6 +4222,14 @@ public abstract class BaseJobApplication extends BaseBusinessClass
{
return getWriteability_Notes ();
}
else if (fieldName.equals (MULTIPLEREFERENCE_ScheduledEmails))
{
return getWriteability_ScheduledEmails ();
}
else if (fieldName.equals (MULTIPLEREFERENCE_SentEmails))
{
return getWriteability_SentEmails ();
}
else if (fieldName.equals (SINGLEREFERENCE_Candidate))
{
return getWriteability_Candidate ();
......@@ -4459,6 +4771,14 @@ public abstract class BaseJobApplication extends BaseBusinessClass
{
return toNotes ();
}
if (name.equals ("ScheduledEmails"))
{
return toScheduledEmails ();
}
if (name.equals ("SentEmails"))
{
return toSentEmails ();
}
if (name.equals ("AppProcessOption"))
{
return toAppProcessOption ();
......@@ -4590,6 +4910,18 @@ public abstract class BaseJobApplication extends BaseBusinessClass
{
return Note.REFERENCE_Note.new NotePipeLineFactory<From, Note> (this, new ORMMultiAssocPipe<Me, Note>(MULTIPLEREFERENCE_Notes, filter));
}
public ScheduledEmail.ScheduledEmailPipeLineFactory<From, ScheduledEmail> toScheduledEmails () { return toScheduledEmails(Filter.ALL); }
public ScheduledEmail.ScheduledEmailPipeLineFactory<From, ScheduledEmail> toScheduledEmails (Filter<ScheduledEmail> filter)
{
return ScheduledEmail.REFERENCE_ScheduledEmail.new ScheduledEmailPipeLineFactory<From, ScheduledEmail> (this, new ORMMultiAssocPipe<Me, ScheduledEmail>(MULTIPLEREFERENCE_ScheduledEmails, filter));
}
public SentEmail.SentEmailPipeLineFactory<From, SentEmail> toSentEmails () { return toSentEmails(Filter.ALL); }
public SentEmail.SentEmailPipeLineFactory<From, SentEmail> toSentEmails (Filter<SentEmail> filter)
{
return SentEmail.REFERENCE_SentEmail.new SentEmailPipeLineFactory<From, SentEmail> (this, new ORMMultiAssocPipe<Me, SentEmail>(MULTIPLEREFERENCE_SentEmails, filter));
}
}
......@@ -4737,6 +5069,40 @@ class DummyJobApplication extends JobApplication
return new TreeSet();
}
public int getScheduledEmailsCount () throws StorageException
{
return 0;
}
public ScheduledEmail getScheduledEmailsAt (int index) throws StorageException
{
throw new RuntimeException ("No elements in a dummy object in association ScheduledEmails");
}
public SortedSet getScheduledEmailsSet () throws StorageException
{
return new TreeSet();
}
public int getSentEmailsCount () throws StorageException
{
return 0;
}
public SentEmail getSentEmailsAt (int index) throws StorageException
{
throw new RuntimeException ("No elements in a dummy object in association SentEmails");
}
public SortedSet getSentEmailsSet () throws StorageException
{
return new TreeSet();
}
}
......@@ -43,7 +43,8 @@ public abstract class BaseMessageTemplate extends BaseBusinessClass
public static final String FIELD_Subject = "Subject";
public static final String FIELD_ApplicationStatus = "ApplicationStatus";
public static final String FIELD_Delay = "Delay";
public static final String FIELD_DelayHrs = "DelayHrs";
public static final String FIELD_DelayMin = "DelayMin";
public static final String FIELD_Variance = "Variance";
public static final String FIELD_BusinessHoursOnly = "BusinessHoursOnly";
public static final String FIELD_MessageContent = "MessageContent";
......@@ -55,7 +56,8 @@ public abstract class BaseMessageTemplate extends BaseBusinessClass
// Static constants corresponding to attribute helpers
private static final DefaultAttributeHelper<MessageTemplate> HELPER_Subject = DefaultAttributeHelper.INSTANCE;
private static final EnumeratedAttributeHelper<MessageTemplate, ApplicationStatus> HELPER_ApplicationStatus = new EnumeratedAttributeHelper<MessageTemplate, ApplicationStatus> (ApplicationStatus.FACTORY_ApplicationStatus);
private static final DefaultAttributeHelper<MessageTemplate> HELPER_Delay = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper<MessageTemplate> HELPER_DelayHrs = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper<MessageTemplate> HELPER_DelayMin = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper<MessageTemplate> HELPER_Variance = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper<MessageTemplate> HELPER_BusinessHoursOnly = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper<MessageTemplate> HELPER_MessageContent = DefaultAttributeHelper.INSTANCE;
......@@ -64,7 +66,8 @@ public abstract class BaseMessageTemplate extends BaseBusinessClass
// Private attributes corresponding to business object data
private String _Subject;
private ApplicationStatus _ApplicationStatus;
private Double _Delay;
private Integer _DelayHrs;
private Integer _DelayMin;
private Integer _Variance;
private Boolean _BusinessHoursOnly;
private String _MessageContent;
......@@ -82,7 +85,8 @@ public abstract class BaseMessageTemplate extends BaseBusinessClass
// Arrays of validators for each attribute
private static final AttributeValidator[] FIELD_Subject_Validators;
private static final AttributeValidator[] FIELD_ApplicationStatus_Validators;
private static final AttributeValidator[] FIELD_Delay_Validators;
private static final AttributeValidator[] FIELD_DelayHrs_Validators;
private static final AttributeValidator[] FIELD_DelayMin_Validators;
private static final AttributeValidator[] FIELD_Variance_Validators;
private static final AttributeValidator[] FIELD_BusinessHoursOnly_Validators;
private static final AttributeValidator[] FIELD_MessageContent_Validators;
......@@ -101,7 +105,8 @@ public abstract class BaseMessageTemplate extends BaseBusinessClass
FIELD_Subject_Validators = (AttributeValidator[])setupAttribMetaData_Subject(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_ApplicationStatus_Validators = (AttributeValidator[])setupAttribMetaData_ApplicationStatus(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_Delay_Validators = (AttributeValidator[])setupAttribMetaData_Delay(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_DelayHrs_Validators = (AttributeValidator[])setupAttribMetaData_DelayHrs(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_DelayMin_Validators = (AttributeValidator[])setupAttribMetaData_DelayMin(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_Variance_Validators = (AttributeValidator[])setupAttribMetaData_Variance(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_BusinessHoursOnly_Validators = (AttributeValidator[])setupAttribMetaData_BusinessHoursOnly(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_MessageContent_Validators = (AttributeValidator[])setupAttribMetaData_MessageContent(validatorMapping).toArray (new AttributeValidator[0]);
......@@ -126,7 +131,7 @@ public abstract class BaseMessageTemplate extends BaseBusinessClass
metaInfo.put ("dbcol", "subject");
metaInfo.put ("length", "200");
metaInfo.put ("mandatory", "false");
metaInfo.put ("mandatory", "true");
metaInfo.put ("name", "Subject");
metaInfo.put ("type", "String");
......@@ -147,7 +152,7 @@ public abstract class BaseMessageTemplate extends BaseBusinessClass
metaInfo.put ("attribHelper", "EnumeratedAttributeHelper");
metaInfo.put ("dbcol", "application_status");
metaInfo.put ("defaultValue", "ApplicationStatus.DRAFT");
metaInfo.put ("mandatory", "false");
metaInfo.put ("mandatory", "true");
metaInfo.put ("name", "ApplicationStatus");
metaInfo.put ("type", "ApplicationStatus");
......@@ -161,20 +166,41 @@ public abstract class BaseMessageTemplate extends BaseBusinessClass
}
// Meta Info setup
private static List setupAttribMetaData_Delay(Map validatorMapping)
private static List setupAttribMetaData_DelayHrs(Map validatorMapping)
{
Map metaInfo = new HashMap ();
metaInfo.put ("dbcol", "delay");
metaInfo.put ("dbcol", "delay_hrs");
metaInfo.put ("defaultValue", "0");
metaInfo.put ("mandatory", "false");
metaInfo.put ("name", "Delay");
metaInfo.put ("type", "Double");
metaInfo.put ("name", "DelayHrs");
metaInfo.put ("type", "Integer");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for MessageTemplate.Delay:", metaInfo);
ATTRIBUTES_METADATA_MessageTemplate.put (FIELD_Delay, Collections.unmodifiableMap (metaInfo));
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for MessageTemplate.DelayHrs:", metaInfo);
ATTRIBUTES_METADATA_MessageTemplate.put (FIELD_DelayHrs, Collections.unmodifiableMap (metaInfo));
List validators = BaseBusinessClass.getAttribValidators(MessageTemplate.class, "Delay", metaInfo, validatorMapping);
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for MessageTemplate.Delay:", validators);
List validators = BaseBusinessClass.getAttribValidators(MessageTemplate.class, "DelayHrs", metaInfo, validatorMapping);
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for MessageTemplate.DelayHrs:", validators);
return validators;
}
// Meta Info setup
private static List setupAttribMetaData_DelayMin(Map validatorMapping)
{
Map metaInfo = new HashMap ();
metaInfo.put ("dbcol", "delay_min");
metaInfo.put ("defaultValue", "0");
metaInfo.put ("mandatory", "false");
metaInfo.put ("name", "DelayMin");
metaInfo.put ("type", "Integer");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for MessageTemplate.DelayMin:", metaInfo);
ATTRIBUTES_METADATA_MessageTemplate.put (FIELD_DelayMin, Collections.unmodifiableMap (metaInfo));
List validators = BaseBusinessClass.getAttribValidators(MessageTemplate.class, "DelayMin", metaInfo, validatorMapping);
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for MessageTemplate.DelayMin:", validators);
return validators;
}
......@@ -185,6 +211,7 @@ public abstract class BaseMessageTemplate extends BaseBusinessClass
Map metaInfo = new HashMap ();
metaInfo.put ("dbcol", "variance");
metaInfo.put ("defaultValue", "0");
metaInfo.put ("mandatory", "false");
metaInfo.put ("name", "Variance");
metaInfo.put ("type", "Integer");
......@@ -204,6 +231,7 @@ public abstract class BaseMessageTemplate extends BaseBusinessClass
Map metaInfo = new HashMap ();
metaInfo.put ("dbcol", "business_hours_only");
metaInfo.put ("defaultValue", "Boolean.FALSE");
metaInfo.put ("mandatory", "false");
metaInfo.put ("name", "BusinessHoursOnly");
metaInfo.put ("type", "Boolean");
......@@ -223,7 +251,7 @@ public abstract class BaseMessageTemplate extends BaseBusinessClass
Map metaInfo = new HashMap ();
metaInfo.put ("dbcol", "message_content");
metaInfo.put ("mandatory", "false");
metaInfo.put ("mandatory", "true");
metaInfo.put ("name", "MessageContent");
metaInfo.put ("type", "String");
......@@ -265,9 +293,10 @@ public abstract class BaseMessageTemplate extends BaseBusinessClass
_Subject = (String)(HELPER_Subject.initialise (_Subject));
_ApplicationStatus = (ApplicationStatus)(ApplicationStatus.DRAFT);
_Delay = (Double)(HELPER_Delay.initialise (_Delay));
_Variance = (Integer)(HELPER_Variance.initialise (_Variance));
_BusinessHoursOnly = (Boolean)(HELPER_BusinessHoursOnly.initialise (_BusinessHoursOnly));
_DelayHrs = (Integer)(0);
_DelayMin = (Integer)(0);
_Variance = (Integer)(0);
_BusinessHoursOnly = (Boolean)(Boolean.FALSE);
_MessageContent = (String)(HELPER_MessageContent.initialise (_MessageContent));
}
......@@ -351,6 +380,7 @@ public abstract class BaseMessageTemplate extends BaseBusinessClass
oldAndNewIdentical = HELPER_Subject.compare (_Subject, newSubject);
}
BusinessObjectParser.assertFieldCondition (newSubject != null, this, FIELD_Subject, "mandatory");
if (FIELD_Subject_Validators.length > 0)
......@@ -449,6 +479,7 @@ public abstract class BaseMessageTemplate extends BaseBusinessClass
oldAndNewIdentical = HELPER_ApplicationStatus.compare (_ApplicationStatus, newApplicationStatus);
}
BusinessObjectParser.assertFieldCondition (newApplicationStatus != null, this, FIELD_ApplicationStatus, "mandatory");
if (FIELD_ApplicationStatus_Validators.length > 0)
......@@ -490,16 +521,16 @@ public abstract class BaseMessageTemplate extends BaseBusinessClass
}
/**
* Get the attribute Delay
* Get the attribute DelayHrs
*/
public Double getDelay ()
public Integer getDelayHrs ()
{
assertValid();
Double valToReturn = _Delay;
Integer valToReturn = _DelayHrs;
for (MessageTemplateBehaviourDecorator bhd : MessageTemplate_BehaviourDecorators)
{
valToReturn = bhd.getDelay ((MessageTemplate)this, valToReturn);
valToReturn = bhd.getDelayHrs ((MessageTemplate)this, valToReturn);
}
return valToReturn;
......@@ -511,7 +542,7 @@ public abstract class BaseMessageTemplate extends BaseBusinessClass
* 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 preDelayChange (Double newDelay) throws FieldException
protected void preDelayHrsChange (Integer newDelayHrs) throws FieldException
{
}
......@@ -521,46 +552,46 @@ public abstract class BaseMessageTemplate extends BaseBusinessClass
* If a field exception is thrown, the value is still changed, however it
* may lead to the TX being rolled back
*/
protected void postDelayChange () throws FieldException
protected void postDelayHrsChange () throws FieldException
{
}
public FieldWriteability getWriteability_Delay ()
public FieldWriteability getWriteability_DelayHrs ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the attribute Delay. Checks to ensure a new value
* Set the attribute DelayHrs. Checks to ensure a new value
* has been supplied. If so, marks the field as altered and sets the attribute.
*/
public void setDelay (Double newDelay) throws FieldException
public void setDelayHrs (Integer newDelayHrs) throws FieldException
{
boolean oldAndNewIdentical = HELPER_Delay.compare (_Delay, newDelay);
boolean oldAndNewIdentical = HELPER_DelayHrs.compare (_DelayHrs, newDelayHrs);
try
{
for (MessageTemplateBehaviourDecorator bhd : MessageTemplate_BehaviourDecorators)
{
newDelay = bhd.setDelay ((MessageTemplate)this, newDelay);
oldAndNewIdentical = HELPER_Delay.compare (_Delay, newDelay);
newDelayHrs = bhd.setDelayHrs ((MessageTemplate)this, newDelayHrs);
oldAndNewIdentical = HELPER_DelayHrs.compare (_DelayHrs, newDelayHrs);
}
if (FIELD_Delay_Validators.length > 0)
if (FIELD_DelayHrs_Validators.length > 0)
{
Object newDelayObj = HELPER_Delay.toObject (newDelay);
Object newDelayHrsObj = HELPER_DelayHrs.toObject (newDelayHrs);
if (newDelayObj != null)
if (newDelayHrsObj != null)
{
int loopMax = FIELD_Delay_Validators.length;
Map metadata = (Map)ATTRIBUTES_METADATA_MessageTemplate.get (FIELD_Delay);
int loopMax = FIELD_DelayHrs_Validators.length;
Map metadata = (Map)ATTRIBUTES_METADATA_MessageTemplate.get (FIELD_DelayHrs);
for (int v = 0 ; v < loopMax ; ++v)
{
FIELD_Delay_Validators[v].checkAttribute (this, FIELD_Delay, metadata, newDelayObj);
FIELD_DelayHrs_Validators[v].checkAttribute (this, FIELD_DelayHrs, metadata, newDelayHrsObj);
}
}
}
......@@ -578,12 +609,110 @@ public abstract class BaseMessageTemplate extends BaseBusinessClass
if (!oldAndNewIdentical)
{
assertValid();
Debug.assertion (getWriteability_Delay () != FieldWriteability.FALSE, "Field Delay is not writeable");
preDelayChange (newDelay);
markFieldChange (FIELD_Delay);
_Delay = newDelay;
postFieldChange (FIELD_Delay);
postDelayChange ();
Debug.assertion (getWriteability_DelayHrs () != FieldWriteability.FALSE, "Field DelayHrs is not writeable");
preDelayHrsChange (newDelayHrs);
markFieldChange (FIELD_DelayHrs);
_DelayHrs = newDelayHrs;
postFieldChange (FIELD_DelayHrs);
postDelayHrsChange ();
}
}
/**
* Get the attribute DelayMin
*/
public Integer getDelayMin ()
{
assertValid();
Integer valToReturn = _DelayMin;
for (MessageTemplateBehaviourDecorator bhd : MessageTemplate_BehaviourDecorators)
{
valToReturn = bhd.getDelayMin ((MessageTemplate)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 preDelayMinChange (Integer newDelayMin) 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 postDelayMinChange () throws FieldException
{
}
public FieldWriteability getWriteability_DelayMin ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the attribute DelayMin. Checks to ensure a new value
* has been supplied. If so, marks the field as altered and sets the attribute.
*/
public void setDelayMin (Integer newDelayMin) throws FieldException
{
boolean oldAndNewIdentical = HELPER_DelayMin.compare (_DelayMin, newDelayMin);
try
{
for (MessageTemplateBehaviourDecorator bhd : MessageTemplate_BehaviourDecorators)
{
newDelayMin = bhd.setDelayMin ((MessageTemplate)this, newDelayMin);
oldAndNewIdentical = HELPER_DelayMin.compare (_DelayMin, newDelayMin);
}
if (FIELD_DelayMin_Validators.length > 0)
{
Object newDelayMinObj = HELPER_DelayMin.toObject (newDelayMin);
if (newDelayMinObj != null)
{
int loopMax = FIELD_DelayMin_Validators.length;
Map metadata = (Map)ATTRIBUTES_METADATA_MessageTemplate.get (FIELD_DelayMin);
for (int v = 0 ; v < loopMax ; ++v)
{
FIELD_DelayMin_Validators[v].checkAttribute (this, FIELD_DelayMin, metadata, newDelayMinObj);
}
}
}
}
catch (FieldException e)
{
if (!oldAndNewIdentical)
{
e.setWouldModify ();
}
throw e;
}
if (!oldAndNewIdentical)
{
assertValid();
Debug.assertion (getWriteability_DelayMin () != FieldWriteability.FALSE, "Field DelayMin is not writeable");
preDelayMinChange (newDelayMin);
markFieldChange (FIELD_DelayMin);
_DelayMin = newDelayMin;
postFieldChange (FIELD_DelayMin);
postDelayMinChange ();
}
}
......@@ -841,6 +970,7 @@ public abstract class BaseMessageTemplate extends BaseBusinessClass
oldAndNewIdentical = HELPER_MessageContent.compare (_MessageContent, newMessageContent);
}
BusinessObjectParser.assertFieldCondition (newMessageContent != null, this, FIELD_MessageContent, "mandatory");
if (FIELD_MessageContent_Validators.length > 0)
......@@ -1141,7 +1271,8 @@ public abstract class BaseMessageTemplate extends BaseBusinessClass
tl_message_templatePSet.setAttrib (FIELD_ObjectID, myID);
tl_message_templatePSet.setAttrib (FIELD_Subject, HELPER_Subject.toObject (_Subject)); //
tl_message_templatePSet.setAttrib (FIELD_ApplicationStatus, HELPER_ApplicationStatus.toObject (_ApplicationStatus)); //
tl_message_templatePSet.setAttrib (FIELD_Delay, HELPER_Delay.toObject (_Delay)); //
tl_message_templatePSet.setAttrib (FIELD_DelayHrs, HELPER_DelayHrs.toObject (_DelayHrs)); //
tl_message_templatePSet.setAttrib (FIELD_DelayMin, HELPER_DelayMin.toObject (_DelayMin)); //
tl_message_templatePSet.setAttrib (FIELD_Variance, HELPER_Variance.toObject (_Variance)); //
tl_message_templatePSet.setAttrib (FIELD_BusinessHoursOnly, HELPER_BusinessHoursOnly.toObject (_BusinessHoursOnly)); //
tl_message_templatePSet.setAttrib (FIELD_MessageContent, HELPER_MessageContent.toObject (_MessageContent)); //
......@@ -1161,7 +1292,8 @@ public abstract class BaseMessageTemplate extends BaseBusinessClass
_Subject = (String)(HELPER_Subject.fromObject (_Subject, tl_message_templatePSet.getAttrib (FIELD_Subject))); //
_ApplicationStatus = (ApplicationStatus)(HELPER_ApplicationStatus.fromObject (_ApplicationStatus, tl_message_templatePSet.getAttrib (FIELD_ApplicationStatus))); //
_Delay = (Double)(HELPER_Delay.fromObject (_Delay, tl_message_templatePSet.getAttrib (FIELD_Delay))); //
_DelayHrs = (Integer)(HELPER_DelayHrs.fromObject (_DelayHrs, tl_message_templatePSet.getAttrib (FIELD_DelayHrs))); //
_DelayMin = (Integer)(HELPER_DelayMin.fromObject (_DelayMin, tl_message_templatePSet.getAttrib (FIELD_DelayMin))); //
_Variance = (Integer)(HELPER_Variance.fromObject (_Variance, tl_message_templatePSet.getAttrib (FIELD_Variance))); //
_BusinessHoursOnly = (Boolean)(HELPER_BusinessHoursOnly.fromObject (_BusinessHoursOnly, tl_message_templatePSet.getAttrib (FIELD_BusinessHoursOnly))); //
_MessageContent = (String)(HELPER_MessageContent.fromObject (_MessageContent, tl_message_templatePSet.getAttrib (FIELD_MessageContent))); //
......@@ -1200,7 +1332,16 @@ public abstract class BaseMessageTemplate extends BaseBusinessClass
try
{
setDelay (otherMessageTemplate.getDelay ());
setDelayHrs (otherMessageTemplate.getDelayHrs ());
}
catch (FieldException ex)
{
e.addException (ex);
}
try
{
setDelayMin (otherMessageTemplate.getDelayMin ());
}
catch (FieldException ex)
{
......@@ -1251,7 +1392,8 @@ public abstract class BaseMessageTemplate extends BaseBusinessClass
_Subject = sourceMessageTemplate._Subject;
_ApplicationStatus = sourceMessageTemplate._ApplicationStatus;
_Delay = sourceMessageTemplate._Delay;
_DelayHrs = sourceMessageTemplate._DelayHrs;
_DelayMin = sourceMessageTemplate._DelayMin;
_Variance = sourceMessageTemplate._Variance;
_BusinessHoursOnly = sourceMessageTemplate._BusinessHoursOnly;
_MessageContent = sourceMessageTemplate._MessageContent;
......@@ -1309,7 +1451,8 @@ public abstract class BaseMessageTemplate extends BaseBusinessClass
_Subject = (String)(HELPER_Subject.readExternal (_Subject, vals.get(FIELD_Subject))); //
_ApplicationStatus = (ApplicationStatus)(HELPER_ApplicationStatus.readExternal (_ApplicationStatus, vals.get(FIELD_ApplicationStatus))); //
_Delay = (Double)(HELPER_Delay.readExternal (_Delay, vals.get(FIELD_Delay))); //
_DelayHrs = (Integer)(HELPER_DelayHrs.readExternal (_DelayHrs, vals.get(FIELD_DelayHrs))); //
_DelayMin = (Integer)(HELPER_DelayMin.readExternal (_DelayMin, vals.get(FIELD_DelayMin))); //
_Variance = (Integer)(HELPER_Variance.readExternal (_Variance, vals.get(FIELD_Variance))); //
_BusinessHoursOnly = (Boolean)(HELPER_BusinessHoursOnly.readExternal (_BusinessHoursOnly, vals.get(FIELD_BusinessHoursOnly))); //
_MessageContent = (String)(HELPER_MessageContent.readExternal (_MessageContent, vals.get(FIELD_MessageContent))); //
......@@ -1326,7 +1469,8 @@ public abstract class BaseMessageTemplate extends BaseBusinessClass
vals.put (FIELD_Subject, HELPER_Subject.writeExternal (_Subject));
vals.put (FIELD_ApplicationStatus, HELPER_ApplicationStatus.writeExternal (_ApplicationStatus));
vals.put (FIELD_Delay, HELPER_Delay.writeExternal (_Delay));
vals.put (FIELD_DelayHrs, HELPER_DelayHrs.writeExternal (_DelayHrs));
vals.put (FIELD_DelayMin, HELPER_DelayMin.writeExternal (_DelayMin));
vals.put (FIELD_Variance, HELPER_Variance.writeExternal (_Variance));
vals.put (FIELD_BusinessHoursOnly, HELPER_BusinessHoursOnly.writeExternal (_BusinessHoursOnly));
vals.put (FIELD_MessageContent, HELPER_MessageContent.writeExternal (_MessageContent));
......@@ -1351,9 +1495,13 @@ public abstract class BaseMessageTemplate extends BaseBusinessClass
{
listener.notifyFieldChange(this, other, FIELD_ApplicationStatus, HELPER_ApplicationStatus.toObject(this._ApplicationStatus), HELPER_ApplicationStatus.toObject(otherMessageTemplate._ApplicationStatus));
}
if (!HELPER_Delay.compare(this._Delay, otherMessageTemplate._Delay))
if (!HELPER_DelayHrs.compare(this._DelayHrs, otherMessageTemplate._DelayHrs))
{
listener.notifyFieldChange(this, other, FIELD_DelayHrs, HELPER_DelayHrs.toObject(this._DelayHrs), HELPER_DelayHrs.toObject(otherMessageTemplate._DelayHrs));
}
if (!HELPER_DelayMin.compare(this._DelayMin, otherMessageTemplate._DelayMin))
{
listener.notifyFieldChange(this, other, FIELD_Delay, HELPER_Delay.toObject(this._Delay), HELPER_Delay.toObject(otherMessageTemplate._Delay));
listener.notifyFieldChange(this, other, FIELD_DelayMin, HELPER_DelayMin.toObject(this._DelayMin), HELPER_DelayMin.toObject(otherMessageTemplate._DelayMin));
}
if (!HELPER_Variance.compare(this._Variance, otherMessageTemplate._Variance))
{
......@@ -1391,7 +1539,8 @@ public abstract class BaseMessageTemplate extends BaseBusinessClass
visitor.visitField(this, FIELD_Subject, HELPER_Subject.toObject(getSubject()));
visitor.visitField(this, FIELD_ApplicationStatus, HELPER_ApplicationStatus.toObject(getApplicationStatus()));
visitor.visitField(this, FIELD_Delay, HELPER_Delay.toObject(getDelay()));
visitor.visitField(this, FIELD_DelayHrs, HELPER_DelayHrs.toObject(getDelayHrs()));
visitor.visitField(this, FIELD_DelayMin, HELPER_DelayMin.toObject(getDelayMin()));
visitor.visitField(this, FIELD_Variance, HELPER_Variance.toObject(getVariance()));
visitor.visitField(this, FIELD_BusinessHoursOnly, HELPER_BusinessHoursOnly.toObject(getBusinessHoursOnly()));
visitor.visitField(this, FIELD_MessageContent, HELPER_MessageContent.toObject(getMessageContent()));
......@@ -1436,9 +1585,13 @@ public abstract class BaseMessageTemplate extends BaseBusinessClass
{
return filter.matches (getApplicationStatus ());
}
else if (attribName.equals (FIELD_Delay))
else if (attribName.equals (FIELD_DelayHrs))
{
return filter.matches (getDelay ());
return filter.matches (getDelayHrs ());
}
else if (attribName.equals (FIELD_DelayMin))
{
return filter.matches (getDelayMin ());
}
else if (attribName.equals (FIELD_Variance))
{
......@@ -1495,9 +1648,15 @@ public abstract class BaseMessageTemplate extends BaseBusinessClass
return this;
}
public SearchAll andDelay (QueryFilter<Double> filter)
public SearchAll andDelayHrs (QueryFilter<Integer> filter)
{
filter.addFilter (context, "tl_message_template.delay", "Delay");
filter.addFilter (context, "tl_message_template.delay_hrs", "DelayHrs");
return this;
}
public SearchAll andDelayMin (QueryFilter<Integer> filter)
{
filter.addFilter (context, "tl_message_template.delay_min", "DelayMin");
return this;
}
......@@ -1562,9 +1721,13 @@ public abstract class BaseMessageTemplate extends BaseBusinessClass
{
return HELPER_ApplicationStatus.toObject (getApplicationStatus ());
}
else if (attribName.equals (FIELD_Delay))
else if (attribName.equals (FIELD_DelayHrs))
{
return HELPER_DelayHrs.toObject (getDelayHrs ());
}
else if (attribName.equals (FIELD_DelayMin))
{
return HELPER_Delay.toObject (getDelay ());
return HELPER_DelayMin.toObject (getDelayMin ());
}
else if (attribName.equals (FIELD_Variance))
{
......@@ -1599,9 +1762,13 @@ public abstract class BaseMessageTemplate extends BaseBusinessClass
{
return HELPER_ApplicationStatus;
}
else if (attribName.equals (FIELD_Delay))
else if (attribName.equals (FIELD_DelayHrs))
{
return HELPER_Delay;
return HELPER_DelayHrs;
}
else if (attribName.equals (FIELD_DelayMin))
{
return HELPER_DelayMin;
}
else if (attribName.equals (FIELD_Variance))
{
......@@ -1636,9 +1803,13 @@ public abstract class BaseMessageTemplate extends BaseBusinessClass
{
setApplicationStatus ((ApplicationStatus)(HELPER_ApplicationStatus.fromObject (_ApplicationStatus, attribValue)));
}
else if (attribName.equals (FIELD_Delay))
else if (attribName.equals (FIELD_DelayHrs))
{
setDelayHrs ((Integer)(HELPER_DelayHrs.fromObject (_DelayHrs, attribValue)));
}
else if (attribName.equals (FIELD_DelayMin))
{
setDelay ((Double)(HELPER_Delay.fromObject (_Delay, attribValue)));
setDelayMin ((Integer)(HELPER_DelayMin.fromObject (_DelayMin, attribValue)));
}
else if (attribName.equals (FIELD_Variance))
{
......@@ -1680,9 +1851,13 @@ public abstract class BaseMessageTemplate extends BaseBusinessClass
{
return getWriteability_ApplicationStatus ();
}
else if (fieldName.equals (FIELD_Delay))
else if (fieldName.equals (FIELD_DelayHrs))
{
return getWriteability_DelayHrs ();
}
else if (fieldName.equals (FIELD_DelayMin))
{
return getWriteability_Delay ();
return getWriteability_DelayMin ();
}
else if (fieldName.equals (FIELD_Variance))
{
......@@ -1716,9 +1891,14 @@ public abstract class BaseMessageTemplate extends BaseBusinessClass
fields.add (FIELD_ApplicationStatus);
}
if (getWriteability_Delay () != FieldWriteability.TRUE)
if (getWriteability_DelayHrs () != FieldWriteability.TRUE)
{
fields.add (FIELD_DelayHrs);
}
if (getWriteability_DelayMin () != FieldWriteability.TRUE)
{
fields.add (FIELD_Delay);
fields.add (FIELD_DelayMin);
}
if (getWriteability_Variance () != FieldWriteability.TRUE)
......@@ -1745,12 +1925,13 @@ public abstract class BaseMessageTemplate extends BaseBusinessClass
List result = super.getAttributes ();
result.add(HELPER_Subject.getAttribObject (getClass (), _Subject, false, FIELD_Subject));
result.add(HELPER_ApplicationStatus.getAttribObject (getClass (), _ApplicationStatus, false, FIELD_ApplicationStatus));
result.add(HELPER_Delay.getAttribObject (getClass (), _Delay, false, FIELD_Delay));
result.add(HELPER_Subject.getAttribObject (getClass (), _Subject, true, FIELD_Subject));
result.add(HELPER_ApplicationStatus.getAttribObject (getClass (), _ApplicationStatus, true, FIELD_ApplicationStatus));
result.add(HELPER_DelayHrs.getAttribObject (getClass (), _DelayHrs, false, FIELD_DelayHrs));
result.add(HELPER_DelayMin.getAttribObject (getClass (), _DelayMin, false, FIELD_DelayMin));
result.add(HELPER_Variance.getAttribObject (getClass (), _Variance, false, FIELD_Variance));
result.add(HELPER_BusinessHoursOnly.getAttribObject (getClass (), _BusinessHoursOnly, false, FIELD_BusinessHoursOnly));
result.add(HELPER_MessageContent.getAttribObject (getClass (), _MessageContent, false, FIELD_MessageContent));
result.add(HELPER_MessageContent.getAttribObject (getClass (), _MessageContent, true, FIELD_MessageContent));
return result;
}
......@@ -1838,21 +2019,39 @@ public abstract class BaseMessageTemplate extends BaseBusinessClass
}
/**
* Get the attribute Delay
* Get the attribute DelayHrs
*/
public Double getDelay (MessageTemplate obj, Double original)
public Integer getDelayHrs (MessageTemplate obj, Integer original)
{
return original;
}
/**
* Change the value set for attribute Delay.
* Change the value set for attribute DelayHrs.
* May modify the field beforehand
* Occurs before validation.
*/
public Double setDelay (MessageTemplate obj, Double newDelay) throws FieldException
public Integer setDelayHrs (MessageTemplate obj, Integer newDelayHrs) throws FieldException
{
return newDelay;
return newDelayHrs;
}
/**
* Get the attribute DelayMin
*/
public Integer getDelayMin (MessageTemplate obj, Integer original)
{
return original;
}
/**
* Change the value set for attribute DelayMin.
* May modify the field beforehand
* Occurs before validation.
*/
public Integer setDelayMin (MessageTemplate obj, Integer newDelayMin) throws FieldException
{
return newDelayMin;
}
/**
......@@ -1969,9 +2168,13 @@ public abstract class BaseMessageTemplate extends BaseBusinessClass
{
return toApplicationStatus ();
}
if (name.equals ("Delay"))
if (name.equals ("DelayHrs"))
{
return toDelayHrs ();
}
if (name.equals ("DelayMin"))
{
return toDelay ();
return toDelayMin ();
}
if (name.equals ("Variance"))
{
......@@ -1995,7 +2198,9 @@ public abstract class BaseMessageTemplate extends BaseBusinessClass
public PipeLine<From, ApplicationStatus> toApplicationStatus () { return pipe(new ORMAttributePipe<Me, ApplicationStatus>(FIELD_ApplicationStatus)); }
public PipeLine<From, Double> toDelay () { return pipe(new ORMAttributePipe<Me, Double>(FIELD_Delay)); }
public PipeLine<From, Integer> toDelayHrs () { return pipe(new ORMAttributePipe<Me, Integer>(FIELD_DelayHrs)); }
public PipeLine<From, Integer> toDelayMin () { return pipe(new ORMAttributePipe<Me, Integer>(FIELD_DelayMin)); }
public PipeLine<From, Integer> toVariance () { return pipe(new ORMAttributePipe<Me, Integer>(FIELD_Variance)); }
......
/*
* IMPORTANT!!!! XSL Autogenerated class, DO NOT EDIT!!!!!
* Template: Infrastructure8.2 rev3 [oneit.objstore.BusinessObjectTemplate.xsl]
*
* Version: 1.0
* Vendor: Apache Software Foundation (Xalan XSLTC)
* Vendor URL: http://xml.apache.org/xalan-j
*/
package performa.orm;
import java.io.*;
import java.util.*;
import oneit.appservices.config.*;
import oneit.logging.*;
import oneit.objstore.*;
import oneit.objstore.assocs.*;
import oneit.objstore.attributes.*;
import oneit.objstore.rdbms.filters.*;
import oneit.objstore.parser.*;
import oneit.objstore.validator.*;
import oneit.objstore.utils.*;
import oneit.utils.*;
import oneit.utils.filter.Filter;
import oneit.utils.transform.*;
import oneit.utils.parsers.FieldException;
import performa.orm.types.*;
public abstract class BaseScheduledEmail extends BaseBusinessClass
{
// Reference instance for the object
public static final ScheduledEmail REFERENCE_ScheduledEmail = new ScheduledEmail ();
// Reference instance for the object
public static final ScheduledEmail DUMMY_ScheduledEmail = new DummyScheduledEmail ();
// Static constants corresponding to field names
public static final String FIELD_Subject = "Subject";
public static final String FIELD_ScheduledDate = "ScheduledDate";
public static final String FIELD_ApplicationStatus = "ApplicationStatus";
public static final String FIELD_MessageContent = "MessageContent";
public static final String SINGLEREFERENCE_JobApplication = "JobApplication";
public static final String BACKREF_JobApplication = "";
public static final String SINGLEREFERENCE_MessageTemplate = "MessageTemplate";
// Static constants corresponding to searches
public static final String SEARCH_All = "All";
// Static constants corresponding to attribute helpers
private static final DefaultAttributeHelper<ScheduledEmail> HELPER_Subject = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper<ScheduledEmail> HELPER_ScheduledDate = DefaultAttributeHelper.INSTANCE;
private static final EnumeratedAttributeHelper<ScheduledEmail, ApplicationStatus> HELPER_ApplicationStatus = new EnumeratedAttributeHelper<ScheduledEmail, ApplicationStatus> (ApplicationStatus.FACTORY_ApplicationStatus);
private static final DefaultAttributeHelper<ScheduledEmail> HELPER_MessageContent = DefaultAttributeHelper.INSTANCE;
// Private attributes corresponding to business object data
private String _Subject;
private Date _ScheduledDate;
private ApplicationStatus _ApplicationStatus;
private String _MessageContent;
// Private attributes corresponding to single references
private SingleAssociation<ScheduledEmail, JobApplication> _JobApplication;
private SingleAssociation<ScheduledEmail, MessageTemplate> _MessageTemplate;
// Private attributes corresponding to multiple references
// Map of maps of metadata
private static final Map ATTRIBUTES_METADATA_ScheduledEmail = new HashMap ();
// Arrays of validators for each attribute
private static final AttributeValidator[] FIELD_Subject_Validators;
private static final AttributeValidator[] FIELD_ScheduledDate_Validators;
private static final AttributeValidator[] FIELD_ApplicationStatus_Validators;
private static final AttributeValidator[] FIELD_MessageContent_Validators;
// Arrays of behaviour decorators
private static final ScheduledEmailBehaviourDecorator[] ScheduledEmail_BehaviourDecorators;
static
{
try
{
String tmp_JobApplication = JobApplication.BACKREF_ScheduledEmails;
Map validatorMapping = ((Map)ConfigMgr.getConfigObject ("CONFIG.ORMVALIDATOR", "ValidatorMapping"));
setupAssocMetaData_JobApplication();
setupAssocMetaData_MessageTemplate();
FIELD_Subject_Validators = (AttributeValidator[])setupAttribMetaData_Subject(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_ScheduledDate_Validators = (AttributeValidator[])setupAttribMetaData_ScheduledDate(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_ApplicationStatus_Validators = (AttributeValidator[])setupAttribMetaData_ApplicationStatus(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_MessageContent_Validators = (AttributeValidator[])setupAttribMetaData_MessageContent(validatorMapping).toArray (new AttributeValidator[0]);
REFERENCE_ScheduledEmail.initialiseReference ();
DUMMY_ScheduledEmail.initialiseReference ();
ScheduledEmail_BehaviourDecorators = BaseBusinessClass.getBBCBehaviours(ScheduledEmail.class).toArray(new ScheduledEmailBehaviourDecorator[0]);
}
catch (RuntimeException e)
{
LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR1, e, "Error initialising");
throw e;
}
}
// Meta Info setup
private static void setupAssocMetaData_JobApplication()
{
Map metaInfo = new HashMap ();
metaInfo.put ("backreferenceName", "ScheduledEmails");
metaInfo.put ("dbcol", "job_application_id");
metaInfo.put ("mandatory", "true");
metaInfo.put ("name", "JobApplication");
metaInfo.put ("type", "JobApplication");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for ScheduledEmail.JobApplication:", metaInfo);
ATTRIBUTES_METADATA_ScheduledEmail.put (SINGLEREFERENCE_JobApplication, Collections.unmodifiableMap (metaInfo));
}
// Meta Info setup
private static void setupAssocMetaData_MessageTemplate()
{
Map metaInfo = new HashMap ();
metaInfo.put ("dbcol", "message_template_id");
metaInfo.put ("name", "MessageTemplate");
metaInfo.put ("type", "MessageTemplate");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for ScheduledEmail.MessageTemplate:", metaInfo);
ATTRIBUTES_METADATA_ScheduledEmail.put (SINGLEREFERENCE_MessageTemplate, Collections.unmodifiableMap (metaInfo));
}
// Meta Info setup
private static List setupAttribMetaData_Subject(Map validatorMapping)
{
Map metaInfo = new HashMap ();
metaInfo.put ("dbcol", "subject");
metaInfo.put ("length", "200");
metaInfo.put ("mandatory", "true");
metaInfo.put ("name", "Subject");
metaInfo.put ("type", "String");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for ScheduledEmail.Subject:", metaInfo);
ATTRIBUTES_METADATA_ScheduledEmail.put (FIELD_Subject, Collections.unmodifiableMap (metaInfo));
List validators = BaseBusinessClass.getAttribValidators(ScheduledEmail.class, "Subject", metaInfo, validatorMapping);
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for ScheduledEmail.Subject:", validators);
return validators;
}
// Meta Info setup
private static List setupAttribMetaData_ScheduledDate(Map validatorMapping)
{
Map metaInfo = new HashMap ();
metaInfo.put ("dbcol", "scheduled_date");
metaInfo.put ("mandatory", "true");
metaInfo.put ("name", "ScheduledDate");
metaInfo.put ("type", "Date");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for ScheduledEmail.ScheduledDate:", metaInfo);
ATTRIBUTES_METADATA_ScheduledEmail.put (FIELD_ScheduledDate, Collections.unmodifiableMap (metaInfo));
List validators = BaseBusinessClass.getAttribValidators(ScheduledEmail.class, "ScheduledDate", metaInfo, validatorMapping);
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for ScheduledEmail.ScheduledDate:", validators);
return validators;
}
// Meta Info setup
private static List setupAttribMetaData_ApplicationStatus(Map validatorMapping)
{
Map metaInfo = new HashMap ();
metaInfo.put ("attribHelper", "EnumeratedAttributeHelper");
metaInfo.put ("dbcol", "application_status");
metaInfo.put ("mandatory", "true");
metaInfo.put ("name", "ApplicationStatus");
metaInfo.put ("type", "ApplicationStatus");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for ScheduledEmail.ApplicationStatus:", metaInfo);
ATTRIBUTES_METADATA_ScheduledEmail.put (FIELD_ApplicationStatus, Collections.unmodifiableMap (metaInfo));
List validators = BaseBusinessClass.getAttribValidators(ScheduledEmail.class, "ApplicationStatus", metaInfo, validatorMapping);
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for ScheduledEmail.ApplicationStatus:", validators);
return validators;
}
// Meta Info setup
private static List setupAttribMetaData_MessageContent(Map validatorMapping)
{
Map metaInfo = new HashMap ();
metaInfo.put ("dbcol", "message_content");
metaInfo.put ("mandatory", "true");
metaInfo.put ("name", "MessageContent");
metaInfo.put ("type", "String");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for ScheduledEmail.MessageContent:", metaInfo);
ATTRIBUTES_METADATA_ScheduledEmail.put (FIELD_MessageContent, Collections.unmodifiableMap (metaInfo));
List validators = BaseBusinessClass.getAttribValidators(ScheduledEmail.class, "MessageContent", metaInfo, validatorMapping);
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for ScheduledEmail.MessageContent:", validators);
return validators;
}
// END OF STATIC METADATA DEFINITION
// This constructor should not be called
protected BaseScheduledEmail ()
{
}
protected BBCBehaviourDecorator[] getBehaviours()
{
return ScheduledEmail_BehaviourDecorators;
}
// Initialise the attributes
protected void _initialiseNewObjAttributes (ObjectTransaction transaction) throws StorageException
{
super._initialiseNewObjAttributes (transaction);
_Subject = (String)(HELPER_Subject.initialise (_Subject));
_ScheduledDate = (Date)(HELPER_ScheduledDate.initialise (_ScheduledDate));
_ApplicationStatus = (ApplicationStatus)(HELPER_ApplicationStatus.initialise (_ApplicationStatus));
_MessageContent = (String)(HELPER_MessageContent.initialise (_MessageContent));
}
// Initialise the associations
protected void _initialiseAssociations ()
{
super._initialiseAssociations ();
_JobApplication = new SingleAssociation<ScheduledEmail, JobApplication> (this, SINGLEREFERENCE_JobApplication, JobApplication.MULTIPLEREFERENCE_ScheduledEmails, JobApplication.REFERENCE_JobApplication, "tl_scheduled_email");
_MessageTemplate = new SingleAssociation<ScheduledEmail, MessageTemplate> (this, SINGLEREFERENCE_MessageTemplate, null, MessageTemplate.REFERENCE_MessageTemplate, "tl_scheduled_email");
}
// Initialise the associations
protected BaseBusinessClass initialiseReference ()
{
super.initialiseReference ();
_JobApplication = new SingleAssociation<ScheduledEmail, JobApplication> (this, SINGLEREFERENCE_JobApplication, JobApplication.MULTIPLEREFERENCE_ScheduledEmails, JobApplication.REFERENCE_JobApplication, "tl_scheduled_email");
_MessageTemplate = new SingleAssociation<ScheduledEmail, MessageTemplate> (this, SINGLEREFERENCE_MessageTemplate, null, MessageTemplate.REFERENCE_MessageTemplate, "tl_scheduled_email");
return this;
}
/**
* Get the attribute Subject
*/
public String getSubject ()
{
assertValid();
String valToReturn = _Subject;
for (ScheduledEmailBehaviourDecorator bhd : ScheduledEmail_BehaviourDecorators)
{
valToReturn = bhd.getSubject ((ScheduledEmail)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 preSubjectChange (String newSubject) 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 postSubjectChange () throws FieldException
{
}
public FieldWriteability getWriteability_Subject ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the attribute Subject. Checks to ensure a new value
* has been supplied. If so, marks the field as altered and sets the attribute.
*/
public void setSubject (String newSubject) throws FieldException
{
boolean oldAndNewIdentical = HELPER_Subject.compare (_Subject, newSubject);
try
{
for (ScheduledEmailBehaviourDecorator bhd : ScheduledEmail_BehaviourDecorators)
{
newSubject = bhd.setSubject ((ScheduledEmail)this, newSubject);
oldAndNewIdentical = HELPER_Subject.compare (_Subject, newSubject);
}
BusinessObjectParser.assertFieldCondition (newSubject != null, this, FIELD_Subject, "mandatory");
if (FIELD_Subject_Validators.length > 0)
{
Object newSubjectObj = HELPER_Subject.toObject (newSubject);
if (newSubjectObj != null)
{
int loopMax = FIELD_Subject_Validators.length;
Map metadata = (Map)ATTRIBUTES_METADATA_ScheduledEmail.get (FIELD_Subject);
for (int v = 0 ; v < loopMax ; ++v)
{
FIELD_Subject_Validators[v].checkAttribute (this, FIELD_Subject, metadata, newSubjectObj);
}
}
}
}
catch (FieldException e)
{
if (!oldAndNewIdentical)
{
e.setWouldModify ();
}
throw e;
}
if (!oldAndNewIdentical)
{
assertValid();
Debug.assertion (getWriteability_Subject () != FieldWriteability.FALSE, "Field Subject is not writeable");
preSubjectChange (newSubject);
markFieldChange (FIELD_Subject);
_Subject = newSubject;
postFieldChange (FIELD_Subject);
postSubjectChange ();
}
}
/**
* Get the attribute ScheduledDate
*/
public Date getScheduledDate ()
{
assertValid();
Date valToReturn = _ScheduledDate;
for (ScheduledEmailBehaviourDecorator bhd : ScheduledEmail_BehaviourDecorators)
{
valToReturn = bhd.getScheduledDate ((ScheduledEmail)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 preScheduledDateChange (Date newScheduledDate) 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 postScheduledDateChange () throws FieldException
{
}
public FieldWriteability getWriteability_ScheduledDate ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the attribute ScheduledDate. Checks to ensure a new value
* has been supplied. If so, marks the field as altered and sets the attribute.
*/
public void setScheduledDate (Date newScheduledDate) throws FieldException
{
boolean oldAndNewIdentical = HELPER_ScheduledDate.compare (_ScheduledDate, newScheduledDate);
try
{
for (ScheduledEmailBehaviourDecorator bhd : ScheduledEmail_BehaviourDecorators)
{
newScheduledDate = bhd.setScheduledDate ((ScheduledEmail)this, newScheduledDate);
oldAndNewIdentical = HELPER_ScheduledDate.compare (_ScheduledDate, newScheduledDate);
}
BusinessObjectParser.assertFieldCondition (newScheduledDate != null, this, FIELD_ScheduledDate, "mandatory");
if (FIELD_ScheduledDate_Validators.length > 0)
{
Object newScheduledDateObj = HELPER_ScheduledDate.toObject (newScheduledDate);
if (newScheduledDateObj != null)
{
int loopMax = FIELD_ScheduledDate_Validators.length;
Map metadata = (Map)ATTRIBUTES_METADATA_ScheduledEmail.get (FIELD_ScheduledDate);
for (int v = 0 ; v < loopMax ; ++v)
{
FIELD_ScheduledDate_Validators[v].checkAttribute (this, FIELD_ScheduledDate, metadata, newScheduledDateObj);
}
}
}
}
catch (FieldException e)
{
if (!oldAndNewIdentical)
{
e.setWouldModify ();
}
throw e;
}
if (!oldAndNewIdentical)
{
assertValid();
Debug.assertion (getWriteability_ScheduledDate () != FieldWriteability.FALSE, "Field ScheduledDate is not writeable");
preScheduledDateChange (newScheduledDate);
markFieldChange (FIELD_ScheduledDate);
_ScheduledDate = newScheduledDate;
postFieldChange (FIELD_ScheduledDate);
postScheduledDateChange ();
}
}
/**
* Get the attribute ApplicationStatus
*/
public ApplicationStatus getApplicationStatus ()
{
assertValid();
ApplicationStatus valToReturn = _ApplicationStatus;
for (ScheduledEmailBehaviourDecorator bhd : ScheduledEmail_BehaviourDecorators)
{
valToReturn = bhd.getApplicationStatus ((ScheduledEmail)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 preApplicationStatusChange (ApplicationStatus newApplicationStatus) 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 postApplicationStatusChange () throws FieldException
{
}
public FieldWriteability getWriteability_ApplicationStatus ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the attribute ApplicationStatus. Checks to ensure a new value
* has been supplied. If so, marks the field as altered and sets the attribute.
*/
public void setApplicationStatus (ApplicationStatus newApplicationStatus) throws FieldException
{
boolean oldAndNewIdentical = HELPER_ApplicationStatus.compare (_ApplicationStatus, newApplicationStatus);
try
{
for (ScheduledEmailBehaviourDecorator bhd : ScheduledEmail_BehaviourDecorators)
{
newApplicationStatus = bhd.setApplicationStatus ((ScheduledEmail)this, newApplicationStatus);
oldAndNewIdentical = HELPER_ApplicationStatus.compare (_ApplicationStatus, newApplicationStatus);
}
BusinessObjectParser.assertFieldCondition (newApplicationStatus != null, this, FIELD_ApplicationStatus, "mandatory");
if (FIELD_ApplicationStatus_Validators.length > 0)
{
Object newApplicationStatusObj = HELPER_ApplicationStatus.toObject (newApplicationStatus);
if (newApplicationStatusObj != null)
{
int loopMax = FIELD_ApplicationStatus_Validators.length;
Map metadata = (Map)ATTRIBUTES_METADATA_ScheduledEmail.get (FIELD_ApplicationStatus);
for (int v = 0 ; v < loopMax ; ++v)
{
FIELD_ApplicationStatus_Validators[v].checkAttribute (this, FIELD_ApplicationStatus, metadata, newApplicationStatusObj);
}
}
}
}
catch (FieldException e)
{
if (!oldAndNewIdentical)
{
e.setWouldModify ();
}
throw e;
}
if (!oldAndNewIdentical)
{
assertValid();
Debug.assertion (getWriteability_ApplicationStatus () != FieldWriteability.FALSE, "Field ApplicationStatus is not writeable");
preApplicationStatusChange (newApplicationStatus);
markFieldChange (FIELD_ApplicationStatus);
_ApplicationStatus = newApplicationStatus;
postFieldChange (FIELD_ApplicationStatus);
postApplicationStatusChange ();
}
}
/**
* Get the attribute MessageContent
*/
public String getMessageContent ()
{
assertValid();
String valToReturn = _MessageContent;
for (ScheduledEmailBehaviourDecorator bhd : ScheduledEmail_BehaviourDecorators)
{
valToReturn = bhd.getMessageContent ((ScheduledEmail)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 preMessageContentChange (String newMessageContent) 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 postMessageContentChange () throws FieldException
{
}
public FieldWriteability getWriteability_MessageContent ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the attribute MessageContent. Checks to ensure a new value
* has been supplied. If so, marks the field as altered and sets the attribute.
*/
public void setMessageContent (String newMessageContent) throws FieldException
{
boolean oldAndNewIdentical = HELPER_MessageContent.compare (_MessageContent, newMessageContent);
try
{
for (ScheduledEmailBehaviourDecorator bhd : ScheduledEmail_BehaviourDecorators)
{
newMessageContent = bhd.setMessageContent ((ScheduledEmail)this, newMessageContent);
oldAndNewIdentical = HELPER_MessageContent.compare (_MessageContent, newMessageContent);
}
BusinessObjectParser.assertFieldCondition (newMessageContent != null, this, FIELD_MessageContent, "mandatory");
if (FIELD_MessageContent_Validators.length > 0)
{
Object newMessageContentObj = HELPER_MessageContent.toObject (newMessageContent);
if (newMessageContentObj != null)
{
int loopMax = FIELD_MessageContent_Validators.length;
Map metadata = (Map)ATTRIBUTES_METADATA_ScheduledEmail.get (FIELD_MessageContent);
for (int v = 0 ; v < loopMax ; ++v)
{
FIELD_MessageContent_Validators[v].checkAttribute (this, FIELD_MessageContent, metadata, newMessageContentObj);
}
}
}
}
catch (FieldException e)
{
if (!oldAndNewIdentical)
{
e.setWouldModify ();
}
throw e;
}
if (!oldAndNewIdentical)
{
assertValid();
Debug.assertion (getWriteability_MessageContent () != FieldWriteability.FALSE, "Field MessageContent is not writeable");
preMessageContentChange (newMessageContent);
markFieldChange (FIELD_MessageContent);
_MessageContent = newMessageContent;
postFieldChange (FIELD_MessageContent);
postMessageContentChange ();
}
}
/**
* A list of multi assoc names e.g. list of strings.
*/
public List<String> getSingleAssocs()
{
List result = super.getSingleAssocs ();
result.add("JobApplication");
result.add("MessageTemplate");
return result;
}
public BaseBusinessClass getSingleAssocReferenceInstance (String assocName)
{
if (assocName == null)
{
throw new RuntimeException ("Game over == null!");
}
else if (assocName.equals (SINGLEREFERENCE_JobApplication))
{
return _JobApplication.getReferencedType ();
}else if (assocName.equals (SINGLEREFERENCE_MessageTemplate))
{
return _MessageTemplate.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_JobApplication))
{
return JobApplication.MULTIPLEREFERENCE_ScheduledEmails ;
}else if (assocName.equals (SINGLEREFERENCE_MessageTemplate))
{
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_JobApplication))
{
return getJobApplication ();
}else if (assocName.equals (SINGLEREFERENCE_MessageTemplate))
{
return getMessageTemplate ();
}
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_JobApplication))
{
return getJobApplication (getType);
}else if (assocName.equals (SINGLEREFERENCE_MessageTemplate))
{
return getMessageTemplate (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_JobApplication))
{
return getJobApplicationID ();
}else if (assocName.equals (SINGLEREFERENCE_MessageTemplate))
{
return getMessageTemplateID ();
}
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_JobApplication))
{
setJobApplication ((JobApplication)(newValue));
}else if (assocName.equals (SINGLEREFERENCE_MessageTemplate))
{
setMessageTemplate ((MessageTemplate)(newValue));
}
else
{
super.setSingleAssoc (assocName, newValue);
}
}
/**
* Get the reference JobApplication
*/
public JobApplication getJobApplication () throws StorageException
{
assertValid();
try
{
return (JobApplication)(_JobApplication.get ());
}
catch (ClassCastException e)
{
LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR2, "Cache collision in ScheduledEmail:", this.getObjectID (), ", was trying to get JobApplication:", getJobApplicationID ());
LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR2, "Instead I got:", _JobApplication.get ().getClass ());
throw e;
}
}
/**
* Get the object id for the referenced object. Does not force a DB access.
*/
public JobApplication getJobApplication (Get getType) throws StorageException
{
assertValid();
return _JobApplication.get(getType);
}
/**
* Get the object id for the referenced object. Does not force a DB access.
*/
public Long getJobApplicationID ()
{
assertValid();
if (_JobApplication == null)
{
return null;
}
else
{
return _JobApplication.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 preJobApplicationChange (JobApplication newJobApplication) 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 postJobApplicationChange () throws FieldException
{
}
public FieldWriteability getWriteability_JobApplication ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the reference JobApplication. Checks to ensure a new value
* has been supplied. If so, marks the reference as altered and sets it.
*/
public void setJobApplication (JobApplication newJobApplication) throws StorageException, FieldException
{
BusinessObjectParser.assertFieldCondition (newJobApplication != null, this, SINGLEREFERENCE_JobApplication, "mandatory");
if (_JobApplication.wouldReferencedChange (newJobApplication))
{
assertValid();
Debug.assertion (getWriteability_JobApplication () != FieldWriteability.FALSE, "Assoc JobApplication is not writeable");
preJobApplicationChange (newJobApplication);
JobApplication oldJobApplication = getJobApplication ();
if (oldJobApplication != null)
{
// This is to stop validation from triggering when we are removed
_JobApplication.set (null);
oldJobApplication.removeFromScheduledEmails ((ScheduledEmail)(this));
}
_JobApplication.set (newJobApplication);
if (newJobApplication != null)
{
newJobApplication.addToScheduledEmails ((ScheduledEmail)(this));
}
postJobApplicationChange ();
}
}
/**
* Get the reference MessageTemplate
*/
public MessageTemplate getMessageTemplate () throws StorageException
{
assertValid();
try
{
return (MessageTemplate)(_MessageTemplate.get ());
}
catch (ClassCastException e)
{
LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR2, "Cache collision in ScheduledEmail:", this.getObjectID (), ", was trying to get MessageTemplate:", getMessageTemplateID ());
LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR2, "Instead I got:", _MessageTemplate.get ().getClass ());
throw e;
}
}
/**
* Get the object id for the referenced object. Does not force a DB access.
*/
public MessageTemplate getMessageTemplate (Get getType) throws StorageException
{
assertValid();
return _MessageTemplate.get(getType);
}
/**
* Get the object id for the referenced object. Does not force a DB access.
*/
public Long getMessageTemplateID ()
{
assertValid();
if (_MessageTemplate == null)
{
return null;
}
else
{
return _MessageTemplate.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 preMessageTemplateChange (MessageTemplate newMessageTemplate) 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 postMessageTemplateChange () throws FieldException
{
}
public FieldWriteability getWriteability_MessageTemplate ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the reference MessageTemplate. Checks to ensure a new value
* has been supplied. If so, marks the reference as altered and sets it.
*/
public void setMessageTemplate (MessageTemplate newMessageTemplate) throws StorageException, FieldException
{
if (_MessageTemplate.wouldReferencedChange (newMessageTemplate))
{
assertValid();
Debug.assertion (getWriteability_MessageTemplate () != FieldWriteability.FALSE, "Assoc MessageTemplate is not writeable");
preMessageTemplateChange (newMessageTemplate);
_MessageTemplate.set (newMessageTemplate);
postMessageTemplateChange ();
}
}
/**
* 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
{
// Ensure we are removed from any loaded multi-associations that aren't mandatory
if (_JobApplication.isLoaded () || getTransaction ().isObjectLoaded (_JobApplication.getReferencedType (), getJobApplicationID ()))
{
JobApplication referenced = getJobApplication ();
if (referenced != null)
{
// Stop the callback
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Setting backreference to null ScheduledEmails from ", getObjectID (), " to ", referenced.getObjectID ());
_JobApplication.set (null);
referenced.removeFromScheduledEmails ((ScheduledEmail)this);
}
}
}
catch (Exception e)
{
throw NestedException.wrap(e);
}
super.onDelete ();
}
public ScheduledEmail newInstance ()
{
return new ScheduledEmail ();
}
public ScheduledEmail referenceInstance ()
{
return REFERENCE_ScheduledEmail;
}
public ScheduledEmail getInTransaction (ObjectTransaction t) throws StorageException
{
return getScheduledEmailByID (t, getObjectID());
}
public BaseBusinessClass dummyInstance ()
{
return DUMMY_ScheduledEmail;
}
public String getBaseSetName ()
{
return "tl_scheduled_email";
}
/**
* This is where an object returns the Persistent sets that will
* store it into the database.
* The should be entered into allSets
*/
public void getPersistentSets (PersistentSetCollection allSets)
{
ObjectStatus myStatus = getStatus ();
PersistentSetStatus myPSetStatus = myStatus.getPSetStatus();
ObjectID myID = getID();
super.getPersistentSets (allSets);
PersistentSet tl_scheduled_emailPSet = allSets.getPersistentSet (myID, "tl_scheduled_email", myPSetStatus);
tl_scheduled_emailPSet.setAttrib (FIELD_ObjectID, myID);
tl_scheduled_emailPSet.setAttrib (FIELD_Subject, HELPER_Subject.toObject (_Subject)); //
tl_scheduled_emailPSet.setAttrib (FIELD_ScheduledDate, HELPER_ScheduledDate.toObject (_ScheduledDate)); //
tl_scheduled_emailPSet.setAttrib (FIELD_ApplicationStatus, HELPER_ApplicationStatus.toObject (_ApplicationStatus)); //
tl_scheduled_emailPSet.setAttrib (FIELD_MessageContent, HELPER_MessageContent.toObject (_MessageContent)); //
_JobApplication.getPersistentSets (allSets);
_MessageTemplate.getPersistentSets (allSets);
}
/**
* Sets the objects state based on Persistent sets.
*/
public void setFromPersistentSets (ObjectID objectID, PersistentSetCollection allSets)
{
super.setFromPersistentSets (objectID, allSets);
PersistentSet tl_scheduled_emailPSet = allSets.getPersistentSet (objectID, "tl_scheduled_email");
_Subject = (String)(HELPER_Subject.fromObject (_Subject, tl_scheduled_emailPSet.getAttrib (FIELD_Subject))); //
_ScheduledDate = (Date)(HELPER_ScheduledDate.fromObject (_ScheduledDate, tl_scheduled_emailPSet.getAttrib (FIELD_ScheduledDate))); //
_ApplicationStatus = (ApplicationStatus)(HELPER_ApplicationStatus.fromObject (_ApplicationStatus, tl_scheduled_emailPSet.getAttrib (FIELD_ApplicationStatus))); //
_MessageContent = (String)(HELPER_MessageContent.fromObject (_MessageContent, tl_scheduled_emailPSet.getAttrib (FIELD_MessageContent))); //
_JobApplication.setFromPersistentSets (objectID, allSets);
_MessageTemplate.setFromPersistentSets (objectID, allSets);
}
public void setAttributesFrom (BaseBusinessClass other, MultiException e)
{
super.setAttributesFrom (other, e);
if (other instanceof ScheduledEmail)
{
ScheduledEmail otherScheduledEmail = (ScheduledEmail)other;
try
{
setSubject (otherScheduledEmail.getSubject ());
}
catch (FieldException ex)
{
e.addException (ex);
}
try
{
setScheduledDate (otherScheduledEmail.getScheduledDate ());
}
catch (FieldException ex)
{
e.addException (ex);
}
try
{
setApplicationStatus (otherScheduledEmail.getApplicationStatus ());
}
catch (FieldException ex)
{
e.addException (ex);
}
try
{
setMessageContent (otherScheduledEmail.getMessageContent ());
}
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 BaseScheduledEmail)
{
BaseScheduledEmail sourceScheduledEmail = (BaseScheduledEmail)(source);
_Subject = sourceScheduledEmail._Subject;
_ScheduledDate = sourceScheduledEmail._ScheduledDate;
_ApplicationStatus = sourceScheduledEmail._ApplicationStatus;
_MessageContent = sourceScheduledEmail._MessageContent;
}
}
/**
* 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 BaseScheduledEmail)
{
BaseScheduledEmail sourceScheduledEmail = (BaseScheduledEmail)(source);
_JobApplication.copyFrom (sourceScheduledEmail._JobApplication, linkToGhosts);
_MessageTemplate.copyFrom (sourceScheduledEmail._MessageTemplate, 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 BaseScheduledEmail)
{
BaseScheduledEmail sourceScheduledEmail = (BaseScheduledEmail)(source);
}
}
public void validate (ValidationContext context)
{
super.validate (context);
context.check (getJobApplicationID() != null, this, SINGLEREFERENCE_JobApplication, "mandatory");
}
/**
* Subclasses must override this to read in their attributes
*/
protected void readExternalData(Map<String, Object> vals) throws IOException, ClassNotFoundException
{
super.readExternalData(vals);
_Subject = (String)(HELPER_Subject.readExternal (_Subject, vals.get(FIELD_Subject))); //
_ScheduledDate = (Date)(HELPER_ScheduledDate.readExternal (_ScheduledDate, vals.get(FIELD_ScheduledDate))); //
_ApplicationStatus = (ApplicationStatus)(HELPER_ApplicationStatus.readExternal (_ApplicationStatus, vals.get(FIELD_ApplicationStatus))); //
_MessageContent = (String)(HELPER_MessageContent.readExternal (_MessageContent, vals.get(FIELD_MessageContent))); //
_JobApplication.readExternalData(vals.get(SINGLEREFERENCE_JobApplication));
_MessageTemplate.readExternalData(vals.get(SINGLEREFERENCE_MessageTemplate));
}
/**
* Subclasses must override this to write out their attributes
*/
protected void writeExternalData(Map<String, Object> vals) throws IOException
{
super.writeExternalData(vals);
vals.put (FIELD_Subject, HELPER_Subject.writeExternal (_Subject));
vals.put (FIELD_ScheduledDate, HELPER_ScheduledDate.writeExternal (_ScheduledDate));
vals.put (FIELD_ApplicationStatus, HELPER_ApplicationStatus.writeExternal (_ApplicationStatus));
vals.put (FIELD_MessageContent, HELPER_MessageContent.writeExternal (_MessageContent));
vals.put (SINGLEREFERENCE_JobApplication, _JobApplication.writeExternalData());
vals.put (SINGLEREFERENCE_MessageTemplate, _MessageTemplate.writeExternalData());
}
public void compare (BaseBusinessClass other, AttributeChangeListener listener) throws StorageException
{
super.compare (other, listener);
if (other instanceof BaseScheduledEmail)
{
BaseScheduledEmail otherScheduledEmail = (BaseScheduledEmail)(other);
if (!HELPER_Subject.compare(this._Subject, otherScheduledEmail._Subject))
{
listener.notifyFieldChange(this, other, FIELD_Subject, HELPER_Subject.toObject(this._Subject), HELPER_Subject.toObject(otherScheduledEmail._Subject));
}
if (!HELPER_ScheduledDate.compare(this._ScheduledDate, otherScheduledEmail._ScheduledDate))
{
listener.notifyFieldChange(this, other, FIELD_ScheduledDate, HELPER_ScheduledDate.toObject(this._ScheduledDate), HELPER_ScheduledDate.toObject(otherScheduledEmail._ScheduledDate));
}
if (!HELPER_ApplicationStatus.compare(this._ApplicationStatus, otherScheduledEmail._ApplicationStatus))
{
listener.notifyFieldChange(this, other, FIELD_ApplicationStatus, HELPER_ApplicationStatus.toObject(this._ApplicationStatus), HELPER_ApplicationStatus.toObject(otherScheduledEmail._ApplicationStatus));
}
if (!HELPER_MessageContent.compare(this._MessageContent, otherScheduledEmail._MessageContent))
{
listener.notifyFieldChange(this, other, FIELD_MessageContent, HELPER_MessageContent.toObject(this._MessageContent), HELPER_MessageContent.toObject(otherScheduledEmail._MessageContent));
}
// Compare single assocs
_JobApplication.compare (otherScheduledEmail._JobApplication, listener);
_MessageTemplate.compare (otherScheduledEmail._MessageTemplate, 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_Subject, HELPER_Subject.toObject(getSubject()));
visitor.visitField(this, FIELD_ScheduledDate, HELPER_ScheduledDate.toObject(getScheduledDate()));
visitor.visitField(this, FIELD_ApplicationStatus, HELPER_ApplicationStatus.toObject(getApplicationStatus()));
visitor.visitField(this, FIELD_MessageContent, HELPER_MessageContent.toObject(getMessageContent()));
visitor.visitAssociation (_JobApplication);
visitor.visitAssociation (_MessageTemplate);
}
public void visitAssociations (AssociationVisitor visitor, AssociatedScope scope) throws StorageException
{
super.visitAssociations (visitor, scope);
if (scope.includes (_JobApplication))
{
visitor.visit (_JobApplication);
}
if (scope.includes (_MessageTemplate))
{
visitor.visit (_MessageTemplate);
}
}
public static ScheduledEmail createScheduledEmail (ObjectTransaction transaction) throws StorageException
{
ScheduledEmail result = new ScheduledEmail ();
result.initialiseNewObject (transaction);
return result;
}
public static ScheduledEmail getScheduledEmailByID (ObjectTransaction transaction, Long objectID) throws StorageException
{
return (ScheduledEmail)(transaction.getObjectByID (REFERENCE_ScheduledEmail, objectID));
}
public boolean testFilter (String attribName, QueryFilter filter) throws StorageException
{
if (false)
{
throw new RuntimeException ("Game over man!!");
}
else if (attribName.equals (FIELD_Subject))
{
return filter.matches (getSubject ());
}
else if (attribName.equals (FIELD_ScheduledDate))
{
return filter.matches (getScheduledDate ());
}
else if (attribName.equals (FIELD_ApplicationStatus))
{
return filter.matches (getApplicationStatus ());
}
else if (attribName.equals (FIELD_MessageContent))
{
return filter.matches (getMessageContent ());
}
else if (attribName.equals (SINGLEREFERENCE_JobApplication))
{
return filter.matches (getJobApplication ());
}
else if (attribName.equals (SINGLEREFERENCE_MessageTemplate))
{
return filter.matches (getMessageTemplate ());
}
else
{
return super.testFilter (attribName, filter);
}
}
public static SearchAll SearchByAll () { return new SearchAll (); }
public static class SearchAll extends SearchObject<ScheduledEmail>
{
public SearchAll andObjectID (QueryFilter<Long> filter)
{
filter.addFilter (context, "tl_scheduled_email.object_id", FIELD_ObjectID);
return this;
}
public SearchAll andObjectCreated (QueryFilter<Date> filter)
{
filter.addFilter (context, "tl_scheduled_email.object_created_date", FIELD_ObjectCreated);
return this;
}
public SearchAll andObjectLastModified (QueryFilter<Date> filter)
{
filter.addFilter (context, "tl_scheduled_email.object_last_updated_date", FIELD_ObjectLastModified);
return this;
}
public SearchAll andSubject (QueryFilter<String> filter)
{
filter.addFilter (context, "tl_scheduled_email.subject", "Subject");
return this;
}
public SearchAll andScheduledDate (QueryFilter<Date> filter)
{
filter.addFilter (context, "tl_scheduled_email.scheduled_date", "ScheduledDate");
return this;
}
public SearchAll andApplicationStatus (QueryFilter<ApplicationStatus> filter)
{
filter.addFilter (context, "tl_scheduled_email.application_status", "ApplicationStatus");
return this;
}
public SearchAll andMessageContent (QueryFilter<String> filter)
{
filter.addFilter (context, "tl_scheduled_email.message_content", "MessageContent");
return this;
}
public SearchAll andJobApplication (QueryFilter<JobApplication> filter)
{
filter.addFilter (context, "tl_scheduled_email.job_application_id", "JobApplication");
return this;
}
public SearchAll andMessageTemplate (QueryFilter<MessageTemplate> filter)
{
filter.addFilter (context, "tl_scheduled_email.message_template_id", "MessageTemplate");
return this;
}
public ScheduledEmail[]
search (ObjectTransaction transaction) throws StorageException
{
BaseBusinessClass[] results = super.search (transaction, REFERENCE_ScheduledEmail, SEARCH_All, criteria);
Set<ScheduledEmail> typedResults = new LinkedHashSet <ScheduledEmail> ();
for (BaseBusinessClass bbcResult : results)
{
ScheduledEmail aResult = (ScheduledEmail)bbcResult;
typedResults.add (aResult);
}
return ObjstoreUtils.removeDeleted(transaction, typedResults).toArray (new ScheduledEmail[0]);
}
}
public static ScheduledEmail[]
searchAll (ObjectTransaction transaction) throws StorageException
{
return SearchByAll ()
.search (transaction);
}
public Object getAttribute (String attribName)
{
if (false)
{
throw new RuntimeException ("Game over man!!");
}
else if (attribName.equals (FIELD_Subject))
{
return HELPER_Subject.toObject (getSubject ());
}
else if (attribName.equals (FIELD_ScheduledDate))
{
return HELPER_ScheduledDate.toObject (getScheduledDate ());
}
else if (attribName.equals (FIELD_ApplicationStatus))
{
return HELPER_ApplicationStatus.toObject (getApplicationStatus ());
}
else if (attribName.equals (FIELD_MessageContent))
{
return HELPER_MessageContent.toObject (getMessageContent ());
}
else
{
return super.getAttribute (attribName);
}
}
public AttributeHelper getAttributeHelper (String attribName)
{
if (false)
{
throw new RuntimeException ("Game over man!!");
}
else if (attribName.equals (FIELD_Subject))
{
return HELPER_Subject;
}
else if (attribName.equals (FIELD_ScheduledDate))
{
return HELPER_ScheduledDate;
}
else if (attribName.equals (FIELD_ApplicationStatus))
{
return HELPER_ApplicationStatus;
}
else if (attribName.equals (FIELD_MessageContent))
{
return HELPER_MessageContent;
}
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_Subject))
{
setSubject ((String)(HELPER_Subject.fromObject (_Subject, attribValue)));
}
else if (attribName.equals (FIELD_ScheduledDate))
{
setScheduledDate ((Date)(HELPER_ScheduledDate.fromObject (_ScheduledDate, attribValue)));
}
else if (attribName.equals (FIELD_ApplicationStatus))
{
setApplicationStatus ((ApplicationStatus)(HELPER_ApplicationStatus.fromObject (_ApplicationStatus, attribValue)));
}
else if (attribName.equals (FIELD_MessageContent))
{
setMessageContent ((String)(HELPER_MessageContent.fromObject (_MessageContent, 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_Subject))
{
return getWriteability_Subject ();
}
else if (fieldName.equals (FIELD_ScheduledDate))
{
return getWriteability_ScheduledDate ();
}
else if (fieldName.equals (FIELD_ApplicationStatus))
{
return getWriteability_ApplicationStatus ();
}
else if (fieldName.equals (FIELD_MessageContent))
{
return getWriteability_MessageContent ();
}
else if (fieldName.equals (SINGLEREFERENCE_JobApplication))
{
return getWriteability_JobApplication ();
}
else if (fieldName.equals (SINGLEREFERENCE_MessageTemplate))
{
return getWriteability_MessageTemplate ();
}
else
{
return super.getWriteable (fieldName);
}
}
public void putUnwriteable (Set<String> fields)
{
if (getWriteability_Subject () != FieldWriteability.TRUE)
{
fields.add (FIELD_Subject);
}
if (getWriteability_ScheduledDate () != FieldWriteability.TRUE)
{
fields.add (FIELD_ScheduledDate);
}
if (getWriteability_ApplicationStatus () != FieldWriteability.TRUE)
{
fields.add (FIELD_ApplicationStatus);
}
if (getWriteability_MessageContent () != FieldWriteability.TRUE)
{
fields.add (FIELD_MessageContent);
}
super.putUnwriteable (fields);
}
public List<AbstractAttribute> getAttributes ()
{
List result = super.getAttributes ();
result.add(HELPER_Subject.getAttribObject (getClass (), _Subject, true, FIELD_Subject));
result.add(HELPER_ScheduledDate.getAttribObject (getClass (), _ScheduledDate, true, FIELD_ScheduledDate));
result.add(HELPER_ApplicationStatus.getAttribObject (getClass (), _ApplicationStatus, true, FIELD_ApplicationStatus));
result.add(HELPER_MessageContent.getAttribObject (getClass (), _MessageContent, true, FIELD_MessageContent));
return result;
}
public Map getAttributeMetadata (String attribute)
{
if (ATTRIBUTES_METADATA_ScheduledEmail.containsKey (attribute))
{
return (Map)ATTRIBUTES_METADATA_ScheduledEmail.get (attribute);
}
else
{
return super.getAttributeMetadata (attribute);
}
}
public Object getAttributeMetadata (String attribute, String metadata)
{
if (ATTRIBUTES_METADATA_ScheduledEmail.containsKey (attribute))
{
return ((Map)ATTRIBUTES_METADATA_ScheduledEmail.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 ScheduledEmailBehaviourDecorator extends BaseBusinessClass.BBCBehaviourDecorator<ScheduledEmail>
{
/**
* Get the attribute Subject
*/
public String getSubject (ScheduledEmail obj, String original)
{
return original;
}
/**
* Change the value set for attribute Subject.
* May modify the field beforehand
* Occurs before validation.
*/
public String setSubject (ScheduledEmail obj, String newSubject) throws FieldException
{
return newSubject;
}
/**
* Get the attribute ScheduledDate
*/
public Date getScheduledDate (ScheduledEmail obj, Date original)
{
return original;
}
/**
* Change the value set for attribute ScheduledDate.
* May modify the field beforehand
* Occurs before validation.
*/
public Date setScheduledDate (ScheduledEmail obj, Date newScheduledDate) throws FieldException
{
return newScheduledDate;
}
/**
* Get the attribute ApplicationStatus
*/
public ApplicationStatus getApplicationStatus (ScheduledEmail obj, ApplicationStatus original)
{
return original;
}
/**
* Change the value set for attribute ApplicationStatus.
* May modify the field beforehand
* Occurs before validation.
*/
public ApplicationStatus setApplicationStatus (ScheduledEmail obj, ApplicationStatus newApplicationStatus) throws FieldException
{
return newApplicationStatus;
}
/**
* Get the attribute MessageContent
*/
public String getMessageContent (ScheduledEmail obj, String original)
{
return original;
}
/**
* Change the value set for attribute MessageContent.
* May modify the field beforehand
* Occurs before validation.
*/
public String setMessageContent (ScheduledEmail obj, String newMessageContent) throws FieldException
{
return newMessageContent;
}
}
public ORMPipeLine pipes()
{
return new ScheduledEmailPipeLineFactory<ScheduledEmail, ScheduledEmail> ((ScheduledEmail)this);
}
/**
* Use this instead of pipes() to get rid of type casting.
*/
public ScheduledEmailPipeLineFactory<ScheduledEmail, ScheduledEmail> pipelineScheduledEmail()
{
return (ScheduledEmailPipeLineFactory<ScheduledEmail, ScheduledEmail>) pipes();
}
public static ScheduledEmailPipeLineFactory<ScheduledEmail, ScheduledEmail> pipesScheduledEmail(Collection<ScheduledEmail> items)
{
return REFERENCE_ScheduledEmail.new ScheduledEmailPipeLineFactory<ScheduledEmail, ScheduledEmail> (items);
}
public static ScheduledEmailPipeLineFactory<ScheduledEmail, ScheduledEmail> pipesScheduledEmail(ScheduledEmail[] _items)
{
return pipesScheduledEmail(Arrays.asList (_items));
}
public static ScheduledEmailPipeLineFactory<ScheduledEmail, ScheduledEmail> pipesScheduledEmail()
{
return pipesScheduledEmail((Collection)null);
}
public class ScheduledEmailPipeLineFactory<From extends BaseBusinessClass, Me extends ScheduledEmail> extends BaseBusinessClass.ORMPipeLine<From, Me>
{
public <Prev> ScheduledEmailPipeLineFactory (PipeLine<From, Prev> pipeLine, Pipe<Prev, Me> nextPipe)
{
super (pipeLine, nextPipe);
}
public ScheduledEmailPipeLineFactory (From seed)
{
super(seed);
}
public ScheduledEmailPipeLineFactory (Collection<From> seed)
{
super(seed);
}
public PipeLine<From, ? extends Object> to(String name)
{
if (name.equals ("Subject"))
{
return toSubject ();
}
if (name.equals ("ScheduledDate"))
{
return toScheduledDate ();
}
if (name.equals ("ApplicationStatus"))
{
return toApplicationStatus ();
}
if (name.equals ("MessageContent"))
{
return toMessageContent ();
}
if (name.equals ("JobApplication"))
{
return toJobApplication ();
}
if (name.equals ("MessageTemplate"))
{
return toMessageTemplate ();
}
return super.to(name);
}
public PipeLine<From, String> toSubject () { return pipe(new ORMAttributePipe<Me, String>(FIELD_Subject)); }
public PipeLine<From, Date> toScheduledDate () { return pipe(new ORMAttributePipe<Me, Date>(FIELD_ScheduledDate)); }
public PipeLine<From, ApplicationStatus> toApplicationStatus () { return pipe(new ORMAttributePipe<Me, ApplicationStatus>(FIELD_ApplicationStatus)); }
public PipeLine<From, String> toMessageContent () { return pipe(new ORMAttributePipe<Me, String>(FIELD_MessageContent)); }
public JobApplication.JobApplicationPipeLineFactory<From, JobApplication> toJobApplication () { return toJobApplication (Filter.ALL); }
public JobApplication.JobApplicationPipeLineFactory<From, JobApplication> toJobApplication (Filter<JobApplication> filter)
{
return JobApplication.REFERENCE_JobApplication.new JobApplicationPipeLineFactory<From, JobApplication> (this, new ORMSingleAssocPipe<Me, JobApplication>(SINGLEREFERENCE_JobApplication, filter));
}
public MessageTemplate.MessageTemplatePipeLineFactory<From, MessageTemplate> toMessageTemplate () { return toMessageTemplate (Filter.ALL); }
public MessageTemplate.MessageTemplatePipeLineFactory<From, MessageTemplate> toMessageTemplate (Filter<MessageTemplate> filter)
{
return MessageTemplate.REFERENCE_MessageTemplate.new MessageTemplatePipeLineFactory<From, MessageTemplate> (this, new ORMSingleAssocPipe<Me, MessageTemplate>(SINGLEREFERENCE_MessageTemplate, filter));
}
}
public boolean isTransientAttrib(String attribName)
{
return super.isTransientAttrib(attribName);
}
public boolean isTransientSingleReference(String assocName)
{
return super.isTransientSingleReference(assocName);
}
}
class DummyScheduledEmail extends ScheduledEmail
{
// Default constructor primarily to support Externalisable
public DummyScheduledEmail()
{
super();
}
public void assertValid ()
{
}
public JobApplication getJobApplication () throws StorageException
{
return (JobApplication)(JobApplication.DUMMY_JobApplication);
}
/**
* Get the object id for the referenced object. Does not force a DB access.
*/
public Long getJobApplicationID ()
{
return JobApplication.DUMMY_JobApplication.getObjectID();
}
public MessageTemplate getMessageTemplate () throws StorageException
{
return (MessageTemplate)(MessageTemplate.DUMMY_MessageTemplate);
}
/**
* Get the object id for the referenced object. Does not force a DB access.
*/
public Long getMessageTemplateID ()
{
return MessageTemplate.DUMMY_MessageTemplate.getObjectID();
}
}
/*
* IMPORTANT!!!! XSL Autogenerated class, DO NOT EDIT!!!!!
* Template: Infrastructure8.2 rev3 [oneit.objstore.BusinessObjectTemplate.xsl]
*
* Version: 1.0
* Vendor: Apache Software Foundation (Xalan XSLTC)
* Vendor URL: http://xml.apache.org/xalan-j
*/
package performa.orm;
import java.io.*;
import java.util.*;
import oneit.appservices.config.*;
import oneit.logging.*;
import oneit.objstore.*;
import oneit.objstore.assocs.*;
import oneit.objstore.attributes.*;
import oneit.objstore.rdbms.filters.*;
import oneit.objstore.parser.*;
import oneit.objstore.validator.*;
import oneit.objstore.utils.*;
import oneit.utils.*;
import oneit.utils.filter.Filter;
import oneit.utils.transform.*;
import oneit.utils.parsers.FieldException;
import performa.orm.types.*;
public abstract class BaseSentEmail extends BaseBusinessClass
{
// Reference instance for the object
public static final SentEmail REFERENCE_SentEmail = new SentEmail ();
// Reference instance for the object
public static final SentEmail DUMMY_SentEmail = new DummySentEmail ();
// Static constants corresponding to field names
public static final String FIELD_Subject = "Subject";
public static final String FIELD_SentDate = "SentDate";
public static final String FIELD_ApplicationStatus = "ApplicationStatus";
public static final String FIELD_MessageContent = "MessageContent";
public static final String FIELD_EmailTo = "EmailTo";
public static final String SINGLEREFERENCE_JobApplication = "JobApplication";
public static final String BACKREF_JobApplication = "";
// Static constants corresponding to searches
public static final String SEARCH_All = "All";
// Static constants corresponding to attribute helpers
private static final DefaultAttributeHelper<SentEmail> HELPER_Subject = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper<SentEmail> HELPER_SentDate = DefaultAttributeHelper.INSTANCE;
private static final EnumeratedAttributeHelper<SentEmail, ApplicationStatus> HELPER_ApplicationStatus = new EnumeratedAttributeHelper<SentEmail, ApplicationStatus> (ApplicationStatus.FACTORY_ApplicationStatus);
private static final DefaultAttributeHelper<SentEmail> HELPER_MessageContent = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper<SentEmail> HELPER_EmailTo = DefaultAttributeHelper.INSTANCE;
// Private attributes corresponding to business object data
private String _Subject;
private Date _SentDate;
private ApplicationStatus _ApplicationStatus;
private String _MessageContent;
private String _EmailTo;
// Private attributes corresponding to single references
private SingleAssociation<SentEmail, JobApplication> _JobApplication;
// Private attributes corresponding to multiple references
// Map of maps of metadata
private static final Map ATTRIBUTES_METADATA_SentEmail = new HashMap ();
// Arrays of validators for each attribute
private static final AttributeValidator[] FIELD_Subject_Validators;
private static final AttributeValidator[] FIELD_SentDate_Validators;
private static final AttributeValidator[] FIELD_ApplicationStatus_Validators;
private static final AttributeValidator[] FIELD_MessageContent_Validators;
private static final AttributeValidator[] FIELD_EmailTo_Validators;
// Arrays of behaviour decorators
private static final SentEmailBehaviourDecorator[] SentEmail_BehaviourDecorators;
static
{
try
{
String tmp_JobApplication = JobApplication.BACKREF_SentEmails;
Map validatorMapping = ((Map)ConfigMgr.getConfigObject ("CONFIG.ORMVALIDATOR", "ValidatorMapping"));
setupAssocMetaData_JobApplication();
FIELD_Subject_Validators = (AttributeValidator[])setupAttribMetaData_Subject(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_SentDate_Validators = (AttributeValidator[])setupAttribMetaData_SentDate(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_ApplicationStatus_Validators = (AttributeValidator[])setupAttribMetaData_ApplicationStatus(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_MessageContent_Validators = (AttributeValidator[])setupAttribMetaData_MessageContent(validatorMapping).toArray (new AttributeValidator[0]);
FIELD_EmailTo_Validators = (AttributeValidator[])setupAttribMetaData_EmailTo(validatorMapping).toArray (new AttributeValidator[0]);
REFERENCE_SentEmail.initialiseReference ();
DUMMY_SentEmail.initialiseReference ();
SentEmail_BehaviourDecorators = BaseBusinessClass.getBBCBehaviours(SentEmail.class).toArray(new SentEmailBehaviourDecorator[0]);
}
catch (RuntimeException e)
{
LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR1, e, "Error initialising");
throw e;
}
}
// Meta Info setup
private static void setupAssocMetaData_JobApplication()
{
Map metaInfo = new HashMap ();
metaInfo.put ("backreferenceName", "SentEmails");
metaInfo.put ("dbcol", "job_application_id");
metaInfo.put ("mandatory", "true");
metaInfo.put ("name", "JobApplication");
metaInfo.put ("type", "JobApplication");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for SentEmail.JobApplication:", metaInfo);
ATTRIBUTES_METADATA_SentEmail.put (SINGLEREFERENCE_JobApplication, Collections.unmodifiableMap (metaInfo));
}
// Meta Info setup
private static List setupAttribMetaData_Subject(Map validatorMapping)
{
Map metaInfo = new HashMap ();
metaInfo.put ("dbcol", "subject");
metaInfo.put ("length", "200");
metaInfo.put ("mandatory", "true");
metaInfo.put ("name", "Subject");
metaInfo.put ("type", "String");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for SentEmail.Subject:", metaInfo);
ATTRIBUTES_METADATA_SentEmail.put (FIELD_Subject, Collections.unmodifiableMap (metaInfo));
List validators = BaseBusinessClass.getAttribValidators(SentEmail.class, "Subject", metaInfo, validatorMapping);
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for SentEmail.Subject:", validators);
return validators;
}
// Meta Info setup
private static List setupAttribMetaData_SentDate(Map validatorMapping)
{
Map metaInfo = new HashMap ();
metaInfo.put ("dbcol", "sent_date");
metaInfo.put ("mandatory", "true");
metaInfo.put ("name", "SentDate");
metaInfo.put ("type", "Date");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for SentEmail.SentDate:", metaInfo);
ATTRIBUTES_METADATA_SentEmail.put (FIELD_SentDate, Collections.unmodifiableMap (metaInfo));
List validators = BaseBusinessClass.getAttribValidators(SentEmail.class, "SentDate", metaInfo, validatorMapping);
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for SentEmail.SentDate:", validators);
return validators;
}
// Meta Info setup
private static List setupAttribMetaData_ApplicationStatus(Map validatorMapping)
{
Map metaInfo = new HashMap ();
metaInfo.put ("attribHelper", "EnumeratedAttributeHelper");
metaInfo.put ("dbcol", "application_status");
metaInfo.put ("mandatory", "true");
metaInfo.put ("name", "ApplicationStatus");
metaInfo.put ("type", "ApplicationStatus");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for SentEmail.ApplicationStatus:", metaInfo);
ATTRIBUTES_METADATA_SentEmail.put (FIELD_ApplicationStatus, Collections.unmodifiableMap (metaInfo));
List validators = BaseBusinessClass.getAttribValidators(SentEmail.class, "ApplicationStatus", metaInfo, validatorMapping);
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for SentEmail.ApplicationStatus:", validators);
return validators;
}
// Meta Info setup
private static List setupAttribMetaData_MessageContent(Map validatorMapping)
{
Map metaInfo = new HashMap ();
metaInfo.put ("dbcol", "message_content");
metaInfo.put ("mandatory", "true");
metaInfo.put ("name", "MessageContent");
metaInfo.put ("type", "String");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for SentEmail.MessageContent:", metaInfo);
ATTRIBUTES_METADATA_SentEmail.put (FIELD_MessageContent, Collections.unmodifiableMap (metaInfo));
List validators = BaseBusinessClass.getAttribValidators(SentEmail.class, "MessageContent", metaInfo, validatorMapping);
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for SentEmail.MessageContent:", validators);
return validators;
}
// Meta Info setup
private static List setupAttribMetaData_EmailTo(Map validatorMapping)
{
Map metaInfo = new HashMap ();
metaInfo.put ("dbcol", "email_to");
metaInfo.put ("mandatory", "true");
metaInfo.put ("name", "EmailTo");
metaInfo.put ("type", "String");
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for SentEmail.EmailTo:", metaInfo);
ATTRIBUTES_METADATA_SentEmail.put (FIELD_EmailTo, Collections.unmodifiableMap (metaInfo));
List validators = BaseBusinessClass.getAttribValidators(SentEmail.class, "EmailTo", metaInfo, validatorMapping);
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for SentEmail.EmailTo:", validators);
return validators;
}
// END OF STATIC METADATA DEFINITION
// This constructor should not be called
protected BaseSentEmail ()
{
}
protected BBCBehaviourDecorator[] getBehaviours()
{
return SentEmail_BehaviourDecorators;
}
// Initialise the attributes
protected void _initialiseNewObjAttributes (ObjectTransaction transaction) throws StorageException
{
super._initialiseNewObjAttributes (transaction);
_Subject = (String)(HELPER_Subject.initialise (_Subject));
_SentDate = (Date)(HELPER_SentDate.initialise (_SentDate));
_ApplicationStatus = (ApplicationStatus)(HELPER_ApplicationStatus.initialise (_ApplicationStatus));
_MessageContent = (String)(HELPER_MessageContent.initialise (_MessageContent));
_EmailTo = (String)(HELPER_EmailTo.initialise (_EmailTo));
}
// Initialise the associations
protected void _initialiseAssociations ()
{
super._initialiseAssociations ();
_JobApplication = new SingleAssociation<SentEmail, JobApplication> (this, SINGLEREFERENCE_JobApplication, JobApplication.MULTIPLEREFERENCE_SentEmails, JobApplication.REFERENCE_JobApplication, "tl_sent_email");
}
// Initialise the associations
protected BaseBusinessClass initialiseReference ()
{
super.initialiseReference ();
_JobApplication = new SingleAssociation<SentEmail, JobApplication> (this, SINGLEREFERENCE_JobApplication, JobApplication.MULTIPLEREFERENCE_SentEmails, JobApplication.REFERENCE_JobApplication, "tl_sent_email");
return this;
}
/**
* Get the attribute Subject
*/
public String getSubject ()
{
assertValid();
String valToReturn = _Subject;
for (SentEmailBehaviourDecorator bhd : SentEmail_BehaviourDecorators)
{
valToReturn = bhd.getSubject ((SentEmail)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 preSubjectChange (String newSubject) 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 postSubjectChange () throws FieldException
{
}
public FieldWriteability getWriteability_Subject ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the attribute Subject. Checks to ensure a new value
* has been supplied. If so, marks the field as altered and sets the attribute.
*/
public void setSubject (String newSubject) throws FieldException
{
boolean oldAndNewIdentical = HELPER_Subject.compare (_Subject, newSubject);
try
{
for (SentEmailBehaviourDecorator bhd : SentEmail_BehaviourDecorators)
{
newSubject = bhd.setSubject ((SentEmail)this, newSubject);
oldAndNewIdentical = HELPER_Subject.compare (_Subject, newSubject);
}
BusinessObjectParser.assertFieldCondition (newSubject != null, this, FIELD_Subject, "mandatory");
if (FIELD_Subject_Validators.length > 0)
{
Object newSubjectObj = HELPER_Subject.toObject (newSubject);
if (newSubjectObj != null)
{
int loopMax = FIELD_Subject_Validators.length;
Map metadata = (Map)ATTRIBUTES_METADATA_SentEmail.get (FIELD_Subject);
for (int v = 0 ; v < loopMax ; ++v)
{
FIELD_Subject_Validators[v].checkAttribute (this, FIELD_Subject, metadata, newSubjectObj);
}
}
}
}
catch (FieldException e)
{
if (!oldAndNewIdentical)
{
e.setWouldModify ();
}
throw e;
}
if (!oldAndNewIdentical)
{
assertValid();
Debug.assertion (getWriteability_Subject () != FieldWriteability.FALSE, "Field Subject is not writeable");
preSubjectChange (newSubject);
markFieldChange (FIELD_Subject);
_Subject = newSubject;
postFieldChange (FIELD_Subject);
postSubjectChange ();
}
}
/**
* Get the attribute SentDate
*/
public Date getSentDate ()
{
assertValid();
Date valToReturn = _SentDate;
for (SentEmailBehaviourDecorator bhd : SentEmail_BehaviourDecorators)
{
valToReturn = bhd.getSentDate ((SentEmail)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 preSentDateChange (Date newSentDate) 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 postSentDateChange () throws FieldException
{
}
public FieldWriteability getWriteability_SentDate ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the attribute SentDate. Checks to ensure a new value
* has been supplied. If so, marks the field as altered and sets the attribute.
*/
public void setSentDate (Date newSentDate) throws FieldException
{
boolean oldAndNewIdentical = HELPER_SentDate.compare (_SentDate, newSentDate);
try
{
for (SentEmailBehaviourDecorator bhd : SentEmail_BehaviourDecorators)
{
newSentDate = bhd.setSentDate ((SentEmail)this, newSentDate);
oldAndNewIdentical = HELPER_SentDate.compare (_SentDate, newSentDate);
}
BusinessObjectParser.assertFieldCondition (newSentDate != null, this, FIELD_SentDate, "mandatory");
if (FIELD_SentDate_Validators.length > 0)
{
Object newSentDateObj = HELPER_SentDate.toObject (newSentDate);
if (newSentDateObj != null)
{
int loopMax = FIELD_SentDate_Validators.length;
Map metadata = (Map)ATTRIBUTES_METADATA_SentEmail.get (FIELD_SentDate);
for (int v = 0 ; v < loopMax ; ++v)
{
FIELD_SentDate_Validators[v].checkAttribute (this, FIELD_SentDate, metadata, newSentDateObj);
}
}
}
}
catch (FieldException e)
{
if (!oldAndNewIdentical)
{
e.setWouldModify ();
}
throw e;
}
if (!oldAndNewIdentical)
{
assertValid();
Debug.assertion (getWriteability_SentDate () != FieldWriteability.FALSE, "Field SentDate is not writeable");
preSentDateChange (newSentDate);
markFieldChange (FIELD_SentDate);
_SentDate = newSentDate;
postFieldChange (FIELD_SentDate);
postSentDateChange ();
}
}
/**
* Get the attribute ApplicationStatus
*/
public ApplicationStatus getApplicationStatus ()
{
assertValid();
ApplicationStatus valToReturn = _ApplicationStatus;
for (SentEmailBehaviourDecorator bhd : SentEmail_BehaviourDecorators)
{
valToReturn = bhd.getApplicationStatus ((SentEmail)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 preApplicationStatusChange (ApplicationStatus newApplicationStatus) 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 postApplicationStatusChange () throws FieldException
{
}
public FieldWriteability getWriteability_ApplicationStatus ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the attribute ApplicationStatus. Checks to ensure a new value
* has been supplied. If so, marks the field as altered and sets the attribute.
*/
public void setApplicationStatus (ApplicationStatus newApplicationStatus) throws FieldException
{
boolean oldAndNewIdentical = HELPER_ApplicationStatus.compare (_ApplicationStatus, newApplicationStatus);
try
{
for (SentEmailBehaviourDecorator bhd : SentEmail_BehaviourDecorators)
{
newApplicationStatus = bhd.setApplicationStatus ((SentEmail)this, newApplicationStatus);
oldAndNewIdentical = HELPER_ApplicationStatus.compare (_ApplicationStatus, newApplicationStatus);
}
BusinessObjectParser.assertFieldCondition (newApplicationStatus != null, this, FIELD_ApplicationStatus, "mandatory");
if (FIELD_ApplicationStatus_Validators.length > 0)
{
Object newApplicationStatusObj = HELPER_ApplicationStatus.toObject (newApplicationStatus);
if (newApplicationStatusObj != null)
{
int loopMax = FIELD_ApplicationStatus_Validators.length;
Map metadata = (Map)ATTRIBUTES_METADATA_SentEmail.get (FIELD_ApplicationStatus);
for (int v = 0 ; v < loopMax ; ++v)
{
FIELD_ApplicationStatus_Validators[v].checkAttribute (this, FIELD_ApplicationStatus, metadata, newApplicationStatusObj);
}
}
}
}
catch (FieldException e)
{
if (!oldAndNewIdentical)
{
e.setWouldModify ();
}
throw e;
}
if (!oldAndNewIdentical)
{
assertValid();
Debug.assertion (getWriteability_ApplicationStatus () != FieldWriteability.FALSE, "Field ApplicationStatus is not writeable");
preApplicationStatusChange (newApplicationStatus);
markFieldChange (FIELD_ApplicationStatus);
_ApplicationStatus = newApplicationStatus;
postFieldChange (FIELD_ApplicationStatus);
postApplicationStatusChange ();
}
}
/**
* Get the attribute MessageContent
*/
public String getMessageContent ()
{
assertValid();
String valToReturn = _MessageContent;
for (SentEmailBehaviourDecorator bhd : SentEmail_BehaviourDecorators)
{
valToReturn = bhd.getMessageContent ((SentEmail)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 preMessageContentChange (String newMessageContent) 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 postMessageContentChange () throws FieldException
{
}
public FieldWriteability getWriteability_MessageContent ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the attribute MessageContent. Checks to ensure a new value
* has been supplied. If so, marks the field as altered and sets the attribute.
*/
public void setMessageContent (String newMessageContent) throws FieldException
{
boolean oldAndNewIdentical = HELPER_MessageContent.compare (_MessageContent, newMessageContent);
try
{
for (SentEmailBehaviourDecorator bhd : SentEmail_BehaviourDecorators)
{
newMessageContent = bhd.setMessageContent ((SentEmail)this, newMessageContent);
oldAndNewIdentical = HELPER_MessageContent.compare (_MessageContent, newMessageContent);
}
BusinessObjectParser.assertFieldCondition (newMessageContent != null, this, FIELD_MessageContent, "mandatory");
if (FIELD_MessageContent_Validators.length > 0)
{
Object newMessageContentObj = HELPER_MessageContent.toObject (newMessageContent);
if (newMessageContentObj != null)
{
int loopMax = FIELD_MessageContent_Validators.length;
Map metadata = (Map)ATTRIBUTES_METADATA_SentEmail.get (FIELD_MessageContent);
for (int v = 0 ; v < loopMax ; ++v)
{
FIELD_MessageContent_Validators[v].checkAttribute (this, FIELD_MessageContent, metadata, newMessageContentObj);
}
}
}
}
catch (FieldException e)
{
if (!oldAndNewIdentical)
{
e.setWouldModify ();
}
throw e;
}
if (!oldAndNewIdentical)
{
assertValid();
Debug.assertion (getWriteability_MessageContent () != FieldWriteability.FALSE, "Field MessageContent is not writeable");
preMessageContentChange (newMessageContent);
markFieldChange (FIELD_MessageContent);
_MessageContent = newMessageContent;
postFieldChange (FIELD_MessageContent);
postMessageContentChange ();
}
}
/**
* Get the attribute EmailTo
*/
public String getEmailTo ()
{
assertValid();
String valToReturn = _EmailTo;
for (SentEmailBehaviourDecorator bhd : SentEmail_BehaviourDecorators)
{
valToReturn = bhd.getEmailTo ((SentEmail)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 preEmailToChange (String newEmailTo) 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 postEmailToChange () throws FieldException
{
}
public FieldWriteability getWriteability_EmailTo ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the attribute EmailTo. Checks to ensure a new value
* has been supplied. If so, marks the field as altered and sets the attribute.
*/
public void setEmailTo (String newEmailTo) throws FieldException
{
boolean oldAndNewIdentical = HELPER_EmailTo.compare (_EmailTo, newEmailTo);
try
{
for (SentEmailBehaviourDecorator bhd : SentEmail_BehaviourDecorators)
{
newEmailTo = bhd.setEmailTo ((SentEmail)this, newEmailTo);
oldAndNewIdentical = HELPER_EmailTo.compare (_EmailTo, newEmailTo);
}
BusinessObjectParser.assertFieldCondition (newEmailTo != null, this, FIELD_EmailTo, "mandatory");
if (FIELD_EmailTo_Validators.length > 0)
{
Object newEmailToObj = HELPER_EmailTo.toObject (newEmailTo);
if (newEmailToObj != null)
{
int loopMax = FIELD_EmailTo_Validators.length;
Map metadata = (Map)ATTRIBUTES_METADATA_SentEmail.get (FIELD_EmailTo);
for (int v = 0 ; v < loopMax ; ++v)
{
FIELD_EmailTo_Validators[v].checkAttribute (this, FIELD_EmailTo, metadata, newEmailToObj);
}
}
}
}
catch (FieldException e)
{
if (!oldAndNewIdentical)
{
e.setWouldModify ();
}
throw e;
}
if (!oldAndNewIdentical)
{
assertValid();
Debug.assertion (getWriteability_EmailTo () != FieldWriteability.FALSE, "Field EmailTo is not writeable");
preEmailToChange (newEmailTo);
markFieldChange (FIELD_EmailTo);
_EmailTo = newEmailTo;
postFieldChange (FIELD_EmailTo);
postEmailToChange ();
}
}
/**
* A list of multi assoc names e.g. list of strings.
*/
public List<String> getSingleAssocs()
{
List result = super.getSingleAssocs ();
result.add("JobApplication");
return result;
}
public BaseBusinessClass getSingleAssocReferenceInstance (String assocName)
{
if (assocName == null)
{
throw new RuntimeException ("Game over == null!");
}
else if (assocName.equals (SINGLEREFERENCE_JobApplication))
{
return _JobApplication.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_JobApplication))
{
return JobApplication.MULTIPLEREFERENCE_SentEmails ;
}
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_JobApplication))
{
return getJobApplication ();
}
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_JobApplication))
{
return getJobApplication (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_JobApplication))
{
return getJobApplicationID ();
}
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_JobApplication))
{
setJobApplication ((JobApplication)(newValue));
}
else
{
super.setSingleAssoc (assocName, newValue);
}
}
/**
* Get the reference JobApplication
*/
public JobApplication getJobApplication () throws StorageException
{
assertValid();
try
{
return (JobApplication)(_JobApplication.get ());
}
catch (ClassCastException e)
{
LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR2, "Cache collision in SentEmail:", this.getObjectID (), ", was trying to get JobApplication:", getJobApplicationID ());
LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR2, "Instead I got:", _JobApplication.get ().getClass ());
throw e;
}
}
/**
* Get the object id for the referenced object. Does not force a DB access.
*/
public JobApplication getJobApplication (Get getType) throws StorageException
{
assertValid();
return _JobApplication.get(getType);
}
/**
* Get the object id for the referenced object. Does not force a DB access.
*/
public Long getJobApplicationID ()
{
assertValid();
if (_JobApplication == null)
{
return null;
}
else
{
return _JobApplication.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 preJobApplicationChange (JobApplication newJobApplication) 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 postJobApplicationChange () throws FieldException
{
}
public FieldWriteability getWriteability_JobApplication ()
{
return getFieldWritabilityUtil (FieldWriteability.TRUE);
}
/**
* Set the reference JobApplication. Checks to ensure a new value
* has been supplied. If so, marks the reference as altered and sets it.
*/
public void setJobApplication (JobApplication newJobApplication) throws StorageException, FieldException
{
BusinessObjectParser.assertFieldCondition (newJobApplication != null, this, SINGLEREFERENCE_JobApplication, "mandatory");
if (_JobApplication.wouldReferencedChange (newJobApplication))
{
assertValid();
Debug.assertion (getWriteability_JobApplication () != FieldWriteability.FALSE, "Assoc JobApplication is not writeable");
preJobApplicationChange (newJobApplication);
JobApplication oldJobApplication = getJobApplication ();
if (oldJobApplication != null)
{
// This is to stop validation from triggering when we are removed
_JobApplication.set (null);
oldJobApplication.removeFromSentEmails ((SentEmail)(this));
}
_JobApplication.set (newJobApplication);
if (newJobApplication != null)
{
newJobApplication.addToSentEmails ((SentEmail)(this));
}
postJobApplicationChange ();
}
}
/**
* 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
{
// Ensure we are removed from any loaded multi-associations that aren't mandatory
if (_JobApplication.isLoaded () || getTransaction ().isObjectLoaded (_JobApplication.getReferencedType (), getJobApplicationID ()))
{
JobApplication referenced = getJobApplication ();
if (referenced != null)
{
// Stop the callback
LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Setting backreference to null SentEmails from ", getObjectID (), " to ", referenced.getObjectID ());
_JobApplication.set (null);
referenced.removeFromSentEmails ((SentEmail)this);
}
}
}
catch (Exception e)
{
throw NestedException.wrap(e);
}
super.onDelete ();
}
public SentEmail newInstance ()
{
return new SentEmail ();
}
public SentEmail referenceInstance ()
{
return REFERENCE_SentEmail;
}
public SentEmail getInTransaction (ObjectTransaction t) throws StorageException
{
return getSentEmailByID (t, getObjectID());
}
public BaseBusinessClass dummyInstance ()
{
return DUMMY_SentEmail;
}
public String getBaseSetName ()
{
return "tl_sent_email";
}
/**
* This is where an object returns the Persistent sets that will
* store it into the database.
* The should be entered into allSets
*/
public void getPersistentSets (PersistentSetCollection allSets)
{
ObjectStatus myStatus = getStatus ();
PersistentSetStatus myPSetStatus = myStatus.getPSetStatus();
ObjectID myID = getID();
super.getPersistentSets (allSets);
PersistentSet tl_sent_emailPSet = allSets.getPersistentSet (myID, "tl_sent_email", myPSetStatus);
tl_sent_emailPSet.setAttrib (FIELD_ObjectID, myID);
tl_sent_emailPSet.setAttrib (FIELD_Subject, HELPER_Subject.toObject (_Subject)); //
tl_sent_emailPSet.setAttrib (FIELD_SentDate, HELPER_SentDate.toObject (_SentDate)); //
tl_sent_emailPSet.setAttrib (FIELD_ApplicationStatus, HELPER_ApplicationStatus.toObject (_ApplicationStatus)); //
tl_sent_emailPSet.setAttrib (FIELD_MessageContent, HELPER_MessageContent.toObject (_MessageContent)); //
tl_sent_emailPSet.setAttrib (FIELD_EmailTo, HELPER_EmailTo.toObject (_EmailTo)); //
_JobApplication.getPersistentSets (allSets);
}
/**
* Sets the objects state based on Persistent sets.
*/
public void setFromPersistentSets (ObjectID objectID, PersistentSetCollection allSets)
{
super.setFromPersistentSets (objectID, allSets);
PersistentSet tl_sent_emailPSet = allSets.getPersistentSet (objectID, "tl_sent_email");
_Subject = (String)(HELPER_Subject.fromObject (_Subject, tl_sent_emailPSet.getAttrib (FIELD_Subject))); //
_SentDate = (Date)(HELPER_SentDate.fromObject (_SentDate, tl_sent_emailPSet.getAttrib (FIELD_SentDate))); //
_ApplicationStatus = (ApplicationStatus)(HELPER_ApplicationStatus.fromObject (_ApplicationStatus, tl_sent_emailPSet.getAttrib (FIELD_ApplicationStatus))); //
_MessageContent = (String)(HELPER_MessageContent.fromObject (_MessageContent, tl_sent_emailPSet.getAttrib (FIELD_MessageContent))); //
_EmailTo = (String)(HELPER_EmailTo.fromObject (_EmailTo, tl_sent_emailPSet.getAttrib (FIELD_EmailTo))); //
_JobApplication.setFromPersistentSets (objectID, allSets);
}
public void setAttributesFrom (BaseBusinessClass other, MultiException e)
{
super.setAttributesFrom (other, e);
if (other instanceof SentEmail)
{
SentEmail otherSentEmail = (SentEmail)other;
try
{
setSubject (otherSentEmail.getSubject ());
}
catch (FieldException ex)
{
e.addException (ex);
}
try
{
setSentDate (otherSentEmail.getSentDate ());
}
catch (FieldException ex)
{
e.addException (ex);
}
try
{
setApplicationStatus (otherSentEmail.getApplicationStatus ());
}
catch (FieldException ex)
{
e.addException (ex);
}
try
{
setMessageContent (otherSentEmail.getMessageContent ());
}
catch (FieldException ex)
{
e.addException (ex);
}
try
{
setEmailTo (otherSentEmail.getEmailTo ());
}
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 BaseSentEmail)
{
BaseSentEmail sourceSentEmail = (BaseSentEmail)(source);
_Subject = sourceSentEmail._Subject;
_SentDate = sourceSentEmail._SentDate;
_ApplicationStatus = sourceSentEmail._ApplicationStatus;
_MessageContent = sourceSentEmail._MessageContent;
_EmailTo = sourceSentEmail._EmailTo;
}
}
/**
* 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 BaseSentEmail)
{
BaseSentEmail sourceSentEmail = (BaseSentEmail)(source);
_JobApplication.copyFrom (sourceSentEmail._JobApplication, 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 BaseSentEmail)
{
BaseSentEmail sourceSentEmail = (BaseSentEmail)(source);
}
}
public void validate (ValidationContext context)
{
super.validate (context);
context.check (getJobApplicationID() != null, this, SINGLEREFERENCE_JobApplication, "mandatory");
}
/**
* Subclasses must override this to read in their attributes
*/
protected void readExternalData(Map<String, Object> vals) throws IOException, ClassNotFoundException
{
super.readExternalData(vals);
_Subject = (String)(HELPER_Subject.readExternal (_Subject, vals.get(FIELD_Subject))); //
_SentDate = (Date)(HELPER_SentDate.readExternal (_SentDate, vals.get(FIELD_SentDate))); //
_ApplicationStatus = (ApplicationStatus)(HELPER_ApplicationStatus.readExternal (_ApplicationStatus, vals.get(FIELD_ApplicationStatus))); //
_MessageContent = (String)(HELPER_MessageContent.readExternal (_MessageContent, vals.get(FIELD_MessageContent))); //
_EmailTo = (String)(HELPER_EmailTo.readExternal (_EmailTo, vals.get(FIELD_EmailTo))); //
_JobApplication.readExternalData(vals.get(SINGLEREFERENCE_JobApplication));
}
/**
* Subclasses must override this to write out their attributes
*/
protected void writeExternalData(Map<String, Object> vals) throws IOException
{
super.writeExternalData(vals);
vals.put (FIELD_Subject, HELPER_Subject.writeExternal (_Subject));
vals.put (FIELD_SentDate, HELPER_SentDate.writeExternal (_SentDate));
vals.put (FIELD_ApplicationStatus, HELPER_ApplicationStatus.writeExternal (_ApplicationStatus));
vals.put (FIELD_MessageContent, HELPER_MessageContent.writeExternal (_MessageContent));
vals.put (FIELD_EmailTo, HELPER_EmailTo.writeExternal (_EmailTo));
vals.put (SINGLEREFERENCE_JobApplication, _JobApplication.writeExternalData());
}
public void compare (BaseBusinessClass other, AttributeChangeListener listener) throws StorageException
{
super.compare (other, listener);
if (other instanceof BaseSentEmail)
{
BaseSentEmail otherSentEmail = (BaseSentEmail)(other);
if (!HELPER_Subject.compare(this._Subject, otherSentEmail._Subject))
{
listener.notifyFieldChange(this, other, FIELD_Subject, HELPER_Subject.toObject(this._Subject), HELPER_Subject.toObject(otherSentEmail._Subject));
}
if (!HELPER_SentDate.compare(this._SentDate, otherSentEmail._SentDate))
{
listener.notifyFieldChange(this, other, FIELD_SentDate, HELPER_SentDate.toObject(this._SentDate), HELPER_SentDate.toObject(otherSentEmail._SentDate));
}
if (!HELPER_ApplicationStatus.compare(this._ApplicationStatus, otherSentEmail._ApplicationStatus))
{
listener.notifyFieldChange(this, other, FIELD_ApplicationStatus, HELPER_ApplicationStatus.toObject(this._ApplicationStatus), HELPER_ApplicationStatus.toObject(otherSentEmail._ApplicationStatus));
}
if (!HELPER_MessageContent.compare(this._MessageContent, otherSentEmail._MessageContent))
{
listener.notifyFieldChange(this, other, FIELD_MessageContent, HELPER_MessageContent.toObject(this._MessageContent), HELPER_MessageContent.toObject(otherSentEmail._MessageContent));
}
if (!HELPER_EmailTo.compare(this._EmailTo, otherSentEmail._EmailTo))
{
listener.notifyFieldChange(this, other, FIELD_EmailTo, HELPER_EmailTo.toObject(this._EmailTo), HELPER_EmailTo.toObject(otherSentEmail._EmailTo));
}
// Compare single assocs
_JobApplication.compare (otherSentEmail._JobApplication, 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_Subject, HELPER_Subject.toObject(getSubject()));
visitor.visitField(this, FIELD_SentDate, HELPER_SentDate.toObject(getSentDate()));
visitor.visitField(this, FIELD_ApplicationStatus, HELPER_ApplicationStatus.toObject(getApplicationStatus()));
visitor.visitField(this, FIELD_MessageContent, HELPER_MessageContent.toObject(getMessageContent()));
visitor.visitField(this, FIELD_EmailTo, HELPER_EmailTo.toObject(getEmailTo()));
visitor.visitAssociation (_JobApplication);
}
public void visitAssociations (AssociationVisitor visitor, AssociatedScope scope) throws StorageException
{
super.visitAssociations (visitor, scope);
if (scope.includes (_JobApplication))
{
visitor.visit (_JobApplication);
}
}
public static SentEmail createSentEmail (ObjectTransaction transaction) throws StorageException
{
SentEmail result = new SentEmail ();
result.initialiseNewObject (transaction);
return result;
}
public static SentEmail getSentEmailByID (ObjectTransaction transaction, Long objectID) throws StorageException
{
return (SentEmail)(transaction.getObjectByID (REFERENCE_SentEmail, objectID));
}
public boolean testFilter (String attribName, QueryFilter filter) throws StorageException
{
if (false)
{
throw new RuntimeException ("Game over man!!");
}
else if (attribName.equals (FIELD_Subject))
{
return filter.matches (getSubject ());
}
else if (attribName.equals (FIELD_SentDate))
{
return filter.matches (getSentDate ());
}
else if (attribName.equals (FIELD_ApplicationStatus))
{
return filter.matches (getApplicationStatus ());
}
else if (attribName.equals (FIELD_MessageContent))
{
return filter.matches (getMessageContent ());
}
else if (attribName.equals (FIELD_EmailTo))
{
return filter.matches (getEmailTo ());
}
else if (attribName.equals (SINGLEREFERENCE_JobApplication))
{
return filter.matches (getJobApplication ());
}
else
{
return super.testFilter (attribName, filter);
}
}
public static SearchAll SearchByAll () { return new SearchAll (); }
public static class SearchAll extends SearchObject<SentEmail>
{
public SearchAll andObjectID (QueryFilter<Long> filter)
{
filter.addFilter (context, "tl_sent_email.object_id", FIELD_ObjectID);
return this;
}
public SearchAll andObjectCreated (QueryFilter<Date> filter)
{
filter.addFilter (context, "tl_sent_email.object_created_date", FIELD_ObjectCreated);
return this;
}
public SearchAll andObjectLastModified (QueryFilter<Date> filter)
{
filter.addFilter (context, "tl_sent_email.object_last_updated_date", FIELD_ObjectLastModified);
return this;
}
public SearchAll andSubject (QueryFilter<String> filter)
{
filter.addFilter (context, "tl_sent_email.subject", "Subject");
return this;
}
public SearchAll andSentDate (QueryFilter<Date> filter)
{
filter.addFilter (context, "tl_sent_email.sent_date", "SentDate");
return this;
}
public SearchAll andApplicationStatus (QueryFilter<ApplicationStatus> filter)
{
filter.addFilter (context, "tl_sent_email.application_status", "ApplicationStatus");
return this;
}
public SearchAll andMessageContent (QueryFilter<String> filter)
{
filter.addFilter (context, "tl_sent_email.message_content", "MessageContent");
return this;
}
public SearchAll andEmailTo (QueryFilter<String> filter)
{
filter.addFilter (context, "tl_sent_email.email_to", "EmailTo");
return this;
}
public SearchAll andJobApplication (QueryFilter<JobApplication> filter)
{
filter.addFilter (context, "tl_sent_email.job_application_id", "JobApplication");
return this;
}
public SentEmail[]
search (ObjectTransaction transaction) throws StorageException
{
BaseBusinessClass[] results = super.search (transaction, REFERENCE_SentEmail, SEARCH_All, criteria);
Set<SentEmail> typedResults = new LinkedHashSet <SentEmail> ();
for (BaseBusinessClass bbcResult : results)
{
SentEmail aResult = (SentEmail)bbcResult;
typedResults.add (aResult);
}
return ObjstoreUtils.removeDeleted(transaction, typedResults).toArray (new SentEmail[0]);
}
}
public static SentEmail[]
searchAll (ObjectTransaction transaction) throws StorageException
{
return SearchByAll ()
.search (transaction);
}
public Object getAttribute (String attribName)
{
if (false)
{
throw new RuntimeException ("Game over man!!");
}
else if (attribName.equals (FIELD_Subject))
{
return HELPER_Subject.toObject (getSubject ());
}
else if (attribName.equals (FIELD_SentDate))
{
return HELPER_SentDate.toObject (getSentDate ());
}
else if (attribName.equals (FIELD_ApplicationStatus))
{
return HELPER_ApplicationStatus.toObject (getApplicationStatus ());
}
else if (attribName.equals (FIELD_MessageContent))
{
return HELPER_MessageContent.toObject (getMessageContent ());
}
else if (attribName.equals (FIELD_EmailTo))
{
return HELPER_EmailTo.toObject (getEmailTo ());
}
else
{
return super.getAttribute (attribName);
}
}
public AttributeHelper getAttributeHelper (String attribName)
{
if (false)
{
throw new RuntimeException ("Game over man!!");
}
else if (attribName.equals (FIELD_Subject))
{
return HELPER_Subject;
}
else if (attribName.equals (FIELD_SentDate))
{
return HELPER_SentDate;
}
else if (attribName.equals (FIELD_ApplicationStatus))
{
return HELPER_ApplicationStatus;
}
else if (attribName.equals (FIELD_MessageContent))
{
return HELPER_MessageContent;
}
else if (attribName.equals (FIELD_EmailTo))
{
return HELPER_EmailTo;
}
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_Subject))
{
setSubject ((String)(HELPER_Subject.fromObject (_Subject, attribValue)));
}
else if (attribName.equals (FIELD_SentDate))
{
setSentDate ((Date)(HELPER_SentDate.fromObject (_SentDate, attribValue)));
}
else if (attribName.equals (FIELD_ApplicationStatus))
{
setApplicationStatus ((ApplicationStatus)(HELPER_ApplicationStatus.fromObject (_ApplicationStatus, attribValue)));
}
else if (attribName.equals (FIELD_MessageContent))
{
setMessageContent ((String)(HELPER_MessageContent.fromObject (_MessageContent, attribValue)));
}
else if (attribName.equals (FIELD_EmailTo))
{
setEmailTo ((String)(HELPER_EmailTo.fromObject (_EmailTo, 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_Subject))
{
return getWriteability_Subject ();
}
else if (fieldName.equals (FIELD_SentDate))
{
return getWriteability_SentDate ();
}
else if (fieldName.equals (FIELD_ApplicationStatus))
{
return getWriteability_ApplicationStatus ();
}
else if (fieldName.equals (FIELD_MessageContent))
{
return getWriteability_MessageContent ();
}
else if (fieldName.equals (FIELD_EmailTo))
{
return getWriteability_EmailTo ();
}
else if (fieldName.equals (SINGLEREFERENCE_JobApplication))
{
return getWriteability_JobApplication ();
}
else
{
return super.getWriteable (fieldName);
}
}
public void putUnwriteable (Set<String> fields)
{
if (getWriteability_Subject () != FieldWriteability.TRUE)
{
fields.add (FIELD_Subject);
}
if (getWriteability_SentDate () != FieldWriteability.TRUE)
{
fields.add (FIELD_SentDate);
}
if (getWriteability_ApplicationStatus () != FieldWriteability.TRUE)
{
fields.add (FIELD_ApplicationStatus);
}
if (getWriteability_MessageContent () != FieldWriteability.TRUE)
{
fields.add (FIELD_MessageContent);
}
if (getWriteability_EmailTo () != FieldWriteability.TRUE)
{
fields.add (FIELD_EmailTo);
}
super.putUnwriteable (fields);
}
public List<AbstractAttribute> getAttributes ()
{
List result = super.getAttributes ();
result.add(HELPER_Subject.getAttribObject (getClass (), _Subject, true, FIELD_Subject));
result.add(HELPER_SentDate.getAttribObject (getClass (), _SentDate, true, FIELD_SentDate));
result.add(HELPER_ApplicationStatus.getAttribObject (getClass (), _ApplicationStatus, true, FIELD_ApplicationStatus));
result.add(HELPER_MessageContent.getAttribObject (getClass (), _MessageContent, true, FIELD_MessageContent));
result.add(HELPER_EmailTo.getAttribObject (getClass (), _EmailTo, true, FIELD_EmailTo));
return result;
}
public Map getAttributeMetadata (String attribute)
{
if (ATTRIBUTES_METADATA_SentEmail.containsKey (attribute))
{
return (Map)ATTRIBUTES_METADATA_SentEmail.get (attribute);
}
else
{
return super.getAttributeMetadata (attribute);
}
}
public Object getAttributeMetadata (String attribute, String metadata)
{
if (ATTRIBUTES_METADATA_SentEmail.containsKey (attribute))
{
return ((Map)ATTRIBUTES_METADATA_SentEmail.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 SentEmailBehaviourDecorator extends BaseBusinessClass.BBCBehaviourDecorator<SentEmail>
{
/**
* Get the attribute Subject
*/
public String getSubject (SentEmail obj, String original)
{
return original;
}
/**
* Change the value set for attribute Subject.
* May modify the field beforehand
* Occurs before validation.
*/
public String setSubject (SentEmail obj, String newSubject) throws FieldException
{
return newSubject;
}
/**
* Get the attribute SentDate
*/
public Date getSentDate (SentEmail obj, Date original)
{
return original;
}
/**
* Change the value set for attribute SentDate.
* May modify the field beforehand
* Occurs before validation.
*/
public Date setSentDate (SentEmail obj, Date newSentDate) throws FieldException
{
return newSentDate;
}
/**
* Get the attribute ApplicationStatus
*/
public ApplicationStatus getApplicationStatus (SentEmail obj, ApplicationStatus original)
{
return original;
}
/**
* Change the value set for attribute ApplicationStatus.
* May modify the field beforehand
* Occurs before validation.
*/
public ApplicationStatus setApplicationStatus (SentEmail obj, ApplicationStatus newApplicationStatus) throws FieldException
{
return newApplicationStatus;
}
/**
* Get the attribute MessageContent
*/
public String getMessageContent (SentEmail obj, String original)
{
return original;
}
/**
* Change the value set for attribute MessageContent.
* May modify the field beforehand
* Occurs before validation.
*/
public String setMessageContent (SentEmail obj, String newMessageContent) throws FieldException
{
return newMessageContent;
}
/**
* Get the attribute EmailTo
*/
public String getEmailTo (SentEmail obj, String original)
{
return original;
}
/**
* Change the value set for attribute EmailTo.
* May modify the field beforehand
* Occurs before validation.
*/
public String setEmailTo (SentEmail obj, String newEmailTo) throws FieldException
{
return newEmailTo;
}
}
public ORMPipeLine pipes()
{
return new SentEmailPipeLineFactory<SentEmail, SentEmail> ((SentEmail)this);
}
/**
* Use this instead of pipes() to get rid of type casting.
*/
public SentEmailPipeLineFactory<SentEmail, SentEmail> pipelineSentEmail()
{
return (SentEmailPipeLineFactory<SentEmail, SentEmail>) pipes();
}
public static SentEmailPipeLineFactory<SentEmail, SentEmail> pipesSentEmail(Collection<SentEmail> items)
{
return REFERENCE_SentEmail.new SentEmailPipeLineFactory<SentEmail, SentEmail> (items);
}
public static SentEmailPipeLineFactory<SentEmail, SentEmail> pipesSentEmail(SentEmail[] _items)
{
return pipesSentEmail(Arrays.asList (_items));
}
public static SentEmailPipeLineFactory<SentEmail, SentEmail> pipesSentEmail()
{
return pipesSentEmail((Collection)null);
}
public class SentEmailPipeLineFactory<From extends BaseBusinessClass, Me extends SentEmail> extends BaseBusinessClass.ORMPipeLine<From, Me>
{
public <Prev> SentEmailPipeLineFactory (PipeLine<From, Prev> pipeLine, Pipe<Prev, Me> nextPipe)
{
super (pipeLine, nextPipe);
}
public SentEmailPipeLineFactory (From seed)
{
super(seed);
}
public SentEmailPipeLineFactory (Collection<From> seed)
{
super(seed);
}
public PipeLine<From, ? extends Object> to(String name)
{
if (name.equals ("Subject"))
{
return toSubject ();
}
if (name.equals ("SentDate"))
{
return toSentDate ();
}
if (name.equals ("ApplicationStatus"))
{
return toApplicationStatus ();
}
if (name.equals ("MessageContent"))
{
return toMessageContent ();
}
if (name.equals ("EmailTo"))
{
return toEmailTo ();
}
if (name.equals ("JobApplication"))
{
return toJobApplication ();
}
return super.to(name);
}
public PipeLine<From, String> toSubject () { return pipe(new ORMAttributePipe<Me, String>(FIELD_Subject)); }
public PipeLine<From, Date> toSentDate () { return pipe(new ORMAttributePipe<Me, Date>(FIELD_SentDate)); }
public PipeLine<From, ApplicationStatus> toApplicationStatus () { return pipe(new ORMAttributePipe<Me, ApplicationStatus>(FIELD_ApplicationStatus)); }
public PipeLine<From, String> toMessageContent () { return pipe(new ORMAttributePipe<Me, String>(FIELD_MessageContent)); }
public PipeLine<From, String> toEmailTo () { return pipe(new ORMAttributePipe<Me, String>(FIELD_EmailTo)); }
public JobApplication.JobApplicationPipeLineFactory<From, JobApplication> toJobApplication () { return toJobApplication (Filter.ALL); }
public JobApplication.JobApplicationPipeLineFactory<From, JobApplication> toJobApplication (Filter<JobApplication> filter)
{
return JobApplication.REFERENCE_JobApplication.new JobApplicationPipeLineFactory<From, JobApplication> (this, new ORMSingleAssocPipe<Me, JobApplication>(SINGLEREFERENCE_JobApplication, filter));
}
}
public boolean isTransientAttrib(String attribName)
{
return super.isTransientAttrib(attribName);
}
public boolean isTransientSingleReference(String assocName)
{
return super.isTransientSingleReference(assocName);
}
}
class DummySentEmail extends SentEmail
{
// Default constructor primarily to support Externalisable
public DummySentEmail()
{
super();
}
public void assertValid ()
{
}
public JobApplication getJobApplication () throws StorageException
{
return (JobApplication)(JobApplication.DUMMY_JobApplication);
}
/**
* Get the object id for the referenced object. Does not force a DB access.
*/
public Long getJobApplicationID ()
{
return JobApplication.DUMMY_JobApplication.getObjectID();
}
}
package performa.orm;
import java.util.HashSet;
import java.util.Set;
import oneit.logging.LoggingArea;
import oneit.objstore.rdbms.filters.EqualsFilter;
import oneit.objstore.rdbms.filters.IsNotNullFilter;
import oneit.objstore.rdbms.filters.NotEqualsFilter;
import oneit.security.SecUser;
import oneit.utils.BusinessException;
import oneit.utils.CollectionUtils;
import oneit.utils.StringUtils;
import oneit.utils.filter.Filter;
import oneit.utils.math.NullArith;
import oneit.utils.parsers.FieldException;
import performa.orm.types.JobStatus;
import performa.orm.types.TimeZone;
import performa.utils.Utils;
......@@ -178,4 +175,9 @@ public class Company extends BaseCompany
return pipelineCompany().toHiringTeams(filter).uniqueVals();
}
public TimeZone getDefaultTimeZone()
{
return pipelineCompany().toHiringTeams().toTimeZone().val();
}
}
\ No newline at end of file
......@@ -17,6 +17,7 @@ import oneit.utils.math.Rounding;
import oneit.utils.parsers.FieldException;
import performa.chart.RingChart;
import performa.orm.types.*;
import performa.orm.types.TimeZone;
import performa.utils.*;
......@@ -31,6 +32,57 @@ public class JobApplication extends BaseJobApplication
// Do not add any code to this, always put it in initialiseNewObject
}
@Override
public void preCommit(boolean willBeStored) throws Exception
{
super.preCommit(willBeStored);
if(willBeStored)
{
JobApplication old = (JobApplication) getEarliestBackup();
// when application status changed
if(!CollectionUtils.equals(old.getApplicationStatus(), getApplicationStatus()))
{
// delete previously scheduled emails for previous application status
Filter<ScheduledEmail> filter = ScheduledEmail.SearchByAll().andApplicationStatus(new EqualsFilter<>(old.getApplicationStatus()));
pipelineJobApplication().toScheduledEmails(filter).uniqueVals().stream().forEach((scheduledEmail) -> {
scheduledEmail.delete();
});
// create scheduled emails for new application status
MessageTemplate[] templates = MessageTemplate.SearchByAll().andApplicationStatus(new EqualsFilter<>(getApplicationStatus())).search(getTransaction());
for(MessageTemplate template : templates)
{
ScheduledEmail scheduledEmail = ScheduledEmail.createScheduledEmail(getTransaction());
Date now = new Date();
int variance = MessagingUtils.randInt(0, template.getVariance());
Date scheduledDate = DateDiff.add(now, Calendar.MINUTE, template.getDelayInMin() + variance);
if(template.getBusinessHoursOnly())
{
TimeZone jobTimeZone = getJob().getHiringTeam().getCompany().getDefaultTimeZone();
Calendar cal = new GregorianCalendar();
cal.setTime(now);
scheduledDate = MessagingUtils.getWithinBusinessHours(cal, jobTimeZone != null ? java.util.TimeZone.getTimeZone(jobTimeZone.getTimeZoneCode()) : cal.getTimeZone());
}
scheduledEmail.setScheduledDate(scheduledDate);
scheduledEmail.setSubject(template.getSubject());
scheduledEmail.setMessageContent(template.getMessageContent());
scheduledEmail.setApplicationStatus(getApplicationStatus());
scheduledEmail.setMessageTemplate(template);
addToScheduledEmails(scheduledEmail);
}
}
}
}
public static JobApplication createNewApplication(Candidate candidate, Job job) throws StorageException, FieldException
{
......
......@@ -3,10 +3,13 @@
<ROOT xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:noNamespaceSchemaLocation='http://www.oneit.com.au/schemas/5.2/BusinessObject.xsd'>
<BUSINESSCLASS name="JobApplication" package="performa.orm">
<IMPORT value="performa.orm.types.*"/>
<MULTIPLEREFERENCE name="AssessmentCriteriaAnswers" type="AssessmentCriteriaAnswer" backreferenceName="JobApplication" />
<MULTIPLEREFERENCE name="Notes" type="Note" backreferenceName="JobApplication" />
<MULTIPLEREFERENCE name="ScheduledEmails" type="ScheduledEmail" backreferenceName="JobApplication" />
<MULTIPLEREFERENCE name="SentEmails" type="SentEmail" backreferenceName="JobApplication" />
<TRANSIENT name="AppProcessOption" type="AppProcessOption" attribHelper="EnumeratedAttributeHelper"/>
<TRANSIENT name="OverallRank" type="Integer" />
......
package performa.orm;
import java.io.*;
import java.util.*;
import oneit.appservices.config.*;
import oneit.logging.*;
import oneit.objstore.*;
import oneit.utils.*;
import performa.orm.types.*;
import performa.orm.*;
public class MessageTemplate extends BaseMessageTemplate
{
......@@ -25,5 +10,9 @@ public class MessageTemplate extends BaseMessageTemplate
{
// Do not add any code to this, always put it in initialiseNewObject
}
}
public int getDelayInMin()
{
return (getDelayHrs() * 60) + getDelayMin();
}
}
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<ROOT>
<BUSINESSCLASS name="MessageTemplate" package="performa.orm">
<IMPORT value="performa.orm.types.*"/>
<IMPORT value="performa.orm.*"/>
<TABLE name="tl_message_template" tablePrefix="object" polymorphic="FALSE">
<ATTRIB name="Subject" type="String" dbcol="subject" mandatory="false" length="200" />
<ATTRIB name="ApplicationStatus" type="ApplicationStatus" dbcol="application_status" attribHelper="EnumeratedAttributeHelper" defaultValue="ApplicationStatus.DRAFT" mandatory="false"/>
<ATTRIB name="Delay" type="Double" dbcol="delay" mandatory="false" />
<ATTRIB name="Variance" type="Integer" dbcol="variance" mandatory="false" />
<ATTRIB name="BusinessHoursOnly" type="Boolean" dbcol="business_hours_only" mandatory="false" />
<ATTRIB name="MessageContent" type="String" dbcol="message_content" mandatory="false" />
<ATTRIB name="Subject" type="String" dbcol="subject" mandatory="true" length="200" />
<ATTRIB name="ApplicationStatus" type="ApplicationStatus" dbcol="application_status" mandatory="true" defaultValue="ApplicationStatus.DRAFT" attribHelper="EnumeratedAttributeHelper" />
<ATTRIB name="DelayHrs" type="Integer" dbcol="delay_hrs" mandatory="false" defaultValue="0" />
<ATTRIB name="DelayMin" type="Integer" dbcol="delay_min" mandatory="false" defaultValue="0" />
<ATTRIB name="Variance" type="Integer" dbcol="variance" mandatory="false" defaultValue="0" />
<ATTRIB name="BusinessHoursOnly" type="Boolean" dbcol="business_hours_only" mandatory="false" defaultValue="Boolean.FALSE"/>
<ATTRIB name="MessageContent" type="String" dbcol="message_content" mandatory="true" />
</TABLE>
......
......@@ -30,7 +30,8 @@ public class MessageTemplatePersistenceMgr extends ObjectPersistenceMgr
// Private attributes corresponding to business object data
private String dummySubject;
private ApplicationStatus dummyApplicationStatus;
private Double dummyDelay;
private Integer dummyDelayHrs;
private Integer dummyDelayMin;
private Integer dummyVariance;
private Boolean dummyBusinessHoursOnly;
private String dummyMessageContent;
......@@ -39,7 +40,8 @@ public class MessageTemplatePersistenceMgr extends ObjectPersistenceMgr
// Static constants corresponding to attribute helpers
private static final DefaultAttributeHelper HELPER_Subject = DefaultAttributeHelper.INSTANCE;
private static final EnumeratedAttributeHelper HELPER_ApplicationStatus = new EnumeratedAttributeHelper (ApplicationStatus.FACTORY_ApplicationStatus);
private static final DefaultAttributeHelper HELPER_Delay = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper HELPER_DelayHrs = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper HELPER_DelayMin = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper HELPER_Variance = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper HELPER_BusinessHoursOnly = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper HELPER_MessageContent = DefaultAttributeHelper.INSTANCE;
......@@ -51,14 +53,15 @@ public class MessageTemplatePersistenceMgr extends ObjectPersistenceMgr
{
dummySubject = (String)(HELPER_Subject.initialise (dummySubject));
dummyApplicationStatus = (ApplicationStatus)(HELPER_ApplicationStatus.initialise (dummyApplicationStatus));
dummyDelay = (Double)(HELPER_Delay.initialise (dummyDelay));
dummyDelayHrs = (Integer)(HELPER_DelayHrs.initialise (dummyDelayHrs));
dummyDelayMin = (Integer)(HELPER_DelayMin.initialise (dummyDelayMin));
dummyVariance = (Integer)(HELPER_Variance.initialise (dummyVariance));
dummyBusinessHoursOnly = (Boolean)(HELPER_BusinessHoursOnly.initialise (dummyBusinessHoursOnly));
dummyMessageContent = (String)(HELPER_MessageContent.initialise (dummyMessageContent));
}
private String SELECT_COLUMNS = "{PREFIX}tl_message_template.object_id as id, {PREFIX}tl_message_template.object_LAST_UPDATED_DATE as LAST_UPDATED_DATE, {PREFIX}tl_message_template.object_CREATED_DATE as CREATED_DATE, {PREFIX}tl_message_template.subject, {PREFIX}tl_message_template.application_status, {PREFIX}tl_message_template.delay, {PREFIX}tl_message_template.variance, {PREFIX}tl_message_template.business_hours_only, {PREFIX}tl_message_template.message_content, 1 AS commasafe ";
private String SELECT_COLUMNS = "{PREFIX}tl_message_template.object_id as id, {PREFIX}tl_message_template.object_LAST_UPDATED_DATE as LAST_UPDATED_DATE, {PREFIX}tl_message_template.object_CREATED_DATE as CREATED_DATE, {PREFIX}tl_message_template.subject, {PREFIX}tl_message_template.application_status, {PREFIX}tl_message_template.delay_hrs, {PREFIX}tl_message_template.delay_min, {PREFIX}tl_message_template.variance, {PREFIX}tl_message_template.business_hours_only, {PREFIX}tl_message_template.message_content, 1 AS commasafe ";
private String SELECT_JOINS = "";
public BaseBusinessClass fetchByID(ObjectID id, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException
......@@ -111,7 +114,8 @@ public class MessageTemplatePersistenceMgr extends ObjectPersistenceMgr
if (false || !tl_message_templatePSet.containsAttrib(BaseBusinessClass.FIELD_ObjectLastModified) ||
!tl_message_templatePSet.containsAttrib(MessageTemplate.FIELD_Subject)||
!tl_message_templatePSet.containsAttrib(MessageTemplate.FIELD_ApplicationStatus)||
!tl_message_templatePSet.containsAttrib(MessageTemplate.FIELD_Delay)||
!tl_message_templatePSet.containsAttrib(MessageTemplate.FIELD_DelayHrs)||
!tl_message_templatePSet.containsAttrib(MessageTemplate.FIELD_DelayMin)||
!tl_message_templatePSet.containsAttrib(MessageTemplate.FIELD_Variance)||
!tl_message_templatePSet.containsAttrib(MessageTemplate.FIELD_BusinessHoursOnly)||
!tl_message_templatePSet.containsAttrib(MessageTemplate.FIELD_MessageContent))
......@@ -184,10 +188,10 @@ public class MessageTemplatePersistenceMgr extends ObjectPersistenceMgr
{
int rowsUpdated = executeStatement (sqlMgr,
"UPDATE {PREFIX}tl_message_template " +
"SET subject = ?, application_status = ?, delay = ?, variance = ?, business_hours_only = ?, message_content = ? , object_LAST_UPDATED_DATE = " + sqlMgr.getPortabilityServices ().getTimestampExpression () + " " +
"SET subject = ?, application_status = ?, delay_hrs = ?, delay_min = ?, variance = ?, business_hours_only = ?, message_content = ? , object_LAST_UPDATED_DATE = " + sqlMgr.getPortabilityServices ().getTimestampExpression () + " " +
"WHERE tl_message_template.object_id = ? AND " + getConcurrencyCheck (sqlMgr, "object_LAST_UPDATED_DATE", obj.getObjectLastModified ()) + " ",
CollectionUtils.listEntry (HELPER_Subject.getForSQL(dummySubject, tl_message_templatePSet.getAttrib (MessageTemplate.FIELD_Subject))).listEntry (HELPER_ApplicationStatus.getForSQL(dummyApplicationStatus, tl_message_templatePSet.getAttrib (MessageTemplate.FIELD_ApplicationStatus))).listEntry (HELPER_Delay.getForSQL(dummyDelay, tl_message_templatePSet.getAttrib (MessageTemplate.FIELD_Delay))).listEntry (HELPER_Variance.getForSQL(dummyVariance, tl_message_templatePSet.getAttrib (MessageTemplate.FIELD_Variance))).listEntry (HELPER_BusinessHoursOnly.getForSQL(dummyBusinessHoursOnly, tl_message_templatePSet.getAttrib (MessageTemplate.FIELD_BusinessHoursOnly))).listEntry (HELPER_MessageContent.getForSQL(dummyMessageContent, tl_message_templatePSet.getAttrib (MessageTemplate.FIELD_MessageContent))).listEntry (objectID.longID ()).listEntry (obj.getObjectLastModified ()).toList().toArray());
CollectionUtils.listEntry (HELPER_Subject.getForSQL(dummySubject, tl_message_templatePSet.getAttrib (MessageTemplate.FIELD_Subject))).listEntry (HELPER_ApplicationStatus.getForSQL(dummyApplicationStatus, tl_message_templatePSet.getAttrib (MessageTemplate.FIELD_ApplicationStatus))).listEntry (HELPER_DelayHrs.getForSQL(dummyDelayHrs, tl_message_templatePSet.getAttrib (MessageTemplate.FIELD_DelayHrs))).listEntry (HELPER_DelayMin.getForSQL(dummyDelayMin, tl_message_templatePSet.getAttrib (MessageTemplate.FIELD_DelayMin))).listEntry (HELPER_Variance.getForSQL(dummyVariance, tl_message_templatePSet.getAttrib (MessageTemplate.FIELD_Variance))).listEntry (HELPER_BusinessHoursOnly.getForSQL(dummyBusinessHoursOnly, tl_message_templatePSet.getAttrib (MessageTemplate.FIELD_BusinessHoursOnly))).listEntry (HELPER_MessageContent.getForSQL(dummyMessageContent, tl_message_templatePSet.getAttrib (MessageTemplate.FIELD_MessageContent))).listEntry (objectID.longID ()).listEntry (obj.getObjectLastModified ()).toList().toArray());
if (rowsUpdated != 1)
{
......@@ -445,7 +449,8 @@ public class MessageTemplatePersistenceMgr extends ObjectPersistenceMgr
tl_message_templatePSet.setAttrib(MessageTemplate.FIELD_Subject, HELPER_Subject.getFromRS(dummySubject, r, "subject"));
tl_message_templatePSet.setAttrib(MessageTemplate.FIELD_ApplicationStatus, HELPER_ApplicationStatus.getFromRS(dummyApplicationStatus, r, "application_status"));
tl_message_templatePSet.setAttrib(MessageTemplate.FIELD_Delay, HELPER_Delay.getFromRS(dummyDelay, r, "delay"));
tl_message_templatePSet.setAttrib(MessageTemplate.FIELD_DelayHrs, HELPER_DelayHrs.getFromRS(dummyDelayHrs, r, "delay_hrs"));
tl_message_templatePSet.setAttrib(MessageTemplate.FIELD_DelayMin, HELPER_DelayMin.getFromRS(dummyDelayMin, r, "delay_min"));
tl_message_templatePSet.setAttrib(MessageTemplate.FIELD_Variance, HELPER_Variance.getFromRS(dummyVariance, r, "variance"));
tl_message_templatePSet.setAttrib(MessageTemplate.FIELD_BusinessHoursOnly, HELPER_BusinessHoursOnly.getFromRS(dummyBusinessHoursOnly, r, "business_hours_only"));
tl_message_templatePSet.setAttrib(MessageTemplate.FIELD_MessageContent, HELPER_MessageContent.getFromRS(dummyMessageContent, r, "message_content"));
......@@ -466,10 +471,10 @@ public class MessageTemplatePersistenceMgr extends ObjectPersistenceMgr
{
executeStatement (sqlMgr,
"INSERT INTO {PREFIX}tl_message_template " +
" (subject, application_status, delay, variance, business_hours_only, message_content, object_id, object_LAST_UPDATED_DATE, object_CREATED_DATE) " +
" (subject, application_status, delay_hrs, delay_min, variance, business_hours_only, message_content, object_id, object_LAST_UPDATED_DATE, object_CREATED_DATE) " +
"VALUES " +
" (?, ?, ?, ?, ?, ?, ?, " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ", " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ")",
CollectionUtils.listEntry (HELPER_Subject.getForSQL(dummySubject, tl_message_templatePSet.getAttrib (MessageTemplate.FIELD_Subject))).listEntry (HELPER_ApplicationStatus.getForSQL(dummyApplicationStatus, tl_message_templatePSet.getAttrib (MessageTemplate.FIELD_ApplicationStatus))).listEntry (HELPER_Delay.getForSQL(dummyDelay, tl_message_templatePSet.getAttrib (MessageTemplate.FIELD_Delay))).listEntry (HELPER_Variance.getForSQL(dummyVariance, tl_message_templatePSet.getAttrib (MessageTemplate.FIELD_Variance))).listEntry (HELPER_BusinessHoursOnly.getForSQL(dummyBusinessHoursOnly, tl_message_templatePSet.getAttrib (MessageTemplate.FIELD_BusinessHoursOnly))).listEntry (HELPER_MessageContent.getForSQL(dummyMessageContent, tl_message_templatePSet.getAttrib (MessageTemplate.FIELD_MessageContent))) .listEntry (objectID.longID ()).toList().toArray());
" (?, ?, ?, ?, ?, ?, ?, ?, " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ", " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ")",
CollectionUtils.listEntry (HELPER_Subject.getForSQL(dummySubject, tl_message_templatePSet.getAttrib (MessageTemplate.FIELD_Subject))).listEntry (HELPER_ApplicationStatus.getForSQL(dummyApplicationStatus, tl_message_templatePSet.getAttrib (MessageTemplate.FIELD_ApplicationStatus))).listEntry (HELPER_DelayHrs.getForSQL(dummyDelayHrs, tl_message_templatePSet.getAttrib (MessageTemplate.FIELD_DelayHrs))).listEntry (HELPER_DelayMin.getForSQL(dummyDelayMin, tl_message_templatePSet.getAttrib (MessageTemplate.FIELD_DelayMin))).listEntry (HELPER_Variance.getForSQL(dummyVariance, tl_message_templatePSet.getAttrib (MessageTemplate.FIELD_Variance))).listEntry (HELPER_BusinessHoursOnly.getForSQL(dummyBusinessHoursOnly, tl_message_templatePSet.getAttrib (MessageTemplate.FIELD_BusinessHoursOnly))).listEntry (HELPER_MessageContent.getForSQL(dummyMessageContent, tl_message_templatePSet.getAttrib (MessageTemplate.FIELD_MessageContent))) .listEntry (objectID.longID ()).toList().toArray());
tl_message_templatePSet.setStatus (PersistentSetStatus.PROCESSED);
}
......
package performa.orm;
public class ScheduledEmail extends BaseScheduledEmail
{
private static final long serialVersionUID = 0L;
// This constructor should not be called
public ScheduledEmail ()
{
// Do not add any code to this, always put it in initialiseNewObject
}
}
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<ROOT xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:noNamespaceSchemaLocation='http://www.oneit.com.au/schemas/5.2/BusinessObject.xsd'>
<BUSINESSCLASS name="ScheduledEmail" package="performa.orm">
<IMPORT value="performa.orm.types.*"/>
<TABLE name="tl_scheduled_email" tablePrefix="object">
<ATTRIB name="Subject" type="String" dbcol="subject" mandatory="true" length="200" />
<ATTRIB name="ScheduledDate" type="Date" dbcol="scheduled_date" mandatory="true" />
<ATTRIB name="ApplicationStatus" type="ApplicationStatus" dbcol="application_status" mandatory="true" attribHelper="EnumeratedAttributeHelper" />
<ATTRIB name="MessageContent" type="String" dbcol="message_content" mandatory="true" />
<SINGLEREFERENCE name="JobApplication" type="JobApplication" dbcol="job_application_id" backreferenceName="ScheduledEmails" mandatory="true"/>
<SINGLEREFERENCE name="MessageTemplate" type="MessageTemplate" dbcol="message_template_id" />
</TABLE>
<SEARCH type="All" paramFilter="tl_scheduled_email.object_id is not null" orderBy="tl_scheduled_email.object_id">
</SEARCH>
</BUSINESSCLASS>
</ROOT>
\ No newline at end of file
package performa.orm;
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 performa.orm.types.*;
/**
* IMPORTANT!!!! Autogenerated class, DO NOT EDIT!!!!!
* Template: Infrastructure8.2[oneit.objstore.PersistenceMgrTemplate.xsl]
*/
public class ScheduledEmailPersistenceMgr extends ObjectPersistenceMgr
{
private static final LoggingArea ScheduledEmailPersistence = LoggingArea.createLoggingArea(ObjectPersistenceMgr.OBJECT_PERSISTENCE, "ScheduledEmail");
// Private attributes corresponding to business object data
private String dummySubject;
private Date dummyScheduledDate;
private ApplicationStatus dummyApplicationStatus;
private String dummyMessageContent;
// Static constants corresponding to attribute helpers
private static final DefaultAttributeHelper HELPER_Subject = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper HELPER_ScheduledDate = DefaultAttributeHelper.INSTANCE;
private static final EnumeratedAttributeHelper HELPER_ApplicationStatus = new EnumeratedAttributeHelper (ApplicationStatus.FACTORY_ApplicationStatus);
private static final DefaultAttributeHelper HELPER_MessageContent = DefaultAttributeHelper.INSTANCE;
public ScheduledEmailPersistenceMgr ()
{
dummySubject = (String)(HELPER_Subject.initialise (dummySubject));
dummyScheduledDate = (Date)(HELPER_ScheduledDate.initialise (dummyScheduledDate));
dummyApplicationStatus = (ApplicationStatus)(HELPER_ApplicationStatus.initialise (dummyApplicationStatus));
dummyMessageContent = (String)(HELPER_MessageContent.initialise (dummyMessageContent));
}
private String SELECT_COLUMNS = "{PREFIX}tl_scheduled_email.object_id as id, {PREFIX}tl_scheduled_email.object_LAST_UPDATED_DATE as LAST_UPDATED_DATE, {PREFIX}tl_scheduled_email.object_CREATED_DATE as CREATED_DATE, {PREFIX}tl_scheduled_email.subject, {PREFIX}tl_scheduled_email.scheduled_date, {PREFIX}tl_scheduled_email.application_status, {PREFIX}tl_scheduled_email.message_content, {PREFIX}tl_scheduled_email.job_application_id, {PREFIX}tl_scheduled_email.message_template_id, 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, ScheduledEmail.REFERENCE_ScheduledEmail);
if (objectToReturn instanceof ScheduledEmail)
{
LogMgr.log (ScheduledEmailPersistence, 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 ScheduledEmail");
}
}
PersistentSet tl_scheduled_emailPSet = allPSets.getPersistentSet(id, "tl_scheduled_email", PersistentSetStatus.FETCHED);
// Check for persistent sets already prefetched
if (false || !tl_scheduled_emailPSet.containsAttrib(BaseBusinessClass.FIELD_ObjectLastModified) ||
!tl_scheduled_emailPSet.containsAttrib(ScheduledEmail.FIELD_Subject)||
!tl_scheduled_emailPSet.containsAttrib(ScheduledEmail.FIELD_ScheduledDate)||
!tl_scheduled_emailPSet.containsAttrib(ScheduledEmail.FIELD_ApplicationStatus)||
!tl_scheduled_emailPSet.containsAttrib(ScheduledEmail.FIELD_MessageContent)||
!tl_scheduled_emailPSet.containsAttrib(ScheduledEmail.SINGLEREFERENCE_JobApplication)||
!tl_scheduled_emailPSet.containsAttrib(ScheduledEmail.SINGLEREFERENCE_MessageTemplate))
{
// We will need to retrieve it
idsToFetch.add (id.longValue());
}
else
{
LogMgr.log (ScheduledEmailPersistence, LogLevel.DEBUG2, "Persistent set preloaded id:", id);
/* Non Polymorphic */
ScheduledEmail result = new ScheduledEmail ();
result.setFromPersistentSets(id, allPSets);
context.addRetrievedObject(result);
results.add (result);
}
}
if (idsToFetch.size () > 0)
{
String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}tl_scheduled_email " +
"WHERE " + SELECT_JOINS + "{PREFIX}tl_scheduled_email.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 if (refName.equals (ScheduledEmail.SINGLEREFERENCE_JobApplication))
{
String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}tl_scheduled_email " +
"WHERE " + SELECT_JOINS + "job_application_id = ?";
BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, new Object[] { _objectID.longID () }, null, false);
return results;
}
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 tl_scheduled_emailPSet = allPSets.getPersistentSet(objectID, "tl_scheduled_email");
if (tl_scheduled_emailPSet.getStatus () != PersistentSetStatus.PROCESSED &&
tl_scheduled_emailPSet.getStatus () != PersistentSetStatus.DEFERRED)
{
int rowsUpdated = executeStatement (sqlMgr,
"UPDATE {PREFIX}tl_scheduled_email " +
"SET subject = ?, scheduled_date = ?, application_status = ?, message_content = ?, job_application_id = ? , message_template_id = ? , object_LAST_UPDATED_DATE = " + sqlMgr.getPortabilityServices ().getTimestampExpression () + " " +
"WHERE tl_scheduled_email.object_id = ? AND " + getConcurrencyCheck (sqlMgr, "object_LAST_UPDATED_DATE", obj.getObjectLastModified ()) + " ",
CollectionUtils.listEntry (HELPER_Subject.getForSQL(dummySubject, tl_scheduled_emailPSet.getAttrib (ScheduledEmail.FIELD_Subject))).listEntry (HELPER_ScheduledDate.getForSQL(dummyScheduledDate, tl_scheduled_emailPSet.getAttrib (ScheduledEmail.FIELD_ScheduledDate))).listEntry (HELPER_ApplicationStatus.getForSQL(dummyApplicationStatus, tl_scheduled_emailPSet.getAttrib (ScheduledEmail.FIELD_ApplicationStatus))).listEntry (HELPER_MessageContent.getForSQL(dummyMessageContent, tl_scheduled_emailPSet.getAttrib (ScheduledEmail.FIELD_MessageContent))).listEntry (SQLManager.CheckNull((Long)(tl_scheduled_emailPSet.getAttrib (ScheduledEmail.SINGLEREFERENCE_JobApplication)))).listEntry (SQLManager.CheckNull((Long)(tl_scheduled_emailPSet.getAttrib (ScheduledEmail.SINGLEREFERENCE_MessageTemplate)))).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}tl_scheduled_email 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[] { "tl_scheduled_email", objectID.longID (), obj.getObjectLastModified (), d },
sqlMgr.getPortabilityServices ());
LogMgr.log (ScheduledEmailPersistence, LogLevel.BUSINESS1, errorMsg);
throw new ConcurrentUpdateConflictException (obj, "tl_scheduled_email");
}
else
{
String errorMsg = "Attempt to update nonexistent row in table:tl_scheduled_email for row:" + objectID + " objDate:" + obj.getObjectLastModified ();
LogMgr.log (ScheduledEmailPersistence, LogLevel.BUSINESS1, errorMsg);
throw new RuntimeException (errorMsg);
}
}
tl_scheduled_emailPSet.setStatus (PersistentSetStatus.PROCESSED);
}
}
else
{
LogMgr.log (ScheduledEmailPersistence, 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 tl_scheduled_emailPSet = allPSets.getPersistentSet(objectID, "tl_scheduled_email");
LogMgr.log (ScheduledEmailPersistence, LogLevel.DEBUG2, "Deleting:", objectID);
if (tl_scheduled_emailPSet.getStatus () != PersistentSetStatus.PROCESSED &&
tl_scheduled_emailPSet.getStatus () != PersistentSetStatus.DEFERRED)
{
int rowsDeleted = executeStatement (sqlMgr,
"DELETE " +
"FROM {PREFIX}tl_scheduled_email " +
"WHERE tl_scheduled_email.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}tl_scheduled_email WHERE object_id = ?",
new Object[] { objectID.longID() });
if (r.next ())
{
throw new ConcurrentUpdateConflictException (obj, "tl_scheduled_email");
}
else
{
String errorMsg = "Attempt to delete nonexistent row in table:tl_scheduled_email for row:" + objectID;
LogMgr.log (ScheduledEmailPersistence, LogLevel.SYSTEMERROR1, errorMsg);
throw new RuntimeException (errorMsg);
}
}
tl_scheduled_emailPSet.setStatus (PersistentSetStatus.PROCESSED);
}
}
public ResultSet executeSearchQueryAll (SQLManager sqlMgr) throws SQLException
{
throw new RuntimeException ("NOT implemented: executeSearchQueryAll");
}
public BaseBusinessClass[] loadQuery (PersistentSetCollection allPSets, SQLManager sqlMgr, RDBMSPersistenceContext context, String query, Object[] params, Integer maxRows, boolean truncateExtra) throws SQLException, StorageException
{
LinkedHashMap<ObjectID, ScheduledEmail> results = new LinkedHashMap ();
ResultSet r = executeQuery (sqlMgr, query, params);
while (r.next())
{
ThreadUtils.checkInterrupted ();
ObjectID objectID = new ObjectID (ScheduledEmail.REFERENCE_ScheduledEmail.getObjectIDSpace (), r.getLong ("id"));
ScheduledEmail 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, ScheduledEmail.REFERENCE_ScheduledEmail);
if (cachedElement instanceof ScheduledEmail)
{
LogMgr.log (ScheduledEmailPersistence, LogLevel.TRACE, "Cache hit for id:", objectID);
resultElement = (ScheduledEmail)cachedElement;
}
else
{
throw new StorageException ("Cache collision for id:" + objectID + " with object " + cachedElement + "while fetching a ScheduledEmail");
}
}
else
{
PersistentSet tl_scheduled_emailPSet = allPSets.getPersistentSet(objectID, "tl_scheduled_email", PersistentSetStatus.FETCHED);
createPersistentSetFromRS(allPSets, r, objectID);
resultElement = new ScheduledEmail ();
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 (ScheduledEmailPersistence, 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}tl_scheduled_email " + tables +
"WHERE " + SELECT_JOINS + " " + customParamFilter + customOrderBy;
BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, searchParams, null, false);
return results;
}
else if (searchType.equals (ScheduledEmail.SEARCH_All))
{
// Local scope for transformed variables
{
}
String orderBy = " ORDER BY tl_scheduled_email.object_id";
String tables = " ";
Set<String> joinTableSet = new HashSet<String>();
String filter;
Object[] searchParams; // paramFilter: tl_scheduled_email.object_id is not null
String preFilter = "(tl_scheduled_email.object_id is not null)"
+ " ";
preFilter += context.getLoadingAttributes ().getCustomSQL() ;
SearchParamTransform tx = new SearchParamTransform (criteria);
filter = StringUtils.replaceParams (preFilter, tx);
searchParams = tx.getParamsArray();
Integer maxRows = context.getLoadingAttributes ().getMaxRows ();
boolean truncateExtra = !context.getLoadingAttributes ().isFailIfMaxExceeded();
String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}tl_scheduled_email " + tables + tableSetToSQL(joinTableSet) +
"WHERE " + SELECT_JOINS + " " + filter + orderBy;
BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, searchParams, maxRows, truncateExtra);
return results;
}
else
{
throw new IllegalArgumentException ("Illegal search type:" + searchType);
}
}
private void createPersistentSetFromRS(PersistentSetCollection allPSets, ResultSet r, ObjectID objectID) throws SQLException
{
PersistentSet tl_scheduled_emailPSet = allPSets.getPersistentSet(objectID, "tl_scheduled_email", PersistentSetStatus.FETCHED);
// Object Modified
tl_scheduled_emailPSet.setAttrib(BaseBusinessClass.FIELD_ObjectLastModified, r.getTimestamp ("LAST_UPDATED_DATE"));
// Object Created
tl_scheduled_emailPSet.setAttrib(BaseBusinessClass.FIELD_ObjectCreated, r.getTimestamp ("CREATED_DATE"));
tl_scheduled_emailPSet.setAttrib(ScheduledEmail.FIELD_Subject, HELPER_Subject.getFromRS(dummySubject, r, "subject"));
tl_scheduled_emailPSet.setAttrib(ScheduledEmail.FIELD_ScheduledDate, HELPER_ScheduledDate.getFromRS(dummyScheduledDate, r, "scheduled_date"));
tl_scheduled_emailPSet.setAttrib(ScheduledEmail.FIELD_ApplicationStatus, HELPER_ApplicationStatus.getFromRS(dummyApplicationStatus, r, "application_status"));
tl_scheduled_emailPSet.setAttrib(ScheduledEmail.FIELD_MessageContent, HELPER_MessageContent.getFromRS(dummyMessageContent, r, "message_content"));
tl_scheduled_emailPSet.setAttrib(ScheduledEmail.SINGLEREFERENCE_JobApplication, r.getObject ("job_application_id"));
tl_scheduled_emailPSet.setAttrib(ScheduledEmail.SINGLEREFERENCE_MessageTemplate, r.getObject ("message_template_id"));
}
public void create(BaseBusinessClass obj, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException
{
ObjectID objectID = obj.getID ();
PersistentSet tl_scheduled_emailPSet = allPSets.getPersistentSet(objectID, "tl_scheduled_email");
if (tl_scheduled_emailPSet.getStatus () != PersistentSetStatus.PROCESSED &&
tl_scheduled_emailPSet.getStatus () != PersistentSetStatus.DEFERRED)
{
executeStatement (sqlMgr,
"INSERT INTO {PREFIX}tl_scheduled_email " +
" (subject, scheduled_date, application_status, message_content, job_application_id, message_template_id, object_id, object_LAST_UPDATED_DATE, object_CREATED_DATE) " +
"VALUES " +
" (?, ?, ?, ?, ?, ?, ?, " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ", " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ")",
CollectionUtils.listEntry (HELPER_Subject.getForSQL(dummySubject, tl_scheduled_emailPSet.getAttrib (ScheduledEmail.FIELD_Subject))).listEntry (HELPER_ScheduledDate.getForSQL(dummyScheduledDate, tl_scheduled_emailPSet.getAttrib (ScheduledEmail.FIELD_ScheduledDate))).listEntry (HELPER_ApplicationStatus.getForSQL(dummyApplicationStatus, tl_scheduled_emailPSet.getAttrib (ScheduledEmail.FIELD_ApplicationStatus))).listEntry (HELPER_MessageContent.getForSQL(dummyMessageContent, tl_scheduled_emailPSet.getAttrib (ScheduledEmail.FIELD_MessageContent))) .listEntry (SQLManager.CheckNull((Long)(tl_scheduled_emailPSet.getAttrib (ScheduledEmail.SINGLEREFERENCE_JobApplication)))).listEntry (SQLManager.CheckNull((Long)(tl_scheduled_emailPSet.getAttrib (ScheduledEmail.SINGLEREFERENCE_MessageTemplate)))) .listEntry (objectID.longID ()).toList().toArray());
tl_scheduled_emailPSet.setStatus (PersistentSetStatus.PROCESSED);
}
}
}
package performa.orm;
public class SentEmail extends BaseSentEmail
{
private static final long serialVersionUID = 0L;
// This constructor should not be called
public SentEmail ()
{
// Do not add any code to this, always put it in initialiseNewObject
}
}
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<ROOT xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:noNamespaceSchemaLocation='http://www.oneit.com.au/schemas/5.2/BusinessObject.xsd'>
<BUSINESSCLASS name="SentEmail" package="performa.orm">
<IMPORT value="performa.orm.types.*"/>
<TABLE name="tl_sent_email" tablePrefix="object">
<ATTRIB name="Subject" type="String" dbcol="subject" mandatory="true" length="200" />
<ATTRIB name="SentDate" type="Date" dbcol="sent_date" mandatory="true" />
<ATTRIB name="ApplicationStatus" type="ApplicationStatus" dbcol="application_status" mandatory="true" attribHelper="EnumeratedAttributeHelper" />
<ATTRIB name="MessageContent" type="String" dbcol="message_content" mandatory="true" />
<ATTRIB name="EmailTo" type="String" dbcol="email_to" mandatory="true" />
<SINGLEREFERENCE name="JobApplication" type="JobApplication" dbcol="job_application_id" backreferenceName="SentEmails" mandatory="true"/>
</TABLE>
<SEARCH type="All" paramFilter="tl_scheduled_email.object_id is not null" orderBy="tl_scheduled_email.object_id">
</SEARCH>
</BUSINESSCLASS>
</ROOT>
\ No newline at end of file
package performa.orm;
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 performa.orm.types.*;
/**
* IMPORTANT!!!! Autogenerated class, DO NOT EDIT!!!!!
* Template: Infrastructure8.2[oneit.objstore.PersistenceMgrTemplate.xsl]
*/
public class SentEmailPersistenceMgr extends ObjectPersistenceMgr
{
private static final LoggingArea SentEmailPersistence = LoggingArea.createLoggingArea(ObjectPersistenceMgr.OBJECT_PERSISTENCE, "SentEmail");
// Private attributes corresponding to business object data
private String dummySubject;
private Date dummySentDate;
private ApplicationStatus dummyApplicationStatus;
private String dummyMessageContent;
private String dummyEmailTo;
// Static constants corresponding to attribute helpers
private static final DefaultAttributeHelper HELPER_Subject = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper HELPER_SentDate = DefaultAttributeHelper.INSTANCE;
private static final EnumeratedAttributeHelper HELPER_ApplicationStatus = new EnumeratedAttributeHelper (ApplicationStatus.FACTORY_ApplicationStatus);
private static final DefaultAttributeHelper HELPER_MessageContent = DefaultAttributeHelper.INSTANCE;
private static final DefaultAttributeHelper HELPER_EmailTo = DefaultAttributeHelper.INSTANCE;
public SentEmailPersistenceMgr ()
{
dummySubject = (String)(HELPER_Subject.initialise (dummySubject));
dummySentDate = (Date)(HELPER_SentDate.initialise (dummySentDate));
dummyApplicationStatus = (ApplicationStatus)(HELPER_ApplicationStatus.initialise (dummyApplicationStatus));
dummyMessageContent = (String)(HELPER_MessageContent.initialise (dummyMessageContent));
dummyEmailTo = (String)(HELPER_EmailTo.initialise (dummyEmailTo));
}
private String SELECT_COLUMNS = "{PREFIX}tl_sent_email.object_id as id, {PREFIX}tl_sent_email.object_LAST_UPDATED_DATE as LAST_UPDATED_DATE, {PREFIX}tl_sent_email.object_CREATED_DATE as CREATED_DATE, {PREFIX}tl_sent_email.subject, {PREFIX}tl_sent_email.sent_date, {PREFIX}tl_sent_email.application_status, {PREFIX}tl_sent_email.message_content, {PREFIX}tl_sent_email.email_to, {PREFIX}tl_sent_email.job_application_id, 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, SentEmail.REFERENCE_SentEmail);
if (objectToReturn instanceof SentEmail)
{
LogMgr.log (SentEmailPersistence, 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 SentEmail");
}
}
PersistentSet tl_sent_emailPSet = allPSets.getPersistentSet(id, "tl_sent_email", PersistentSetStatus.FETCHED);
// Check for persistent sets already prefetched
if (false || !tl_sent_emailPSet.containsAttrib(BaseBusinessClass.FIELD_ObjectLastModified) ||
!tl_sent_emailPSet.containsAttrib(SentEmail.FIELD_Subject)||
!tl_sent_emailPSet.containsAttrib(SentEmail.FIELD_SentDate)||
!tl_sent_emailPSet.containsAttrib(SentEmail.FIELD_ApplicationStatus)||
!tl_sent_emailPSet.containsAttrib(SentEmail.FIELD_MessageContent)||
!tl_sent_emailPSet.containsAttrib(SentEmail.FIELD_EmailTo)||
!tl_sent_emailPSet.containsAttrib(SentEmail.SINGLEREFERENCE_JobApplication))
{
// We will need to retrieve it
idsToFetch.add (id.longValue());
}
else
{
LogMgr.log (SentEmailPersistence, LogLevel.DEBUG2, "Persistent set preloaded id:", id);
/* Non Polymorphic */
SentEmail result = new SentEmail ();
result.setFromPersistentSets(id, allPSets);
context.addRetrievedObject(result);
results.add (result);
}
}
if (idsToFetch.size () > 0)
{
String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}tl_sent_email " +
"WHERE " + SELECT_JOINS + "{PREFIX}tl_sent_email.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 if (refName.equals (SentEmail.SINGLEREFERENCE_JobApplication))
{
String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}tl_sent_email " +
"WHERE " + SELECT_JOINS + "job_application_id = ?";
BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, new Object[] { _objectID.longID () }, null, false);
return results;
}
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 tl_sent_emailPSet = allPSets.getPersistentSet(objectID, "tl_sent_email");
if (tl_sent_emailPSet.getStatus () != PersistentSetStatus.PROCESSED &&
tl_sent_emailPSet.getStatus () != PersistentSetStatus.DEFERRED)
{
int rowsUpdated = executeStatement (sqlMgr,
"UPDATE {PREFIX}tl_sent_email " +
"SET subject = ?, sent_date = ?, application_status = ?, message_content = ?, email_to = ?, job_application_id = ? , object_LAST_UPDATED_DATE = " + sqlMgr.getPortabilityServices ().getTimestampExpression () + " " +
"WHERE tl_sent_email.object_id = ? AND " + getConcurrencyCheck (sqlMgr, "object_LAST_UPDATED_DATE", obj.getObjectLastModified ()) + " ",
CollectionUtils.listEntry (HELPER_Subject.getForSQL(dummySubject, tl_sent_emailPSet.getAttrib (SentEmail.FIELD_Subject))).listEntry (HELPER_SentDate.getForSQL(dummySentDate, tl_sent_emailPSet.getAttrib (SentEmail.FIELD_SentDate))).listEntry (HELPER_ApplicationStatus.getForSQL(dummyApplicationStatus, tl_sent_emailPSet.getAttrib (SentEmail.FIELD_ApplicationStatus))).listEntry (HELPER_MessageContent.getForSQL(dummyMessageContent, tl_sent_emailPSet.getAttrib (SentEmail.FIELD_MessageContent))).listEntry (HELPER_EmailTo.getForSQL(dummyEmailTo, tl_sent_emailPSet.getAttrib (SentEmail.FIELD_EmailTo))).listEntry (SQLManager.CheckNull((Long)(tl_sent_emailPSet.getAttrib (SentEmail.SINGLEREFERENCE_JobApplication)))).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}tl_sent_email 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[] { "tl_sent_email", objectID.longID (), obj.getObjectLastModified (), d },
sqlMgr.getPortabilityServices ());
LogMgr.log (SentEmailPersistence, LogLevel.BUSINESS1, errorMsg);
throw new ConcurrentUpdateConflictException (obj, "tl_sent_email");
}
else
{
String errorMsg = "Attempt to update nonexistent row in table:tl_sent_email for row:" + objectID + " objDate:" + obj.getObjectLastModified ();
LogMgr.log (SentEmailPersistence, LogLevel.BUSINESS1, errorMsg);
throw new RuntimeException (errorMsg);
}
}
tl_sent_emailPSet.setStatus (PersistentSetStatus.PROCESSED);
}
}
else
{
LogMgr.log (SentEmailPersistence, 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 tl_sent_emailPSet = allPSets.getPersistentSet(objectID, "tl_sent_email");
LogMgr.log (SentEmailPersistence, LogLevel.DEBUG2, "Deleting:", objectID);
if (tl_sent_emailPSet.getStatus () != PersistentSetStatus.PROCESSED &&
tl_sent_emailPSet.getStatus () != PersistentSetStatus.DEFERRED)
{
int rowsDeleted = executeStatement (sqlMgr,
"DELETE " +
"FROM {PREFIX}tl_sent_email " +
"WHERE tl_sent_email.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}tl_sent_email WHERE object_id = ?",
new Object[] { objectID.longID() });
if (r.next ())
{
throw new ConcurrentUpdateConflictException (obj, "tl_sent_email");
}
else
{
String errorMsg = "Attempt to delete nonexistent row in table:tl_sent_email for row:" + objectID;
LogMgr.log (SentEmailPersistence, LogLevel.SYSTEMERROR1, errorMsg);
throw new RuntimeException (errorMsg);
}
}
tl_sent_emailPSet.setStatus (PersistentSetStatus.PROCESSED);
}
}
public ResultSet executeSearchQueryAll (SQLManager sqlMgr) throws SQLException
{
throw new RuntimeException ("NOT implemented: executeSearchQueryAll");
}
public BaseBusinessClass[] loadQuery (PersistentSetCollection allPSets, SQLManager sqlMgr, RDBMSPersistenceContext context, String query, Object[] params, Integer maxRows, boolean truncateExtra) throws SQLException, StorageException
{
LinkedHashMap<ObjectID, SentEmail> results = new LinkedHashMap ();
ResultSet r = executeQuery (sqlMgr, query, params);
while (r.next())
{
ThreadUtils.checkInterrupted ();
ObjectID objectID = new ObjectID (SentEmail.REFERENCE_SentEmail.getObjectIDSpace (), r.getLong ("id"));
SentEmail 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, SentEmail.REFERENCE_SentEmail);
if (cachedElement instanceof SentEmail)
{
LogMgr.log (SentEmailPersistence, LogLevel.TRACE, "Cache hit for id:", objectID);
resultElement = (SentEmail)cachedElement;
}
else
{
throw new StorageException ("Cache collision for id:" + objectID + " with object " + cachedElement + "while fetching a SentEmail");
}
}
else
{
PersistentSet tl_sent_emailPSet = allPSets.getPersistentSet(objectID, "tl_sent_email", PersistentSetStatus.FETCHED);
createPersistentSetFromRS(allPSets, r, objectID);
resultElement = new SentEmail ();
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 (SentEmailPersistence, 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}tl_sent_email " + tables +
"WHERE " + SELECT_JOINS + " " + customParamFilter + customOrderBy;
BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, searchParams, null, false);
return results;
}
else if (searchType.equals (SentEmail.SEARCH_All))
{
// Local scope for transformed variables
{
}
String orderBy = " ORDER BY tl_scheduled_email.object_id";
String tables = " ";
Set<String> joinTableSet = new HashSet<String>();
String filter;
Object[] searchParams; // paramFilter: tl_scheduled_email.object_id is not null
String preFilter = "(tl_scheduled_email.object_id is not null)"
+ " ";
preFilter += context.getLoadingAttributes ().getCustomSQL() ;
SearchParamTransform tx = new SearchParamTransform (criteria);
filter = StringUtils.replaceParams (preFilter, tx);
searchParams = tx.getParamsArray();
Integer maxRows = context.getLoadingAttributes ().getMaxRows ();
boolean truncateExtra = !context.getLoadingAttributes ().isFailIfMaxExceeded();
String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}tl_sent_email " + tables + tableSetToSQL(joinTableSet) +
"WHERE " + SELECT_JOINS + " " + filter + orderBy;
BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, searchParams, maxRows, truncateExtra);
return results;
}
else
{
throw new IllegalArgumentException ("Illegal search type:" + searchType);
}
}
private void createPersistentSetFromRS(PersistentSetCollection allPSets, ResultSet r, ObjectID objectID) throws SQLException
{
PersistentSet tl_sent_emailPSet = allPSets.getPersistentSet(objectID, "tl_sent_email", PersistentSetStatus.FETCHED);
// Object Modified
tl_sent_emailPSet.setAttrib(BaseBusinessClass.FIELD_ObjectLastModified, r.getTimestamp ("LAST_UPDATED_DATE"));
// Object Created
tl_sent_emailPSet.setAttrib(BaseBusinessClass.FIELD_ObjectCreated, r.getTimestamp ("CREATED_DATE"));
tl_sent_emailPSet.setAttrib(SentEmail.FIELD_Subject, HELPER_Subject.getFromRS(dummySubject, r, "subject"));
tl_sent_emailPSet.setAttrib(SentEmail.FIELD_SentDate, HELPER_SentDate.getFromRS(dummySentDate, r, "sent_date"));
tl_sent_emailPSet.setAttrib(SentEmail.FIELD_ApplicationStatus, HELPER_ApplicationStatus.getFromRS(dummyApplicationStatus, r, "application_status"));
tl_sent_emailPSet.setAttrib(SentEmail.FIELD_MessageContent, HELPER_MessageContent.getFromRS(dummyMessageContent, r, "message_content"));
tl_sent_emailPSet.setAttrib(SentEmail.FIELD_EmailTo, HELPER_EmailTo.getFromRS(dummyEmailTo, r, "email_to"));
tl_sent_emailPSet.setAttrib(SentEmail.SINGLEREFERENCE_JobApplication, r.getObject ("job_application_id"));
}
public void create(BaseBusinessClass obj, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException
{
ObjectID objectID = obj.getID ();
PersistentSet tl_sent_emailPSet = allPSets.getPersistentSet(objectID, "tl_sent_email");
if (tl_sent_emailPSet.getStatus () != PersistentSetStatus.PROCESSED &&
tl_sent_emailPSet.getStatus () != PersistentSetStatus.DEFERRED)
{
executeStatement (sqlMgr,
"INSERT INTO {PREFIX}tl_sent_email " +
" (subject, sent_date, application_status, message_content, email_to, job_application_id, object_id, object_LAST_UPDATED_DATE, object_CREATED_DATE) " +
"VALUES " +
" (?, ?, ?, ?, ?, ?, ?, " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ", " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ")",
CollectionUtils.listEntry (HELPER_Subject.getForSQL(dummySubject, tl_sent_emailPSet.getAttrib (SentEmail.FIELD_Subject))).listEntry (HELPER_SentDate.getForSQL(dummySentDate, tl_sent_emailPSet.getAttrib (SentEmail.FIELD_SentDate))).listEntry (HELPER_ApplicationStatus.getForSQL(dummyApplicationStatus, tl_sent_emailPSet.getAttrib (SentEmail.FIELD_ApplicationStatus))).listEntry (HELPER_MessageContent.getForSQL(dummyMessageContent, tl_sent_emailPSet.getAttrib (SentEmail.FIELD_MessageContent))).listEntry (HELPER_EmailTo.getForSQL(dummyEmailTo, tl_sent_emailPSet.getAttrib (SentEmail.FIELD_EmailTo))) .listEntry (SQLManager.CheckNull((Long)(tl_sent_emailPSet.getAttrib (SentEmail.SINGLEREFERENCE_JobApplication)))) .listEntry (objectID.longID ()).toList().toArray());
tl_sent_emailPSet.setStatus (PersistentSetStatus.PROCESSED);
}
}
}
package performa.utils;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.Random;
import java.util.TimeZone;
public class MessagingUtils
{
private static final Random rand = new Random();
public static int WORK_START_HOUR = 9;
public static int WORK_STOP_HOUR = 17;
public static int randInt(int min, int max)
{
return rand.nextInt((max - min) + 1) + min;
}
public static Date getWithinBusinessHours(Calendar cal, TimeZone timeZone)
{
while (!isWorkingDay(cal))
{
cal.add(Calendar.DAY_OF_MONTH, 1);
}
Calendar calDayStart = new GregorianCalendar();
Calendar calDayEnd = new GregorianCalendar();
calDayStart.setTime(cal.getTime());
calDayEnd.setTime(cal.getTime());
startOfWorkingDay(calDayStart, timeZone);
endOfWorkingDay(calDayEnd, timeZone);
if(cal.before(calDayStart))
{
cal.setTimeZone(timeZone);
cal.set(GregorianCalendar.HOUR_OF_DAY, WORK_START_HOUR);
}
else if(cal.after(calDayEnd))
{
cal.setTimeZone(timeZone);
cal.add(Calendar.DAY_OF_MONTH, 1);
cal.set(GregorianCalendar.HOUR_OF_DAY, WORK_START_HOUR);
while (!isWorkingDay(cal))
{
cal.add(Calendar.DAY_OF_MONTH, 1);
}
}
return cal.getTime();
}
public static void startOfWorkingDay(Calendar cal, TimeZone timeZone)
{
cal.setTimeZone(timeZone);
cal.set(GregorianCalendar.MILLISECOND, 0);
cal.set(GregorianCalendar.SECOND, 0);
cal.set(GregorianCalendar.MINUTE, 0);
cal.set(GregorianCalendar.HOUR_OF_DAY, WORK_START_HOUR);
}
public static void endOfWorkingDay(Calendar cal, TimeZone timeZone)
{
cal.setTimeZone(timeZone);
cal.set(GregorianCalendar.MILLISECOND, 0);
cal.set(GregorianCalendar.SECOND, 0);
cal.set(GregorianCalendar.MINUTE, 0);
cal.set(GregorianCalendar.HOUR_OF_DAY, WORK_STOP_HOUR);
}
public static boolean isWorkingDay(Calendar day)
{
int dayOfWeek = day.get(Calendar.DAY_OF_WEEK);
return !(dayOfWeek == Calendar.SATURDAY || dayOfWeek == Calendar.SUNDAY);
}
}
\ No newline at end of file
......@@ -66,10 +66,10 @@
<oneit:skin tagName="layout_row">
<oneit:layout_label width="1">
<oneit:ormlabel obj="<%= messageTemplate %>" field="Delay"/>
<oneit:ormlabel obj="<%= messageTemplate %>" field="DelayHrs"/>
</oneit:layout_label>
<oneit:layout_field width="1">
<oneit:ormInput obj="<%= messageTemplate %>" attributeName="Delay" style="width:30%" /><span>Hours</span>
<oneit:ormInput obj="<%= messageTemplate %>" attributeName="DelayHrs" style="width:30%" /><span>Hours</span>
</oneit:layout_field>
</oneit:skin>
......
<?xml version="1.0" encoding="UTF-8"?>
<!-- @AutoRun -->
<!-- @AutoRun -->
<OBJECTS name="" xmlns:oneit="http://www.1iT.com.au"><NODE name="Script" factory="Vector">
<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">tl_message_template</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="subject" type="String" nullable="true" length="200"/>
<column name="application_status" type="String" nullable="true" length="200"/>
<column name="delay" type="Double" nullable="true"/>
<column name="subject" type="String" nullable="false" length="200"/>
<column name="application_status" type="String" nullable="false" length="200"/>
<column name="delay_hrs" type="Long" nullable="true"/>
<column name="delay_min" type="Long" nullable="true"/>
<column name="variance" type="Long" nullable="true"/>
<column name="business_hours_only" type="Boolean" nullable="true"/>
<column name="message_content" type="CLOB" nullable="true"/>
<column name="message_content" type="CLOB" nullable="false"/>
</NODE>
</NODE></OBJECTS>
\ No newline at end of file
</NODE>
</OBJECTS>
\ No newline at end of file
<?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">tl_scheduled_email</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="subject" type="String" nullable="false" length="200"/>
<column name="scheduled_date" type="Date" nullable="false"/>
<column name="application_status" type="String" nullable="false" length="200"/>
<column name="message_content" type="CLOB" nullable="false"/>
<column name="job_application_id" type="Long" length="11" nullable="false"/>
<column name="message_template_id" type="Long" length="11" nullable="true"/>
</NODE>
<NODE name="INDEX" factory="Participant" class="oneit.sql.transfer.DefineIndexOperation" tableName="tl_scheduled_email" indexName="idx_tl_scheduled_email_job_application_id" isUnique="false">
<column name="job_application_id"/>
</NODE>
</NODE>
</OBJECTS>
\ No newline at end of file
<?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">tl_sent_email</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="subject" type="String" nullable="false" length="200"/>
<column name="sent_date" type="Date" nullable="false"/>
<column name="application_status" type="String" nullable="false" length="200"/>
<column name="message_content" type="CLOB" nullable="false"/>
<column name="email_to" type="CLOB" nullable="false"/>
<column name="job_application_id" type="Long" length="11" nullable="false"/>
</NODE>
<NODE name="INDEX" factory="Participant" class="oneit.sql.transfer.DefineIndexOperation" tableName="tl_sent_email" indexName="idx_tl_sent_email_job_application_id" isUnique="false">
<column name="job_application_id"/>
</NODE>
</NODE>
</OBJECTS>
\ No newline at end of file
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