use of org.jboss.pnc.model.BuildRecord in project pnc by project-ncl.
the class BuildProviderImpl method setDependentArtifacts.
@RolesAllowed(SYSTEM_USER)
@Override
public void setDependentArtifacts(String buildId, List<String> artifactIds) {
BuildRecord buildRecord = repository.queryById(parseId(buildId));
Set<Artifact> artifacts = artifactIds.stream().map(aId -> Artifact.Builder.newBuilder().id(Integer.valueOf(aId)).build()).collect(Collectors.toSet());
buildRecord.setDependencies(artifacts);
repository.save(buildRecord);
}
use of org.jboss.pnc.model.BuildRecord 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());
}
use of org.jboss.pnc.model.BuildRecord in project pnc by project-ncl.
the class BuildProviderImpl method addAttribute.
@Override
public void addAttribute(String buildId, String key, String value) {
BuildRecord buildRecord = getBuildRecord(buildId);
if (null == key) {
throw new IllegalArgumentException("Attribute key must not be null");
}
if (!key.matches("[a-zA-Z_0-9]+")) {
throw new IllegalArgumentException("Attribute key must match [a-zA-Z_0-9]+");
}
switch(key) {
case // workaround for NCL-4889
Attributes.BUILD_BREW_NAME:
buildRecord.setExecutionRootName(value);
break;
case // workaround for NCL-4889
Attributes.BUILD_BREW_VERSION:
buildRecord.setExecutionRootVersion(value);
break;
default:
buildRecord.putAttribute(key, value);
break;
}
repository.save(buildRecord);
}
use of org.jboss.pnc.model.BuildRecord in project pnc by project-ncl.
the class BuildProviderImpl method readLatestFinishedBuild.
private Optional<Build> readLatestFinishedBuild(Predicate<BuildRecord> predicate) {
PageInfo pageInfo = this.pageInfoProducer.getPageInfo(0, 1);
SortInfo sortInfo = this.sortInfoProducer.getSortInfo(SortInfo.SortingDirection.DESC, "submitTime");
List<BuildRecord> buildRecords = repository.queryWithPredicates(pageInfo, sortInfo, predicate);
return buildRecords.stream().map(mapper::toDTO).findFirst();
}
use of org.jboss.pnc.model.BuildRecord in project pnc by project-ncl.
the class BuildProviderImpl method removeAttribute.
@Override
public void removeAttribute(String buildId, String key) {
BuildRecord buildRecord = getBuildRecord(buildId);
switch(key) {
case // workaround for NCL-4889
Attributes.BUILD_BREW_NAME:
buildRecord.setExecutionRootName(null);
break;
case // workaround for NCL-4889
Attributes.BUILD_BREW_VERSION:
buildRecord.setExecutionRootVersion(null);
break;
default:
buildRecord.removeAttribute(key);
break;
}
repository.save(buildRecord);
}
Aggregations