use of org.activiti.bpmn.model.SequenceFlow in project Activiti by Activiti.
the class AbstractActivitiTestCase method createTwoTasksTestProcess.
public BpmnModel createTwoTasksTestProcess() {
BpmnModel model = new BpmnModel();
org.activiti.bpmn.model.Process process = new org.activiti.bpmn.model.Process();
model.addProcess(process);
process.setId("twoTasksProcess");
process.setName("The two tasks process");
StartEvent startEvent = new StartEvent();
startEvent.setId("start");
process.addFlowElement(startEvent);
UserTask userTask = new UserTask();
userTask.setName("The First Task");
userTask.setId("task1");
userTask.setAssignee("kermit");
process.addFlowElement(userTask);
UserTask userTask2 = new UserTask();
userTask2.setName("The Second Task");
userTask2.setId("task2");
userTask2.setAssignee("kermit");
process.addFlowElement(userTask2);
EndEvent endEvent = new EndEvent();
endEvent.setId("theEnd");
process.addFlowElement(endEvent);
process.addFlowElement(new SequenceFlow("start", "task1"));
process.addFlowElement(new SequenceFlow("start", "task2"));
process.addFlowElement(new SequenceFlow("task1", "theEnd"));
process.addFlowElement(new SequenceFlow("task2", "theEnd"));
return model;
}
use of org.activiti.bpmn.model.SequenceFlow in project Activiti by Activiti.
the class BpmnAutoLayout method translateNestedSubprocessElements.
protected void translateNestedSubprocessElements(SubProcess subProcess) {
GraphicInfo subProcessGraphicInfo = bpmnModel.getLocationMap().get(subProcess.getId());
double subProcessX = subProcessGraphicInfo.getX();
double subProcessY = subProcessGraphicInfo.getY();
List<SubProcess> nestedSubProcesses = new ArrayList<SubProcess>();
for (FlowElement flowElement : subProcess.getFlowElements()) {
if (flowElement instanceof SequenceFlow) {
List<GraphicInfo> graphicInfos = bpmnModel.getFlowLocationMap().get(flowElement.getId());
for (GraphicInfo graphicInfo : graphicInfos) {
graphicInfo.setX(graphicInfo.getX() + subProcessX + subProcessMargin);
graphicInfo.setY(graphicInfo.getY() + subProcessY + subProcessMargin);
}
} else if (flowElement instanceof DataObject == false) {
// Regular element
GraphicInfo graphicInfo = bpmnModel.getLocationMap().get(flowElement.getId());
graphicInfo.setX(graphicInfo.getX() + subProcessX + subProcessMargin);
graphicInfo.setY(graphicInfo.getY() + subProcessY + subProcessMargin);
}
if (flowElement instanceof SubProcess) {
nestedSubProcesses.add((SubProcess) flowElement);
}
}
// Continue for next level of nested subprocesses
for (SubProcess nestedSubProcess : nestedSubProcesses) {
translateNestedSubprocessElements(nestedSubProcess);
}
}
use of org.activiti.bpmn.model.SequenceFlow in project Activiti by Activiti.
the class BpmnAutoLayout method layout.
protected void layout(FlowElementsContainer flowElementsContainer) {
graph = new mxGraph();
cellParent = graph.getDefaultParent();
graph.getModel().beginUpdate();
// Subprocesses are handled in a new instance of BpmnAutoLayout, hence they instantiations of new maps here.
handledFlowElements = new HashMap<String, FlowElement>();
handledArtifacts = new HashMap<String, Artifact>();
generatedVertices = new HashMap<String, Object>();
generatedSequenceFlowEdges = new HashMap<String, Object>();
generatedAssociationEdges = new HashMap<String, Object>();
// Associations are gathered and processed afterwards, because we must be sure we already found source and target
associations = new HashMap<String, Association>();
// Text Annotations are gathered and processed afterwards, because we must be sure we already found the parent.
textAnnotations = new HashMap<String, TextAnnotation>();
// Sequence flow are gathered and processed afterwards,because we mustbe sure we already found source and target
sequenceFlows = new HashMap<String, SequenceFlow>();
// Boundary events are gathered and processed afterwards, because we must be sure we have its parent
boundaryEvents = new ArrayList<BoundaryEvent>();
// Process all elements
for (FlowElement flowElement : flowElementsContainer.getFlowElements()) {
if (flowElement instanceof SequenceFlow) {
handleSequenceFlow((SequenceFlow) flowElement);
} else if (flowElement instanceof Event) {
handleEvent(flowElement);
} else if (flowElement instanceof Gateway) {
createGatewayVertex(flowElement);
} else if (flowElement instanceof Task || flowElement instanceof CallActivity) {
handleActivity(flowElement);
} else if (flowElement instanceof SubProcess) {
handleSubProcess(flowElement);
}
handledFlowElements.put(flowElement.getId(), flowElement);
}
// process artifacts
for (Artifact artifact : flowElementsContainer.getArtifacts()) {
if (artifact instanceof Association) {
handleAssociation((Association) artifact);
} else if (artifact instanceof TextAnnotation) {
handleTextAnnotation((TextAnnotation) artifact);
}
handledArtifacts.put(artifact.getId(), artifact);
}
// Process gathered elements
handleBoundaryEvents();
handleSequenceFlow();
handleAssociations();
// All elements are now put in the graph. Let's layout them!
CustomLayout layout = new CustomLayout(graph, SwingConstants.WEST);
layout.setIntraCellSpacing(100.0);
layout.setResizeParent(true);
layout.setFineTuning(true);
layout.setParentBorder(20);
layout.setMoveParent(true);
layout.setDisableEdgeStyle(false);
layout.setUseBoundingBox(true);
layout.execute(graph.getDefaultParent());
graph.getModel().endUpdate();
generateDiagramInterchangeElements();
}
use of org.activiti.bpmn.model.SequenceFlow in project Activiti by Activiti.
the class BpmnJsonConverterUtil method parseListeners.
protected static void parseListeners(JsonNode listenersNode, BaseElement element, boolean isTaskListener) {
if (listenersNode == null)
return;
listenersNode = validateIfNodeIsTextual(listenersNode);
for (JsonNode listenerNode : listenersNode) {
listenerNode = validateIfNodeIsTextual(listenerNode);
JsonNode eventNode = listenerNode.get(PROPERTY_LISTENER_EVENT);
if (eventNode != null && !eventNode.isNull() && StringUtils.isNotEmpty(eventNode.asText())) {
ActivitiListener listener = new ActivitiListener();
listener.setEvent(eventNode.asText());
if (StringUtils.isNotEmpty(getValueAsString(PROPERTY_LISTENER_CLASS_NAME, listenerNode))) {
listener.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_CLASS);
listener.setImplementation(getValueAsString(PROPERTY_LISTENER_CLASS_NAME, listenerNode));
} else if (StringUtils.isNotEmpty(getValueAsString(PROPERTY_LISTENER_EXPRESSION, listenerNode))) {
listener.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_EXPRESSION);
listener.setImplementation(getValueAsString(PROPERTY_LISTENER_EXPRESSION, listenerNode));
} else if (StringUtils.isNotEmpty(getValueAsString(PROPERTY_LISTENER_DELEGATE_EXPRESSION, listenerNode))) {
listener.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION);
listener.setImplementation(getValueAsString(PROPERTY_LISTENER_DELEGATE_EXPRESSION, listenerNode));
}
JsonNode fieldsNode = listenerNode.get(PROPERTY_LISTENER_FIELDS);
if (fieldsNode != null) {
for (JsonNode fieldNode : fieldsNode) {
JsonNode nameNode = fieldNode.get(PROPERTY_FIELD_NAME);
if (nameNode != null && !nameNode.isNull() && StringUtils.isNotEmpty(nameNode.asText())) {
FieldExtension fieldExtension = new FieldExtension();
fieldExtension.setFieldName(nameNode.asText());
fieldExtension.setStringValue(getValueAsString(PROPERTY_FIELD_STRING_VALUE, fieldNode));
if (StringUtils.isEmpty(fieldExtension.getStringValue())) {
fieldExtension.setStringValue(getValueAsString(PROPERTY_FIELD_STRING, fieldNode));
}
if (StringUtils.isEmpty(fieldExtension.getStringValue())) {
fieldExtension.setExpression(getValueAsString(PROPERTY_FIELD_EXPRESSION, fieldNode));
}
listener.getFieldExtensions().add(fieldExtension);
}
}
}
if (element instanceof Process) {
((Process) element).getExecutionListeners().add(listener);
} else if (element instanceof SequenceFlow) {
((SequenceFlow) element).getExecutionListeners().add(listener);
} else if (element instanceof UserTask) {
if (isTaskListener) {
((UserTask) element).getTaskListeners().add(listener);
} else {
((UserTask) element).getExecutionListeners().add(listener);
}
} else if (element instanceof FlowElement) {
((FlowElement) element).getExecutionListeners().add(listener);
}
}
}
}
use of org.activiti.bpmn.model.SequenceFlow in project Activiti by Activiti.
the class SimpleConverterTest method validateModel.
private void validateModel(BpmnModel model) {
assertThat(model.getMainProcess().getId()).isEqualTo("simpleProcess");
assertThat(model.getMainProcess().getName()).isEqualTo("Simple process");
assertThat(model.getMainProcess().isExecutable()).isEqualTo(true);
FlowElement flowElement = model.getMainProcess().getFlowElement("flow1", true);
assertThat(flowElement).isNotNull();
assertThat(flowElement).isInstanceOf(SequenceFlow.class);
assertThat(flowElement.getId()).isEqualTo("flow1");
flowElement = model.getMainProcess().getFlowElement("catchEvent", true);
assertThat(flowElement).isNotNull();
assertThat(flowElement).isInstanceOf(IntermediateCatchEvent.class);
assertThat(flowElement.getId()).isEqualTo("catchEvent");
IntermediateCatchEvent catchEvent = (IntermediateCatchEvent) flowElement;
assertThat(catchEvent.getEventDefinitions().size() == 1).isTrue();
EventDefinition eventDefinition = catchEvent.getEventDefinitions().get(0);
assertThat(eventDefinition).isInstanceOf(TimerEventDefinition.class);
TimerEventDefinition timerDefinition = (TimerEventDefinition) eventDefinition;
assertThat(timerDefinition.getTimeDuration()).isEqualTo("PT5M");
flowElement = model.getMainProcess().getFlowElement("flow1Condition", true);
assertThat(flowElement).isNotNull();
assertThat(flowElement).isInstanceOf(SequenceFlow.class);
assertThat(flowElement.getId()).isEqualTo("flow1Condition");
SequenceFlow flow = (SequenceFlow) flowElement;
assertThat(flow.getConditionExpression()).isEqualTo("${number <= 1}");
}
Aggregations