From 4bfd79e52cea465f226c78abb253c2073f4c1d4c Mon Sep 17 00:00:00 2001 From: simonbrandhof Date: Thu, 18 Nov 2010 15:02:54 +0000 Subject: SONAR-1663 include the dbcleaner plugin + move all purges in this plugin --- .../org/sonar/plugins/design/DesignPlugin.java | 3 +- .../plugins/design/batch/OldDependenciesPurge.java | 44 --------- .../design/batch/OldDependenciesPurgeTest.java | 40 -------- .../purgeOldDependencies-result.xml | 102 --------------------- .../purgeOldDependencies.xml | 102 --------------------- 5 files changed, 1 insertion(+), 290 deletions(-) delete mode 100644 plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/batch/OldDependenciesPurge.java delete mode 100644 plugins/sonar-design-plugin/src/test/java/org/sonar/plugins/design/batch/OldDependenciesPurgeTest.java delete mode 100644 plugins/sonar-design-plugin/src/test/resources/org/sonar/plugins/design/batch/OldDependenciesPurgeTest/purgeOldDependencies-result.xml delete mode 100644 plugins/sonar-design-plugin/src/test/resources/org/sonar/plugins/design/batch/OldDependenciesPurgeTest/purgeOldDependencies.xml (limited to 'plugins/sonar-design-plugin/src') 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 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 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ 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 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file -- cgit v1.2.3