use of org.jboss.pnc.model.BuildRecord in project pnc by project-ncl.
the class BuildRecordRepositoryImpl method getPreferredLatestSuccessfulBuildRecordWithBuildConfig.
@Override
public BuildRecord getPreferredLatestSuccessfulBuildRecordWithBuildConfig(Integer configurationId, boolean temporaryBuild, AlignmentPreference alignmentPreference) {
PageInfo pageInfo = new DefaultPageInfo(0, 1);
SortInfo sortInfo = new DefaultSortInfo(SortInfo.SortingDirection.DESC, BuildRecord_.submitTime.getName());
List<BuildRecord> buildRecords = queryWithPredicates(pageInfo, sortInfo, withBuildConfigurationId(configurationId), withSuccess(), includeTemporary(configurationId, temporaryBuild, alignmentPreference));
if (buildRecords.size() == 0) {
return null;
} else {
return buildRecords.get(0);
}
}
use of org.jboss.pnc.model.BuildRecord in project pnc by project-ncl.
the class DefaultDatastore method hasARebuiltExplicitDependency.
/**
* Check is some of the dependencies defined on BuildConfiguration has newer version.
*/
private boolean hasARebuiltExplicitDependency(BuildRecord latestSuccessfulBuildRecord, Set<BuildConfiguration> dependencies, boolean temporaryBuild, AlignmentPreference alignmentPreference) {
for (BuildConfiguration dependencyBuildConfiguration : dependencies) {
BuildRecord dependencyLatestSuccessfulBuildRecord = buildRecordRepository.getPreferredLatestSuccessfulBuildRecordWithBuildConfig(dependencyBuildConfiguration.getId(), temporaryBuild, alignmentPreference);
if (dependencyLatestSuccessfulBuildRecord == null) {
return true;
}
boolean newer = dependencyLatestSuccessfulBuildRecord.getEndTime().after(latestSuccessfulBuildRecord.getEndTime());
if (newer) {
return true;
}
}
return false;
}
use of org.jboss.pnc.model.BuildRecord in project pnc by project-ncl.
the class BuildConfigurationAuditedRepositoryImpl method getBuildRecords.
/**
* @param buildConfigurationId
* @return List of BuildRecords where only id is fetched
*/
private List<BuildRecord> getBuildRecords(Integer buildConfigurationId) {
CriteriaBuilder cb = entityManager.getCriteriaBuilder();
CriteriaQuery<Base32LongID> query = cb.createQuery(Base32LongID.class);
Root<BuildRecord> root = query.from(BuildRecord.class);
query.select(root.get(BuildRecord_.id));
query.where(cb.equal(root.get(BuildRecord_.buildConfigurationId), buildConfigurationId));
List<Base32LongID> buildRecordIds = entityManager.createQuery(query).getResultList();
return buildRecordIds.stream().map(id -> BuildRecord.Builder.newBuilder().id(id).build()).collect(Collectors.toList());
}
use of org.jboss.pnc.model.BuildRecord in project pnc by project-ncl.
the class BuildConfigurationAuditedRepositoryImpl method getBuildRecords.
/**
* @param idRev
* @return List of BuildRecords where only id is fetched
*/
private List<BuildRecord> getBuildRecords(IdRev idRev) {
CriteriaBuilder cb = entityManager.getCriteriaBuilder();
CriteriaQuery<Base32LongID> query = cb.createQuery(Base32LongID.class);
Root<BuildRecord> root = query.from(BuildRecord.class);
query.select(root.get(BuildRecord_.id));
query.where(cb.and(cb.equal(root.get(BuildRecord_.buildConfigurationId), idRev.getId()), cb.equal(root.get(BuildRecord_.buildConfigurationRev), idRev.getRev())));
List<Base32LongID> buildRecordIds = entityManager.createQuery(query).getResultList();
return buildRecordIds.stream().map(id -> BuildRecord.Builder.newBuilder().id(id).build()).collect(Collectors.toList());
}
use of org.jboss.pnc.model.BuildRecord in project pnc by project-ncl.
the class TemporaryBuildsCleanerTest method shouldNotReturnWithNewNoRebuildRecord.
@Test
public void shouldNotReturnWithNewNoRebuildRecord() throws Exception {
// given
BuildRecord tempBr = initBuildRecordBuilder().submitTime(Date.from(Instant.now().minus(2, ChronoUnit.DAYS))).endTime(Date.from(Instant.now().minus(2, ChronoUnit.DAYS))).temporaryBuild(true).build();
tempBr = buildRecordRepository.save(tempBr);
BuildRecord tempNRRBr = initBuildRecordBuilder().status(BuildStatus.NO_REBUILD_REQUIRED).noRebuildCause(tempBr).temporaryBuild(true).build();
tempNRRBr = buildRecordRepository.save(tempNRRBr);
// when
Page<Build> builds = buildProvider.getAllIndependentTemporaryOlderThanTimestamp(0, 50, null, null, Date.from(Instant.now().minus(1, ChronoUnit.DAYS)).getTime());
// then
assertThat(builds.getContent()).extracting("id", String.class).doesNotContain(BuildMapper.idMapper.toDto(tempBr.getId()), BuildMapper.idMapper.toDto(tempNRRBr.getId()));
}
Aggregations