org.activiti.bpmn.model.EndEvent Java Examples

The following examples show how to use org.activiti.bpmn.model.EndEvent. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AddBpmnModelTest.java    From CrazyWorkflowHandoutsActiviti6 with MIT License 7 votes vote down vote up
private static BpmnModel createProcessModel() {
	// 创建BPMN模型
	BpmnModel model = new BpmnModel();
	// 创建一个流程定义
	Process process = new Process();
	model.addProcess(process);
	process.setId("myProcess");
	process.setName("My Process");
	// 开始事件
	StartEvent startEvent = new StartEvent();
	startEvent.setId("startEvent");
	process.addFlowElement(startEvent);
	// 用户任务
	UserTask userTask = new UserTask();
	userTask.setName("User Task");
	userTask.setId("userTask");
	process.addFlowElement(userTask);
	// 结束事件
	EndEvent endEvent = new EndEvent();
	endEvent.setId("endEvent");
	process.addFlowElement(endEvent);		
	// 添加流程顺序
	process.addFlowElement(new SequenceFlow("startEvent", "userTask"));
	process.addFlowElement(new SequenceFlow("userTask", "endEvent"));
	return model;
}
 
Example #2
Source File: AddBpmnModelTest.java    From CrazyWorkflowHandoutsActiviti6 with MIT License 6 votes vote down vote up
private static BpmnModel createProcessModel() {
	// 创建BPMN模型
	BpmnModel model = new BpmnModel();
	// 创建一个流程定义
	Process process = new Process();
	model.addProcess(process);
	process.setId("myProcess");
	process.setName("My Process");
	// 开始事件
	StartEvent startEvent = new StartEvent();
	startEvent.setId("startEvent");
	process.addFlowElement(startEvent);
	// 用户任务
	UserTask userTask = new UserTask();
	userTask.setName("User Task");
	userTask.setId("userTask");
	process.addFlowElement(userTask);
	// 结束事件
	EndEvent endEvent = new EndEvent();
	endEvent.setId("endEvent");
	process.addFlowElement(endEvent);		
	// 添加流程顺序
	process.addFlowElement(new SequenceFlow("startEvent", "userTask"));
	process.addFlowElement(new SequenceFlow("userTask", "endEvent"));
	return model;
}
 
Example #3
Source File: TestProcessUtil.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
public static org.activiti.bpmn.model.Process createOneTaskProcess() {
  org.activiti.bpmn.model.Process process = new org.activiti.bpmn.model.Process();

  process.setId("oneTaskProcess");
  process.setName("The one task process");

  StartEvent startEvent = new StartEvent();
  startEvent.setId("start");
  process.addFlowElement(startEvent);

  UserTask userTask = new UserTask();
  userTask.setName("The Task");
  userTask.setId("theTask");
  userTask.setAssignee("kermit");
  process.addFlowElement(userTask);

  EndEvent endEvent = new EndEvent();
  endEvent.setId("theEnd");
  process.addFlowElement(endEvent);

  process.addFlowElement(new SequenceFlow("start", "theTask"));
  process.addFlowElement(new SequenceFlow("theTask", "theEnd"));

  return process;
}
 
Example #4
Source File: TerminateEndEventTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
public void testParseTerminateEndEventDefinitionWithExtensions() {
  org.activiti.engine.repository.Deployment deployment = repositoryService.createDeployment().addClasspathResource("org/activiti/engine/test/bpmn/event/end/TerminateEndEventTest.parseExtensionElements.bpmn20.xml").deploy();
  ProcessDefinition processDefinitionQuery = repositoryService.createProcessDefinitionQuery().deploymentId(deployment.getId()).singleResult();
  BpmnModel bpmnModel = this.processEngineConfiguration.getProcessDefinitionCache()
      .get(processDefinitionQuery.getId()).getBpmnModel();

  Map<String, List<ExtensionElement>> extensionElements = bpmnModel.getProcesses().get(0)
      .findFlowElementsOfType(EndEvent.class).get(0).getExtensionElements();
  assertThat(extensionElements.size(), is(1));
  List<ExtensionElement> strangeProperties = extensionElements.get("strangeProperty");
  assertThat(strangeProperties.size(), is(1));
  ExtensionElement strangeProperty = strangeProperties.get(0);
  assertThat(strangeProperty.getNamespace(), is("http://activiti.org/bpmn"));
  assertThat(strangeProperty.getElementText(), is("value"));
  assertThat(strangeProperty.getAttributes().size(), is(1));
  ExtensionAttribute id = strangeProperty.getAttributes().get("id").get(0);
  assertThat(id.getName(), is("id"));
  assertThat(id.getValue(), is("strangeId"));


  repositoryService.deleteDeployment(deployment.getId());
}
 
Example #5
Source File: EndEventValidator.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
@Override
protected void executeValidation(BpmnModel bpmnModel, Process process, List<ValidationError> errors) {
  List<EndEvent> endEvents = process.findFlowElementsOfType(EndEvent.class);
  for (EndEvent endEvent : endEvents) {
    if (endEvent.getEventDefinitions() != null && !endEvent.getEventDefinitions().isEmpty()) {

      EventDefinition eventDefinition = endEvent.getEventDefinitions().get(0);

      // Error end event
      if (eventDefinition instanceof CancelEventDefinition) {

        FlowElementsContainer parent = process.findParent(endEvent);
        if (!(parent instanceof Transaction)) {
          addError(errors, Problems.END_EVENT_CANCEL_ONLY_INSIDE_TRANSACTION, process, endEvent, "end event with cancelEventDefinition only supported inside transaction subprocess");
        }

      }

    }
  }
}
 
Example #6
Source File: AsyncEndEventConverterTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
private void validateModel(BpmnModel model) {
  FlowElement flowElement = model.getMainProcess().getFlowElement("endEvent");
  assertNotNull(flowElement);
  assertTrue(flowElement instanceof EndEvent);
  assertEquals("endEvent", flowElement.getId());
  EndEvent endEvent = (EndEvent) flowElement;
  assertEquals("endEvent", endEvent.getId());
  assertTrue(endEvent.isAsynchronous());
  
  List<ActivitiListener> listeners = endEvent.getExecutionListeners();
  assertEquals(1, listeners.size());
  ActivitiListener listener = listeners.get(0);
  assertTrue(ImplementationType.IMPLEMENTATION_TYPE_CLASS.equals(listener.getImplementationType()));
  assertEquals("org.test.TestClass", listener.getImplementation());
  assertEquals("start", listener.getEvent());
}
 
Example #7
Source File: DefaultActivityBehaviorFactory.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
public TerminateEndEventActivityBehavior createTerminateEndEventActivityBehavior(EndEvent endEvent) {
  boolean terminateAll = false;
  boolean terminateMultiInstance = false;
  
  if (endEvent.getEventDefinitions() != null 
      && endEvent.getEventDefinitions().size() > 0
      && endEvent.getEventDefinitions().get(0) instanceof TerminateEventDefinition) {
    terminateAll = ((TerminateEventDefinition) endEvent.getEventDefinitions().get(0)).isTerminateAll();
    terminateMultiInstance = ((TerminateEventDefinition) endEvent.getEventDefinitions().get(0)).isTerminateMultiInstance();
  }
  
  TerminateEndEventActivityBehavior terminateEndEventActivityBehavior = new TerminateEndEventActivityBehavior();
  terminateEndEventActivityBehavior.setTerminateAll(terminateAll);
  terminateEndEventActivityBehavior.setTerminateMultiInstance(terminateMultiInstance);
  return terminateEndEventActivityBehavior;
}
 
Example #8
Source File: EndEventJsonConverter.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
protected String getStencilId(BaseElement baseElement) {
  EndEvent endEvent = (EndEvent) baseElement;
  List<EventDefinition> eventDefinitions = endEvent.getEventDefinitions();
  if (eventDefinitions.size() != 1) {
    return STENCIL_EVENT_END_NONE;
  }

  EventDefinition eventDefinition = eventDefinitions.get(0);
  if (eventDefinition instanceof ErrorEventDefinition) {
    return STENCIL_EVENT_END_ERROR;
  } else if (eventDefinition instanceof CancelEventDefinition) {
    return STENCIL_EVENT_END_CANCEL;
  } else if (eventDefinition instanceof TerminateEventDefinition) {
    return STENCIL_EVENT_END_TERMINATE;
  } else {
    return STENCIL_EVENT_END_NONE;
  }
}
 
Example #9
Source File: TerminateEndEventActivityBehavior.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
public TerminateEndEventActivityBehavior(EndEvent endEvent) {
  this.endEvent = endEvent.clone();
  
  // Terminate all attribute
  if (endEvent.getEventDefinitions() != null) {
    for (EventDefinition eventDefinition : endEvent.getEventDefinitions()) {
      if (eventDefinition instanceof TerminateEventDefinition) {
        TerminateEventDefinition terminateEventDefinition = (TerminateEventDefinition) eventDefinition;
        if (terminateEventDefinition.isTerminateAll()) {
          this.terminateAll = true;
          break;
        }
      }
    }
  }
  
}
 
Example #10
Source File: TestProcessUtil.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
public static org.activiti.bpmn.model.Process createOneTaskProcess() {
	org.activiti.bpmn.model.Process process = new org.activiti.bpmn.model.Process();

	process.setId("oneTaskProcess");
	process.setName("The one task process");

	StartEvent startEvent = new StartEvent();
	startEvent.setId("start");
	process.addFlowElement(startEvent);

	UserTask userTask = new UserTask();
	userTask.setName("The Task");
	userTask.setId("theTask");
	userTask.setAssignee("kermit");
	process.addFlowElement(userTask);

	EndEvent endEvent = new EndEvent();
	endEvent.setId("theEnd");
	process.addFlowElement(endEvent);

	process.addFlowElement(new SequenceFlow("start", "theTask"));
	process.addFlowElement(new SequenceFlow("theTask", "theEnd"));

	return process;
}
 
Example #11
Source File: TerminateEndEventTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
public void testParseTerminateEndEventDefinitionWithExtensions() {
  org.activiti.engine.repository.Deployment deployment = repositoryService.createDeployment().addClasspathResource("org/activiti5/engine/test/bpmn/event/end/TerminateEndEventTest.parseExtensionElements.bpmn20.xml").deploy();
  ProcessDefinition processDefinitionQuery = repositoryService.createProcessDefinitionQuery().deploymentId(deployment.getId()).singleResult();
  BpmnModel bpmnModel = this.processEngineConfiguration.getProcessDefinitionCache()
      .get(processDefinitionQuery.getId()).getBpmnModel();

  Map<String, List<ExtensionElement>> extensionElements = bpmnModel.getProcesses().get(0)
      .findFlowElementsOfType(EndEvent.class).get(0).getExtensionElements();
  assertThat(extensionElements.size(), is(1));
  List<ExtensionElement> strangeProperties = extensionElements.get("strangeProperty");
  assertThat(strangeProperties.size(), is(1));
  ExtensionElement strangeProperty = strangeProperties.get(0);
  assertThat(strangeProperty.getNamespace(), is("http://activiti.org/bpmn"));
  assertThat(strangeProperty.getElementText(), is("value"));
  assertThat(strangeProperty.getAttributes().size(), is(1));
  ExtensionAttribute id = strangeProperty.getAttributes().get("id").get(0);
  assertThat(id.getName(), is("id"));
  assertThat(id.getValue(), is("strangeId"));


  repositoryService.deleteDeployment(deployment.getId());
}
 
Example #12
Source File: AbstractActivitiTestCase.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #13
Source File: EndEventXMLConverter.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
@Override
protected BaseElement convertXMLToElement(XMLStreamReader xtr, BpmnModel model) throws Exception {
  EndEvent endEvent = new EndEvent();
  BpmnXMLUtil.addXMLLocation(endEvent, xtr);
  parseChildElements(getXMLElementName(), endEvent, model, xtr);
  return endEvent;
}
 
Example #14
Source File: TerminateEventDefinitionParser.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public void parseChildElement(XMLStreamReader xtr, BaseElement parentElement, BpmnModel model) throws Exception {
  if (parentElement instanceof EndEvent == false) {
    return;
  }

  TerminateEventDefinition eventDefinition = new TerminateEventDefinition();
  
  parseTerminateAllAttribute(xtr, eventDefinition);
  parseTerminateMultiInstanceAttribute(xtr, eventDefinition);
  
  BpmnXMLUtil.addXMLLocation(eventDefinition, xtr);
  BpmnXMLUtil.parseChildElements(ELEMENT_EVENT_TERMINATEDEFINITION, eventDefinition, xtr, model);

  ((Event) parentElement).getEventDefinitions().add(eventDefinition);
}
 
Example #15
Source File: EndEventParseHandler.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
@Override
protected void executeParse(BpmnParse bpmnParse, EndEvent endEvent) {

  EventDefinition eventDefinition = null;
  if (endEvent.getEventDefinitions().size() > 0) {
    eventDefinition = endEvent.getEventDefinitions().get(0);

    if (eventDefinition instanceof ErrorEventDefinition) {
      ErrorEventDefinition errorDefinition = (ErrorEventDefinition) eventDefinition;
      if (bpmnParse.getBpmnModel().containsErrorRef(errorDefinition.getErrorCode())) {
        String errorCode = bpmnParse.getBpmnModel().getErrors().get(errorDefinition.getErrorCode());
        if (StringUtils.isEmpty(errorCode)) {
          logger.warn("errorCode is required for an error event " + endEvent.getId());
        }
      }
      endEvent.setBehavior(bpmnParse.getActivityBehaviorFactory().createErrorEndEventActivityBehavior(endEvent, errorDefinition));
    } else if (eventDefinition instanceof TerminateEventDefinition) {
      endEvent.setBehavior(bpmnParse.getActivityBehaviorFactory().createTerminateEndEventActivityBehavior(endEvent));
    } else if (eventDefinition instanceof CancelEventDefinition) {
      endEvent.setBehavior(bpmnParse.getActivityBehaviorFactory().createCancelEndEventActivityBehavior(endEvent));
    } else {
      endEvent.setBehavior(bpmnParse.getActivityBehaviorFactory().createNoneEndEventActivityBehavior(endEvent));
    }

  } else {
    endEvent.setBehavior(bpmnParse.getActivityBehaviorFactory().createNoneEndEventActivityBehavior(endEvent));
  }
}
 
Example #16
Source File: AbstractActivitiTestCase.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
/**
 * Since the 'one task process' is used everywhere the actual process content
 * doesn't matter, instead of copying around the BPMN 2.0 xml one could use 
 * this method which gives a {@link BpmnModel} version of the same process back.
 */
public BpmnModel createOneTaskTestProcess() {
	BpmnModel model = new BpmnModel();
	org.activiti.bpmn.model.Process process = new org.activiti.bpmn.model.Process();
  model.addProcess(process);
  process.setId("oneTaskProcess");
  process.setName("The one task process");
 
  StartEvent startEvent = new StartEvent();
  startEvent.setId("start");
  process.addFlowElement(startEvent);
  
  UserTask userTask = new UserTask();
  userTask.setName("The Task");
  userTask.setId("theTask");
  userTask.setAssignee("kermit");
  process.addFlowElement(userTask);
  
  EndEvent endEvent = new EndEvent();
  endEvent.setId("theEnd");
  process.addFlowElement(endEvent);
  
  process.addFlowElement(new SequenceFlow("start", "theTask"));
  process.addFlowElement(new SequenceFlow("theTask", "theEnd"));
  
  return model;
}
 
Example #17
Source File: AbstractActivitiTestCase.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #18
Source File: AbstractActivitiTestCase.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
/**
 * Since the 'one task process' is used everywhere the actual process content doesn't matter, instead of copying around the BPMN 2.0 xml one could use this method which gives a {@link BpmnModel}
 * version of the same process back.
 */
public BpmnModel createOneTaskTestProcess() {
  BpmnModel model = new BpmnModel();
  org.activiti.bpmn.model.Process process = new org.activiti.bpmn.model.Process();
  model.addProcess(process);
  process.setId("oneTaskProcess");
  process.setName("The one task process");

  StartEvent startEvent = new StartEvent();
  startEvent.setId("start");
  process.addFlowElement(startEvent);

  UserTask userTask = new UserTask();
  userTask.setName("The Task");
  userTask.setId("theTask");
  userTask.setAssignee("kermit");
  process.addFlowElement(userTask);

  EndEvent endEvent = new EndEvent();
  endEvent.setId("theEnd");
  process.addFlowElement(endEvent);

  process.addFlowElement(new SequenceFlow("start", "theTask"));
  process.addFlowElement(new SequenceFlow("theTask", "theEnd"));

  return model;
}
 
Example #19
Source File: EventJavaTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
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());
}
 
Example #20
Source File: TestProcessUtil.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #21
Source File: ProcessDefinitionPersistenceTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
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);

  assertEquals(procDefId, processDefinition.getId());
  assertEquals("Process One", processDefinition.getName());
  
  Process process = repositoryService.getBpmnModel(processDefinition.getId()).getMainProcess();
  StartEvent startElement = (StartEvent) process.getFlowElement("start");
  assertNotNull(startElement);
  assertEquals("start", startElement.getId());
  assertEquals("S t a r t", startElement.getName());
  assertEquals("the start event", startElement.getDocumentation());
  List<SequenceFlow> outgoingFlows = startElement.getOutgoingFlows();
  assertEquals(1, outgoingFlows.size());
  assertEquals("${a == b}", outgoingFlows.get(0).getConditionExpression());

  EndEvent endElement = (EndEvent) process.getFlowElement("end");
  assertNotNull(endElement);
  assertEquals("end", endElement.getId());

  assertEquals("flow1", outgoingFlows.get(0).getId());
  assertEquals("Flow One", outgoingFlows.get(0).getName());
  assertEquals("The only transitions in the process", outgoingFlows.get(0).getDocumentation());
  assertSame(startElement, outgoingFlows.get(0).getSourceFlowElement());
  assertSame(endElement, outgoingFlows.get(0).getTargetFlowElement());

  repositoryService.deleteDeployment(deploymentId);
}
 
Example #22
Source File: TestProcessUtil.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #23
Source File: EventJavaTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
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))
      .deploymentProperty(DeploymentProperties.DEPLOY_AS_ACTIVITI5_PROCESS_DEFINITION, Boolean.TRUE)
      .deploy();
  repositoryService.deleteDeployment(deployment.getId());
}
 
Example #24
Source File: TraceService.java    From lemon with Apache License 2.0 4 votes vote down vote up
public NodeDTO convertNodeDto(GraphicInfo graphicInfo,
        FlowElement flowElement, String id, BpmnModel bpmnModel) {
    NodeDTO nodeDto = new NodeDTO();
    nodeDto.setX((int) graphicInfo.getX());
    nodeDto.setY((int) graphicInfo.getY());
    nodeDto.setWidth((int) graphicInfo.getWidth());
    nodeDto.setHeight((int) graphicInfo.getHeight());
    //
    nodeDto.setId(id);
    nodeDto.setName(flowElement.getName());

    if (flowElement instanceof UserTask) {
        nodeDto.setType("用户任务");

        UserTask userTask = (UserTask) flowElement;
        nodeDto.setAssignee(userTask.getAssignee());
    } else if (flowElement instanceof StartEvent) {
        nodeDto.setType("开始事件");
    } else if (flowElement instanceof EndEvent) {
        nodeDto.setType("结束事件");
    } else if (flowElement instanceof ExclusiveGateway) {
        nodeDto.setType("选择网关");
    }

    if (flowElement instanceof FlowNode) {
        FlowNode flowNode = (FlowNode) flowElement;

        for (SequenceFlow sequenceFlow : flowNode.getOutgoingFlows()) {
            EdgeDTO edgeDto = new EdgeDTO();
            edgeDto.setId(sequenceFlow.getTargetRef());

            for (GraphicInfo flowGraphicInfo : bpmnModel
                    .getFlowLocationGraphicInfo(sequenceFlow.getId())) {
                List<Integer> position = new ArrayList<Integer>();
                position.add((int) flowGraphicInfo.getX()
                        - ((int) graphicInfo.getWidth() / 2));
                position.add((int) flowGraphicInfo.getY()
                        - ((int) graphicInfo.getHeight() / 2));
                edgeDto.getG().add(position);
            }

            edgeDto.getG().remove(0);
            edgeDto.getG().remove(edgeDto.getG().size() - 1);
            logger.debug("{}", edgeDto.getG());
            nodeDto.getOutgoings().add(edgeDto);
        }
    }

    return nodeDto;
}
 
Example #25
Source File: DynamicProcess.java    From activiti-in-action-codes with Apache License 2.0 4 votes vote down vote up
protected EndEvent createEndEvent() {
    EndEvent endEvent = new EndEvent();
    endEvent.setId("end");
    return endEvent;
}
 
Example #26
Source File: ActivityBehaviorFactoryDelegate.java    From openwebflow with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public TerminateEndEventActivityBehavior createTerminateEndEventActivityBehavior(EndEvent endEvent)
{
	return _source.createTerminateEndEventActivityBehavior(endEvent);
}
 
Example #27
Source File: EndEventXMLConverter.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
public Class<? extends BaseElement> getBpmnElementType() {
  return EndEvent.class;
}
 
Example #28
Source File: EndEventXMLConverter.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
@Override
protected void writeAdditionalChildElements(BaseElement element, BpmnModel model, XMLStreamWriter xtw) throws Exception {
  EndEvent endEvent = (EndEvent) element;
  writeEventDefinitions(endEvent, endEvent.getEventDefinitions(), model, xtw);
}
 
Example #29
Source File: ActivityBehaviorFactoryDelegate.java    From openwebflow with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public NoneEndEventActivityBehavior createNoneEndEventActivityBehavior(EndEvent endEvent)
{
	return _source.createNoneEndEventActivityBehavior(endEvent);
}
 
Example #30
Source File: ActivityBehaviorFactoryDelegate.java    From openwebflow with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public ErrorEndEventActivityBehavior createErrorEndEventActivityBehavior(EndEvent endEvent,
		ErrorEventDefinition errorEventDefinition)
{
	return _source.createErrorEndEventActivityBehavior(endEvent, errorEventDefinition);
}