5
5
import main .model .db .dao .audit .AuditStatisticDao ;
6
6
import main .model .db .dao .project .UserDao ;
7
7
import main .model .dto .*;
8
+ import main .utils .AppProperties ;
8
9
import org .json .JSONException ;
9
10
10
11
import javax .naming .NamingException ;
19
20
public class AuditEmails extends Emails {
20
21
21
22
private AuditStatisticDao auditStatisticController ;
23
+ private AppProperties appProperties = new AppProperties ();
22
24
23
25
public AuditEmails () {
24
26
auditStatisticController = new AuditStatisticDao ();
25
27
}
26
28
27
- public List <EmailDto > GetUpcomingEmails () throws SQLException , IOException , JSONException , NamingException , IllegalAccessException , InstantiationException , RPException {
29
+ public List <EmailDto > GetUpcomingEmails () throws RPException {
28
30
List <AuditStatisticDto > audits = auditStatisticController .getAll ();
29
31
List <String > recipients = getRecipients ();
30
32
@@ -36,7 +38,7 @@ public List<EmailDto> GetUpcomingEmails() throws SQLException, IOException, JSON
36
38
return emails ;
37
39
}
38
40
39
- public List <EmailDto > GetOverdueEmails () throws SQLException , IOException , JSONException , NamingException , IllegalAccessException , InstantiationException , RPException {
41
+ public List <EmailDto > GetOverdueEmails () throws RPException {
40
42
List <AuditStatisticDto > audits = auditStatisticController .getAll ();
41
43
List <String > recipients = getRecipients ();
42
44
List <AuditStatisticDto > overdueAudits = audits .stream ()
@@ -47,16 +49,16 @@ public List<EmailDto> GetOverdueEmails() throws SQLException, IOException, JSONE
47
49
48
50
for (AuditStatisticDto overdueAudit : overdueAudits ){
49
51
EmailDto email = new EmailDto ();
50
- email .setSubject ("[REPORTING PORTAL ] Overdue Project Audit - " + overdueAudit .getName ());
52
+ email .setSubject (String . format ( "[%s ] Overdue Project Audit - %s" , appProperties . getName (), overdueAudit .getName () ));
51
53
email .setContent ("<p style=\" font-family: Calibri, sans-serif; font-size: 11pt; line-height: 4px;\" >Next Audit Date for the <strong><a style=\" color: #6b6b6b;\" href=\" "
52
54
+ hostUri () +"#/project/" + overdueAudit .getId ()+"\" >" + overdueAudit .getName () +"</a> </strong>project is overdue and requires your attention.</p>\n " +
53
55
"<p style=\" font-family: Calibri, sans-serif; font-size: 11pt; line-height: 4px;\" >Please follow this <a style=\" color: #6b6b6b;\" href=\" "
54
56
+ hostUri () + "#/audit\" >link</a> to access Audits Dashboard.</p>\n " +
55
57
"<p> </p>" +
56
58
"<p style=\" font-family: Calibri, sans-serif; font-size: 10pt; line-height: 2px;\" >Best Regards,</p>\n " +
57
- "<p style=\" font-family: Calibri, sans-serif; font-size: 10pt; line-height: 2px;\" >Reporting Portal Administration</p>\n " +
59
+ "<p style=\" font-family: Calibri, sans-serif; font-size: 10pt; line-height: 2px;\" >" + appProperties . getName () + " Administration</p>\n " +
58
60
"<p><img src=\" cid:logo\" ></p>\n " +
59
- "<p><span style=\" font-family: Calibri; font-size: 7.5pt; color: #7f7f7f;\" >This message is automatically generated by Notification Assistant for Reporting Portal. <br /> If you think it was sent incorrectly, please contact your Reporting Portal administrators.</span></p>" );
61
+ "<p><span style=\" font-family: Calibri; font-size: 7.5pt; color: #7f7f7f;\" >This message is automatically generated by Notification Assistant for " + appProperties . getName () + ". <br /> If you think it was sent incorrectly, please contact your " + appProperties . getName () + " administrators.</span></p>" );
60
62
List <String > customRecipients = new ArrayList <>(recipients );
61
63
62
64
if (!Objects .equals (overdueAudit .getLast_created_id (), overdueAudit .getLast_submitted_id ())){
@@ -80,17 +82,17 @@ private List<EmailDto> getUpcomingAudits(int daysFromToday, List<AuditStatisticD
80
82
81
83
for (AuditStatisticDto upcAudit : upcomingAudits ){
82
84
EmailDto email = new EmailDto ();
83
- email .setSubject ("[REPORTING PORTAL ] Upcoming Project Audit - " + upcAudit .getName ());
85
+ email .setSubject (String . format ( "[%s ] Upcoming Project Audit - %s" , appProperties . getName (), upcAudit .getName () ));
84
86
email .setContent ("<p style=\" font-family: Calibri, sans-serif; font-size: 11pt; line-height: 4px;\" >Next Audit for the <strong><a style=\" color: #6b6b6b;\" href=\" "
85
87
+ hostUri () +"#/project/" + upcAudit .getId ()+"\" >" + upcAudit .getName () + "</a> </strong>project should be submitted within<strong> "
86
88
+ days + " days.</strong></p>\n " +
87
89
"<p style=\" font-family: Calibri, sans-serif; font-size: 11pt; line-height: 4px;\" >Please follow this <a style=\" color: #6b6b6b;\" href=\" "
88
90
+ hostUri () + "#/audit\" >link</a> to access Audits Dashboard and create a new Audit.</p>\n " +
89
91
"<p> </p>\n " +
90
92
"<p style=\" font-family: Calibri, sans-serif; font-size: 10pt; line-height: 2px;\" >Best Regards,</p>\n " +
91
- "<p style=\" font-family: Calibri, sans-serif; font-size: 10pt; line-height: 2px;\" >Reporting Portal Administration</p>\n " +
93
+ "<p style=\" font-family: Calibri, sans-serif; font-size: 10pt; line-height: 2px;\" >" + appProperties . getName () + " Administration</p>\n " +
92
94
"<p><img src=\" cid:logo\" ></p>\n " +
93
- "<p><span style=\" font-family: Calibri; font-size: 7.5pt; color: #7f7f7f;\" >This message is automatically generated by Notification Assistant for Reporting Portal. <br /> If you think it was sent incorrectly, please contact your Reporting Portal administrators.</span></p>" );
95
+ "<p><span style=\" font-family: Calibri; font-size: 7.5pt; color: #7f7f7f;\" >This message is automatically generated by Notification Assistant for " + appProperties . getName () + ". <br /> If you think it was sent incorrectly, please contact your " + appProperties . getName () + " administrators.</span></p>" );
94
96
email .setRecipients (recipients );
95
97
emails .add (email );
96
98
}
@@ -111,7 +113,7 @@ private List<String> getCustomRecipients(Integer id) throws RPException {
111
113
auditTemplate .setId (id );
112
114
List <AuditorDto > users = auditDao .searchAll (auditTemplate ).get (0 ).getAuditors ();
113
115
users = users .stream ().filter (userX -> userX .getAudit_notifications () == 1 ).collect (Collectors .toList ());
114
- return users .stream ().map (auditor -> auditor . getEmail () ).collect (Collectors .toList ());
116
+ return users .stream ().map (UserDto :: getEmail ).collect (Collectors .toList ());
115
117
}
116
118
117
119
private Date getDueDate (AuditStatisticDto auditStat ){
0 commit comments