use of com.liferay.ide.kaleo.core.model.JoinXor 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.JoinXor in project liferay-ide by liferay.
the class JoinXorNodeAddActionHandler method postDiagramNodePartAdded.
@Override
public void postDiagramNodePartAdded(NewNodeOp op, CanTransition newNodeFromWizard, CanTransition newNode) {
NewJoinXorNodeOp newJoinXorNodeOp = op.nearest(NewJoinXorNodeOp.class);
JoinXor newJoinXor = newNode.nearest(JoinXor.class);
WorkflowDefinition workflowDefinition = newJoinXor.nearest(WorkflowDefinition.class);
for (Node nodeName : newJoinXorNodeOp.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(newJoinXor.getName().content());
newTransition.setTarget(newJoinXor.getName().content());
}
}
}
}
if (newJoinXorNodeOp.getExitTransitionName().content() != null) {
Transition newTransition = newJoinXor.getTransitions().insert();
newTransition.setTarget(newJoinXorNodeOp.getExitTransitionName().content());
newTransition.setName(newJoinXorNodeOp.getExitTransitionName().content());
}
}
Aggregations