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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
/*******************************************************************************
* Copyright (c) 2004, 2007 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.notify;
import java.util.Collection;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.osee.ats.internal.AtsPlugin;
import org.eclipse.osee.ats.util.AtsUtil;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.operation.AbstractOperation;
import org.eclipse.osee.framework.core.operation.Operations;
import org.eclipse.osee.framework.jdk.core.util.AHTML;
import org.eclipse.osee.framework.logging.OseeLevel;
import org.eclipse.osee.framework.logging.OseeLog;
import org.eclipse.osee.framework.skynet.core.utility.Artifacts;
import org.eclipse.osee.framework.ui.plugin.PluginUiImage;
import org.eclipse.osee.framework.ui.plugin.util.AWorkbench;
import org.eclipse.osee.framework.ui.plugin.xnavigate.XNavigateComposite.TableLoadOption;
import org.eclipse.osee.framework.ui.plugin.xnavigate.XNavigateItem;
import org.eclipse.osee.framework.ui.plugin.xnavigate.XNavigateItemAction;
import org.eclipse.osee.framework.ui.skynet.notify.OseeNotificationEvent;
import org.eclipse.osee.framework.ui.skynet.notify.OseeNotificationManager;
import org.eclipse.osee.framework.ui.skynet.notify.OseeNotifyUsersJob;
import org.eclipse.osee.framework.ui.skynet.results.XResultData;
/**
* @author Donald G. Dunne
*/
public class AtsNotificationNavigateItem extends XNavigateItemAction {
public AtsNotificationNavigateItem(XNavigateItem parent) {
this(parent, false);
}
public AtsNotificationNavigateItem(XNavigateItem parent, boolean sync) {
super(parent, (sync ? "Sync - " : "") + "Process ATS Notifications", PluginUiImage.ADMIN);
}
@Override
public void run(TableLoadOption... tableLoadOptions) throws Exception {
AtsNotificationCheckTreeDialog diag = new AtsNotificationCheckTreeDialog();
if (diag.open() == 0) {
if (diag.getSelectedAtsNotifications().isEmpty()) {
AWorkbench.popup("Error", "No Notifications Selected");
return;
}
Operations.executeAsJob(new NotificationJob(diag.isSendNotifications(), diag.getSelectedAtsNotifications()),
true);
}
}
public class NotificationJob extends AbstractOperation {
private final boolean sendNotifications;
private final Collection<IAtsNotification> notifications;
public NotificationJob(boolean sendNotifications, Collection<IAtsNotification> notifications) {
super("Processing ATS Notifications", AtsPlugin.PLUGIN_ID);
this.sendNotifications = sendNotifications;
this.notifications = notifications;
}
@Override
protected void doWork(IProgressMonitor monitor) throws Exception {
try {
XResultData rd = new XResultData();
if (sendNotifications) {
rd.addRaw(AHTML.bold("Notifications were sent"));
} else {
rd.addRaw("Report Only - Notifications were NOT sent");
}
rd.addRaw(AHTML.beginMultiColumnTable(100, 1));
rd.addRaw(AHTML.addHeaderRowMultiColumnTable(new String[] {"Reason", "Description", "Id", "User(s)", "URL"}));
int numEvents = 0;
for (IAtsNotification notify : notifications) {
for (OseeNotificationEvent event : notify.getNotificationEvents(monitor)) {
numEvents++;
rd.addRaw(AHTML.addRowMultiColumnTable(event.getType(), event.getDescription(),
XResultData.getHyperlink(event.getId(), event.getId(), AtsUtil.getAtsBranch().getId()),
Artifacts.semmicolonArts(event.getUsers()), OseeNotifyUsersJob.getHyperlink(event)));
if (sendNotifications) {
OseeNotificationManager.getInstance().addNotificationEvent(event);
}
}
}
rd.addRaw(AHTML.endMultiColumnTable());
rd.report(getName() + " - (" + numEvents + " Events)");
if (sendNotifications) {
OseeNotificationManager.getInstance().sendNotifications();
AWorkbench.popup("Complete", numEvents + " Notifications Sent");
}
} catch (OseeCoreException ex) {
OseeLog.log(AtsPlugin.class, OseeLevel.SEVERE_POPUP, ex);
}
}
};
}
|