Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
PERFORMA_REPLICA
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Muhammad Usman
PERFORMA_REPLICA
Commits
2dad92bb
Commit
2dad92bb
authored
Mar 11, 2019
by
Nilu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Messaging engine email sending and replacing placeholder tags
parent
e5f514bb
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
6 deletions
+32
-6
MessagingEngineBatch.java
cmsWebApp/src/performa/batch/MessagingEngineBatch.java
+31
-5
JobApplication.java
cmsWebApp/src/performa/orm/JobApplication.java
+1
-1
No files found.
cmsWebApp/src/performa/batch/MessagingEngineBatch.java
View file @
2dad92bb
...
@@ -14,9 +14,12 @@ import oneit.objstore.ObjectTransaction;
...
@@ -14,9 +14,12 @@ import oneit.objstore.ObjectTransaction;
import
oneit.objstore.StorageException
;
import
oneit.objstore.StorageException
;
import
oneit.objstore.rdbms.filters.LessThanEqualFilter
;
import
oneit.objstore.rdbms.filters.LessThanEqualFilter
;
import
oneit.utils.InitialisationException
;
import
oneit.utils.InitialisationException
;
import
oneit.utils.StringUtils
;
import
oneit.utils.parsers.FieldException
;
import
oneit.utils.parsers.FieldException
;
import
performa.orm.JobApplication
;
import
performa.orm.ScheduledEmail
;
import
performa.orm.ScheduledEmail
;
import
performa.orm.SentEmail
;
import
performa.orm.SentEmail
;
import
performa.orm.types.PlaceholderOptions
;
public
class
MessagingEngineBatch
extends
ORMBatch
implements
InitialisationParticipant
public
class
MessagingEngineBatch
extends
ORMBatch
implements
InitialisationParticipant
...
@@ -34,25 +37,48 @@ public class MessagingEngineBatch extends ORMBatch implements InitialisationPart
...
@@ -34,25 +37,48 @@ public class MessagingEngineBatch extends ORMBatch implements InitialisationPart
for
(
ScheduledEmail
scheduledEmail
:
scheduledEmails
)
for
(
ScheduledEmail
scheduledEmail
:
scheduledEmails
)
{
{
String
messageContent
=
scheduledEmail
.
getMessageContent
();
LogMgr
.
log
(
MESSAGING_ENGINE_BATCH
,
LogLevel
.
PROCESSING1
,
"Starting to create email for scheduled email : "
,
scheduledEmail
);
JobApplication
jobApplication
=
scheduledEmail
.
getJobApplication
();
// replace tags
// replace tags
String
messageContent
=
StringUtils
.
replace
(
scheduledEmail
.
getMessageContent
(),
new
String
[]
{
PlaceholderOptions
.
FIRST_NAME
.
getPlaceholder
(),
PlaceholderOptions
.
SURNAME
.
getPlaceholder
(),
PlaceholderOptions
.
EMAIL_ADDRESS
.
getPlaceholder
(),
PlaceholderOptions
.
LOCATION
.
getPlaceholder
(),
PlaceholderOptions
.
JOB_TITLE
.
getPlaceholder
(),
PlaceholderOptions
.
JOB_REFERENCE
.
getPlaceholder
()},
new
String
[]
{
jobApplication
.
getCandidate
().
getFirstName
(),
jobApplication
.
getCandidate
().
getUser
().
getLastName
(),
jobApplication
.
getCandidate
().
getUser
().
getEmail
(),
jobApplication
.
getJob
().
getGoogleAddressText
(),
jobApplication
.
getJob
().
getJobTitle
(),
jobApplication
.
getJob
().
getReferenceNumber
()});
LogMgr
.
log
(
MESSAGING_ENGINE_BATCH
,
LogLevel
.
PROCESSING1
,
"Replaced tags of message content : "
,
messageContent
);
TextDataSource
mesgBodyDataSource
=
new
TextDataSource
(
messageContent
);
TextDataSource
mesgBodyDataSource
=
new
TextDataSource
(
StringUtils
.
fromHTML
(
messageContent
)
);
String
toEmail
=
scheduledEmail
.
getJobApplication
()
.
getCandidate
().
getUser
().
getEmail
();
String
toEmail
=
jobApplication
.
getCandidate
().
getUser
().
getEmail
();
String
fromEmail
=
scheduledEmail
.
getJobApplication
()
.
getJob
().
getCreatedBy
().
getUser
().
getEmail
();
String
fromEmail
=
jobApplication
.
getJob
().
getCreatedBy
().
getUser
().
getEmail
();
SentEmail
sentEmail
=
SentEmail
.
createSentEmail
(
ot
);
SentEmail
sentEmail
=
SentEmail
.
createSentEmail
(
ot
);
emailEngine
.
sendEmail
(
new
String
[]
{
toEmail
},
fromEmail
,
scheduledEmail
.
getSubject
()
,
new
DataSource
[]{
mesgBodyDataSource
});
emailEngine
.
sendEmail
(
new
String
[]
{
toEmail
},
fromEmail
,
scheduledEmail
.
getSubject
()
,
new
DataSource
[]{
mesgBodyDataSource
});
LogMgr
.
log
(
MESSAGING_ENGINE_BATCH
,
LogLevel
.
PROCESSING1
,
"Email sent to : "
,
toEmail
,
" from : "
,
fromEmail
);
sentEmail
.
setSubject
(
scheduledEmail
.
getSubject
());
sentEmail
.
setSubject
(
scheduledEmail
.
getSubject
());
sentEmail
.
setSentDate
(
new
Date
());
sentEmail
.
setSentDate
(
new
Date
());
sentEmail
.
setApplicationStatus
(
scheduledEmail
.
getApplicationStatus
());
sentEmail
.
setApplicationStatus
(
scheduledEmail
.
getApplicationStatus
());
sentEmail
.
setMessageContent
(
messageContent
);
sentEmail
.
setMessageContent
(
messageContent
);
sentEmail
.
setEmailTo
(
toEmail
);
sentEmail
.
setEmailTo
(
toEmail
);
sentEmail
.
setJobApplication
(
scheduledEmail
.
getJobApplication
());
sentEmail
.
setJobApplication
(
jobApplication
);
LogMgr
.
log
(
MESSAGING_ENGINE_BATCH
,
LogLevel
.
PROCESSING1
,
"SentEmail object created to store sent email details : "
,
sentEmail
);
scheduledEmail
.
delete
();
scheduledEmail
.
delete
();
}
}
LogMgr
.
log
(
MESSAGING_ENGINE_BATCH
,
LogLevel
.
PROCESSING1
,
"End of Messaging Engine Batch"
);
}
}
@Override
@Override
...
...
cmsWebApp/src/performa/orm/JobApplication.java
View file @
2dad92bb
...
@@ -67,7 +67,7 @@ public class JobApplication extends BaseJobApplication
...
@@ -67,7 +67,7 @@ public class JobApplication extends BaseJobApplication
TimeZone
jobTimeZone
=
getJob
().
getHiringTeam
().
getCompany
().
getDefaultTimeZone
();
TimeZone
jobTimeZone
=
getJob
().
getHiringTeam
().
getCompany
().
getDefaultTimeZone
();
Calendar
cal
=
new
GregorianCalendar
();
Calendar
cal
=
new
GregorianCalendar
();
cal
.
setTime
(
now
);
cal
.
setTime
(
scheduledDate
);
scheduledDate
=
MessagingUtils
.
getWithinBusinessHours
(
cal
,
jobTimeZone
!=
null
?
java
.
util
.
TimeZone
.
getTimeZone
(
jobTimeZone
.
getTimeZoneCode
())
:
cal
.
getTimeZone
());
scheduledDate
=
MessagingUtils
.
getWithinBusinessHours
(
cal
,
jobTimeZone
!=
null
?
java
.
util
.
TimeZone
.
getTimeZone
(
jobTimeZone
.
getTimeZoneCode
())
:
cal
.
getTimeZone
());
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment