use of org.jboss.pnc.spi.datastore.repositories.api.PageInfo in project pnc by project-ncl.
the class BuildRecordRepositoryImpl method getAnyLatestSuccessfulBuildRecordWithRevision.
@Override
public BuildRecord getAnyLatestSuccessfulBuildRecordWithRevision(IdRev idRev, boolean temporaryBuild) {
PageInfo pageInfo = new DefaultPageInfo(0, 1);
SortInfo sortInfo = new DefaultSortInfo(SortInfo.SortingDirection.DESC, BuildRecord_.submitTime.getName());
List<BuildRecord> buildRecords = queryWithPredicates(pageInfo, sortInfo, withBuildConfigurationIdRev(idRev), withSuccess(), includeTemporary(temporaryBuild));
if (buildRecords.size() == 0) {
return null;
} else {
return buildRecords.get(0);
}
}
use of org.jboss.pnc.spi.datastore.repositories.api.PageInfo in project pnc by project-ncl.
the class BuildRecordRepositoryImpl method getLatestSuccessfulBuildRecord.
@Override
public BuildRecord getLatestSuccessfulBuildRecord(IdRev idRev, boolean temporaryBuild) {
PageInfo pageInfo = new DefaultPageInfo(0, 1);
SortInfo sortInfo = new DefaultSortInfo(SortInfo.SortingDirection.DESC, BuildRecord_.id.getName());
List<BuildRecord> buildRecords = queryWithPredicates(pageInfo, sortInfo, withBuildConfigurationIdRev(idRev), withSuccess(), includeTemporary(idRev, temporaryBuild));
if (buildRecords.size() == 0) {
return null;
} else {
return buildRecords.get(0);
}
}
use of org.jboss.pnc.spi.datastore.repositories.api.PageInfo in project pnc by project-ncl.
the class AbstractProvider method queryForCollection.
@Override
public Page<DTO> queryForCollection(int pageIndex, int pageSize, String sortingRsql, String query, Predicate<DB>... predicates) {
Predicate<DB> rsqlPredicate = rsqlPredicateProducer.getCriteriaPredicate(type, query);
PageInfo pageInfo = pageInfoProducer.getPageInfo(pageIndex, pageSize);
SortInfo sortInfo = rsqlPredicateProducer.getSortInfo(type, sortingRsql);
List<DB> collection = repository.queryWithPredicates(pageInfo, sortInfo, ObjectArrays.concat(rsqlPredicate, predicates));
int totalHits = repository.count(ObjectArrays.concat(rsqlPredicate, predicates));
int totalPages = (totalHits + pageSize - 1) / pageSize;
List<DTO> content = nullableStreamOf(collection).map(mapper::toDTO).collect(Collectors.toList());
return new Page<>(pageIndex, pageSize, totalPages, totalHits, content);
}
use of org.jboss.pnc.spi.datastore.repositories.api.PageInfo in project pnc by project-ncl.
the class BuildProviderImpl method readLatestFinishedBuild.
private Optional<Build> readLatestFinishedBuild(Predicate<BuildRecord> predicate) {
PageInfo pageInfo = this.pageInfoProducer.getPageInfo(0, 1);
SortInfo sortInfo = this.sortInfoProducer.getSortInfo(SortInfo.SortingDirection.DESC, "submitTime");
List<BuildRecord> buildRecords = repository.queryWithPredicates(pageInfo, sortInfo, predicate);
return buildRecords.stream().map(mapper::toDTO).findFirst();
}
Aggregations