Search in sources :

Example 1 with NotificationTransport

use of com.liferay.ide.kaleo.core.model.NotificationTransport in project liferay-ide by liferay.

the class NotificationsListAddActionHandler method addNotificationDefaults.

public static void addNotificationDefaults(ActionNotification newNotification) {
    String defaultTemplateLanguage = KaleoModelUtil.getDefaultValue(newNotification, KaleoCore.DEFAULT_TEMPLATE_LANGUAGE_KEY, TemplateLanguageType.FREEMARKER);
    Node[] nodes = new Node[0];
    if (newNotification.nearest(Task.class) != null) {
        Task task = newNotification.nearest(Task.class);
        ElementList<TaskActionNotification> taskNotifications = task.getTaskNotifications();
        nodes = taskNotifications.toArray(new Node[0]);
    } else {
        ActionTimer actionTimer = newNotification.nearest(ActionTimer.class);
        ElementList<ActionNotification> actionNotifications = actionTimer.getNotifications();
        nodes = actionNotifications.toArray(new Node[0]);
    }
    String newName = getDefaultName("newNotification1", newNotification, nodes);
    newNotification.setName(newName);
    newNotification.setTemplateLanguage(defaultTemplateLanguage);
    newNotification.setExecutionType(Executable.DEFAULT_EXECUTION_TYPE);
    if (newNotification.nearest(Task.class) != null) {
        newNotification.setTemplate("/* specify task notification template */");
    } else {
        newNotification.setTemplate("/* specify notification template */");
    }
    ElementList<NotificationTransport> notificationTransports = newNotification.getNotificationTransports();
    NotificationTransport insertTransport = notificationTransports.insert();
    insertTransport.setNotificationTransport("email");
}
Also used : ActionTimer(com.liferay.ide.kaleo.core.model.ActionTimer) NotificationTransport(com.liferay.ide.kaleo.core.model.NotificationTransport) Task(com.liferay.ide.kaleo.core.model.Task) Node(com.liferay.ide.kaleo.core.model.Node) TaskActionNotification(com.liferay.ide.kaleo.core.model.TaskActionNotification) ActionNotification(com.liferay.ide.kaleo.core.model.ActionNotification) TaskActionNotification(com.liferay.ide.kaleo.core.model.TaskActionNotification)

Example 2 with NotificationTransport

use of com.liferay.ide.kaleo.core.model.NotificationTransport in project liferay-ide by liferay.

the class NotificationTypesDerivedValueService method compute.

@Override
protected String compute() {
    StringBuilder data = new StringBuilder();
    List<NotificationTransport> transports = context(Notification.class).getNotificationTransports();
    for (NotificationTransport transport : transports) {
        if (data.length() != 0) {
            data.append(',');
        }
        data.append(transport.getNotificationTransport().content());
    }
    return data.toString();
}
Also used : NotificationTransport(com.liferay.ide.kaleo.core.model.NotificationTransport) Notification(com.liferay.ide.kaleo.core.model.Notification)

Aggregations

NotificationTransport (com.liferay.ide.kaleo.core.model.NotificationTransport)2 ActionNotification (com.liferay.ide.kaleo.core.model.ActionNotification)1 ActionTimer (com.liferay.ide.kaleo.core.model.ActionTimer)1 Node (com.liferay.ide.kaleo.core.model.Node)1 Notification (com.liferay.ide.kaleo.core.model.Notification)1 Task (com.liferay.ide.kaleo.core.model.Task)1 TaskActionNotification (com.liferay.ide.kaleo.core.model.TaskActionNotification)1