Commit cd98608b authored by Matija Obreza's avatar Matija Obreza
Browse files

Duplicated myDescriptors, myDatasets from /me controller in correct controllers

- Methods from /me to be removed after UI is updated
parent e358ef76
......@@ -77,6 +77,34 @@ public class DatasetController {
@Autowired
protected DescriptorService descriptorService;
/**
* My datasets.
*
* @param page the page
* @param pageSize the page size
* @param direction the direction
* @param sort the sort
* @param filterCode short filter code -- overrides filter in body
* @param filter the filter
* @return the page
* @throws IOException
*/
@PostMapping(value = "/list-mine")
public FilteredPage<Dataset> myDatasets(@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 = "DESC") final Sort.Direction direction,
@RequestParam(name = "s", required = false, defaultValue = "lastModifiedDate") final String[] sort,
@RequestParam(name = "f", required = false) String filterCode,
@RequestBody(required = false) DatasetFilter filter) throws IOException {
if (filterCode != null) {
filter = shortFilterService.filterByCode(filterCode, DatasetFilter.class);
} else {
filterCode = shortFilterService.getCode(filter);
}
return new FilteredPage<>(filterCode, filter, datasetService.listDatasetsForCurrentUser(filter, new PageRequest(page, Integer.min(pageSize, 100), direction, sort)));
}
/**
* List datasets.
*
......
......@@ -77,6 +77,33 @@ public class DescriptorController {
return Descriptor.Category.values();
}
/**
* My descriptors.
*
* @param page the page
* @param pageSize the page size
* @param direction the direction
* @param sort the sort
* @param filter the descriptor filter
* @return the page
* @throws IOException
*/
@PostMapping(value = "/list-mine")
public FilteredPage<Descriptor> myDescriptors(@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 = "DESC") final Sort.Direction direction,
@RequestParam(name = "s", required = false, defaultValue = "lastModifiedDate") final String[] sort,
@RequestParam(name = "f", required = false) String filterCode,
@RequestBody(required = false) DescriptorFilter filter) throws IOException {
if (filterCode != null) {
filter = shortFilterService.filterByCode(filterCode, DescriptorFilter.class);
} else {
filterCode = shortFilterService.getCode(filter);
}
return new FilteredPage<>(filterCode, filter, descriptorService.listDescriptorsForCurrentUser(filter, new PageRequest(page, Integer.min(pageSize, 100), direction, sort)));
}
/**
* List descriptors.
*
......
......@@ -173,6 +173,33 @@ public class DescriptorListController {
return descriptorList;
}
/**
* My descriptor lists.
*
* @param page the page
* @param pageSize the page size
* @param direction the direction
* @param sort the sort
* @param descriptorListFilter the descriptor list filter
* @return the page
* @throws IOException
*/
@PostMapping(value = "/list-mine")
public FilteredPage<DescriptorList> myDescriptorLists(@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 = "DESC") final Sort.Direction direction,
@RequestParam(name = "s", required = false, defaultValue = "lastModifiedDate") final String[] sort,
@RequestParam(name = "f", required = false) String filterCode,
@RequestBody(required = false) DescriptorListFilter filter) throws IOException {
if (filterCode != null) {
filter = shortFilterService.filterByCode(filterCode, DescriptorListFilter.class);
} else {
filterCode = shortFilterService.getCode(filter);
}
return new FilteredPage<>(filterCode, filter, descriptorListService.listDescriptorListsForCurrentUser(filter, new PageRequest(page, Integer.min(pageSize, 100), direction, sort)));
}
/**
* List descriptor lists.
*
......
......@@ -158,6 +158,7 @@ public class MeController {
* @param sort the sort
* @param partnerFilter the partner filter
* @return the page
* @deprecated Moved to PartnerController
*/
@PostMapping(value = "/partners")
public Page<Partner> myPartners(@RequestParam(name = "p", required = false, defaultValue = "0") final int page,
......@@ -179,6 +180,7 @@ public class MeController {
* @param filter the filter
* @return the page
* @throws IOException
* @deprecated Moved to DatasetController
*/
@PostMapping(value = "/datasets")
public FilteredPage<Dataset> myDatasets(@RequestParam(name = "p", required = false, defaultValue = "0") final int page,
......@@ -206,6 +208,7 @@ public class MeController {
* @param filter the descriptor filter
* @return the page
* @throws IOException
* @deprecated Moved to DescriptorController
*/
@PostMapping(value = "/descriptors")
public FilteredPage<Descriptor> myDescriptors(@RequestParam(name = "p", required = false, defaultValue = "0") final int page,
......@@ -233,6 +236,7 @@ public class MeController {
* @param descriptorListFilter the descriptor list filter
* @return the page
* @throws IOException
* @deprecated Moved to DescriptorListController
*/
@PostMapping(value = "/descriptorlists")
public FilteredPage<DescriptorList> myDescriptorLists(@RequestParam(name = "p", required = false, defaultValue = "0") final int page,
......
......@@ -25,6 +25,7 @@ import org.genesys.catalog.service.PartnerService;
import org.genesys.catalog.service.ShortFilterService;
import org.genesys2.server.api.ApiBaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.security.access.prepost.PreAuthorize;
......@@ -59,6 +60,26 @@ public class PartnerController {
@Autowired
protected ShortFilterService shortFilterService;
/**
* My partners.
*
* @param page the page
* @param pageSize the page size
* @param direction the direction
* @param sort the sort
* @param partnerFilter the partner filter
* @return the page
*/
@PostMapping(value = "/list-mine")
public Page<Partner> myPartners(@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 = "name") final String[] sort, @RequestBody final PartnerFilter partnerFilter) {
return partnerService.listPartnersForCurrentUser(partnerFilter, new PageRequest(page, Integer.min(pageSize, 100), direction, sort));
}
/**
* List partners.
*
......
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