Search in sources :

Example 6 with TagListDTO

use of org.wso2.carbon.apimgt.rest.api.store.v1.dto.TagListDTO in project carbon-apimgt by wso2.

the class TagMappingUtil method setPaginationParams.

/**
 * Sets pagination urls for a TagListDTO object given pagination parameters and url parameters
 *
 * @param tagListDTO a TagListDTO object
 * @param limit       max number of objects returned
 * @param offset      starting index
 * @param size        max offset
 */
public static void setPaginationParams(TagListDTO tagListDTO, 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.getTagsPaginatedURL(paginatedParams.get(RestApiConstants.PAGINATION_PREVIOUS_OFFSET), paginatedParams.get(RestApiConstants.PAGINATION_PREVIOUS_LIMIT));
    }
    if (paginatedParams.get(RestApiConstants.PAGINATION_NEXT_OFFSET) != null) {
        paginatedNext = RestApiCommonUtil.getTagsPaginatedURL(paginatedParams.get(RestApiConstants.PAGINATION_NEXT_OFFSET), paginatedParams.get(RestApiConstants.PAGINATION_NEXT_LIMIT));
    }
    PaginationDTO paginationDTO = CommonMappingUtil.getPaginationDTO(limit, offset, size, paginatedNext, paginatedPrevious);
    tagListDTO.setPagination(paginationDTO);
}
Also used : PaginationDTO(org.wso2.carbon.apimgt.rest.api.store.v1.dto.PaginationDTO)

Aggregations

Tag (org.wso2.carbon.apimgt.core.models.Tag)3 TagListDTO (org.wso2.carbon.apimgt.rest.api.store.dto.TagListDTO)3 ArrayList (java.util.ArrayList)2 Tag (org.wso2.carbon.apimgt.api.model.Tag)2 TagListDTO (org.wso2.carbon.apimgt.rest.api.store.v1.dto.TagListDTO)2 HashMap (java.util.HashMap)1 Test (org.testng.annotations.Test)1 APIConsumer (org.wso2.carbon.apimgt.api.APIConsumer)1 APIManagementException (org.wso2.carbon.apimgt.api.APIManagementException)1 APIStore (org.wso2.carbon.apimgt.core.api.APIStore)1 APIManagementException (org.wso2.carbon.apimgt.core.exception.APIManagementException)1 ErrorDTO (org.wso2.carbon.apimgt.rest.api.common.dto.ErrorDTO)1 TagDTO (org.wso2.carbon.apimgt.rest.api.store.dto.TagDTO)1 PaginationDTO (org.wso2.carbon.apimgt.rest.api.store.v1.dto.PaginationDTO)1 TagDTO (org.wso2.carbon.apimgt.rest.api.store.v1.dto.TagDTO)1