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;
}
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);
}
}
Aggregations