Search in sources :

Example 1 with Join

use of com.liferay.ide.kaleo.core.model.Join 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)

Example 2 with Join

use of com.liferay.ide.kaleo.core.model.Join 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 3 with Join

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

the class JoinNodeAddActionHandler method postDiagramNodePartAdded.

@Override
public void postDiagramNodePartAdded(NewNodeOp op, CanTransition newNodeFromWizard, CanTransition newNode) {
    NewJoinNodeOp newJoinNodeOp = op.nearest(NewJoinNodeOp.class);
    Join newJoin = newNode.nearest(Join.class);
    WorkflowDefinition workflowDefinition = newJoin.nearest(WorkflowDefinition.class);
    for (Node nodeName : newJoinNodeOp.getConnectedNodes()) {
        for (WorkflowNode diagramNode : workflowDefinition.getDiagramNodes()) {
            if (nodeName.getName().content() != null) {
                String name = nodeName.getName().content();
                if (name.equals(diagramNode.getName().content())) {
                    CanTransition canTransition = diagramNode.nearest(CanTransition.class);
                    Transition newTransition = canTransition.getTransitions().insert();
                    newTransition.setName(newJoin.getName().content());
                    newTransition.setTarget(newJoin.getName().content());
                }
            }
        }
    }
    if (newJoinNodeOp.getExitTransitionName().content() != null) {
        Transition newTransition = newJoin.getTransitions().insert();
        newTransition.setTarget(newJoinNodeOp.getExitTransitionName().content());
        newTransition.setName(newJoinNodeOp.getExitTransitionName().content());
    }
}
Also used : Node(com.liferay.ide.kaleo.core.model.Node) WorkflowNode(com.liferay.ide.kaleo.core.model.WorkflowNode) CanTransition(com.liferay.ide.kaleo.core.model.CanTransition) Transition(com.liferay.ide.kaleo.core.model.Transition) Join(com.liferay.ide.kaleo.core.model.Join) WorkflowDefinition(com.liferay.ide.kaleo.core.model.WorkflowDefinition) CanTransition(com.liferay.ide.kaleo.core.model.CanTransition) NewJoinNodeOp(com.liferay.ide.kaleo.core.op.NewJoinNodeOp) WorkflowNode(com.liferay.ide.kaleo.core.model.WorkflowNode)

Example 4 with Join

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

the class NodeNameListener method handleTypedEvent.

@Override
protected void handleTypedEvent(PropertyContentEvent event) {
    Property property = event.property();
    Element element = property.element();
    WorkflowDefinition workflow = element.adapt(WorkflowDefinition.class);
    Map<String, String> eventInfo = new HashMap<>();
    event.fillTracingInfo(eventInfo);
    String oldName = eventInfo.get("before");
    if (oldName == null) {
        oldName = _lastNodeNames.get(property);
    }
    String newName = eventInfo.get("after");
    List<Transition> allTransitions = new ArrayList<>();
    if (workflow != null) {
        ElementList<Condition> allConditions = workflow.getConditions();
        ElementList<Fork> allForks = workflow.getForks();
        ElementList<Join> allJoins = workflow.getJoins();
        ElementList<State> allStates = workflow.getStates();
        ElementList<Task> allTasks = workflow.getTasks();
        for (Condition condition : allConditions) {
            ElementList<Transition> conditionTransitions = condition.getTransitions();
            for (Transition transition : conditionTransitions) {
                allTransitions.add(transition);
            }
        }
        for (Fork fork : allForks) {
            ElementList<Transition> forkTransitions = fork.getTransitions();
            for (Transition transition : forkTransitions) {
                allTransitions.add(transition);
            }
        }
        for (Join join : allJoins) {
            ElementList<Transition> joinTransitions = join.getTransitions();
            for (Transition transition : joinTransitions) {
                allTransitions.add(transition);
            }
        }
        for (State state : allStates) {
            ElementList<Transition> stateTransitions = state.getTransitions();
            for (Transition transition : stateTransitions) {
                allTransitions.add(transition);
            }
        }
        for (Task task : allTasks) {
            ElementList<Transition> taskTransitions = task.getTransitions();
            for (Transition transition : taskTransitions) {
                allTransitions.add(transition);
            }
        }
    }
    for (Transition transition : allTransitions) {
        String targetName = transition.getTarget().toString();
        if (targetName.equals(oldName)) {
            if (newName != null) {
                transition.setTarget(newName);
                if (_lastNodeNames.containsKey(property)) {
                    _lastNodeNames.remove(property);
                }
            } else {
                _lastNodeNames.put(property, oldName);
            }
        }
    }
}
Also used : Condition(com.liferay.ide.kaleo.core.model.Condition) Task(com.liferay.ide.kaleo.core.model.Task) Fork(com.liferay.ide.kaleo.core.model.Fork) HashMap(java.util.HashMap) Element(org.eclipse.sapphire.Element) ArrayList(java.util.ArrayList) WorkflowDefinition(com.liferay.ide.kaleo.core.model.WorkflowDefinition) Join(com.liferay.ide.kaleo.core.model.Join) State(com.liferay.ide.kaleo.core.model.State) Transition(com.liferay.ide.kaleo.core.model.Transition) Property(org.eclipse.sapphire.Property)

Aggregations

Join (com.liferay.ide.kaleo.core.model.Join)4 Transition (com.liferay.ide.kaleo.core.model.Transition)4 WorkflowDefinition (com.liferay.ide.kaleo.core.model.WorkflowDefinition)4 CanTransition (com.liferay.ide.kaleo.core.model.CanTransition)3 Fork (com.liferay.ide.kaleo.core.model.Fork)3 Node (com.liferay.ide.kaleo.core.model.Node)3 Condition (com.liferay.ide.kaleo.core.model.Condition)2 State (com.liferay.ide.kaleo.core.model.State)2 Task (com.liferay.ide.kaleo.core.model.Task)2 WorkflowNode (com.liferay.ide.kaleo.core.model.WorkflowNode)2 JoinXor (com.liferay.ide.kaleo.core.model.JoinXor)1 ChooseDiagramNode (com.liferay.ide.kaleo.core.op.ChooseDiagramNode)1 NewForkNode (com.liferay.ide.kaleo.core.op.NewForkNode)1 NewForkNodeOp (com.liferay.ide.kaleo.core.op.NewForkNodeOp)1 NewJoinNodeOp (com.liferay.ide.kaleo.core.op.NewJoinNodeOp)1 NewNodeOp (com.liferay.ide.kaleo.core.op.NewNodeOp)1 ConditionForOp (com.liferay.ide.kaleo.core.op.NewNodeOp.ConditionForOp)1 ForkForOp (com.liferay.ide.kaleo.core.op.NewNodeOp.ForkForOp)1 JoinForOp (com.liferay.ide.kaleo.core.op.NewNodeOp.JoinForOp)1 JoinXorForOp (com.liferay.ide.kaleo.core.op.NewNodeOp.JoinXorForOp)1