Skip to content

Commit

Permalink
refactor(engine): Code Review points
Browse files Browse the repository at this point in the history
- Remove execute method from FetchAndLockBuilder
- Refactor FetchAndLockBuilderImpl to use a List instead of a Map and make it similar to the QueryAPI for the sake of consistency
- Add tests for covering invalid usages of fetchAndLock API
- Infer useCreateTime
- Correct JavaDoc
- Generify Sorting of FetchAndLock Impl
- Remove var
  • Loading branch information
psavidis committed Dec 1, 2023
1 parent 8f1555e commit c50657a
Show file tree
Hide file tree
Showing 13 changed files with 677 additions and 637 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -203,19 +203,19 @@ public void setIncludeExtensionProperties(boolean includeExtensionProperties) {
}
}

public FetchAndLockBuilder buildQuery(ProcessEngine processEngine) {
public ExternalTaskQueryTopicBuilder buildQuery(ProcessEngine processEngine) {
FetchAndLockBuilder fetchAndLockBuilder = getBuilder(processEngine);

if (CollectionUtil.isEmpty(topics)) {
return fetchAndLockBuilder;
}

return configureTopics(fetchAndLockBuilder);
}

protected FetchAndLockBuilder configureTopics(FetchAndLockBuilder builder) {
protected ExternalTaskQueryTopicBuilder configureTopics(FetchAndLockBuilder builder) {
ExternalTaskQueryTopicBuilder topicBuilder = builder.subscribe();

if (CollectionUtil.isEmpty(topics)) {
return topicBuilder;
}

topics.forEach(topic -> {
topicBuilder.topic(topic.getTopicName(), topic.getLockDuration());

Expand Down Expand Up @@ -272,7 +272,7 @@ protected FetchAndLockBuilder configureTopics(FetchAndLockBuilder builder) {
}
});

return builder;
return topicBuilder;
}

protected FetchAndLockBuilder getBuilder(ProcessEngine engine) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import javax.ws.rs.core.Response.Status;
import org.camunda.bpm.engine.IdentityService;
import org.camunda.bpm.engine.ProcessEngine;
import org.camunda.bpm.engine.externaltask.FetchAndLockBuilder;
import org.camunda.bpm.engine.externaltask.ExternalTaskQueryTopicBuilder;
import org.camunda.bpm.engine.externaltask.LockedExternalTask;
import org.camunda.bpm.engine.impl.ProcessEngineImpl;
import org.camunda.bpm.engine.impl.identity.Authentication;
Expand Down Expand Up @@ -262,8 +262,9 @@ protected FetchAndLockResult tryFetchAndLock(FetchAndLockRequest request) {
}

protected List<LockedExternalTaskDto> executeFetchAndLock(FetchExternalTasksExtendedDto fetchingDto, ProcessEngine processEngine) {
FetchAndLockBuilder fetchBuilder = fetchingDto.buildQuery(processEngine);
ExternalTaskQueryTopicBuilder fetchBuilder = fetchingDto.buildQuery(processEngine);
List<LockedExternalTask> externalTasks = fetchBuilder.execute();

return LockedExternalTaskDto.fromLockedExternalTasks(externalTasks);
}

Expand Down
Loading

0 comments on commit c50657a

Please sign in to comment.