aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@sonarsource.com>2013-12-02 12:29:58 +0100
committerJulien Lancelot <julien.lancelot@sonarsource.com>2013-12-02 14:44:37 +0100
commit211f8bbf72b8c4d50b0493db8b995f922b1d470d (patch)
tree0b3d701569ca6cc23c80e16ff06f96e5bfde792b
parent11ce39d38a3cba818285a6e373db2cdb3a76a05d (diff)
downloadsonarqube-211f8bbf72b8c4d50b0493db8b995f922b1d470d.tar.gz
sonarqube-211f8bbf72b8c4d50b0493db8b995f922b1d470d.zip
SONAR-4891 Remove useless characteristics columns and tables
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/bootstrap/BootstrapContainer.java18
-rw-r--r--sonar-core/src/main/java/org/sonar/core/persistence/DatabaseVersion.java5
-rw-r--r--sonar-core/src/main/java/org/sonar/core/persistence/PreviewDatabaseFactory.java3
-rw-r--r--sonar-core/src/main/java/org/sonar/core/qualitymodel/DefaultModelFinder.java40
-rw-r--r--sonar-core/src/main/resources/META-INF/persistence.xml3
-rw-r--r--sonar-core/src/main/resources/org/sonar/core/persistence/rows-h2.sql1
-rw-r--r--sonar-core/src/main/resources/org/sonar/core/persistence/schema-h2.ddl23
-rw-r--r--sonar-core/src/test/java/org/sonar/core/qualitymodel/DefaultModelFinderTest.java46
-rw-r--r--sonar-core/src/test/java/org/sonar/core/qualitymodel/ModelTest.java101
-rw-r--r--sonar-core/src/test/resources/org/sonar/core/purge/PurgeCommandsTest/shouldDeleteWastedMeasuresWhenPurgingSnapshot-result.xml27
-rw-r--r--sonar-core/src/test/resources/org/sonar/core/purge/PurgeCommandsTest/shouldDeleteWastedMeasuresWhenPurgingSnapshot.xml25
-rw-r--r--sonar-core/src/test/resources/org/sonar/core/qualitymodel/DefaultModelFinderTest/shared.xml8
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/qualitymodel/Characteristic.java369
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/qualitymodel/CharacteristicProperty.java110
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/qualitymodel/Model.java227
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/qualitymodel/ModelDefinition.java70
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/qualitymodel/ModelFinder.java35
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/qualitymodel/CharacteristicPropertyTest.java55
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/qualitymodel/CharacteristicTest.java80
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/qualitymodel/ModelTest.java85
-rw-r--r--sonar-server/src/main/java/org/sonar/server/platform/Platform.java3
-rw-r--r--sonar-server/src/main/java/org/sonar/server/startup/VerifyNoQualityModelsAreDefined.java47
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/models/characteristic.rb8
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/models/quality_model.rb24
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/db/migrate/464_remove_useless_characteristics_data.rb (renamed from sonar-server/src/main/webapp/WEB-INF/app/models/characteristic_property.rb)34
-rw-r--r--sonar-server/src/test/java/org/sonar/server/startup/VerifyNoQualityModelsAreDefinedTest.java49
26 files changed, 80 insertions, 1416 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BootstrapContainer.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BootstrapContainer.java
index 502c092e8dc..29e0148ba59 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BootstrapContainer.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BootstrapContainer.java
@@ -27,24 +27,13 @@ import org.sonar.api.platform.PluginMetadata;
import org.sonar.api.utils.HttpDownloader;
import org.sonar.api.utils.UriReader;
import org.sonar.api.utils.internal.TempFolderCleaner;
-import org.sonar.batch.components.PastMeasuresLoader;
-import org.sonar.batch.components.PastSnapshotFinder;
-import org.sonar.batch.components.PastSnapshotFinderByDate;
-import org.sonar.batch.components.PastSnapshotFinderByDays;
-import org.sonar.batch.components.PastSnapshotFinderByPreviousAnalysis;
-import org.sonar.batch.components.PastSnapshotFinderByPreviousVersion;
-import org.sonar.batch.components.PastSnapshotFinderByVersion;
+import org.sonar.batch.components.*;
import org.sonar.core.config.Logback;
import org.sonar.core.i18n.I18nManager;
import org.sonar.core.i18n.RuleI18nManager;
import org.sonar.core.metric.CacheMetricFinder;
-import org.sonar.core.persistence.DaoUtils;
-import org.sonar.core.persistence.DatabaseVersion;
-import org.sonar.core.persistence.MyBatis;
-import org.sonar.core.persistence.SemaphoreUpdater;
-import org.sonar.core.persistence.SemaphoresImpl;
+import org.sonar.core.persistence.*;
import org.sonar.core.purge.PurgeProfiler;
-import org.sonar.core.qualitymodel.DefaultModelFinder;
import org.sonar.core.rule.CacheRuleFinder;
import org.sonar.core.user.HibernateUserFinder;
import org.sonar.jpa.dao.MeasuresDao;
@@ -134,8 +123,7 @@ public class BootstrapContainer extends ComponentContainer {
PastSnapshotFinderByVersion.class,
PastSnapshotFinderByPreviousVersion.class,
PastMeasuresLoader.class,
- PastSnapshotFinder.class,
- DefaultModelFinder.class);
+ PastSnapshotFinder.class);
}
@Override
diff --git a/sonar-core/src/main/java/org/sonar/core/persistence/DatabaseVersion.java b/sonar-core/src/main/java/org/sonar/core/persistence/DatabaseVersion.java
index 55787c8b7fb..caa95eeab07 100644
--- a/sonar-core/src/main/java/org/sonar/core/persistence/DatabaseVersion.java
+++ b/sonar-core/src/main/java/org/sonar/core/persistence/DatabaseVersion.java
@@ -33,7 +33,7 @@ import java.util.List;
*/
public class DatabaseVersion implements BatchComponent, ServerComponent {
- public static final int LAST_VERSION = 463;
+ public static final int LAST_VERSION = 464;
public static enum Status {
UP_TO_DATE, REQUIRES_UPGRADE, REQUIRES_DOWNGRADE, FRESH_INSTALL
@@ -54,8 +54,6 @@ public class DatabaseVersion implements BatchComponent, ServerComponent {
"alerts",
"authors",
"characteristics",
- "characteristic_edges",
- "characteristic_properties",
"dashboards",
"dependencies",
"duplications_index",
@@ -82,7 +80,6 @@ public class DatabaseVersion implements BatchComponent, ServerComponent {
"project_links",
"project_measures",
"properties",
- "quality_models",
"resource_index",
"rules",
"rules_parameters",
diff --git a/sonar-core/src/main/java/org/sonar/core/persistence/PreviewDatabaseFactory.java b/sonar-core/src/main/java/org/sonar/core/persistence/PreviewDatabaseFactory.java
index 032a58d3e3b..4aab0b4b547 100644
--- a/sonar-core/src/main/java/org/sonar/core/persistence/PreviewDatabaseFactory.java
+++ b/sonar-core/src/main/java/org/sonar/core/persistence/PreviewDatabaseFactory.java
@@ -85,13 +85,10 @@ public class PreviewDatabaseFactory implements ServerComponent {
.copyTable(source, dest, "active_rules")
.copyTable(source, dest, "active_rule_parameters")
.copyTable(source, dest, "characteristics")
- .copyTable(source, dest, "characteristic_edges")
- .copyTable(source, dest, "characteristic_properties")
.copyTable(source, dest, "metrics")
.copyTable(source, dest, "permission_templates")
.copyTable(source, dest, "perm_templates_users")
.copyTable(source, dest, "perm_templates_groups")
- .copyTable(source, dest, "quality_models")
.copyTable(source, dest, "rules")
.copyTable(source, dest, "rules_parameters")
.copyTable(source, dest, "rules_profiles")
diff --git a/sonar-core/src/main/java/org/sonar/core/qualitymodel/DefaultModelFinder.java b/sonar-core/src/main/java/org/sonar/core/qualitymodel/DefaultModelFinder.java
deleted file mode 100644
index ebf3690ef10..00000000000
--- a/sonar-core/src/main/java/org/sonar/core/qualitymodel/DefaultModelFinder.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2013 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube 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.
- *
- * SonarQube 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 this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.core.qualitymodel;
-
-import org.sonar.api.database.DatabaseSession;
-import org.sonar.api.qualitymodel.Model;
-import org.sonar.api.qualitymodel.ModelFinder;
-import org.sonar.jpa.session.DatabaseSessionFactory;
-
-public class DefaultModelFinder implements ModelFinder {
-
- private DatabaseSessionFactory sessionFactory;
-
- public DefaultModelFinder(DatabaseSessionFactory sessionFactory) {
- this.sessionFactory = sessionFactory;
- }
-
- public Model findByName(String name) {
- DatabaseSession session = sessionFactory.getSession();
- return session.getSingleResult(Model.class, "name", name);
- }
-
-}
diff --git a/sonar-core/src/main/resources/META-INF/persistence.xml b/sonar-core/src/main/resources/META-INF/persistence.xml
index 0cf0c2f31c8..63c5ae34869 100644
--- a/sonar-core/src/main/resources/META-INF/persistence.xml
+++ b/sonar-core/src/main/resources/META-INF/persistence.xml
@@ -9,9 +9,6 @@
<class>org.sonar.jpa.entity.SchemaMigration</class>
<class>org.sonar.jpa.entity.ManualMeasure</class>
<class>org.sonar.api.database.configuration.Property</class>
- <class>org.sonar.api.qualitymodel.Model</class>
- <class>org.sonar.api.qualitymodel.Characteristic</class>
- <class>org.sonar.api.qualitymodel.CharacteristicProperty</class>
<class>org.sonar.api.database.model.User</class>
<class>org.sonar.api.database.model.Snapshot</class>
<class>org.sonar.api.database.model.MeasureModel</class>
diff --git a/sonar-core/src/main/resources/org/sonar/core/persistence/rows-h2.sql b/sonar-core/src/main/resources/org/sonar/core/persistence/rows-h2.sql
index 5c68dd607c0..7c25b9f59fb 100644
--- a/sonar-core/src/main/resources/org/sonar/core/persistence/rows-h2.sql
+++ b/sonar-core/src/main/resources/org/sonar/core/persistence/rows-h2.sql
@@ -187,6 +187,7 @@ INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('460');
INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('461');
INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('462');
INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('463');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('464');
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;
diff --git a/sonar-core/src/main/resources/org/sonar/core/persistence/schema-h2.ddl b/sonar-core/src/main/resources/org/sonar/core/persistence/schema-h2.ddl
index 1abb68dedc5..d10f1505036 100644
--- a/sonar-core/src/main/resources/org/sonar/core/persistence/schema-h2.ddl
+++ b/sonar-core/src/main/resources/org/sonar/core/persistence/schema-h2.ddl
@@ -3,21 +3,11 @@
-- Initially this file has been generated from existing H2 DB
-- Should be updated manually, during addition of new migrations
-CREATE TABLE "QUALITY_MODELS" (
- "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
- "NAME" VARCHAR(100)
-);
-
CREATE TABLE "GROUPS_USERS" (
"USER_ID" INTEGER,
"GROUP_ID" INTEGER
);
-CREATE TABLE "CHARACTERISTIC_EDGES" (
- "CHILD_ID" INTEGER,
- "PARENT_ID" INTEGER
-);
-
CREATE TABLE "DEPENDENCIES" (
"ID" BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
"FROM_SNAPSHOT_ID" INTEGER,
@@ -34,10 +24,8 @@ CREATE TABLE "DEPENDENCIES" (
CREATE TABLE "CHARACTERISTICS" (
"ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
- "QUALITY_MODEL_ID" INTEGER,
"KEE" VARCHAR(100),
"NAME" VARCHAR(100),
- "DESCRIPTION" VARCHAR(4000),
"PARENT_ID" INTEGER,
"ROOT_ID" INTEGER,
"RULE_ID" INTEGER,
@@ -47,7 +35,6 @@ CREATE TABLE "CHARACTERISTICS" (
"OFFSET_VALUE" DOUBLE,
"OFFSET_UNIT" VARCHAR(100),
"CHARACTERISTIC_ORDER" INTEGER,
- "DEPTH" INTEGER,
"ENABLED" BOOLEAN,
"CREATED_AT" TIMESTAMP,
"UPDATED_AT" TIMESTAMP
@@ -327,14 +314,6 @@ CREATE TABLE "ACTIVE_RULE_PARAMETERS" (
"VALUE" VARCHAR(4000)
);
-CREATE TABLE "CHARACTERISTIC_PROPERTIES" (
- "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
- "CHARACTERISTIC_ID" INTEGER,
- "KEE" VARCHAR(100),
- "VALUE" DOUBLE,
- "TEXT_VALUE" VARCHAR(4000)
-);
-
CREATE TABLE "USERS" (
"ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
"LOGIN" VARCHAR(40),
@@ -604,8 +583,6 @@ CREATE INDEX "MEASURES_SID_METRIC" ON "PROJECT_MEASURES" ("SNAPSHOT_ID", "METRIC
CREATE INDEX "ACTIVE_RULE_CHANGES_PID" ON "ACTIVE_RULE_CHANGES" ("PROFILE_ID");
-CREATE INDEX "CHARACTERISTIC_PROPERTIES_CID" ON "CHARACTERISTIC_PROPERTIES" ("CHARACTERISTIC_ID");
-
CREATE UNIQUE INDEX "METRICS_UNIQUE_NAME" ON "METRICS" ("NAME");
CREATE INDEX "ACTIVE_RULE_PARAM_CHANGES_CID" ON "ACTIVE_RULE_PARAM_CHANGES" ("ACTIVE_RULE_CHANGE_ID");
diff --git a/sonar-core/src/test/java/org/sonar/core/qualitymodel/DefaultModelFinderTest.java b/sonar-core/src/test/java/org/sonar/core/qualitymodel/DefaultModelFinderTest.java
deleted file mode 100644
index 841c6a5027f..00000000000
--- a/sonar-core/src/test/java/org/sonar/core/qualitymodel/DefaultModelFinderTest.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2013 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube 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.
- *
- * SonarQube 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 this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.core.qualitymodel;
-
-import org.junit.Test;
-import org.sonar.api.qualitymodel.Model;
-import org.sonar.jpa.test.AbstractDbUnitTestCase;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-
-public class DefaultModelFinderTest extends AbstractDbUnitTestCase {
-
- @Test
- public void findByName() {
- setupData("shared");
- DefaultModelFinder provider = new DefaultModelFinder(getSessionFactory());
- Model model = provider.findByName("M1");
- assertNotNull(model);
- assertNotNull(model.getCharacteristicByName("M1C1"));
- }
-
- @Test
- public void findByNameNotFound() {
- setupData("shared");
- DefaultModelFinder provider = new DefaultModelFinder(getSessionFactory());
- assertNull(provider.findByName("UNKNOWN"));
- }
-}
diff --git a/sonar-core/src/test/java/org/sonar/core/qualitymodel/ModelTest.java b/sonar-core/src/test/java/org/sonar/core/qualitymodel/ModelTest.java
deleted file mode 100644
index 4febd3e8139..00000000000
--- a/sonar-core/src/test/java/org/sonar/core/qualitymodel/ModelTest.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2013 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube 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.
- *
- * SonarQube 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 this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.core.qualitymodel;
-
-import org.junit.Test;
-import org.sonar.api.qualitymodel.Characteristic;
-import org.sonar.api.qualitymodel.Model;
-import org.sonar.jpa.test.AbstractDbUnitTestCase;
-
-import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.*;
-import static org.junit.internal.matchers.IsCollectionContaining.hasItems;
-
-public class ModelTest extends AbstractDbUnitTestCase {
-
- @Test
- public void saveModelAndCharacteristics() {
- Model model = Model.createByName("fake");
- model.createCharacteristicByName("Efficiency");
- model.createCharacteristicByName("Usability");
- getSession().save(model);
- getSession().commit();
-
- model = getSession().getSingleResult(Model.class, "name", "fake");
- assertThat(model.getName(), is("fake"));
- assertThat(model.getCharacteristics().size(), is(2));
- assertThat(model.getRootCharacteristics().size(), is(2));
- assertNotNull(model.getCharacteristicByName("Efficiency"));
- }
-
- /**
- * max one parent by characteristic
- */
- @Test
- public void saveTreeOfCharacteristics() {
- Model model = Model.createByName("fake");
-
- Characteristic efficiency = model.createCharacteristicByName("Efficiency");
- Characteristic usability = model.createCharacteristicByName("Usability");
- Characteristic cpuEfficiency = model.createCharacteristicByName("CPU Efficiency");
- Characteristic ramEfficiency = model.createCharacteristicByName("RAM Efficiency");
-
- efficiency.addChildren(cpuEfficiency, ramEfficiency);
-
- getSession().save(model);
- getSession().commit();
-
- model = getSession().getSingleResult(Model.class, "name", "fake");
- assertThat(model.getCharacteristics().size(), is(4));
- assertThat(model.getCharacteristics(), hasItems(efficiency, usability, ramEfficiency, cpuEfficiency));
- assertThat(efficiency.getChildren(), hasItems(ramEfficiency, cpuEfficiency));
- assertTrue(ramEfficiency.getChildren().isEmpty());
- assertThat(ramEfficiency.getParents(), hasItems(efficiency));
- }
-
- /**
- * many-to-many relation between characteristics
- */
- @Test
- public void testGraphOfCharacteristics() {
- Model model = Model.createByName("fake");
-
- Characteristic level1a = model.createCharacteristicByName("level1a");
- Characteristic level1b = model.createCharacteristicByName("level1b");
- Characteristic level2a = model.createCharacteristicByName("level2a");
- Characteristic level2b = model.createCharacteristicByName("level2b");
-
- level1a.addChildren(level2a, level2b);
- level1b.addChildren(level2a, level2b);
-
- getSession().save(model);
- getSession().commit();
-
- Model persistedModel = getSession().getSingleResult(Model.class, "name", "fake");
- assertThat(persistedModel.getCharacteristics().size(), is(4));
- assertThat(persistedModel.getRootCharacteristics().size(), is(2));
-
- assertThat(persistedModel.getCharacteristicByName("level1a").getChildren().size(), is(2));
- assertThat(persistedModel.getCharacteristicByName("level1b").getChildren().size(), is(2));
-
- assertThat(persistedModel.getCharacteristicByName("level2a").getParents().size(), is(2));
- assertThat(persistedModel.getCharacteristicByName("level2b").getParents().size(), is(2));
- }
-}
diff --git a/sonar-core/src/test/resources/org/sonar/core/purge/PurgeCommandsTest/shouldDeleteWastedMeasuresWhenPurgingSnapshot-result.xml b/sonar-core/src/test/resources/org/sonar/core/purge/PurgeCommandsTest/shouldDeleteWastedMeasuresWhenPurgingSnapshot-result.xml
index 6f524778bae..ef9c9433014 100644
--- a/sonar-core/src/test/resources/org/sonar/core/purge/PurgeCommandsTest/shouldDeleteWastedMeasuresWhenPurgingSnapshot-result.xml
+++ b/sonar-core/src/test/resources/org/sonar/core/purge/PurgeCommandsTest/shouldDeleteWastedMeasuresWhenPurgingSnapshot-result.xml
@@ -10,10 +10,9 @@
worst_value="0" optimized_best_value="[true]" best_value="100"
direction="1" hidden="[false]"/>
- <characteristics id="1" kee="M1C1" name="M1C1" quality_model_id="1" rule_id="[null]" characteristic_order="1"
- depth="1" description="[null]" enabled="[true]"/>
- <characteristics id="2" kee="M1C2" name="M1C2" quality_model_id="1" rule_id="333" characteristic_order="1"
- depth="2" description="[null]" enabled="[true]"/>
+ <characteristics id="1" kee="M1C1" name="M1C1" parent_id="[null]" root_id="[null]" rule_id="[null]" characteristic_order="1" enabled="[true]"/>
+ <characteristics id="2" kee="M1C2" name="M1C1" parent_id="1" root_id="1" rule_id="[null]" characteristic_order="[null]" enabled="[true]"/>
+ <characteristics id="3" kee="M1C3" name="M1C3" parent_id="2" root_id="1" rule_id="333" characteristic_order="[null]" enabled="[true]"/>
<snapshots id="1"
project_id="1" parent_snapshot_id="[null]" root_project_id="1" root_snapshot_id="[null]"
@@ -46,7 +45,7 @@
text_value="[null]" tendency="[null]" measure_date="[null]" alert_status="[null]"
description="[null]"/>-->
- <!-- do not delete measure on quality model characteristic -->
+ <!-- do not delete measure on characteristic -->
<project_measures id="3" project_id="1" snapshot_id="1" rule_id="[null]" characteristic_id="1" metric_id="1"
url="[null]" variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[null]"
variation_value_4="[null]"
@@ -56,8 +55,18 @@
text_value="[null]" tendency="[null]" measure_date="[null]" alert_status="[null]"
description="[null]"/>
- <!-- delete measure on quality model requirement -->
- <!--<project_measures ID="4" project_id="1" SNAPSHOT_ID="1" RULE_ID="[null]" characteristic_id="2" METRIC_ID="1"
+ <!-- do not delete measure on characteristic -->
+ <project_measures id="4" project_id="1" snapshot_id="1" rule_id="[null]" characteristic_id="2" metric_id="1"
+ url="[null]" variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[null]"
+ variation_value_4="[null]"
+ variation_value_5="[null]" rule_priority="[null]" alert_text="[null]" value="10.0"
+ rules_category_id="[null]"
+ person_id="[null]"
+ text_value="[null]" tendency="[null]" measure_date="[null]" alert_status="[null]"
+ description="[null]"/>
+
+ <!-- delete measure on requirement -->
+ <!--<project_measures ID="5" project_id="1" SNAPSHOT_ID="1" RULE_ID="[null]" characteristic_id="2" METRIC_ID="1"
url="[null]" variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[null]"
variation_value_4="[null]"
variation_value_5="[null]" rule_priority="[null]" alert_text="[null]" VALUE="10.0"
@@ -67,7 +76,7 @@
description="[null]"/>-->
<!-- delete measure on metrics that are flagged with delete_historical_data=true -->
- <!--<project_measures ID="5" project_id="1" SNAPSHOT_ID="1" RULE_ID="[null]" characteristic_id="[null]" METRIC_ID="2"
+ <!--<project_measures ID="6" project_id="1" SNAPSHOT_ID="1" RULE_ID="[null]" characteristic_id="[null]" METRIC_ID="2"
url="[null]" variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[null]"
variation_value_4="[null]"
variation_value_5="[null]" rule_priority="[null]" alert_text="[null]" VALUE="10.0"
@@ -77,7 +86,7 @@
description="[null]"/>-->
<!-- delete measure on developers -->
- <!--<project_measures id="6" project_id="1" snapshot_id="1" rule_id="[null]" characteristic_id="[null]" metric_id="2"
+ <!--<project_measures id="7" project_id="1" snapshot_id="1" rule_id="[null]" characteristic_id="[null]" metric_id="2"
url="[null]" variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[null]"
person_id="123456"
variation_value_4="[null]"
diff --git a/sonar-core/src/test/resources/org/sonar/core/purge/PurgeCommandsTest/shouldDeleteWastedMeasuresWhenPurgingSnapshot.xml b/sonar-core/src/test/resources/org/sonar/core/purge/PurgeCommandsTest/shouldDeleteWastedMeasuresWhenPurgingSnapshot.xml
index 78c9a13bb76..3321a4d8cf8 100644
--- a/sonar-core/src/test/resources/org/sonar/core/purge/PurgeCommandsTest/shouldDeleteWastedMeasuresWhenPurgingSnapshot.xml
+++ b/sonar-core/src/test/resources/org/sonar/core/purge/PurgeCommandsTest/shouldDeleteWastedMeasuresWhenPurgingSnapshot.xml
@@ -10,10 +10,9 @@
worst_value="0" optimized_best_value="[true]" best_value="100"
direction="1" hidden="[false]"/>
- <characteristics id="1" kee="M1C1" name="M1C1" quality_model_id="1" rule_id="[null]" characteristic_order="1"
- depth="1" description="[null]" enabled="[true]"/>
- <characteristics id="2" kee="M1C2" name="M1C2" quality_model_id="1" rule_id="333" characteristic_order="1"
- depth="2" description="[null]" enabled="[true]"/>
+ <characteristics id="1" kee="M1C1" name="M1C1" parent_id="[null]" root_id="[null]" rule_id="[null]" characteristic_order="1" enabled="[true]"/>
+ <characteristics id="2" kee="M1C2" name="M1C1" parent_id="1" root_id="1" rule_id="[null]" characteristic_order="[null]" enabled="[true]"/>
+ <characteristics id="3" kee="M1C3" name="M1C3" parent_id="2" root_id="1" rule_id="333" characteristic_order="[null]" enabled="[true]"/>
<snapshots id="1"
project_id="1" parent_snapshot_id="[null]" root_project_id="1" root_snapshot_id="[null]"
@@ -46,7 +45,7 @@
text_value="[null]" tendency="[null]" measure_date="[null]" alert_status="[null]"
description="[null]"/>
- <!-- do not delete measure on quality model characteristic -->
+ <!-- do not delete measure on root characteristic -->
<project_measures id="3" project_id="1" snapshot_id="1" rule_id="[null]" characteristic_id="1" metric_id="1"
url="[null]" variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[null]"
variation_value_4="[null]"
@@ -56,7 +55,7 @@
text_value="[null]" tendency="[null]" measure_date="[null]" alert_status="[null]"
description="[null]"/>
- <!-- delete measure on quality model requirement -->
+ <!-- do not delete measure on characteristic -->
<project_measures id="4" project_id="1" snapshot_id="1" rule_id="[null]" characteristic_id="2" metric_id="1"
url="[null]" variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[null]"
variation_value_4="[null]"
@@ -66,8 +65,18 @@
text_value="[null]" tendency="[null]" measure_date="[null]" alert_status="[null]"
description="[null]"/>
+ <!-- delete measure on requirement -->
+ <project_measures id="5" project_id="1" snapshot_id="1" rule_id="[null]" characteristic_id="3" metric_id="1"
+ url="[null]" variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[null]"
+ variation_value_4="[null]"
+ variation_value_5="[null]" rule_priority="[null]" alert_text="[null]" value="10.0"
+ rules_category_id="[null]"
+ person_id="[null]"
+ text_value="[null]" tendency="[null]" measure_date="[null]" alert_status="[null]"
+ description="[null]"/>
+
<!-- delete measure on metrics that are flagged with delete_historical_data=true -->
- <project_measures id="5" project_id="1" snapshot_id="1" rule_id="[null]" characteristic_id="[null]" metric_id="2"
+ <project_measures id="6" project_id="1" snapshot_id="1" rule_id="[null]" characteristic_id="[null]" metric_id="2"
url="[null]" variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[null]"
variation_value_4="[null]"
variation_value_5="[null]" rule_priority="[null]" alert_text="[null]" value="10.0"
@@ -77,7 +86,7 @@
description="[null]"/>
<!-- delete measure on developers -->
- <project_measures id="6" project_id="1" snapshot_id="1" rule_id="[null]" characteristic_id="[null]" metric_id="2"
+ <project_measures id="7" project_id="1" snapshot_id="1" rule_id="[null]" characteristic_id="[null]" metric_id="2"
url="[null]" variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[null]"
person_id="123456"
variation_value_4="[null]"
diff --git a/sonar-core/src/test/resources/org/sonar/core/qualitymodel/DefaultModelFinderTest/shared.xml b/sonar-core/src/test/resources/org/sonar/core/qualitymodel/DefaultModelFinderTest/shared.xml
index c26de5371bb..a55ec8060f6 100644
--- a/sonar-core/src/test/resources/org/sonar/core/qualitymodel/DefaultModelFinderTest/shared.xml
+++ b/sonar-core/src/test/resources/org/sonar/core/qualitymodel/DefaultModelFinderTest/shared.xml
@@ -2,9 +2,9 @@
<quality_models id="1" name="M1" />
<quality_models id="2" name="M2" />
- <characteristics id="1" kee="M1C1" name="M1C1" quality_model_id="1" rule_id="[null]" characteristic_order="1" depth="1" description="[null]" enabled="true" />
- <characteristics id="2" kee="M1C2" name="M1C2" quality_model_id="1" rule_id="[null]" characteristic_order="1" depth="2" description="[null]" enabled="true" />
- <characteristics id="3" kee="M2C1" name="M2C1" quality_model_id="2" rule_id="[null]" characteristic_order="1" depth="1" description="[null]" enabled="true"/>
+ <characteristics id="1" kee="M1C1" name="M1C1" parent_id="[null]" root_id="[null]" rule_id="[null]" characteristic_order="1" enabled="true" />
+ <characteristics id="2" kee="M1C2" name="M1C2" parent_id="[null]" root_id="[null]" ule_id="[null]" characteristic_order="1" enabled="true" />
+ <characteristics id="3" kee="M2C1" name="M2C1" parent_id="[null]" root_id="[null]" rule_id="[null]" characteristic_order="1" enabled="true"/>
<characteristic_edges child_id="2" parent_id="1"/>
-</dataset> \ No newline at end of file
+</dataset>
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/qualitymodel/Characteristic.java b/sonar-plugin-api/src/main/java/org/sonar/api/qualitymodel/Characteristic.java
deleted file mode 100644
index 474b7509e34..00000000000
--- a/sonar-plugin-api/src/main/java/org/sonar/api/qualitymodel/Characteristic.java
+++ /dev/null
@@ -1,369 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2013 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube 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.
- *
- * SonarQube 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 this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.api.qualitymodel;
-
-import com.google.common.collect.Lists;
-import org.apache.commons.lang.StringUtils;
-import org.apache.commons.lang.builder.ToStringBuilder;
-import org.apache.commons.lang.builder.ToStringStyle;
-import org.hibernate.annotations.Sort;
-import org.hibernate.annotations.SortType;
-import org.sonar.api.rules.Rule;
-
-import javax.persistence.*;
-
-import java.util.Collections;
-import java.util.List;
-
-/**
- * @since 2.3
- */
-@Entity
-@Table(name = "characteristics")
-public final class Characteristic implements Comparable<Characteristic> {
-
- public static final int ROOT_DEPTH = 1;
-
- @Id
- @Column(name = "id")
- @GeneratedValue
- private Integer id;
-
- @Column(name = "kee", nullable = true, length = 100)
- private String key;
-
- @Column(name = "name", nullable = true, length = 100)
- private String name;
-
- @Column(name = "depth")
- private int depth = ROOT_DEPTH;
-
- @Column(name = "characteristic_order")
- private int order = 0;
-
- @ManyToOne(fetch = FetchType.EAGER)
- @JoinColumn(name = "quality_model_id")
- private Model model;
-
- @ManyToOne(fetch = FetchType.EAGER)
- @JoinColumn(name = "rule_id")
- private Rule rule;
-
- @Column(name = "description", nullable = true, length = 4000)
- private String description;
-
- @Column(name = "enabled", updatable = true, nullable = true)
- private Boolean enabled = Boolean.TRUE;
-
- @ManyToMany
- @JoinTable(
- name = "characteristic_edges",
- joinColumns = @JoinColumn(name = "child_id", referencedColumnName = "id"),
- inverseJoinColumns = @JoinColumn(name = "parent_id",
- referencedColumnName = "id")
- )
- private List<Characteristic> parents = Lists.newArrayList();
-
- @Sort(type = SortType.NATURAL)
- @ManyToMany(mappedBy = "parents", cascade = CascadeType.ALL)
- private List<Characteristic> children = Lists.newArrayList();
-
- @OneToMany(mappedBy = "characteristic", fetch = FetchType.LAZY, cascade = {CascadeType.MERGE, CascadeType.PERSIST, CascadeType.REMOVE})
- private List<CharacteristicProperty> properties = Lists.newArrayList();
-
- Characteristic() {
- }
-
- public Integer getId() {
- return id;
- }
-
- Characteristic setId(Integer id) {
- this.id = id;
- return this;
- }
-
- public String getKey() {
- return key;
- }
-
- public Characteristic setKey(String s) {
- this.key = StringUtils.trimToNull(s);
- return this;
- }
-
- public String getName() {
- return name;
- }
-
- public Characteristic setName(String s) {
- return setName(s, false);
- }
-
- public Characteristic setName(String s, boolean asKey) {
- this.name = StringUtils.trimToNull(s);
- if (asKey) {
- this.key = StringUtils.upperCase(this.name);
- this.key = StringUtils.replaceChars(this.key, ' ', '_');
- }
- return this;
- }
-
- public Model getModel() {
- return model;
- }
-
- Characteristic setModel(Model model) {
- this.model = model;
- return this;
- }
-
- public Rule getRule() {
- return rule;
- }
-
- public boolean hasRule() {
- return rule != null;
- }
-
- public Characteristic setRule(Rule r) {
- this.rule = r;
- return this;
- }
-
- public Boolean getEnabled() {
- return enabled;
- }
-
- public Characteristic setEnabled(Boolean b) {
- this.enabled = b;
- return this;
- }
-
- public Characteristic addChildren(Characteristic... list) {
- if (list != null) {
- for (Characteristic c : list) {
- addChild(c);
- }
- }
- return this;
- }
-
- public Characteristic addChild(Characteristic child) {
- propagateDepth(child, depth + 1);
- child.addParents(this);
- child.setModel(model);
- children.add(child);
- return this;
- }
-
- public Characteristic removeChild(Characteristic child) {
- children.remove(child);
- return this;
- }
-
- private static void propagateDepth(Characteristic characteristic, int depth) {
- characteristic.setDepth(depth);
- for (Characteristic child : characteristic.getChildren()) {
- propagateDepth(child, depth + 1);
- }
- }
-
- Characteristic addParents(Characteristic... pc) {
- if (pc != null) {
- Collections.addAll(this.parents, pc);
- }
- return this;
- }
-
- public List<Characteristic> getParents() {
- return parents;
- }
-
- public Characteristic getParent(String name) {
- for (Characteristic parent : parents) {
- if (StringUtils.equals(parent.getName(), name)) {
- return parent;
- }
- }
- return null;
- }
-
- /**
- * Enabled children sorted by insertion order
- */
- public List<Characteristic> getChildren() {
- return getChildren(true);
- }
-
- /**
- * Enabled children sorted by insertion order
- */
- public List<Characteristic> getChildren(boolean onlyEnabled) {
- if (!onlyEnabled) {
- return children;
- }
- List<Characteristic> result = Lists.newArrayList();
- for (Characteristic child : children) {
- if (child.getEnabled()) {
- result.add(child);
- }
- }
- return result;
- }
-
- public Characteristic getChild(String name) {
- for (Characteristic child : children) {
- if (StringUtils.equals(child.getName(), name)) {
- return child;
- }
- }
- return null;
- }
-
- public int getDepth() {
- return depth;
- }
-
- public boolean isRoot() {
- return depth == ROOT_DEPTH;
- }
-
- Characteristic setDepth(int i) {
- this.depth = i;
- return this;
- }
-
- public int getOrder() {
- return order;
- }
-
- public Characteristic setOrder(int i) {
- this.order = i;
- return this;
- }
-
- public String getDescription() {
- return description;
- }
-
- public Characteristic setDescription(String s) {
- this.description = s;
- return this;
- }
-
- public CharacteristicProperty setProperty(String key, String value) {
- return addProperty(CharacteristicProperty.create(key).setTextValue(value));
- }
-
- public CharacteristicProperty setProperty(String key, Double value) {
- return addProperty(CharacteristicProperty.create(key).setValue(value));
- }
-
- public CharacteristicProperty addProperty(CharacteristicProperty property) {
- property.setCharacteristic(this);
- properties.add(property);
- return property;
- }
-
- public CharacteristicProperty getProperty(String key) {
- for (CharacteristicProperty property : properties) {
- if (StringUtils.equals(key, property.getKey())) {
- return property;
- }
- }
- return null;
- }
-
- public String getPropertyTextValue(String key, String defaultValue) {
- CharacteristicProperty property = getProperty(key);
- String value = property != null ? property.getTextValue() : null;
- return StringUtils.defaultIfEmpty(value, defaultValue);
- }
-
- public Double getPropertyValue(String key, Double defaultValue) {
- CharacteristicProperty property = getProperty(key);
- Double value = property != null ? property.getValue() : null;
- return value == null ? defaultValue : value;
- }
-
- public List<CharacteristicProperty> getProperties() {
- return properties;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
-
- Characteristic that = (Characteristic) o;
- if (key != null ? !key.equals(that.key) : that.key != null) {
- return false;
- }
- if (rule != null ? !rule.equals(that.rule) : that.rule != null) {
- return false;
- }
- return true;
- }
-
- @Override
- public int hashCode() {
- int result = key != null ? key.hashCode() : 0;
- result = 31 * result + (rule != null ? rule.hashCode() : 0);
- return result;
- }
-
- @Override
- public String toString() {
- return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE)
- .append("key", key)
- .append("name", name)
- .append("rule", rule)
- .append("description", description)
- .toString();
- }
-
- public int compareTo(Characteristic o) {
- if (equals(o)) {
- return 0;
- }
- return order - o.order;
- }
-
- public static Characteristic create() {
- return new Characteristic();
- }
-
- public static Characteristic createByName(String name) {
- return new Characteristic().setName(name, true);
- }
-
- public static Characteristic createByKey(String key, String name) {
- return new Characteristic().setKey(key).setName(name, false);
- }
-
- public static Characteristic createByRule(Rule rule) {
- return new Characteristic().setRule(rule);
- }
-}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/qualitymodel/CharacteristicProperty.java b/sonar-plugin-api/src/main/java/org/sonar/api/qualitymodel/CharacteristicProperty.java
deleted file mode 100644
index cd2c3dc2613..00000000000
--- a/sonar-plugin-api/src/main/java/org/sonar/api/qualitymodel/CharacteristicProperty.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2013 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube 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.
- *
- * SonarQube 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 this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.api.qualitymodel;
-
-import javax.persistence.*;
-
-/**
- * @since 2.3
- */
-@Entity
-@Table(name = "characteristic_properties")
-public final class CharacteristicProperty {
-
- @Id
- @Column(name = "id")
- @GeneratedValue
- private Integer id;
-
- @Column(name = "kee", nullable = true, length = 100)
- private String key;
-
- @Column(name = "value", nullable = true)
- private Double value;
-
- @Column(name = "text_value", nullable = true, length = 4000)
- private String textValue;
-
- @ManyToOne(fetch = FetchType.EAGER)
- @JoinColumn(name = "characteristic_id", updatable = true, nullable = false)
- private Characteristic characteristic;
-
- /**
- * Use the factory method create()
- */
- CharacteristicProperty() {
- }
-
- public static CharacteristicProperty create(String key) {
- return new CharacteristicProperty().setKey(key);
- }
-
- public Integer getId() {
- return id;
- }
-
- CharacteristicProperty setId(Integer i) {
- this.id = i;
- return this;
- }
-
- public String getKey() {
- return key;
- }
-
- public CharacteristicProperty setKey(String s) {
- this.key = s;
- return this;
- }
-
- public String getTextValue() {
- return textValue;
- }
-
- public Double getValue() {
- return value;
- }
-
- public Long getValueAsLong() {
- if (value!=null) {
- return value.longValue();
- }
- return null;
- }
-
- public CharacteristicProperty setTextValue(String s) {
- this.textValue = s;
- return this;
- }
-
- public CharacteristicProperty setValue(Double d) {
- this.value = d;
- return this;
- }
-
- Characteristic getCharacteristic() {
- return characteristic;
- }
-
- CharacteristicProperty setCharacteristic(Characteristic c) {
- this.characteristic = c;
- return this;
- }
-}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/qualitymodel/Model.java b/sonar-plugin-api/src/main/java/org/sonar/api/qualitymodel/Model.java
deleted file mode 100644
index 131fa2a41e1..00000000000
--- a/sonar-plugin-api/src/main/java/org/sonar/api/qualitymodel/Model.java
+++ /dev/null
@@ -1,227 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2013 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube 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.
- *
- * SonarQube 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 this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.api.qualitymodel;
-
-import com.google.common.collect.Lists;
-import org.apache.commons.lang.ObjectUtils;
-import org.apache.commons.lang.StringUtils;
-import org.apache.commons.lang.builder.ToStringBuilder;
-import org.apache.commons.lang.builder.ToStringStyle;
-import org.sonar.api.rules.Rule;
-
-import javax.persistence.*;
-import java.util.List;
-
-/**
- * @since 2.3
- */
-@Entity
-@Table(name = "quality_models")
-public final class Model implements Comparable<Model> {
-
- @Id
- @Column(name = "id")
- @GeneratedValue
- private Integer id;
-
- @Column(name = "name", nullable = false, unique = true, length = 100)
- private String name;
-
- @OneToMany(mappedBy = "model", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
- private List<Characteristic> characteristics = Lists.newArrayList();
-
- /**
- * Use the factory method <code>Model</code>
- */
- Model() {
- }
-
- public static Model create() {
- return new Model();
- }
-
- public static Model createByName(String s) {
- return new Model().setName(s);
- }
-
- public Characteristic createCharacteristicByName(String name) {
- Characteristic c = new Characteristic().setName(name, true);
- return addCharacteristic(c);
- }
-
- public Characteristic createCharacteristicByKey(String key, String name) {
- Characteristic c = new Characteristic().setKey(key).setName(name, false);
- return addCharacteristic(c);
- }
-
- public Characteristic createCharacteristicByRule(Rule rule) {
- Characteristic c = new Characteristic().setRule(rule);
- return addCharacteristic(c);
- }
-
- public Integer getId() {
- return id;
- }
-
- Model setId(Integer id) {
- this.id = id;
- return this;
- }
-
- public String getName() {
- return name;
- }
-
- public List<Characteristic> getRootCharacteristics() {
- return getCharacteristicsByDepth(Characteristic.ROOT_DEPTH);
- }
-
- public Model setName(String name) {
- this.name = StringUtils.trim(name);
- return this;
- }
-
- public Characteristic addCharacteristic(Characteristic c) {
- c.setModel(this);
- c.setOrder(characteristics.size() + 1);
- characteristics.add(c);
- return c;
- }
-
- /**
- * @return enabled characteristics
- */
- public List<Characteristic> getCharacteristics() {
- return getCharacteristics(true);
- }
-
- public List<Characteristic> getCharacteristics(boolean onlyEnabled) {
- if (!onlyEnabled) {
- return characteristics;
- }
- List<Characteristic> result = Lists.newArrayList();
- for (Characteristic characteristic : characteristics) {
- if (characteristic.getEnabled()) {
- result.add(characteristic);
- }
- }
- return result;
- }
-
- /**
- * Search for an ENABLED characteristic by its key.
- */
- public Characteristic getCharacteristicByKey(String key) {
- for (Characteristic characteristic : characteristics) {
- if (characteristic.getEnabled() && StringUtils.equals(key, characteristic.getKey())) {
- return characteristic;
- }
- }
- return null;
- }
-
- /**
- * Search for an ENABLED characteristic with the specified rule.
- */
- public Characteristic getCharacteristicByRule(Rule rule) {
- if (rule != null) {
- for (Characteristic characteristic : characteristics) {
- if (characteristic.getEnabled() && ObjectUtils.equals(rule, characteristic.getRule())) {
- return characteristic;
- }
- }
- }
- return null;
- }
-
- /**
- * Search for ENABLED characteristics by their depth.
- */
- public List<Characteristic> getCharacteristicsByDepth(int depth) {
- List<Characteristic> result = Lists.newArrayList();
- for (Characteristic c : characteristics) {
- if (c.getEnabled() && c.getDepth() == depth) {
- result.add(c);
- }
- }
- return result;
- }
-
- /**
- * Search for an ENABLED characteristic by its name.
- */
- public Characteristic getCharacteristicByName(String name) {
- for (Characteristic characteristic : characteristics) {
- if (characteristic.getEnabled() && StringUtils.equals(name, characteristic.getName())) {
- return characteristic;
- }
- }
- return null;
- }
-
- public Model removeCharacteristic(Characteristic characteristic) {
- if (characteristic.getId() == null) {
- characteristics.remove(characteristic);
- for (Characteristic parent : characteristic.getParents()) {
- parent.removeChild(characteristic);
- }
- } else {
- characteristic.setEnabled(false);
- }
- for (Characteristic child : characteristic.getChildren()) {
- removeCharacteristic(child);
- }
- return this;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
-
- Model model = (Model) o;
- if (name != null ? !name.equals(model.name) : model.name != null) {
- return false;
- }
- return true;
- }
-
- @Override
- public int hashCode() {
- return name != null ? name.hashCode() : 0;
- }
-
- @Override
- public String toString() {
- return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE)
- .append("id", id)
- .append("name", name)
- .toString();
- }
-
- public int compareTo(Model o) {
- return getName().compareTo(o.getName());
- }
-
-}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/qualitymodel/ModelDefinition.java b/sonar-plugin-api/src/main/java/org/sonar/api/qualitymodel/ModelDefinition.java
deleted file mode 100644
index fc60a319668..00000000000
--- a/sonar-plugin-api/src/main/java/org/sonar/api/qualitymodel/ModelDefinition.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2013 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube 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.
- *
- * SonarQube 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 this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.api.qualitymodel;
-
-import org.apache.commons.lang.builder.ToStringBuilder;
-import org.apache.commons.lang.builder.ToStringStyle;
-import org.sonar.api.ServerExtension;
-
-/**
- *
- * @since 2.3
- * @deprecated since 4.0. It no more possible to define new quality models.
- */
-@Deprecated
-public abstract class ModelDefinition implements ServerExtension {
-
- private String name;
-
- protected ModelDefinition(String name) {
- this.name = name;
- }
-
- public final String getName() {
- return name;
- }
-
- public abstract Model createModel();
-
- @Override
- public final boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
-
- ModelDefinition that = (ModelDefinition) o;
- return name.equals(that.name);
- }
-
- @Override
- public final int hashCode() {
- return name.hashCode();
- }
-
- @Override
- public String toString() {
- return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE)
- .append("name", name)
- .toString();
- }
-}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/qualitymodel/ModelFinder.java b/sonar-plugin-api/src/main/java/org/sonar/api/qualitymodel/ModelFinder.java
deleted file mode 100644
index 669e5b51646..00000000000
--- a/sonar-plugin-api/src/main/java/org/sonar/api/qualitymodel/ModelFinder.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2013 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube 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.
- *
- * SonarQube 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 this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.api.qualitymodel;
-
-import org.sonar.api.BatchComponent;
-import org.sonar.api.ServerComponent;
-
-/**
- * @since 2.3
- */
-public interface ModelFinder extends BatchComponent, ServerComponent {
-
- /**
- * @return null if the name is not found
- */
- Model findByName(String name);
-
-}
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/qualitymodel/CharacteristicPropertyTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/qualitymodel/CharacteristicPropertyTest.java
deleted file mode 100644
index 0ce05e3133c..00000000000
--- a/sonar-plugin-api/src/test/java/org/sonar/api/qualitymodel/CharacteristicPropertyTest.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2013 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube 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.
- *
- * SonarQube 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 this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.api.qualitymodel;
-
-import org.junit.Test;
-
-import static org.hamcrest.CoreMatchers.nullValue;
-import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.assertThat;
-
-public class CharacteristicPropertyTest {
-
- @Test
- public void testNullValues() {
- CharacteristicProperty property = CharacteristicProperty.create("foo");
- assertThat(property.getTextValue(), nullValue());
- assertThat(property.getValue(), nullValue());
- assertThat(property.getValueAsLong(), nullValue());
- }
-
- @Test
- public void testNumericValue() {
- CharacteristicProperty property = CharacteristicProperty.create("foo");
- property.setValue(3.14);
- assertThat(property.getValue(), is(3.14));//stored in the value column
- assertThat(property.getValueAsLong(), is(3L));
- assertThat(property.getTextValue(), nullValue());
- }
-
- @Test
- public void testTextValue() {
- CharacteristicProperty property = CharacteristicProperty.create("foo");
- property.setTextValue("bar");
- assertThat(property.getTextValue(), is("bar"));
- assertThat(property.getValue(), nullValue());
- assertThat(property.getValueAsLong(), nullValue());
- }
-}
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/qualitymodel/CharacteristicTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/qualitymodel/CharacteristicTest.java
deleted file mode 100644
index d9051ffd13f..00000000000
--- a/sonar-plugin-api/src/test/java/org/sonar/api/qualitymodel/CharacteristicTest.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2013 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube 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.
- *
- * SonarQube 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 this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.api.qualitymodel;
-
-import org.junit.Test;
-
-import static org.fest.assertions.Assertions.assertThat;
-
-public class CharacteristicTest {
-
- @Test
- public void testStringProperties() {
- Characteristic characteristic = Characteristic.create();
- characteristic.setProperty("foo", "bar");
-
- assertThat(characteristic.getProperty("foo")).isNotNull();
- assertThat(characteristic.getPropertyTextValue("foo", null)).isEqualTo("bar");
- assertThat(characteristic.getPropertyValue("foo", null)).isNull();
-
- assertThat(characteristic.getProperty("unknown")).isNull();
- assertThat(characteristic.getPropertyTextValue("unknown", null)).isNull();
- }
-
- @Test
- public void testDoubleProperties() {
- Characteristic characteristic = Characteristic.create();
- characteristic.setProperty("foo", 3.1);
-
- assertThat(characteristic.getProperty("foo")).isNotNull();
- assertThat(characteristic.getPropertyValue("foo", null)).isEqualTo(3.1);
- assertThat(characteristic.getPropertyTextValue("foo", null)).isNull();
- }
-
- @Test
- public void addProperty() {
- Characteristic characteristic = Characteristic.create();
- characteristic.addProperty(CharacteristicProperty.create("foo"));
-
- CharacteristicProperty property = characteristic.getProperty("foo");
- assertThat(property).isNotNull();
- assertThat(property.getCharacteristic()).isSameAs(characteristic);
- }
-
- @Test
- public void shouldCreateByName() {
- Characteristic characteristic = Characteristic.createByName("Foo");
-
- assertThat(characteristic.getKey()).isEqualTo("FOO");
- assertThat(characteristic.getName()).isEqualTo("Foo");
- }
-
- @Test
- public void shouldReturnDefaultValues() {
- Characteristic characteristic = Characteristic.create();
- characteristic.setProperty("foo", (String) null);
- characteristic.setProperty("bar", (Double) null);
-
- assertThat(characteristic.getPropertyTextValue("foo", "foodef")).isEqualTo("foodef");
- assertThat(characteristic.getPropertyTextValue("other", "otherdef")).isEqualTo("otherdef");
- assertThat(characteristic.getPropertyValue("bar", 3.14)).isEqualTo(3.14);
- assertThat(characteristic.getPropertyValue("other", 3.14)).isEqualTo(3.14);
- }
-}
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/qualitymodel/ModelTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/qualitymodel/ModelTest.java
deleted file mode 100644
index ff33f7c8b41..00000000000
--- a/sonar-plugin-api/src/test/java/org/sonar/api/qualitymodel/ModelTest.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2013 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube 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.
- *
- * SonarQube 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 this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.api.qualitymodel;
-
-import org.junit.Test;
-import org.sonar.api.rules.Rule;
-
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.hamcrest.CoreMatchers.nullValue;
-import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.assertThat;
-
-public class ModelTest {
- @Test
- public void searchEnabledCharacteristics() {
- Model model = Model.create();
- model.createCharacteristicByKey("foo", "enabled foo");
- model.createCharacteristicByKey("foo", "disabled foo").setEnabled(false);
-
- assertThat(model.getCharacteristicByKey("foo").getName(), is("enabled foo"));
- assertThat(model.getCharacteristicByKey("foo").getEnabled(), is(true));
-
- assertThat(model.getCharacteristicByName("enabled foo").getName(), is("enabled foo"));
- assertThat(model.getCharacteristicByName("disabled foo"), nullValue());
-
- assertThat(model.getCharacteristics().size(), is(1));
- assertThat(model.getCharacteristics(false).size(), is(2));
- }
-
- @Test
- public void shouldFindCharacteristicByRule() {
- Model model = Model.create();
- Rule rule1 = Rule.create("checkstyle", "regexp", "Regular expression");
- Rule rule2 = Rule.create("checkstyle", "import", "Check imports");
-
- Characteristic efficiency = model.createCharacteristicByName("Efficiency");
- Characteristic requirement1 = model.createCharacteristicByRule(rule1);
- Characteristic requirement2 = model.createCharacteristicByRule(rule2);
- efficiency.addChild(requirement1);
- efficiency.addChild(requirement2);
-
- assertThat(model.getCharacteristicByRule(rule1), is(requirement1));
- assertThat(model.getCharacteristicByRule(rule2), is(requirement2));
- assertThat(model.getCharacteristicByRule(null), nullValue());
- assertThat(model.getCharacteristicByRule(Rule.create("foo", "bar", "Bar")), nullValue());
- }
-
- @Test
- public void shouldRemoveCharacteristic() {
- Model model = Model.create();
- Characteristic efficiency = model.createCharacteristicByName("Efficiency");
- model.createCharacteristicByName("Usability");
- assertThat(model.getCharacteristics().size(), is(2));
-
- model.removeCharacteristic(efficiency);
- assertThat(model.getCharacteristics().size(), is(1));
- assertThat(model.getCharacteristicByName("Efficiency"), nullValue());
- assertThat(model.getCharacteristicByName("Usability"), notNullValue());
- }
-
- @Test
- public void shouldNotFailWhenRemovingUnknownCharacteristic() {
- Model model = Model.create();
- model.createCharacteristicByName("Efficiency");
- model.removeCharacteristic(Characteristic.createByKey("foo", "Foo"));
- assertThat(model.getCharacteristics().size(), is(1));
- }
-}
diff --git a/sonar-server/src/main/java/org/sonar/server/platform/Platform.java b/sonar-server/src/main/java/org/sonar/server/platform/Platform.java
index b6e42e65060..41470cf1af1 100644
--- a/sonar-server/src/main/java/org/sonar/server/platform/Platform.java
+++ b/sonar-server/src/main/java/org/sonar/server/platform/Platform.java
@@ -55,7 +55,6 @@ import org.sonar.core.permission.PermissionFacade;
import org.sonar.core.persistence.*;
import org.sonar.core.preview.PreviewCache;
import org.sonar.core.purge.PurgeProfiler;
-import org.sonar.core.qualitymodel.DefaultModelFinder;
import org.sonar.core.resource.DefaultResourcePermissions;
import org.sonar.core.rule.DefaultRuleFinder;
import org.sonar.core.source.HtmlSourceDecorator;
@@ -229,7 +228,6 @@ public final class Platform {
servicesContainer.addSingleton(PluginDownloader.class);
servicesContainer.addSingleton(ServerIdGenerator.class);
// depends on plugins
- servicesContainer.addSingleton(DefaultModelFinder.class);
servicesContainer.addSingleton(ChartFactory.class);
servicesContainer.addSingleton(Languages.class);
servicesContainer.addSingleton(Views.class);
@@ -343,7 +341,6 @@ public final class Platform {
startupContainer.addSingleton(RegisterRules.class);
startupContainer.addSingleton(RegisterNewProfiles.class);
startupContainer.addSingleton(JdbcDriverDeployer.class);
- startupContainer.addSingleton(VerifyNoQualityModelsAreDefined.class);
startupContainer.addSingleton(RegisterTechnicalDebtModel.class);
startupContainer.addSingleton(DeleteDeprecatedMeasures.class);
startupContainer.addSingleton(GeneratePluginIndex.class);
diff --git a/sonar-server/src/main/java/org/sonar/server/startup/VerifyNoQualityModelsAreDefined.java b/sonar-server/src/main/java/org/sonar/server/startup/VerifyNoQualityModelsAreDefined.java
deleted file mode 100644
index a9147a13256..00000000000
--- a/sonar-server/src/main/java/org/sonar/server/startup/VerifyNoQualityModelsAreDefined.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2013 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube 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.
- *
- * SonarQube 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 this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.server.startup;
-
-import org.sonar.api.qualitymodel.ModelDefinition;
-import org.sonar.api.utils.MessageException;
-
-/**
- * Verify that no quality models are defined by plugin as now a technical debt model is already provided. See SONAR-4752 for detail.
- * @see org.sonar.server.startup.RegisterTechnicalDebtModel
- */
-public final class VerifyNoQualityModelsAreDefined {
-
- private final ModelDefinition[] definitions;
-
- public VerifyNoQualityModelsAreDefined(ModelDefinition[] definitions) {
- this.definitions = definitions;
- }
-
- public VerifyNoQualityModelsAreDefined() {
- this.definitions = new ModelDefinition[0];
- }
-
- public void start() {
- if (definitions.length > 0) {
- throw MessageException.of("The server could not start because the SQALE model definition is already provided by SonarQube. " +
- "You're probably using an old version of the SQALE plugin, please upgrade to a version compatible with the current version of SonarQube.");
- }
- }
-}
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/characteristic.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/characteristic.rb
index db4084008f9..bed36b0c249 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/models/characteristic.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/models/characteristic.rb
@@ -39,6 +39,10 @@ class Characteristic < ActiveRecord::Base
parent_id.nil?
end
+ def requirement?
+ rule_id.nil?
+ end
+
def key
kee
end
@@ -51,8 +55,4 @@ class Characteristic < ActiveRecord::Base
result
end
- #def enabled_children
- # children.select{|c| c.enabled}
- #end
-
end
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/quality_model.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/quality_model.rb
deleted file mode 100644
index 0e5a1e1fa7e..00000000000
--- a/sonar-server/src/main/webapp/WEB-INF/app/models/quality_model.rb
+++ /dev/null
@@ -1,24 +0,0 @@
-#
-# Sonar, entreprise quality control tool.
-# Copyright (C) 2008-2013 SonarSource
-# mailto:contact AT sonarsource DOT com
-#
-# SonarQube 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.
-#
-# SonarQube 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 this program; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-
-# TODO delete it
-class QualityModel < ActiveRecord::Base
-
-end
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/characteristic_property.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/464_remove_useless_characteristics_data.rb
index c407614bf37..40e1388c8fe 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/models/characteristic_property.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/db/migrate/464_remove_useless_characteristics_data.rb
@@ -18,8 +18,38 @@
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
-# TODO delete it
-class CharacteristicProperty < ActiveRecord::Base
+#
+# Sonar 4.1
+# SONAR-4831
+# SONAR-4891
+#
+
+class RemoveUselessCharacteristicsData < ActiveRecord::Migration
+
+ class QualityModel < ActiveRecord::Base
+ end
+
+ class Characteristic < ActiveRecord::Base
+ end
+
+ def self.up
+ Characteristic.reset_column_information
+
+ # Delete all characteristics not related to SQALE
+ sqale_model = QualityModel.first(['name = ?', 'SQALE'])
+ if sqale_model
+ Characteristic.delete_all(['quality_model_id <> ?', sqale_model.id.to_i])
+ end
+
+ # Delete useless columns
+ remove_column('characteristics', 'quality_model_id')
+ remove_column('characteristics', 'depth')
+ remove_column('characteristics', 'description')
+ # Delete useless tables
+ drop_table(:characteristic_properties)
+ drop_table(:characteristic_edges)
+ drop_table(:quality_models)
+ end
end
diff --git a/sonar-server/src/test/java/org/sonar/server/startup/VerifyNoQualityModelsAreDefinedTest.java b/sonar-server/src/test/java/org/sonar/server/startup/VerifyNoQualityModelsAreDefinedTest.java
deleted file mode 100644
index 36b4a08abcd..00000000000
--- a/sonar-server/src/test/java/org/sonar/server/startup/VerifyNoQualityModelsAreDefinedTest.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2013 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube 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.
- *
- * SonarQube 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 this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.server.startup;
-
-import org.junit.Test;
-import org.sonar.api.qualitymodel.ModelDefinition;
-import org.sonar.api.utils.MessageException;
-
-import static org.fest.assertions.Assertions.assertThat;
-import static org.fest.assertions.Fail.fail;
-import static org.mockito.Mockito.mock;
-
-public class VerifyNoQualityModelsAreDefinedTest {
-
- @Test
- public void not_fail_if_no_model_defined() {
- // Not fail
- VerifyNoQualityModelsAreDefined verifyNoQualityModelsAreDefined = new VerifyNoQualityModelsAreDefined();
- verifyNoQualityModelsAreDefined.start();
- }
-
- @Test
- public void fail_if_at_least_one_model_is_defined() {
- try {
- VerifyNoQualityModelsAreDefined verifyNoQualityModelsAreDefined = new VerifyNoQualityModelsAreDefined(new ModelDefinition[]{mock(ModelDefinition.class)});
- verifyNoQualityModelsAreDefined.start();
- fail();
- } catch (Exception e) {
- assertThat(e).isInstanceOf(MessageException.class);
- }
- }
-}