use of org.apache.inlong.manager.common.pojo.sink.SinkPageRequest in project incubator-inlong by apache.
the class StreamSinkServiceImpl method listByCondition.
@Override
public PageInfo<? extends SinkListResponse> listByCondition(SinkPageRequest request) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("begin to list sink page by " + request);
}
Preconditions.checkNotNull(request.getInlongGroupId(), Constant.GROUP_ID_IS_EMPTY);
PageHelper.startPage(request.getPageNum(), request.getPageSize());
List<StreamSinkEntity> entityPage = sinkMapper.selectByCondition(request);
Map<SinkType, Page<StreamSinkEntity>> sinkMap = Maps.newHashMap();
for (StreamSinkEntity streamSink : entityPage) {
SinkType sinkType = SinkType.forType(streamSink.getSinkType());
sinkMap.computeIfAbsent(sinkType, k -> new Page<>()).add(streamSink);
}
List<SinkListResponse> sinkListResponses = Lists.newArrayList();
for (Map.Entry<SinkType, Page<StreamSinkEntity>> entry : sinkMap.entrySet()) {
SinkType sinkType = entry.getKey();
StreamSinkOperation operation = operationFactory.getInstance(sinkType);
PageInfo<? extends SinkListResponse> pageInfo = operation.getPageInfo(entry.getValue());
sinkListResponses.addAll(pageInfo.getList());
}
// Encapsulate the paging query results into the PageInfo object to obtain related paging information
PageInfo<? extends SinkListResponse> pageInfo = PageInfo.of(sinkListResponses);
LOGGER.debug("success to list sink page");
return pageInfo;
}
Aggregations