From 6a6034ac6f99ec2d7528cc1e326f1d4e27b24314 Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Fri, 27 Jan 2012 10:40:00 +0100 Subject: SONAR-2757 do not delete events on profile changes --- sonar-core/src/main/java/org/sonar/core/purge/PurgeDao.java | 4 ++-- .../src/main/java/org/sonar/core/purge/PurgeMapper.java | 4 ++-- .../main/java/org/sonar/core/purge/PurgeableSnapshotDto.java | 10 +++++----- .../src/main/resources/org/sonar/core/purge/PurgeMapper.xml | 12 ++++++------ .../src/test/java/org/sonar/core/purge/PurgeDaoTest.java | 10 +++++----- 5 files changed, 20 insertions(+), 20 deletions(-) (limited to 'sonar-core/src') diff --git a/sonar-core/src/main/java/org/sonar/core/purge/PurgeDao.java b/sonar-core/src/main/java/org/sonar/core/purge/PurgeDao.java index e751cc32f20..32561f1c583 100644 --- a/sonar-core/src/main/java/org/sonar/core/purge/PurgeDao.java +++ b/sonar-core/src/main/java/org/sonar/core/purge/PurgeDao.java @@ -89,8 +89,8 @@ public class PurgeDao { try { PurgeMapper mapper = session.getMapper(PurgeMapper.class); List result = Lists.newArrayList(); - result.addAll(mapper.selectPurgeableSnapshotsWithVersionEvent(resourceId)); - result.addAll(mapper.selectPurgeableSnapshotsWithoutVersionEvent(resourceId)); + result.addAll(mapper.selectPurgeableSnapshotsWithReadOnlyEvents(resourceId)); + result.addAll(mapper.selectPurgeableSnapshotsWithoutReadOnlyEvents(resourceId)); Collections.sort(result);// sort by date return result; } finally { diff --git a/sonar-core/src/main/java/org/sonar/core/purge/PurgeMapper.java b/sonar-core/src/main/java/org/sonar/core/purge/PurgeMapper.java index d663cd44c53..350c115bb7e 100644 --- a/sonar-core/src/main/java/org/sonar/core/purge/PurgeMapper.java +++ b/sonar-core/src/main/java/org/sonar/core/purge/PurgeMapper.java @@ -73,7 +73,7 @@ public interface PurgeMapper { void closeResourceReviews(long resourceId); - List selectPurgeableSnapshotsWithVersionEvent(long resourceId); + List selectPurgeableSnapshotsWithReadOnlyEvents(long resourceId); - List selectPurgeableSnapshotsWithoutVersionEvent(long resourceId); + List selectPurgeableSnapshotsWithoutReadOnlyEvents(long resourceId); } diff --git a/sonar-core/src/main/java/org/sonar/core/purge/PurgeableSnapshotDto.java b/sonar-core/src/main/java/org/sonar/core/purge/PurgeableSnapshotDto.java index 5579bfa7c06..20d4ab1f829 100644 --- a/sonar-core/src/main/java/org/sonar/core/purge/PurgeableSnapshotDto.java +++ b/sonar-core/src/main/java/org/sonar/core/purge/PurgeableSnapshotDto.java @@ -27,7 +27,7 @@ import java.util.Date; public class PurgeableSnapshotDto implements Comparable { private Date date; private long snapshotId; - private boolean hasVersionEvent; + private boolean hasReadOnlyEvents; private boolean isLast; public Date getDate() { @@ -38,8 +38,8 @@ public class PurgeableSnapshotDto implements Comparable { return snapshotId; } - public boolean hasVersionEvent() { - return hasVersionEvent; + public boolean hasReadOnlyEvents() { + return hasReadOnlyEvents; } public boolean isLast() { @@ -55,8 +55,8 @@ public class PurgeableSnapshotDto implements Comparable { return this; } - public PurgeableSnapshotDto setHasVersionEvent(boolean hasVersionEvent) { - this.hasVersionEvent = hasVersionEvent; + public PurgeableSnapshotDto setHasReadOnlyEvents(boolean b) { + this.hasReadOnlyEvents = b; return this; } diff --git a/sonar-core/src/main/resources/org/sonar/core/purge/PurgeMapper.xml b/sonar-core/src/main/resources/org/sonar/core/purge/PurgeMapper.xml index 34c85d4f7e2..002a448873a 100644 --- a/sonar-core/src/main/resources/org/sonar/core/purge/PurgeMapper.xml +++ b/sonar-core/src/main/resources/org/sonar/core/purge/PurgeMapper.xml @@ -48,18 +48,18 @@ - + select s.id as "snapshotId", s.created_at as "date", ${_true} as "hasReadOnlyEvents", islast as "isLast" from snapshots s where s.project_id=#{id} and s.status='P' and s.qualifier <> 'LIB' and exists(select e.id from events e where - e.snapshot_id=s.id and e.category='Version') + e.snapshot_id=s.id and e.category in ('Version', 'Profile')) - + select s.id as "snapshotId", s.created_at as "date", ${_false} as "hasReadOnlyEvents", islast as "isLast" from snapshots s where s.project_id=#{id} and s.status='P' and s.qualifier <> 'LIB' and not exists(select e.id from events e - where e.snapshot_id=s.id and e.category='Version') + where e.snapshot_id=s.id and e.category in ('Version', 'Profile'))