use of org.wso2.carbon.apimgt.rest.api.admin.v1.dto.PaginationDTO in project carbon-apimgt by wso2.
the class ThrottlingPolicyMappingUtil method setPaginationParams.
/**
* Sets pagination urls for a TierListDTO object given pagination parameters and url parameters
*
* @param tierListDTO a TierListDTO object
* @param limit max number of objects returned
* @param offset starting index
* @param size max offset
*/
public static void setPaginationParams(ThrottlingPolicyListDTO tierListDTO, String tierLevel, int limit, int offset, int size) {
String paginatedPrevious = "";
String paginatedNext = "";
Map<String, Integer> paginatedParams = RestApiCommonUtil.getPaginationParams(offset, limit, size);
if (paginatedParams.get(RestApiConstants.PAGINATION_PREVIOUS_OFFSET) != null) {
paginatedPrevious = RestApiCommonUtil.getTiersPaginatedURL(tierLevel, paginatedParams.get(RestApiConstants.PAGINATION_PREVIOUS_OFFSET), paginatedParams.get(RestApiConstants.PAGINATION_PREVIOUS_LIMIT));
}
if (paginatedParams.get(RestApiConstants.PAGINATION_NEXT_OFFSET) != null) {
paginatedNext = RestApiCommonUtil.getTiersPaginatedURL(tierLevel, paginatedParams.get(RestApiConstants.PAGINATION_NEXT_OFFSET), paginatedParams.get(RestApiConstants.PAGINATION_NEXT_LIMIT));
}
PaginationDTO paginationDTO = CommonMappingUtil.getPaginationDTO(limit, offset, size, paginatedNext, paginatedPrevious);
tierListDTO.setPagination(paginationDTO);
}
use of org.wso2.carbon.apimgt.rest.api.admin.v1.dto.PaginationDTO in project carbon-apimgt by wso2.
the class ServiceEntryMappingUtil method setPaginationParams.
public static void setPaginationParams(ServiceListDTO serviceListDTO, int offset, int limit, int size, ServiceFilterParams filterParams) {
Map<String, Integer> paginatedParams = RestApiCommonUtil.getPaginationParams(offset, limit, size);
String paginatedPrevious = "";
String paginatedNext = "";
if (paginatedParams.get(RestApiConstants.PAGINATION_PREVIOUS_OFFSET) != null) {
paginatedPrevious = getServicesPaginatedUrl(paginatedParams.get(RestApiConstants.PAGINATION_PREVIOUS_OFFSET), paginatedParams.get(RestApiConstants.PAGINATION_PREVIOUS_LIMIT), filterParams);
}
if (paginatedParams.get(RestApiConstants.PAGINATION_NEXT_OFFSET) != null) {
paginatedNext = getServicesPaginatedUrl(paginatedParams.get(RestApiConstants.PAGINATION_NEXT_OFFSET), paginatedParams.get(RestApiConstants.PAGINATION_NEXT_LIMIT), filterParams);
}
PaginationDTO paginationDTO = getPaginationDTO(limit, offset, size, paginatedNext, paginatedPrevious);
serviceListDTO.setPagination(paginationDTO);
}
use of org.wso2.carbon.apimgt.rest.api.admin.v1.dto.PaginationDTO in project carbon-apimgt by wso2.
the class OperationPolicyMappingUtil method fromOperationPolicyDataListToDTO.
public static OperationPolicyDataListDTO fromOperationPolicyDataListToDTO(List<OperationPolicyData> policyDataList, int offset, int limit) {
List<OperationPolicyDataDTO> operationPolicyList = new ArrayList<>();
if (policyDataList == null) {
policyDataList = new ArrayList<>();
}
int size = policyDataList.size();
int start = offset < size && offset >= 0 ? offset : Integer.MAX_VALUE;
int end = Math.min(offset + limit - 1, size - 1);
for (int i = start; i <= end; i++) {
operationPolicyList.add(fromOperationPolicyDataToDTO(policyDataList.get(i)));
}
PaginationDTO paginationDTO = new PaginationDTO();
paginationDTO.setLimit(limit);
paginationDTO.setOffset(offset);
paginationDTO.setTotal(size);
OperationPolicyDataListDTO dataListDTO = new OperationPolicyDataListDTO();
dataListDTO.setList(operationPolicyList);
dataListDTO.setCount(operationPolicyList.size());
dataListDTO.setPagination(paginationDTO);
return dataListDTO;
}
use of org.wso2.carbon.apimgt.rest.api.admin.v1.dto.PaginationDTO in project carbon-apimgt by wso2.
the class SubscriptionMappingUtil method setPaginationParams.
/**
* Sets pagination urls for a SubscriptionListDTO object given pagination parameters and url parameters
*
* @param subscriptionListDTO a SubscriptionListDTO object
* @param apiId uuid/id of API
* @param groupId group id of the applications to be returned
* @param limit max number of objects returned
* @param offset starting index
* @param size max offset
*/
public static void setPaginationParams(SubscriptionListDTO subscriptionListDTO, String apiId, String groupId, int limit, int offset, int size) {
String paginatedPrevious = "";
String paginatedNext = "";
Map<String, Integer> paginatedParams = RestApiCommonUtil.getPaginationParams(offset, limit, size);
if (paginatedParams.get(RestApiConstants.PAGINATION_PREVIOUS_OFFSET) != null) {
paginatedPrevious = RestApiCommonUtil.getSubscriptionPaginatedURLForAPIId(paginatedParams.get(RestApiConstants.PAGINATION_PREVIOUS_OFFSET), paginatedParams.get(RestApiConstants.PAGINATION_PREVIOUS_LIMIT), apiId, groupId);
}
if (paginatedParams.get(RestApiConstants.PAGINATION_NEXT_OFFSET) != null) {
paginatedNext = RestApiCommonUtil.getSubscriptionPaginatedURLForAPIId(paginatedParams.get(RestApiConstants.PAGINATION_NEXT_OFFSET), paginatedParams.get(RestApiConstants.PAGINATION_NEXT_LIMIT), apiId, groupId);
}
PaginationDTO pagination = new PaginationDTO();
pagination.setOffset(offset);
pagination.setLimit(limit);
pagination.setNext(paginatedNext);
pagination.setPrevious(paginatedPrevious);
pagination.setTotal(size);
subscriptionListDTO.setPagination(pagination);
}
use of org.wso2.carbon.apimgt.rest.api.admin.v1.dto.PaginationDTO in project carbon-apimgt by wso2.
the class ApplicationMappingUtil method setPaginationParamsWithSortParams.
/**
* Sets pagination urls for a ApplicationListDTO object given pagination parameters and url parameters with
* sortOrder and sortBy params.
*
* @param applicationListDTO a SubscriptionListDTO object
* @param groupId group id of the applications to be returned
* @param limit max number of objects returned
* @param offset starting index
* @param size max offset
* @param sortOrder sorting order
* @param sortBy specified sort param
*/
public static void setPaginationParamsWithSortParams(ApplicationListDTO applicationListDTO, String groupId, int limit, int offset, int size, String sortOrder, String sortBy) {
Map<String, Integer> paginatedParams = RestApiCommonUtil.getPaginationParams(offset, limit, size);
String paginatedPrevious = "";
String paginatedNext = "";
if (paginatedParams.get(RestApiConstants.PAGINATION_PREVIOUS_OFFSET) != null) {
paginatedPrevious = RestApiCommonUtil.getApplicationPaginatedURLWithSortParams(paginatedParams.get(RestApiConstants.PAGINATION_PREVIOUS_OFFSET), paginatedParams.get(RestApiConstants.PAGINATION_PREVIOUS_LIMIT), groupId, sortOrder, sortBy);
}
if (paginatedParams.get(RestApiConstants.PAGINATION_NEXT_OFFSET) != null) {
paginatedNext = RestApiCommonUtil.getApplicationPaginatedURLWithSortParams(paginatedParams.get(RestApiConstants.PAGINATION_NEXT_OFFSET), paginatedParams.get(RestApiConstants.PAGINATION_NEXT_LIMIT), groupId, sortOrder, sortBy);
}
PaginationDTO paginationDTO = CommonMappingUtil.getPaginationDTO(limit, offset, size, paginatedNext, paginatedPrevious);
applicationListDTO.setPagination(paginationDTO);
}
Aggregations