use of org.activiti.bpmn.model.SequenceFlow in project Activiti by Activiti.
the class BpmnParse method processFlowElements.
public void processFlowElements(Collection<FlowElement> flowElements) {
// Parsing the elements is done in a strict order of types,
// as otherwise certain information might not be available when parsing
// a certain type.
// Using lists as we want to keep the order in which they are defined
List<SequenceFlow> sequenceFlowToParse = new ArrayList<SequenceFlow>();
List<BoundaryEvent> boundaryEventsToParse = new ArrayList<BoundaryEvent>();
// Flow elements that depend on other elements are parse after the first run-through
List<FlowElement> defferedFlowElementsToParse = new ArrayList<FlowElement>();
// Activities are parsed first
for (FlowElement flowElement : flowElements) {
// Sequence flow are also flow elements, but are only parsed once every activity is found
if (flowElement instanceof SequenceFlow) {
sequenceFlowToParse.add((SequenceFlow) flowElement);
} else if (flowElement instanceof BoundaryEvent) {
boundaryEventsToParse.add((BoundaryEvent) flowElement);
} else if (flowElement instanceof Event) {
defferedFlowElementsToParse.add(flowElement);
} else {
bpmnParserHandlers.parseElement(this, flowElement);
}
}
// Deferred elements
for (FlowElement flowElement : defferedFlowElementsToParse) {
bpmnParserHandlers.parseElement(this, flowElement);
}
// Boundary events are parsed after all the regular activities are parsed
for (BoundaryEvent boundaryEvent : boundaryEventsToParse) {
bpmnParserHandlers.parseElement(this, boundaryEvent);
}
// sequence flows
for (SequenceFlow sequenceFlow : sequenceFlowToParse) {
bpmnParserHandlers.parseElement(this, sequenceFlow);
}
}
use of org.activiti.bpmn.model.SequenceFlow in project Activiti by Activiti.
the class BpmnParse method createBPMNEdge.
public void createBPMNEdge(String key, List<GraphicInfo> graphicList) {
FlowElement flowElement = bpmnModel.getFlowElement(key);
if (flowElement instanceof SequenceFlow) {
SequenceFlow sequenceFlow = (SequenceFlow) flowElement;
List<Integer> waypoints = new ArrayList<Integer>();
for (GraphicInfo waypointInfo : graphicList) {
waypoints.add((int) waypointInfo.getX());
waypoints.add((int) waypointInfo.getY());
}
sequenceFlow.setWaypoints(waypoints);
} else if (bpmnModel.getArtifact(key) != null) {
// it's an association, so nothing to do
} else {
LOGGER.warn("Invalid reference in 'bpmnElement' attribute, sequenceFlow " + key + " not found");
}
}
use of org.activiti.bpmn.model.SequenceFlow in project Activiti by Activiti.
the class ProcessDefinitionPersistenceTest method testProcessDefinitionIntrospection.
public void testProcessDefinitionIntrospection() {
String deploymentId = repositoryService.createDeployment().addClasspathResource("org/activiti/engine/test/db/processOne.bpmn20.xml").deploy().getId();
String procDefId = repositoryService.createProcessDefinitionQuery().singleResult().getId();
ProcessDefinition processDefinition = ((RepositoryServiceImpl) repositoryService).getDeployedProcessDefinition(procDefId);
assertThat(processDefinition.getId()).isEqualTo(procDefId);
assertThat(processDefinition.getName()).isEqualTo("Process One");
Process process = repositoryService.getBpmnModel(processDefinition.getId()).getMainProcess();
StartEvent startElement = (StartEvent) process.getFlowElement("start");
assertThat(startElement).isNotNull();
assertThat(startElement.getId()).isEqualTo("start");
assertThat(startElement.getName()).isEqualTo("S t a r t");
assertThat(startElement.getDocumentation()).isEqualTo("the start event");
List<SequenceFlow> outgoingFlows = startElement.getOutgoingFlows();
assertThat(outgoingFlows).hasSize(1);
assertThat(outgoingFlows.get(0).getConditionExpression()).isEqualTo("${a == b}");
EndEvent endElement = (EndEvent) process.getFlowElement("end");
assertThat(endElement).isNotNull();
assertThat(endElement.getId()).isEqualTo("end");
assertThat(outgoingFlows.get(0).getId()).isEqualTo("flow1");
assertThat(outgoingFlows.get(0).getName()).isEqualTo("Flow One");
assertThat(outgoingFlows.get(0).getDocumentation()).isEqualTo("The only transitions in the process");
assertThat(outgoingFlows.get(0).getSourceFlowElement()).isSameAs(startElement);
assertThat(outgoingFlows.get(0).getTargetFlowElement()).isSameAs(endElement);
repositoryService.deleteDeployment(deploymentId);
}
use of org.activiti.bpmn.model.SequenceFlow in project Activiti by Activiti.
the class TestProcessUtil method createTwoTasksBpmnModel.
public static BpmnModel createTwoTasksBpmnModel() {
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 EventJavaTest method testStartEventWithExecutionListener.
public void testStartEventWithExecutionListener() throws Exception {
BpmnModel bpmnModel = new BpmnModel();
Process process = new Process();
process.setId("simpleProcess");
process.setName("Very simple process");
bpmnModel.getProcesses().add(process);
StartEvent startEvent = new StartEvent();
startEvent.setId("startEvent1");
TimerEventDefinition timerDef = new TimerEventDefinition();
timerDef.setTimeDuration("PT5M");
startEvent.getEventDefinitions().add(timerDef);
ActivitiListener listener = new ActivitiListener();
listener.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_EXPRESSION);
listener.setImplementation("${test}");
listener.setEvent("end");
startEvent.getExecutionListeners().add(listener);
process.addFlowElement(startEvent);
UserTask task = new UserTask();
task.setId("reviewTask");
task.setAssignee("kermit");
process.addFlowElement(task);
SequenceFlow flow1 = new SequenceFlow();
flow1.setId("flow1");
flow1.setSourceRef("startEvent1");
flow1.setTargetRef("reviewTask");
process.addFlowElement(flow1);
EndEvent endEvent = new EndEvent();
endEvent.setId("endEvent1");
process.addFlowElement(endEvent);
byte[] xml = new BpmnXMLConverter().convertToXML(bpmnModel);
new BpmnXMLConverter().validateModel(new InputStreamSource(new ByteArrayInputStream(xml)));
Deployment deployment = repositoryService.createDeployment().name("test").addString("test.bpmn20.xml", new String(xml)).deploy();
repositoryService.deleteDeployment(deployment.getId());
}
Aggregations