diff options
author | simonbrandhof <simon.brandhof@gmail.com> | 2010-11-18 15:02:54 +0000 |
---|---|---|
committer | simonbrandhof <simon.brandhof@gmail.com> | 2010-11-18 15:02:54 +0000 |
commit | 4bfd79e52cea465f226c78abb253c2073f4c1d4c (patch) | |
tree | d3812db183fbd869e2451148c32b2bd583f1112a /plugins/sonar-design-plugin/src | |
parent | f8ba14ececd0a5b60ec7112d4df3266f105541f5 (diff) | |
download | sonarqube-4bfd79e52cea465f226c78abb253c2073f4c1d4c.tar.gz sonarqube-4bfd79e52cea465f226c78abb253c2073f4c1d4c.zip |
SONAR-1663 include the dbcleaner plugin + move all purges in this plugin
Diffstat (limited to 'plugins/sonar-design-plugin/src')
5 files changed, 1 insertions, 290 deletions
diff --git a/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/DesignPlugin.java b/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/DesignPlugin.java index 90fe463ed82..fdb70535b59 100644 --- a/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/DesignPlugin.java +++ b/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/DesignPlugin.java @@ -23,11 +23,11 @@ import org.sonar.api.*; import org.sonar.plugins.design.batch.*; import org.sonar.plugins.design.ui.dependencies.GwtDependenciesTab; import org.sonar.plugins.design.ui.lcom4.GwtLcom4Tab; +import org.sonar.plugins.design.ui.libraries.GwtLibrariesPage; import org.sonar.plugins.design.ui.page.GwtDesignPage; import org.sonar.plugins.design.ui.widgets.ChidamberKemererWidget; import org.sonar.plugins.design.ui.widgets.FileDesignWidget; import org.sonar.plugins.design.ui.widgets.PackageDesignWidget; -import org.sonar.plugins.design.ui.libraries.GwtLibrariesPage; import java.util.ArrayList; import java.util.List; @@ -62,7 +62,6 @@ public class DesignPlugin implements Plugin { extensions.add(ProjectDsmDecorator.class); extensions.add(PackageTangleIndexDecorator.class); extensions.add(FileTangleIndexDecorator.class); - extensions.add(OldDependenciesPurge.class); extensions.add(SuspectLcom4DensityDecorator.class); extensions.add(GwtLibrariesPage.class); diff --git a/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/batch/OldDependenciesPurge.java b/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/batch/OldDependenciesPurge.java deleted file mode 100644 index 2a17e576721..00000000000 --- a/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/batch/OldDependenciesPurge.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2009 SonarSource SA - * mailto:contact AT sonarsource DOT com - * - * Sonar is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * Sonar is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.plugins.design.batch; - -import org.sonar.api.batch.PurgeContext; -import org.sonar.api.database.DatabaseSession; -import org.sonar.api.database.model.Snapshot; -import org.sonar.api.design.DependencyDto; -import org.sonar.core.purge.AbstractPurge; - -import javax.persistence.Query; -import java.util.List; - -public class OldDependenciesPurge extends AbstractPurge { - - public OldDependenciesPurge(DatabaseSession session) { - super(session); - } - - public void purge(PurgeContext context) { - Query query = getSession().createQuery("SELECT d.projectSnapshotId FROM " + DependencyDto.class.getSimpleName() + - " d WHERE NOT EXISTS(FROM " + Snapshot.class.getSimpleName() + " s WHERE s.id=d.projectSnapshotId AND s.last=:last)"); - query.setParameter("last", true); - final List<Integer> projectSnapshotIds = query.getResultList(); - executeQuery(projectSnapshotIds, "DELETE FROM " + DependencyDto.class.getSimpleName() + " WHERE projectSnapshotId in (:ids)"); - } -} diff --git a/plugins/sonar-design-plugin/src/test/java/org/sonar/plugins/design/batch/OldDependenciesPurgeTest.java b/plugins/sonar-design-plugin/src/test/java/org/sonar/plugins/design/batch/OldDependenciesPurgeTest.java deleted file mode 100644 index 300139b78e3..00000000000 --- a/plugins/sonar-design-plugin/src/test/java/org/sonar/plugins/design/batch/OldDependenciesPurgeTest.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2009 SonarSource SA - * mailto:contact AT sonarsource DOT com - * - * Sonar is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * Sonar is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.plugins.design.batch; - -import org.junit.Test; -import org.sonar.jpa.test.AbstractDbUnitTestCase; - -import java.sql.SQLException; - -public class OldDependenciesPurgeTest extends AbstractDbUnitTestCase { - - @Test - public void purgeOldDependencies() throws SQLException { - assertPurge("purgeOldDependencies"); - } - - private void assertPurge(String testName) { - setupData(testName); - new OldDependenciesPurge(getSession()).purge(null); - checkTables(testName, "dependencies"); - } - -} diff --git a/plugins/sonar-design-plugin/src/test/resources/org/sonar/plugins/design/batch/OldDependenciesPurgeTest/purgeOldDependencies-result.xml b/plugins/sonar-design-plugin/src/test/resources/org/sonar/plugins/design/batch/OldDependenciesPurgeTest/purgeOldDependencies-result.xml deleted file mode 100644 index 6b0bf1b88c4..00000000000 --- a/plugins/sonar-design-plugin/src/test/resources/org/sonar/plugins/design/batch/OldDependenciesPurgeTest/purgeOldDependencies-result.xml +++ /dev/null @@ -1,102 +0,0 @@ -<dataset> - <!-- first project with one package --> - <projects long_name="[null]" id="1" scope="PRJ" qualifier="TRK" kee="mygroup:myartifact" name="project" - root_id="[null]" - description="[null]" - enabled="true" language="java" copy_resource_id="[null]"/> - - <projects long_name="[null]" id="2" scope="DIR" qualifier="PAC" kee="mygroup:myartifact:my.package" name="package" - root_id="[null]" - description="[null]" - enabled="true" language="java" copy_resource_id="[null]"/> - - <!-- second project with two packages --> - <projects long_name="[null]" id="3" scope="PRJ" qualifier="TRK" kee="mygroup:myartifact2" name="project2" - root_id="[null]" - description="[null]" - enabled="true" language="java" copy_resource_id="[null]"/> - - <projects long_name="[null]" id="4" scope="DIR" qualifier="PAC" kee="mygroup:myartifact2:my.package" name="package" - root_id="[null]" - description="[null]" - enabled="true" language="java" copy_resource_id="[null]"/> - - <projects long_name="[null]" id="5" scope="DIR" qualifier="PAC" kee="mygroup:myartifact2:my.package2" name="package2" - root_id="[null]" - description="[null]" - enabled="true" language="java" copy_resource_id="[null]"/> - - - <!-- old snapshots --> - <snapshots depth="[null]" id="1" scope="PRJ" qualifier="TRK" created_at="2008-12-02 13:58:00.00" version="[null]" - project_id="1" - parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="false" - path="[null]"/> - - <snapshots depth="[null]" id="2" scope="DIR" qualifier="PAC" created_at="2008-12-02 13:58:00.00" version="[null]" - project_id="2" - parent_snapshot_id="1" root_project_id="[null]" root_snapshot_id="1" status="P" islast="false" - path="[null]"/> - - <snapshots depth="[null]" id="3" scope="PRJ" qualifier="TRK" created_at="2008-12-02 13:58:00.00" version="[null]" - project_id="3" - parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="false" - path="[null]"/> - - <snapshots depth="[null]" id="4" scope="DIR" qualifier="PAC" created_at="2008-12-02 13:58:00.00" version="[null]" - project_id="4" - parent_snapshot_id="3" root_project_id="[null]" root_snapshot_id="3" status="P" islast="false" - path="[null]"/> - - <snapshots depth="[null]" id="5" scope="DIR" qualifier="PAC" created_at="2008-12-02 13:58:00.00" version="[null]" - project_id="5" - parent_snapshot_id="3" root_project_id="[null]" root_snapshot_id="3" status="P" islast="false" - path="[null]"/> - - <!-- last snapshots --> - <snapshots depth="[null]" id="6" scope="PRJ" qualifier="TRK" created_at="2008-12-02 13:58:00.00" version="[null]" - project_id="1" - parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="true" - path="[null]"/> - - <snapshots depth="[null]" id="7" scope="DIR" qualifier="PAC" created_at="2008-12-02 13:58:00.00" version="[null]" - project_id="2" - parent_snapshot_id="6" root_project_id="[null]" root_snapshot_id="6" status="P" islast="true" - path="[null]"/> - - <snapshots depth="[null]" id="8" scope="PRJ" qualifier="TRK" created_at="2008-12-02 13:58:00.00" version="[null]" - project_id="3" - parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="true" - path="[null]"/> - - <snapshots depth="[null]" id="9" scope="DIR" qualifier="PAC" created_at="2008-12-02 13:58:00.00" version="[null]" - project_id="2" - parent_snapshot_id="8" root_project_id="[null]" root_snapshot_id="8" status="P" islast="true" - path="[null]"/> - - <snapshots depth="[null]" id="10" scope="DIR" qualifier="PAC" created_at="2008-12-02 13:58:00.00" version="[null]" - project_id="2" - parent_snapshot_id="8" root_project_id="[null]" root_snapshot_id="8" status="P" islast="true" - path="[null]"/> - - - <!-- old dependencies --> - <!--<dependencies id="1" from_resource_id="3" from_snapshot_id="3" to_resource_id="1" to_snapshot_id="1"--> - <!--parent_dependency_id="[null]" project_snapshot_id="3"--> - <!--dep_usage="compile" dep_weight="1" from_scope="PRJ" to_scope="PRJ"/>--> - - <!--<dependencies id="2" from_resource_id="4" from_snapshot_id="4" to_resource_id="5" to_snapshot_id="5"--> - <!--parent_dependency_id="[null]" project_snapshot_id="3"--> - <!--dep_usage="uses" dep_weight="3" from_scope="DIR" to_scope="DIR"/>--> - - - <!-- last dependencies --> - <dependencies id="3" from_resource_id="3" from_snapshot_id="8" to_resource_id="1" to_snapshot_id="6" - parent_dependency_id="[null]" project_snapshot_id="8" - dep_usage="compile" dep_weight="1" from_scope="PRJ" to_scope="PRJ"/> - - <dependencies id="4" from_resource_id="4" from_snapshot_id="9" to_resource_id="5" to_snapshot_id="10" - parent_dependency_id="[null]" project_snapshot_id="8" - dep_usage="uses" dep_weight="3" from_scope="DIR" to_scope="DIR"/> - -</dataset>
\ No newline at end of file diff --git a/plugins/sonar-design-plugin/src/test/resources/org/sonar/plugins/design/batch/OldDependenciesPurgeTest/purgeOldDependencies.xml b/plugins/sonar-design-plugin/src/test/resources/org/sonar/plugins/design/batch/OldDependenciesPurgeTest/purgeOldDependencies.xml deleted file mode 100644 index 5ffbb85ac9f..00000000000 --- a/plugins/sonar-design-plugin/src/test/resources/org/sonar/plugins/design/batch/OldDependenciesPurgeTest/purgeOldDependencies.xml +++ /dev/null @@ -1,102 +0,0 @@ -<dataset> - <!-- first project with one package --> - <projects long_name="[null]" id="1" scope="PRJ" qualifier="TRK" kee="mygroup:myartifact" name="project" - root_id="[null]" - description="[null]" - enabled="true" language="java" copy_resource_id="[null]"/> - - <projects long_name="[null]" id="2" scope="DIR" qualifier="PAC" kee="mygroup:myartifact:my.package" name="package" - root_id="[null]" - description="[null]" - enabled="true" language="java" copy_resource_id="[null]"/> - - <!-- second project with two packages --> - <projects long_name="[null]" id="3" scope="PRJ" qualifier="TRK" kee="mygroup:myartifact2" name="project2" - root_id="[null]" - description="[null]" - enabled="true" language="java" copy_resource_id="[null]"/> - - <projects long_name="[null]" id="4" scope="DIR" qualifier="PAC" kee="mygroup:myartifact2:my.package" name="package" - root_id="[null]" - description="[null]" - enabled="true" language="java" copy_resource_id="[null]"/> - - <projects long_name="[null]" id="5" scope="DIR" qualifier="PAC" kee="mygroup:myartifact2:my.package2" name="package2" - root_id="[null]" - description="[null]" - enabled="true" language="java" copy_resource_id="[null]"/> - - - <!-- old snapshots --> - <snapshots depth="[null]" id="1" scope="PRJ" qualifier="TRK" created_at="2008-12-02 13:58:00.00" version="[null]" - project_id="1" - parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="false" - path="[null]"/> - - <snapshots depth="[null]" id="2" scope="DIR" qualifier="PAC" created_at="2008-12-02 13:58:00.00" version="[null]" - project_id="2" - parent_snapshot_id="1" root_project_id="[null]" root_snapshot_id="1" status="P" islast="false" - path="[null]"/> - - <snapshots depth="[null]" id="3" scope="PRJ" qualifier="TRK" created_at="2008-12-02 13:58:00.00" version="[null]" - project_id="3" - parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="false" - path="[null]"/> - - <snapshots depth="[null]" id="4" scope="DIR" qualifier="PAC" created_at="2008-12-02 13:58:00.00" version="[null]" - project_id="4" - parent_snapshot_id="3" root_project_id="[null]" root_snapshot_id="3" status="P" islast="false" - path="[null]"/> - - <snapshots depth="[null]" id="5" scope="DIR" qualifier="PAC" created_at="2008-12-02 13:58:00.00" version="[null]" - project_id="5" - parent_snapshot_id="3" root_project_id="[null]" root_snapshot_id="3" status="P" islast="false" - path="[null]"/> - - <!-- last snapshots --> - <snapshots depth="[null]" id="6" scope="PRJ" qualifier="TRK" created_at="2008-12-02 13:58:00.00" version="[null]" - project_id="1" - parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="true" - path="[null]"/> - - <snapshots depth="[null]" id="7" scope="DIR" qualifier="PAC" created_at="2008-12-02 13:58:00.00" version="[null]" - project_id="2" - parent_snapshot_id="6" root_project_id="[null]" root_snapshot_id="6" status="P" islast="true" - path="[null]"/> - - <snapshots depth="[null]" id="8" scope="PRJ" qualifier="TRK" created_at="2008-12-02 13:58:00.00" version="[null]" - project_id="3" - parent_snapshot_id="[null]" root_project_id="[null]" root_snapshot_id="[null]" status="P" islast="true" - path="[null]"/> - - <snapshots depth="[null]" id="9" scope="DIR" qualifier="PAC" created_at="2008-12-02 13:58:00.00" version="[null]" - project_id="2" - parent_snapshot_id="8" root_project_id="[null]" root_snapshot_id="8" status="P" islast="true" - path="[null]"/> - - <snapshots depth="[null]" id="10" scope="DIR" qualifier="PAC" created_at="2008-12-02 13:58:00.00" version="[null]" - project_id="2" - parent_snapshot_id="8" root_project_id="[null]" root_snapshot_id="8" status="P" islast="true" - path="[null]"/> - - - <!-- old dependencies --> - <dependencies id="1" from_resource_id="3" from_snapshot_id="3" to_resource_id="1" to_snapshot_id="1" - parent_dependency_id="[null]" project_snapshot_id="3" - dep_usage="compile" dep_weight="1" from_scope="PRJ" to_scope="PRJ"/> - - <dependencies id="2" from_resource_id="4" from_snapshot_id="4" to_resource_id="5" to_snapshot_id="5" - parent_dependency_id="[null]" project_snapshot_id="3" - dep_usage="uses" dep_weight="3" from_scope="DIR" to_scope="DIR"/> - - - <!-- last dependencies --> - <dependencies id="3" from_resource_id="3" from_snapshot_id="8" to_resource_id="1" to_snapshot_id="6" - parent_dependency_id="[null]" project_snapshot_id="8" - dep_usage="compile" dep_weight="1" from_scope="PRJ" to_scope="PRJ"/> - - <dependencies id="4" from_resource_id="4" from_snapshot_id="9" to_resource_id="5" to_snapshot_id="10" - parent_dependency_id="[null]" project_snapshot_id="8" - dep_usage="uses" dep_weight="3" from_scope="DIR" to_scope="DIR"/> - -</dataset>
\ No newline at end of file |