blob: ce392fac6c3092ac2b8f29639785f57e56ca2169 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
/*******************************************************************************
* Copyright (c) 2014 Boeing.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
package org.eclipse.osee.ats.impl.internal.notify;
import java.util.List;
import org.eclipse.osee.ats.api.notify.AtsNotificationCollector;
import org.eclipse.osee.ats.api.notify.AtsNotificationEvent;
import org.eclipse.osee.ats.api.notify.AtsWorkItemNotificationEvent;
import org.eclipse.osee.ats.api.user.IAtsUserService;
import org.eclipse.osee.framework.jdk.core.util.Strings;
public class AtsNotificationEventProcessor {
private final String noReplyEmail;
private final WorkItemNotificationProcessor workItemNotificationProcessor;
private final IAtsUserService userService;
public AtsNotificationEventProcessor(WorkItemNotificationProcessor workItemNotificationProcessor, IAtsUserService userService, String noReplyEmail) {
this.workItemNotificationProcessor = workItemNotificationProcessor;
this.userService = userService;
this.noReplyEmail = noReplyEmail;
}
public void sendNotifications(AtsNotificationCollector notifications, List<IAtsNotifierServer> notifiers) {
// convert all WorkItem notifications to AtsNotificationEvent
for (AtsWorkItemNotificationEvent workItemEvent : notifications.getWorkItemNotificationEvents()) {
workItemNotificationProcessor.run(notifications, workItemEvent);
}
String testingUserEmail = "donald.g.dunne@boeing.com"; // change to email address for testing purposes; all emails will go there
String fromUserEmail = getFromUserEmail(notifications);
for (IAtsNotifierServer notifier : notifiers) {
notifier.sendNotifications(fromUserEmail, testingUserEmail, notifications.getSubject(),
notifications.getBody(), notifications.getNotificationEvents());
}
}
private String getFromUserEmail(AtsNotificationCollector notifications) {
String email = noReplyEmail;
for (AtsNotificationEvent event : notifications.getNotificationEvents()) {
if (Strings.isValid(event.getFromUserId())) {
email = userService.getUserById(event.getFromUserId()).getEmail();
break;
}
}
return email;
}
}
|