import org.sonar.core.properties.PropertiesMapper;
import org.sonar.core.properties.PropertyDto;
import org.sonar.core.purge.PurgeMapper;
-import org.sonar.core.purge.PurgeVendorMapper;
import org.sonar.core.purge.PurgeableSnapshotDto;
import org.sonar.core.resource.ResourceDto;
import org.sonar.core.resource.ResourceIndexDto;
loadAlias(conf, "MeasureModel", MeasureModel.class);
Class<?>[] mappers = {ActiveDashboardMapper.class, AuthorMapper.class, FilterMapper.class, CriterionMapper.class, FilterColumnMapper.class, DashboardMapper.class,
- DependencyMapper.class, DuplicationMapper.class, LoadedTemplateMapper.class, PropertiesMapper.class, PurgeMapper.class, PurgeVendorMapper.class,
+ DependencyMapper.class, DuplicationMapper.class, LoadedTemplateMapper.class, PropertiesMapper.class, PurgeMapper.class,
ResourceKeyUpdaterMapper.class, ResourceIndexerMapper.class, ResourceMapper.class, ResourceSnapshotMapper.class, ReviewCommentMapper.class,
ReviewMapper.class, RoleMapper.class, RuleMapper.class, SchemaMigrationMapper.class, UserMapper.class, WidgetMapper.class, WidgetPropertyMapper.class,
MeasureMapper.class};
class PurgeCommands {
private final SqlSession session;
private final PurgeMapper purgeMapper;
- private final PurgeVendorMapper purgeVendorMapper;
- PurgeCommands(SqlSession session, PurgeMapper purgeMapper, PurgeVendorMapper purgeVendorMapper) {
+ PurgeCommands(SqlSession session, PurgeMapper purgeMapper) {
this.session = session;
this.purgeMapper = purgeMapper;
- this.purgeVendorMapper = purgeVendorMapper;
}
@VisibleForTesting
PurgeCommands(SqlSession session) {
- this(session, session.getMapper(PurgeMapper.class), session.getMapper(PurgeVendorMapper.class));
+ this(session, session.getMapper(PurgeMapper.class));
}
List<Long> selectSnapshotIds(PurgeSnapshotQuery query) {
session.commit();
for (Long resourceId : resourceIds) {
- purgeVendorMapper.deleteResourceReviewComments(resourceId);
+ purgeMapper.deleteResourceReviewComments(resourceId);
}
session.commit();
for (Long resourceId : resourceIds) {
- purgeVendorMapper.deleteResourceActionPlansReviews(resourceId);
+ purgeMapper.deleteResourceActionPlansReviews(resourceId);
}
session.commit();
public PurgeDao purge(long rootResourceId, String[] scopesWithoutHistoricalData) {
SqlSession session = mybatis.openBatchSession();
PurgeMapper purgeMapper = session.getMapper(PurgeMapper.class);
- PurgeCommands commands = new PurgeCommands(session, purgeMapper, session.getMapper(PurgeVendorMapper.class));
+ PurgeCommands commands = new PurgeCommands(session, purgeMapper);
try {
List<ResourceDto> projects = getProjects(rootResourceId, session);
for (ResourceDto project : projects) {
List<PurgeableSnapshotDto> selectPurgeableSnapshotsWithoutEvents(long resourceId);
List<Long> selectResourceIdsByRootId(long rootProjectId);
+
+ void deleteResourceReviewComments(long resourceId);
+
+ void deleteResourceActionPlansReviews(long resourceId);
}
+++ /dev/null
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2012 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * Sonar is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
- */
-package org.sonar.core.purge;
-
-/**
- * Purge requests that are specific to database vendors. They are extracted from PurgeMapper
- * as long as MyBatis does not support multiple databases in the same XML file.
- *
- * See code.google.com/p/mybatis/issues/detail?id=21
- */
-public interface PurgeVendorMapper {
- void deleteResourceReviewComments(long resourceId);
-
- void deleteResourceActionPlansReviews(long resourceId);
-}
<update id="setSnapshotIsLastToFalse" parameterType="long">
update snapshots set islast=${_false} where project_id=#{id}
</update>
+
+ <delete id="deleteResourceReviewComments" parameterType="long">
+ delete from review_comments rc where exists (select * from reviews r where rc.review_id=r.id and
+ r.resource_id=#{id})
+ </delete>
+
+ <delete id="deleteResourceActionPlansReviews" parameterType="long">
+ delete from action_plans_reviews apr where exists (select * from action_plans ap where ap.id=apr.action_plan_id and
+ ap.project_id=#{id})
+ </delete>
+
+ <!-- Mssql -->
+ <delete id="deleteResourceReviewComments" databaseId="mssql" parameterType="long">
+ delete review_comments from review_comments
+ inner join reviews on review_comments.review_id=reviews.id
+ where reviews.resource_id=#{id}
+ </delete>
+
+ <delete id="deleteResourceActionPlansReviews" databaseId="mssql" parameterType="long">
+ delete action_plans_reviews from action_plans_reviews
+ inner join action_plans on action_plans.id=action_plans_reviews.action_plan_id
+ where action_plans.project_id=#{id}
+ </delete>
+
+ <!-- Mysql -->
+ <delete id="deleteResourceReviewComments" databaseId="mysql" parameterType="long">
+ delete rc from review_comments as rc, reviews as r where rc.review_id=r.id and r.resource_id=#{id}
+ </delete>
+
+ <delete id="deleteResourceActionPlansReviews" databaseId="mysql" parameterType="long">
+ delete apr from action_plans_reviews as apr, action_plans as ap where ap.id=apr.action_plan_id and ap.project_id=#{id}
+ </delete>
+
</mapper>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8" ?>
-<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-
-<mapper namespace="org.sonar.core.purge.PurgeVendorMapper">
-
- <delete id="deleteResourceReviewComments" parameterType="long">
- delete review_comments from review_comments
- inner join reviews on review_comments.review_id=reviews.id
- where reviews.resource_id=#{id}
- </delete>
-
- <delete id="deleteResourceActionPlansReviews" parameterType="long">
- delete action_plans_reviews from action_plans_reviews
- inner join action_plans on action_plans.id=action_plans_reviews.action_plan_id
- where action_plans.project_id=#{id}
- </delete>
-
-</mapper>
-
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8" ?>
-<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-
-<mapper namespace="org.sonar.core.purge.PurgeVendorMapper">
-
- <delete id="deleteResourceReviewComments" parameterType="long">
- delete rc from review_comments as rc, reviews as r where rc.review_id=r.id and r.resource_id=#{id}
- </delete>
-
- <delete id="deleteResourceActionPlansReviews" parameterType="long">
- delete apr from action_plans_reviews as apr, action_plans as ap where ap.id=apr.action_plan_id and ap.project_id=#{id}
- </delete>
-
-</mapper>
-
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8" ?>
-<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-
-<mapper namespace="org.sonar.core.purge.PurgeVendorMapper">
-
- <delete id="deleteResourceReviewComments" parameterType="long">
- delete from review_comments rc where exists (select * from reviews r where rc.review_id=r.id and
- r.resource_id=#{id})
- </delete>
-
- <delete id="deleteResourceActionPlansReviews" parameterType="long">
- delete from action_plans_reviews apr where exists (select * from action_plans ap where ap.id=apr.action_plan_id and
- ap.project_id=#{id})
- </delete>
-
-</mapper>
-