use of org.jboss.pnc.model.BuildConfiguration in project pnc by project-ncl.
the class BuildConfigurationAuditedRepositoryImpl method createAudited.
private BuildConfigurationAudited createAudited(Object entity, Object revision) {
BuildConfiguration buildConfiguration = (BuildConfiguration) entity;
DefaultRevisionEntity revisionEntity = (DefaultRevisionEntity) revision;
// preload generic parameters
buildConfiguration.getGenericParameters().forEach((k, v) -> k.equals(null));
return BuildConfigurationAudited.fromBuildConfiguration(buildConfiguration, revisionEntity.getId());
}
use of org.jboss.pnc.model.BuildConfiguration in project pnc by project-ncl.
the class BuildConfigurationAuditedRepositoryImpl method queryById.
@Override
public BuildConfigurationAudited queryById(IdRev idRev) {
logger.trace("Querying for BuildConfigurationAudited.idRev: {}.", idRev);
BuildConfiguration buildConfiguration = AuditReaderFactory.get(entityManager).find(BuildConfiguration.class, idRev.getId(), idRev.getRev());
if (buildConfiguration == null) {
return null;
}
// preload generic parameters
buildConfiguration.getGenericParameters().forEach((k, v) -> k.equals(null));
return BuildConfigurationAudited.fromBuildConfiguration(buildConfiguration, idRev.getRev());
}
use of org.jboss.pnc.model.BuildConfiguration in project pnc by project-ncl.
the class DefaultDatastore method requiresRebuild.
@Override
@TransactionAttribute(TransactionAttributeType.REQUIRED)
public boolean requiresRebuild(BuildConfigurationAudited buildConfigurationAudited, boolean checkImplicitDependencies, boolean temporaryBuild, AlignmentPreference alignmentPreference, Set<Integer> processedDependenciesCache, Consumer<BuildRecord> nonRebuildCauseSetter) {
IdRev idRev = buildConfigurationAudited.getIdRev();
// Step 1 - Check the existence of a build with the same revision
BuildRecord latestSuccessfulBuildRecord = buildRecordRepository.getAnyLatestSuccessfulBuildRecordWithRevision(idRev, temporaryBuild);
if (latestSuccessfulBuildRecord == null) {
logger.debug("Rebuild of buildConfiguration.idRev: {} required as there is no successful BuildRecord.", idRev);
return true;
}
// Step 2 - Check the existence of more recent builds with different revision
if (!isLatestSuccessBRFromThisBCA(buildConfigurationAudited, temporaryBuild)) {
return true;
}
// Step 3 - check implicit dependencies
if (checkImplicitDependencies) {
logger.debug("Checking if BCA: {} has implicit dependencies that need rebuild", idRev);
boolean rebuild = hasARebuiltImplicitDependency(latestSuccessfulBuildRecord, temporaryBuild, alignmentPreference, processedDependenciesCache);
logger.debug("Implicit dependency check for rebuild of buildConfiguration.idRev: {} required: {}.", idRev, rebuild);
if (rebuild) {
return true;
}
}
// Step 4 - check explicit dependencies
Set<BuildConfiguration> dependencies = buildConfigurationAudited.getBuildConfiguration().getDependencies();
boolean rebuild = hasARebuiltExplicitDependency(latestSuccessfulBuildRecord, dependencies, temporaryBuild, alignmentPreference);
logger.debug("Explicit dependency check for rebuild of buildConfiguration.idRev: {} required: {}.", idRev, rebuild);
if (!rebuild) {
nonRebuildCauseSetter.accept(latestSuccessfulBuildRecord);
}
return rebuild;
}
use of org.jboss.pnc.model.BuildConfiguration in project pnc by project-ncl.
the class BuildConfigProviderTest method fill.
@Before
public void fill() {
User currentUser = prepareNewUser();
when(userService.currentUser()).thenReturn(currentUser);
when(buildEnvironmentRepository.queryById(anyInt())).thenAnswer(i -> mockEnvironment(12));
final BuildConfiguration a = prepareBuildConfig("First!", 1, 1, 1);
final BuildConfiguration b = prepareBuildConfig("Second!!", 1, 2, 2, a);
final BuildConfiguration c = prepareBuildConfig("THIRD!!!", 2, 2, 3, a, b);
final BuildConfiguration d = prepareBuildConfig("Fourth-_-", 3, 3, 3, a, b, c);
List<BuildConfiguration> configs = new ArrayList<>(Arrays.asList(new BuildConfiguration[] { a, b, c, d, bc }));
fillRepository(configs);
}
use of org.jboss.pnc.model.BuildConfiguration in project pnc by project-ncl.
the class GroupConfigurationProviderTest method testRemoveConfiguration.
@Test
public void testRemoveConfiguration() {
// With
//
org.jboss.pnc.dto.GroupConfiguration groupConfiguration = provider.getSpecific("1");
BuildConfiguration toRemove = bcs.getBuildConfigurations().stream().findFirst().get();
when(buildConfigurationRepository.queryById(toRemove.getId())).thenReturn(toRemove);
assertThat(groupConfiguration.getBuildConfigs()).containsKey(toRemove.getId().toString());
// When
provider.removeConfiguration(groupConfiguration.getId(), toRemove.getId().toString());
// Then
org.jboss.pnc.dto.GroupConfiguration refreshed = provider.getSpecific(groupConfiguration.getId());
assertThat(refreshed.getBuildConfigs().values()).doNotHave(new Condition<>(toRemove::equals, "BC is equal to 'toRemove' bc"));
}
Aggregations