diff options
author | simonbrandhof <simon.brandhof@gmail.com> | 2011-01-10 16:23:06 +0100 |
---|---|---|
committer | simonbrandhof <simon.brandhof@gmail.com> | 2011-01-10 16:23:06 +0100 |
commit | 64438bb95377cb144b538dc134e6db33ba4e615d (patch) | |
tree | 2d0864666fbcb5936c37f85e2d9311a2bd4a7944 /plugins | |
parent | f4322ee342723d15173b31ff6eb59199cf3f4a37 (diff) | |
download | sonarqube-64438bb95377cb144b538dc134e6db33ba4e615d.tar.gz sonarqube-64438bb95377cb144b538dc134e6db33ba4e615d.zip |
merge 2.5-RC2: save SNAPSHOTS.VARIATION_x columns on views
Diffstat (limited to 'plugins')
2 files changed, 18 insertions, 4 deletions
diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/TimeMachineConfigurationPersister.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/TimeMachineConfigurationPersister.java index 4e1bba5d7c3..5d2e923e70a 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/TimeMachineConfigurationPersister.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/TimeMachineConfigurationPersister.java @@ -19,15 +19,19 @@ */ package org.sonar.plugins.core.timemachine; -import org.sonar.api.BatchExtension; +import org.sonar.api.batch.Decorator; +import org.sonar.api.batch.DecoratorContext; import org.sonar.api.database.DatabaseSession; import org.sonar.api.database.model.Snapshot; +import org.sonar.api.resources.Project; +import org.sonar.api.resources.Resource; +import org.sonar.api.resources.ResourceUtils; import org.sonar.batch.components.PastSnapshot; import org.sonar.batch.components.TimeMachineConfiguration; import java.util.List; -public final class TimeMachineConfigurationPersister implements BatchExtension { +public final class TimeMachineConfigurationPersister implements Decorator { private TimeMachineConfiguration configuration; private Snapshot projectSnapshot; @@ -39,7 +43,13 @@ public final class TimeMachineConfigurationPersister implements BatchExtension { this.session = session; } - public void start() { + public void decorate(Resource resource, DecoratorContext context) { + if (ResourceUtils.isProject(resource)) { + persistConfiguration(); + } + } + + void persistConfiguration() { List<PastSnapshot> pastSnapshots = configuration.getProjectPastSnapshots(); for (PastSnapshot pastSnapshot : pastSnapshots) { projectSnapshot = session.reattach(Snapshot.class, projectSnapshot.getId()); @@ -50,4 +60,8 @@ public final class TimeMachineConfigurationPersister implements BatchExtension { } session.commit(); } + + public boolean shouldExecuteOnProject(Project project) { + return true; + } } diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/timemachine/TimeMachineConfigurationPersisterTest.java b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/timemachine/TimeMachineConfigurationPersisterTest.java index 6c0477004f5..20bf7ddcdf2 100644 --- a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/timemachine/TimeMachineConfigurationPersisterTest.java +++ b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/timemachine/TimeMachineConfigurationPersisterTest.java @@ -48,7 +48,7 @@ public class TimeMachineConfigurationPersisterTest extends AbstractDbUnitTestCas Snapshot projectSnapshot = getSession().getSingleResult(Snapshot.class, "id", 1000); TimeMachineConfigurationPersister persister = new TimeMachineConfigurationPersister(conf, projectSnapshot, getSession()); - persister.start(); + persister.persistConfiguration(); checkTables("shouldSaveConfigurationInSnapshotsTable", "snapshots"); } |