use of org.wso2.carbon.apimgt.rest.api.store.v1.dto.PaginationDTO in project carbon-apimgt by wso2.
the class ApplicationMappingUtil method setPaginationParams.
/**
* Sets pagination urls for a ApplicationListDTO object given pagination parameters and url parameters
*
* @param applicationListDTO a SubscriptionListDTO object
* @param limit max number of objects returned
* @param offset starting index
* @param size max offset
*/
public static void setPaginationParams(ApplicationListDTO applicationListDTO, int limit, int offset, int size) {
Map<String, Integer> paginatedParams = RestApiCommonUtil.getPaginationParams(offset, limit, size);
String paginatedPrevious = "";
String paginatedNext = "";
if (paginatedParams.get(RestApiConstants.PAGINATION_PREVIOUS_OFFSET) != null) {
paginatedPrevious = RestApiCommonUtil.getApplicationPaginatedURL(paginatedParams.get(RestApiConstants.PAGINATION_PREVIOUS_OFFSET), paginatedParams.get(RestApiConstants.PAGINATION_PREVIOUS_LIMIT), null);
}
if (paginatedParams.get(RestApiConstants.PAGINATION_NEXT_OFFSET) != null) {
paginatedNext = RestApiCommonUtil.getApplicationPaginatedURL(paginatedParams.get(RestApiConstants.PAGINATION_NEXT_OFFSET), paginatedParams.get(RestApiConstants.PAGINATION_NEXT_LIMIT), null);
}
PaginationDTO paginationDTO = getPaginationDTO(limit, offset, size, paginatedNext, paginatedPrevious);
applicationListDTO.setPagination(paginationDTO);
}
use of org.wso2.carbon.apimgt.rest.api.store.v1.dto.PaginationDTO in project carbon-apimgt by wso2.
the class APIMappingUtil method setPaginationParams.
/**
* Sets pagination urls for a APIProductListDTO object given pagination parameters and url parameters.
*
* @param apiProductListDTO a APIProductListDTO object
* @param query search condition
* @param limit max number of objects returned
* @param offset starting index
* @param size max offset
*/
public static void setPaginationParams(APIProductListDTO apiProductListDTO, String query, int offset, int limit, int size) {
// acquiring pagination parameters and setting pagination urls
Map<String, Integer> paginatedParams = RestApiCommonUtil.getPaginationParams(offset, limit, size);
String paginatedPrevious = "";
String paginatedNext = "";
if (paginatedParams.get(RestApiConstants.PAGINATION_PREVIOUS_OFFSET) != null) {
paginatedPrevious = RestApiCommonUtil.getAPIProductPaginatedURL(paginatedParams.get(RestApiConstants.PAGINATION_PREVIOUS_OFFSET), paginatedParams.get(RestApiConstants.PAGINATION_PREVIOUS_LIMIT), query);
}
if (paginatedParams.get(RestApiConstants.PAGINATION_NEXT_OFFSET) != null) {
paginatedNext = RestApiCommonUtil.getAPIProductPaginatedURL(paginatedParams.get(RestApiConstants.PAGINATION_NEXT_OFFSET), paginatedParams.get(RestApiConstants.PAGINATION_NEXT_LIMIT), query);
}
PaginationDTO paginationDTO = CommonMappingUtil.getPaginationDTO(limit, offset, size, paginatedNext, paginatedPrevious);
apiProductListDTO.setPagination(paginationDTO);
}
use of org.wso2.carbon.apimgt.rest.api.store.v1.dto.PaginationDTO in project carbon-apimgt by wso2.
the class APIMappingUtil method setPaginationParamsForAPIResourcePathList.
/**
* Sets pagination urls for a ResourcePathListDTO object.
*
* @param resourcePathListDTO ResourcePathListDTO object to which pagination urls need to be set
* @param offset starting index
* @param limit max number of returned objects
* @param size max offset
*/
public static void setPaginationParamsForAPIResourcePathList(ResourcePathListDTO resourcePathListDTO, int offset, int limit, int size) {
// acquiring pagination parameters and setting pagination urls
Map<String, Integer> paginatedParams = RestApiCommonUtil.getPaginationParams(offset, limit, size);
String paginatedPrevious = "";
String paginatedNext = "";
if (paginatedParams.get(RestApiConstants.PAGINATION_PREVIOUS_OFFSET) != null) {
paginatedPrevious = RestApiCommonUtil.getResourcePathPaginatedURL(paginatedParams.get(RestApiConstants.PAGINATION_PREVIOUS_OFFSET), paginatedParams.get(RestApiConstants.PAGINATION_PREVIOUS_LIMIT));
}
if (paginatedParams.get(RestApiConstants.PAGINATION_NEXT_OFFSET) != null) {
paginatedNext = RestApiCommonUtil.getResourcePathPaginatedURL(paginatedParams.get(RestApiConstants.PAGINATION_NEXT_OFFSET), paginatedParams.get(RestApiConstants.PAGINATION_NEXT_LIMIT));
}
PaginationDTO paginationDTO = CommonMappingUtil.getPaginationDTO(limit, offset, size, paginatedNext, paginatedPrevious);
resourcePathListDTO.setPagination(paginationDTO);
}
use of org.wso2.carbon.apimgt.rest.api.store.v1.dto.PaginationDTO in project carbon-apimgt by wso2.
the class APIMappingUtil method setPaginationParams.
/**
* Sets pagination urls for a APIListDTO object given pagination parameters and url parameters.
*
* @param apiListDTO a APIListDTO object
* @param query search condition
* @param limit max number of objects returned
* @param offset starting index
* @param size max offset
*/
public static void setPaginationParams(Object apiListDTO, String query, int offset, int limit, int size) {
// acquiring pagination parameters and setting pagination urls
Map<String, Integer> paginatedParams = RestApiCommonUtil.getPaginationParams(offset, limit, size);
String paginatedPrevious = "";
String paginatedNext = "";
if (paginatedParams.get(RestApiConstants.PAGINATION_PREVIOUS_OFFSET) != null) {
paginatedPrevious = RestApiCommonUtil.getAPIPaginatedURL(paginatedParams.get(RestApiConstants.PAGINATION_PREVIOUS_OFFSET), paginatedParams.get(RestApiConstants.PAGINATION_PREVIOUS_LIMIT), query);
}
if (paginatedParams.get(RestApiConstants.PAGINATION_NEXT_OFFSET) != null) {
paginatedNext = RestApiCommonUtil.getAPIPaginatedURL(paginatedParams.get(RestApiConstants.PAGINATION_NEXT_OFFSET), paginatedParams.get(RestApiConstants.PAGINATION_NEXT_LIMIT), query);
}
PaginationDTO paginationDTO = CommonMappingUtil.getPaginationDTO(limit, offset, size, paginatedNext, paginatedPrevious);
((APIListDTO) apiListDTO).setPagination(paginationDTO);
}
use of org.wso2.carbon.apimgt.rest.api.store.v1.dto.PaginationDTO in project carbon-apimgt by wso2.
the class CommentMappingUtil method fromCommentListToDTO.
/**
* Wraps a List of Comments to a CommentListDTO.
*
* @param commentList list of comments
* @return CommentListDTO
*/
public static CommentListDTO fromCommentListToDTO(CommentList commentList, boolean includeCommenterInfo) {
CommentListDTO commentListDTO = new CommentListDTO();
List<CommentDTO> listOfCommentDTOs = new ArrayList<>();
commentListDTO.setCount(commentList.getCount());
PaginationDTO paginationDTO = new PaginationDTO();
paginationDTO.setLimit(commentList.getPagination().getLimit());
paginationDTO.setOffset(commentList.getPagination().getOffset());
paginationDTO.setTotal(commentList.getPagination().getTotal());
paginationDTO.setNext(commentList.getPagination().getNext());
paginationDTO.setPrevious(commentList.getPagination().getPrevious());
commentListDTO.setPagination(paginationDTO);
Map<String, Map<String, String>> userClaimsMap = new HashMap<>();
for (Comment comment : commentList.getList()) {
try {
if (includeCommenterInfo) {
userClaimsMap = retrieveUserClaims(comment.getUser(), userClaimsMap);
listOfCommentDTOs.add(fromCommentToDTOWithUserInfo(comment, userClaimsMap));
} else {
listOfCommentDTOs.add(fromCommentToDTO(comment));
}
} catch (APIManagementException e) {
log.error("Error while creating comments list", e);
}
}
commentListDTO.setList(listOfCommentDTOs);
return commentListDTO;
}
Aggregations