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;
}
Aggregations