aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-core/src
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@gmail.com>2012-01-27 10:40:00 +0100
committerSimon Brandhof <simon.brandhof@gmail.com>2012-01-27 10:40:00 +0100
commit6a6034ac6f99ec2d7528cc1e326f1d4e27b24314 (patch)
treed28f21aeec3f2631b8ff114edc17d2a997744bc0 /sonar-core/src
parent3a1b309e342a4b61cbc7ff06c6900150beee3573 (diff)
downloadsonarqube-6a6034ac6f99ec2d7528cc1e326f1d4e27b24314.tar.gz
sonarqube-6a6034ac6f99ec2d7528cc1e326f1d4e27b24314.zip
SONAR-2757 do not delete events on profile changes
Diffstat (limited to 'sonar-core/src')
-rw-r--r--sonar-core/src/main/java/org/sonar/core/purge/PurgeDao.java4
-rw-r--r--sonar-core/src/main/java/org/sonar/core/purge/PurgeMapper.java4
-rw-r--r--sonar-core/src/main/java/org/sonar/core/purge/PurgeableSnapshotDto.java10
-rw-r--r--sonar-core/src/main/resources/org/sonar/core/purge/PurgeMapper.xml12
-rw-r--r--sonar-core/src/test/java/org/sonar/core/purge/PurgeDaoTest.java10
5 files changed, 20 insertions, 20 deletions
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<PurgeableSnapshotDto> 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<PurgeableSnapshotDto> selectPurgeableSnapshotsWithVersionEvent(long resourceId);
+ List<PurgeableSnapshotDto> selectPurgeableSnapshotsWithReadOnlyEvents(long resourceId);
- List<PurgeableSnapshotDto> selectPurgeableSnapshotsWithoutVersionEvent(long resourceId);
+ List<PurgeableSnapshotDto> 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<PurgeableSnapshotDto> {
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<PurgeableSnapshotDto> {
return snapshotId;
}
- public boolean hasVersionEvent() {
- return hasVersionEvent;
+ public boolean hasReadOnlyEvents() {
+ return hasReadOnlyEvents;
}
public boolean isLast() {
@@ -55,8 +55,8 @@ public class PurgeableSnapshotDto implements Comparable<PurgeableSnapshotDto> {
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 @@
</where>
</select>
- <select id="selectPurgeableSnapshotsWithVersionEvent" parameterType="long" resultType="PurgeableSnapshot">
- select s.id as "snapshotId", s.created_at as "date", ${_true} as "hasVersionEvent", islast as "isLast" from
+ <select id="selectPurgeableSnapshotsWithReadOnlyEvents" parameterType="long" resultType="PurgeableSnapshot">
+ 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 &lt;&gt; '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>
- <select id="selectPurgeableSnapshotsWithoutVersionEvent" parameterType="long" resultType="PurgeableSnapshot">
- select s.id as "snapshotId", s.created_at as "date", ${_false} as "hasVersionEvent", islast as "isLast" from
+ <select id="selectPurgeableSnapshotsWithoutReadOnlyEvents" parameterType="long" resultType="PurgeableSnapshot">
+ 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 &lt;&gt; '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'))
</select>
<select id="selectResourceIdsToDisable" resultType="long" parameterType="long">
diff --git a/sonar-core/src/test/java/org/sonar/core/purge/PurgeDaoTest.java b/sonar-core/src/test/java/org/sonar/core/purge/PurgeDaoTest.java
index c1a3541aeb0..af30c7bbf70 100644
--- a/sonar-core/src/test/java/org/sonar/core/purge/PurgeDaoTest.java
+++ b/sonar-core/src/test/java/org/sonar/core/purge/PurgeDaoTest.java
@@ -180,24 +180,24 @@ public class PurgeDaoTest extends DaoTestCase {
static final class SnapshotMatcher extends BaseMatcher<PurgeableSnapshotDto> {
long snapshotId;
boolean isLast;
- boolean hasVersionEvent;
+ boolean hasReadOnlyEvents;
- SnapshotMatcher(long snapshotId, boolean last, boolean hasVersionEvent) {
+ SnapshotMatcher(long snapshotId, boolean last, boolean hasReadOnlyEvents) {
this.snapshotId = snapshotId;
this.isLast = last;
- this.hasVersionEvent = hasVersionEvent;
+ this.hasReadOnlyEvents = hasReadOnlyEvents;
}
public boolean matches(Object o) {
PurgeableSnapshotDto obj = (PurgeableSnapshotDto) o;
- return obj.getSnapshotId() == snapshotId && obj.isLast() == isLast && obj.hasVersionEvent() == hasVersionEvent;
+ return obj.getSnapshotId() == snapshotId && obj.isLast() == isLast && obj.hasReadOnlyEvents() == hasReadOnlyEvents;
}
public void describeTo(Description description) {
description
.appendText("snapshotId").appendValue(snapshotId)
.appendText("isLast").appendValue(isLast)
- .appendText("hasVersionEvent").appendValue(hasVersionEvent);
+ .appendText("hasReadOnlyEvents").appendValue(hasReadOnlyEvents);
}
}
}