Commit 28815040 authored by Matija Obreza's avatar Matija Obreza

Obsoleted filterByCode methods

parent 7369d070
......@@ -15,6 +15,7 @@
*/
package org.genesys.catalog.api.v0;
import org.apache.commons.lang3.StringUtils;
import org.genesys.catalog.api.FilteredPage;
import org.genesys.catalog.exceptions.NotFoundElement;
import org.genesys.catalog.model.dataset.AccessionIdentifier;
......@@ -81,11 +82,18 @@ public class DatasetController {
*/
@PostMapping(value = "/list")
public FilteredPage<Dataset> datasetList(@RequestParam(name = "p", required = false, defaultValue = "0") final int page,
@RequestParam(name = "l", required = false, defaultValue = "50") final int pageSize,
@RequestParam(name = "d", required = false, defaultValue = "ASC") final Sort.Direction direction,
@RequestParam(name = "s", required = false, defaultValue = "id") final String[] sort, @RequestBody final DatasetFilter filter) {
return new FilteredPage<>(shortFilterService.getCode(filter), filter, datasetService.listDatasets(filter, new PageRequest(page, Integer.min(pageSize, 100), direction, sort)));
@RequestParam(name = "l", required = false, defaultValue = "50") final int pageSize,
@RequestParam(name = "d", required = false, defaultValue = "ASC") final Sort.Direction direction,
@RequestParam(name = "s", required = false, defaultValue = "id") final String[] sort,
@RequestParam(name = "f", required = false) String filterCode,
@RequestBody DatasetFilter filter) throws IOException {
if (StringUtils.isNotBlank(filterCode)) {
filter = shortFilterService.filterByCode(filterCode, DatasetFilter.class);
} else {
filterCode = shortFilterService.getCode(filter);
}
return new FilteredPage<>(filterCode, filter, datasetService.listDatasets(filter, new PageRequest(page, Integer.min(pageSize, 100), direction, sort)));
}
/**
......@@ -98,6 +106,7 @@ public class DatasetController {
* @param filterCode the filter code
* @return the filtered page
* @throws IOException Signals that an I/O exception has occurred.
* @deprecated Use {@link #datasetList(int, int, org.springframework.data.domain.Sort.Direction, String[], String, DatasetFilter)}
*/
@PostMapping(value = "/list/{filterCode}")
public FilteredPage<Dataset> datasetListShort(@RequestParam(name = "p", required = false, defaultValue = "0") final int page,
......
......@@ -15,10 +15,11 @@
*/
package org.genesys.catalog.api.v0;
import com.fasterxml.jackson.annotation.JsonView;
import io.swagger.annotations.Api;
import java.io.IOException;
import java.util.List;
import java.util.UUID;
import org.apache.commons.lang3.StringUtils;
import org.genesys.blocks.model.JsonViews;
import org.genesys.catalog.api.FilteredPage;
import org.genesys.catalog.model.dataset.Dataset;
......@@ -32,11 +33,19 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.io.IOException;
import java.util.List;
import java.util.UUID;
import com.fasterxml.jackson.annotation.JsonView;
import io.swagger.annotations.Api;
/**
* The Class DescriptorController.
......@@ -78,14 +87,22 @@ public class DescriptorController {
* @param sort the sort
* @param filter the descriptor filter
* @return the page
* @throws IOException
*/
@PostMapping(value = "/list")
public FilteredPage<Descriptor> listDescriptorsByFilter(@RequestParam(name = "p", required = false, defaultValue = "0") final int page,
@RequestParam(name = "l", required = false, defaultValue = "50") final int pageSize,
@RequestParam(name = "d", required = false, defaultValue = "ASC") final Sort.Direction direction,
@RequestParam(name = "s", required = false, defaultValue = "id") final String[] sort, @RequestBody final DescriptorFilter filter) {
@RequestParam(name = "s", required = false, defaultValue = "id") final String[] sort,
@RequestParam(name = "f", required = false) String filterCode,
@RequestBody DescriptorFilter filter) throws IOException {
return new FilteredPage<>(shortFilterService.getCode(filter), filter, descriptorService.listDescriptors(filter, new PageRequest(page, Integer.min(pageSize, 100), direction, sort)));
if (StringUtils.isNotBlank(filterCode)) {
filter = shortFilterService.filterByCode(filterCode, DescriptorFilter.class);
} else {
filterCode = shortFilterService.getCode(filter);
}
return new FilteredPage<>(filterCode, filter, descriptorService.listDescriptors(filter, new PageRequest(page, Integer.min(pageSize, 100), direction, sort)));
}
/**
......@@ -98,6 +115,7 @@ public class DescriptorController {
* @param filterCode the filter code
* @return the filtered page
* @throws IOException Signals that an I/O exception has occurred.
* @deprecated Use {@link #listDescriptorsByFilter(int, int, org.springframework.data.domain.Sort.Direction, String[], DescriptorFilter)}
*/
@PostMapping(value = "/list/{filterCode}")
public FilteredPage<Descriptor> listDescriptorsByShort(@RequestParam(name = "p", required = false, defaultValue = "0") final int page,
......
......@@ -202,6 +202,7 @@ public class DescriptorListController {
* @param filterCode the filter code
* @return the filtered page
* @throws IOException Signals that an I/O exception has occurred.
* @deprecated Use {@link #listDescriptorLists(int, int, org.springframework.data.domain.Sort.Direction, String[], String, DescriptorListFilter)}
*/
@PostMapping(value = "/list/{filterCode}")
public FilteredPage<DescriptorList> listDescriptorListsByCode(@RequestParam(name = "p", required = false, defaultValue = "0") final int page,
......
......@@ -15,6 +15,10 @@
*/
package org.genesys.catalog.api.v0;
import java.io.IOException;
import java.util.UUID;
import org.apache.commons.lang3.StringUtils;
import org.genesys.catalog.api.FilteredPage;
import org.genesys.catalog.model.Partner;
import org.genesys.catalog.model.filters.PartnerFilter;
......@@ -25,13 +29,17 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;
import java.io.IOException;
import java.util.UUID;
/**
* Rest controller for Partner.
*
......@@ -61,14 +69,22 @@ public class PartnerController {
* @param sort the sort
* @param filter the partner filter
* @return the page
* @throws IOException
*/
@PostMapping(value = "/list")
public FilteredPage<Partner> listPartners(@RequestParam(name = "p", required = false, defaultValue = "0") final int page,
@RequestParam(name = "l", required = false, defaultValue = "50") final int pageSize,
@RequestParam(name = "d", required = false, defaultValue = "ASC") final Sort.Direction direction,
@RequestParam(name = "s", required = false, defaultValue = "id") final String[] sort, @RequestBody final PartnerFilter filter) {
@RequestParam(name = "s", required = false, defaultValue = "id") final String[] sort,
@RequestParam(name = "f", required = false) String filterCode,
@RequestBody PartnerFilter filter) throws IOException {
return new FilteredPage<>(shortFilterService.getCode(filter), filter, partnerService.listPartners(filter, new PageRequest(page, Integer.min(pageSize, 100), direction, sort)));
if (StringUtils.isNotBlank(filterCode)) {
filter = shortFilterService.filterByCode(filterCode, PartnerFilter.class);
} else {
filterCode = shortFilterService.getCode(filter);
}
return new FilteredPage<>(filterCode, filter, partnerService.listPartners(filter, new PageRequest(page, Integer.min(pageSize, 100), direction, sort)));
}
/**
......@@ -81,6 +97,7 @@ public class PartnerController {
* @param filterCode the filter code
* @return the filtered page
* @throws IOException Signals that an I/O exception has occurred.
* @deprecated Use {@link #listPartners(int, int, org.springframework.data.domain.Sort.Direction, String[], String, PartnerFilter)}
*/
@PostMapping(value = "/list/{filterCode}")
public FilteredPage<Partner> listPartners2(@RequestParam(name = "p", required = false, defaultValue = "0") final int page,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment