Search in sources :

Example 1 with GraphDtoBuilder

use of org.jboss.pnc.facade.util.GraphDtoBuilder in project pnc by project-ncl.

the class BuildProviderImpl method getDependencyGraph.

@Override
public Graph<Build> getDependencyGraph(String buildId) {
    Build specific = getSpecific(buildId);
    if (specific == null) {
        throw new EmptyEntityException("there is no record for given buildId.");
    }
    org.jboss.util.graph.Graph<BuildWithDependencies> buildGraph = createBuildDependencyGraph(buildId);
    GraphDtoBuilder<BuildWithDependencies, Build> graphBuilder = new GraphDtoBuilder();
    return graphBuilder.from(buildGraph, Build.class, vertex -> vertex.getData().getBuild());
}
Also used : EmptyEntityException(org.jboss.pnc.facade.validation.EmptyEntityException) GraphDtoBuilder(org.jboss.pnc.facade.util.GraphDtoBuilder) BuildRecordPredicates.temporaryBuild(org.jboss.pnc.spi.datastore.predicates.BuildRecordPredicates.temporaryBuild) Build(org.jboss.pnc.dto.Build)

Example 2 with GraphDtoBuilder

use of org.jboss.pnc.facade.util.GraphDtoBuilder in project pnc by project-ncl.

the class BuildProviderImpl method getBuildGraphForGroupBuild.

@Override
public Graph<Build> getBuildGraphForGroupBuild(String groupBuildId) {
    BuildConfigSetRecord buildConfigSetRecord = buildConfigSetRecordRepository.queryById(Integer.valueOf(groupBuildId));
    if (buildConfigSetRecord == null) {
        throw new EmptyEntityException("Build group " + groupBuildId + " does not exists.");
    }
    List<String> runningAndStoredIds = getBuildIdsInTheGroup(buildConfigSetRecord);
    org.jboss.util.graph.Graph<BuildWithDependencies> buildGraph = new org.jboss.util.graph.Graph<>();
    for (String buildId : runningAndStoredIds) {
        org.jboss.util.graph.Graph<BuildWithDependencies> dependencyGraph = createBuildDependencyGraph(buildId);
        GraphUtils.merge(buildGraph, dependencyGraph);
        logger.trace("Merged graph from buildRecordId {} to BuildConfigSetRecordGraph {}; Edges {},", buildId, buildGraph, buildGraph.getEdges());
    }
    GraphDtoBuilder<BuildWithDependencies, Build> graphBuilder = new GraphDtoBuilder();
    Graph<Build> graphDto = graphBuilder.from(buildGraph, Build.class, vertex -> vertex.getData().getBuild());
    return graphDto;
}
Also used : GraphDtoBuilder(org.jboss.pnc.facade.util.GraphDtoBuilder) EmptyEntityException(org.jboss.pnc.facade.validation.EmptyEntityException) Graph(org.jboss.pnc.dto.response.Graph) BuildRecordPredicates.temporaryBuild(org.jboss.pnc.spi.datastore.predicates.BuildRecordPredicates.temporaryBuild) Build(org.jboss.pnc.dto.Build) BuildConfigSetRecord(org.jboss.pnc.model.BuildConfigSetRecord)

Aggregations

Build (org.jboss.pnc.dto.Build)2 GraphDtoBuilder (org.jboss.pnc.facade.util.GraphDtoBuilder)2 EmptyEntityException (org.jboss.pnc.facade.validation.EmptyEntityException)2 BuildRecordPredicates.temporaryBuild (org.jboss.pnc.spi.datastore.predicates.BuildRecordPredicates.temporaryBuild)2 Graph (org.jboss.pnc.dto.response.Graph)1 BuildConfigSetRecord (org.jboss.pnc.model.BuildConfigSetRecord)1