Search in sources :

Example 11 with PaginationDTO

use of org.wso2.carbon.apimgt.rest.api.publisher.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);
}
Also used : PaginationDTO(org.wso2.carbon.apimgt.rest.api.store.v1.dto.PaginationDTO)

Example 12 with PaginationDTO

use of org.wso2.carbon.apimgt.rest.api.publisher.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);
}
Also used : PaginationDTO(org.wso2.carbon.apimgt.rest.api.service.catalog.dto.PaginationDTO)

Example 13 with PaginationDTO

use of org.wso2.carbon.apimgt.rest.api.publisher.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;
}
Also used : OperationPolicyDataListDTO(org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.OperationPolicyDataListDTO) ArrayList(java.util.ArrayList) PaginationDTO(org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.PaginationDTO) OperationPolicyDataDTO(org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.OperationPolicyDataDTO)

Example 14 with PaginationDTO

use of org.wso2.carbon.apimgt.rest.api.publisher.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);
}
Also used : PaginationDTO(org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.PaginationDTO)

Example 15 with PaginationDTO

use of org.wso2.carbon.apimgt.rest.api.publisher.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);
}
Also used : PaginationDTO(org.wso2.carbon.apimgt.rest.api.store.v1.dto.PaginationDTO)

Aggregations

PaginationDTO (org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.PaginationDTO)14 PaginationDTO (org.wso2.carbon.apimgt.rest.api.store.v1.dto.PaginationDTO)12 ArrayList (java.util.ArrayList)6 APIManagementException (org.wso2.carbon.apimgt.api.APIManagementException)5 HashMap (java.util.HashMap)3 Map (java.util.Map)3 APIConsumer (org.wso2.carbon.apimgt.api.APIConsumer)2 Comment (org.wso2.carbon.apimgt.api.model.Comment)2 PaginationDTO (org.wso2.carbon.apimgt.rest.api.admin.v1.dto.PaginationDTO)2 ClientCertificatesDTO (org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.ClientCertificatesDTO)2 PaginationDTO (org.wso2.carbon.apimgt.rest.api.service.catalog.dto.PaginationDTO)2 Set (java.util.Set)1 JSONObject (org.json.simple.JSONObject)1 APIProvider (org.wso2.carbon.apimgt.api.APIProvider)1 CertificateMetadataDTO (org.wso2.carbon.apimgt.api.dto.CertificateMetadataDTO)1 ClientCertificateDTO (org.wso2.carbon.apimgt.api.dto.ClientCertificateDTO)1 API (org.wso2.carbon.apimgt.api.model.API)1 APIIdentifier (org.wso2.carbon.apimgt.api.model.APIIdentifier)1 Application (org.wso2.carbon.apimgt.api.model.Application)1 SubscribedAPI (org.wso2.carbon.apimgt.api.model.SubscribedAPI)1