Skip to content

Commit

Permalink
chore(engine-rest, clients): Change FetchAndLock Sorting Param
Browse files Browse the repository at this point in the history
Description: This commit renames the `sortings` parameter of the FetchAndLock API to sorting to match the existing convention of other similar APIs that involve sorting.

Related-to: #4018, #3896
  • Loading branch information
psavidis committed Mar 4, 2024
1 parent 58129e0 commit 3d0fb99
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class FetchAndLockRequestDto extends RequestDto {
protected boolean usePriority;
protected Long asyncResponseTimeout;
protected List<TopicRequestDto> topics;
protected List<SortingDto> sortings;
protected List<SortingDto> sorting;

public FetchAndLockRequestDto(String workerId, int maxTasks, Long asyncResponseTimeout, List<TopicRequestDto> topics) {
this(workerId, maxTasks, asyncResponseTimeout, topics, true);
Expand All @@ -50,7 +50,7 @@ public FetchAndLockRequestDto(String workerId, int maxTasks, Long asyncResponseT
this.usePriority = usePriority;
this.asyncResponseTimeout = asyncResponseTimeout;
this.topics = topics;
this.sortings = orderingConfig.toSortingDtos();
this.sorting = orderingConfig.toSortingDtos();
}

public int getMaxTasks() {
Expand All @@ -69,12 +69,12 @@ public Long getAsyncResponseTimeout() {
return asyncResponseTimeout;
}

public List<SortingDto> getSortings() {
return sortings;
public List<SortingDto> getSorting() {
return sorting;
}

public void setSortings(List<SortingDto> sortings) {
this.sortings = sortings;
public void setSorting(List<SortingDto> sorting) {
this.sorting = sorting;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class FetchExternalTasksDto {
protected List<FetchExternalTaskTopicDto> topics;
protected boolean includeExtensionProperties = false;

protected List<SortingDto> sortings;
protected List<SortingDto> sorting;

public int getMaxTasks() {
return maxTasks;
Expand Down Expand Up @@ -77,12 +77,12 @@ public void setUsePriority(boolean usePriority) {
this.usePriority = usePriority;
}

public void setSortings(List<SortingDto> sortings) {
this.sortings = sortings;
public void setSorting(List<SortingDto> sorting) {
this.sorting = sorting;
}

public List<SortingDto> getSortings() {
return this.sortings;
public List<SortingDto> getSorting() {
return this.sorting;
}

public boolean isIncludeExtensionProperties() {
Expand Down Expand Up @@ -283,7 +283,7 @@ protected FetchAndLockBuilder getBuilder(ProcessEngine engine) {
.maxTasks(maxTasks)
.usePriority(usePriority);

SortMapper mapper = new SortMapper(sortings, builder);
SortMapper mapper = new SortMapper(sorting, builder);

return mapper.getBuilderWithSortConfigs();
}
Expand All @@ -306,19 +306,19 @@ static class SortMapper {
"desc", FetchAndLockBuilder::desc
);

protected final List<SortingDto> sortings;
protected final List<SortingDto> sorting;
protected final FetchAndLockBuilder builder;

protected SortMapper(List<SortingDto> sortings, FetchAndLockBuilder builder) {
this.sortings = (sortings == null) ? Collections.emptyList() : sortings;
protected SortMapper(List<SortingDto> sorting, FetchAndLockBuilder builder) {
this.sorting = (sorting == null) ? Collections.emptyList() : sorting;
this.builder = builder;
}

/**
* Applies the sorting field mappings to the builder and returns it.
*/
protected FetchAndLockBuilder getBuilderWithSortConfigs() {
sortings.forEach(dto -> {
sorting.forEach(dto -> {
fieldMappingKey(dto).ifPresent(key -> FIELD_MAPPINGS.get(key).accept(builder));
orderMappingKey(dto).ifPresent(key -> ORDER_MAPPINGS.get(key).accept(builder));
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ public void testFetchAndLockWithCreateTimeDesc() {
parameters.put("maxTasks", 5);
parameters.put("workerId", "aWorkerId");
parameters.put("usePriority", false);
parameters.put("sortings", List.of(create("createTime", "desc")));
parameters.put("sorting", List.of(create("createTime", "desc")));

Map<String, Object> topicParameter = new HashMap<>();
topicParameter.put("topicName", "aTopicName");
Expand Down Expand Up @@ -408,7 +408,7 @@ public void testFetchAndLockWithCreateTimeWithoutOrder() {
parameters.put("maxTasks", 5);
parameters.put("workerId", "aWorkerId");
parameters.put("usePriority", false);
parameters.put("sortings", List.of(create("createTime", null)));
parameters.put("sorting", List.of(create("createTime", null)));

Map<String, Object> topicParameter = new HashMap<>();
topicParameter.put("topicName", "aTopicName");
Expand Down

0 comments on commit 3d0fb99

Please sign in to comment.