use of com.liferay.ide.kaleo.core.model.Task in project liferay-ide by liferay.
the class NewNodeOpWizard method performPostDiagramNodeAdded.
protected void performPostDiagramNodeAdded() {
NewNodeOp newNodeOp = element().nearest(NewNodeOp.class);
CanTransition newNode = newNodeOp.adapt(CanTransition.class);
CanTransition node = _diagramNodePart.getLocalModelElement().nearest(CanTransition.class);
WorkflowDefinition workflowDefinition = node.nearest(WorkflowDefinition.class);
if ((newNode != null) && (node != null)) {
Value<String> newNodeName = newNode.getName();
node.setName(newNodeName.content());
if (newNodeOp.getConnectedNodes().size() > 0) {
for (Node diagramNode : newNodeOp.getConnectedNodes()) {
Value<String> nodeName = diagramNode.getName();
String diagramNodeName = nodeName.content(true);
if (diagramNode instanceof ConditionForOp) {
ElementList<Condition> conditions = workflowDefinition.getConditions();
Condition insertCondition = conditions.insert();
insertCondition.setName(diagramNodeName);
} else if (diagramNode instanceof ForkForOp) {
ElementList<Fork> forks = workflowDefinition.getForks();
Fork insertFork = forks.insert();
insertFork.setName(diagramNodeName);
} else if (diagramNode instanceof JoinForOp) {
ElementList<Join> joins = workflowDefinition.getJoins();
Join insertJoin = joins.insert();
insertJoin.setName(diagramNodeName);
} else if (diagramNode instanceof JoinXorForOp) {
ElementList<JoinXor> joinXors = workflowDefinition.getJoinXors();
JoinXor insertJoinXor = joinXors.insert();
insertJoinXor.setName(diagramNodeName);
} else if (diagramNode instanceof StateForOp) {
ElementList<State> states = workflowDefinition.getStates();
State insertState = states.insert();
insertState.setName(diagramNodeName);
} else if (diagramNode instanceof TaskForOp) {
ElementList<Task> tasks = workflowDefinition.getTasks();
Task insertTask = tasks.insert();
insertTask.setName(diagramNodeName);
}
if (diagramNode instanceof ChooseDiagramNode || node instanceof Condition || node instanceof Fork || node instanceof State || node instanceof Task) {
Transition newTransition = node.getTransitions().insert();
newTransition.setName(diagramNodeName);
newTransition.setTarget(diagramNodeName);
} else {
CanTransition canTransition = diagramNode.nearest(CanTransition.class);
ElementList<Transition> transition = canTransition.getTransitions();
Transition joinTransition = transition.insert();
joinTransition.setName(node.getName().content());
joinTransition.setTarget(node.getName().content());
}
}
}
}
_actionHandler.postDiagramNodePartAdded(element(), newNode, node);
}
use of com.liferay.ide.kaleo.core.model.Task in project liferay-ide by liferay.
the class TaskScriptedAssignmentCondition method _task.
private Task _task() {
Task retval = null;
Element modelElement = getPart().getLocalModelElement();
retval = modelElement.nearest(Task.class);
return retval;
}
use of com.liferay.ide.kaleo.core.model.Task in project liferay-ide by liferay.
the class TaskNotificationsDiagramNodeEditHandlerFactory method getNotifications.
@Override
protected List<ActionNotification> getNotifications() {
ListFactory<ActionNotification> factory = ListFactory.start();
Task task = getModelElement().nearest(Task.class);
if (task != null) {
ElementList<TaskActionNotification> taskNotifiations = task.getTaskNotifications();
for (TaskActionNotification notification : taskNotifiations) {
factory.add(notification);
}
}
return factory.result();
}
use of com.liferay.ide.kaleo.core.model.Task 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.Task 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");
}
Aggregations