Search in sources :

Example 6 with ArtifactQuality

use of org.jboss.pnc.enums.ArtifactQuality in project pnc by project-ncl.

the class DefaultDatastore method storeCompletedBuild.

@Override
@TransactionAttribute(TransactionAttributeType.REQUIRED)
public BuildRecord storeCompletedBuild(BuildRecord.Builder buildRecordBuilder, List<Artifact> builtArtifacts, List<Artifact> dependencies) {
    BuildRecord buildRecord = buildRecordBuilder.build(true);
    logger.debug("Storing completed build {}.", buildRecord);
    BuildRecord previouslySavedBuild = buildRecordRepository.queryById(buildRecord.getId());
    if (previouslySavedBuild != null) {
        throw new IllegalStateException("When trying to save build " + buildRecord + " previously saved build with status " + previouslySavedBuild.getStatus() + " was found.");
    }
    if (logger.isTraceEnabled()) {
        logger.trace("Build Log: {}.", buildRecord.getBuildLog());
    }
    Map<TargetRepository.IdentifierPath, TargetRepository> repositoriesCache = new HashMap<>();
    Map<Artifact.IdentifierSha256, Artifact> artifactCache = new HashMap<>();
    /**
     * Built artifacts must be saved before the dependencies. In case an artifact is built and the dependency
     * (re-downloaded), it must be linked to built artifacts repository.
     */
    logger.debug("Saving built artifacts ...");
    final Set<Artifact> savedBuiltArtifacts = saveArtifacts(builtArtifacts, repositoriesCache, artifactCache);
    logger.debug("Saving dependencies ...");
    buildRecord.setDependencies(saveArtifacts(dependencies, repositoriesCache, artifactCache));
    logger.debug("Done saving artifacts.");
    logger.trace("Saving build record {}.", buildRecord);
    buildRecord = buildRecordRepository.save(buildRecord);
    logger.debug("Build record {} saved.", buildRecord.getId());
    ArtifactQuality quality = buildRecord.isTemporaryBuild() ? ArtifactQuality.TEMPORARY : ArtifactQuality.NEW;
    logger.trace("Setting artifacts as built and their quality to {}.", quality);
    for (Artifact builtArtifact : savedBuiltArtifacts) {
        builtArtifact.setBuildRecord(buildRecord);
        builtArtifact.setArtifactQuality(quality);
    }
    return buildRecord;
}
Also used : TargetRepository(org.jboss.pnc.model.TargetRepository) HashMap(java.util.HashMap) ArtifactQuality(org.jboss.pnc.enums.ArtifactQuality) BuildRecord(org.jboss.pnc.model.BuildRecord) Artifact(org.jboss.pnc.model.Artifact) TransactionAttribute(javax.ejb.TransactionAttribute)

Example 7 with ArtifactQuality

use of org.jboss.pnc.enums.ArtifactQuality in project pnc by project-ncl.

the class BuildEndpointImpl method createBuiltArtifactsQualityLevelRevisions.

@Override
public void createBuiltArtifactsQualityLevelRevisions(String id, String quality, String reason) {
    Set<String> builtArtifactIds = provider.getBuiltArtifactIds(id);
    for (String builtArtifactId : builtArtifactIds) {
        artifactProvider.createQualityLevelRevision(builtArtifactId, quality, reason);
    }
    ArtifactQuality newQuality = ArtifactQuality.valueOf(quality.toUpperCase());
    if (ArtifactQuality.DELETED.equals(newQuality)) {
        provider.addAttribute(id, Attributes.DELETE_REASON, reason);
    } else if (ArtifactQuality.BLACKLISTED.equals(newQuality)) {
        provider.addAttribute(id, Attributes.BLACKLIST_REASON, reason);
    }
}
Also used : ArtifactQuality(org.jboss.pnc.enums.ArtifactQuality)

Aggregations

ArtifactQuality (org.jboss.pnc.enums.ArtifactQuality)7 Artifact (org.jboss.pnc.model.Artifact)3 TargetRepository (org.jboss.pnc.model.TargetRepository)3 HashSet (java.util.HashSet)2 List (java.util.List)2 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)2 Condition (org.assertj.core.api.Condition)2 Page (org.jboss.pnc.dto.response.Page)2 RepositoryType (org.jboss.pnc.enums.RepositoryType)2 InvalidEntityException (org.jboss.pnc.facade.validation.InvalidEntityException)2 ArtifactAudited (org.jboss.pnc.model.ArtifactAudited)2 User (org.jboss.pnc.model.User)2 ArtifactRepository (org.jboss.pnc.spi.datastore.repositories.ArtifactRepository)2 BuildRecordRepository (org.jboss.pnc.spi.datastore.repositories.BuildRecordRepository)2 TargetRepositoryRepository (org.jboss.pnc.spi.datastore.repositories.TargetRepositoryRepository)2 Assert.assertEquals (org.junit.Assert.assertEquals)2 Assert.fail (org.junit.Assert.fail)2 Before (org.junit.Before)2 Test (org.junit.Test)2 RunWith (org.junit.runner.RunWith)2