Search in sources :

Example 26 with BuildConfigurationSet

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);
    }
}
Also used : BuildConfigurationSet(org.jboss.pnc.model.BuildConfigurationSet)

Example 27 with BuildConfigurationSet

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;
}
Also used : BuildConfigurationSet(org.jboss.pnc.model.BuildConfigurationSet) BuildTask(org.jboss.pnc.spi.coordinator.BuildTask) BuildSetTask(org.jboss.pnc.spi.coordinator.BuildSetTask) BuildConfigurationRevisionRef(org.jboss.pnc.dto.BuildConfigurationRevisionRef)

Example 28 with BuildConfigurationSet

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);
}
Also used : BuildConfiguration(org.jboss.pnc.model.BuildConfiguration) BuildConfigurationSet(org.jboss.pnc.model.BuildConfigurationSet) WhenUpdating(org.jboss.pnc.dto.validation.groups.WhenUpdating)

Example 29 with 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);
    }
}
Also used : BuildConfiguration(org.jboss.pnc.model.BuildConfiguration) BuildConfigurationSet(org.jboss.pnc.model.BuildConfigurationSet)

Aggregations

BuildConfigurationSet (org.jboss.pnc.model.BuildConfigurationSet)29 BuildSetTask (org.jboss.pnc.spi.coordinator.BuildSetTask)11 Test (org.junit.Test)11 BuildConfiguration (org.jboss.pnc.model.BuildConfiguration)8 BuildOptions (org.jboss.pnc.spi.BuildOptions)8 BuildSetStatus (org.jboss.pnc.spi.BuildSetStatus)5 BuildTask (org.jboss.pnc.spi.coordinator.BuildTask)5 CoreException (org.jboss.pnc.spi.exception.CoreException)5 Inject (javax.inject.Inject)4 BuildConfigSetRecord (org.jboss.pnc.model.BuildConfigSetRecord)4 BuildCoordinator (org.jboss.pnc.spi.coordinator.BuildCoordinator)4 Logger (org.slf4j.Logger)4 LoggerFactory (org.slf4j.LoggerFactory)4 HashSet (java.util.HashSet)3 List (java.util.List)3 Set (java.util.Set)3 Consumer (java.util.function.Consumer)3 BuildStatus (org.jboss.pnc.enums.BuildStatus)3 BuildSetStatusChangedEvent (org.jboss.pnc.spi.events.BuildSetStatusChangedEvent)3 ArrayList (java.util.ArrayList)2