Search in sources :

Example 1 with ExternalTaskService

use of org.camunda.bpm.engine.ExternalTaskService in project camunda-bpm-platform by camunda.

the class ExternalTaskRestServiceImpl method updateRetries.

protected UpdateExternalTaskRetriesBuilder updateRetries(SetRetriesForExternalTasksDto retriesDto) {
    ExternalTaskService externalTaskService = getProcessEngine().getExternalTaskService();
    List<String> externalTaskIds = retriesDto.getExternalTaskIds();
    List<String> processInstanceIds = retriesDto.getProcessInstanceIds();
    ExternalTaskQuery externalTaskQuery = null;
    ProcessInstanceQuery processInstanceQuery = null;
    HistoricProcessInstanceQuery historicProcessInstanceQuery = null;
    ExternalTaskQueryDto externalTaskQueryDto = retriesDto.getExternalTaskQuery();
    if (externalTaskQueryDto != null) {
        externalTaskQuery = externalTaskQueryDto.toQuery(getProcessEngine());
    }
    ProcessInstanceQueryDto processInstanceQueryDto = retriesDto.getProcessInstanceQuery();
    if (processInstanceQueryDto != null) {
        processInstanceQuery = processInstanceQueryDto.toQuery(getProcessEngine());
    }
    HistoricProcessInstanceQueryDto historicProcessInstanceQueryDto = retriesDto.getHistoricProcessInstanceQuery();
    if (historicProcessInstanceQueryDto != null) {
        historicProcessInstanceQuery = historicProcessInstanceQueryDto.toQuery(getProcessEngine());
    }
    return externalTaskService.updateRetries().externalTaskIds(externalTaskIds).processInstanceIds(processInstanceIds).externalTaskQuery(externalTaskQuery).processInstanceQuery(processInstanceQuery).historicProcessInstanceQuery(historicProcessInstanceQuery);
}
Also used : HistoricProcessInstanceQueryDto(org.camunda.bpm.engine.rest.dto.history.HistoricProcessInstanceQueryDto) HistoricProcessInstanceQuery(org.camunda.bpm.engine.history.HistoricProcessInstanceQuery) ProcessInstanceQuery(org.camunda.bpm.engine.runtime.ProcessInstanceQuery) ExternalTaskQuery(org.camunda.bpm.engine.externaltask.ExternalTaskQuery) HistoricProcessInstanceQuery(org.camunda.bpm.engine.history.HistoricProcessInstanceQuery) ExternalTaskQueryDto(org.camunda.bpm.engine.rest.dto.externaltask.ExternalTaskQueryDto) ExternalTaskService(org.camunda.bpm.engine.ExternalTaskService) ProcessInstanceQueryDto(org.camunda.bpm.engine.rest.dto.runtime.ProcessInstanceQueryDto) HistoricProcessInstanceQueryDto(org.camunda.bpm.engine.rest.dto.history.HistoricProcessInstanceQueryDto)

Example 2 with ExternalTaskService

use of org.camunda.bpm.engine.ExternalTaskService in project camunda-bpm-platform by camunda.

the class ExternalTaskResourceImpl method complete.

@Override
public void complete(CompleteExternalTaskDto dto) {
    ExternalTaskService externalTaskService = engine.getExternalTaskService();
    VariableMap variables = VariableValueDto.toMap(dto.getVariables(), engine, objectMapper);
    VariableMap localVariables = VariableValueDto.toMap(dto.getLocalVariables(), engine, objectMapper);
    try {
        externalTaskService.complete(externalTaskId, dto.getWorkerId(), variables, localVariables);
    } catch (NotFoundException e) {
        throw new RestException(Status.NOT_FOUND, e, "External task with id " + externalTaskId + " does not exist");
    } catch (BadUserRequestException e) {
        throw new RestException(Status.BAD_REQUEST, e, e.getMessage());
    }
}
Also used : VariableMap(org.camunda.bpm.engine.variable.VariableMap) ExternalTaskService(org.camunda.bpm.engine.ExternalTaskService) RestException(org.camunda.bpm.engine.rest.exception.RestException) NotFoundException(org.camunda.bpm.engine.exception.NotFoundException) BadUserRequestException(org.camunda.bpm.engine.BadUserRequestException)

Example 3 with ExternalTaskService

use of org.camunda.bpm.engine.ExternalTaskService in project camunda-bpm-platform by camunda.

the class ExternalTaskRestServiceInteractionTest method setUpRuntimeData.

@Before
public void setUpRuntimeData() {
    externalTaskService = mock(ExternalTaskService.class);
    when(processEngine.getExternalTaskService()).thenReturn(externalTaskService);
    runtimeServiceMock = mock(RuntimeServiceImpl.class);
    when(processEngine.getRuntimeService()).thenReturn(runtimeServiceMock);
    historyServiceMock = mock(HistoryServiceImpl.class);
    when(processEngine.getHistoryService()).thenReturn(historyServiceMock);
    // locked external task
    lockedExternalTaskMock = MockProvider.createMockLockedExternalTask();
    // fetching
    fetchTopicBuilder = mock(ExternalTaskQueryTopicBuilder.class);
    when(externalTaskService.fetchAndLock(anyInt(), any(String.class))).thenReturn(fetchTopicBuilder);
    when(externalTaskService.fetchAndLock(anyInt(), any(String.class), any(Boolean.class))).thenReturn(fetchTopicBuilder);
    when(fetchTopicBuilder.topic(any(String.class), anyLong())).thenReturn(fetchTopicBuilder);
    when(fetchTopicBuilder.variables(anyListOf(String.class))).thenReturn(fetchTopicBuilder);
    when(fetchTopicBuilder.variables(any(String[].class))).thenReturn(fetchTopicBuilder);
    when(fetchTopicBuilder.enableCustomObjectDeserialization()).thenReturn(fetchTopicBuilder);
    when(fetchTopicBuilder.topic(any(String.class), anyLong())).thenReturn(fetchTopicBuilder);
    when(fetchTopicBuilder.businessKey(any(String.class))).thenReturn(fetchTopicBuilder);
    when(fetchTopicBuilder.processInstanceVariableEquals(anyMapOf(String.class, Object.class))).thenReturn(fetchTopicBuilder);
    Batch batch = createMockBatch();
    updateRetriesBuilder = mock(UpdateExternalTaskRetriesBuilder.class);
    when(externalTaskService.updateRetries()).thenReturn(updateRetriesBuilder);
    when(updateRetriesBuilder.externalTaskIds(anyListOf(String.class))).thenReturn(updateRetriesBuilder);
    when(updateRetriesBuilder.processInstanceIds(anyListOf(String.class))).thenReturn(updateRetriesBuilder);
    when(updateRetriesBuilder.externalTaskQuery(any(ExternalTaskQuery.class))).thenReturn(updateRetriesBuilder);
    when(updateRetriesBuilder.processInstanceQuery(any(ProcessInstanceQuery.class))).thenReturn(updateRetriesBuilder);
    when(updateRetriesBuilder.historicProcessInstanceQuery(any(HistoricProcessInstanceQuery.class))).thenReturn(updateRetriesBuilder);
    when(updateRetriesBuilder.setAsync(anyInt())).thenReturn(batch);
    // querying
    externalTaskQueryMock = mock(ExternalTaskQuery.class);
    when(externalTaskQueryMock.externalTaskId(any(String.class))).thenReturn(externalTaskQueryMock);
    when(externalTaskService.createExternalTaskQuery()).thenReturn(externalTaskQueryMock);
    // external task
    externalTaskMock = MockProvider.createMockExternalTask();
}
Also used : HistoricProcessInstanceQuery(org.camunda.bpm.engine.history.HistoricProcessInstanceQuery) ProcessInstanceQuery(org.camunda.bpm.engine.runtime.ProcessInstanceQuery) UpdateExternalTaskRetriesBuilder(org.camunda.bpm.engine.externaltask.UpdateExternalTaskRetriesBuilder) ExternalTaskQuery(org.camunda.bpm.engine.externaltask.ExternalTaskQuery) HistoricProcessInstanceQuery(org.camunda.bpm.engine.history.HistoricProcessInstanceQuery) HistoryServiceImpl(org.camunda.bpm.engine.impl.HistoryServiceImpl) MockProvider.createMockBatch(org.camunda.bpm.engine.rest.helper.MockProvider.createMockBatch) Batch(org.camunda.bpm.engine.batch.Batch) ExternalTaskService(org.camunda.bpm.engine.ExternalTaskService) Matchers.anyString(org.mockito.Matchers.anyString) RuntimeServiceImpl(org.camunda.bpm.engine.impl.RuntimeServiceImpl) ExternalTaskQueryTopicBuilder(org.camunda.bpm.engine.externaltask.ExternalTaskQueryTopicBuilder) Before(org.junit.Before)

Example 4 with ExternalTaskService

use of org.camunda.bpm.engine.ExternalTaskService in project camunda-bpm-platform by camunda.

the class MockedProcessEngineProvider method mockServices.

private void mockServices(ProcessEngine engine) {
    RepositoryService repoService = mock(RepositoryService.class);
    IdentityService identityService = mock(IdentityService.class);
    TaskService taskService = mock(TaskService.class);
    RuntimeService runtimeService = mock(RuntimeService.class);
    FormService formService = mock(FormService.class);
    HistoryService historyService = mock(HistoryService.class);
    ManagementService managementService = mock(ManagementService.class);
    CaseService caseService = mock(CaseService.class);
    FilterService filterService = mock(FilterService.class);
    ExternalTaskService externalTaskService = mock(ExternalTaskService.class);
    when(engine.getRepositoryService()).thenReturn(repoService);
    when(engine.getIdentityService()).thenReturn(identityService);
    when(engine.getTaskService()).thenReturn(taskService);
    when(engine.getRuntimeService()).thenReturn(runtimeService);
    when(engine.getFormService()).thenReturn(formService);
    when(engine.getHistoryService()).thenReturn(historyService);
    when(engine.getManagementService()).thenReturn(managementService);
    when(engine.getCaseService()).thenReturn(caseService);
    when(engine.getFilterService()).thenReturn(filterService);
    when(engine.getExternalTaskService()).thenReturn(externalTaskService);
}
Also used : IdentityService(org.camunda.bpm.engine.IdentityService) ManagementService(org.camunda.bpm.engine.ManagementService) RuntimeService(org.camunda.bpm.engine.RuntimeService) TaskService(org.camunda.bpm.engine.TaskService) ExternalTaskService(org.camunda.bpm.engine.ExternalTaskService) ExternalTaskService(org.camunda.bpm.engine.ExternalTaskService) FormService(org.camunda.bpm.engine.FormService) FilterService(org.camunda.bpm.engine.FilterService) HistoryService(org.camunda.bpm.engine.HistoryService) CaseService(org.camunda.bpm.engine.CaseService) RepositoryService(org.camunda.bpm.engine.RepositoryService)

Aggregations

ExternalTaskService (org.camunda.bpm.engine.ExternalTaskService)4 ExternalTaskQuery (org.camunda.bpm.engine.externaltask.ExternalTaskQuery)2 HistoricProcessInstanceQuery (org.camunda.bpm.engine.history.HistoricProcessInstanceQuery)2 ProcessInstanceQuery (org.camunda.bpm.engine.runtime.ProcessInstanceQuery)2 BadUserRequestException (org.camunda.bpm.engine.BadUserRequestException)1 CaseService (org.camunda.bpm.engine.CaseService)1 FilterService (org.camunda.bpm.engine.FilterService)1 FormService (org.camunda.bpm.engine.FormService)1 HistoryService (org.camunda.bpm.engine.HistoryService)1 IdentityService (org.camunda.bpm.engine.IdentityService)1 ManagementService (org.camunda.bpm.engine.ManagementService)1 RepositoryService (org.camunda.bpm.engine.RepositoryService)1 RuntimeService (org.camunda.bpm.engine.RuntimeService)1 TaskService (org.camunda.bpm.engine.TaskService)1 Batch (org.camunda.bpm.engine.batch.Batch)1 NotFoundException (org.camunda.bpm.engine.exception.NotFoundException)1 ExternalTaskQueryTopicBuilder (org.camunda.bpm.engine.externaltask.ExternalTaskQueryTopicBuilder)1 UpdateExternalTaskRetriesBuilder (org.camunda.bpm.engine.externaltask.UpdateExternalTaskRetriesBuilder)1 HistoryServiceImpl (org.camunda.bpm.engine.impl.HistoryServiceImpl)1 RuntimeServiceImpl (org.camunda.bpm.engine.impl.RuntimeServiceImpl)1