use of org.jboss.pnc.model.BuildConfigurationSet in project pnc by project-ncl.
the class BuildConfigurationProviderImpl method addBuildConfigurationToSet.
private void addBuildConfigurationToSet(org.jboss.pnc.model.BuildConfiguration buildConfig, Set<Integer> bcSetIds) {
Set<String> notFoundSets = null;
for (Integer setId : bcSetIds) {
BuildConfigurationSet bcSet = buildConfigurationSetRepository.queryById(setId);
if (bcSet == null) {
if (notFoundSets == null) {
notFoundSets = new HashSet<>();
}
notFoundSets.add(setId.toString());
} else {
if (!bcSet.getBuildConfigurations().contains(buildConfig)) {
bcSet.addBuildConfiguration(buildConfig);
buildConfigurationSetRepository.save(bcSet);
}
}
}
if (notFoundSets != null) {
String ids = String.join(", ", notFoundSets);
throw new IllegalArgumentException("No group configuration exists for ids: " + ids);
}
}
use of org.jboss.pnc.model.BuildConfigurationSet in project pnc by project-ncl.
the class BuildTriggererImpl method doTriggerGroupBuild.
private BuildSetTask doTriggerGroupBuild(final int groupConfigId, Optional<GroupBuildRequest> revs, BuildOptions buildOptions) throws CoreException {
final BuildConfigurationSet buildConfigurationSet = buildConfigurationSetRepository.queryById(groupConfigId);
Preconditions.checkArgument(buildConfigurationSet != null, "Can't find configuration with given id=" + groupConfigId);
List<BuildConfigurationRevisionRef> revisions = revs.map(GroupBuildRequest::getBuildConfigurationRevisions).orElse(Collections.emptyList());
BuildSetTask buildSetTask = buildCoordinator.build(hibernateLazyInitializer.initializeBuildConfigurationSetBeforeTriggeringIt(buildConfigurationSet), loadAuditedsFromDB(buildConfigurationSet, revisions), user.currentUser(), buildOptions);
logger.info("Started build of Group Configuration {}. Build Tasks: {}", groupConfigId, buildSetTask.getBuildTasks().stream().map(BuildTask::getId).collect(Collectors.joining()));
return buildSetTask;
}
use of org.jboss.pnc.model.BuildConfigurationSet in project pnc by project-ncl.
the class GroupConfigurationProviderImpl method archive.
private void archive(String groupConfigurationId) throws DTOValidationException {
ValidationBuilder.validateObject(WhenUpdating.class).validateAgainstRepository(repository, Integer.valueOf(groupConfigurationId), true);
BuildConfigurationSet buildConfigurationSet = repository.queryById(Integer.valueOf(groupConfigurationId));
buildConfigurationSet.setArchived(true);
// if a build group is archived, unlink the build group from the build configurations is associated with
for (BuildConfiguration bc : buildConfigurationSet.getBuildConfigurations()) {
bc.removeBuildConfigurationSet(buildConfigurationSet);
buildConfigurationRepository.save(bc);
buildConfigurationSet.removeBuildConfiguration(bc);
}
repository.save(buildConfigurationSet);
}
use of org.jboss.pnc.model.BuildConfigurationSet in project pnc by project-ncl.
the class GroupConfigurationProviderImpl method removeConfiguration.
@Override
public void removeConfiguration(String id, String configId) {
BuildConfigurationSet buildConfigSet = repository.queryById(Integer.valueOf(id));
BuildConfiguration buildConfig = buildConfigurationRepository.queryById(Integer.valueOf(configId));
ValidationBuilder.validateObject(buildConfigSet, WhenUpdating.class).validateCondition(buildConfigSet != null, "No build configuration set exists with id: " + id).validateCondition(buildConfig != null, "No build configuration exists with id: " + configId);
if (buildConfigSet.getBuildConfigurations().contains(buildConfig)) {
buildConfigSet.removeBuildConfiguration(buildConfig);
repository.save(buildConfigSet);
}
}
Aggregations