Search in sources :

Example 21 with Base32LongID

use of org.jboss.pnc.model.Base32LongID in project pnc by project-ncl.

the class DatastoreAdapter method initBuildRecordBuilder.

/**
 * Initialize a new BuildRecord.Builder based on the data contained in the BuildTask. Note, this must be done inside
 * a transaction because it fetches the BuildRecordSet entities from the database.
 *
 * @return The initialized build record builder
 */
private BuildRecord.Builder initBuildRecordBuilder(BuildTask buildTask) {
    BuildOptions buildOptions = buildTask.getBuildOptions();
    BuildRecord.Builder builder = BuildRecord.Builder.newBuilder().id(buildTask.getId()).buildConfigurationAudited(buildTask.getBuildConfigurationAudited()).user(buildTask.getUser()).submitTime(buildTask.getSubmitTime()).startTime(buildTask.getStartTime()).productMilestone(buildTask.getProductMilestone()).temporaryBuild(buildOptions.isTemporaryBuild()).alignmentPreference(buildOptions.getAlignmentPreference()).noRebuildCause(buildTask.getNoRebuildCause());
    if (buildTask.getEndTime() == null) {
        buildTask.setEndTime(Date.from(Instant.now()));
    }
    builder.endTime(buildTask.getEndTime());
    if (buildTask.getBuildConfigSetRecordId() != null) {
        BuildConfigSetRecord buildConfigSetRecord = datastore.getBuildConfigSetRecordById(buildTask.getBuildConfigSetRecordId());
        builder.buildConfigSetRecord(buildConfigSetRecord);
    }
    List<Base32LongID> dependencies = buildTask.getDependencies().stream().map(BuildTask::getId).map(Base32LongID::new).collect(Collectors.toList());
    builder.dependencyBuildRecordIds(dependencies.toArray(new Base32LongID[dependencies.size()]));
    List<Base32LongID> dependants = buildTask.getDependants().stream().map(BuildTask::getId).map(Base32LongID::new).collect(Collectors.toList());
    builder.dependentBuildRecordIds(dependants.toArray(new Base32LongID[dependants.size()]));
    return builder;
}
Also used : Base32LongID(org.jboss.pnc.model.Base32LongID) BuildTask(org.jboss.pnc.spi.coordinator.BuildTask) BuildOptions(org.jboss.pnc.spi.BuildOptions) BuildRecord(org.jboss.pnc.model.BuildRecord) BuildConfigSetRecord(org.jboss.pnc.model.BuildConfigSetRecord)

Example 22 with Base32LongID

use of org.jboss.pnc.model.Base32LongID in project pnc by project-ncl.

the class BuildResultPushManagerTest method buildRecord.

private BuildRecord buildRecord(boolean withExecutionRootName) {
    BuildRecord record = new BuildRecord();
    record.setId(new Base32LongID(Sequence.nextId()));
    record.setStatus(BuildStatus.SUCCESS);
    record.setBuildConfigurationAudited(bca);
    record.setDependencies(Collections.emptySet());
    record.setStartTime(new Date());
    record.setEndTime(new Date());
    record.setScmRepoURL("https://example.com/foo.git");
    record.setScmRevision("abcdef012345");
    if (withExecutionRootName) {
        record.setExecutionRootName("execution:root");
    }
    buildRecordRepository.save(record);
    return record;
}
Also used : Base32LongID(org.jboss.pnc.model.Base32LongID) BuildRecord(org.jboss.pnc.model.BuildRecord) Date(java.util.Date)

Example 23 with Base32LongID

use of org.jboss.pnc.model.Base32LongID in project pnc by project-ncl.

the class BuildProviderImpl method getBuiltArtifactIds.

@Override
public Set<String> getBuiltArtifactIds(String buildId) {
    final Base32LongID id = parseId(buildId);
    BuildRecord buildRecord = repository.queryById(id);
    return nullableStreamOf(buildRecord.getBuiltArtifacts()).map(builtArtifact -> builtArtifact.getId().toString()).collect(Collectors.toSet());
}
Also used : PageInfo(org.jboss.pnc.spi.datastore.repositories.api.PageInfo) BuildConfiguration(org.jboss.pnc.model.BuildConfiguration) Vertex(org.jboss.util.graph.Vertex) Arrays(java.util.Arrays) RolesAllowed(javax.annotation.security.RolesAllowed) ArtifactRepository(org.jboss.pnc.spi.datastore.repositories.ArtifactRepository) SYSTEM_USER(org.jboss.pnc.facade.providers.api.UserRoles.SYSTEM_USER) StringUtils(org.jboss.pnc.common.util.StringUtils) BuildConfigSetRecordRepository(org.jboss.pnc.spi.datastore.repositories.BuildConfigSetRecordRepository) Map(java.util.Map) RunningBuildCount(org.jboss.pnc.dto.response.RunningBuildCount) BigInteger(java.math.BigInteger) EJBAccessException(javax.ejb.EJBAccessException) BuildConfigurationRevision(org.jboss.pnc.dto.BuildConfigurationRevision) BuildConfigurationRepository(org.jboss.pnc.spi.datastore.repositories.BuildConfigurationRepository) User(org.jboss.pnc.model.User) BuildRef(org.jboss.pnc.dto.BuildRef) SortInfoProducer(org.jboss.pnc.spi.datastore.repositories.SortInfoProducer) Gerrit(org.jboss.pnc.common.gerrit.Gerrit) BuildProvider(org.jboss.pnc.facade.providers.api.BuildProvider) Set(java.util.Set) BuildRecordPredicates.withArtifactProduced(org.jboss.pnc.spi.datastore.predicates.BuildRecordPredicates.withArtifactProduced) IdRev(org.jboss.pnc.model.IdRev) BuildRecordPredicates.withPerformedInMilestone(org.jboss.pnc.spi.datastore.predicates.BuildRecordPredicates.withPerformedInMilestone) Base32LongID(org.jboss.pnc.model.Base32LongID) BuildRecordPredicates.withBuildConfigurationId(org.jboss.pnc.spi.datastore.predicates.BuildRecordPredicates.withBuildConfigurationId) BuildTask(org.jboss.pnc.spi.coordinator.BuildTask) HttpUtils(org.jboss.pnc.common.util.HttpUtils) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) BuildPageInfo(org.jboss.pnc.facade.providers.api.BuildPageInfo) BuildRecordPredicates.withoutImplicitDependants(org.jboss.pnc.spi.datastore.predicates.BuildRecordPredicates.withoutImplicitDependants) DTOValidationException(org.jboss.pnc.facade.validation.DTOValidationException) StreamSupport(java.util.stream.StreamSupport) CorruptedDataException(org.jboss.pnc.facade.validation.CorruptedDataException) ResultMapper(org.jboss.pnc.mapper.api.ResultMapper) ValidationException(org.jboss.pnc.spi.exception.ValidationException) BuildRecordPredicates.withoutLinkedNRRRecordOlderThanTimestamp(org.jboss.pnc.spi.datastore.predicates.BuildRecordPredicates.withoutLinkedNRRRecordOlderThanTimestamp) BuildRecord(org.jboss.pnc.model.BuildRecord) TemporaryBuildsCleanerAsyncInvoker(org.jboss.pnc.coordinator.maintenance.TemporaryBuildsCleanerAsyncInvoker) Page(org.jboss.pnc.dto.response.Page) BuildRecordPredicates(org.jboss.pnc.spi.datastore.predicates.BuildRecordPredicates) BuildRecordPredicates.withBuildConfigSetId(org.jboss.pnc.spi.datastore.predicates.BuildRecordPredicates.withBuildConfigSetId) InvalidEntityException(org.jboss.pnc.facade.validation.InvalidEntityException) StreamHelper.nullableStreamOf(org.jboss.pnc.common.util.StreamHelper.nullableStreamOf) BuildRecordPredicates.buildFinishedBefore(org.jboss.pnc.spi.datastore.predicates.BuildRecordPredicates.buildFinishedBefore) LongBase32IdConverter(org.jboss.pnc.common.pnc.LongBase32IdConverter) Date(java.util.Date) Spliterators(java.util.Spliterators) URISyntaxException(java.net.URISyntaxException) LoggerFactory(org.slf4j.LoggerFactory) BuildConfigurationAuditedRepository(org.jboss.pnc.spi.datastore.repositories.BuildConfigurationAuditedRepository) GraphUtils(org.jboss.pnc.common.graph.GraphUtils) BuildConfigurationAudited(org.jboss.pnc.model.BuildConfigurationAudited) EmptyEntityException(org.jboss.pnc.facade.validation.EmptyEntityException) DefaultPageInfo(org.jboss.pnc.spi.datastore.repositories.api.impl.DefaultPageInfo) UserService(org.jboss.pnc.facade.util.UserService) Graph(org.jboss.pnc.dto.response.Graph) BuildRecordPredicates.withUserId(org.jboss.pnc.spi.datastore.predicates.BuildRecordPredicates.withUserId) BuildConfigurationRevisionMapper(org.jboss.pnc.mapper.api.BuildConfigurationRevisionMapper) URI(java.net.URI) Stateless(javax.ejb.Stateless) PermitAll(javax.annotation.security.PermitAll) Collection(java.util.Collection) Artifact(org.jboss.pnc.model.Artifact) BuildCoordinator(org.jboss.pnc.spi.coordinator.BuildCoordinator) Result(org.jboss.pnc.spi.coordinator.Result) BuildRecordInsights(org.jboss.pnc.dto.insights.BuildRecordInsights) RepositoryViolationException(org.jboss.pnc.facade.validation.RepositoryViolationException) Math.min(java.lang.Math.min) Collectors(java.util.stream.Collectors) BuildStatus(org.jboss.pnc.enums.BuildStatus) Objects(java.util.Objects) BuildRecordPredicates.withBuildConfigSetRecordId(org.jboss.pnc.spi.datastore.predicates.BuildRecordPredicates.withBuildConfigSetRecordId) List(java.util.List) GerritException(org.jboss.pnc.common.gerrit.GerritException) ConflictedEntryException(org.jboss.pnc.facade.validation.ConflictedEntryException) Optional(java.util.Optional) BuildRecordPredicates.withAttribute(org.jboss.pnc.spi.datastore.predicates.BuildRecordPredicates.withAttribute) Spliterator(java.util.Spliterator) BuildRecordPredicates.withoutAttribute(org.jboss.pnc.spi.datastore.predicates.BuildRecordPredicates.withoutAttribute) BuildConfigSetRecord(org.jboss.pnc.model.BuildConfigSetRecord) SortInfo(org.jboss.pnc.spi.datastore.repositories.api.SortInfo) Getter(lombok.Getter) Predicate(org.jboss.pnc.spi.datastore.repositories.api.Predicate) Function(java.util.function.Function) BuildMapper(org.jboss.pnc.mapper.api.BuildMapper) HashSet(java.util.HashSet) Inject(javax.inject.Inject) BuildRecordRepository(org.jboss.pnc.spi.datastore.repositories.BuildRecordRepository) GraphBuilder(org.jboss.pnc.common.graph.GraphBuilder) Attributes(org.jboss.pnc.constants.Attributes) MergeIterator(org.jboss.pnc.facade.util.MergeIterator) NoSuchElementException(java.util.NoSuchElementException) SSHCredentials(org.jboss.pnc.dto.response.SSHCredentials) ArtifactPredicates.withIds(org.jboss.pnc.spi.datastore.predicates.ArtifactPredicates.withIds) TimeUtils(org.jboss.pnc.common.util.TimeUtils) Logger(org.slf4j.Logger) Iterator(java.util.Iterator) BuildRecordPredicates.withArtifactDependency(org.jboss.pnc.spi.datastore.predicates.BuildRecordPredicates.withArtifactDependency) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) BuildConfigurationPredicates.withProjectId(org.jboss.pnc.spi.datastore.predicates.BuildConfigurationPredicates.withProjectId) Consumer(java.util.function.Consumer) BuildRecordPredicates.temporaryBuild(org.jboss.pnc.spi.datastore.predicates.BuildRecordPredicates.temporaryBuild) GraphDtoBuilder(org.jboss.pnc.facade.util.GraphDtoBuilder) Build(org.jboss.pnc.dto.Build) BuildRecordPredicates.withBuildConfigurationIds(org.jboss.pnc.spi.datastore.predicates.BuildRecordPredicates.withBuildConfigurationIds) Comparator(java.util.Comparator) Collections(java.util.Collections) Base32LongID(org.jboss.pnc.model.Base32LongID) BuildRecord(org.jboss.pnc.model.BuildRecord)

Example 24 with Base32LongID

use of org.jboss.pnc.model.Base32LongID in project pnc by project-ncl.

the class DeliverableAnalyzerManagerImpl method analyzeDeliverables.

@Override
public DeliverableAnalyzerOperation analyzeDeliverables(String id, List<String> sourcesLink) {
    int i = 1;
    Map<String, String> inputParams = new HashMap<>();
    for (String url : sourcesLink) {
        inputParams.put(URL_PARAMETER_PREFIX + (i++), url);
    }
    Base32LongID operationId = operationsManager.newDeliverableAnalyzerOperation(id, inputParams).getId();
    try {
        startAnalysis(id, sourcesLink, operationId);
        return deliverableAnalyzerOperationMapper.toDTO((org.jboss.pnc.model.DeliverableAnalyzerOperation) operationsManager.updateProgress(operationId, ProgressStatus.IN_PROGRESS));
    } catch (RuntimeException ex) {
        operationsManager.setResult(operationId, OperationResult.SYSTEM_ERROR);
        throw ex;
    }
}
Also used : Base32LongID(org.jboss.pnc.model.Base32LongID)

Example 25 with Base32LongID

use of org.jboss.pnc.model.Base32LongID in project pnc by project-ncl.

the class BrewPusherImpl method pushBuild.

@Override
public BuildPushResult pushBuild(String buildId, BuildPushParameters buildPushParameters) throws ProcessException {
    Base32LongID id = BuildMapper.idMapper.toEntity(buildId);
    BuildRecord build = buildRecordRepository.queryById(BuildMapper.idMapper.toEntity(buildId));
    if (build.getStatus().equals(BuildStatus.NO_REBUILD_REQUIRED)) {
        throw new OperationNotAllowedException("Build has NO_REBUILD_REQUIRED status, push last successful build or use force-rebuild.");
    }
    Long buildPushResultId = Sequence.nextId();
    MDCUtils.addProcessContext(buildPushResultId.toString());
    MDCUtils.addCustomContext(BUILD_ID_KEY, id.getId());
    try {
        return doPushBuild(id, buildPushParameters, buildPushResultId);
    } finally {
        MDCUtils.removeProcessContext();
        MDCUtils.removeCustomContext(BUILD_ID_KEY);
    }
}
Also used : Base32LongID(org.jboss.pnc.model.Base32LongID) OperationNotAllowedException(org.jboss.pnc.facade.validation.OperationNotAllowedException) BuildRecord(org.jboss.pnc.model.BuildRecord)

Aggregations

Base32LongID (org.jboss.pnc.model.Base32LongID)26 BuildRecord (org.jboss.pnc.model.BuildRecord)18 Test (org.junit.Test)7 Build (org.jboss.pnc.dto.Build)6 BuildConfigurationAudited (org.jboss.pnc.model.BuildConfigurationAudited)6 Date (java.util.Date)5 BuildPageInfo (org.jboss.pnc.facade.providers.api.BuildPageInfo)5 IdRev (org.jboss.pnc.model.IdRev)5 BuildTask (org.jboss.pnc.spi.coordinator.BuildTask)5 List (java.util.List)4 Map (java.util.Map)4 Set (java.util.Set)4 BuildConfigSetRecord (org.jboss.pnc.model.BuildConfigSetRecord)4 Collectors (java.util.stream.Collectors)3 Stateless (javax.ejb.Stateless)3 Inject (javax.inject.Inject)3 BuildConfiguration (org.jboss.pnc.model.BuildConfiguration)3 BuildConfigurationAuditedRepository (org.jboss.pnc.spi.datastore.repositories.BuildConfigurationAuditedRepository)3 BuildRecordRepository (org.jboss.pnc.spi.datastore.repositories.BuildRecordRepository)3 Logger (org.slf4j.Logger)3