Search in sources :

Example 1 with FanInEventListener

use of com.thoughtworks.go.server.service.dd.FanInEventListener in project gocd by gocd.

the class PipelineService method getRevisionsBasedOnDependenciesForDebug.

// This is for debugging purposes
public String getRevisionsBasedOnDependenciesForDebug(CaseInsensitiveString pipelineName, final Integer targetIterationCount) {
    CruiseConfig cruiseConfig = goConfigService.getCurrentConfig();
    FanInGraph fanInGraph = new FanInGraph(cruiseConfig, pipelineName, materialRepository, pipelineDao, systemEnvironment, materialConfigConverter);
    final String[] iterationData = { null };
    fanInGraph.setFanInEventListener(new FanInEventListener() {

        @Override
        public void iterationComplete(int iterationCount, List<DependencyFanInNode> dependencyFanInNodes) {
            if (iterationCount == targetIterationCount) {
                iterationData[0] = new GsonBuilder().setExclusionStrategies(getGsonExclusionStrategy()).create().toJson(dependencyFanInNodes);
            }
        }
    });
    PipelineConfig pipelineConfig = goConfigService.pipelineConfigNamed(pipelineName);
    Materials materials = materialConfigConverter.toMaterials(pipelineConfig.materialConfigs());
    MaterialRevisions actualRevisions = new MaterialRevisions();
    for (Material material : materials) {
        actualRevisions.addAll(materialRepository.findLatestModification(material));
    }
    MaterialRevisions materialRevisions = fanInGraph.computeRevisions(actualRevisions, pipelineTimeline);
    if (iterationData[0] == null) {
        iterationData[0] = new GsonBuilder().setExclusionStrategies(getGsonExclusionStrategy()).create().toJson(materialRevisions);
    }
    return iterationData[0];
}
Also used : PipelineConfig(com.thoughtworks.go.config.PipelineConfig) GsonBuilder(com.google.gson.GsonBuilder) Materials(com.thoughtworks.go.config.materials.Materials) FanInGraph(com.thoughtworks.go.server.service.dd.FanInGraph) Material(com.thoughtworks.go.domain.materials.Material) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) CruiseConfig(com.thoughtworks.go.config.CruiseConfig) DependencyFanInNode(com.thoughtworks.go.server.service.dd.DependencyFanInNode) FanInEventListener(com.thoughtworks.go.server.service.dd.FanInEventListener)

Aggregations

GsonBuilder (com.google.gson.GsonBuilder)1 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)1 CruiseConfig (com.thoughtworks.go.config.CruiseConfig)1 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)1 Materials (com.thoughtworks.go.config.materials.Materials)1 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)1 Material (com.thoughtworks.go.domain.materials.Material)1 DependencyFanInNode (com.thoughtworks.go.server.service.dd.DependencyFanInNode)1 FanInEventListener (com.thoughtworks.go.server.service.dd.FanInEventListener)1 FanInGraph (com.thoughtworks.go.server.service.dd.FanInGraph)1