use of org.jboss.pnc.model.Base32LongID in project pnc by project-ncl.
the class ProductMilestoneReleaseManager method storeBuildRecordPush.
private void storeBuildRecordPush(BuildImportResultRest buildRest, ProductMilestoneRelease productMilestoneRelease) {
Base32LongID recordId = BuildMapper.idMapper.toEntity(buildRest.getBuildRecordId());
BuildRecord record = buildRecordRepository.queryById(recordId);
if (record == null) {
log.error("No record found for record id: {}, skipped saving info: {}", recordId, buildRest);
return;
}
BuildPushStatus status;
try {
status = convertStatus(buildRest.getStatus());
} catch (ProcessManagerException e) {
log.error("Cannot convert status.", e);
throw new RuntimeException("Cannot convert status.", e);
}
BuildRecordPushResult buildRecordPush = BuildRecordPushResult.newBuilder().id(Sequence.nextId()).buildRecord(record).status(status).brewBuildId(buildRest.getBrewBuildId()).brewBuildUrl(buildRest.getBrewBuildUrl()).tagPrefix(// TODO tag!
"").productMilestoneRelease(productMilestoneRelease).build();
buildRecordPushResultRepository.save(buildRecordPush);
}
use of org.jboss.pnc.model.Base32LongID 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.Base32LongID 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.Base32LongID in project pnc by project-ncl.
the class BuildProviderImplTest method testFilterFinishedBuildsByBuildConfigName.
@Test
public void testFilterFinishedBuildsByBuildConfigName() {
// Given
Base32LongID givenIdAndBcName = new Base32LongID(85792L);
mockBuildTask();
mockBuildTask();
BuildRecord givenBuild = mockBuildRecord(givenIdAndBcName, new Long[0], new Long[0]);
when(buildConfigurationAuditedRepository.searchIdRevForBuildConfigurationName(givenIdAndBcName.toString())).thenReturn(Stream.of(givenBuild.getBuildConfigurationAuditedIdRev()).collect(Collectors.toList()));
// When
BuildPageInfo pageInfo = new BuildPageInfo(0, 10, "", "", false, false, givenIdAndBcName.toString());
Page<Build> builds = provider.getBuilds(pageInfo);
// Then
assertEquals(1, builds.getTotalHits());
Iterator<Build> it = builds.getContent().iterator();
assertEquals(BuildMapper.idMapper.toDto(givenBuild.getId()), it.next().getId());
}
use of org.jboss.pnc.model.Base32LongID in project pnc by project-ncl.
the class BuildProviderImplTest method testGetBuildsPages.
@Test
public void testGetBuildsPages() {
// Prepare
BuildRecord build8 = mockBuildRecord();
BuildTask build7 = mockBuildTask();
BuildRecord build6 = mockBuildRecord();
BuildTask build5 = mockBuildTask();
BuildRecord build4 = mockBuildRecord();
BuildTask build3 = mockBuildTask();
BuildRecord build2 = mockBuildRecord();
BuildTask build1 = mockBuildTask();
testPage(0, 2, new Base32LongID(build1.getId()), build2.getId());
testPage(1, 2, new Base32LongID(build3.getId()), build4.getId());
testPage(2, 2, new Base32LongID(build5.getId()), build6.getId());
testPage(3, 2, new Base32LongID(build7.getId()), build8.getId());
testPage(1, 3, build4.getId(), new Base32LongID(build5.getId()), build6.getId());
testPage(2, 3, new Base32LongID(build7.getId()), build8.getId());
testPage(2, 10);
}
Aggregations