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

feat(rest) : Search for vendors added #2934

Merged
merged 1 commit into from
Mar 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,15 @@ public List<Vendor> getVendors() {
}
}

public List<Vendor> searchVendors(String searchText) {
try {
VendorService.Iface sw360VendorClient = getThriftVendorClient();
return sw360VendorClient.searchVendors(searchText);
} catch (TException e) {
throw new RuntimeException(e);
}
}

public Vendor getVendorById(String vendorId) {
try {
VendorService.Iface sw360VendorClient = getThriftVendorClient();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
import java.util.List;
import jakarta.servlet.http.HttpServletResponse;

import static com.google.common.base.Strings.isNullOrEmpty;
import static org.eclipse.sw360.datahandler.common.SW360Constants.CONTENT_TYPE_OPENXML_SPREADSHEET;
import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo;

Expand All @@ -78,10 +79,17 @@ public class VendorController implements RepresentationModelProcessor<Repository
)
@RequestMapping(value = VENDORS_URL, method = RequestMethod.GET)
public ResponseEntity<CollectionModel<EntityModel<Vendor>>> getVendors(
@Parameter(description = "Search text")
@RequestParam(value = "searchText", required = false) String searchText,
Pageable pageable,
HttpServletRequest request
) throws TException, URISyntaxException, PaginationParameterException, ResourceClassNotFoundException {
List<Vendor> vendors = vendorService.getVendors();
List<Vendor> vendors = null;
if (!isNullOrEmpty(searchText)) {
vendors = vendorService.searchVendors(searchText);
} else {
vendors = vendorService.getVendors();
}

PaginationResult<Vendor> paginationResult = restControllerHelper.createPaginationResult(request, pageable, vendors, SW360Constants.TYPE_VENDOR);
List<EntityModel<Vendor>> vendorResources = new ArrayList<>();
Expand Down