use of org.ovirt.engine.core.common.EventNotificationEntity in project ovirt-engine by oVirt.
the class UserEventNotifierListModel method manageEvents.
public void manageEvents() {
EventNotificationModel model = new EventNotificationModel();
setWindow(model);
model.setTitle(ConstantsManager.getInstance().getConstants().addEventNotificationTitle());
model.setHelpTag(HelpTag.add_event_notification);
// $NON-NLS-1$
model.setHashName("add_event_notification");
ArrayList<EventNotificationEntity> eventTypes = ApplicationModeHelper.getModeSpecificEventNotificationTypeList();
Map<EventNotificationEntity, HashSet<AuditLogType>> availableEvents = AsyncDataProvider.getInstance().getAvailableNotificationEvents();
Translator translator = EnumTranslator.getInstance();
ArrayList<SelectionTreeNodeModel> list = new ArrayList<>();
Collection<EventSubscriber> items = getItems() == null ? new ArrayList<EventSubscriber>() : getItems();
for (EventNotificationEntity eventType : eventTypes) {
SelectionTreeNodeModel stnm = new SelectionTreeNodeModel();
stnm.setTitle(eventType.toString());
stnm.setDescription(translator.translate(eventType));
list.add(stnm);
for (AuditLogType logtype : availableEvents.get(eventType)) {
SelectionTreeNodeModel eventGrp = new SelectionTreeNodeModel();
String description;
try {
description = translator.translate(logtype);
} catch (MissingResourceException e) {
description = logtype.toString();
}
eventGrp.setTitle(logtype.toString());
eventGrp.setDescription(description);
eventGrp.setParent(list.get(list.size() - 1));
eventGrp.setIsSelectedNotificationPrevent(true);
eventGrp.setIsSelectedNullable(false);
for (EventSubscriber es : items) {
if (es.getEventUpName().equals(logtype.toString())) {
eventGrp.setIsSelectedNullable(true);
break;
}
}
list.get(list.size() - 1).getChildren().add(eventGrp);
eventGrp.setIsSelectedNotificationPrevent(false);
}
if (list.get(list.size() - 1).getChildren().size() > 0) {
list.get(list.size() - 1).getChildren().get(0).updateParentSelection();
}
}
model.setEventGroupModels(list);
if (!StringHelper.isNullOrEmpty(getEntity().getEmail())) {
model.getEmail().setEntity(getEntity().getEmail());
} else if (items.size() > 0) {
model.getEmail().setEntity(items.iterator().next().getMethodAddress());
}
model.setOldEmail(model.getEmail().getEntity());
// $NON-NLS-1$
UICommand tempVar = UICommand.createDefaultOkUiCommand("OnSave", this);
model.getCommands().add(tempVar);
// $NON-NLS-1$
UICommand tempVar2 = UICommand.createCancelUiCommand("Cancel", this);
model.getCommands().add(tempVar2);
}
Aggregations