Search in sources :

Example 6 with Task

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);
}
Also used : Task(com.liferay.ide.kaleo.core.model.Task) Fork(com.liferay.ide.kaleo.core.model.Fork) JoinXor(com.liferay.ide.kaleo.core.model.JoinXor) JoinXorForOp(com.liferay.ide.kaleo.core.op.NewNodeOp.JoinXorForOp) ChooseDiagramNode(com.liferay.ide.kaleo.core.op.ChooseDiagramNode) Node(com.liferay.ide.kaleo.core.model.Node) StateForOp(com.liferay.ide.kaleo.core.op.NewNodeOp.StateForOp) CanTransition(com.liferay.ide.kaleo.core.model.CanTransition) ElementList(org.eclipse.sapphire.ElementList) ForkForOp(com.liferay.ide.kaleo.core.op.NewNodeOp.ForkForOp) ConditionForOp(com.liferay.ide.kaleo.core.op.NewNodeOp.ConditionForOp) Condition(com.liferay.ide.kaleo.core.model.Condition) WorkflowDefinition(com.liferay.ide.kaleo.core.model.WorkflowDefinition) Join(com.liferay.ide.kaleo.core.model.Join) ChooseDiagramNode(com.liferay.ide.kaleo.core.op.ChooseDiagramNode) State(com.liferay.ide.kaleo.core.model.State) NewNodeOp(com.liferay.ide.kaleo.core.op.NewNodeOp) CanTransition(com.liferay.ide.kaleo.core.model.CanTransition) Transition(com.liferay.ide.kaleo.core.model.Transition) JoinForOp(com.liferay.ide.kaleo.core.op.NewNodeOp.JoinForOp) TaskForOp(com.liferay.ide.kaleo.core.op.NewNodeOp.TaskForOp)

Example 7 with Task

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;
}
Also used : Task(com.liferay.ide.kaleo.core.model.Task) Element(org.eclipse.sapphire.Element)

Example 8 with Task

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();
}
Also used : Task(com.liferay.ide.kaleo.core.model.Task) 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 9 with Task

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;
}
Also used : ActionHandlerDef(org.eclipse.sapphire.ui.def.ActionHandlerDef) ActionTimer(com.liferay.ide.kaleo.core.model.ActionTimer) Task(com.liferay.ide.kaleo.core.model.Task) Action(com.liferay.ide.kaleo.core.model.Action) SapphireAction(org.eclipse.sapphire.ui.SapphireAction) SapphireAction(org.eclipse.sapphire.ui.SapphireAction) ArrayList(java.util.ArrayList) Presentation(org.eclipse.sapphire.ui.Presentation) SapphireActionHandler(org.eclipse.sapphire.ui.SapphireActionHandler) ActionNotification(com.liferay.ide.kaleo.core.model.ActionNotification)

Example 10 with Task

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");
}
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)

Aggregations

Task (com.liferay.ide.kaleo.core.model.Task)13 Action (com.liferay.ide.kaleo.core.model.Action)4 ActionNotification (com.liferay.ide.kaleo.core.model.ActionNotification)4 WorkflowDefinition (com.liferay.ide.kaleo.core.model.WorkflowDefinition)4 ActionTimer (com.liferay.ide.kaleo.core.model.ActionTimer)3 Node (com.liferay.ide.kaleo.core.model.Node)3 State (com.liferay.ide.kaleo.core.model.State)3 Transition (com.liferay.ide.kaleo.core.model.Transition)3 Element (org.eclipse.sapphire.Element)3 Condition (com.liferay.ide.kaleo.core.model.Condition)2 Fork (com.liferay.ide.kaleo.core.model.Fork)2 Join (com.liferay.ide.kaleo.core.model.Join)2 Scriptable (com.liferay.ide.kaleo.core.model.Scriptable)2 TaskActionNotification (com.liferay.ide.kaleo.core.model.TaskActionNotification)2 ArrayList (java.util.ArrayList)2 Assignable (com.liferay.ide.kaleo.core.model.Assignable)1 CanTransition (com.liferay.ide.kaleo.core.model.CanTransition)1 JoinXor (com.liferay.ide.kaleo.core.model.JoinXor)1 NotificationTransport (com.liferay.ide.kaleo.core.model.NotificationTransport)1 Position (com.liferay.ide.kaleo.core.model.Position)1