Search in sources :

Example 1 with SourcePageRequest

use of org.apache.inlong.manager.common.pojo.source.SourcePageRequest in project incubator-inlong by apache.

the class StreamSourceServiceImpl method listByCondition.

@Override
public PageInfo<? extends SourceListResponse> listByCondition(SourcePageRequest request) {
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("begin to list source page by " + request);
    }
    Preconditions.checkNotNull(request.getInlongGroupId(), Constant.GROUP_ID_IS_EMPTY);
    PageHelper.startPage(request.getPageNum(), request.getPageSize());
    List<StreamSourceEntity> entityPage = sourceMapper.selectByCondition(request);
    // Encapsulate the paging query results into the PageInfo object to obtain related paging information
    Map<SourceType, Page<StreamSourceEntity>> sourceMap = Maps.newHashMap();
    for (StreamSourceEntity streamSource : entityPage) {
        SourceType sourceType = SourceType.forType(streamSource.getSourceType());
        sourceMap.computeIfAbsent(sourceType, k -> new Page<>()).add(streamSource);
    }
    List<SourceListResponse> sourceListResponses = Lists.newArrayList();
    for (Map.Entry<SourceType, Page<StreamSourceEntity>> entry : sourceMap.entrySet()) {
        SourceType sourceType = entry.getKey();
        StreamSourceOperation operation = operationFactory.getInstance(sourceType);
        PageInfo<? extends SourceListResponse> pageInfo = operation.getPageInfo(entry.getValue());
        sourceListResponses.addAll(pageInfo.getList());
    }
    PageInfo<? extends SourceListResponse> pageInfo = PageInfo.of(sourceListResponses);
    LOGGER.debug("success to list source page");
    return pageInfo;
}
Also used : Date(java.util.Date) LoggerFactory(org.slf4j.LoggerFactory) StreamSourceEntityMapper(org.apache.inlong.manager.dao.mapper.StreamSourceEntityMapper) Autowired(org.springframework.beans.factory.annotation.Autowired) StringUtils(org.apache.commons.lang3.StringUtils) SourceType(org.apache.inlong.manager.common.enums.SourceType) ArrayList(java.util.ArrayList) Lists(com.google.common.collect.Lists) Preconditions(org.apache.inlong.manager.common.util.Preconditions) CollectionUtils(org.apache.commons.collections.CollectionUtils) CommonOperateService(org.apache.inlong.manager.service.CommonOperateService) Service(org.springframework.stereotype.Service) Map(java.util.Map) SourceState(org.apache.inlong.manager.common.enums.SourceState) GroupState(org.apache.inlong.manager.common.enums.GroupState) Logger(org.slf4j.Logger) PageHelper(com.github.pagehelper.PageHelper) PageInfo(com.github.pagehelper.PageInfo) SourceRequest(org.apache.inlong.manager.common.pojo.source.SourceRequest) Maps(com.google.common.collect.Maps) SourceResponse(org.apache.inlong.manager.common.pojo.source.SourceResponse) ErrorCodeEnum(org.apache.inlong.manager.common.enums.ErrorCodeEnum) Constant(org.apache.inlong.manager.common.enums.Constant) SourceListResponse(org.apache.inlong.manager.common.pojo.source.SourceListResponse) List(java.util.List) InlongGroupEntity(org.apache.inlong.manager.dao.entity.InlongGroupEntity) Page(com.github.pagehelper.Page) SourcePageRequest(org.apache.inlong.manager.common.pojo.source.SourcePageRequest) StreamSourceEntity(org.apache.inlong.manager.dao.entity.StreamSourceEntity) CommonBeanUtils(org.apache.inlong.manager.common.util.CommonBeanUtils) Collections(java.util.Collections) Transactional(org.springframework.transaction.annotation.Transactional) SourceType(org.apache.inlong.manager.common.enums.SourceType) StreamSourceEntity(org.apache.inlong.manager.dao.entity.StreamSourceEntity) Page(com.github.pagehelper.Page) Map(java.util.Map) SourceListResponse(org.apache.inlong.manager.common.pojo.source.SourceListResponse)

Aggregations

Page (com.github.pagehelper.Page)1 PageHelper (com.github.pagehelper.PageHelper)1 PageInfo (com.github.pagehelper.PageInfo)1 Lists (com.google.common.collect.Lists)1 Maps (com.google.common.collect.Maps)1 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 Date (java.util.Date)1 List (java.util.List)1 Map (java.util.Map)1 CollectionUtils (org.apache.commons.collections.CollectionUtils)1 StringUtils (org.apache.commons.lang3.StringUtils)1 Constant (org.apache.inlong.manager.common.enums.Constant)1 ErrorCodeEnum (org.apache.inlong.manager.common.enums.ErrorCodeEnum)1 GroupState (org.apache.inlong.manager.common.enums.GroupState)1 SourceState (org.apache.inlong.manager.common.enums.SourceState)1 SourceType (org.apache.inlong.manager.common.enums.SourceType)1 SourceListResponse (org.apache.inlong.manager.common.pojo.source.SourceListResponse)1 SourcePageRequest (org.apache.inlong.manager.common.pojo.source.SourcePageRequest)1 SourceRequest (org.apache.inlong.manager.common.pojo.source.SourceRequest)1