From a34a3671bd0c8427ae3cdf165f7a2136713e875e Mon Sep 17 00:00:00 2001 From: simonbrandhof Date: Mon, 7 Feb 2011 17:40:42 +0100 Subject: [PATCH] Remove useless purge --- .../plugins/dbcleaner/DbCleanerPlugin.java | 2 +- .../dbcleaner/purges/UnflagLastDoublons.java | 49 ------------- .../purges/UnflagLastDoublonsTest.java | 38 ----------- .../UnflagLastDoublonsTest/sharedFixture.xml | 34 ---------- .../unflagLastDoublons-result.xml | 68 ------------------- .../unflagLastDoublons.xml | 68 ------------------- 6 files changed, 1 insertion(+), 258 deletions(-) delete mode 100644 plugins/sonar-dbcleaner-plugin/src/main/java/org/sonar/plugins/dbcleaner/purges/UnflagLastDoublons.java delete mode 100644 plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/purges/UnflagLastDoublonsTest.java delete mode 100644 plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/UnflagLastDoublonsTest/sharedFixture.xml delete mode 100644 plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/UnflagLastDoublonsTest/unflagLastDoublons-result.xml delete mode 100644 plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/UnflagLastDoublonsTest/unflagLastDoublons.xml diff --git a/plugins/sonar-dbcleaner-plugin/src/main/java/org/sonar/plugins/dbcleaner/DbCleanerPlugin.java b/plugins/sonar-dbcleaner-plugin/src/main/java/org/sonar/plugins/dbcleaner/DbCleanerPlugin.java index 2ab4c945bca..68308e30f6a 100644 --- a/plugins/sonar-dbcleaner-plugin/src/main/java/org/sonar/plugins/dbcleaner/DbCleanerPlugin.java +++ b/plugins/sonar-dbcleaner-plugin/src/main/java/org/sonar/plugins/dbcleaner/DbCleanerPlugin.java @@ -69,7 +69,7 @@ public final class DbCleanerPlugin implements Plugin { // purges PurgeOrphanResources.class, PurgeEntities.class, PurgeRuleMeasures.class, PurgeUnprocessed.class, - PurgeDeletedResources.class, PurgeDeprecatedLast.class, UnflagLastDoublons.class, PurgeDisabledResources.class, + PurgeDeletedResources.class, PurgeDeprecatedLast.class, PurgeDisabledResources.class, PurgeResourceRoles.class, PurgeEventOrphans.class, PurgePropertyOrphans.class, PeriodPurge.class, PurgeDependencies.class, // post-job diff --git a/plugins/sonar-dbcleaner-plugin/src/main/java/org/sonar/plugins/dbcleaner/purges/UnflagLastDoublons.java b/plugins/sonar-dbcleaner-plugin/src/main/java/org/sonar/plugins/dbcleaner/purges/UnflagLastDoublons.java deleted file mode 100644 index 5799850f8e8..00000000000 --- a/plugins/sonar-dbcleaner-plugin/src/main/java/org/sonar/plugins/dbcleaner/purges/UnflagLastDoublons.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2011 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * Sonar is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.plugins.dbcleaner.purges; - -import org.sonar.api.database.DatabaseSession; -import org.sonar.api.database.model.Snapshot; -import org.sonar.plugins.dbcleaner.api.Purge; -import org.sonar.plugins.dbcleaner.api.PurgeContext; -import org.sonar.plugins.dbcleaner.api.PurgeUtils; - -import java.util.List; - -import javax.persistence.Query; - -/** - * @since 1.11 - */ -public final class UnflagLastDoublons extends Purge { - - public UnflagLastDoublons(DatabaseSession session) { - super(session); - } - - public void purge(PurgeContext context) { - Query query = getSession().createQuery( - "SELECT olds.id FROM " + Snapshot.class.getSimpleName() + " olds " + - " where olds.last=true AND EXISTS (from " + Snapshot.class.getSimpleName() + " news WHERE news.last=true AND news.resourceId=olds.resourceId AND news.createdAt>olds.createdAt)"); - List snapshotIds = query.getResultList(); - - PurgeUtils.executeQuery(getSession(), "", snapshotIds, "UPDATE " + Snapshot.class.getSimpleName() + " SET last=false WHERE id in (:ids)"); - } -} diff --git a/plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/purges/UnflagLastDoublonsTest.java b/plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/purges/UnflagLastDoublonsTest.java deleted file mode 100644 index e9204a462d9..00000000000 --- a/plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/purges/UnflagLastDoublonsTest.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2011 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * Sonar is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.plugins.dbcleaner.purges; - -import org.junit.Test; -import org.sonar.jpa.test.AbstractDbUnitTestCase; - -import java.sql.SQLException; - -public class UnflagLastDoublonsTest extends AbstractDbUnitTestCase { - - @Test - public void unflagLastDoublons() throws SQLException { - setupData("sharedFixture", "unflagLastDoublons"); - - new UnflagLastDoublons(getSession()).purge(null); - - checkTables("unflagLastDoublons", "snapshots"); - } -} - diff --git a/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/UnflagLastDoublonsTest/sharedFixture.xml b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/UnflagLastDoublonsTest/sharedFixture.xml deleted file mode 100644 index b0485cc36ca..00000000000 --- a/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/UnflagLastDoublonsTest/sharedFixture.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/UnflagLastDoublonsTest/unflagLastDoublons-result.xml b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/UnflagLastDoublonsTest/unflagLastDoublons-result.xml deleted file mode 100644 index 61e0dfbce33..00000000000 --- a/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/UnflagLastDoublonsTest/unflagLastDoublons-result.xml +++ /dev/null @@ -1,68 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/UnflagLastDoublonsTest/unflagLastDoublons.xml b/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/UnflagLastDoublonsTest/unflagLastDoublons.xml deleted file mode 100644 index 97a76b074fd..00000000000 --- a/plugins/sonar-dbcleaner-plugin/src/test/resources/org/sonar/plugins/dbcleaner/purges/UnflagLastDoublonsTest/unflagLastDoublons.xml +++ /dev/null @@ -1,68 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file -- 2.39.5