use of org.activiti.api.process.model.ProcessInstance in project Activiti by Activiti.
the class ProcessRuntimeImpl method start.
@Override
public ProcessInstance start(StartMessagePayload messagePayload) {
String messageName = messagePayload.getName();
String businessKey = messagePayload.getBusinessKey();
Map<String, Object> variables = messagePayload.getVariables();
processVariablesValidator.checkStartMessagePayloadVariables(messagePayload, null);
ProcessInstance processInstance = processInstanceConverter.from(runtimeService.startProcessInstanceByMessage(messageName, businessKey, variables));
return processInstance;
}
use of org.activiti.api.process.model.ProcessInstance in project Activiti by Activiti.
the class ProcessRuntimeImpl method update.
@Override
public ProcessInstance update(UpdateProcessPayload updateProcessPayload) {
ProcessInstance processInstance = processInstance(updateProcessPayload.getProcessInstanceId());
checkUserCanWrite(processInstance.getProcessDefinitionKey());
if (updateProcessPayload.getBusinessKey() != null) {
runtimeService.updateBusinessKey(updateProcessPayload.getProcessInstanceId(), updateProcessPayload.getBusinessKey());
}
if (updateProcessPayload.getName() != null) {
runtimeService.setProcessInstanceName(updateProcessPayload.getProcessInstanceId(), updateProcessPayload.getName());
}
ProcessInstance updatedProcessInstance = processInstanceConverter.from(runtimeService.createProcessInstanceQuery().processInstanceId(updateProcessPayload.getProcessInstanceId()).singleResult());
return updatedProcessInstance;
}
use of org.activiti.api.process.model.ProcessInstance in project Activiti by Activiti.
the class ProcessAdminRuntimeImpl method start.
@Override
public ProcessInstance start(StartMessagePayload messagePayload) {
String messageName = messagePayload.getName();
String businessKey = messagePayload.getBusinessKey();
Map<String, Object> variables = messagePayload.getVariables();
processVariablesValidator.checkStartMessagePayloadVariables(messagePayload, null);
ProcessInstance processInstance = processInstanceConverter.from(runtimeService.startProcessInstanceByMessage(messageName, businessKey, variables));
return processInstance;
}
use of org.activiti.api.process.model.ProcessInstance in project Activiti by Activiti.
the class TaskRuntimeMultiInstanceIT method parallelMultiInstance_should_collectOutputValues.
@Test
public void parallelMultiInstance_should_collectOutputValues() {
ProcessInstance processInstance = processBaseRuntime.startProcessWithProcessDefinitionKey("miParallelUserTasksOutputCollection");
List<Task> tasks = taskBaseRuntime.getTasks(processInstance);
assertThat(tasks).hasSize(2);
taskBaseRuntime.completeTask(tasks.get(0), singletonMap("meal", "pizza"));
taskBaseRuntime.completeTask(tasks.get(1), singletonMap("meal", "pasta"));
List<VariableInstance> variables = processBaseRuntime.getVariables(processInstance);
assertThat(variables).extracting(VariableInstance::getName, VariableInstance::getValue).contains(tuple("meals", asList("pizza", "pasta")));
}
use of org.activiti.api.process.model.ProcessInstance in project Activiti by Activiti.
the class TaskRuntimeMultiInstanceIT method processWithParallelMultiInstancesOnSubProcess_should_emmit_EqualStartAndEndEvent.
@Test
public void processWithParallelMultiInstancesOnSubProcess_should_emmit_EqualStartAndEndEvent() {
// when
ProcessInstance processInstance = processBaseRuntime.startProcessWithProcessDefinitionKey("miParallelSubprocess");
// then
List<Task> tasks = taskBaseRuntime.getTasks(processInstance);
assertThat(tasks).extracting(Task::getName).containsExactlyInAnyOrder("Task in sub-process 0", "Task in sub-process 1");
assertThat(localEventSource.getEvents(TaskCreatedEvent.class)).extracting(event -> event.getEntity().getName()).containsExactlyInAnyOrder("Task in sub-process 0", "Task in sub-process 1");
assertActivityEvents("miSubProcess", BPMNActivityEvent.ActivityEvents.ACTIVITY_STARTED, BPMNActivityEvent.ActivityEvents.ACTIVITY_STARTED);
// complete first iteration: multi instance should not finish yet
localEventSource.clearEvents();
taskBaseRuntime.completeTask(tasks.get(0));
assertThat(localEventSource.getTaskEvents()).extracting(RuntimeEvent::getEventType, event -> ((Task) event.getEntity()).getName(), event -> ((Task) event.getEntity()).getProcessInstanceId()).containsExactly(tuple(TaskRuntimeEvent.TaskEvents.TASK_COMPLETED, tasks.get(0).getName(), processInstance.getId()));
assertActivityEvents("miSubProcess", BPMNActivityEvent.ActivityEvents.ACTIVITY_COMPLETED);
assertThat(localEventSource.getProcessInstanceEvents()).isEmpty();
// complete second iteration: multi instance should finish
localEventSource.clearEvents();
taskBaseRuntime.completeTask(tasks.get(1));
assertThat(localEventSource.getTaskEvents()).extracting(RuntimeEvent::getEventType, event -> ((Task) event.getEntity()).getName(), event -> ((Task) event.getEntity()).getProcessInstanceId()).containsExactly(tuple(TaskRuntimeEvent.TaskEvents.TASK_COMPLETED, tasks.get(1).getName(), processInstance.getId()));
assertActivityEvents("miSubProcess", BPMNActivityEvent.ActivityEvents.ACTIVITY_COMPLETED);
assertThat(localEventSource.getProcessInstanceEvents()).extracting(RuntimeEvent::getEventType, RuntimeEvent::getProcessInstanceId).containsExactly(tuple(ProcessRuntimeEvent.ProcessEvents.PROCESS_COMPLETED, processInstance.getId()));
}
Aggregations