use of org.springframework.data.domain.Pageable in project commons-dao by reportportal.
the class TestItemRepositoryCustomImpl method loadItemsHistoryPage.
@Override
public Page<TestItemHistory> loadItemsHistoryPage(Queryable filter, Pageable pageable, Long projectId, String launchName, int historyDepth, boolean usingHash) {
SelectQuery<? extends Record> filteringQuery = QueryBuilder.newBuilder(filter, QueryUtils.collectJoinFields(filter, pageable.getSort())).with(pageable.getSort()).build();
Field<?> historyGroupingField = usingHash ? TEST_ITEM.TEST_CASE_HASH : TEST_ITEM.UNIQUE_ID;
Page<String> historyBaseline = loadHistoryBaseline(filteringQuery, historyGroupingField, LAUNCH.PROJECT_ID.eq(projectId).and(LAUNCH.NAME.eq(launchName)), pageable);
List<TestItemHistory> itemHistories = historyBaseline.getContent().stream().map(value -> {
List<Long> itemIds = loadHistoryItem(getHistoryFilter(filter, usingHash, value), pageable.getSort(), LAUNCH.PROJECT_ID.eq(projectId).and(LAUNCH.NAME.eq(launchName))).map(testItem -> getHistoryIds(testItem, usingHash, projectId, launchName, historyDepth - 1)).orElseGet(Collections::emptyList);
return new TestItemHistory(value, itemIds);
}).collect(Collectors.toList());
return new PageImpl<>(itemHistories, pageable, historyBaseline.getTotalElements());
}
use of org.springframework.data.domain.Pageable in project commons-dao by reportportal.
the class TestItemRepositoryCustomImpl method loadItemsHistoryPage.
@Override
public Page<TestItemHistory> loadItemsHistoryPage(Queryable filter, Pageable pageable, Long projectId, int historyDepth, boolean usingHash) {
SelectQuery<? extends Record> filteringQuery = QueryBuilder.newBuilder(filter, QueryUtils.collectJoinFields(filter, pageable.getSort())).with(pageable.getSort()).build();
Field<?> historyGroupingField = usingHash ? TEST_ITEM.TEST_CASE_HASH : TEST_ITEM.UNIQUE_ID;
Page<String> historyBaseline = loadHistoryBaseline(filteringQuery, historyGroupingField, LAUNCH.PROJECT_ID.eq(projectId), pageable);
List<TestItemHistory> itemHistories = historyBaseline.getContent().stream().map(value -> {
List<Long> itemIds = loadHistoryItem(getHistoryFilter(filter, usingHash, value), pageable.getSort(), LAUNCH.PROJECT_ID.eq(projectId)).map(testItem -> getHistoryIds(testItem, usingHash, projectId, historyDepth - 1)).orElseGet(Collections::emptyList);
return new TestItemHistory(value, itemIds);
}).collect(Collectors.toList());
return new PageImpl<>(itemHistories, pageable, historyBaseline.getTotalElements());
}
use of org.springframework.data.domain.Pageable in project commons-dao by reportportal.
the class TestItemRepositoryCustomImpl method loadItemsHistoryPage.
@Override
public Page<TestItemHistory> loadItemsHistoryPage(Queryable filter, Pageable pageable, Long projectId, List<Long> launchIds, int historyDepth, boolean usingHash) {
SelectQuery<? extends Record> filteringQuery = QueryBuilder.newBuilder(filter, QueryUtils.collectJoinFields(filter, pageable.getSort())).with(pageable.getSort()).addCondition(LAUNCH.ID.in(launchIds).and(LAUNCH.PROJECT_ID.eq(projectId))).build();
Field<?> historyGroupingField = usingHash ? TEST_ITEM.TEST_CASE_HASH : TEST_ITEM.UNIQUE_ID;
Page<String> historyBaseline = loadHistoryBaseline(filteringQuery, historyGroupingField, LAUNCH.ID.in(launchIds).and(LAUNCH.PROJECT_ID.eq(projectId)), pageable);
List<TestItemHistory> itemHistories = historyBaseline.getContent().stream().map(value -> {
List<Long> itemIds = loadHistoryItem(getHistoryFilter(filter, usingHash, value), pageable.getSort(), LAUNCH.ID.in(launchIds).and(LAUNCH.PROJECT_ID.eq(projectId))).map(testItem -> getHistoryIds(testItem, usingHash, projectId, historyDepth - 1)).orElseGet(Collections::emptyList);
return new TestItemHistory(value, itemIds);
}).collect(Collectors.toList());
return new PageImpl<>(itemHistories, pageable, historyBaseline.getTotalElements());
}
use of org.springframework.data.domain.Pageable in project commons-dao by reportportal.
the class ClusterRepositoryTest method shouldDeleteByLaunchId.
@Test
void shouldDeleteByLaunchId() {
final int removed = clusterRepository.deleteAllByLaunchId(LAUNCH_ID);
assertEquals(3, removed);
final Pageable pageable = PageRequest.of(0, 3, Sort.by(Sort.Order.by(CRITERIA_ID)));
final Page<Cluster> clusters = clusterRepository.findAllByLaunchId(LAUNCH_ID, pageable);
assertTrue(clusters.isEmpty());
}
use of org.springframework.data.domain.Pageable in project commons-dao by reportportal.
the class ClusterRepositoryTest method shouldFindByLaunchId.
@Test
void shouldFindByLaunchId() {
final Pageable pageable = PageRequest.of(0, 3, Sort.by(Sort.Order.by(CRITERIA_ID)));
final Page<Cluster> clusters = clusterRepository.findAllByLaunchId(LAUNCH_ID, pageable);
assertFalse(clusters.isEmpty());
assertEquals(3, clusters.getContent().size());
clusters.getContent().forEach(cluster -> assertEquals(LAUNCH_ID, cluster.getLaunchId()));
}
Aggregations