Search in sources :

Example 1 with ExternalTaskQueryBuilder

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

the class FetchExternalTasksDto method buildQuery.

public ExternalTaskQueryBuilder buildQuery(ProcessEngine processEngine) {
    ExternalTaskQueryBuilder fetchBuilder = processEngine.getExternalTaskService().fetchAndLock(getMaxTasks(), getWorkerId(), isUsePriority());
    if (getTopics() != null) {
        for (FetchExternalTaskTopicDto topicDto : getTopics()) {
            ExternalTaskQueryTopicBuilder topicFetchBuilder = fetchBuilder.topic(topicDto.getTopicName(), topicDto.getLockDuration());
            if (topicDto.getBusinessKey() != null) {
                topicFetchBuilder = topicFetchBuilder.businessKey(topicDto.getBusinessKey());
            }
            if (topicDto.getVariables() != null) {
                topicFetchBuilder = topicFetchBuilder.variables(topicDto.getVariables());
            }
            if (topicDto.getProcessVariables() != null) {
                topicFetchBuilder = topicFetchBuilder.processInstanceVariableEquals(topicDto.getProcessVariables());
            }
            if (topicDto.isDeserializeValues()) {
                topicFetchBuilder = topicFetchBuilder.enableCustomObjectDeserialization();
            }
            fetchBuilder = topicFetchBuilder;
        }
    }
    return fetchBuilder;
}
Also used : ExternalTaskQueryBuilder(org.camunda.bpm.engine.externaltask.ExternalTaskQueryBuilder) ExternalTaskQueryTopicBuilder(org.camunda.bpm.engine.externaltask.ExternalTaskQueryTopicBuilder)

Example 2 with ExternalTaskQueryBuilder

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

the class FetchAndLockHandlerImpl method executeFetchAndLock.

protected List<LockedExternalTaskDto> executeFetchAndLock(FetchExternalTasksExtendedDto fetchingDto, ProcessEngine processEngine) {
    ExternalTaskQueryBuilder fetchBuilder = fetchingDto.buildQuery(processEngine);
    List<LockedExternalTask> externalTasks = fetchBuilder.execute();
    return LockedExternalTaskDto.fromLockedExternalTasks(externalTasks);
}
Also used : ExternalTaskQueryBuilder(org.camunda.bpm.engine.externaltask.ExternalTaskQueryBuilder) LockedExternalTask(org.camunda.bpm.engine.externaltask.LockedExternalTask)

Example 3 with ExternalTaskQueryBuilder

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

the class ExternalTaskRestServiceImpl method fetchAndLock.

@Override
public List<LockedExternalTaskDto> fetchAndLock(FetchExternalTasksDto fetchingDto) {
    ExternalTaskQueryBuilder fetchBuilder = fetchingDto.buildQuery(processEngine);
    List<LockedExternalTask> externalTasks = fetchBuilder.execute();
    return LockedExternalTaskDto.fromLockedExternalTasks(externalTasks);
}
Also used : ExternalTaskQueryBuilder(org.camunda.bpm.engine.externaltask.ExternalTaskQueryBuilder) LockedExternalTask(org.camunda.bpm.engine.externaltask.LockedExternalTask)

Example 4 with ExternalTaskQueryBuilder

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

the class ExternalTaskServiceTest method testFetchAndLockWithInitialBuilder.

/**
 * Note: this does not test a hard API guarantee, i.e. the test is stricter than the API (Javadoc).
 * Its purpose is to ensure that the API implementation is less error-prone to use.
 *
 * Bottom line: if there is good reason to change behavior such that this test breaks, it may
 * be ok to change the test.
 */
@Deployment(resources = "org/camunda/bpm/engine/test/api/externaltask/oneExternalTaskProcess.bpmn20.xml")
public void testFetchAndLockWithInitialBuilder() {
    // given
    runtimeService.startProcessInstanceByKey("oneExternalTaskProcess");
    // when
    ExternalTaskQueryBuilder initialBuilder = externalTaskService.fetchAndLock(1, WORKER_ID);
    initialBuilder.topic(TOPIC_NAME, LOCK_TIME);
    // should execute regardless whether the initial builder is used or the builder returned by the
    // #topic invocation
    List<LockedExternalTask> tasks = initialBuilder.execute();
    // then
    assertEquals(1, tasks.size());
}
Also used : ExternalTaskQueryBuilder(org.camunda.bpm.engine.externaltask.ExternalTaskQueryBuilder) LockedExternalTask(org.camunda.bpm.engine.externaltask.LockedExternalTask) Deployment(org.camunda.bpm.engine.test.Deployment)

Aggregations

ExternalTaskQueryBuilder (org.camunda.bpm.engine.externaltask.ExternalTaskQueryBuilder)4 LockedExternalTask (org.camunda.bpm.engine.externaltask.LockedExternalTask)3 ExternalTaskQueryTopicBuilder (org.camunda.bpm.engine.externaltask.ExternalTaskQueryTopicBuilder)1 Deployment (org.camunda.bpm.engine.test.Deployment)1