use of com.liferay.ide.kaleo.core.model.ActionTimer in project liferay-ide by liferay.
the class NotificationsDiagramNodeEditHandlerFactory method getNotifications.
protected List<ActionNotification> getNotifications() {
ElementList<ActionNotification> notifications = null;
ActionTimer actionTimer = getModelElement().nearest(ActionTimer.class);
if (actionTimer != null) {
notifications = actionTimer.getNotifications();
}
return notifications;
}
use of com.liferay.ide.kaleo.core.model.ActionTimer in project liferay-ide by liferay.
the class WorkflowNodeAddHandlerFactory method create.
@Override
public List<SapphireActionHandler> create() {
List<SapphireActionHandler> handlers = new ArrayList<>();
if (getModelElement() instanceof Task) {
Task task = getModelElement().nearest(Task.class);
handlers.add(new SapphireActionHandler() {
@Override
public void init(SapphireAction action, ActionHandlerDef def) {
super.init(action, def);
addImage(Action.TYPE.image());
setLabel("Task Action");
}
@Override
protected Object run(Presentation context) {
Action newAction = task.getTaskActions().insert();
ActionsListAddActionHandler.addActionDefaults(newAction);
return newAction;
}
});
handlers.add(new SapphireActionHandler() {
@Override
public void init(SapphireAction action, ActionHandlerDef def) {
super.init(action, def);
addImage(ActionNotification.TYPE.image());
setLabel("Task Notification");
}
@Override
protected Object run(Presentation context) {
ActionNotification newTaskNotificaction = task.getTaskNotifications().insert();
NotificationsListAddActionHandler.addNotificationDefaults(newTaskNotificaction);
return newTaskNotificaction;
}
});
} else {
ActionTimer actionTimer = getModelElement().nearest(ActionTimer.class);
handlers.add(new SapphireActionHandler() {
@Override
public void init(SapphireAction action, ActionHandlerDef def) {
super.init(action, def);
addImage(Action.TYPE.image());
setLabel("Action");
}
@Override
protected Object run(Presentation context) {
Action newAction = actionTimer.getActions().insert();
ActionsListAddActionHandler.addActionDefaults(newAction);
return newAction;
}
});
handlers.add(new SapphireActionHandler() {
@Override
public void init(SapphireAction action, ActionHandlerDef def) {
super.init(action, def);
addImage(Notification.TYPE.image());
setLabel("Notification");
}
@Override
protected Object run(Presentation context) {
ActionNotification newNotificaction = actionTimer.getNotifications().insert();
NotificationsListAddActionHandler.addNotificationDefaults(newNotificaction);
return newNotificaction;
}
});
}
return handlers;
}
use of com.liferay.ide.kaleo.core.model.ActionTimer 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");
}
use of com.liferay.ide.kaleo.core.model.ActionTimer in project liferay-ide by liferay.
the class ActionsDiagramNodeEditHandlerFactory method getActions.
protected ElementList<Action> getActions() {
ElementList<Action> actions = null;
ActionTimer actionTimer = getModelElement().nearest(ActionTimer.class);
if (actionTimer != null) {
actions = actionTimer.getActions();
}
return actions;
}
use of com.liferay.ide.kaleo.core.model.ActionTimer in project liferay-ide by liferay.
the class ActionsListAddActionHandler method addActionDefaults.
public static void addActionDefaults(Action newAction) {
Node[] actions = new Node[0];
if (newAction.nearest(Task.class) != null) {
Task task = newAction.nearest(Task.class);
actions = task.getTaskActions().toArray(new Node[0]);
} else {
ActionTimer actionTimer = newAction.nearest(ActionTimer.class);
actions = actionTimer.getActions().toArray(new Node[0]);
}
String newName = getDefaultName("newAction1", newAction, actions);
String defaultScriptLanguage = KaleoModelUtil.getDefaultValue(newAction, KaleoCore.DEFAULT_SCRIPT_LANGUAGE_KEY, ScriptLanguageType.GROOVY);
newAction.setName(newName);
newAction.setScriptLanguage(defaultScriptLanguage);
newAction.setExecutionType(Executable.DEFAULT_EXECUTION_TYPE);
if (newAction.nearest(Task.class) != null) {
newAction.setScript("/* specify task action script */");
} else {
newAction.setScript("/* specify action script */");
}
}
Aggregations