aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/sonar-dbcleaner-plugin
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@gmail.com>2013-06-06 11:05:58 +0200
committerSimon Brandhof <simon.brandhof@gmail.com>2013-06-06 11:05:58 +0200
commitfd6307ec1730d0be111317bd61caff3a860477e9 (patch)
treea58ed589b1269f447c60242b84e7f2cca788be87 /plugins/sonar-dbcleaner-plugin
parentb2f8d990393d775068ab5623ee6aca22a6b79d75 (diff)
downloadsonarqube-fd6307ec1730d0be111317bd61caff3a860477e9.tar.gz
sonarqube-fd6307ec1730d0be111317bd61caff3a860477e9.zip
Change order of DBCleaner properties
Diffstat (limited to 'plugins/sonar-dbcleaner-plugin')
-rw-r--r--plugins/sonar-dbcleaner-plugin/src/main/java/org/sonar/plugins/dbcleaner/DbCleanerPlugin.java118
-rw-r--r--plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/DbCleanerPluginTest.java2
-rw-r--r--plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/DefaultPurgeTaskTest.java6
3 files changed, 70 insertions, 56 deletions
diff --git a/plugins/sonar-dbcleaner-plugin/src/main/java/org/sonar/plugins/dbcleaner/DbCleanerPlugin.java b/plugins/sonar-dbcleaner-plugin/src/main/java/org/sonar/plugins/dbcleaner/DbCleanerPlugin.java
index 78d561c8fff..5a0e48fb96a 100644
--- a/plugins/sonar-dbcleaner-plugin/src/main/java/org/sonar/plugins/dbcleaner/DbCleanerPlugin.java
+++ b/plugins/sonar-dbcleaner-plugin/src/main/java/org/sonar/plugins/dbcleaner/DbCleanerPlugin.java
@@ -20,67 +20,81 @@
package org.sonar.plugins.dbcleaner;
import com.google.common.collect.ImmutableList;
-import org.sonar.api.Properties;
-import org.sonar.api.Property;
import org.sonar.api.PropertyType;
import org.sonar.api.SonarPlugin;
+import org.sonar.api.config.PropertyDefinition;
+import org.sonar.api.resources.Qualifiers;
import org.sonar.plugins.dbcleaner.api.DbCleanerConstants;
import org.sonar.plugins.dbcleaner.period.DefaultPeriodCleaner;
+import java.util.Arrays;
import java.util.List;
-@Properties({
- @Property(key = DbCleanerConstants.HOURS_BEFORE_KEEPING_ONLY_ONE_SNAPSHOT_BY_DAY, defaultValue = "24",
- name = "Number of hours before starting to keep only one snapshot per day",
- description = "After this number of hours, if there are several snapshots during the same day, "
- + "the DbCleaner keeps the most recent one and fully deletes the other ones.",
- global = true,
- project = true,
- type = PropertyType.INTEGER),
- @Property(key = DbCleanerConstants.WEEKS_BEFORE_KEEPING_ONLY_ONE_SNAPSHOT_BY_WEEK, defaultValue = "4",
- name = "Number of weeks before starting to keep only one snapshot per week",
- description = "After this number of weeks, if there are several snapshots during the same week, "
- + "the DbCleaner keeps the most recent one and fully deletes the other ones.",
- global = true,
- project = true,
- type = PropertyType.INTEGER),
- @Property(key = DbCleanerConstants.WEEKS_BEFORE_KEEPING_ONLY_ONE_SNAPSHOT_BY_MONTH, defaultValue = "52",
- name = "Number of weeks before starting to keep only one snapshot per month",
- description = "After this number of weeks, if there are several snapshots during the same month, "
- + "the DbCleaner keeps the most recent one and fully deletes the other ones.",
- global = true,
- project = true,
- type = PropertyType.INTEGER),
- @Property(key = DbCleanerConstants.WEEKS_BEFORE_DELETING_ALL_SNAPSHOTS, defaultValue = "260",
- name = "Number of weeks before starting to delete all remaining snapshots",
- description = "After this number of weeks, all snapshots are fully deleted.",
- global = true,
- project = true,
- type = PropertyType.INTEGER),
- @Property(
- key = DbCleanerConstants.PROPERTY_CLEAN_DIRECTORY,
- defaultValue = "true",
- name = "Clean history data of directories/packages",
- description = "If set to true, no history is kept at directory/package level. Setting this to false can cause database bloat.",
- global = true,
- project = true,
- module = false,
- type = PropertyType.BOOLEAN),
- @Property(
- key = DbCleanerConstants.DAYS_BEFORE_DELETING_CLOSED_ISSUES,
- defaultValue = "30",
- name = "Number of days before deleting closed issues",
- description = "Issues that have been closed for more than this number of days will be deleted.",
- global = true,
- project = true,
- type = PropertyType.INTEGER)
-})
public final class DbCleanerPlugin extends SonarPlugin {
public List getExtensions() {
- return ImmutableList.of(
- DefaultPeriodCleaner.class,
- DefaultPurgeTask.class,
- ProjectPurgePostJob.class);
+ return ImmutableList.builder().add(DefaultPeriodCleaner.class, DefaultPurgeTask.class, ProjectPurgePostJob.class)
+ .addAll(propertyDefinitions()).build();
+ }
+
+ static List<PropertyDefinition> propertyDefinitions() {
+ return Arrays.asList(
+ PropertyDefinition.builder(DbCleanerConstants.PROPERTY_CLEAN_DIRECTORY)
+ .defaultValue("true")
+ .name("Clean history data of directories/packages")
+ .description("If set to true, no history is kept at directory/package level. Setting this to false can cause database bloat.")
+ .type(PropertyType.BOOLEAN)
+ .onQualifiers(Qualifiers.PROJECT)
+ .index(1)
+ .build(),
+
+ PropertyDefinition.builder(DbCleanerConstants.DAYS_BEFORE_DELETING_CLOSED_ISSUES)
+ .defaultValue("30")
+ .name("Number of days before deleting closed issues")
+ .description("Issues that have been closed for more than this number of days will be deleted.")
+ .type(PropertyType.INTEGER)
+ .onQualifiers(Qualifiers.PROJECT)
+ .index(2)
+ .build(),
+
+ PropertyDefinition.builder(DbCleanerConstants.HOURS_BEFORE_KEEPING_ONLY_ONE_SNAPSHOT_BY_DAY)
+ .defaultValue("24")
+ .name("Number of hours before starting to keep only one snapshot per day")
+ .description("After this number of hours, if there are several snapshots during the same day, "
+ + "the DbCleaner keeps the most recent one and fully deletes the other ones.")
+ .type(PropertyType.INTEGER)
+ .onQualifiers(Qualifiers.PROJECT)
+ .index(3)
+ .build(),
+
+ PropertyDefinition.builder(DbCleanerConstants.WEEKS_BEFORE_KEEPING_ONLY_ONE_SNAPSHOT_BY_WEEK)
+ .defaultValue("4")
+ .name("Number of weeks before starting to keep only one snapshot per week")
+ .description("After this number of weeks, if there are several snapshots during the same week, "
+ + "the DbCleaner keeps the most recent one and fully deletes the other ones")
+ .type(PropertyType.INTEGER)
+ .onQualifiers(Qualifiers.PROJECT)
+ .index(4)
+ .build(),
+
+ PropertyDefinition.builder(DbCleanerConstants.WEEKS_BEFORE_KEEPING_ONLY_ONE_SNAPSHOT_BY_MONTH)
+ .defaultValue("52")
+ .name("Number of weeks before starting to keep only one snapshot per month")
+ .description("After this number of weeks, if there are several snapshots during the same month, "
+ + "the DbCleaner keeps the most recent one and fully deletes the other ones.")
+ .type(PropertyType.INTEGER)
+ .onQualifiers(Qualifiers.PROJECT)
+ .index(5)
+ .build(),
+
+ PropertyDefinition.builder(DbCleanerConstants.WEEKS_BEFORE_DELETING_ALL_SNAPSHOTS)
+ .defaultValue("260")
+ .name("Number of weeks before starting to delete all remaining snapshots")
+ .description("After this number of weeks, all snapshots are fully deleted.")
+ .type(PropertyType.INTEGER)
+ .onQualifiers(Qualifiers.PROJECT)
+ .index(6)
+ .build()
+ );
}
}
diff --git a/plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/DbCleanerPluginTest.java b/plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/DbCleanerPluginTest.java
index 651c7fb575f..160699524f7 100644
--- a/plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/DbCleanerPluginTest.java
+++ b/plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/DbCleanerPluginTest.java
@@ -27,6 +27,6 @@ public class DbCleanerPluginTest {
@Test
public void shouldGetExtensions() {
- assertThat(new DbCleanerPlugin().getExtensions()).hasSize(3);
+ assertThat(new DbCleanerPlugin().getExtensions()).hasSize(9);
}
}
diff --git a/plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/DefaultPurgeTaskTest.java b/plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/DefaultPurgeTaskTest.java
index 4469ad0ac65..9a8a2edc1ef 100644
--- a/plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/DefaultPurgeTaskTest.java
+++ b/plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/DefaultPurgeTaskTest.java
@@ -44,7 +44,7 @@ public class DefaultPurgeTaskTest {
@Test
public void shouldNotDeleteHistoricalDataOfDirectories() {
PurgeDao purgeDao = mock(PurgeDao.class);
- Settings settings = new Settings(new PropertyDefinitions(DbCleanerPlugin.class));
+ Settings settings = new Settings(new PropertyDefinitions(DbCleanerPlugin.propertyDefinitions()));
settings.setProperty(DbCleanerConstants.PROPERTY_CLEAN_DIRECTORY, "false");
DefaultPurgeTask task = new DefaultPurgeTask(purgeDao, settings, mock(DefaultPeriodCleaner.class), mock(PurgeProfiler.class));
@@ -62,7 +62,7 @@ public class DefaultPurgeTaskTest {
@Test
public void shouldDeleteHistoricalDataOfDirectoriesByDefault() {
PurgeDao purgeDao = mock(PurgeDao.class);
- Settings settings = new Settings(new PropertyDefinitions(DbCleanerPlugin.class));
+ Settings settings = new Settings(new PropertyDefinitions(DbCleanerPlugin.propertyDefinitions()));
DefaultPurgeTask task = new DefaultPurgeTask(purgeDao, settings, mock(DefaultPeriodCleaner.class), mock(PurgeProfiler.class));
task.purge(1L);
@@ -95,7 +95,7 @@ public class DefaultPurgeTaskTest {
PurgeConfiguration conf = new PurgeConfiguration(1L, new String[0], 30);
PurgeDao purgeDao = mock(PurgeDao.class);
when(purgeDao.purge(conf)).thenThrow(new RuntimeException());
- Settings settings = new Settings(new PropertyDefinitions(DbCleanerPlugin.class));
+ Settings settings = new Settings(new PropertyDefinitions(DbCleanerPlugin.propertyDefinitions()));
settings.setProperty(CoreProperties.PROFILING_LOG_PROPERTY, true);
PurgeProfiler profiler = mock(PurgeProfiler.class);