]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-2602 support project modules with different languages
authorSimon Brandhof <simon.brandhof@gmail.com>
Thu, 27 Sep 2012 13:17:59 +0000 (15:17 +0200)
committerSimon Brandhof <simon.brandhof@gmail.com>
Thu, 27 Sep 2012 13:17:59 +0000 (15:17 +0200)
77 files changed:
plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties
plugins/sonar-core-plugin/src/test/resources/org/sonar/plugins/core/timemachine/ReferenceAnalysisTest/shared.xml
plugins/sonar-core-plugin/src/test/resources/org/sonar/plugins/core/timemachine/ViolationPersisterDecoratorTest/shared.xml
plugins/sonar-core-plugin/src/test/resources/org/sonar/plugins/core/timemachine/ViolationPersisterDecoratorTest/shouldCopyPermanentIdFromReferenceViolation-result.xml
plugins/sonar-core-plugin/src/test/resources/org/sonar/plugins/core/timemachine/ViolationPersisterDecoratorTest/shouldSaveViolations-result.xml
sonar-batch/src/main/java/org/sonar/batch/DefaultProfileLoader.java
sonar-batch/src/main/java/org/sonar/batch/ProfileProvider.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/DefaultProfileLoaderTest.java
sonar-batch/src/test/java/org/sonar/batch/ProjectConfiguratorTest.java
sonar-batch/src/test/resources/org/sonar/batch/DefaultTimeMachineTest/loadMeasuresFromDate.xml
sonar-batch/src/test/resources/org/sonar/batch/components/TimeMachineConfigurationTest/shared.xml
sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shared.xml
sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldRemoveRootIndexIfResourceIsProject-result.xml
sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldRemoveRootIndexIfResourceIsProject.xml
sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldSaveNewDirectory-result.xml
sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldSaveNewLibrary-result.xml
sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldSaveNewMultiModulesProject-result.xml
sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldSaveNewProject-result.xml
sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldUpdateExistingResource-result.xml
sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldUpdateExistingResource.xml
sonar-batch/src/test/resources/org/sonar/batch/index/SourcePersisterTest/shared.xml
sonar-batch/src/test/resources/org/sonar/batch/index/SourcePersisterTest/shouldSaveSource-result.xml
sonar-core/src/main/java/org/sonar/core/persistence/DatabaseVersion.java
sonar-core/src/main/java/org/sonar/core/resource/ResourceDto.java
sonar-core/src/main/java/org/sonar/jpa/dao/ProfilesDao.java
sonar-core/src/main/resources/org/sonar/core/persistence/rows-h2.sql
sonar-core/src/main/resources/org/sonar/core/persistence/schema-h2.ddl
sonar-core/src/main/resources/org/sonar/core/resource/ResourceMapper.xml
sonar-core/src/test/java/org/sonar/jpa/dao/ProfilesDaoTest.java
sonar-core/src/test/resources/org/sonar/core/purge/PurgeCommandsTest/shouldDeleteResource.xml
sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/shouldDeleteAbortedBuilds-result.xml
sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/shouldDeleteAbortedBuilds.xml
sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/shouldDeleteHistoricalDataOfDirectoriesAndFiles-result.xml
sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/shouldDeleteHistoricalDataOfDirectoriesAndFiles.xml
sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/shouldDeleteProject.xml
sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/shouldDisableResourcesWithoutLastSnapshot-result.xml
sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/shouldDisableResourcesWithoutLastSnapshot.xml
sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/shouldPurgeProject-result.xml
sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/shouldPurgeProject.xml
sonar-core/src/test/resources/org/sonar/core/resource/ResourceDaoTest/insert-result.xml
sonar-core/src/test/resources/org/sonar/core/resource/ResourceDaoTest/update-result.xml
sonar-core/src/test/resources/org/sonar/core/resource/ResourceDaoTest/update.xml
sonar-core/src/test/resources/org/sonar/core/resource/ResourceKeyUpdaterDaoTest/shared.xml
sonar-core/src/test/resources/org/sonar/core/resource/ResourceKeyUpdaterDaoTest/shouldBulkUpdateKey-result.xml
sonar-core/src/test/resources/org/sonar/core/resource/ResourceKeyUpdaterDaoTest/shouldBulkUpdateKeyOnOnlyOneSubmodule-result.xml
sonar-core/src/test/resources/org/sonar/core/resource/ResourceKeyUpdaterDaoTest/shouldNotUpdateAllSubmodules-result.xml
sonar-core/src/test/resources/org/sonar/core/resource/ResourceKeyUpdaterDaoTest/shouldNotUpdateAllSubmodules.xml
sonar-core/src/test/resources/org/sonar/core/resource/ResourceKeyUpdaterDaoTest/shouldUpdateKey-result.xml
sonar-plugin-api/src/main/java/org/sonar/api/database/model/ResourceModel.java
sonar-plugin-api/src/main/java/org/sonar/api/profiles/RulesProfile.java
sonar-server/src/main/java/org/sonar/server/configuration/ProfilesManager.java
sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java
sonar-server/src/main/webapp/WEB-INF/app/controllers/application_controller.rb
sonar-server/src/main/webapp/WEB-INF/app/controllers/profiles_controller.rb
sonar-server/src/main/webapp/WEB-INF/app/controllers/project_controller.rb
sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb
sonar-server/src/main/webapp/WEB-INF/app/models/api/utils.rb
sonar-server/src/main/webapp/WEB-INF/app/models/profile.rb
sonar-server/src/main/webapp/WEB-INF/app/models/project.rb
sonar-server/src/main/webapp/WEB-INF/app/models/property.rb
sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_layout.html.erb
sonar-server/src/main/webapp/WEB-INF/app/views/profiles/_copy_form.html.erb
sonar-server/src/main/webapp/WEB-INF/app/views/profiles/_rename_form.html.erb
sonar-server/src/main/webapp/WEB-INF/app/views/profiles/index.html.erb
sonar-server/src/main/webapp/WEB-INF/app/views/profiles/projects.html.erb
sonar-server/src/main/webapp/WEB-INF/app/views/project/profile.html.erb [new file with mode: 0644]
sonar-server/src/main/webapp/WEB-INF/app/views/project/quality_profile.html.erb [deleted file]
sonar-server/src/main/webapp/WEB-INF/db/migrate/331_remove_projects_profile_id.rb [new file with mode: 0644]
sonar-server/src/test/java/org/sonar/server/configuration/InheritedProfilesTest.java
sonar-server/src/test/java/org/sonar/server/configuration/ProfilesManagerTest.java
sonar-server/src/test/resources/org/sonar/server/configuration/InheritedProfilesTest/shouldNotDeleteInheritedProfile-result.xml [deleted file]
sonar-server/src/test/resources/org/sonar/server/configuration/InheritedProfilesTest/shouldRenameInheritedProfile-result.xml [deleted file]
sonar-server/src/test/resources/org/sonar/server/filters/FilterExecutorTest/measures.xml
sonar-server/src/test/resources/org/sonar/server/filters/FilterExecutorTest/shared.xml
sonar-server/src/test/resources/org/sonar/server/filters/FilterExecutorTest/views.xml

index bafe68fcfaa8f9ef9eac3a52da1e6755e96d1d52..267ccceeffe3f40a3d3e5da2b962dbdaccf41197 100644 (file)
@@ -75,6 +75,7 @@ min=Min
 minor=Minor
 more_actions=More actions
 name=Name
+name_too_long_x=Name is too long (maximum is {0} characters)
 none=None
 off=Off
 on=On
@@ -94,6 +95,7 @@ plugin=Plugin
 project=Project
 projects=Projects
 raw=Raw
+remove=Remove
 rename=Rename
 reset_verb=Reset
 result=Result
@@ -132,6 +134,7 @@ unselect_all=Unselect all
 unselect_verb=Unselect
 updated=Updated
 update_verb=Update
+updating=Updating
 user=User
 value=Value
 variation=Variation
@@ -141,6 +144,7 @@ views=Views
 violations=Violations
 
 
+
 #------------------------------------------------------------------------------
 #
 # GENERIC EXPRESSIONS, sorted alphabetically
@@ -1094,10 +1098,7 @@ update_key.no_key_to_update=No key contains the string to replace ("{0}").
 # PROJECT QUALITY PROFILE PAGE
 #
 #------------------------------------------------------------------------------
-project_quality_profile.select_profile_for_x=Select the quality profile to be used when analyzing the "{0}" project:
-project_quality_profile.project_cannot_be_update_with_profile_x=The current project can not be updated with the following profile: "{0}".
-project_quality_profile.profile_successfully_updated=Quality profile successfully updated.
-project_quality_profile.default_profile=default
+project_quality_profile.default_profile=Default
 
 
 #------------------------------------------------------------------------------
@@ -1153,7 +1154,6 @@ quality_profiles.are_you_sure_want_x_profile_as_default=Are you sure that you wa
 quality_profiles.profile_x_created=Profile "{0}" created. Set it as default or link it to a project to use it for next measures.
 quality_profiles.already_exists=This profile already exists.
 quality_profiles.please_type_profile_name=Please type a profile name.
-quality_profiles.delete_confirm_title=Delete Profile
 quality_profiles.profile_x_deleted=Profile "{0}" is deleted.
 quality_profiles.default_profile_is_x=Default profile is "{0}".
 quality_profiles.profile_x_not_activated=Profile "{0}" is created but not activated.
@@ -1193,7 +1193,9 @@ quality_profiles.with_same_configuration=With same configuration
 quality_profiles.x_rules_only_in={0} rules only in
 quality_profiles.x_rules_have_different_configuration={0} rules have a different configuration
 quality_profiles.export_all_rules=All rules
-
+quality_profiles.remove_projects_action=Remove All
+quality_profiles.copy_x_title=Copy Profile {0}
+quality_profiles.copy_new_name=New Name
 
 #------------------------------------------------------------------------------
 #
index dd96aeecbf15aa09201ca0a0426a9bb361781ded..cca1757cb78647643b530729ea46d29ae70c32e0 100644 (file)
@@ -2,7 +2,7 @@
 
   <projects id="200" scope="FIL" qualifier="CLA" kee="project:org.foo.Bar" root_id="[null]"
             name="Bar" long_name="org.foo.Bar" description="[null]"
-            enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]"/>
+            enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" />
 
   <snapshots purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" period2_param="[null]" period2_date="[null]" period3_mode="[null]" period3_param="[null]" period3_date="[null]" period4_mode="[null]" period4_param="[null]" period4_date="[null]" period5_mode="[null]" period5_param="[null]" period5_date="[null]" id="1000" project_id="200" parent_snapshot_id="[null]" root_project_id="100" root_snapshot_id="[null]"
              scope="FIL" qualifier="CLA" created_at="2008-11-01 13:58:00.00" build_date="2008-11-01 13:58:00.00" version="[null]" path=""
index 47dd47e31a2f7d0bbe7854e2dc17dbc8c0faf9f8..53b31f29464159018c89edf80e183d0917e3cf36 100644 (file)
@@ -10,7 +10,7 @@
 
   <projects id="200" scope="FIL" qualifier="CLA" kee="project:org.foo.Bar" root_id="[null]"
             name="Bar" long_name="org.foo.Bar" description="[null]"
-            enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]"/>
+            enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" />
 
   <snapshots purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" period2_param="[null]" period2_date="[null]" period3_mode="[null]" period3_param="[null]"
              period3_date="[null]" period4_mode="[null]" period4_param="[null]" period4_date="[null]" period5_mode="[null]" period5_param="[null]" period5_date="[null]"
index b5ce1f7afc717f2f212671c0302bd3820d96d9d7..76d13a534896fcc3ac1e23d27d062d8e1182fee9 100644 (file)
@@ -10,7 +10,7 @@
 
   <projects id="200" scope="FIL" qualifier="CLA" kee="project:org.foo.Bar" root_id="[null]"
             name="Bar" long_name="org.foo.Bar" description="[null]"
-            enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]"/>
+            enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" />
 
   <snapshots purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" period2_param="[null]" period2_date="[null]" period3_mode="[null]" period3_param="[null]"
              period3_date="[null]" period4_mode="[null]" period4_param="[null]" period4_date="[null]" period5_mode="[null]" period5_param="[null]" period5_date="[null]" id="1000" project_id="200"
index 5bd323e886669a66e992908c13aac616ac641447..485a01a597726f5d35929e2fa9e8c931f2fdb56d 100644 (file)
@@ -9,7 +9,7 @@
 
   <projects id="200" scope="FIL" qualifier="CLA" kee="project:org.foo.Bar" root_id="[null]"
             name="Bar" long_name="org.foo.Bar" description="[null]"
-            enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]"/>
+            enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" />
 
   <snapshots purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" period2_param="[null]" period2_date="[null]" period3_mode="[null]" period3_param="[null]"
              period3_date="[null]" period4_mode="[null]" period4_param="[null]" period4_date="[null]" period5_mode="[null]" period5_param="[null]" period5_date="[null]" id="1000" project_id="200"
index 35a10a679f788cf97190683f49bdbd20669f0177..cdc5876300c3f42f25342e7ef1afafa937914fb7 100644 (file)
@@ -19,6 +19,8 @@
  */
 package org.sonar.batch;
 
+import org.apache.commons.lang.StringUtils;
+import org.sonar.api.config.Settings;
 import org.sonar.api.profiles.RulesProfile;
 import org.sonar.api.resources.Project;
 import org.sonar.api.rules.ActiveRule;
@@ -26,27 +28,26 @@ import org.sonar.api.utils.SonarException;
 import org.sonar.jpa.dao.ProfilesDao;
 
 public class DefaultProfileLoader implements ProfileLoader {
-  static final String PARAM_PROFILE = "sonar.profile";
-
   private ProfilesDao dao;
+  private Settings settings;
 
-  public DefaultProfileLoader(ProfilesDao dao) {
+  public DefaultProfileLoader(ProfilesDao dao, Settings settings) {
     this.dao = dao;
+    this.settings = settings;
   }
 
   public RulesProfile load(Project project) {
-    String profileName = (String) project.getProperty(PARAM_PROFILE);
+    String profileName = StringUtils.defaultIfBlank(settings.getString("sonar.profile." + project.getLanguageKey()), settings.getString("sonar.profile"));
     RulesProfile profile;
-    if (profileName == null) {
-      Project root = project.getRoot();
-      profile = dao.getActiveProfile(root.getLanguageKey(), root.getKey());
+
+    // temporary
+    if (StringUtils.isBlank(profileName)) {
+      profile = dao.getDefaultProfile(project.getLanguageKey());
       if (profile == null) {
         // This means that the current language is not supported by any installed plugin, otherwise at least a
         // "Default <Language Name>" profile would have been created by ActivateDefaultProfiles class.
-        throw new SonarException("You must intall a Sonar plugin that supports language '" + root.getLanguageKey()
-          + "' in order to analyse the following project: " + root.getKey());
+        throw new SonarException("You must install a plugin that supports the language '" + project.getLanguageKey() + "'");
       }
-
     } else {
       profile = dao.getProfile(project.getLanguageKey(), profileName);
       if (profile == null) {
@@ -56,6 +57,7 @@ public class DefaultProfileLoader implements ProfileLoader {
 
     // hack to lazy initialize the profile collections
     profile.getActiveRules().size();
+
     for (ActiveRule activeRule : profile.getActiveRules()) {
       activeRule.getActiveRuleParams().size();
       activeRule.getRule().getParams().size();
index a274827ee366248d83531172332e8bff1b9f5a45..22a8c030108a91a38cae1997d1627519fab48576 100644 (file)
@@ -34,7 +34,7 @@ public class ProfileProvider extends ProviderAdapter {
   public RulesProfile provide(Project project, ProfileLoader profileLoader) {
     if (profile == null) {
       profile = profileLoader.load(project);
-      LOG.info("Selected quality profile : {}", profile);
+      LOG.info("Quality profile : {}", profile);
     }
     return profile;
   }
index 139c296fad71ffec776bfad2f9f5e80d534d201d..1ea83f62df9d198cf8d01fad66a70a8f9aae0ce5 100644 (file)
@@ -73,8 +73,7 @@ public class ProjectConfigurator implements BatchComponent {
         .setAnalysisDate(analysisDate)
         .setLatestAnalysis(isLatestAnalysis(project.getKey(), analysisDate))
         .setAnalysisVersion(loadAnalysisVersion())
-        .setAnalysisType(loadAnalysisType())
-        .setLanguageKey(loadLanguageKey());
+        .setAnalysisType(loadAnalysisType());
     return this;
   }
 
@@ -88,7 +87,7 @@ public class ProjectConfigurator implements BatchComponent {
   }
 
   Date loadAnalysisDate() {
-    Date date = null;
+    Date date;
     try {
       // sonar.projectDate may have been specified as a time
       date = settings.getDateTime(CoreProperties.PROJECT_DATE_PROPERTY);
@@ -119,8 +118,4 @@ public class ProjectConfigurator implements BatchComponent {
   String loadAnalysisVersion() {
     return settings.getString(CoreProperties.PROJECT_VERSION_PROPERTY);
   }
-
-  String loadLanguageKey() {
-    return StringUtils.defaultIfBlank(settings.getString(CoreProperties.PROJECT_LANGUAGE_PROPERTY), Java.KEY);
-  }
 }
index d470a9cdb02135dd0777f836dd69440891067d08..aca22d363f46effb9a99a69d2fed81077238085f 100644 (file)
@@ -26,6 +26,7 @@ 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.core.config.ConfigurationUtils;
 import org.sonar.core.properties.PropertiesDao;
@@ -48,6 +49,13 @@ public class ProjectSettings extends Settings {
     this.projectDefinition = projectDefinition;
     this.propertiesDao = propertiesDao;
     load();
+    updateProject(project);
+  }
+
+  private void updateProject(Project project) {
+    // The class org.sonar.api.batch.Project should be deeply refactored and should load language from settings.
+    // Meanwhile the language must be updated :
+    project.setLanguageKey(StringUtils.defaultIfBlank(getString("sonar.language"), Java.KEY));
   }
 
   public ProjectSettings load() {
index 735c21c71303fb85d8e38f0fe260983667696e78..9d50aadfb9b6af066ce9e9286a80d058f4c9008b 100644 (file)
  */
 package org.sonar.batch;
 
-import static org.junit.Assert.assertNotNull;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import java.util.Collections;
-import java.util.HashMap;
-
-import org.apache.commons.configuration.MapConfiguration;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
-import org.sonar.api.profiles.Alert;
+import org.sonar.api.config.Settings;
 import org.sonar.api.profiles.RulesProfile;
 import org.sonar.api.resources.Java;
 import org.sonar.api.resources.Project;
-import org.sonar.api.rules.ActiveRule;
 import org.sonar.api.utils.SonarException;
 import org.sonar.jpa.dao.ProfilesDao;
 
+import static org.fest.assertions.Assertions.assertThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
 public class DefaultProfileLoaderTest {
 
   @Rule
   public ExpectedException thrown = ExpectedException.none();
 
   private ProfilesDao dao;
-  private ProfileLoader loader;
+  private Project javaProject = new Project("project").setLanguageKey(Java.KEY);
 
   @Before
   public void setUp() {
     dao = mock(ProfilesDao.class);
-    loader = new DefaultProfileLoader(dao);
   }
 
   @Test
-  public void shouldGetProjectProfile() {
-    Project project = new Project("project").setLanguageKey(Java.KEY);
-    Project module = new Project("module").setParent(project).setLanguageKey(Java.KEY);
+  public void should_get_configured_profile() {
+    Settings settings = new Settings();
+    settings.setProperty("sonar.profile.java", "legacy profile");
+    when(dao.getProfile(Java.KEY, "legacy profile")).thenReturn(RulesProfile.create("legacy profile", "java"));
 
-    when(dao.getActiveProfile(Java.KEY, "project")).thenReturn(newProfile());
+    RulesProfile profile = new DefaultProfileLoader(dao, settings).load(javaProject);
 
-    assertNotNull(loader.load(module));
-
-    verify(dao, never()).getActiveProfile(Java.KEY, "module");
-    verify(dao).getActiveProfile(Java.KEY, "project");
-  }
-
-  private RulesProfile newProfile() {
-    RulesProfile profile = new RulesProfile();
-    profile.setAlerts(Collections.<Alert> emptyList());
-    profile.setActiveRules(Collections.<ActiveRule> emptyList());
-    return profile;
+    assertThat(profile.getName()).isEqualTo("legacy profile");
   }
 
   @Test
-  public void mavenPropertyShouldOverrideProfile() {
-    Project project = new Project("project").setLanguageKey(Java.KEY);
-
-    MapConfiguration conf = new MapConfiguration(new HashMap());
-    conf.addProperty(DefaultProfileLoader.PARAM_PROFILE, "profile1");
-    project.setConfiguration(conf);
+  public void should_get_default_profile() {
+    Settings settings = new Settings();
+    when(dao.getDefaultProfile(Java.KEY)).thenReturn(RulesProfile.create("default profile", "java"));
 
-    when(dao.getProfile(Java.KEY, "profile1")).thenReturn(newProfile());
+    RulesProfile profile = new DefaultProfileLoader(dao, settings).load(javaProject);
 
-    loader.load(project);
-
-    verify(dao).getProfile(Java.KEY, "profile1");
-    verify(dao, never()).getActiveProfile(Java.KEY, "project");
+    assertThat(profile.getName()).isEqualTo("default profile");
   }
 
   @Test
-  public void shouldFailIfProfileIsNotFound() {
-    Project project = new Project("project").setLanguageKey(Java.KEY);
-
-    MapConfiguration conf = new MapConfiguration(new HashMap());
-    conf.addProperty(DefaultProfileLoader.PARAM_PROFILE, "unknown");
-    project.setConfiguration(conf);
-
-    when(dao.getProfile(Java.KEY, "profile1")).thenReturn(null);
+  public void should_fail_if_not_found() {
+    Settings settings = new Settings();
+    settings.setProperty("sonar.profile.java", "unknown");
 
     thrown.expect(SonarException.class);
     thrown.expectMessage("Quality profile not found : unknown, language java");
-    loader.load(project);
+    new DefaultProfileLoader(dao, settings).load(javaProject);
   }
 
   /**
    * SONAR-3125
    */
   @Test
-  public void shouldGiveExplicitMessageIfNoProfileFound() {
-    Project project = new Project("foo:project").setLanguageKey("unknown-language");
-    when(dao.getProfile(Java.KEY, "profile1")).thenReturn(null);
+  public void should_give_explicit_message_if_default_profile_not_found() {
+    Project cobolProject = new Project("cobol-javaProject").setLanguageKey("cobol");
 
     thrown.expect(SonarException.class);
-    thrown.expectMessage("You must intall a Sonar plugin that supports language 'unknown-language' in order to analyse the following project: foo:project");
-    loader.load(project);
+    thrown.expectMessage("You must install a plugin that supports the language 'cobol'");
+    new DefaultProfileLoader(dao, new Settings()).load(cobolProject);
   }
 
 }
index 1d60f84f59bcd336e27474697dfb8358c777f167..4db0e9f4c5a1f5c8ac60bd86c2869363b8c2af6d 100644 (file)
@@ -36,25 +36,6 @@ import static org.junit.Assert.assertTrue;
 
 public class ProjectConfiguratorTest extends AbstractDbUnitTestCase {
 
-  @Test
-  public void getLanguageFromConfiguration() {
-    Settings configuration = new Settings();
-    configuration.setProperty(CoreProperties.PROJECT_LANGUAGE_PROPERTY, "foo");
-
-    Project project = new Project("key");
-    new ProjectConfigurator(getSession(), configuration).configure(project);
-
-    assertThat(project.getLanguageKey(), is("foo"));
-  }
-
-  @Test
-  public void defaultLanguageIsJava() {
-    Project project = new Project("key");
-    new ProjectConfigurator(getSession(), new Settings()).configure(project);
-
-    assertThat(project.getLanguageKey(), is(Java.KEY));
-  }
-
   @Test
   public void analysisIsTodayByDefault() {
     Project project = new Project("key");
index 3a6d76cabaf5fc0ce44f4a82d0efe9b3f01f27fe..fef06b0f60d69ed5e24925bce1560b9f485b0dd5 100644 (file)
@@ -6,10 +6,10 @@
 
   <projects long_name="[null]" id="1" scope="PRJ" kee="group:artifact" qualifier="TRK" name="my project"
             root_id="[null]"
-            description="[null]" enabled="true" profile_id="[null]" language="java" copy_resource_id="[null]" person_id="[null]"/>
+            description="[null]" enabled="true"  language="java" copy_resource_id="[null]" person_id="[null]"/>
   <projects long_name="[null]" id="2" scope="DIR" kee="group:artifact:org.sonar" qualifier="PAC" name="org.sonar"
             root_id="2"
-            description="[null]" enabled="true" profile_id="[null]" language="java" copy_resource_id="[null]" person_id="[null]"/>
+            description="[null]" enabled="true"  language="java" copy_resource_id="[null]" person_id="[null]"/>
 
 
   <!-- Project : 3 snapshots -->
index 65c8a4950385624ffcef908e2bfd7b1d510b265f..c8796e2bb80156e461188928fb8811adf001a44e 100644 (file)
@@ -1,12 +1,12 @@
 <dataset>
 
   <projects long_name="[null]" id="1" scope="PRJ" kee="my:project" qualifier="LIB" name="my project as lib"
-            root_id="[null]" description="[null]" enabled="true" profile_id="[null]" language="java" copy_resource_id="[null]" person_id="[null]"/>
+            root_id="[null]" description="[null]" enabled="true"  language="java" copy_resource_id="[null]" person_id="[null]"/>
 
   <projects long_name="[null]" id="2" scope="PRJ" kee="my:project" qualifier="TRK" name="my project"
-            root_id="[null]" description="[null]" enabled="true" profile_id="[null]" language="java" copy_resource_id="[null]" person_id="[null]"/>
+            root_id="[null]" description="[null]" enabled="true"  language="java" copy_resource_id="[null]" person_id="[null]"/>
 
   <projects long_name="[null]" id="3" scope="DIR" kee="my:project:path/to/dir" qualifier="TRK" name="my dir"
-            root_id="2" description="[null]" enabled="true" profile_id="[null]" language="java" copy_resource_id="[null]" person_id="[null]"/>
+            root_id="2" description="[null]" enabled="true"  language="java" copy_resource_id="[null]" person_id="[null]"/>
 
 </dataset>
index cff08ac82fe7784a9bb115e0e14ce0c1edc4a1f4..4eaddace0e19407baf2a2b72e8a3d3c4bb906890 100644 (file)
@@ -3,7 +3,7 @@
   <!-- other project -->
   <projects id="1000" scope="PRJ" qualifier="TRK" kee="my:key" root_id="[null]"
             name="Other project" long_name="Other" description="[null]"
-            enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]" created_at="[null]"/>
+            enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/>
 
   <snapshots purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" period2_param="[null]" period2_date="[null]" period3_mode="[null]" period3_param="[null]" period3_date="[null]" period4_mode="[null]" period4_param="[null]" period4_date="[null]" period5_mode="[null]" period5_param="[null]" period5_date="[null]" id="3000" project_id="1000" parent_snapshot_id="[null]" root_project_id="1000" root_snapshot_id="[null]"
              scope="PRJ" qualifier="TRK" created_at="2008-11-01 13:58:00.00" build_date="2008-11-01 13:58:00.00" version="[null]" path=""
index 475dc3fe89b35667b3be0c620bb0555853d7ec95..bc7fc1c6f0af0cdc81c3aab351e7fd274812eed9 100644 (file)
@@ -2,7 +2,7 @@
 
   <projects id="1001" scope="PRJ" qualifier="TRK" kee="foo" root_id="[null]"
             name="Foo" long_name="Foo" description="some description"
-            enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]" created_at="[null]"/>
+            enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/>
 
   <!-- old snapshot -->
   <snapshots purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" period2_param="[null]" period2_date="[null]" period3_mode="[null]" period3_param="[null]" period3_date="[null]" period4_mode="[null]" period4_param="[null]" period4_date="[null]" period5_mode="[null]" period5_param="[null]" period5_date="[null]" id="3001" project_id="1001" parent_snapshot_id="[null]" root_project_id="1001" root_snapshot_id="[null]"
index a8e44dd6f86d01221af734e61f1e4c889fdce904..8b4092b1e967f9870271a3ad134e4926c39d307a 100644 (file)
@@ -3,7 +3,7 @@
   <!-- This project has a root_id which should be set to NULL (SONAR-1700) -->
   <projects id="1001" scope="PRJ" qualifier="TRK" kee="foo" root_id="12345"
             name="name" long_name="long name" description="description"
-            enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]" created_at="[null]"/>
+            enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/>
 
   <snapshots purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" period2_param="[null]" period2_date="[null]" period3_mode="[null]" period3_param="[null]" period3_date="[null]" period4_mode="[null]" period4_param="[null]" period4_date="[null]" period5_mode="[null]" period5_param="[null]" period5_date="[null]" id="3001" project_id="1001" parent_snapshot_id="[null]" root_project_id="1001" root_snapshot_id="[null]"
              scope="PRJ" qualifier="TRK" created_at="2010-12-23 00:00:00.00" build_date="2010-12-23 00:00:00.00" version="[null]" path=""
index b78bd590b186f35514972dfe035f291c9a3c7fb9..bfa0198e5b9e9a64b19e36c24eff183a9e70402b 100644 (file)
@@ -3,7 +3,7 @@
   <!-- other project -->
   <projects id="1000" scope="PRJ" qualifier="TRK" kee="my:key" root_id="[null]"
             name="Other project" long_name="Other" description="[null]"
-            enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]" created_at="[null]"/>
+            enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" />
 
   <snapshots purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" period2_param="[null]" period2_date="[null]" period3_mode="[null]" period3_param="[null]" period3_date="[null]" period4_mode="[null]" period4_param="[null]" period4_date="[null]" period5_mode="[null]" period5_param="[null]" period5_date="[null]" id="3000" project_id="1000" parent_snapshot_id="[null]" root_project_id="1000" root_snapshot_id="[null]"
              scope="PRJ" qualifier="TRK" created_at="2008-11-01 13:58:00.00" build_date="2008-11-01 13:58:00.00" version="[null]" path=""
   <!-- new project -->
   <projects id="1001" scope="PRJ" qualifier="TRK" kee="foo" root_id="[null]"
             name="Foo" long_name="Foo" description="some description"
-            enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]" created_at="[null]"/>
+            enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" />
 
   <projects id="1002" scope="DIR" qualifier="PAC" kee="foo:org.foo" root_id="1001"
             name="org.foo" long_name="org.foo" description="[null]"
-            enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]" created_at="[null]"/>
+            enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" />
 
   <snapshots purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" period2_param="[null]" period2_date="[null]" period3_mode="[null]" period3_param="[null]" period3_date="[null]" period4_mode="[null]" period4_param="[null]" period4_date="[null]" period5_mode="[null]" period5_param="[null]" period5_date="[null]" id="3001" project_id="1001" parent_snapshot_id="[null]" root_project_id="1001" root_snapshot_id="[null]"
              scope="PRJ" qualifier="TRK" created_at="2010-12-25 00:00:00.00" build_date="2010-12-25 00:00:00.00" version="[null]" path=""
index bfc203efeeaf97a5f9261bae26e8b7522b234834..7c4ab1f4008f444e4a5234cd2f8f18ed5f6b334f 100644 (file)
@@ -3,7 +3,7 @@
   <!-- other project -->
   <projects id="1000" scope="PRJ" qualifier="TRK" kee="my:key" root_id="[null]"
             name="Other project" long_name="Other" description="[null]"
-            enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]" created_at="[null]"/>
+            enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" />
 
   <snapshots purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" period2_param="[null]" period2_date="[null]" period3_mode="[null]" period3_param="[null]" period3_date="[null]" period4_mode="[null]" period4_param="[null]" period4_date="[null]" period5_mode="[null]" period5_param="[null]" period5_date="[null]" id="3000" project_id="1000" parent_snapshot_id="[null]" root_project_id="1000" root_snapshot_id="[null]"
              scope="PRJ" qualifier="TRK" created_at="2008-11-01 13:58:00.00" build_date="2008-11-01 13:58:00.00" version="[null]" path=""
   <!-- new project -->
   <projects id="1001" scope="PRJ" qualifier="TRK" kee="foo" root_id="[null]"
             name="Foo" long_name="Foo" description="some description"
-            enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]" created_at="[null]"/>
+            enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" />
 
   <projects id="1002" scope="PRJ" qualifier="LIB" kee="junit:junit" root_id="[null]"
             name="junit:junit" long_name="junit:junit" description="[null]"
-            enabled="true" language="[null]" copy_resource_id="[null]" person_id="[null]" profile_id="[null]" created_at="[null]"/>
+            enabled="true" language="[null]" copy_resource_id="[null]" person_id="[null]" />
 
   <snapshots purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" period2_param="[null]" period2_date="[null]" period3_mode="[null]" period3_param="[null]" period3_date="[null]" period4_mode="[null]" period4_param="[null]" period4_date="[null]" period5_mode="[null]" period5_param="[null]" period5_date="[null]" id="3001" project_id="1001" parent_snapshot_id="[null]" root_project_id="1001" root_snapshot_id="[null]"
              scope="PRJ" qualifier="TRK" created_at="2010-12-25 00:00:00.00" build_date="2010-12-25 00:00:00.00" version="[null]" path=""
index 5e9999e6488ec80670a927a7b4d09d701a608e25..a36b177dafb6d8edd453ee7bbf911486e2fb535a 100644 (file)
@@ -3,7 +3,7 @@
   <!-- other project -->
   <projects id="1000" scope="PRJ" qualifier="TRK" kee="my:key" root_id="[null]"
             name="Other project" long_name="Other" description="[null]"
-            enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]" created_at="[null]"/>
+            enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" />
 
   <snapshots purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" period2_param="[null]" period2_date="[null]" period3_mode="[null]" period3_param="[null]" period3_date="[null]" period4_mode="[null]" period4_param="[null]" period4_date="[null]" period5_mode="[null]" period5_param="[null]" period5_date="[null]" id="3000" project_id="1000" parent_snapshot_id="[null]" root_project_id="1000" root_snapshot_id="[null]"
              scope="PRJ" qualifier="TRK" created_at="2008-11-01 13:58:00.00" build_date="2008-11-01 13:58:00.00" version="[null]" path=""
   <!-- new project -->
   <projects id="1001" scope="PRJ" qualifier="TRK" kee="root" root_id="[null]"
             name="Root" long_name="Root" description="[null]"
-            enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]" created_at="[null]"/>
+            enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" />
 
   <projects id="1002" scope="PRJ" qualifier="BRC" kee="a" root_id="1001"
             name="A" long_name="A" description="[null]"
-            enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]" created_at="[null]"/>
+            enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" />
 
   <projects id="1003" scope="PRJ" qualifier="BRC" kee="b" root_id="1001"
             name="B" long_name="B" description="[null]"
-            enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]" created_at="[null]"/>
+            enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" />
 
   <projects id="1004" scope="PRJ" qualifier="BRC" kee="b1" root_id="1001"
             name="B1" long_name="B1" description="[null]"
-            enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]" created_at="[null]"/>
+            enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" />
 
 
   <snapshots purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" period2_param="[null]" period2_date="[null]" period3_mode="[null]" period3_param="[null]" period3_date="[null]" period4_mode="[null]" period4_param="[null]" period4_date="[null]" period5_mode="[null]" period5_param="[null]" period5_date="[null]" id="3001" project_id="1001" root_project_id="1001" parent_snapshot_id="[null]"  root_snapshot_id="[null]"
index e78b1d113568897ef2bd49315de2750606639fdc..9f7c802b57efcf8fe760008b0ecb77d74c05690c 100644 (file)
@@ -3,7 +3,7 @@
   <!-- other project -->
   <projects id="1000" scope="PRJ" qualifier="TRK" kee="my:key" root_id="[null]"
             name="Other project" long_name="Other" description="[null]"
-            enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]" created_at="[null]"/>
+            enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" />
 
   <snapshots purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" period2_param="[null]" period2_date="[null]" period3_mode="[null]" period3_param="[null]" period3_date="[null]" period4_mode="[null]" period4_param="[null]" period4_date="[null]" period5_mode="[null]" period5_param="[null]" period5_date="[null]" id="3000" project_id="1000" parent_snapshot_id="[null]" root_project_id="1000" root_snapshot_id="[null]"
              scope="PRJ" qualifier="TRK" created_at="2008-11-01 13:58:00.00" build_date="2008-11-01 13:58:00.00" version="[null]" path=""
@@ -13,7 +13,7 @@
   <!-- new project -->
   <projects id="1001" scope="PRJ" qualifier="TRK" kee="foo" root_id="[null]"
             name="Foo" long_name="Foo" description="some description"
-            enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]" created_at="[null]"/>
+            enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" />
 
   <snapshots purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" period2_param="[null]" period2_date="[null]" period3_mode="[null]" period3_param="[null]" period3_date="[null]" period4_mode="[null]" period4_param="[null]" period4_date="[null]" period5_mode="[null]" period5_param="[null]" period5_date="[null]" id="3001" project_id="1001" parent_snapshot_id="[null]" root_project_id="1001" root_snapshot_id="[null]"
              scope="PRJ" qualifier="TRK" created_at="2010-12-25 00:00:00.00" build_date="2010-12-25 00:00:00.00" version="[null]" path=""
index 4114dac7b8e13969700761596a84b03fb411e2fc..4fe4bcf5894f62f27fc71c624297150c76e42d2c 100644 (file)
@@ -2,7 +2,7 @@
 
   <projects id="1001" scope="PRJ" qualifier="TRK" kee="foo" root_id="[null]"
             name="new name" long_name="new name" description="new description"
-            enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]" created_at="[null]"/>
+            enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" />
 
   <!-- old snapshot -->
   <snapshots purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" period2_param="[null]" period2_date="[null]" period3_mode="[null]" period3_param="[null]" period3_date="[null]" period4_mode="[null]" period4_param="[null]" period4_date="[null]" period5_mode="[null]" period5_param="[null]" period5_date="[null]" id="3001" project_id="1001" parent_snapshot_id="[null]" root_project_id="1001" root_snapshot_id="[null]"
index 95efadf881b3101723ebfa4641c1ec910ddaf72e..23570debd77fe68aafd5e5a790d5907fb1c0984a 100644 (file)
@@ -2,7 +2,7 @@
 
   <projects id="1001" scope="PRJ" qualifier="TRK" kee="foo" root_id="[null]"
             name="old name" long_name="old name" description="old description"
-            enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]" created_at="[null]"/>
+            enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" />
 
   <snapshots purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" period2_param="[null]" period2_date="[null]" period3_mode="[null]" period3_param="[null]" period3_date="[null]" period4_mode="[null]" period4_param="[null]" period4_date="[null]" period5_mode="[null]" period5_param="[null]" period5_date="[null]" id="3001" project_id="1001" parent_snapshot_id="[null]" root_project_id="1001" root_snapshot_id="[null]"
              scope="PRJ" qualifier="TRK" created_at="2010-12-23 00:00:00.00" build_date="2010-12-23 00:00:00.00" version="[null]" path=""
index 9bfe3ded05dde3c6beb1b0b3f381251bc2355210..f20f89769d84fa11a92b424886a30d4f6530532f 100644 (file)
@@ -2,7 +2,7 @@
 
   <projects id="200" scope="FIL" qualifier="CLA" kee="project:org.foo.Bar" root_id="[null]"
             name="Bar" long_name="org.foo.Bar" description="[null]"
-            enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]"/>
+            enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" />
 
   <snapshots purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" period2_param="[null]" period2_date="[null]" period3_mode="[null]" period3_param="[null]" period3_date="[null]" period4_mode="[null]" period4_param="[null]" period4_date="[null]" period5_mode="[null]" period5_param="[null]" period5_date="[null]" id="1000" project_id="200" parent_snapshot_id="[null]" root_project_id="100" root_snapshot_id="[null]"
              scope="FIL" qualifier="CLA" created_at="2008-11-01 13:58:00.00" build_date="2008-11-01 13:58:00.00" version="[null]" path=""
index 8bc81a76ad27a3e247060534d2f9c752fbc4f74d..d1e1a8dc456050c6e4cb5941cdfaf7695cf6e7cf 100644 (file)
@@ -2,7 +2,7 @@
 
   <projects id="200" scope="FIL" qualifier="CLA" kee="project:org.foo.Bar" root_id="[null]"
             name="Bar" long_name="org.foo.Bar" description="[null]"
-            enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]"/>
+            enabled="true" language="java" copy_resource_id="[null]" person_id="[null]" />
 
   <snapshots purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" period2_param="[null]" period2_date="[null]" period3_mode="[null]" period3_param="[null]" period3_date="[null]" period4_mode="[null]" period4_param="[null]" period4_date="[null]" period5_mode="[null]" period5_param="[null]" period5_date="[null]" id="1000" project_id="200" parent_snapshot_id="[null]" root_project_id="100" root_snapshot_id="[null]"
              scope="FIL" qualifier="CLA" created_at="2008-11-01 13:58:00.00" build_date="2008-11-01 13:58:00.00" version="[null]" path=""
index 8aa94e8d2a549e71e78532b54b9da528f8057f41..754d5e973b67bf5901a79186cdd81be4aa7d4cf1 100644 (file)
@@ -35,7 +35,7 @@ import java.util.List;
  */
 public class DatabaseVersion implements BatchComponent, ServerComponent {
 
-  public static final int LAST_VERSION = 330;
+  public static final int LAST_VERSION = 331;
 
   public static enum Status {
     UP_TO_DATE, REQUIRES_UPGRADE, REQUIRES_DOWNGRADE, FRESH_INSTALL
index 73ee680a5d4d3d4723b4b474b1e6143fd51ee813..a9edcb4ed195887fad91cd71b7fafcc4016c1f94 100644 (file)
@@ -35,7 +35,6 @@ public final class ResourceDto {
   private String language;
   private Long copyResourceId;
   private Long personId;
-  private Long profileId;
   private Date createdAt;
 
   public Long getId() {
@@ -146,15 +145,6 @@ public final class ResourceDto {
     return this;
   }
 
-  public Long getProfileId() {
-    return profileId;
-  }
-
-  public ResourceDto setProfileId(Long profileId) {
-    this.profileId = profileId;
-    return this;
-  }
-
   public Date getCreatedAt() {
     return createdAt;// NOSONAR May expose internal representation by returning reference to mutable object
   }
index 3721c2560dc627523ad25cacb7732cd8a7aaec70..40ab93b9cbec9e2ee3707baa9ea26b5f91eb24ea 100644 (file)
@@ -20,7 +20,6 @@
 package org.sonar.jpa.dao;
 
 import org.sonar.api.database.DatabaseSession;
-import org.sonar.api.database.model.ResourceModel;
 import org.sonar.api.profiles.RulesProfile;
 
 public class ProfilesDao extends BaseDao {
@@ -29,16 +28,12 @@ public class ProfilesDao extends BaseDao {
     super(session);
   }
 
-  public RulesProfile getActiveProfile(String languageKey, String projectResourceKey) {
-    ResourceModel projectResource = getSession().getSingleResult(ResourceModel.class, "key", projectResourceKey, "scope", ResourceModel.SCOPE_PROJECT);
-    if (projectResource != null && projectResource.getRulesProfile() != null && projectResource.getRulesProfile().isEnabled()) {
-      return projectResource.getRulesProfile();
-    }
-    return getSession().getSingleResult(RulesProfile.class, "defaultProfile", true, "language", languageKey, "enabled", true);
+  public RulesProfile getDefaultProfile(String languageKey) {
+    return getSession().getSingleResult(RulesProfile.class, "defaultProfile", true, "language", languageKey);
   }
 
   public RulesProfile getProfile(String languageKey, String profileName) {
-    return getSession().getSingleResult(RulesProfile.class, "language", languageKey, "name", profileName, "enabled", true);
+    return getSession().getSingleResult(RulesProfile.class, "language", languageKey, "name", profileName);
   }
 
 }
index 9b7211d2862b3b008e084ae3e24eab31dfd84cf1..05b077452b23061e48cc448cc119903751e24263 100644 (file)
@@ -172,6 +172,7 @@ INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('306');
 INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('320');
 INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('321');
 INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('330');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('331');
 
 INSERT INTO USERS(ID, LOGIN, NAME, EMAIL, CRYPTED_PASSWORD, SALT, CREATED_AT, UPDATED_AT, REMEMBER_TOKEN, REMEMBER_TOKEN_EXPIRES_AT) VALUES (1, 'admin', 'Administrator', '', 'a373a0e667abb2604c1fd571eb4ad47fe8cc0878', '48bc4b0d93179b5103fd3885ea9119498e9d161b', '2011-09-26 22:27:48.0', '2011-09-26 22:27:48.0', null, null);
 ALTER TABLE USERS ALTER COLUMN ID RESTART WITH 2;
index a66ee4b5f0f3abcfd0785c5278c1ae7660b351e5..53e322fc4494e586059f56f751e9019340ca7434 100644 (file)
@@ -293,7 +293,6 @@ CREATE TABLE "PROJECTS" (
   "QUALIFIER" VARCHAR(10),
   "KEE" VARCHAR(400),
   "ROOT_ID" INTEGER,
-  "PROFILE_ID" INTEGER,
   "LANGUAGE" VARCHAR(5),
   "COPY_RESOURCE_ID" INTEGER,
   "LONG_NAME" VARCHAR(256),
index 1d51aff6cc66f57019c178b27a486eee47b74654..e35451c4f6eb73526d5280b06f729381023cf1f6 100644 (file)
@@ -34,7 +34,6 @@
     <result property="language" column="language"/>
     <result property="copyResourceId" column="copy_resource_id"/>
     <result property="personId" column="person_id"/>
-    <result property="profileId" column="profile_id"/>
     <result property="createdAt" column="created_at"/>
   </resultMap>
 
 
   <insert id="insert" parameterType="Resource" useGeneratedKeys="true" keyProperty="id">
     insert into projects
-    (name, long_name, description, scope, qualifier, kee, language, root_id, copy_resource_id, person_id, profile_id, enabled, created_at)
+    (name, long_name, description, scope, qualifier, kee, language, root_id, copy_resource_id, person_id, enabled, created_at)
     values (
     #{name}, #{longName}, #{description}, #{scope}, #{qualifier},
     #{key}, #{language}, #{rootId}, #{copyResourceId},
-    #{personId}, #{profileId}, #{enabled}, #{createdAt}
+    #{personId}, #{enabled}, #{createdAt}
     )
   </insert>
 
       select projects_seq.NEXTVAL from DUAL
     </selectKey>
     insert into projects
-    (id, name, long_name, description, scope, qualifier, kee, language, root_id, copy_resource_id, person_id, profile_id, enabled, created_at)
+    (id, name, long_name, description, scope, qualifier, kee, language, root_id, copy_resource_id, person_id, enabled, created_at)
     values (
     #{id}, #{name}, #{longName}, #{description}, #{scope}, #{qualifier},
     #{key}, #{language}, #{rootId}, #{copyResourceId},
-    #{personId}, #{profileId}, #{enabled}, #{createdAt}
+    #{personId}, #{enabled}, #{createdAt}
     )
   </insert>
 
     update projects set name=#{name}, long_name=#{longName}, description=#{description},
     scope=#{scope}, qualifier=#{qualifier}, kee=#{key},
     language=#{language}, root_id=#{rootId}, copy_resource_id=#{copyResourceId},
-    person_id=#{personId}, profile_id=#{profileId}, enabled=#{enabled} where id=#{id}
+    person_id=#{personId}, enabled=#{enabled} where id=#{id}
   </update>
 </mapper>
 
index 0ab2cf17506f0f0244d9be26201f1d89bfe3c30f..01f7310fca066d5a81344c84081fa89ccea2ef5a 100644 (file)
@@ -21,12 +21,10 @@ package org.sonar.jpa.dao;
 
 import org.junit.Before;
 import org.junit.Test;
-import org.sonar.api.database.model.ResourceModel;
 import org.sonar.api.profiles.RulesProfile;
 import org.sonar.jpa.test.AbstractDbUnitTestCase;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
+import static org.fest.assertions.Assertions.assertThat;
 
 public class ProfilesDaoTest extends AbstractDbUnitTestCase {
 
@@ -37,22 +35,24 @@ public class ProfilesDaoTest extends AbstractDbUnitTestCase {
     profilesDao = new ProfilesDao(getSession());
   }
 
+  @Test
+  public void should_get_profile_by_name() {
+    RulesProfile profile = RulesProfile.create("my profile", "java");
+    getSession().save(profile);
+
+    assertThat(profilesDao.getProfile("unknown language", "my profile")).isNull();
+    assertThat(profilesDao.getProfile("java", "my profile").getName()).isEqualTo("my profile");
+  }
 
   @Test
-  public void testGetActiveProfile() {
-    RulesProfile testDefaultProfile = new RulesProfile("default", "java", true, true);
-    RulesProfile testProfile = new RulesProfile("not default", "java", false, false);
-    getSession().save(testDefaultProfile, testProfile);
-
-    ResourceModel testResourceWithProfile = new ResourceModel(ResourceModel.SCOPE_PROJECT, "withProfile", "TRK", null, "test");
-    testResourceWithProfile.setRulesProfile(testProfile);
-    ResourceModel testResourceWithNoProfile = new ResourceModel(ResourceModel.SCOPE_PROJECT, "withoutProfile", "TRK", null, "test");
-    getSession().save(testResourceWithProfile, testResourceWithNoProfile);
-
-    assertNull(profilesDao.getActiveProfile("wrongLanguage", "withoutProfile"));
-    assertEquals(testDefaultProfile.getId(), profilesDao.getActiveProfile("java", "wrongKey").getId());
-    assertEquals(testDefaultProfile.getId(), profilesDao.getActiveProfile("java", "withoutProfile").getId());
-    assertEquals(testProfile.getId(), profilesDao.getActiveProfile("java", "withProfile").getId());
+  public void should_get_default_profile() {
+    RulesProfile defaultProfile = RulesProfile.create("default profile", "java");
+    defaultProfile.setDefaultProfile(true);
+    RulesProfile otherProfile = RulesProfile.create("other profile", "java");
+    otherProfile.setDefaultProfile(false);
+    getSession().save(defaultProfile, otherProfile);
+
+    assertThat(profilesDao.getDefaultProfile("java").getName()).isEqualTo("default profile");
   }
 
 }
index d9fe0172ed6d6982df190640742af7583337f7eb..ff3b37a56eac269856cd42d5a2d3c39b53ff73f4 100644 (file)
@@ -2,7 +2,7 @@
 
   <projects id="1" enabled="[true]" root_id="[null]"
             long_name="[null]" scope="PRJ" qualifier="TRK" kee="project" name="project"
-            description="[null]" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]"/>
+            description="[null]" language="java" copy_resource_id="[null]" person_id="[null]" />
 
   <snapshots id="1" project_id="1" parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]"
              status="P" islast="[false]" purge_status="[null]"
index 7f21ab01f6ecccf971528631b413e05560b3cf04..4e982e4dc12bf5260445ca98d890b5f054d35062 100644 (file)
@@ -8,7 +8,7 @@ Snapshot 2 has been deleted
   <!-- the project -->
   <projects id="1" enabled="[true]" root_id="[null]"
             long_name="[null]" scope="PRJ" qualifier="TRK" kee="project" name="project"
-            description="[null]" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]"/>
+            description="[null]" language="java" copy_resource_id="[null]" person_id="[null]" />
 
   <!-- past snapshot with status "processed" and already purged -->
   <snapshots id="1"
index da6f52837c7ffa3c82626023b01b247b86d12053..34716adee47b4688b82dde814cb7ad47077a5a71 100644 (file)
@@ -3,7 +3,7 @@
   <!-- the project -->
   <projects id="1" enabled="[true]" root_id="[null]"
             long_name="[null]" scope="PRJ" qualifier="TRK" kee="project" name="project"
-            description="[null]" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]"/>
+            description="[null]" language="java" copy_resource_id="[null]" person_id="[null]" />
 
   <!-- past snapshot with status "processed" and already purged -->
   <snapshots id="1"
index 5a659ed2b1477af02ce35e38ad900dda7f19ea78..83f1ff3676ed0b16de6e5277ddf5e4731a1ea7b7 100644 (file)
@@ -9,17 +9,17 @@ What has been changed : purge_status=1 on snapshot 4 (PRJ) and snapshots 5 and 6
   <!-- the project -->
   <projects id="1" enabled="[true]" root_id="[null]" created_at="[null]"
             long_name="[null]" scope="PRJ" qualifier="TRK" kee="project" name="project"
-            description="[null]" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]"/>
+            description="[null]" language="java" copy_resource_id="[null]" person_id="[null]" />
 
   <!-- the directory -->
   <projects id="2" enabled="[true]" root_id="1" created_at="[null]"
             long_name="[null]" scope="DIR" qualifier="DIR" kee="project:my/dir" name="my/dir"
-            description="[null]" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]"/>
+            description="[null]" language="java" copy_resource_id="[null]" person_id="[null]" />
 
   <!-- the file -->
   <projects id="3" enabled="[true]" root_id="1" created_at="[null]"
             long_name="[null]" scope="FIL" qualifier="FIL" kee="project:my/dir/File.java" name="my/dir/File.java"
-            description="[null]" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]"/>
+            description="[null]" language="java" copy_resource_id="[null]" person_id="[null]" />
 
   <!-- do not purge last snapshots -->
   <snapshots id="1"
index 49f63da1e7f80f660dd6358687ddc1aeaf24ed07..a3445a40a64c2eab8cd57967a01f2389f395a066 100644 (file)
@@ -3,17 +3,17 @@
   <!-- the project -->
   <projects id="1" enabled="[true]" root_id="[null]" created_at="[null]"
             long_name="[null]" scope="PRJ" qualifier="TRK" kee="project" name="project"
-            description="[null]" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]"/>
+            description="[null]" language="java" copy_resource_id="[null]" person_id="[null]" />
 
   <!-- the directory -->
   <projects id="2" enabled="[true]" root_id="1" created_at="[null]"
             long_name="[null]" scope="DIR" qualifier="DIR" kee="project:my/dir" name="my/dir"
-            description="[null]" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]"/>
+            description="[null]" language="java" copy_resource_id="[null]" person_id="[null]" />
 
   <!-- the file -->
   <projects id="3" enabled="[true]" root_id="1" created_at="[null]"
             long_name="[null]" scope="FIL" qualifier="FIL" kee="project:my/dir/File.java" name="my/dir/File.java"
-            description="[null]" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]"/>
+            description="[null]" language="java" copy_resource_id="[null]" person_id="[null]" />
 
   <!-- do not purge last snapshots -->
   <snapshots id="1"
index 66d6efd5e73ae1079bd53e8a06720727ffd3e162..8888c64bb0fcea9f7bff68221109178f73ac1116 100644 (file)
@@ -3,7 +3,7 @@
   <!-- root -->
   <projects id="1" enabled="[true]" root_id="[null]"
             long_name="[null]" scope="PRJ" qualifier="TRK" kee="project" name="project"
-            description="[null]" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]"/>
+            description="[null]" language="java" copy_resource_id="[null]" person_id="[null]" />
 
   <snapshots id="1" project_id="1" parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]"
              status="P" islast="[false]" purge_status="[null]"
@@ -34,7 +34,7 @@
   <!-- modules -->
   <projects id="2" enabled="[true]" root_id="1"
             long_name="[null]" scope="PRJ" qualifier="BRC" kee="module1" name="module1"
-            description="[null]" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]"/>
+            description="[null]" language="java" copy_resource_id="[null]" person_id="[null]" />
 
   <snapshots id="2" project_id="2" parent_snapshot_id="1" root_project_id="1" root_snapshot_id="1"
              status="P" islast="[false]" purge_status="[null]"
@@ -50,7 +50,7 @@
 
   <projects id="3" enabled="[false]" root_id="1"
             long_name="[null]" scope="PRJ" qualifier="BRC" kee="module2" name="module2"
-            description="[null]" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]"/>
+            description="[null]" language="java" copy_resource_id="[null]" person_id="[null]" />
 
   <snapshots id="3" project_id="3" parent_snapshot_id="1" root_project_id="1" root_snapshot_id="1"
              status="P" islast="[true]" purge_status="[null]"
@@ -66,7 +66,7 @@
   <!-- file of module 2-->
   <projects id="4" enabled="[false]" root_id="3"
             long_name="[null]" scope="FIL" qualifier="FIL" kee="module2:File.java" name="File"
-            description="[null]" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]"/>
+            description="[null]" language="java" copy_resource_id="[null]" person_id="[null]" />
 
   <snapshots id="4" project_id="4" parent_snapshot_id="3" root_project_id="1" root_snapshot_id="1"
              status="P" islast="[true]" purge_status="[null]"
index b14e00595da1de54c622675385168cd09c863f9e..96c616fb46f646b56b2b6ad993731d697453ab5c 100644 (file)
@@ -10,17 +10,17 @@ What has been changed :
   <!-- the project -->
   <projects id="1" enabled="[false]" root_id="[null]" created_at="[null]"
             long_name="[null]" scope="PRJ" qualifier="TRK" kee="project" name="project"
-            description="[null]" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]"/>
+            description="[null]" language="java" copy_resource_id="[null]" person_id="[null]" />
 
   <!-- the directory -->
   <projects id="2" enabled="[false]" root_id="1" created_at="[null]"
             long_name="[null]" scope="DIR" qualifier="DIR" kee="project:my/dir" name="my/dir"
-            description="[null]" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]"/>
+            description="[null]" language="java" copy_resource_id="[null]" person_id="[null]" />
 
   <!-- the file -->
   <projects id="3" enabled="[false]" root_id="1" created_at="[null]"
             long_name="[null]" scope="FIL" qualifier="FIL" kee="project:my/dir/File.java" name="my/dir/File.java"
-            description="[null]" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]"/>
+            description="[null]" language="java" copy_resource_id="[null]" person_id="[null]" />
 
   <snapshots id="1"
              project_id="1" parent_snapshot_id="[null]" root_project_id="1" root_snapshot_id="[null]"
index 05bb41f18f6500b3cb53edf711d77b2c4b137ae1..b943a8f0ea6a586e1ad79a9fd04a557c58ad71ae 100644 (file)
@@ -3,17 +3,17 @@
   <!-- the project -->
   <projects id="1" enabled="[true]" root_id="[null]" created_at="[null]"
             long_name="[null]" scope="PRJ" qualifier="TRK" kee="project" name="project"
-            description="[null]" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]"/>
+            description="[null]" language="java" copy_resource_id="[null]" person_id="[null]" />
 
   <!-- the directory -->
   <projects id="2" enabled="[true]" root_id="1" created_at="[null]"
             long_name="[null]" scope="DIR" qualifier="DIR" kee="project:my/dir" name="my/dir"
-            description="[null]" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]"/>
+            description="[null]" language="java" copy_resource_id="[null]" person_id="[null]" />
 
   <!-- the file -->
   <projects id="3" enabled="[true]" root_id="1" created_at="[null]"
             long_name="[null]" scope="FIL" qualifier="FIL" kee="project:my/dir/File.java" name="my/dir/File.java"
-            description="[null]" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]"/>
+            description="[null]" language="java" copy_resource_id="[null]" person_id="[null]" />
 
   <snapshots id="1"
              project_id="1" parent_snapshot_id="[null]" root_project_id="1" root_snapshot_id="[null]"
index 0adc84368f7d9cfc76015d9e72ad919cd14cf143..d80268aff4e984a2aaf89b254a1592c1fdb3ca8c 100644 (file)
@@ -3,7 +3,7 @@
   <!-- the project -->
   <projects id="1" enabled="[true]" created_at="[null]"
             long_name="[null]" scope="PRJ" qualifier="TRK" kee="project" name="project"
-            root_id="[null]" description="[null]" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]"/>
+            root_id="[null]" description="[null]" language="java" copy_resource_id="[null]" person_id="[null]" />
 
 
   <!-- snapshot already purged -->
index a38c88faa59c88021a624723d9e7a5bc08d9c9e4..23490655cbed0cca1cc41792cc670c55bf7f36aa 100644 (file)
@@ -3,7 +3,7 @@
   <!-- the project -->
   <projects id="1" enabled="[true]" created_at="[null]"
             long_name="[null]" scope="PRJ" qualifier="TRK" kee="project" name="project"
-            root_id="[null]" description="[null]" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]"/>
+            root_id="[null]" description="[null]" language="java" copy_resource_id="[null]" person_id="[null]" />
 
 
   <!-- snapshot already purged -->
index 0b7b932505620de3fc9e87650d9a04281e7f0295..27016ad3471555274d68fbeb683ee3906335e5c6 100644 (file)
@@ -2,10 +2,10 @@
 
   <projects id="1" root_id="[null]" scope="FIL" qualifier="FIL" kee="org.struts:struts:org.struts.Action" name="Action"
             description="[null]" long_name="org.struts.Action"
-            enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]" created_at="[null]"/>
+            enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]" />
 
   <projects id="2" root_id="[null]" scope="FIL" qualifier="FIL" kee="org.struts:struts:org.struts.Filter" name="Filter"
             description="[null]" long_name="org.struts.Filter"
-            enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]" created_at="[null]"/>
+            enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]" />
 
 </dataset>
index 05ef16cbee515f0509854cd3a00adb97e15c50af..4a59dd793f1dbca42c5cb609afc5945d4181fcb5 100644 (file)
@@ -2,6 +2,6 @@
 
   <projects id="1" root_id="[null]" scope="PRJ" qualifier="TRK" kee="org.struts:struts" name="Struts"
             description="MVC Framework" long_name="Apache Struts"
-            enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]" created_at="[null]"/>
+            enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/>
 
 </dataset>
index 74ff92ef7437c6ccf10477fb5bec451f4eb92a30..dcd5ae6480bd52d1606462a1972e1b646fab9b09 100644 (file)
@@ -2,6 +2,6 @@
 
   <projects id="1" root_id="200" scope="PRJ" qualifier="TRK" kee="old key" name="old name"
             description="old name" long_name="old long name"
-            enabled="[false]" language="old" copy_resource_id="2" person_id="3" profile_id="4" created_at="[null]"/>
+            enabled="[false]" language="old" copy_resource_id="2" person_id="3" created_at="[null]"/>
 
 </dataset>
index dff49673540baff37894465587802cc0e2ad1a08..4613c167d3185f200073f538d1311778fad0e5ec 100644 (file)
@@ -2,49 +2,49 @@
 
   <!-- root project -->
   <projects id="1" root_id="[null]" scope="PRJ" qualifier="TRK" kee="org.struts:struts" name="Struts"
-            description="[null]" long_name="Apache Struts" profile_id="1"
+            description="[null]" long_name="Apache Struts"
             enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/>
 
 
   <!-- **************** First sub project **************** -->
   <projects id="2" root_id="1" kee="org.struts:struts-core" name="Struts Core"
-            scope="PRJ" qualifier="BRC" long_name="Struts Core" profile_id="1"
+            scope="PRJ" qualifier="BRC" long_name="Struts Core"
             description="[null]" enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/>
 
   <!-- directory -->
   <projects long_name="org.struts" id="3" scope="DIR" qualifier="PAC" kee="org.struts:struts-core:org.struts"
               name="org.struts" root_id="2"
-              description="[null]" profile_id="1"
+              description="[null]"
               enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/>
 
   <!-- file -->
   <projects long_name="org.struts.RequestContext" id="4" scope="FIL" qualifier="CLA" kee="org.struts:struts-core:org.struts.RequestContext"
             name="RequestContext" root_id="2"
-            description="[null]" profile_id="1"
+            description="[null]"
             enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/>
 
 
   <!-- **************** Second sub project **************** -->
   <projects id="5" root_id="1" kee="org.struts:struts-ui" name="Struts UI"
-            scope="PRJ" qualifier="BRC" long_name="Struts UI" profile_id="1"
+            scope="PRJ" qualifier="BRC" long_name="Struts UI"
             description="[null]" enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/>
 
   <!-- directory -->
   <projects long_name="org.struts" id="6" scope="DIR" qualifier="PAC" kee="org.struts:struts-ui:org.struts"
               name="org.struts" root_id="5"
-              description="[null]" profile_id="1"
+              description="[null]"
               enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/>
 
   <!-- file -->
   <projects long_name="org.struts.RequestContext" id="7" scope="FIL" qualifier="CLA" kee="org.struts:struts-ui:org.struts.RequestContext"
             name="RequestContext" root_id="5"
-            description="[null]" profile_id="1"
+            description="[null]"
             enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/>
 
 
   <!-- **************** Another independent project **************** -->
   <projects id="8" root_id="[null]" kee="foo:struts-core" name="Foo Struts Core"
-            scope="PRJ" qualifier="BRC" long_name="Foo Struts Core" profile_id="1"
+            scope="PRJ" qualifier="BRC" long_name="Foo Struts Core"
             description="[null]" enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/>
 
 </dataset>
index a4b3fdd195e01090adc2fc562cb802606998def1..b9fc934e5465a6d89a51994f057e5cd8609146ad 100644 (file)
@@ -2,49 +2,49 @@
 
   <!-- root project -->
   <projects id="1" root_id="[null]" scope="PRJ" qualifier="TRK" kee="org.apache.struts:struts" name="Struts"
-            description="[null]" long_name="Apache Struts" profile_id="1"
-            enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]" />
+            description="[null]" long_name="Apache Struts"
+            enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/>
 
 
   <!-- **************** First sub project **************** -->
   <projects id="2" root_id="1" kee="org.apache.struts:struts-core" name="Struts Core"
-            scope="PRJ" qualifier="BRC" long_name="Struts Core" profile_id="1"
-            description="[null]" enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]" />
+            scope="PRJ" qualifier="BRC" long_name="Struts Core"
+            description="[null]" enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/>
 
   <!-- directory -->
   <projects long_name="org.struts" id="3" scope="DIR" qualifier="PAC" kee="org.apache.struts:struts-core:org.struts"
               name="org.struts" root_id="2"
-              description="[null]" profile_id="1"
-              enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]" />
+              description="[null]"
+              enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/>
 
   <!-- file -->
   <projects long_name="org.struts.RequestContext" id="4" scope="FIL" qualifier="CLA" kee="org.apache.struts:struts-core:org.struts.RequestContext"
             name="RequestContext" root_id="2"
-            description="[null]" profile_id="1"
-            enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]" />
+            description="[null]"
+            enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/>
 
 
   <!-- **************** Second sub project **************** -->
   <projects id="5" root_id="1" kee="org.apache.struts:struts-ui" name="Struts UI"
-            scope="PRJ" qualifier="BRC" long_name="Struts UI" profile_id="1"
-            description="[null]" enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]" />
+            scope="PRJ" qualifier="BRC" long_name="Struts UI"
+            description="[null]" enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/>
 
   <!-- directory -->
   <projects long_name="org.struts" id="6" scope="DIR" qualifier="PAC" kee="org.apache.struts:struts-ui:org.struts"
               name="org.struts" root_id="5"
-              description="[null]" profile_id="1"
-              enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]" />
+              description="[null]"
+              enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/>
 
   <!-- file -->
   <projects long_name="org.struts.RequestContext" id="7" scope="FIL" qualifier="CLA" kee="org.apache.struts:struts-ui:org.struts.RequestContext"
             name="RequestContext" root_id="5"
-            description="[null]" profile_id="1"
-            enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]" />
+            description="[null]"
+            enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/>
 
 
   <!-- **************** Another independent project **************** -->
   <projects id="8" root_id="[null]" kee="foo:struts-core" name="Foo Struts Core"
-            scope="PRJ" qualifier="BRC" long_name="Foo Struts Core" profile_id="1"
-            description="[null]" enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]" />
+            scope="PRJ" qualifier="BRC" long_name="Foo Struts Core"
+            description="[null]" enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/>
 
 </dataset>
index 40bb3ed144df5abfb3aff28a8ffe1a493852c706..71ed68a61aeaf8f2b642a0069e6da805dc1e4b6b 100644 (file)
@@ -2,49 +2,49 @@
 
   <!-- root project -->
   <projects id="1" root_id="[null]" scope="PRJ" qualifier="TRK" kee="org.struts:struts" name="Struts"
-            description="[null]" long_name="Apache Struts" profile_id="1"
-            enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]" />
+            description="[null]" long_name="Apache Struts"
+            enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/>
 
 
   <!-- **************** First sub project **************** -->
   <projects id="2" root_id="1" kee="org.struts:struts-core" name="Struts Core"
-            scope="PRJ" qualifier="BRC" long_name="Struts Core" profile_id="1"
-            description="[null]" enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]" />
+            scope="PRJ" qualifier="BRC" long_name="Struts Core"
+            description="[null]" enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/>
 
   <!-- directory -->
   <projects long_name="org.struts" id="3" scope="DIR" qualifier="PAC" kee="org.struts:struts-core:org.struts"
               name="org.struts" root_id="2"
-              description="[null]" profile_id="1"
-              enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]" />
+              description="[null]"
+              enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/>
 
   <!-- file -->
   <projects long_name="org.struts.RequestContext" id="4" scope="FIL" qualifier="CLA" kee="org.struts:struts-core:org.struts.RequestContext"
             name="RequestContext" root_id="2"
-            description="[null]" profile_id="1"
-            enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]" />
+            description="[null]"
+            enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/>
 
 
   <!-- **************** Second sub project **************** -->
   <projects id="5" root_id="1" kee="org.struts:struts-web" name="Struts UI"
-            scope="PRJ" qualifier="BRC" long_name="Struts UI" profile_id="1"
-            description="[null]" enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]" />
+            scope="PRJ" qualifier="BRC" long_name="Struts UI"
+            description="[null]" enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/>
 
   <!-- directory -->
   <projects long_name="org.struts" id="6" scope="DIR" qualifier="PAC" kee="org.struts:struts-web:org.struts"
               name="org.struts" root_id="5"
-              description="[null]" profile_id="1"
-              enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]" />
+              description="[null]"
+              enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/>
 
   <!-- file -->
   <projects long_name="org.struts.RequestContext" id="7" scope="FIL" qualifier="CLA" kee="org.struts:struts-web:org.struts.RequestContext"
             name="RequestContext" root_id="5"
-            description="[null]" profile_id="1"
-            enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]" />
+            description="[null]"
+            enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/>
 
 
   <!-- **************** Another independent project **************** -->
   <projects id="8" root_id="[null]" kee="foo:struts-core" name="Foo Struts Core"
-            scope="PRJ" qualifier="BRC" long_name="Foo Struts Core" profile_id="1"
-            description="[null]" enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]" />
+            scope="PRJ" qualifier="BRC" long_name="Foo Struts Core"
+            description="[null]" enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/>
 
 </dataset>
index 6ebe224cfaf91039fd4db7f947bf005e59cef45c..54bf43d58021be6d210af471779de0a72b7e5ece 100644 (file)
@@ -2,43 +2,43 @@
 
   <!-- root project -->
   <projects id="1" root_id="[null]" scope="PRJ" qualifier="TRK" kee="org.apache.struts:struts" name="Struts"
-            description="[null]" long_name="Apache Struts" profile_id="1"
-            enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]" />
+            description="[null]" long_name="Apache Struts" 
+            enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/>
 
 
   <!-- **************** First sub project **************** -->
   <projects id="2" root_id="1" kee="org.apache.struts:struts-core" name="Struts Core"
-            scope="PRJ" qualifier="BRC" long_name="Struts Core" profile_id="1"
-            description="[null]" enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]" />
+            scope="PRJ" qualifier="BRC" long_name="Struts Core" 
+            description="[null]" enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/>
 
   <!-- directory -->
   <projects long_name="org.struts" id="3" scope="DIR" qualifier="PAC" kee="org.apache.struts:struts-core:org.struts"
               name="org.struts" root_id="2"
-              description="[null]" profile_id="1"
-              enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]" />
+              description="[null]" 
+              enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/>
 
   <!-- file -->
   <projects long_name="org.struts.RequestContext" id="4" scope="FIL" qualifier="CLA" kee="org.apache.struts:struts-core:org.struts.RequestContext"
             name="RequestContext" root_id="2"
-            description="[null]" profile_id="1"
-            enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]" />
+            description="[null]" 
+            enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/>
 
 
   <!-- **************** Second sub project THAT HAS A DIFFERENT GROUP ID => MUST NOT BE UPDATED **************** -->
   <projects id="5" root_id="1" kee="foo:struts-ui" name="Struts UI"
-            scope="PRJ" qualifier="BRC" long_name="Struts UI" profile_id="1"
-            description="[null]" enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]" />
+            scope="PRJ" qualifier="BRC" long_name="Struts UI" 
+            description="[null]" enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/>
 
   <!-- directory -->
   <projects long_name="org.struts" id="6" scope="DIR" qualifier="PAC" kee="foo:struts-ui:org.struts"
               name="org.struts" root_id="5"
-              description="[null]" profile_id="1"
-              enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]" />
+              description="[null]" 
+              enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/>
 
   <!-- file -->
   <projects long_name="org.struts.RequestContext" id="7" scope="FIL" qualifier="CLA" kee="foo:struts-ui:org.struts.RequestContext"
             name="RequestContext" root_id="5"
-            description="[null]" profile_id="1"
-            enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]" />
+            description="[null]" 
+            enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/>
 
 </dataset>
index 1b33265baeb69c34904705b2d6d0a534f9c1911b..93f747e9d72c87fe38653469b8a51dc1ab89a7a1 100644 (file)
@@ -2,43 +2,43 @@
 
   <!-- root project -->
   <projects id="1" root_id="[null]" scope="PRJ" qualifier="TRK" kee="org.struts:struts" name="Struts"
-            description="[null]" long_name="Apache Struts" profile_id="1"
-            enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]"/>
+            description="[null]" long_name="Apache Struts" 
+            enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/>
 
 
   <!-- **************** First sub project **************** -->
   <projects id="2" root_id="1" kee="org.struts:struts-core" name="Struts Core"
-            scope="PRJ" qualifier="BRC" long_name="Struts Core" profile_id="1"
-            description="[null]" enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]"/>
+            scope="PRJ" qualifier="BRC" long_name="Struts Core" 
+            description="[null]" enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/>
 
   <!-- directory -->
   <projects long_name="org.struts" id="3" scope="DIR" qualifier="PAC" kee="org.struts:struts-core:org.struts"
               name="org.struts" root_id="2"
-              description="[null]" profile_id="1"
-              enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]"/>
+              description="[null]" 
+              enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/>
 
   <!-- file -->
   <projects long_name="org.struts.RequestContext" id="4" scope="FIL" qualifier="CLA" kee="org.struts:struts-core:org.struts.RequestContext"
             name="RequestContext" root_id="2"
-            description="[null]" profile_id="1"
-            enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]"/>
+            description="[null]" 
+            enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/>
 
 
   <!-- **************** Second sub project THAT HAS A DIFFERENT GROUP ID => MUST NOT BE UPDATED **************** -->
   <projects id="5" root_id="1" kee="foo:struts-ui" name="Struts UI"
-            scope="PRJ" qualifier="BRC" long_name="Struts UI" profile_id="1"
-            description="[null]" enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]"/>
+            scope="PRJ" qualifier="BRC" long_name="Struts UI" 
+            description="[null]" enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/>
 
   <!-- directory -->
   <projects long_name="org.struts" id="6" scope="DIR" qualifier="PAC" kee="foo:struts-ui:org.struts"
               name="org.struts" root_id="5"
-              description="[null]" profile_id="1"
-              enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]"/>
+              description="[null]" 
+              enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/>
 
   <!-- file -->
   <projects long_name="org.struts.RequestContext" id="7" scope="FIL" qualifier="CLA" kee="foo:struts-ui:org.struts.RequestContext"
             name="RequestContext" root_id="5"
-            description="[null]" profile_id="1"
-            enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]"/>
+            description="[null]" 
+            enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/>
 
 </dataset>
index 5680e1d1814ebdf9854c4aca80382d26aa7833ac..178b172ddd0aa7d6558dba2164fd78ee30fb8869 100644 (file)
@@ -2,7 +2,7 @@
 
   <!-- root project -->
   <projects id="1" root_id="[null]" scope="PRJ" qualifier="TRK" kee="org.struts:struts" name="Struts"
-            description="[null]" long_name="Apache Struts" profile_id="1"
+            description="[null]" long_name="Apache Struts" 
             enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/>
 
 
   <!-- ONLY THIS PROJECT MUST HAVE BEEN UPDATED            -->
   <!--                                                     -->
   <projects id="2" root_id="1" kee="struts:core" name="Struts Core"
-            scope="PRJ" qualifier="BRC" long_name="Struts Core" profile_id="1"
-            description="[null]" enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/>
+            scope="PRJ" qualifier="BRC" long_name="Struts Core" 
+            description="[null]" enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]"/>
 
   <!-- directory -->
   <projects long_name="org.struts" id="3" scope="DIR" qualifier="PAC" kee="struts:core:org.struts"
               name="org.struts" root_id="2"
-              description="[null]" profile_id="1"
+              description="[null]" 
               enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/>
 
   <!-- file -->
   <projects long_name="org.struts.RequestContext" id="4" scope="FIL" qualifier="CLA" kee="struts:core:org.struts.RequestContext"
             name="RequestContext" root_id="2"
-            description="[null]" profile_id="1"
+            description="[null]" 
             enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/>
 
 
   <!-- **************** Second sub project **************** -->
   <projects id="5" root_id="1" kee="org.struts:struts-ui" name="Struts UI"
-            scope="PRJ" qualifier="BRC" long_name="Struts UI" profile_id="1"
+            scope="PRJ" qualifier="BRC" long_name="Struts UI" 
             description="[null]" enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/>
 
   <!-- directory -->
   <projects long_name="org.struts" id="6" scope="DIR" qualifier="PAC" kee="org.struts:struts-ui:org.struts"
               name="org.struts" root_id="5"
-              description="[null]" profile_id="1"
+              description="[null]" 
               enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/>
 
   <!-- file -->
   <projects long_name="org.struts.RequestContext" id="7" scope="FIL" qualifier="CLA" kee="org.struts:struts-ui:org.struts.RequestContext"
             name="RequestContext" root_id="5"
-            description="[null]" profile_id="1"
+            description="[null]" 
             enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/>
 
 
   <!-- **************** Another independent project **************** -->
   <projects id="8" root_id="[null]" kee="foo:struts-core" name="Foo Struts Core"
-            scope="PRJ" qualifier="BRC" long_name="Foo Struts Core" profile_id="1"
+            scope="PRJ" qualifier="BRC" long_name="Foo Struts Core" 
             description="[null]" enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="[null]"/>
 
 </dataset>
index 35a6e481340eadccbd1664030f2f2db084d7a32d..59b735a0138ab45509706a0c8acc7f1aded0b6f4 100644 (file)
@@ -25,7 +25,6 @@ import org.apache.commons.lang.builder.HashCodeBuilder;
 import org.apache.commons.lang.builder.ToStringBuilder;
 import org.hibernate.annotations.BatchSize;
 import org.sonar.api.database.BaseIdentifiable;
-import org.sonar.api.profiles.RulesProfile;
 import org.sonar.api.resources.ProjectLink;
 import org.sonar.api.resources.Resource;
 
@@ -99,10 +98,6 @@ public class ResourceModel extends BaseIdentifiable implements Cloneable {
   @BatchSize(size = 8)
   private List<ProjectLink> projectLinks = new ArrayList<ProjectLink>();
 
-  @ManyToOne(fetch = FetchType.LAZY)
-  @JoinColumn(name = "profile_id", updatable = true, nullable = true)
-  private RulesProfile rulesProfile;
-
   /**
    * Default constructor
    */
@@ -264,14 +259,6 @@ public class ResourceModel extends BaseIdentifiable implements Cloneable {
     this.rootId = rootId;
   }
 
-  public RulesProfile getRulesProfile() {
-    return rulesProfile;
-  }
-
-  public void setRulesProfile(RulesProfile rulesProfile) {
-    this.rulesProfile = rulesProfile;
-  }
-
   public String getQualifier() {
     return qualifier;
   }
@@ -337,7 +324,6 @@ public class ResourceModel extends BaseIdentifiable implements Cloneable {
     clone.setDescription(getDescription());
     clone.setEnabled(getEnabled());
     clone.setProjectLinks(getProjectLinks());
-    clone.setRulesProfile(getRulesProfile());
     clone.setLanguageKey(getLanguageKey());
     clone.setCopyResourceId(getCopyResourceId());
     clone.setLongName(getLongName());
index a06e887c02d21b9d9264e25f99023c1e24dfb1f6..171f2e922193a9e511734dc80bccbfe72085e004 100644 (file)
@@ -91,9 +91,6 @@ public class RulesProfile implements Cloneable {
   @OneToMany(mappedBy = "rulesProfile", fetch = FetchType.LAZY, cascade = {CascadeType.MERGE, CascadeType.PERSIST, CascadeType.REMOVE})
   private List<Alert> alerts = Lists.newArrayList();
 
-  @OneToMany(mappedBy = "rulesProfile", fetch = FetchType.LAZY)
-  private List<ResourceModel> projects = Lists.newArrayList();
-
   /**
    * @deprecated use the factory method create()
    */
@@ -110,7 +107,6 @@ public class RulesProfile implements Cloneable {
     this.language = language;
     this.activeRules = Lists.newArrayList();
     this.alerts = Lists.newArrayList();
-    this.projects = Lists.newArrayList();
   }
 
   /**
@@ -290,20 +286,6 @@ public class RulesProfile implements Cloneable {
     this.alerts = alerts;
   }
 
-  /**
-   * @return the list of projects attached to the profile
-   */
-  public List<ResourceModel> getProjects() {
-    return projects;
-  }
-
-  /**
-   * Sets the list of projects attached to the profile
-   */
-  public void setProjects(List<ResourceModel> projects) {
-    this.projects = projects;
-  }
-
   /**
    * Note: disabled rules are excluded.
    *
@@ -424,13 +406,6 @@ public class RulesProfile implements Cloneable {
         }
       })));
     }
-    if (CollectionUtils.isNotEmpty(getProjects())) {
-      clone.setProjects(new ArrayList<ResourceModel>(CollectionUtils.collect(getProjects(), new Transformer() {
-        public Object transform(Object input) {
-          return ((ResourceModel) input).clone();
-        }
-      })));
-    }
     return clone;
   }
 
index bd7b1921eb00c562352adb835c568cb80d9804b6..54fbae8b53807cd003bdb05e59e236122d47ec5f 100644 (file)
@@ -22,7 +22,6 @@ package org.sonar.server.configuration;
 import org.apache.commons.lang.ObjectUtils;
 import org.codehaus.plexus.util.StringUtils;
 import org.sonar.api.database.DatabaseSession;
-import org.sonar.api.database.model.ResourceModel;
 import org.sonar.api.profiles.RulesProfile;
 import org.sonar.api.rules.*;
 import org.sonar.api.utils.ValidationMessages;
@@ -40,20 +39,6 @@ public class ProfilesManager extends BaseDao {
     this.rulesDao = rulesDao;
   }
 
-  public void renameProfile(int profileId, String newProfileName) {
-    RulesProfile profile = getSession().getSingleResult(RulesProfile.class, "id", profileId);
-    if (profile != null && !profile.getProvided()) {
-      String hql = "UPDATE " + RulesProfile.class.getSimpleName() + " o SET o.parentName=:newName  WHERE o.parentName=:oldName";
-      getSession().getEntityManager().createQuery(hql)
-          .setParameter("oldName", profile.getName())
-          .setParameter("newName", newProfileName)
-          .executeUpdate();
-      profile.setName(newProfileName);
-      getSession().save(profile);
-      getSession().commit();
-    }
-  }
-
   public void copyProfile(int profileId, String newProfileName) {
     RulesProfile profile = getSession().getSingleResult(RulesProfile.class, "id", profileId);
     RulesProfile toImport = (RulesProfile) profile.clone();
@@ -65,27 +50,12 @@ public class ProfilesManager extends BaseDao {
     getSession().commit();
   }
 
-  public void deleteProfile(int profileId) {
-    RulesProfile profile = getSession().getEntity(RulesProfile.class, profileId);
-    if (profile != null && !profile.getProvided() && getChildren(profile).isEmpty()) {
-      // Remove history of rule changes
-      String hqlDeleteRc = "DELETE " + ActiveRuleChange.class.getSimpleName() + " rc WHERE rc.rulesProfile=:rulesProfile";
-      getSession().createQuery(hqlDeleteRc).setParameter("rulesProfile", profile).executeUpdate();
-
-      String hql = "UPDATE " + ResourceModel.class.getSimpleName() + " o SET o.rulesProfile=null WHERE o.rulesProfile=:rulesProfile";
-      getSession().createQuery(hql).setParameter("rulesProfile", profile).executeUpdate();
-      getSession().remove(profile);
-      getSession().commit();
-    }
-  }
 
   public void deleteAllProfiles() {
     // Remove history of rule changes
     String hqlDeleteRc = "DELETE " + ActiveRuleChange.class.getSimpleName() + " rc";
     getSession().createQuery(hqlDeleteRc).executeUpdate();
 
-    String hql = "UPDATE " + ResourceModel.class.getSimpleName() + " o SET o.rulesProfile = null WHERE o.rulesProfile IS NOT NULL";
-    getSession().createQuery(hql).executeUpdate();
     List profiles = getSession().createQuery("FROM " + RulesProfile.class.getSimpleName()).getResultList();
     for (Object profile : profiles) {
       getSession().removeWithoutFlush(profile);
index 85f177aaec9e252ec19a37925f6a65620faaab24..3738332bdccf1c055a37cc3199c52a1ade525838 100644 (file)
@@ -280,18 +280,10 @@ public final class JRubyFacade {
     return get(ProfilesConsole.class).getProfileExporter(exporterKey).getMimeType();
   }
 
-  public void renameProfile(int profileId, String newProfileName) {
-    getProfilesManager().renameProfile(profileId, newProfileName);
-  }
-
   public void copyProfile(long profileId, String newProfileName) {
     getProfilesManager().copyProfile((int) profileId, newProfileName);
   }
 
-  public void deleteProfile(long profileId) {
-    getProfilesManager().deleteProfile((int) profileId);
-  }
-
   public ValidationMessages changeParentProfile(int profileId, String parentName, String userName) {
     return getProfilesManager().changeParentProfile(profileId, parentName, userName);
   }
index 8636de40e54ffa15de300044c73c5b42457feeab..e125aaefe2d58b0d5f495b967e34040c55710b8b 100644 (file)
@@ -125,6 +125,23 @@ class ApplicationController < ActionController::Base
     raise Errors::AccessDenied
   end
 
+  # since 3.3
+  def require_parameters(*keys)
+    keys.each do |key|
+      bad_request("Missing parameter: #{key}") if params[key].blank?
+    end
+  end
+
+  # since 3.3
+  def verify_post_request
+    bad_request('Not a POST request') unless request.post?
+  end
+
+  # since 3.3
+  def verify_ajax_request
+    bad_request('Not an AJAX request') unless request.xhr?
+  end
+
   def render_not_found(error)
     render :file => "#{Rails.public_path}/404.html", :status => 404
   end
index d380dbff83775bb67a65ca0ede11e0d797525ec3..50fbf55c26fcef6ddfab9f4e9e8ab4a2e3ef303e 100644 (file)
 class ProfilesController < ApplicationController
   SECTION=Navigation::SECTION_CONFIGURATION
 
-  # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html)
-  verify :method => :post, :only => ['create', 'delete', 'copy', 'set_as_default', 'restore', 'set_projects', 'rename', 'change_parent'], :redirect_to => {:action => 'index'}
-
   # the backup action is allow to non-admin users : see http://jira.codehaus.org/browse/SONAR-2039
   before_filter :admin_required, :only => ['create', 'delete', 'set_as_default', 'copy', 'restore', 'change_parent', 'set_projects', 'rename_form', 'rename']
 
   # GET /profiles/index
   def index
-    @profiles = Profile.find(:all, :conditions => ['enabled=?', true], :order => 'name')
+    @profiles = Profile.find(:all, :order => 'name')
   end
 
 
   # GET /profiles/show/<id>
   def show
+    require_parameters 'id'
     @profile = Profile.find(params[:id])
   end
 
 
   # GET /profiles/create_form?language=<language>
   def create_form
-    language = params[:language]
-    bad_request 'Missing parameter: language' if language.blank?
-    profile = Profile.new(:language => language)
-    render :partial => 'profiles/create_form', :locals => {:language_key => language}
+    require_parameters 'language'
+    render :partial => 'profiles/create_form', :locals => {:language_key => params[:language]}
   end
 
   # POST /profiles/create?name=<profile name>&language=<language>&[backup=<file>]
   def create
+    verify_post_request
+    require_parameters 'language'
+
     profile_name=params[:name]
     language=params[:language]
 
-    profile = Profile.create(:name => profile_name, :language => language, :default_profile => false, :enabled => true)
+    profile = Profile.create(:name => profile_name, :language => language, :default_profile => false)
     ok = profile.errors.empty?
     if ok && params[:backup]
       params[:backup].each_pair do |importer_key, file|
@@ -75,9 +74,12 @@ class ProfilesController < ApplicationController
 
   # POST /profiles/delete/<id>
   def delete
+    verify_post_request
+    require_parameters 'id'
+
     @profile = Profile.find(params[:id])
     if @profile && @profile.deletable?
-      java_facade.deleteProfile(@profile.id)
+      @profile.destroy
     end
     redirect_to(:controller => 'profiles', :action => 'index')
   end
@@ -85,40 +87,50 @@ class ProfilesController < ApplicationController
 
   # POST /profiles/set_as_default/<id>
   def set_as_default
+    verify_post_request
+    require_parameters 'id'
+
     profile = Profile.find(params[:id])
     profile.set_as_default
-    flash[:notice]=message('quality_profiles.default_profile_is_x', :params => profile.name)
+    #TODO remove l10n key: flash[:notice]=message('quality_profiles.default_profile_is_x', :params => profile.name)
     redirect_to :action => 'index'
   end
 
 
   # GET /profiles/copy_form/<profile id>
   def copy_form
+    require_parameters 'id'
     @profile = Profile.find(params[:id])
     render :partial => 'profiles/copy_form'
   end
 
   # POST /profiles/copy/<id>?name=<name of new profile>
   def copy
-    render :text => 'Not an ajax request', :status => '400' unless request.xhr?
+    verify_post_request
+    verify_ajax_request
+    require_parameters 'id'
 
     @profile = Profile.find(params[:id])
     name = params['name']
 
-    validation_errors = @profile.validate_copy(name)
-    if validation_errors.empty?
+    target_profile=Profile.new(:name => name, :language => @profile.language, :provided => false, :default_profile => false)
+    if target_profile.valid?
       java_facade.copyProfile(@profile.id, name)
       flash[:notice]= message('quality_profiles.profile_x_not_activated', :params => name)
       render :text => 'ok', :status => 200
     else
-      @error = validation_errors.full_messages.first
+      @errors = []
+      target_profile.errors.each{|attr,msg| @errors<<msg}
       render :partial => 'profiles/copy_form', :status => 400
     end
   end
 
 
-  # POST /profiles/backup/<id>
+  # POST /profiles/backup?id=<profile id>
   def backup
+    verify_post_request
+    require_parameters 'id'
+
     profile = Profile.find(params[:id])
     xml = java_facade.backupProfile(profile.id)
     filename=profile.name.gsub(' ', '_')
@@ -129,11 +141,13 @@ class ProfilesController < ApplicationController
   # Modal window to restore profile backup
   # GET /profiles/restore_form/<profile id>
   def restore_form
+    verify_ajax_request
     render :partial => 'profiles/restore_form'
   end
 
   # POST /profiles/restore?backup=<file>
   def restore
+    verify_post_request
     if params[:backup].blank?
       flash[:warning]=message('quality_profiles.please_upload_backup_file')
     else
@@ -148,7 +162,7 @@ class ProfilesController < ApplicationController
   def export
     language = params[:language]
     if (params[:name].blank?)
-      profile = Profile.find_active_profile_by_language(language)
+      profile = Profile.by_default(language)
     else
       profile = Profile.find_by_name_and_language(CGI::unescape(params[:name]), language)
     end
@@ -165,24 +179,18 @@ class ProfilesController < ApplicationController
     end
   end
 
-  #
-  #
   # GET /profiles/inheritance?id=<profile id>
-  #
-  #
   def inheritance
+    require_parameters 'id'
     @profile = Profile.find(params[:id])
 
-    profiles=Profile.find(:all, :conditions => ['language=? and id<>? and (parent_name is null or parent_name<>?) and enabled=?', @profile.language, @profile.id, @profile.name, true], :order => 'name')
+    profiles=Profile.find(:all, :conditions => ['language=? and id<>? and (parent_name is null or parent_name<>?)', @profile.language, @profile.id, @profile.name], :order => 'name')
     @select_parent = [[message('none'), nil]] + profiles.collect { |profile| [profile.name, profile.name] }
   end
 
-  #
-  #
   # GET /profiles/changelog?id=<profile id>
-  #
-  #
   def changelog
+    require_parameters 'id'
     @profile = Profile.find(params[:id])
 
     versions = ActiveRuleChange.find(:all, :select => 'profile_version, MAX(change_date) AS change_date', :conditions => ['profile_id=?', @profile.id], :group => 'profile_version')
@@ -210,12 +218,11 @@ class ProfilesController < ApplicationController
   end
 
 
-  #
-  #
   # POST /profiles/change_parent?id=<profile id>&parent_name=<parent profile name>
-  #
-  #
   def change_parent
+    verify_post_request
+    require_parameters 'id'
+
     id = params[:id].to_i
     parent_name = params[:parent_name]
     if parent_name.blank?
@@ -234,6 +241,7 @@ class ProfilesController < ApplicationController
   #
   #
   def permalinks
+    require_parameters 'id'
     @profile = Profile.find(params[:id])
   end
 
@@ -244,62 +252,68 @@ class ProfilesController < ApplicationController
   #
   #
   def projects
+    require_parameters 'id'
     @profile = Profile.find(params[:id])
-    @available_projects=Project.find(:all,
-                                     :include => ['profile', 'snapshots'],
-                                     :conditions => ['projects.qualifier=? AND projects.scope=? AND snapshots.islast=?', Project::QUALIFIER_PROJECT, Project::SCOPE_SET, true],
-                                     :order => 'projects.name asc')
-    @available_projects-=@profile.projects
   end
 
 
-  #
-  #
-  # POST /profiles/set_projects/<id>?projects=<project ids>
-  #
-  #
-  def set_projects
-    @profile = Profile.find(params[:id])
-    @profile.projects.clear
+  # POST /profiles/add_project?id=<profile id>&project_id=<project id>
+  def add_project
+    verify_post_request
+    require_parameters 'id', 'project_id'
+    admin_required
+
+    profile=Profile.find(params[:id])
+    bad_request('Unknown profile') unless profile
+    project=Project.find(params[:project_id])
+    bad_request('Unknown project') unless project
 
-    projects=Project.find(params[:projects] || [])
-    @profile.projects=projects
-    flash[:notice]=message('quality_profiles.profile_x_associated_to_x_projects', :params => [@profile.name, projects.size])
-    redirect_to :action => 'projects', :id => @profile.id
+    profile.add_project_id(project.id)
+    redirect_to :action => 'projects', :id => profile.id
   end
 
+  # POST /profiles/remove_project?id=<profile id>&project_id=<project id>
+  def remove_project
+    verify_post_request
+    require_parameters 'id', 'project_id'
+    admin_required
+
+    profile=Profile.find(params[:id])
+    bad_request('Unknown profile') unless profile
+
+    Profile.reset_default_profile_for_project_id(profile.language, params[:project_id])
+    redirect_to :action => 'projects', :id => profile.id
+  end
+
+  # POST /profiles/remove_projects?id=<profile id>
+  def remove_projects
+    verify_post_request
+    require_parameters 'id'
+    admin_required
+
+    profile=Profile.find(params[:id])
+    bad_request('Unknown profile') unless profile
+
+    profile.remove_projects
+    redirect_to :action => 'projects', :id => profile.id
+  end
 
   # GET /profiles/rename_form?id=<id>
   def rename_form
+    require_parameters 'id'
     @profile = Profile.find(params[:id])
     render :partial => 'profiles/rename_form'
   end
 
-  #
-  #
   # POST /profiles/rename?id=<id>&name=<new name>
-  #
-  #
   def rename
-    render :text => 'Not an ajax request', :status => '400' unless request.xhr?
+    verify_post_request
+    verify_ajax_request
+    require_parameters 'id'
 
     @profile = Profile.find(params[:id])
-    name = params[:name]
 
-    success=false
-    if name.blank?
-      @error=message('quality_profiles.profile_name_cant_be_blank')
-    else
-      existing=Profile.find(:first, :conditions => {:name => name, :language => @profile.language, :enabled => true})
-      if existing
-        @error=message('quality_profiles.already_exists')
-      elsif !@profile.provided?
-        java_facade.renameProfile(@profile.id, name)
-        success=true
-      end
-    end
-
-    if success
+    if @profile.rename(params[:name]).errors.empty?
       render :text => 'ok', :status => 200
     else
       render :partial => 'profiles/rename_form', :status => 400
@@ -307,13 +321,9 @@ class ProfilesController < ApplicationController
   end
 
 
-  #
-  #
   # GET /profiles/compare?id1=<profile1 id>&id2=<profile2 id>
-  #
-  #
   def compare
-    @profiles = Profile.find(:all, :conditions => ['enabled=?', true], :order => 'language asc, name')
+    @profiles = Profile.find(:all, :order => 'language asc, name')
     if params[:id1].present? && params[:id2].present?
       @profile1 = Profile.find(params[:id1])
       @profile2 = Profile.find(params[:id2])
index a993d5331ec4f1de1004365bf00fdae6992fd293..5e59296c6e3f882cdc32c3f7aadb467303516f9a 100644 (file)
@@ -18,7 +18,7 @@
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
 #
 class ProjectController < ApplicationController
-  verify :method => :post, :only => [:set_links, :set_exclusions, :delete_exclusions, :update_key, :perform_key_bulk_update, :update_quality_profile],
+  verify :method => :post, :only => [:set_links, :set_exclusions, :delete_exclusions, :update_key, :perform_key_bulk_update],
          :redirect_to => {:action => :index}
   verify :method => :delete, :only => [:delete], :redirect_to => {:action => :index}
 
@@ -75,25 +75,29 @@ class ProjectController < ApplicationController
     redirect_to :action => 'deletion', :id => params[:id]
   end
 
-  def quality_profile
+  # GET /project/profile?id=<project id>
+  def profile
+    require_parameters :id
     @project = get_current_project(params[:id])
-    @profiles = Profile.find(:all, :conditions => {:language => @project.language, :enabled => true})
   end
 
-  def update_quality_profile
+  # POST /project/set_profile?id=<project id>&language=<language>[&profile_id=<profile id>]
+  def set_profile
+    require_parameters :id, :language
+    verify_post_request
+
+    language=params[:language]
     project = get_current_project(params[:id])
 
-    selected_profile = Profile.find(:first, :conditions => {:id => params[:quality_profile].to_i})
-    if selected_profile && selected_profile.language == project.language
-      project.profile = selected_profile
-      project.save!
-      flash[:notice] = message('project_quality_profile.profile_successfully_updated')
+    if params[:profile_id].blank?
+      Profile.reset_default_profile_for_project_id(language, project.id)
     else
-      selected_profile_name = selected_profile ? selected_profile.name + "(" + selected_profile.language + ")" : "Unknown profile"
-      flash[:error] = message('project_quality_profile.project_cannot_be_update_with_profile_x', :params => selected_profile_name)
+      profile = Profile.find(params[:profile_id])
+      bad_request('Bad language') if profile.language!=language
+      profile.add_project_id(project.id)
     end
 
-    redirect_to :action => 'quality_profile', :id => project.id
+    redirect_to :action => 'profile', :id => project.id
   end
 
   def key
index 39b9ac0f3abd10fcf097d05676e796d3e6d8b01a..8720d718e204a710f0d6b32c54e1ed82f08520cb 100644 (file)
@@ -721,7 +721,7 @@ module ApplicationHelper
   end
 
   #
-  # Creates a button linked to a POST action. A confirmation popup is opened when user clicks on the button.
+  # Creates a link linked to a POST action. A confirmation popup is opened when user clicks on the button.
   # ==== Options
   # * <tt>:id</tt> - HTML ID of the button
   # * <tt>:class</tt> - Additional CSS class, generally 'red-button' for deletions
@@ -731,7 +731,7 @@ module ApplicationHelper
   # * <tt>:message_params</tt> -
   # * <tt>:width</tt> - width in pixels
   #
-  def button_to_action(label, post_url, options={})
+  def link_to_action(label, post_url, options={})
     clazz = options[:class]
     id = "id='#{options[:id]}'" if options[:id]
     title_key = options[:title_key]
@@ -750,6 +750,6 @@ module ApplicationHelper
       url += "&bk=#{button_key}"
     end
 
-    "<a href='#{url}' modal-width='#{width}' class='open-modal button #{clazz}' #{id}>#{h label}</a>"
+    "<a href='#{url}' modal-width='#{width}' class='open-modal #{clazz}' #{id}>#{h label}</a>"
   end
 end
index ddf214b88e2aa840ba4cddcae3568b3d506870bd..81e74632ca9fae889d762a26ed45ede33593b5fa 100644 (file)
@@ -169,4 +169,8 @@ class Api::Utils
   def self.java_facade
     Java::OrgSonarServerUi::JRubyFacade.getInstance()
   end
+
+  def self.languages
+    java_facade.getLanguages()
+  end
 end
index 079645ff6c6b5ebf519e0a9e188a56706e6e3e1f..a9bb3d3a20ed822ef6ac683d83aa31b8aeef2aee 100644 (file)
@@ -22,13 +22,21 @@ class Profile < ActiveRecord::Base
 
   has_many :alerts, :dependent => :delete_all
   has_many :active_rules, :class_name => 'ActiveRule', :foreign_key => 'profile_id', :dependent => :destroy, :include => ['rule']
-  has_many :projects, :order => 'name asc'
-  has_many :active_rules_with_params, :class_name => 'ActiveRule', :foreign_key => 'profile_id',
-           :include => ['active_rule_parameters', 'active_rule_note']
+  has_many :active_rules_with_params, :class_name => 'ActiveRule', :foreign_key => 'profile_id', :include => ['active_rule_parameters', 'active_rule_note']
+  has_many :projects, :class_name => 'Project', :finder_sql => %q(
+    select prj.* from projects prj, properties prop where prj.id=prop.resource_id and prop.resource_id is not null and prop.prop_key='sonar.profile.#{language}' and prop.text_value='#{name}'
+  )
+  has_many :changes, :class_name => 'ActiveRuleChange', :dependent => :destroy
+  has_many :children, :class_name => 'Profile', :finder_sql => %q(
+      select c.* from rules_profiles c where c.parent_name='#{name}' and c.language='#{language}'
+  )
 
   validates_uniqueness_of :name, :scope => :language, :case_sensitive => false, :message => Api::Utils.message('quality_profiles.already_exists')
   validates_presence_of :name, :message => Api::Utils.message('quality_profiles.please_type_profile_name')
 
+  MAX_NAME_LENGTH = 100
+  validates_length_of :name, :maximum => MAX_NAME_LENGTH, :message => Api::Utils.message('name_too_long_x', :params => [MAX_NAME_LENGTH])
+
   # The warnings that are set on this record, equivalent to normal ActiveRecord errors but does not prevent
   # the record from saving.
   def warnings
@@ -36,7 +44,7 @@ class Profile < ActiveRecord::Base
   end
 
   def warnings?
-    not warnings.empty?
+    !warnings.empty?
   end
 
   def notices
@@ -59,34 +67,16 @@ class Profile < ActiveRecord::Base
     provided
   end
 
-  def validate_copy(name)
-    new_rule_profile = Profile.new(:name => name, :provided => false, :default_profile => false, :language => language)
-    new_rule_profile.valid?
-    new_rule_profile.errors
-  end
-
-  def self.find_by_name_and_language(name, language)
-    Profile.find(:first, :conditions => {:name => name, :language => language, :enabled => true})
-  end
-
-  def self.find_active_profile_by_language(language)
-    Profile.find(:first, :conditions => {:default_profile => true, :language => language, :enabled => true})
-  end
-
-  def self.default_profile
-    Profile.find(:first, :conditions => {:default_profile => true, :enabled => true})
-  end
-
   def set_as_default
-    default_profile=nil
-    Profile.find(:all, :conditions => {:language => language, :enabled => true}).each do |profile|
-      if profile.id==id
-        profile.default_profile=true
-        default_profile=profile
-      else
-        profile.default_profile=false
+    Profile.transaction do
+      Profile.find(:all, :conditions => {:language => language}).each do |profile|
+        if profile.id==id
+          profile.default_profile=true
+        else
+          profile.default_profile=false
+        end
+        profile.save
       end
-      profile.save
     end
     self
   end
@@ -97,7 +87,7 @@ class Profile < ActiveRecord::Base
 
   def self.options_for_select
     array=[]
-    Profile.find(:all, :conditions => {:enabled => true}, :order => 'name').each do |profile|
+    Profile.find(:all, :order => 'name').each do |profile|
       label = profile.name
       label = label + ' (active)' if profile.default_profile?
       array<<[label, profile.id]
@@ -123,9 +113,9 @@ class Profile < ActiveRecord::Base
 
   def count_overriding_rules
     @count_overriding_rules||=
-        begin
-          active_rules.count(:conditions => ['inheritance=?', 'OVERRIDES'])
-        end
+      begin
+        active_rules.count(:conditions => ['inheritance=?', 'OVERRIDES'])
+      end
   end
 
   def inherited?
@@ -134,13 +124,13 @@ class Profile < ActiveRecord::Base
 
   def parent
     @parent||=
-        begin
-          if parent_name.present?
-            Profile.find(:first, :conditions => ['language=? and name=? and enabled=?', language, parent_name, true])
-          else
-            nil
-          end
+      begin
+        if parent_name.present?
+          Profile.find(:first, :conditions => ['language=? and name=?', language, parent_name])
+        else
+          nil
         end
+      end
   end
 
   def count_active_rules
@@ -149,21 +139,14 @@ class Profile < ActiveRecord::Base
 
   def ancestors
     @ancestors ||=
-        begin
-          array=[]
-          if parent
-            array<<parent
-            array.concat(parent.ancestors)
-          end
-          array
-        end
-  end
-
-  def children
-    @children ||=
-        begin
-          Profile.find(:all, :conditions => ['language=? and parent_name=? and enabled=?', language, name, true], :order => 'name')
+      begin
+        array=[]
+        if parent
+          array<<parent
+          array.concat(parent.ancestors)
         end
+        array
+      end
   end
 
   def import_configuration(importer_key, file)
@@ -178,4 +161,60 @@ class Profile < ActiveRecord::Base
       notices.add_to_base msg
     end
   end
+
+  def before_destroy
+    Property.clear_for_resources("sonar.profile.#{language}", name)
+    #TODO clear global property sonar.profile.#{language} with value #{name}
+  end
+
+  def rename(new_name)
+    old_name=self.name
+    Profile.transaction do
+      children_to_be_renamed=children()
+      self.name=new_name
+      if save
+        children_to_be_renamed.each do |child|
+          child.parent_name=new_name
+          child.save
+        end
+        Property.update_all("text_value='#{new_name}'", ['prop_key=? and text_value=?', "sonar.profile.#{language}", old_name])
+      end
+    end
+    self
+  end
+
+  def add_project_id(project_id)
+    Property.set("sonar.profile.#{language}", name, project_id)
+  end
+
+  def remove_projects
+    Property.clear_for_resources("sonar.profile.#{language}", name)
+  end
+
+  def self.reset_default_profile_for_project_id(lang, project_id)
+    Property.clear("sonar.profile.#{lang}", project_id)
+  end
+
+  def self.by_project_id(language, project_id, returns_default_if_nil=false)
+    profile_name=Property.value("sonar.profile.#{language}", project_id)
+    profile = (profile_name.present? ? Profile.find_by_name_and_language(profile_name, language) : nil)
+
+    if !profile && returns_default_if_nil
+      profile = by_default(language)
+    end
+    profile
+  end
+
+  def self.by_default(language)
+    Profile.find(:first, :conditions => {:default_profile => true, :language => language})
+  end
+
+  # Results are NOT sorted
+  def self.all_by_language(language)
+    Profile.find(:all, :conditions => {:language => language})
+  end
+
+  def self.find_by_name_and_language(name, language)
+    Profile.find(:first, :conditions => {:name => name, :language => language})
+  end
 end
\ No newline at end of file
index 07e3a25128235125a601fca8e9cbafc0ec06300a..4acf953c17c7384de245f739e1a2925e3dc20dba 100644 (file)
@@ -25,7 +25,6 @@ class Project < ActiveRecord::Base
   has_many :processed_snapshots, :class_name => 'Snapshot', :conditions => "status='#{Snapshot::STATUS_PROCESSED}' AND qualifier<>'LIB'", :order => 'created_at asc'
   has_many :events, :foreign_key => 'resource_id', :order => 'event_date DESC'
   has_many :project_links, :dependent => :delete_all, :order => 'link_type'
-  belongs_to :profile, :class_name => 'Profile', :foreign_key => 'profile_id'
   has_many :user_roles, :foreign_key => 'resource_id'
   has_many :group_roles, :foreign_key => 'resource_id'
   has_many :manual_measures, :foreign_key => 'resource_id'
@@ -182,6 +181,10 @@ class Project < ActiveRecord::Base
     last_snapshot ? last_snapshot.path_name : nil
   end
 
+  def profile(lang, returns_default_if_nil=false)
+    Profile.by_project_id(lang, id, returns_default_if_nil)
+  end
+
   private
 
   def create_chart_measures(results, date_column_name, value_column_name)
index 976fdf7480a8909398da5f70223b9725b87502c6..6371b51242d643504c90e0b1393c961fa7f0de37 100644 (file)
@@ -21,9 +21,11 @@ class Property < ActiveRecord::Base
   validates_presence_of :prop_key
 
   named_scope :with_key, lambda { |value| {:conditions => {:prop_key, value}} }
+  named_scope :with_value, lambda { |value| {:conditions => {:text_value, value}} }
   named_scope :with_resource, lambda { |value| {:conditions => {:resource_id => value}} }
   named_scope :with_user, lambda { |value| {:conditions => {:user_id => value}} }
-  named_scope :on_resource, :conditions => ['resource_id is not ?', nil]
+  named_scope :with_resources, :conditions => 'resource_id is not null'
+  named_scope :with_users, :conditions => 'user_id is not null'
 
   def key
     prop_key
@@ -47,6 +49,18 @@ class Property < ActiveRecord::Base
     end
   end
 
+  def self.clear_for_resources(key, value=nil)
+    scope=Property.with_resources().with_key(key)
+    if value
+      scope.with_value(value)
+    end
+    scope.delete_all
+  end
+
+  def self.clear_for_users(key)
+    Property.with_users().with_key(key).delete_all
+  end
+
   def self.by_key(key, resource_id=nil, user_id=nil)
     all(key, resource_id, user_id).first
   end
index 9788893ab967ef5d5a0a8fec11de22fd7f00b522..96d831919b5f6803e71152d9165268017b198345 100644 (file)
@@ -89,8 +89,8 @@
           <% if has_role?(:admin, @project) %>
             <li class="h2"><%= message('sidebar.project_settings') -%></li>
             <% if (@project.project?) %>
-              <li class="<%= 'selected' if request.request_uri.include?('/project/quality_profile') -%>">
-                <a href="<%= ApplicationController.root_context -%>/project/quality_profile/<%= @project.id -%>"><%= message('project_quality_profile.page') -%></a></li>
+              <li class="<%= 'selected' if request.request_uri.include?('/project/profile') -%>">
+                <a href="<%= ApplicationController.root_context -%>/project/profile/<%= @project.id -%>"><%= message('project_quality_profile.page') -%></a></li>
             <% end %>
             <li class="<%= 'selected' if request.request_uri.include?('/manual_measures') -%>">
               <a href="<%= ApplicationController.root_context -%>/manual_measures/index/<%= @project.id -%>"><%= message('manual_measures.page') -%></a></li>
index bff1d8c7bfc22529a325ad49eaa685b29e923d7b..535ea549a10a8028d652968b8968f19a3274192a 100644 (file)
@@ -2,14 +2,18 @@
   <input type="hidden" name="id" value="<%= @profile.id -%>"/>
   <fieldset>
     <div class="form-head">
-      <h2>Copy Profile: <%= h @profile.name -%></h2>
+      <h2> <%= message('quality_profiles.copy_x_title', :params => [h @profile.name]) -%></h2>
     </div>
     <div class="form-body">
-      <% if @error %>
-        <p class="error"><%= h @error -%></p>
-      <% end %>
+      <% if @errors
+          @errors.each do |error|
+      %>
+        <p class="error"><%= h error -%></p>
+      <% end
+      end
+      %>
       <div class="form-field">
-        <label for="name">New name <em>*</em></label>
+        <label for="name"><%= message 'quality_profiles.copy_new_name' -%> <em>*</em></label>
         <input id="copy-name" name="name" type="text" size="50" maxlength="100"/>
       </div>
     </div>
index 4da833e138daf5f0859516c8368a16505b459b5f..b7c11aa4ac72c8d1299183f5243af734b9526dba 100644 (file)
@@ -3,12 +3,12 @@
   <fieldset>
 
     <div class="form-head">
-      <h2>Rename Profile: <%= h @profile.name -%></h2>
+      <h2>Rename Profile: <%= h @profile.name_was -%></h2>
     </div>
 
     <div class="form-body">
-      <% if @error %>
-        <p class="error"><%= h @error -%></p>
+      <% @profile.errors.each do |attr, msg| %>
+        <p class="error"><%= h msg -%></p>
       <% end %>
 
       <div class="form-field">
index 201a77186820cf8fe6e8540842a7c6adf34dd13e..50efc517ad0930427c51be52b40bd92fa3caaf4b 100644 (file)
@@ -49,7 +49,7 @@
         </td>
 
         <td align="right">
-          <span id="activated_rules_<%= u profile.key -%>"><%= profile.count_active_rules -%></span>
+          <span id="activated_rules_<%= u profile.key -%>"><%= profile.active_rules.count -%></span>
         </td>
 
         <td align="right"><span id="alerts_<%= u profile.key -%>"><%= profile.alerts.size -%></span></td>
@@ -62,8 +62,9 @@
 
         <td align="right">
           <% if !profile.default_profile? && administrator? %>
-            <%= button_to_action message('set_as_default'), "profiles/set_as_default?id=#{profile.id}",
+            <%= link_to_action message('set_as_default'), "profiles/set_as_default?id=#{profile.id}",
                                                :id => "activate_#{profile.key.parameterize}",
+                                               :class => 'button',
                                                :title_key => 'set_as_default',
                                                :message_key => 'quality_profiles.are_you_sure_want_x_profile_as_default',
                                                :message_params => [profile.name] -%>
@@ -96,8 +97,8 @@
 
           <td>
             <% if profile.deletable? %>
-              <%= button_to_action message('delete'), "profiles/delete/#{profile.id}",
-                                   :class => 'red-button',
+              <%= link_to_action message('delete'), "profiles/delete/#{profile.id}",
+                                   :class => 'button red-button',
                                    :id => "delete_#{profile.key.parameterize}",
                                    :button_key => 'delete',
                                    :title_key => 'quality_profiles.delete_confirm_title',
index 8a155a8adbd4e16063a4e15925abc854dd6e1c3d..df77976eb84482ff03ec6c4a89e60a0cac847ecc 100644 (file)
@@ -1,54 +1,79 @@
-<h1 class="marginbottom10"><%= link_to message('quality_profiles.quality_profiles'), :controller => 'profiles', :action => 'index' -%> / <%= h @profile.language -%> / <%= h @profile.name %></h1>
-<%= render :partial => 'profiles/tabs', :locals => {:selected_tab=>'Projects'} %>
+<h1 class="marginbottom10"><%= link_to message('quality_profiles.quality_profiles'), :controller => 'profiles', :action => 'index' -%> / <%= h @profile.language -%>
+  / <%= h @profile.name %></h1>
+<%= render :partial => 'profiles/tabs', :locals => {:selected_tab => 'Projects'} %>
 
 <div class="tabs-panel">
-<% if is_admin? %>
-<form action="<%= url_for :action => 'set_projects' -%>" method="post" id="select_projects_form">
-  <input type="hidden" name="id" value="<%= @profile.id -%>"/>
-<table>
-  <tr>
-    <td style="padding: 5px 0" valign="top">
-      <h3><%= message('quality_profiles.available_projects') -%></h3>
-      <select name="from" id="from" size="10" style="max-width:380px;margin-top: 5px" multiple="multiple">
-        <% @available_projects.each do |project| %>
-        <option value="<%= project.id -%>"><%= project.name %><%= " (#{project.profile.name})" if project.profile %></option>
+  <% if is_admin? %>
+    <form method="POST" action="<%= ApplicationController.root_context -%>/profiles/add_project" id="add_project_form">
+      <input type="hidden" name="id" value="<%= @profile.id -%>"/>
+
+      Add project: <%= resource_select_tag 'project_id', {
+      :qualifiers => ['TRK'],
+      :width => '400px',
+      :html_id => "select-project",
+    } -%>
+      <script>$j('#select-project').on("change", function (e) {
+        $j(this).select2("disable");
+        $j('#add_project_form').submit();
+      })</script>
+    </form>
+
+    <% unless @profile.projects.empty? %>
+      <table class="data">
+        <thead>
+        <tr>
+          <th></th>
+          <th></th>
+        </tr>
+        </thead>
+        <tbody>
+        <% @profile.projects.each do |project| %>
+          <tr class="<%= cycle('even', 'odd') -%>">
+            <td class="thin">
+              <%= link_to_action message('remove'),
+                                 "#{ApplicationController.root_context}/profiles/remove_project?id=#{@profile.id}&project_id=#{project.id}",
+                                 :class => 'link-action',
+                                 :id => "link-remove-#{project.key.parameterize}" -%>
+            </td>
+            <td><%= h project.name -%> <span class="small gray"><%= h project.key -%></span></td>
+          </tr>
         <% end %>
-      </select>
-    </td>
-    <td align="center" style="padding: 0 10px;">
-         <button id="select_right" onclick="SelectBox.move('from', 'to');SelectBox.sort('to');SelectBox.redisplay('to');return false;"><%= message('select_verb').downcase -%> &raquo;</button><br/>
-      <button id="select_right_all" onclick="SelectBox.move_all('from', 'to');return false;"><%= message('select_all').downcase -%> &raquo;</button><br/><br/>
-      <button id="select_left" onclick="SelectBox.move('to', 'from');return false;">&laquo; <%= message('unselect_verb').downcase -%></button><br/>
-      <button id="select_left_all" onclick="SelectBox.move_all('to', 'from');return false;">&laquo; <%= message('unselect_all').downcase -%></button>
-    </td>
-    <td class="box" style="padding: 5px 10px;" valign="top">
-           <h3><%= message('quality_profiles.associated_projects') -%></h3>
-      <select name="projects[]" id="to" size="10" multiple="multiple" style="min-width: 300px;margin: 5px 0;">
-      <%= options_from_collection_for_select(@profile.projects, "id", "name") %>
-      </select><br/>
-    <div style="padding:5px 0">
-          <input type="submit" id="save" value="<%= message('save') -%>" onclick="SelectBox.select_all('to');submit();"/>
-         </div>
-  </td>
-</tr>
-</table>
-</form>
-<script>
-SelectBox.init('from');
-SelectBox.init('to');
-</script>
+        </tbody>
+        <tfoot>
+        <tr>
+          <td colspan="2">
+            <%= link_to_action message('quality_profiles.remove_projects_action'),
+                               "#{ApplicationController.root_context}/profiles/remove_projects?id=#{@profile.id}",
+                               :class => 'link-action',
+                               :id => "link-remove-projects" -%>
+          </td>
+        </tr>
+        </tfoot>
+      </table>
 
-<% else %>
 
-  <% if @profile.projects.empty? %>
-    <p><%= message('quality_profiles.no_projects_associated_to_profile_x', :params => @profile.name) -%></p>
+    <% end %>
   <% else %>
-  <p><%= message('quality_profiles.projects_warning') -%></p>
-  <ol>
-    <% @profile.projects.each do |project| %>
-      <li><%= project.name %></li>
+
+    <% if @profile.projects.empty? %>
+      <p><%= message('quality_profiles.no_projects_associated_to_profile_x', :params => @profile.name) -%></p>
+    <% else %>
+      <p><%= message('quality_profiles.projects_warning') -%></p>
+
+      <table class="data">
+        <thead>
+        <tr>
+          <th></th>
+        </tr>
+        </thead>
+        <tbody>
+        <% @profile.projects.each do |project| %>
+          <tr class="<%= cycle('even', 'odd') -%>">
+            <td><%= h project.name -%> <span class="small gray"><%= h project.key -%></span></td>
+          </tr>
+        <% end %>
+        </tbody>
+      </table>
     <% end %>
-  </ol>
   <% end %>
-<% end %>
 </div>
\ No newline at end of file
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/project/profile.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/project/profile.html.erb
new file mode 100644 (file)
index 0000000..a52e06a
--- /dev/null
@@ -0,0 +1,40 @@
+<h1 class="marginbottom10"><%= message('project_quality_profile.page') -%></h1>
+
+<table class="data">
+  <thead>
+  <tr>
+    <th><%= message 'language' -%></th>
+    <th>Quality Profile</th>
+  </tr>
+  </thead>
+  <tbody>
+  <%
+     Api::Utils.languages.sort_by { |l| l.getKey() }.each do |language|
+       selected_profile=@project.profile(language.getKey(), false)
+  %>
+    <tr class="<%= cycle 'even', 'odd' -%>">
+      <td class="thin"><%= h language.getName() -%></td>
+      <td>
+        <form id="form-<%= language.getKey().parameterize -%>" method="POST" action="<%= ApplicationController.root_context -%>/project/set_profile">
+          <input type="hidden" name="id" value="<%= @project.id -%>"/>
+          <input type="hidden" name="language" value="<%= language.getKey() -%>"/>
+
+          <select id="select-profiles-<%= language.getKey().parameterize -%>" name="profile_id">
+            <option value="" <%= "selected='selected'" unless selected_profile -%>><%= message 'project_quality_profile.default_profile' -%></option>
+            <optgroup>
+              <%
+                 profiles = Api::Utils.insensitive_sort(Profile.all_by_language(language.getKey())) { |profile| profile.name }
+                 profiles.each do |profile|
+              %>
+                <option value="<%= profile.id -%>" <%= "selected='selected'" if selected_profile && selected_profile.id==profile.id -%>><%= h profile.name -%></option>
+              <% end %>
+            </optgroup>
+          </select>
+
+          <%= submit_tag message('update_verb'), :id => "submit-#{language.getKey()}", :disable_with => message('updating') %>
+        </form>
+      </td>
+    </tr>
+  <% end %>
+  </tbody>
+</table>
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/project/quality_profile.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/project/quality_profile.html.erb
deleted file mode 100644 (file)
index f75218f..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-<h1><%= message('project_quality_profile.page') -%></h1>
-<br/>
-<% 
-   form_tag( {:action => 'update_quality_profile', :id => @project.id }) do
-     project_profile = @project.profile 
-%>
-
-  <span style= "padding-right: 10px"><%= message('project_quality_profile.select_profile_for_x', :params => @project.name) -%></span>
-
-  <select name="quality_profile" id="quality_profile">
-    <% 
-       @profiles.each do |profile| 
-         should_be_selected = (project_profile && project_profile==profile) || (!project_profile && profile.default_profile)
-         label = profile.name
-         label += ' (' + message('project_quality_profile.default_profile') + ')' if profile.default_profile
-    %>
-      <option <%= 'selected' if should_be_selected -%> value="<%= profile.id -%>"><%= label -%></option>
-    <% end %>
-  </select>
-  
-  <%= submit_tag message('update_verb'), :id => 'update_profile' %>
-  
-<% end %>
diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/331_remove_projects_profile_id.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/331_remove_projects_profile_id.rb
new file mode 100644 (file)
index 0000000..68fc650
--- /dev/null
@@ -0,0 +1,45 @@
+#
+# 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 Sonar; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
+#
+
+#
+# Sonar 3.3
+#
+class RemoveProjectsProfileId < ActiveRecord::Migration
+
+  class Profile < ActiveRecord::Base
+    set_table_name 'rules_profiles'
+  end
+
+  class Project < ActiveRecord::Base
+    belongs_to :profile
+  end
+
+  class Property < ActiveRecord::Base
+  end
+
+  def self.up
+    projects=Project.find(:all, :conditions => ['profile_id is not null and copy_resource_id is null'], :include => :profile)
+    projects.each do |project|
+      Property.create(:prop_key => "sonar.profile.#{project.profile.language}", :text_value => project.profile.name, :resource_id => project.id)
+    end
+    remove_column('projects', 'profile_id')
+  end
+
+end
index 8674f421d4ae253bf5545c3dae7c3ffaa4f91e37..461caa5efb85c973b25a6a0148f071842d8976ff 100644 (file)
@@ -53,20 +53,6 @@ public class InheritedProfilesTest extends AbstractDbUnitTestCase {
     assertThat(profilesManager.isCycle(level2, level3), is(true));
   }
 
-  @Test
-  public void shouldNotDeleteInheritedProfile() {
-    setupData("shouldCheckCycles");
-    profilesManager.deleteProfile(1);
-    checkTables("shouldNotDeleteInheritedProfile", "rules_profiles");
-  }
-
-  @Test
-  public void shouldRenameInheritedProfile() {
-    setupData("shouldCheckCycles");
-    profilesManager.renameProfile(1, "newName");
-    checkTables("shouldRenameInheritedProfile", "rules_profiles");
-  }
-
   @Test
   public void shouldSetParent() {
     setupData("shouldSetParent");
index 917cc55bfbc6b27f00187d69bc3ba64e7f475596..162600f78712256af65e6682c70fe3e86b41a2c3 100644 (file)
@@ -21,13 +21,10 @@ package org.sonar.server.configuration;
 
 import org.junit.Before;
 import org.junit.Test;
-import org.sonar.api.database.model.ResourceModel;
 import org.sonar.api.profiles.RulesProfile;
 import org.sonar.jpa.test.AbstractDbUnitTestCase;
 
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
 
 public class ProfilesManagerTest extends AbstractDbUnitTestCase {
 
@@ -38,32 +35,6 @@ public class ProfilesManagerTest extends AbstractDbUnitTestCase {
     manager = new ProfilesManager(getSession(), null);
   }
 
-  @Test
-  public void testDeleteProfile() {
-    RulesProfile testDefaultProfile = RulesProfile.create("default", "java");
-    testDefaultProfile.setDefaultProfile(true);
-    testDefaultProfile.setProvided(true);
-    RulesProfile testProfile = RulesProfile.create("not default", "java");
-    ResourceModel testResourceWithProfile = new ResourceModel(ResourceModel.SCOPE_PROJECT, "withProfile", "TRK", null, "test");
-    testResourceWithProfile.setRulesProfile(testProfile);
-    getSession().save(testDefaultProfile, testProfile, testResourceWithProfile);
-
-    getSession().commit();
-    getSession().getEntityManager().clear();
-
-    manager.deleteProfile(testDefaultProfile.getId());
-    // default profiles cannot be deleted
-    assertNotNull(getSession().getEntity(RulesProfile.class, testDefaultProfile.getId()));
-
-    manager.deleteProfile(testProfile.getId());
-    // default profiles cannot be deleted
-    assertNull(getSession().getEntity(RulesProfile.class, testProfile.getId()));
-
-    testResourceWithProfile = getSession().getEntity(ResourceModel.class, testResourceWithProfile.getId());
-    assertNull(testResourceWithProfile.getRulesProfile());
-
-  }
-
   @Test
   public void testDeleteAllProfiles() {
     RulesProfile test1 = RulesProfile.create("test1", "java");
@@ -71,9 +42,7 @@ public class ProfilesManagerTest extends AbstractDbUnitTestCase {
     test1.setProvided(true);
     RulesProfile test2 = RulesProfile.create("test2", "java");
 
-    ResourceModel testResourceWithProfile = new ResourceModel(ResourceModel.SCOPE_PROJECT, "withProfile", "TRK", null, "test");
-    testResourceWithProfile.setRulesProfile(test1);
-    getSession().save(test1, test2, testResourceWithProfile);
+    getSession().save(test1, test2);
 
     assertEquals(new Long(2), getHQLCount(RulesProfile.class));
 
diff --git a/sonar-server/src/test/resources/org/sonar/server/configuration/InheritedProfilesTest/shouldNotDeleteInheritedProfile-result.xml b/sonar-server/src/test/resources/org/sonar/server/configuration/InheritedProfilesTest/shouldNotDeleteInheritedProfile-result.xml
deleted file mode 100644 (file)
index 5200875..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-<dataset>
-
-  <rules id="1" name="foo" description="test" plugin_config_key="checker/foo"
-         plugin_rule_key="checkstyle.rule1" plugin_name="plugin" enabled="true" cardinality="SINGLE" parent_id="[null]"/>
-
-  <rules_profiles id="1" version="1" used_profile="true" provided="false" name="level1" default_profile="0" language="java" parent_name="[null]" enabled="true"/>
-  
-  <rules_profiles id="2" version="1" used_profile="true" provided="false" name="level2" default_profile="0" language="java" parent_name="level1" enabled="true"/>
-  
-  <rules_profiles id="3" version="1" used_profile="true" provided="false" name="level3" default_profile="0" language="java" parent_name="level2" enabled="true"/>
-
-</dataset>
diff --git a/sonar-server/src/test/resources/org/sonar/server/configuration/InheritedProfilesTest/shouldRenameInheritedProfile-result.xml b/sonar-server/src/test/resources/org/sonar/server/configuration/InheritedProfilesTest/shouldRenameInheritedProfile-result.xml
deleted file mode 100644 (file)
index c7a2355..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-<dataset>
-
-  <rules id="1" name="foo" description="test" plugin_config_key="checker/foo"
-         plugin_rule_key="checkstyle.rule1" plugin_name="plugin" enabled="true" cardinality="SINGLE" parent_id="[null]"/>
-
-  <rules_profiles id="1" version="1" used_profile="true" provided="false" name="newName" default_profile="0" language="java" parent_name="[null]" enabled="true"/>
-  
-  <rules_profiles id="2" version="1" used_profile="true" provided="false" name="level2" default_profile="0" language="java" parent_name="newName" enabled="true"/>
-  
-  <rules_profiles id="3" version="1" used_profile="true" provided="false" name="level3" default_profile="0" language="java" parent_name="level2" enabled="true"/>
-
-</dataset>
index daf3a4cf609b96c40d2554bf87f833d632cc3245..73a9937f7815cd98cd5a331e46cabb0f11ede34e 100644 (file)
   <!-- Java classes -->
   <projects long_name="org.sonar.foo:File1" id="4" scope="FIL" kee="project:java:org.sonar.foo:File1" qualifier="CLA" name="File1"
             root_id="1"
-            description="[null]" enabled="true" profile_id="[null]" language="java" copy_resource_id="[null]" person_id="[null]"/>
+            description="[null]" enabled="true"  language="java" copy_resource_id="[null]" person_id="[null]"/>
 
   <projects long_name="org.sonar.foo:File2" id="5" scope="FIL" kee="project:java:org.sonar.foo:File2" qualifier="CLA" name="File2"
             root_id="1"
-            description="[null]" enabled="true" profile_id="[null]" language="java" copy_resource_id="[null]" person_id="[null]"/>
+            description="[null]" enabled="true"  language="java" copy_resource_id="[null]" person_id="[null]"/>
 
 
   <snapshots purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" period2_param="[null]" period2_date="[null]" period3_mode="[null]" period3_param="[null]" period3_date="[null]" period4_mode="[null]" period4_param="[null]" period4_date="[null]" period5_mode="[null]" period5_param="[null]" period5_date="[null]" id="5" created_at="2008-12-25 01:00:01.00" build_date="2008-12-25 01:00:01.00" version="1.0" project_id="4" scope="FIL" qualifier="CLA"
index 03e194f11aa739c952fcaff89f0240f200dc1a30..cdb51032ca98c77ddf60d5ddf867259fe8997f7e 100644 (file)
@@ -1,15 +1,15 @@
 <dataset>
   <projects long_name="java project" id="1" scope="PRJ" kee="project:java" qualifier="TRK" name="java project"
             root_id="[null]"
-            description="[null]" enabled="true" profile_id="[null]" language="java" copy_resource_id="[null]" person_id="[null]"/>
+            description="[null]" enabled="true"  language="java" copy_resource_id="[null]" person_id="[null]"/>
 
   <projects long_name="php project" id="2" scope="PRJ" kee="project:a-php-project" qualifier="TRK" name="php project"
             root_id="[null]"
-            description="[null]" enabled="true" profile_id="[null]" language="php" copy_resource_id="[null]" person_id="[null]"/>
+            description="[null]" enabled="true"  language="php" copy_resource_id="[null]" person_id="[null]"/>
 
   <projects long_name="org.sonar.foo" id="3" scope="DIR" kee="project:java:org.sonar.foo" qualifier="PAC" name="org.sonar.foo"
             root_id="1"
-            description="[null]" enabled="true" profile_id="[null]" language="java" copy_resource_id="[null]" person_id="[null]"/>
+            description="[null]" enabled="true"  language="java" copy_resource_id="[null]" person_id="[null]"/>
 
 
   <!-- Java project -->
index aac9b0863b0bbb8ea17e0d789d35a8e967f5b964..2b6a20367172b649f8d3c509750e1db95d159cb2 100644 (file)
@@ -2,21 +2,21 @@
   <!-- java project -->
   <projects long_name="java project" id="1" scope="PRJ" kee="project:java" qualifier="TRK" name="java project"
             root_id="[null]"
-            description="[null]" enabled="true" profile_id="[null]" language="java" copy_resource_id="[null]" person_id="[null]"/>
+            description="[null]" enabled="true"  language="java" copy_resource_id="[null]" person_id="[null]"/>
 
   <!-- views -->
   <projects long_name="Root view" id="2" scope="PRJ" kee="ROOT_VIEW" qualifier="VW" name="Root view"
             root_id="[null]"
-            description="[null]" enabled="true" profile_id="[null]" language="[null]" copy_resource_id="[null]" person_id="[null]"/>
+            description="[null]" enabled="true"  language="[null]" copy_resource_id="[null]" person_id="[null]"/>
 
   <projects long_name="Sub view" id="3" scope="PRJ" kee="SUB_VIEW" qualifier="SVW" name="Sub view"
             root_id="2"
-            description="[null]" enabled="true" profile_id="[null]" language="[null]" copy_resource_id="[null]" person_id="[null]"/>
+            description="[null]" enabled="true"  language="[null]" copy_resource_id="[null]" person_id="[null]"/>
 
   <!-- java project copy used in view -->
   <projects long_name="java project" id="4" scope="FIL" kee="cp-project:java" qualifier="TRK" name="java project"
             root_id="2"
-            description="[null]" enabled="true" profile_id="[null]" language="java" copy_resource_id="1"/>
+            description="[null]" enabled="true"  language="java" copy_resource_id="1"/>
 
 
   <!-- snapshots -->