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
project=Project
projects=Projects
raw=Raw
+remove=Remove
rename=Rename
reset_verb=Reset
result=Result
unselect_verb=Unselect
updated=Updated
update_verb=Update
+updating=Updating
user=User
value=Value
variation=Variation
violations=Violations
+
#------------------------------------------------------------------------------
#
# GENERIC EXPRESSIONS, sorted alphabetically
# 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
#------------------------------------------------------------------------------
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.
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
#------------------------------------------------------------------------------
#
<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=""
<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]"
<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"
<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"
*/
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;
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) {
// hack to lazy initialize the profile collections
profile.getActiveRules().size();
+
for (ActiveRule activeRule : profile.getActiveRules()) {
activeRule.getActiveRuleParams().size();
activeRule.getRule().getParams().size();
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;
}
.setAnalysisDate(analysisDate)
.setLatestAnalysis(isLatestAnalysis(project.getKey(), analysisDate))
.setAnalysisVersion(loadAnalysisVersion())
- .setAnalysisType(loadAnalysisType())
- .setLanguageKey(loadLanguageKey());
+ .setAnalysisType(loadAnalysisType());
return this;
}
}
Date loadAnalysisDate() {
- Date date = null;
+ Date date;
try {
// sonar.projectDate may have been specified as a time
date = settings.getDateTime(CoreProperties.PROJECT_DATE_PROPERTY);
String loadAnalysisVersion() {
return settings.getString(CoreProperties.PROJECT_VERSION_PROPERTY);
}
-
- String loadLanguageKey() {
- return StringUtils.defaultIfBlank(settings.getString(CoreProperties.PROJECT_LANGUAGE_PROPERTY), Java.KEY);
- }
}
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;
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() {
*/
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);
}
}
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");
<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 -->
<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>
<!-- 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=""
<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]"
<!-- 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=""
<!-- 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=""
<!-- 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=""
<!-- 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]"
<!-- 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]" />
<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=""
<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]"
<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=""
<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=""
<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=""
*/
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
private String language;
private Long copyResourceId;
private Long personId;
- private Long profileId;
private Date createdAt;
public Long getId() {
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
}
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 {
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);
}
}
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;
"QUALIFIER" VARCHAR(10),
"KEE" VARCHAR(400),
"ROOT_ID" INTEGER,
- "PROFILE_ID" INTEGER,
"LANGUAGE" VARCHAR(5),
"COPY_RESOURCE_ID" INTEGER,
"LONG_NAME" VARCHAR(256),
<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>
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 {
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");
}
}
<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]"
<!-- 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"
<!-- 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"
<!-- 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"
<!-- 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"
<!-- 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]"
<!-- 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]"
<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]"
<!-- 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]"
<!-- 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]"
<!-- 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]"
<!-- 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 -->
<!-- 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 -->
<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>
<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>
<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>
<!-- 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>
<!-- 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>
<!-- 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>
<!-- 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>
<!-- 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>
<!-- 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>
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;
@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
*/
this.rootId = rootId;
}
- public RulesProfile getRulesProfile() {
- return rulesProfile;
- }
-
- public void setRulesProfile(RulesProfile rulesProfile) {
- this.rulesProfile = rulesProfile;
- }
-
public String getQualifier() {
return qualifier;
}
clone.setDescription(getDescription());
clone.setEnabled(getEnabled());
clone.setProjectLinks(getProjectLinks());
- clone.setRulesProfile(getRulesProfile());
clone.setLanguageKey(getLanguageKey());
clone.setCopyResourceId(getCopyResourceId());
clone.setLongName(getLongName());
@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()
*/
this.language = language;
this.activeRules = Lists.newArrayList();
this.alerts = Lists.newArrayList();
- this.projects = Lists.newArrayList();
}
/**
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.
*
}
})));
}
- 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;
}
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;
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();
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);
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);
}
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
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|
# 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
# 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(' ', '_')
# 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
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
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')
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?
#
#
def permalinks
+ require_parameters 'id'
@profile = Profile.find(params[:id])
end
#
#
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
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])
# 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}
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
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
# * <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]
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
def self.java_facade
Java::OrgSonarServerUi::JRubyFacade.getInstance()
end
+
+ def self.languages
+ java_facade.getLanguages()
+ end
end
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
end
def warnings?
- not warnings.empty?
+ !warnings.empty?
end
def notices
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
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]
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?
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
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)
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
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'
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)
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
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
<% 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>
<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>
<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">
</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>
<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] -%>
<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',
-<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 -%> »</button><br/>
- <button id="select_right_all" onclick="SelectBox.move_all('from', 'to');return false;"><%= message('select_all').downcase -%> »</button><br/><br/>
- <button id="select_left" onclick="SelectBox.move('to', 'from');return false;">« <%= message('unselect_verb').downcase -%></button><br/>
- <button id="select_left_all" onclick="SelectBox.move_all('to', 'from');return false;">« <%= 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
--- /dev/null
+<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>
+++ /dev/null
-<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 %>
--- /dev/null
+#
+# 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
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");
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 {
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");
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));
+++ /dev/null
-<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>
+++ /dev/null
-<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>
<!-- 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"
<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 -->
<!-- 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 -->