3 * Copyright (C) 2009-2016 SonarSource SA
4 * mailto:contact AT sonarsource DOT com
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 3 of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 package org.sonar.server.computation.task.projectanalysis.step;
22 import com.google.common.base.Predicate;
23 import java.util.Arrays;
24 import java.util.List;
25 import javax.annotation.Nonnull;
26 import org.picocontainer.ComponentAdapter;
27 import org.sonar.server.computation.task.container.TaskContainer;
28 import org.sonar.server.computation.task.projectanalysis.api.developer.PersistDevelopersDelegate;
29 import org.sonar.server.computation.task.projectanalysis.filemove.FileMoveDetectionStep;
30 import org.sonar.server.computation.task.step.ComputationStep;
32 import static com.google.common.collect.FluentIterable.from;
35 * Ordered list of steps classes and instances to be executed for batch processing
37 public class ReportComputationSteps extends AbstractComputationSteps {
39 private static final List<Class<? extends ComputationStep>> STEPS = Arrays.asList(
40 ExtractReportStep.class,
41 LogScannerContextStep.class,
42 GenerateAnalysisUuid.class,
44 // Builds Component tree
45 LoadReportAnalysisMetadataHolderStep.class,
46 BuildComponentTreeStep.class,
47 ValidateProjectStep.class,
49 LoadQualityProfilesStep.class,
51 // load project related stuffs
52 LoadQualityGateStep.class,
53 LoadPeriodsStep.class,
54 FileMoveDetectionStep.class,
56 // load duplications related stuff
57 LoadDuplicationsFromReportStep.class,
58 LoadCrossProjectDuplicationsRepositoryStep.class,
61 SizeMeasuresStep.class,
62 NewCoverageMeasuresStep.class,
63 CoverageMeasuresStep.class,
64 CommentMeasuresStep.class,
65 CustomMeasuresCopyStep.class,
66 DuplicationMeasuresStep.class,
67 DuplicationDataMeasuresStep.class,
68 NewDuplicationMeasuresStep.class,
69 LanguageDistributionMeasuresStep.class,
70 UnitTestMeasuresStep.class,
71 ComplexityMeasuresStep.class,
73 LoadMeasureComputersStep.class,
74 ExecuteVisitorsStep.class,
76 // Must be executed after computation of all measures
77 ComputeMeasureVariationsStep.class,
79 // Must be executed after computation of differential measures
80 QualityGateMeasuresStep.class,
81 // Must be executed after computation of language distribution
82 ComputeQProfileMeasureStep.class,
83 // Must be executed after computation of quality profile measure
84 QualityProfileEventsStep.class,
86 // Must be executed after computation of quality gate measure
87 QualityGateEventsStep.class,
90 PersistComponentsStep.class,
91 PersistAnalysisStep.class,
92 PersistDevelopersStep.class,
93 PersistMeasuresStep.class,
94 PersistIssuesStep.class,
95 PersistProjectLinksStep.class,
96 PersistEventsStep.class,
97 PersistFileSourcesStep.class,
98 PersistTestsStep.class,
99 PersistCrossProjectDuplicationIndexStep.class,
100 EnableAnalysisStep.class,
102 UpdateQualityProfilesLastUsedDateStep.class,
103 IndexComponentsStep.class,
104 PurgeDatastoresStep.class,
105 ApplyPermissionsStep.class,
107 // ES indexing is done after all db changes
108 IndexIssuesStep.class,
109 IndexTestsStep.class,
111 // notifications are sent at the end, so that webapp displays up-to-date information
112 SendIssueNotificationsStep.class,
114 PublishTaskResultStep.class);
116 private final TaskContainer taskContainer;
118 public ReportComputationSteps(TaskContainer taskContainer) {
119 super(taskContainer);
120 this.taskContainer = taskContainer;
124 * List of all {@link ComputationStep},
125 * ordered by execution sequence.
128 public List<Class<? extends ComputationStep>> orderedStepClasses() {
130 .filter(new AllowPersistDevelopersStepIfDevCockpitPluginInstalled(taskContainer))
134 private static class AllowPersistDevelopersStepIfDevCockpitPluginInstalled implements Predicate<Class<? extends ComputationStep>> {
135 private final boolean devCockpitIsInstalled;
137 private AllowPersistDevelopersStepIfDevCockpitPluginInstalled(TaskContainer taskContainer) {
138 this.devCockpitIsInstalled = isDevCockpitInstalled(taskContainer);
141 private static boolean isDevCockpitInstalled(TaskContainer taskContainer) {
142 List<ComponentAdapter<PersistDevelopersDelegate>> componentAdapters = taskContainer.getPicoContainer().getComponentAdapters(PersistDevelopersDelegate.class);
143 return !componentAdapters.isEmpty();
147 public boolean apply(@Nonnull Class<? extends ComputationStep> input) {
148 return devCockpitIsInstalled || !input.equals(PersistDevelopersStep.class);