Search in sources :

Example 1 with NewForkNode

use of com.liferay.ide.kaleo.core.op.NewForkNode in project liferay-ide by liferay.

the class ForkNodeAddActionHandler method postDiagramNodePartAdded.

@Override
public void postDiagramNodePartAdded(NewNodeOp op, CanTransition newNodeFromWizard, CanTransition newNode) {
    NewForkNodeOp newForkOp = op.nearest(NewForkNodeOp.class);
    NewForkNode newForkNodeFromWizard = newNodeFromWizard.nearest(NewForkNode.class);
    Fork newFork = newNode.nearest(Fork.class);
    WorkflowDefinition workflowDefinition = newFork.nearest(WorkflowDefinition.class);
    if (newForkOp.isAddJoin().content(true)) {
        Join newJoin = workflowDefinition.getJoins().insert();
        String newJoinName = newForkNodeFromWizard.getName().content() + " Join";
        newJoin.setName(newJoinName);
        for (Node connectedNode : op.getConnectedNodes()) {
            for (WorkflowNode diagramNode : workflowDefinition.getDiagramNodes()) {
                Value<String> nodeName = connectedNode.getName();
                if (nodeName.content().equals(diagramNode.getName().content())) {
                    CanTransition canTransition = diagramNode.nearest(CanTransition.class);
                    ElementList<Transition> transitions = canTransition.getTransitions();
                    Transition newTransition = transitions.insert();
                    newTransition.setName(newJoinName);
                    newTransition.setTarget(newJoinName);
                }
            }
        }
    }
}
Also used : Fork(com.liferay.ide.kaleo.core.model.Fork) Node(com.liferay.ide.kaleo.core.model.Node) NewForkNode(com.liferay.ide.kaleo.core.op.NewForkNode) WorkflowNode(com.liferay.ide.kaleo.core.model.WorkflowNode) CanTransition(com.liferay.ide.kaleo.core.model.CanTransition) Transition(com.liferay.ide.kaleo.core.model.Transition) WorkflowDefinition(com.liferay.ide.kaleo.core.model.WorkflowDefinition) Join(com.liferay.ide.kaleo.core.model.Join) CanTransition(com.liferay.ide.kaleo.core.model.CanTransition) NewForkNode(com.liferay.ide.kaleo.core.op.NewForkNode) NewForkNodeOp(com.liferay.ide.kaleo.core.op.NewForkNodeOp) WorkflowNode(com.liferay.ide.kaleo.core.model.WorkflowNode)

Aggregations

CanTransition (com.liferay.ide.kaleo.core.model.CanTransition)1 Fork (com.liferay.ide.kaleo.core.model.Fork)1 Join (com.liferay.ide.kaleo.core.model.Join)1 Node (com.liferay.ide.kaleo.core.model.Node)1 Transition (com.liferay.ide.kaleo.core.model.Transition)1 WorkflowDefinition (com.liferay.ide.kaleo.core.model.WorkflowDefinition)1 WorkflowNode (com.liferay.ide.kaleo.core.model.WorkflowNode)1 NewForkNode (com.liferay.ide.kaleo.core.op.NewForkNode)1 NewForkNodeOp (com.liferay.ide.kaleo.core.op.NewForkNodeOp)1