1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
package org.kuali.rice.kew.mail.service.impl; |
19 | |
|
20 | |
import java.util.Collection; |
21 | |
|
22 | |
import org.apache.log4j.Logger; |
23 | |
import org.kuali.rice.core.mail.EmailBody; |
24 | |
import org.kuali.rice.core.mail.EmailContent; |
25 | |
import org.kuali.rice.core.mail.EmailSubject; |
26 | |
import org.kuali.rice.kew.actionitem.ActionItem; |
27 | |
import org.kuali.rice.kew.mail.service.EmailContentService; |
28 | |
import org.kuali.rice.kew.routeheader.DocumentRouteHeaderValue; |
29 | |
import org.kuali.rice.kew.service.KEWServiceLocator; |
30 | |
import org.kuali.rice.kew.util.KEWConstants; |
31 | |
import org.kuali.rice.kim.bo.Person; |
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | 0 | public class CustomizableActionListEmailServiceImpl extends ActionListEmailServiceImpl { |
40 | 0 | private static final Logger LOG = Logger.getLogger(CustomizableActionListEmailServiceImpl.class); |
41 | |
|
42 | |
private EmailContentService contentService; |
43 | |
|
44 | |
|
45 | |
|
46 | |
public void setEmailContentGenerator(EmailContentService contentService) { |
47 | 0 | this.contentService = contentService; |
48 | 0 | } |
49 | |
|
50 | |
protected EmailContentService getEmailContentGenerator() { |
51 | 0 | return contentService; |
52 | |
} |
53 | |
|
54 | |
public void sendImmediateReminder(Person user, ActionItem actionItem) { |
55 | 0 | if (!sendActionListEmailNotification()) { |
56 | 0 | LOG.debug("not sending immediate reminder"); |
57 | 0 | return; |
58 | |
} |
59 | |
|
60 | |
|
61 | 0 | DocumentRouteHeaderValue document = KEWServiceLocator.getRouteHeaderService().getRouteHeader(actionItem.getDocumentId()); |
62 | 0 | EmailContent content = getEmailContentGenerator().generateImmediateReminder(user, actionItem, document.getDocumentType()); |
63 | 0 | sendEmail(user, new EmailSubject(content.getSubject()), |
64 | |
new EmailBody(content.getBody()), document.getDocumentType()); |
65 | 0 | } |
66 | |
|
67 | |
@Override |
68 | |
protected void sendPeriodicReminder(Person person, Collection<ActionItem> actionItems, String emailSetting) { |
69 | 0 | actionItems = filterActionItemsToNotify(person.getPrincipalId(), actionItems); |
70 | |
|
71 | |
|
72 | 0 | if (actionItems.isEmpty()) { |
73 | 0 | return; |
74 | |
} |
75 | |
EmailContent content; |
76 | 0 | if (KEWConstants.EMAIL_RMNDR_DAY_VAL.equals(emailSetting)) { |
77 | 0 | content = getEmailContentGenerator().generateDailyReminder(person, actionItems); |
78 | 0 | } else if (KEWConstants.EMAIL_RMNDR_WEEK_VAL.equals(emailSetting)) { |
79 | 0 | content = getEmailContentGenerator().generateWeeklyReminder(person, actionItems); |
80 | |
} else { |
81 | |
|
82 | 0 | throw new RuntimeException("invalid email setting. this code needs refactoring"); |
83 | |
} |
84 | 0 | sendEmail(person, new EmailSubject(content.getSubject()), new EmailBody(content.getBody())); |
85 | 0 | } |
86 | |
|
87 | |
} |