Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sort resource search result by type #892

Merged
merged 5 commits into from
Sep 15, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: use typeSort when retrieving resources
  • Loading branch information
Laura Molnar committed Sep 15, 2021
commit 9c9d31a3efd3b2be0c31b60a949237d520f61cac
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,21 @@
*/
package com.b2international.snowowl.core.rest.resource;

import java.util.List;
import java.util.Map;

import org.springdoc.api.annotations.ParameterObject;
import org.springframework.web.bind.annotation.*;

import com.b2international.snowowl.core.Resource;
import com.b2international.snowowl.core.Resources;
import com.b2international.snowowl.core.events.util.Promise;
import com.b2international.snowowl.core.request.ResourceRequests;
import com.b2international.snowowl.core.request.SearchResourceRequest.Sort;
import com.b2international.snowowl.core.request.SearchResourceRequest.SortScript;
import com.b2international.snowowl.core.rest.AbstractRestService;
import com.b2international.snowowl.core.rest.domain.ResourceSelectors;
import com.google.common.collect.Lists;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
Expand Down Expand Up @@ -53,6 +59,10 @@ public ResourceRestService() {
})
@GetMapping
public Promise<Resources> searchByGet(@ParameterObject final ResourceRestSearch params) {
List<Sort> sortFields = Lists.newArrayList();
sortFields.add(SortScript.of("typeSort", Map.of(), true));
molnarlaura marked this conversation as resolved.
Show resolved Hide resolved
sortFields.addAll(extractSortFields(params.getSort()));

return ResourceRequests.prepareSearch()
.filterByIds(params.getId())
.filterByResourceTypes(params.getResourceType())
Expand All @@ -66,7 +76,7 @@ public Promise<Resources> searchByGet(@ParameterObject final ResourceRestSearch
.setExpand(params.getExpand())
.setFields(params.getField())
.setSearchAfter(params.getSearchAfter())
.sortBy(extractSortFields(params.getSort()))
.sortBy(sortFields)
.buildAsync()
.execute(getBus());
}
Expand Down