use of org.camunda.bpm.engine.impl.externaltask.LockedExternalTaskImpl in project camunda-bpm-platform by camunda.
the class FetchExternalTasksCmd method execute.
@Override
public List<LockedExternalTask> execute(CommandContext commandContext) {
validateInput();
for (TopicFetchInstruction instruction : fetchInstructions.values()) {
instruction.ensureVariablesInitialized();
}
List<ExternalTaskEntity> externalTasks = commandContext.getExternalTaskManager().selectExternalTasksForTopics(fetchInstructions.values(), filterByBusinessKey, maxResults, usePriority);
final List<LockedExternalTask> result = new ArrayList<LockedExternalTask>();
for (ExternalTaskEntity entity : externalTasks) {
TopicFetchInstruction fetchInstruction = fetchInstructions.get(entity.getTopicName());
entity.lock(workerId, fetchInstruction.getLockDuration());
LockedExternalTaskImpl resultTask = LockedExternalTaskImpl.fromEntity(entity, fetchInstruction.getVariablesToFetch(), fetchInstruction.isDeserializeVariables());
result.add(resultTask);
}
filterOnOptimisticLockingFailure(commandContext, result);
return result;
}
Aggregations