Search in sources :

Example 1 with PiplineConfigVisitor

use of com.thoughtworks.go.domain.PiplineConfigVisitor in project gocd by gocd.

the class GoDashboardCurrentStateLoader method allPipelines.

public List<GoDashboardPipeline> allPipelines(CruiseConfig config) {
    List<String> pipelineNames = CaseInsensitiveString.toStringList(config.getAllPipelineNames());
    PipelineInstanceModels historyForDashboard = loadHistoryForPipelines(pipelineNames);
    LOGGER.debug("Loading permissions from authority");
    final Map<CaseInsensitiveString, Permissions> pipelinesAndTheirPermissions = permissionsAuthority.pipelinesAndTheirPermissions();
    final List<GoDashboardPipeline> pipelines = new ArrayList<>(1024);
    LOGGER.debug("Populating dashboard pipelines");
    config.accept(new PipelineGroupVisitor() {

        @Override
        public void visit(final PipelineConfigs group) {
            group.accept(new PiplineConfigVisitor() {

                @Override
                public void visit(PipelineConfig pipelineConfig) {
                    long start = System.currentTimeMillis();
                    Permissions permissions = permissionsFor(pipelineConfig, pipelinesAndTheirPermissions);
                    pipelines.add(createGoDashboardPipeline(pipelineConfig, permissions, historyForDashboard, group));
                    LOGGER.debug("It took {}ms to process pipeline {}", (System.currentTimeMillis() - start), pipelineConfig.getName());
                }
            });
        }
    });
    LOGGER.debug("Done populating dashboard pipelines");
    this.everLoadedCurrentState = true;
    return pipelines;
}
Also used : PipelineGroupVisitor(com.thoughtworks.go.domain.PipelineGroupVisitor) PipelineInstanceModels(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModels) PipelineInstanceModels.createPipelineInstanceModels(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModels.createPipelineInstanceModels) Permissions(com.thoughtworks.go.config.security.Permissions) PiplineConfigVisitor(com.thoughtworks.go.domain.PiplineConfigVisitor)

Example 2 with PiplineConfigVisitor

use of com.thoughtworks.go.domain.PiplineConfigVisitor in project gocd by gocd.

the class PipelineScheduler method onConfigChange.

public void onConfigChange(CruiseConfig newCruiseConfig) {
    synchronized (pipelines) {
        newCruiseConfig.accept(new PiplineConfigVisitor() {

            public void visit(PipelineConfig pipelineConfig) {
                addPipelineIfNotPresent(pipelineConfig, pipelines);
            }
        });
        List<String> deletedPipeline = new ArrayList<>();
        for (String pipelineName : pipelines.keySet()) {
            if (!newCruiseConfig.hasPipelineNamed(new CaseInsensitiveString(pipelineName))) {
                deletedPipeline.add(pipelineName);
            }
        }
        for (String pipelineName : deletedPipeline) {
            pipelines.remove(pipelineName);
        }
    }
}
Also used : ArrayList(java.util.ArrayList) PiplineConfigVisitor(com.thoughtworks.go.domain.PiplineConfigVisitor)

Aggregations

PiplineConfigVisitor (com.thoughtworks.go.domain.PiplineConfigVisitor)2 Permissions (com.thoughtworks.go.config.security.Permissions)1 PipelineGroupVisitor (com.thoughtworks.go.domain.PipelineGroupVisitor)1 PipelineInstanceModels (com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModels)1 PipelineInstanceModels.createPipelineInstanceModels (com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModels.createPipelineInstanceModels)1 ArrayList (java.util.ArrayList)1