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;
}
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);
}
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);
}
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());
}
Aggregations