]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-3529 Get rid of property sets. Use PropertyFields instead
authorDavid Gageot <david@gageot.net>
Fri, 28 Sep 2012 11:35:23 +0000 (13:35 +0200)
committerDavid Gageot <david@gageot.net>
Fri, 28 Sep 2012 13:08:45 +0000 (15:08 +0200)
33 files changed:
plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java
sonar-batch/src/main/java/org/sonar/batch/ProjectConfigurator.java
sonar-batch/src/main/java/org/sonar/batch/config/ProjectSettings.java
sonar-batch/src/test/java/org/sonar/batch/ProjectConfiguratorTest.java
sonar-plugin-api/src/main/java/org/sonar/api/Property.java
sonar-plugin-api/src/main/java/org/sonar/api/PropertyField.java [new file with mode: 0644]
sonar-plugin-api/src/main/java/org/sonar/api/config/PropertyDefinition.java
sonar-plugin-api/src/main/java/org/sonar/api/config/PropertyFieldDefinition.java [new file with mode: 0644]
sonar-plugin-api/src/main/java/org/sonar/api/config/PropertySet.java [deleted file]
sonar-plugin-api/src/main/java/org/sonar/api/config/PropertySetDefinitions.java [deleted file]
sonar-plugin-api/src/main/java/org/sonar/api/config/PropertySetField.java [deleted file]
sonar-plugin-api/src/main/java/org/sonar/api/config/PropertySetTemplate.java [deleted file]
sonar-plugin-api/src/main/java/org/sonar/api/config/PropertySetValue.java [deleted file]
sonar-plugin-api/src/main/java/org/sonar/api/config/Settings.java
sonar-plugin-api/src/main/java/org/sonar/api/config/TestPropertySetTemplate.java [deleted file]
sonar-plugin-api/src/main/java/org/sonar/api/profiles/RulesProfile.java
sonar-plugin-api/src/test/java/org/sonar/api/config/PropertyDefinitionTest.java
sonar-plugin-api/src/test/java/org/sonar/api/config/PropertySetDefinitionsTest.java [deleted file]
sonar-plugin-api/src/test/java/org/sonar/api/config/PropertySetFieldTest.java [deleted file]
sonar-plugin-api/src/test/java/org/sonar/api/config/PropertySetTest.java [deleted file]
sonar-plugin-api/src/test/java/org/sonar/api/config/PropertySetValueTest.java [deleted file]
sonar-plugin-api/src/test/java/org/sonar/api/config/SettingsTest.java
sonar-server/src/main/java/org/sonar/server/platform/Platform.java
sonar-server/src/main/java/org/sonar/server/startup/RegisterPropertySets.java [deleted file]
sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java
sonar-server/src/main/webapp/WEB-INF/app/helpers/settings_helper.rb
sonar-server/src/main/webapp/WEB-INF/app/models/property_set.rb [deleted file]
sonar-server/src/main/webapp/WEB-INF/app/views/settings/_multi_value.html.erb
sonar-server/src/main/webapp/WEB-INF/app/views/settings/_properties.html.erb
sonar-server/src/main/webapp/WEB-INF/app/views/settings/_single_value.html.erb [new file with mode: 0644]
sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_PROPERTY_SET.html.erb
sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_PROPERTY_SET_DEFINITION.html.erb [new file with mode: 0644]
sonar-server/src/test/java/org/sonar/server/startup/RegisterPropertySetsTest.java [deleted file]

index d1647af49946e2fb2a0e3714efcd9b90907f8200..10ab1cbb50930cdcfcf2e6df2b0a392c9f9bd0ac 100644 (file)
 package org.sonar.plugins.core;
 
 import com.google.common.collect.ImmutableList;
-import org.sonar.api.*;
+import org.sonar.api.CoreProperties;
+import org.sonar.api.Extension;
+import org.sonar.api.Properties;
+import org.sonar.api.Property;
+import org.sonar.api.PropertyField;
+import org.sonar.api.PropertyType;
+import org.sonar.api.SonarPlugin;
 import org.sonar.api.checks.NoSonarFilter;
-import org.sonar.api.config.PropertySetDefinitions;
-import org.sonar.api.config.TestPropertySetTemplate;
 import org.sonar.api.resources.Java;
 import org.sonar.plugins.core.batch.ExcludedResourceFilter;
 import org.sonar.plugins.core.batch.IndexProjectPostJob;
@@ -33,19 +37,80 @@ import org.sonar.plugins.core.charts.DistributionAreaChart;
 import org.sonar.plugins.core.charts.DistributionBarChart;
 import org.sonar.plugins.core.charts.XradarChart;
 import org.sonar.plugins.core.colorizers.JavaColorizerFormat;
-import org.sonar.plugins.core.dashboards.*;
+import org.sonar.plugins.core.dashboards.DefaultDashboard;
+import org.sonar.plugins.core.dashboards.HotspotsDashboard;
+import org.sonar.plugins.core.dashboards.MyFavouritesDashboard;
+import org.sonar.plugins.core.dashboards.ProjectsDashboard;
+import org.sonar.plugins.core.dashboards.ReviewsDashboard;
+import org.sonar.plugins.core.dashboards.TimeMachineDashboard;
+import org.sonar.plugins.core.dashboards.TreemapDashboard;
 import org.sonar.plugins.core.filters.MyFavouritesFilter;
 import org.sonar.plugins.core.filters.ProjectFilter;
 import org.sonar.plugins.core.filters.TreeMapFilter;
 import org.sonar.plugins.core.security.ApplyProjectRolesDecorator;
 import org.sonar.plugins.core.security.DefaultResourcePermissions;
-import org.sonar.plugins.core.sensors.*;
+import org.sonar.plugins.core.sensors.BranchCoverageDecorator;
+import org.sonar.plugins.core.sensors.CheckAlertThresholds;
+import org.sonar.plugins.core.sensors.CommentDensityDecorator;
+import org.sonar.plugins.core.sensors.CoverageDecorator;
+import org.sonar.plugins.core.sensors.DirectoriesDecorator;
+import org.sonar.plugins.core.sensors.FilesDecorator;
+import org.sonar.plugins.core.sensors.GenerateAlertEvents;
+import org.sonar.plugins.core.sensors.ItBranchCoverageDecorator;
+import org.sonar.plugins.core.sensors.ItCoverageDecorator;
+import org.sonar.plugins.core.sensors.ItLineCoverageDecorator;
+import org.sonar.plugins.core.sensors.LineCoverageDecorator;
+import org.sonar.plugins.core.sensors.ManualMeasureDecorator;
+import org.sonar.plugins.core.sensors.ManualViolationInjector;
+import org.sonar.plugins.core.sensors.ProfileEventsSensor;
+import org.sonar.plugins.core.sensors.ProfileSensor;
+import org.sonar.plugins.core.sensors.ProjectLinksSensor;
+import org.sonar.plugins.core.sensors.ReviewNotifications;
+import org.sonar.plugins.core.sensors.ReviewWorkflowDecorator;
+import org.sonar.plugins.core.sensors.ReviewsMeasuresDecorator;
+import org.sonar.plugins.core.sensors.UnitTestDecorator;
+import org.sonar.plugins.core.sensors.VersionEventsSensor;
+import org.sonar.plugins.core.sensors.ViolationSeverityUpdater;
+import org.sonar.plugins.core.sensors.ViolationsDecorator;
+import org.sonar.plugins.core.sensors.ViolationsDensityDecorator;
+import org.sonar.plugins.core.sensors.WeightedViolationsDecorator;
 import org.sonar.plugins.core.testdetailsviewer.TestsViewerDefinition;
-import org.sonar.plugins.core.timemachine.*;
+import org.sonar.plugins.core.timemachine.NewCoverageAggregator;
+import org.sonar.plugins.core.timemachine.NewCoverageFileAnalyzer;
+import org.sonar.plugins.core.timemachine.NewItCoverageFileAnalyzer;
+import org.sonar.plugins.core.timemachine.NewViolationsDecorator;
+import org.sonar.plugins.core.timemachine.ReferenceAnalysis;
+import org.sonar.plugins.core.timemachine.TendencyDecorator;
+import org.sonar.plugins.core.timemachine.TimeMachineConfigurationPersister;
+import org.sonar.plugins.core.timemachine.VariationDecorator;
+import org.sonar.plugins.core.timemachine.ViolationPersisterDecorator;
+import org.sonar.plugins.core.timemachine.ViolationTrackingDecorator;
 import org.sonar.plugins.core.web.Lcom4Viewer;
-import org.sonar.plugins.core.widgets.*;
+import org.sonar.plugins.core.widgets.AlertsWidget;
+import org.sonar.plugins.core.widgets.CommentsDuplicationsWidget;
+import org.sonar.plugins.core.widgets.ComplexityWidget;
+import org.sonar.plugins.core.widgets.CoverageWidget;
+import org.sonar.plugins.core.widgets.CustomMeasuresWidget;
+import org.sonar.plugins.core.widgets.DescriptionWidget;
+import org.sonar.plugins.core.widgets.EventsWidget;
+import org.sonar.plugins.core.widgets.FilterWidget;
+import org.sonar.plugins.core.widgets.HotspotMetricWidget;
+import org.sonar.plugins.core.widgets.HotspotMostViolatedResourcesWidget;
+import org.sonar.plugins.core.widgets.HotspotMostViolatedRulesWidget;
+import org.sonar.plugins.core.widgets.ItCoverageWidget;
+import org.sonar.plugins.core.widgets.RulesWidget;
+import org.sonar.plugins.core.widgets.SizeWidget;
+import org.sonar.plugins.core.widgets.TimeMachineWidget;
+import org.sonar.plugins.core.widgets.TimelineWidget;
+import org.sonar.plugins.core.widgets.TreemapWidget;
 import org.sonar.plugins.core.widgets.actionPlans.ActionPlansWidget;
-import org.sonar.plugins.core.widgets.reviews.*;
+import org.sonar.plugins.core.widgets.reviews.FalsePositiveReviewsWidget;
+import org.sonar.plugins.core.widgets.reviews.MyReviewsWidget;
+import org.sonar.plugins.core.widgets.reviews.PlannedReviewsWidget;
+import org.sonar.plugins.core.widgets.reviews.ProjectReviewsWidget;
+import org.sonar.plugins.core.widgets.reviews.ReviewsMetricsWidget;
+import org.sonar.plugins.core.widgets.reviews.ReviewsPerDeveloperWidget;
+import org.sonar.plugins.core.widgets.reviews.UnplannedReviewsWidget;
 
 import java.util.List;
 
@@ -59,12 +124,27 @@ import java.util.List;
     global = true,
     category = CoreProperties.CATEGORY_GENERAL),
   @Property(
-    key = "toto",
-    name = "Toto",
+    key = "sonar.test.jira.servers",
+    name = "Jira Servers",
     global = true,
+    project = true,
+    category = "DEV",
+    fields = {
+      @PropertyField(
+        key = "url",
+        name = "Url",
+        type = PropertyType.STRING),
+      @PropertyField(
+        key = "port",
+        name = "Port",
+        type = PropertyType.INTEGER)}),
+  @Property(
+    key = "sonar.test.jira",
+    name = "Jira",
+    project = true,
+    category = "DEV",
     type = PropertyType.PROPERTY_SET,
-    propertySetName = "myset",
-    category = CoreProperties.CATEGORY_GENERAL),
+    propertySetKey = "sonar.test.jira.servers"),
   @Property(
     key = CoreProperties.PROJECT_LANGUAGE_PROPERTY,
     defaultValue = Java.KEY,
@@ -254,115 +334,111 @@ public final class CorePlugin extends SonarPlugin {
   @SuppressWarnings("unchecked")
   public List<Class<? extends Extension>> getExtensions() {
     return ImmutableList.of(
-      DefaultResourceTypes.class,
-      UserManagedMetrics.class,
-      ProjectFileSystemLogger.class,
-
-      // maven
-      MavenInitializer.class,
+        DefaultResourceTypes.class,
+        UserManagedMetrics.class,
+        ProjectFileSystemLogger.class,
 
-      // languages
-      Java.class,
+        // maven
+        MavenInitializer.class,
 
-      // pages
-      TestsViewerDefinition.class,
-      Lcom4Viewer.class,
+        // languages
+        Java.class,
 
-      // filters
-      ProjectFilter.class,
-      TreeMapFilter.class,
-      MyFavouritesFilter.class,
+        // pages
+        TestsViewerDefinition.class,
+        Lcom4Viewer.class,
 
-      // widgets
-      AlertsWidget.class,
-      CoverageWidget.class,
-      ItCoverageWidget.class,
-      CommentsDuplicationsWidget.class,
-      DescriptionWidget.class,
-      ComplexityWidget.class,
-      RulesWidget.class,
-      SizeWidget.class,
-      EventsWidget.class,
-      CustomMeasuresWidget.class,
-      TimelineWidget.class,
-      TimeMachineWidget.class,
-      HotspotMetricWidget.class,
-      HotspotMostViolatedResourcesWidget.class,
-      HotspotMostViolatedRulesWidget.class,
-      MyReviewsWidget.class,
-      ProjectReviewsWidget.class,
-      FalsePositiveReviewsWidget.class,
-      ReviewsPerDeveloperWidget.class,
-      PlannedReviewsWidget.class,
-      UnplannedReviewsWidget.class,
-      ActionPlansWidget.class,
-      ReviewsMetricsWidget.class,
-      TreemapWidget.class,
-      FilterWidget.class,
+        // filters
+        ProjectFilter.class,
+        TreeMapFilter.class,
+        MyFavouritesFilter.class,
 
-      // dashboards
-      DefaultDashboard.class,
-      HotspotsDashboard.class,
-      ReviewsDashboard.class,
-      TimeMachineDashboard.class,
-      ProjectsDashboard.class,
-      TreemapDashboard.class,
-      MyFavouritesDashboard.class,
+        // widgets
+        AlertsWidget.class,
+        CoverageWidget.class,
+        ItCoverageWidget.class,
+        CommentsDuplicationsWidget.class,
+        DescriptionWidget.class,
+        ComplexityWidget.class,
+        RulesWidget.class,
+        SizeWidget.class,
+        EventsWidget.class,
+        CustomMeasuresWidget.class,
+        TimelineWidget.class,
+        TimeMachineWidget.class,
+        HotspotMetricWidget.class,
+        HotspotMostViolatedResourcesWidget.class,
+        HotspotMostViolatedRulesWidget.class,
+        MyReviewsWidget.class,
+        ProjectReviewsWidget.class,
+        FalsePositiveReviewsWidget.class,
+        ReviewsPerDeveloperWidget.class,
+        PlannedReviewsWidget.class,
+        UnplannedReviewsWidget.class,
+        ActionPlansWidget.class,
+        ReviewsMetricsWidget.class,
+        TreemapWidget.class,
+        FilterWidget.class,
 
-      // Property sets
-      PropertySetDefinitions.class,
-      TestPropertySetTemplate.class,
+        // dashboards
+        DefaultDashboard.class,
+        HotspotsDashboard.class,
+        ReviewsDashboard.class,
+        TimeMachineDashboard.class,
+        ProjectsDashboard.class,
+        TreemapDashboard.class,
+        MyFavouritesDashboard.class,
 
-      // chart
-      XradarChart.class,
-      DistributionBarChart.class,
-      DistributionAreaChart.class,
+        // chart
+        XradarChart.class,
+        DistributionBarChart.class,
+        DistributionAreaChart.class,
 
-      // colorizers
-      JavaColorizerFormat.class,
+        // colorizers
+        JavaColorizerFormat.class,
 
-      // batch
-      ProfileSensor.class,
-      ProfileEventsSensor.class,
-      ProjectLinksSensor.class,
-      UnitTestDecorator.class,
-      VersionEventsSensor.class,
-      CheckAlertThresholds.class,
-      GenerateAlertEvents.class,
-      ViolationsDecorator.class,
-      WeightedViolationsDecorator.class,
-      ViolationsDensityDecorator.class,
-      LineCoverageDecorator.class,
-      CoverageDecorator.class,
-      BranchCoverageDecorator.class,
-      ItLineCoverageDecorator.class,
-      ItCoverageDecorator.class,
-      ItBranchCoverageDecorator.class,
-      DefaultResourcePermissions.class,
-      ApplyProjectRolesDecorator.class,
-      ExcludedResourceFilter.class,
-      CommentDensityDecorator.class,
-      NoSonarFilter.class,
-      DirectoriesDecorator.class,
-      FilesDecorator.class,
-      ReviewNotifications.class,
-      ReviewWorkflowDecorator.class,
-      ReferenceAnalysis.class,
-      ManualMeasureDecorator.class,
-      ManualViolationInjector.class,
-      ViolationSeverityUpdater.class,
-      IndexProjectPostJob.class,
-      ReviewsMeasuresDecorator.class,
+        // batch
+        ProfileSensor.class,
+        ProfileEventsSensor.class,
+        ProjectLinksSensor.class,
+        UnitTestDecorator.class,
+        VersionEventsSensor.class,
+        CheckAlertThresholds.class,
+        GenerateAlertEvents.class,
+        ViolationsDecorator.class,
+        WeightedViolationsDecorator.class,
+        ViolationsDensityDecorator.class,
+        LineCoverageDecorator.class,
+        CoverageDecorator.class,
+        BranchCoverageDecorator.class,
+        ItLineCoverageDecorator.class,
+        ItCoverageDecorator.class,
+        ItBranchCoverageDecorator.class,
+        DefaultResourcePermissions.class,
+        ApplyProjectRolesDecorator.class,
+        ExcludedResourceFilter.class,
+        CommentDensityDecorator.class,
+        NoSonarFilter.class,
+        DirectoriesDecorator.class,
+        FilesDecorator.class,
+        ReviewNotifications.class,
+        ReviewWorkflowDecorator.class,
+        ReferenceAnalysis.class,
+        ManualMeasureDecorator.class,
+        ManualViolationInjector.class,
+        ViolationSeverityUpdater.class,
+        IndexProjectPostJob.class,
+        ReviewsMeasuresDecorator.class,
 
-      // time machine
-      TendencyDecorator.class,
-      VariationDecorator.class,
-      ViolationTrackingDecorator.class,
-      ViolationPersisterDecorator.class,
-      NewViolationsDecorator.class,
-      TimeMachineConfigurationPersister.class,
-      NewCoverageFileAnalyzer.class,
-      NewItCoverageFileAnalyzer.class,
-      NewCoverageAggregator.class);
+        // time machine
+        TendencyDecorator.class,
+        VariationDecorator.class,
+        ViolationTrackingDecorator.class,
+        ViolationPersisterDecorator.class,
+        NewViolationsDecorator.class,
+        TimeMachineConfigurationPersister.class,
+        NewCoverageFileAnalyzer.class,
+        NewItCoverageFileAnalyzer.class,
+        NewCoverageAggregator.class);
   }
 }
index 1ea83f62df9d198cf8d01fad66a70a8f9aae0ce5..7ef42fbd60ea4adec33d6b8be464f28835c92c99 100644 (file)
@@ -19,8 +19,6 @@
  */
 package org.sonar.batch;
 
-import java.util.Date;
-
 import org.apache.commons.configuration.PropertiesConfiguration;
 import org.apache.commons.lang.StringUtils;
 import org.apache.maven.project.MavenProject;
@@ -31,10 +29,11 @@ import org.sonar.api.config.Settings;
 import org.sonar.api.database.DatabaseSession;
 import org.sonar.api.database.model.ResourceModel;
 import org.sonar.api.database.model.Snapshot;
-import org.sonar.api.resources.Java;
 import org.sonar.api.resources.Project;
 import org.sonar.api.utils.SonarException;
 
+import java.util.Date;
+
 public class ProjectConfigurator implements BatchComponent {
 
   private DatabaseSession databaseSession;
index 95822bcb32af3bfde448e1b3c84f6b9551c11a01..09496102faff5253ed9925194b2c80c8e3bf3d11 100644 (file)
@@ -26,7 +26,6 @@ import org.sonar.api.CoreProperties;
 import org.sonar.api.batch.bootstrap.ProjectDefinition;
 import org.sonar.api.config.PropertyDefinitions;
 import org.sonar.api.config.Settings;
-import org.sonar.api.resources.Java;
 import org.sonar.api.resources.Project;
 import org.sonar.batch.bootstrap.ProjectInitializer;
 import org.sonar.core.config.ConfigurationUtils;
index 4db0e9f4c5a1f5c8ac60bd86c2869363b8c2af6d..3b0db7ee94506c36ff0d9d20c6428b009043fa0c 100644 (file)
@@ -22,7 +22,6 @@ package org.sonar.batch;
 import org.junit.Test;
 import org.sonar.api.CoreProperties;
 import org.sonar.api.config.Settings;
-import org.sonar.api.resources.Java;
 import org.sonar.api.resources.Project;
 import org.sonar.jpa.test.AbstractDbUnitTestCase;
 
index ca2c727069932e2404d9e76aad4d052c4949a1f6..3d85cfb46f00b0aaf87fe511fcb39a0558dbf6a1 100644 (file)
@@ -100,9 +100,17 @@ public @interface Property {
   boolean multiValues() default false;
 
   /**
-   * Name of the property set. Used only when type = <code>PropertyType.PROPERTY_SET</code>.
+   * A Property of type <code>PropertyType.PROPERTY_SET</code> can reference a set of properties
+   * by its key.
    *
    * @since 3.3
    */
-  String propertySetName() default "";
+  String propertySetKey() default "";
+
+  /**
+   * A Property with fields is considered a property set.
+   *
+   * @since 3.3
+   */
+  PropertyField[] fields() default {};
 }
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/PropertyField.java b/sonar-plugin-api/src/main/java/org/sonar/api/PropertyField.java
new file mode 100644 (file)
index 0000000..4f2c9e1
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2012 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * Sonar is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
+ */
+package org.sonar.api;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Property field.
+ *
+ * @since 3.3
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.TYPE)
+public @interface PropertyField {
+  /**
+   * Unique key within a property.
+   */
+  String key();
+
+  /**
+   * The empty string "" is considered as null, so it's not possible to have empty strings for default values.
+   */
+  String defaultValue() default "";
+
+  String name();
+
+  String description() default "";
+
+  PropertyType type() default PropertyType.STRING;
+
+  /**
+   * Options for *_LIST types
+   */
+  String[] options() default {};
+}
index 5c20b5c56e5b99f55d76dce6dedc0763166ee563..7e497b49aaa14799a61f403ed4904fc3c3eaee3c 100644 (file)
@@ -67,7 +67,8 @@ public final class PropertyDefinition {
   private boolean onModule = false;
   private boolean isGlobal = true;
   private boolean multiValues;
-  private String propertySetName;
+  private String propertySetKey;
+  private PropertyFieldDefinition[] fields;
 
   private PropertyDefinition(Property annotation) {
     this.key = annotation.key();
@@ -81,7 +82,8 @@ public final class PropertyDefinition {
     this.type = fixType(annotation.key(), annotation.type());
     this.options = annotation.options();
     this.multiValues = annotation.multiValues();
-    this.propertySetName = annotation.propertySetName();
+    propertySetKey = annotation.propertySetKey();
+    this.fields = PropertyFieldDefinition.create(annotation.fields());
   }
 
   private static PropertyType fixType(String key, PropertyType type) {
@@ -186,7 +188,14 @@ public final class PropertyDefinition {
   /**
    * @since 3.3
    */
-  public String getPropertySetName() {
-    return propertySetName;
+  public String getPropertySetKey() {
+    return propertySetKey;
+  }
+
+  /**
+   * @since 3.3
+   */
+  public PropertyFieldDefinition[] getFields() {
+    return fields;
   }
 }
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/config/PropertyFieldDefinition.java b/sonar-plugin-api/src/main/java/org/sonar/api/config/PropertyFieldDefinition.java
new file mode 100644 (file)
index 0000000..51775b7
--- /dev/null
@@ -0,0 +1,83 @@
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2012 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * Sonar is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
+ */
+package org.sonar.api.config;
+
+import org.sonar.api.PropertyField;
+import org.sonar.api.PropertyType;
+
+/**
+ * @since 3.3
+ */
+public final class PropertyFieldDefinition {
+  private String key;
+  private String defaultValue;
+  private String name;
+  private PropertyType type = PropertyType.STRING;
+  private String[] options;
+  private String description;
+
+  private PropertyFieldDefinition(PropertyField annotation) {
+    this.key = annotation.key();
+    this.name = annotation.name();
+    this.defaultValue = annotation.defaultValue();
+    this.description = annotation.description();
+    this.type = annotation.type();
+    this.options = annotation.options();
+  }
+
+  public static PropertyFieldDefinition create(PropertyField annotation) {
+    return new PropertyFieldDefinition(annotation);
+  }
+
+  public static PropertyFieldDefinition[] create(PropertyField[] fields) {
+    PropertyFieldDefinition[] definitions = new PropertyFieldDefinition[fields.length];
+
+    for (int i = 0; i < fields.length; i++) {
+      definitions[i] = create(fields[i]);
+    }
+
+    return definitions;
+  }
+
+
+  public String getKey() {
+    return key;
+  }
+
+  public String getDefaultValue() {
+    return defaultValue;
+  }
+
+  public String getName() {
+    return name;
+  }
+
+  public PropertyType getType() {
+    return type;
+  }
+
+  public String[] getOptions() {
+    return options.clone();
+  }
+
+  public String getDescription() {
+    return description;
+  }
+}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/config/PropertySet.java b/sonar-plugin-api/src/main/java/org/sonar/api/config/PropertySet.java
deleted file mode 100644 (file)
index ee13b94..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2012 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * Sonar is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
- */
-package org.sonar.api.config;
-
-import com.google.common.collect.Lists;
-
-import java.util.List;
-
-public class PropertySet {
-  private final List<PropertySetField> fields = Lists.newArrayList();
-
-  public PropertySet add(PropertySetField field) {
-    fields.add(field);
-    return this;
-  }
-
-  public List<PropertySetField> getFields() {
-    return fields;
-  }
-}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/config/PropertySetDefinitions.java b/sonar-plugin-api/src/main/java/org/sonar/api/config/PropertySetDefinitions.java
deleted file mode 100644 (file)
index 511f3d9..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2012 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * Sonar is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
- */
-package org.sonar.api.config;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Maps;
-import org.sonar.api.ServerExtension;
-
-import java.util.List;
-import java.util.Map;
-import java.util.NoSuchElementException;
-
-public class PropertySetDefinitions implements ServerExtension {
-  private final Map<String, PropertySet> index = Maps.newHashMap();
-
-  public void register(String name, PropertySet propertySet) {
-    if (null != index.put(name, propertySet)) {
-      throw new IllegalStateException("Unable to register two property sets with same name " + name);
-    }
-  }
-
-  public List<PropertySet> findAll() {
-    return ImmutableList.copyOf(index.values());
-  }
-
-  public PropertySet findByName(String name) {
-    PropertySet propertySet = index.get(name);
-    if (propertySet == null) {
-      throw new NoSuchElementException("Property set not found " + name);
-    }
-    return propertySet;
-  }
-}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/config/PropertySetField.java b/sonar-plugin-api/src/main/java/org/sonar/api/config/PropertySetField.java
deleted file mode 100644 (file)
index 69376a4..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2012 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * Sonar is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
- */
-package org.sonar.api.config;
-
-import org.sonar.api.PropertyType;
-
-public final class PropertySetField {
-  private final String name;
-  private final PropertyType type;
-  private String description = "";
-  private String defaultValue = "";
-
-  private PropertySetField(String name, PropertyType type) {
-    this.name = name;
-    this.type = type;
-  }
-
-  public static PropertySetField create(String name, PropertyType type) {
-    return new PropertySetField(name, type);
-  }
-
-  public String getName() {
-    return name;
-  }
-
-  public PropertyType getType() {
-    return type;
-  }
-
-  public String getDescription() {
-    return description;
-  }
-
-  public PropertySetField setDescription(String description) {
-    this.description = description;
-    return this;
-  }
-
-  public String getDefaultValue() {
-    return defaultValue;
-  }
-
-  public PropertySetField setDefaultValue(String defaultValue) {
-    this.defaultValue = defaultValue;
-    return this;
-  }
-}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/config/PropertySetTemplate.java b/sonar-plugin-api/src/main/java/org/sonar/api/config/PropertySetTemplate.java
deleted file mode 100644 (file)
index cef931d..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2012 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * Sonar is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
- */
-package org.sonar.api.config;
-
-import org.sonar.api.ServerExtension;
-
-/**
- * This extension point must be implemented to define a new property set.
- *
- * @since 3.3
- */
-public abstract class PropertySetTemplate implements ServerExtension {
-  /**
-   * Returns the {@link org.sonar.api.config.PropertySet} object that a property set.
-   *
-   * @return the property set
-   */
-  public abstract PropertySet createPropertySet();
-
-  /**
-   * Property set unique name.
-   */
-  public abstract String getName();
-}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/config/PropertySetValue.java b/sonar-plugin-api/src/main/java/org/sonar/api/config/PropertySetValue.java
deleted file mode 100644 (file)
index 8df3ca2..0000000
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2012 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * Sonar is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
- */
-package org.sonar.api.config;
-
-import com.google.common.base.Splitter;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Lists;
-import org.apache.commons.lang.ArrayUtils;
-import org.sonar.api.utils.DateUtils;
-
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-
-/**
- * @since 3.3
- */
-public final class PropertySetValue {
-  private final Map<String, String> keyValues;
-
-  private PropertySetValue(Map<String, String> keyValues) {
-    this.keyValues = ImmutableMap.copyOf(keyValues);
-  }
-
-  public static PropertySetValue create(Map<String, String> keyValues) {
-    return new PropertySetValue(keyValues);
-  }
-
-  /**
-   * @return the field as String. If the field does not exist, then an empty string is returned.
-   */
-  public String getString(String fieldName) {
-    String value = keyValues.get(fieldName);
-    return (value == null) ? "" : value;
-  }
-
-  /**
-   * @return the field as int. If the field does not exist, then <code>0</code> is returned.
-   */
-  public int getInt(String fieldName) {
-    String value = keyValues.get(fieldName);
-    return (value == null) ? 0 : Integer.parseInt(value);
-  }
-
-  /**
-   * @return the field as boolean. If the field does not exist, then <code>false</code> is returned.
-   */
-  public boolean getBoolean(String fieldName) {
-    String value = keyValues.get(fieldName);
-    return (value == null) ? false : Boolean.parseBoolean(value);
-  }
-
-  /**
-   * @return the field as float. If the field does not exist, then <code>0.0</code> is returned.
-   */
-  public float getFloat(String fieldName) {
-    String value = keyValues.get(fieldName);
-    return (value == null) ? 0f : Float.parseFloat(value);
-  }
-
-  /**
-   * @return the field as long. If the field does not exist, then <code>0L</code> is returned.
-   */
-  public long getLong(String fieldName) {
-    String value = keyValues.get(fieldName);
-    return (value == null) ? 0L : Long.parseLong(value);
-  }
-
-  /**
-   * @return the field as Date. If the field does not exist, then <code>null</code> is returned.
-   */
-  public Date getDate(String fieldName) {
-    String value = keyValues.get(fieldName);
-    return (value == null) ? null : DateUtils.parseDate(value);
-  }
-
-  /**
-   * @return the field as Date with time. If the field does not exist, then <code>null</code> is returned.
-   */
-  public Date getDateTime(String fieldName) {
-    String value = keyValues.get(fieldName);
-    return (value == null) ? null : DateUtils.parseDateTime(value);
-  }
-
-  /**
-   * @return the field as an array of String. If the field does not exist, then an empty array is returned.
-   */
-  public String[] getStringArray(String fieldName) {
-    String value = keyValues.get(fieldName);
-    if (value == null) {
-      return ArrayUtils.EMPTY_STRING_ARRAY;
-    }
-
-    List<String> values = Lists.newArrayList();
-    for (String v : Splitter.on(",").trimResults().split(value)) {
-      values.add(v.replace("%2C", ","));
-    }
-    return values.toArray(new String[values.size()]);
-  }
-}
index 0735c91073b470838f04e3ba8ee1837c169c35be..3ec41a5cf6e79594bb8f44c867db3635778902fc 100644 (file)
@@ -19,8 +19,6 @@
  */
 package org.sonar.api.config;
 
-import com.google.common.collect.Iterables;
-
 import com.google.common.base.Joiner;
 import com.google.common.base.Splitter;
 import com.google.common.base.Strings;
@@ -29,14 +27,16 @@ import com.google.common.collect.Maps;
 import org.apache.commons.lang.ArrayUtils;
 import org.apache.commons.lang.StringUtils;
 import org.sonar.api.BatchComponent;
-import org.sonar.api.PropertyType;
 import org.sonar.api.ServerComponent;
 import org.sonar.api.utils.DateUtils;
 
 import javax.annotation.Nullable;
-import java.util.*;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
+
+import java.util.Collections;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
 
 /**
  * Project Settings on batch side, Global Settings on server side. This component does not access to database, so
@@ -184,23 +184,6 @@ public class Settings implements BatchComponent, ServerComponent {
     return getStringArrayBySeparator(key, ",");
   }
 
-  public final PropertySetValue getPropertySetValue(String key) {
-    PropertyDefinition property = getDefinitions().get(key);
-    if ((null == property) || (property.getType() != PropertyType.PROPERTY_SET)) {
-      throw new IllegalArgumentException("Property " + key + " is not of type PROPERTY_SET");
-    }
-
-    String propertySetName = property.getPropertySetName();
-    String valueName = getString(key);
-    String propertySetJson = getString("sonar.property_set." + propertySetName);
-
-    return PropertySetValue.create(lowTechJsonParsing(valueName, propertySetJson));
-  }
-
-  private static Map<String, String> lowTechJsonParsing(String valueName, String json) {
-    return Maps.newHashMap();
-  }
-  
   /**
    * Value is split by carriage returns.
    *
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/config/TestPropertySetTemplate.java b/sonar-plugin-api/src/main/java/org/sonar/api/config/TestPropertySetTemplate.java
deleted file mode 100644 (file)
index fdc53be..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2012 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * Sonar is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
- */
-package org.sonar.api.config;
-
-import org.sonar.api.PropertyType;
-
-public class TestPropertySetTemplate extends PropertySetTemplate {
-  public PropertySet createPropertySet() {
-    return new PropertySet()
-      .add(PropertySetField.create("firstName", PropertyType.TEXT))
-      .add(PropertySetField.create("lastName", PropertyType.TEXT));
-  }
-
-  public String getName() {
-    return "test";
-  }
-}
index 26409d1742b86775dea3a2d2449aa76c88ec1ca1..c8eccd712bfddf03f200b7cbd42b935943e30451 100644 (file)
@@ -25,12 +25,19 @@ import org.apache.commons.collections.Transformer;
 import org.apache.commons.lang.StringUtils;
 import org.apache.commons.lang.builder.EqualsBuilder;
 import org.apache.commons.lang.builder.HashCodeBuilder;
-import org.sonar.api.database.model.ResourceModel;
 import org.sonar.api.rules.ActiveRule;
 import org.sonar.api.rules.Rule;
 import org.sonar.api.rules.RulePriority;
 
-import javax.persistence.*;
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.OneToMany;
+import javax.persistence.Table;
+
 import java.util.ArrayList;
 import java.util.List;
 
index 59d3927aa33fdfd335412e5396a59bfd6edd47a5..caea3a388b74ddc4268cb8b2a2b7a266e95b1170 100644 (file)
@@ -19,6 +19,8 @@
  */
 package org.sonar.api.config;
 
+import org.sonar.api.PropertyField;
+
 import org.junit.Test;
 import org.sonar.api.Properties;
 import org.sonar.api.Property;
@@ -47,11 +49,12 @@ public class PropertyDefinitionTest {
     assertThat(def.isOnProject()).isTrue();
     assertThat(def.isOnModule()).isTrue();
     assertThat(def.isMultiValues()).isTrue();
-    assertThat(def.getPropertySetName()).isEmpty();
+    assertThat(def.getPropertySetKey()).isEqualTo("set");
+    assertThat(def.getFields()).isEmpty();
   }
 
   @Properties(@Property(key = "hello", name = "Hello", defaultValue = "world", description = "desc",
-    options = {"de", "en"}, category = "categ", type = PropertyType.FLOAT, global = false, project = true, module = true, multiValues = true))
+    options = {"de", "en"}, category = "categ", type = PropertyType.FLOAT, global = false, project = true, module = true, multiValues = true, propertySetKey = "set"))
   static class Init {
   }
 
@@ -73,9 +76,13 @@ public class PropertyDefinitionTest {
     assertThat(def.isOnProject()).isFalse();
     assertThat(def.isOnModule()).isFalse();
     assertThat(def.isMultiValues()).isFalse();
+    assertThat(def.getPropertySetKey()).isEmpty();
+    assertThat(def.getFields()).isEmpty();
   }
 
-  @Properties(@Property(key = "hello", name = "Hello", type = PropertyType.PROPERTY_SET, propertySetName = "set1"))
+  @Properties(@Property(key = "hello", name = "Hello", fields = {
+    @PropertyField(key = "first", name = "First"),
+    @PropertyField(key = "second", name = "Second", type = PropertyType.INTEGER)}))
   static class WithPropertySet {
   }
 
@@ -86,8 +93,13 @@ public class PropertyDefinitionTest {
 
     PropertyDefinition def = PropertyDefinition.create(prop);
 
-    assertThat(def.getType()).isEqualTo(PropertyType.PROPERTY_SET);
-    assertThat(def.getPropertySetName()).isEqualTo("set1");
+    assertThat(def.getFields()).hasSize(2);
+    assertThat(def.getFields()[0].getKey()).isEqualTo("first");
+    assertThat(def.getFields()[0].getName()).isEqualTo("First");
+    assertThat(def.getFields()[0].getType()).isEqualTo(PropertyType.STRING);
+    assertThat(def.getFields()[1].getKey()).isEqualTo("second");
+    assertThat(def.getFields()[1].getName()).isEqualTo("Second");
+    assertThat(def.getFields()[1].getType()).isEqualTo(PropertyType.INTEGER);
   }
 
   @Properties(@Property(key = "hello", name = "Hello"))
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/config/PropertySetDefinitionsTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/config/PropertySetDefinitionsTest.java
deleted file mode 100644 (file)
index cd0a3c3..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2012 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * Sonar is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
- */
-package org.sonar.api.config;
-
-import org.junit.Test;
-
-import java.util.NoSuchElementException;
-
-import static org.fest.assertions.Assertions.assertThat;
-
-public class PropertySetDefinitionsTest {
-  PropertySetDefinitions definitions = new PropertySetDefinitions();
-
-  @Test
-  public void should_register_by_name() {
-    PropertySet set = new PropertySet();
-    PropertySet other = new PropertySet();
-
-    definitions.register("name", set);
-    definitions.register("other", other);
-
-    assertThat(definitions.findByName("name")).isSameAs(set);
-    assertThat(definitions.findByName("other")).isSameAs(other);
-    assertThat(definitions.findAll()).containsOnly(set, other);
-  }
-
-  @Test(expected = IllegalStateException.class)
-  public void should_fail_to_register_twice() {
-    definitions.register("name", new PropertySet());
-    definitions.register("name", new PropertySet());
-  }
-
-  @Test(expected = NoSuchElementException.class)
-  public void should_fail_to_find_unknown_set() {
-    definitions.findByName("UNKNOWN");
-  }
-}
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/config/PropertySetFieldTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/config/PropertySetFieldTest.java
deleted file mode 100644 (file)
index c1a06cb..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2012 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * Sonar is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
- */
-package org.sonar.api.config;
-
-import org.junit.Test;
-import org.sonar.api.PropertyType;
-
-import static org.fest.assertions.Assertions.assertThat;
-
-public class PropertySetFieldTest {
-  @Test
-  public void should_set_name_and_type() {
-    PropertySetField field = PropertySetField.create("name", PropertyType.STRING);
-
-    assertThat(field.getName()).isEqualTo("name");
-    assertThat(field.getType()).isEqualTo(PropertyType.STRING);
-    assertThat(field.getDefaultValue()).isEmpty();
-    assertThat(field.getDescription()).isEmpty();
-  }
-
-  @Test
-  public void should_set_optional_characteristics() {
-    PropertySetField field = PropertySetField.create("name", PropertyType.STRING);
-
-    field.setDefaultValue("default");
-    field.setDescription("description");
-
-    assertThat(field.getDefaultValue()).isEqualTo("default");
-    assertThat(field.getDescription()).isEqualTo("description");
-  }
-}
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/config/PropertySetTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/config/PropertySetTest.java
deleted file mode 100644 (file)
index cd99914..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2012 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * Sonar is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
- */
-package org.sonar.api.config;
-
-import org.junit.Test;
-import org.sonar.api.PropertyType;
-
-import static org.fest.assertions.Assertions.assertThat;
-
-public class PropertySetTest {
-  @Test
-  public void should_add_fields() {
-    PropertySetField firstField = PropertySetField.create("first", PropertyType.STRING);
-    PropertySetField secondField = PropertySetField.create("second", PropertyType.STRING);
-
-    PropertySet set = new PropertySet();
-    set.add(firstField);
-    set.add(secondField);
-
-    assertThat(set.getFields()).containsExactly(firstField, secondField);
-  }
-}
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/config/PropertySetValueTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/config/PropertySetValueTest.java
deleted file mode 100644 (file)
index b59ac26..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2012 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * Sonar is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
- */
-package org.sonar.api.config;
-
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Maps;
-import org.junit.Test;
-
-import static org.fest.assertions.Assertions.assertThat;
-
-public class PropertySetValueTest {
-  @Test
-  public void should_get_default_values() {
-    PropertySetValue value = PropertySetValue.create(Maps.<String, String>newHashMap());
-
-    assertThat(value.getString("UNKNOWN")).isEmpty();
-    assertThat(value.getInt("UNKNOWN")).isZero();
-    assertThat(value.getFloat("UNKNOWN")).isZero();
-    assertThat(value.getLong("UNKNOWN")).isZero();
-    assertThat(value.getDate("UNKNOWN")).isNull();
-    assertThat(value.getDateTime("UNKNOWN")).isNull();
-    assertThat(value.getStringArray("UNKNOWN")).isEmpty();
-  }
-
-  @Test
-  public void should_get_values() {
-    PropertySetValue value = PropertySetValue.create(ImmutableMap.<String, String>builder()
-      .put("age", "12")
-      .put("child", "true")
-      .put("size", "12.4")
-      .put("distance", "1000000000")
-      .put("array", "1,2,3,4,5")
-      .put("birth", "1975-01-29")
-      .put("now", "2012-09-25T10:08:30+0100")
-      .build());
-
-    assertThat(value.getString("age")).isEqualTo("12");
-    assertThat(value.getInt("age")).isEqualTo(12);
-    assertThat(value.getBoolean("child")).isTrue();
-    assertThat(value.getFloat("size")).isEqualTo(12.4f);
-    assertThat(value.getLong("distance")).isEqualTo(1000000000L);
-    assertThat(value.getStringArray("array")).contains("1", "2", "3", "4", "5");
-    assertThat(value.getDate("birth")).isNotNull();
-    assertThat(value.getDateTime("now")).isNotNull();
-  }
-}
index 137e76a8b4fc48d1e4424ade3ccbdbadfc8e983a..2e5259a4995e81f164244bea3e1cac4b6b398425 100644 (file)
@@ -19,8 +19,6 @@
  */
 package org.sonar.api.config;
 
-import org.junit.Ignore;
-
 import com.google.common.collect.ImmutableMap;
 import org.junit.Before;
 import org.junit.Rule;
@@ -45,7 +43,7 @@ public class SettingsTest {
     @Property(key = "integer", name = "Integer", defaultValue = "12345"),
     @Property(key = "array", name = "Array", defaultValue = "one,two,three"),
     @Property(key = "multi_values", name = "Array", defaultValue = "1,2,3", multiValues = true),
-    @Property(key = "sonar.jira", name = "Jira Server", type = PropertyType.PROPERTY_SET, propertySetName = "jira")
+    @Property(key = "sonar.jira", name = "Jira Server", type = PropertyType.PROPERTY_SET, propertySetKey = "jira")
   })
   static class Init {
   }
@@ -155,53 +153,53 @@ public class SettingsTest {
   public void getStringArray() {
     Settings settings = new Settings(definitions);
     String[] array = settings.getStringArray("array");
-    assertThat(array).isEqualTo(new String[]{"one", "two", "three"});
+    assertThat(array).isEqualTo(new String[] {"one", "two", "three"});
   }
 
   @Test
   public void setStringArray() {
     Settings settings = new Settings(definitions);
-    settings.setProperty("multi_values", new String[]{"A", "B"});
+    settings.setProperty("multi_values", new String[] {"A", "B"});
     String[] array = settings.getStringArray("multi_values");
-    assertThat(array).isEqualTo(new String[]{"A", "B"});
+    assertThat(array).isEqualTo(new String[] {"A", "B"});
   }
 
   @Test
   public void setStringArrayTrimValues() {
     Settings settings = new Settings(definitions);
-    settings.setProperty("multi_values", new String[]{" A ", " B "});
+    settings.setProperty("multi_values", new String[] {" A ", " B "});
     String[] array = settings.getStringArray("multi_values");
-    assertThat(array).isEqualTo(new String[]{"A", "B"});
+    assertThat(array).isEqualTo(new String[] {"A", "B"});
   }
 
   @Test
   public void setStringArrayEscapeCommas() {
     Settings settings = new Settings(definitions);
-    settings.setProperty("multi_values", new String[]{"A,B", "C,D"});
+    settings.setProperty("multi_values", new String[] {"A,B", "C,D"});
     String[] array = settings.getStringArray("multi_values");
-    assertThat(array).isEqualTo(new String[]{"A,B", "C,D"});
+    assertThat(array).isEqualTo(new String[] {"A,B", "C,D"});
   }
 
   @Test
   public void setStringArrayWithEmptyValues() {
     Settings settings = new Settings(definitions);
-    settings.setProperty("multi_values", new String[]{"A,B", "", "C,D"});
+    settings.setProperty("multi_values", new String[] {"A,B", "", "C,D"});
     String[] array = settings.getStringArray("multi_values");
-    assertThat(array).isEqualTo(new String[]{"A,B", "", "C,D"});
+    assertThat(array).isEqualTo(new String[] {"A,B", "", "C,D"});
   }
 
   @Test
   public void setStringArrayWithNullValues() {
     Settings settings = new Settings(definitions);
-    settings.setProperty("multi_values", new String[]{"A,B", null, "C,D"});
+    settings.setProperty("multi_values", new String[] {"A,B", null, "C,D"});
     String[] array = settings.getStringArray("multi_values");
-    assertThat(array).isEqualTo(new String[]{"A,B", "", "C,D"});
+    assertThat(array).isEqualTo(new String[] {"A,B", "", "C,D"});
   }
 
   @Test(expected = IllegalStateException.class)
   public void shouldFailToSetArrayValueOnSingleValueProperty() {
     Settings settings = new Settings(definitions);
-    settings.setProperty("array", new String[]{"A", "B", "C"});
+    settings.setProperty("array", new String[] {"A", "B", "C"});
   }
 
   @Test
@@ -216,7 +214,7 @@ public class SettingsTest {
     Settings settings = new Settings();
     settings.setProperty("foo", "  one,  two, three  ");
     String[] array = settings.getStringArray("foo");
-    assertThat(array).isEqualTo(new String[]{"one", "two", "three"});
+    assertThat(array).isEqualTo(new String[] {"one", "two", "three"});
   }
 
   @Test
@@ -224,7 +222,7 @@ public class SettingsTest {
     Settings settings = new Settings();
     settings.setProperty("foo", "  one,  , two");
     String[] array = settings.getStringArray("foo");
-    assertThat(array).isEqualTo(new String[]{"one", "", "two"});
+    assertThat(array).isEqualTo(new String[] {"one", "", "two"});
   }
 
   @Test
@@ -282,34 +280,34 @@ public class SettingsTest {
   public void getStringLines_single_line() {
     Settings settings = new Settings();
     settings.setProperty("foo", "the line");
-    assertThat(settings.getStringLines("foo")).isEqualTo(new String[]{"the line"});
+    assertThat(settings.getStringLines("foo")).isEqualTo(new String[] {"the line"});
   }
 
   @Test
   public void getStringLines_linux() {
     Settings settings = new Settings();
     settings.setProperty("foo", "one\ntwo");
-    assertThat(settings.getStringLines("foo")).isEqualTo(new String[]{"one", "two"});
+    assertThat(settings.getStringLines("foo")).isEqualTo(new String[] {"one", "two"});
 
     settings.setProperty("foo", "one\ntwo\n");
-    assertThat(settings.getStringLines("foo")).isEqualTo(new String[]{"one", "two"});
+    assertThat(settings.getStringLines("foo")).isEqualTo(new String[] {"one", "two"});
   }
 
   @Test
   public void getStringLines_windows() {
     Settings settings = new Settings();
     settings.setProperty("foo", "one\r\ntwo");
-    assertThat(settings.getStringLines("foo")).isEqualTo(new String[]{"one", "two"});
+    assertThat(settings.getStringLines("foo")).isEqualTo(new String[] {"one", "two"});
 
     settings.setProperty("foo", "one\r\ntwo\r\n");
-    assertThat(settings.getStringLines("foo")).isEqualTo(new String[]{"one", "two"});
+    assertThat(settings.getStringLines("foo")).isEqualTo(new String[] {"one", "two"});
   }
 
   @Test
   public void getStringLines_mix() {
     Settings settings = new Settings();
     settings.setProperty("foo", "one\r\ntwo\nthree");
-    assertThat(settings.getStringLines("foo")).isEqualTo(new String[]{"one", "two", "three"});
+    assertThat(settings.getStringLines("foo")).isEqualTo(new String[] {"one", "two", "three"});
   }
 
   @Test
@@ -323,19 +321,4 @@ public class SettingsTest {
     assertThat(settings.getKeysStartingWith("sonar.jdbc")).containsOnly("sonar.jdbc.url", "sonar.jdbc.username");
     assertThat(settings.getKeysStartingWith("other")).hasSize(0);
   }
-
-  @Test
-  @Ignore
-  public void should_get_property_set_value() {
-    Settings settings = new Settings(definitions);
-    settings.setProperty("sonar.property_set.jira",
-        "[{\"set\": {\"name\": \"codehaus_jira\", \"values\": {\"key1\":\"value1\", \"key2\":\"value2\"}}},{\"set\": {\"name\": \"other\", \"values\": {\"key3\":\"value3\"}}}]");
-
-    settings.setProperty("sonar.jira", "codehaus_jira");
-    assertThat(settings.getPropertySetValue("sonar.jira").getString("key1")).isEqualTo("value1");
-    assertThat(settings.getPropertySetValue("sonar.jira").getString("key2")).isEqualTo("value2");
-
-    settings.setProperty("sonar.jira", "other");
-    assertThat(settings.getPropertySetValue("sonar.jira").getString("key3")).isEqualTo("value3");
-  }
 }
index e6b41748b0860f6cc4aa270564d1f46f226c2a54..81901dffde6b4f1e5792861f1d69344b5f454eb9 100644 (file)
@@ -44,7 +44,11 @@ import org.sonar.core.i18n.I18nManager;
 import org.sonar.core.i18n.RuleI18nManager;
 import org.sonar.core.metric.DefaultMetricFinder;
 import org.sonar.core.notification.DefaultNotificationManager;
-import org.sonar.core.persistence.*;
+import org.sonar.core.persistence.DaoUtils;
+import org.sonar.core.persistence.DatabaseMigrator;
+import org.sonar.core.persistence.DatabaseVersion;
+import org.sonar.core.persistence.DefaultDatabase;
+import org.sonar.core.persistence.MyBatis;
 import org.sonar.core.qualitymodel.DefaultModelFinder;
 import org.sonar.core.rule.DefaultRuleFinder;
 import org.sonar.core.user.DefaultUserFinder;
@@ -64,12 +68,33 @@ import org.sonar.server.database.EmbeddedDatabaseFactory;
 import org.sonar.server.filters.FilterExecutor;
 import org.sonar.server.notifications.NotificationService;
 import org.sonar.server.notifications.reviews.ReviewsNotificationManager;
-import org.sonar.server.plugins.*;
+import org.sonar.server.plugins.ApplicationDeployer;
+import org.sonar.server.plugins.DefaultServerPluginRepository;
+import org.sonar.server.plugins.PluginDeployer;
+import org.sonar.server.plugins.PluginDownloader;
+import org.sonar.server.plugins.ServerExtensionInstaller;
+import org.sonar.server.plugins.UpdateCenterClient;
+import org.sonar.server.plugins.UpdateCenterMatrixFactory;
 import org.sonar.server.qualitymodel.DefaultModelManager;
 import org.sonar.server.rules.ProfilesConsole;
 import org.sonar.server.rules.RulesConsole;
-import org.sonar.server.startup.*;
-import org.sonar.server.ui.*;
+import org.sonar.server.startup.ActivateDefaultProfiles;
+import org.sonar.server.startup.DeleteDeprecatedMeasures;
+import org.sonar.server.startup.GeneratePluginIndex;
+import org.sonar.server.startup.GwtPublisher;
+import org.sonar.server.startup.JdbcDriverDeployer;
+import org.sonar.server.startup.RegisterMetrics;
+import org.sonar.server.startup.RegisterNewDashboards;
+import org.sonar.server.startup.RegisterNewFilters;
+import org.sonar.server.startup.RegisterProvidedProfiles;
+import org.sonar.server.startup.RegisterQualityModels;
+import org.sonar.server.startup.RegisterRules;
+import org.sonar.server.startup.ServerMetadataPersister;
+import org.sonar.server.ui.CodeColorizers;
+import org.sonar.server.ui.JRubyI18n;
+import org.sonar.server.ui.PageDecorations;
+import org.sonar.server.ui.SecurityRealmFactory;
+import org.sonar.server.ui.Views;
 
 import javax.servlet.ServletContext;
 
@@ -243,7 +268,6 @@ public final class Platform {
     startupContainer.addSingleton(GeneratePluginIndex.class);
     startupContainer.addSingleton(RegisterNewFilters.class);
     startupContainer.addSingleton(RegisterNewDashboards.class);
-    startupContainer.addSingleton(RegisterPropertySets.class);
     startupContainer.startComponents();
 
     startupContainer.getComponentByType(ServerLifecycleNotifier.class).notifyStart();
diff --git a/sonar-server/src/main/java/org/sonar/server/startup/RegisterPropertySets.java b/sonar-server/src/main/java/org/sonar/server/startup/RegisterPropertySets.java
deleted file mode 100644 (file)
index a3a1995..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2012 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * Sonar is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
- */
-package org.sonar.server.startup;
-
-import com.google.common.collect.ImmutableList;
-import org.sonar.api.config.PropertySetDefinitions;
-import org.sonar.api.config.PropertySetTemplate;
-import org.sonar.api.utils.TimeProfiler;
-
-import java.util.List;
-
-/**
- * @since 3.3
- */
-public final class RegisterPropertySets {
-  private final List<PropertySetTemplate> propertySetTemplates;
-  private final PropertySetDefinitions propertySetDefinitions;
-
-  public RegisterPropertySets(PropertySetTemplate[] propertySetTemplates, PropertySetDefinitions propertySetDefinitions) {
-    this.propertySetTemplates = ImmutableList.copyOf(propertySetTemplates);
-    this.propertySetDefinitions = propertySetDefinitions;
-  }
-
-  public void start() {
-    TimeProfiler profiler = new TimeProfiler().start("Register dashboards");
-
-    for (PropertySetTemplate template : propertySetTemplates) {
-      propertySetDefinitions.register(template.getName(), template.createPropertySet());
-    }
-
-    profiler.stop();
-  }
-}
index 3738332bdccf1c055a37cc3199c52a1ade525838..b588f82a9245d4178f344c4d6673231faa06f3de 100644 (file)
@@ -23,7 +23,9 @@ import com.google.common.collect.ListMultimap;
 import com.google.common.collect.Lists;
 import org.slf4j.LoggerFactory;
 import org.sonar.api.CoreProperties;
-import org.sonar.api.config.*;
+import org.sonar.api.config.License;
+import org.sonar.api.config.PropertyDefinitions;
+import org.sonar.api.config.Settings;
 import org.sonar.api.platform.ComponentContainer;
 import org.sonar.api.platform.NewUserHandler;
 import org.sonar.api.platform.PluginMetadata;
@@ -36,7 +38,11 @@ import org.sonar.api.resources.ResourceTypes;
 import org.sonar.api.rules.RulePriority;
 import org.sonar.api.rules.RuleRepository;
 import org.sonar.api.utils.ValidationMessages;
-import org.sonar.api.web.*;
+import org.sonar.api.web.Footer;
+import org.sonar.api.web.NavigationSection;
+import org.sonar.api.web.Page;
+import org.sonar.api.web.RubyRailsWebservice;
+import org.sonar.api.web.Widget;
 import org.sonar.api.workflow.Review;
 import org.sonar.api.workflow.internal.DefaultReview;
 import org.sonar.api.workflow.internal.DefaultWorkflowContext;
@@ -55,13 +61,22 @@ import org.sonar.server.filters.Filter;
 import org.sonar.server.filters.FilterExecutor;
 import org.sonar.server.filters.FilterResult;
 import org.sonar.server.notifications.reviews.ReviewsNotificationManager;
-import org.sonar.server.platform.*;
-import org.sonar.server.plugins.*;
+import org.sonar.server.platform.NewUserNotifier;
+import org.sonar.server.platform.Platform;
+import org.sonar.server.platform.ServerIdGenerator;
+import org.sonar.server.platform.ServerSettings;
+import org.sonar.server.platform.SettingsChangeNotifier;
+import org.sonar.server.plugins.DefaultServerPluginRepository;
+import org.sonar.server.plugins.PluginDeployer;
+import org.sonar.server.plugins.PluginDownloader;
+import org.sonar.server.plugins.UpdateCenterMatrix;
+import org.sonar.server.plugins.UpdateCenterMatrixFactory;
 import org.sonar.server.rules.ProfilesConsole;
 import org.sonar.server.rules.RulesConsole;
 import org.sonar.updatecenter.common.Version;
 
 import javax.annotation.Nullable;
+
 import java.net.InetAddress;
 import java.sql.Connection;
 import java.util.Collection;
@@ -298,7 +313,7 @@ public final class JRubyFacade {
 
   public void ruleSeverityChanged(int parentProfileId, int activeRuleId, int oldSeverityId, int newSeverityId, String userName) {
     getProfilesManager().ruleSeverityChanged(parentProfileId, activeRuleId, RulePriority.values()[oldSeverityId],
-      RulePriority.values()[newSeverityId], userName);
+        RulePriority.values()[newSeverityId], userName);
   }
 
   public void ruleDeactivated(int parentProfileId, int deactivatedRuleId, String userName) {
@@ -494,14 +509,10 @@ public final class JRubyFacade {
     // notifier is null when creating the administrator in the migration script 011.
     if (notifier != null) {
       notifier.onNewUser(NewUserHandler.Context.builder()
-        .setLogin(fields.get("login"))
-        .setName(fields.get("name"))
-        .setEmail(fields.get("email"))
-        .build());
+          .setLogin(fields.get("login"))
+          .setName(fields.get("name"))
+          .setEmail(fields.get("email"))
+          .build());
     }
   }
-
-  public List<PropertySet> listPropertySets() {
-    return get(PropertySetDefinitions.class).findAll();
-  }
 }
index 4ff3b687e35e5ce36aaff2941cd7e48b49bfcced..ca9c3da81890098ba6c0245c53d0f7a3bccd1942 100644 (file)
@@ -57,9 +57,4 @@ module SettingsHelper
   def input_name(property)
     h(property.key) + (property.multi_values ? '[]' : '')
   end
-
-  def property_set_value_names(property)
-    names = PropertySet.findAll(property.propertySetName).map(&:name);
-    Api::Utils.insensitive_sort(names)
-  end
 end
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/property_set.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/property_set.rb
deleted file mode 100644 (file)
index 1defe5d..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-#
-# Sonar, entreprise quality control tool.
-# Copyright (C) 2008-2012 SonarSource
-# mailto:contact AT sonarsource DOT com
-#
-# Sonar is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 3 of the License, or (at your option) any later version.
-#
-# Sonar is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with {library}; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
-#
-class PropertySet < ActiveRecord::Base
-  attr_accessor :name
-
-  def self.columns
-    @columns ||= [];
-  end
-
-  def self.column(name, sql_type = nil, default = nil, null = true)
-    columns << ActiveRecord::ConnectionAdapters::Column.new(name.to_s, default, sql_type.to_s, null)
-  end
-
-  def self.findAll(set_name)
-    ActiveSupport::JSON.decode(values_as_json(set_name)).map { |set| PropertySet.new(set) }
-  end
-
-  def save(validate = true)
-    validate ? valid? : true
-  end
-
-  private
-
-  def self.values_as_json(set_name)
-    json = Property.value('sonar.property_set.' + set_name)
-
-    #json || '[]'
-    json || '[{"name":"set2"},{"name":"set1"}]'
-  end
-end
index b98f736a8d02f7b64f87d81a24aca8f080be02fc..b2fb09af73dbf1ef26643cd624d64c126a6a679d 100644 (file)
@@ -1,5 +1,5 @@
 <div class="multi_value marginbottom5">
-  <%= render "settings/type_#{property_type(property, value)}", :property => property, :value => value -%>
+  <%= render "settings/single_value", :property => property, :value => value -%>
   <% if delete_link -%>
     <a href="#" class="delete link-action"><%= message('delete') -%></a>
   <% end -%>
index 458b02c27c295f394daa77427a23084572704c00..8bc051e73396dc9b2d410dca98d2d65dc547c6f4 100644 (file)
@@ -37,7 +37,7 @@
               <button class="add_value"><%= message('settings.add') -%></button>
               <br/>
             <% else -%>
-              <%= render "settings/type_#{property_type(property, value)}", :property => property, :value => value -%>
+              <%= render "settings/single_value", :property => property, :value => value -%>
             <% end -%>
 
             <% p = @updated_properties[property.key] if @updated_properties -%>
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_single_value.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_single_value.html.erb
new file mode 100644 (file)
index 0000000..0a6a04d
--- /dev/null
@@ -0,0 +1,5 @@
+<% if property.fields.blank? -%>
+  <%= render "settings/type_#{property_type(property, value)}", :property => property, :value => value -%>
+<% else -%>
+  <%= render "settings/type_PROPERTY_SET_DEFINITION", :property => property, :value => value -%>
+<% end -%>
\ No newline at end of file
index aa9a1bbb2a04f6fb7063b454136c6520dadecc26..5a5928c97306704b852ffc919f61fe317fca9e70 100644 (file)
@@ -1,7 +1,7 @@
-<select name="<%= input_name(property) -%>" id="input_<%= h property.key -%>">
+<select name="<%= input_name(property) -%>" id="input_<%= h property.getKey() -%>">
   <option value=""><%= message('default') -%></option>
-  <% property_set_value_names(property).each do |option| %>
-    <option value="<%= h option -%>" <%= 'selected' if value && value==option -%>><%= h option -%></option>
-  <% end %>
-</select>
-<a id="edit-set-<%= h property.key -%>" href="property_sets/index" class="open-modal link-action">Edit property set...</a>
+
+  <% Property.values(property.propertySetKey).reject(&:blank?).each do |set_key| -%>
+    <option value="<%= set_key -%>"><%= set_key -%></option>
+  <% end -%>
+</select>
\ No newline at end of file
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_PROPERTY_SET_DEFINITION.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_type_PROPERTY_SET_DEFINITION.html.erb
new file mode 100644 (file)
index 0000000..22777ac
--- /dev/null
@@ -0,0 +1,17 @@
+<% Property.set('sonar.test.jira.servers', 'jira1,jira2') -%>
+<% Property.set('sonar.test.jira.servers.jira1.url', 'http://url1') -%>
+<% Property.set('sonar.test.jira.servers.jira1.port', '1234') -%>
+<% Property.set('sonar.test.jira.servers.jira2.url', 'http://url2') -%>
+<% Property.set('sonar.test.jira.servers.jira2.port', '9999') -%>
+
+<% Property.values(property.key).reject(&:blank?).each do |set_key| -%>
+  <h3><%= set_key -%></h3>
+
+  <% property.fields.each do |field| -%>
+    <label><%= field.key -%>: </label><input type="text" value="<%= Property.value([property.key, set_key, field.key].join('.')) -%>"/><br/>
+  <% end -%>
+
+  <a href="#" class="delete link-action"><%= message('delete') -%></a>
+<% end -%>
+
+<button class="add_value"><%= message('settings.add') -%></button>
diff --git a/sonar-server/src/test/java/org/sonar/server/startup/RegisterPropertySetsTest.java b/sonar-server/src/test/java/org/sonar/server/startup/RegisterPropertySetsTest.java
deleted file mode 100644 (file)
index b74d1b8..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2012 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * Sonar is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
- */
-package org.sonar.server.startup;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.sonar.api.config.PropertySet;
-import org.sonar.api.config.PropertySetDefinitions;
-import org.sonar.api.config.PropertySetTemplate;
-
-import static org.mockito.Mockito.*;
-
-public class RegisterPropertySetsTest {
-  private RegisterPropertySets task;
-  private PropertySetDefinitions propertySetDefinitions = mock(PropertySetDefinitions.class);
-  private PropertySetTemplate firstTemplate = mock(PropertySetTemplate.class);
-  private PropertySetTemplate secondTemplate = mock(PropertySetTemplate.class);
-  private PropertySet firstPropertySet = mock(PropertySet.class);
-  private PropertySet secondPropertySet = mock(PropertySet.class);
-
-  @Before
-  public void init() {
-    task = new RegisterPropertySets(new PropertySetTemplate[]{firstTemplate, secondTemplate}, propertySetDefinitions);
-  }
-
-  @Test
-  public void should_register_on_startup() {
-    when(firstTemplate.getName()).thenReturn("first");
-    when(secondTemplate.getName()).thenReturn("second");
-    when(firstTemplate.createPropertySet()).thenReturn(firstPropertySet);
-    when(secondTemplate.createPropertySet()).thenReturn(secondPropertySet);
-
-    task.start();
-
-    verify(propertySetDefinitions).register("first", firstPropertySet);
-    verify(propertySetDefinitions).register("second", secondPropertySet);
-  }
-}