diff options
author | Evgeny Mandrikov <mandrikov@gmail.com> | 2011-07-25 23:53:25 +0400 |
---|---|---|
committer | Evgeny Mandrikov <mandrikov@gmail.com> | 2011-07-26 00:00:59 +0400 |
commit | 6acbf886c2cc4b8f6998481e24236b1739ba079a (patch) | |
tree | f4cb4b93d8a5897a5a96ebbadce2b0b2b1c73dc6 /plugins/sonar-core-plugin | |
parent | 3380cba1de57f48e535de91e0c98c16030a36fa8 (diff) | |
download | sonarqube-6acbf886c2cc4b8f6998481e24236b1739ba079a.tar.gz sonarqube-6acbf886c2cc4b8f6998481e24236b1739ba079a.zip |
Fix CloseReviewsDecorator for Derby and move Review entity from sonar-plugin-api to sonar-core
Diffstat (limited to 'plugins/sonar-core-plugin')
-rw-r--r-- | plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/CloseReviewsDecorator.java | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/CloseReviewsDecorator.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/CloseReviewsDecorator.java index 437db024b2a..6e17f67f66d 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/CloseReviewsDecorator.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/CloseReviewsDecorator.java @@ -28,7 +28,6 @@ import org.sonar.api.batch.DecoratorBarriers; import org.sonar.api.batch.DecoratorContext; import org.sonar.api.batch.DependsUpon; import org.sonar.api.database.DatabaseSession; -import org.sonar.api.database.model.Review; import org.sonar.api.database.model.Snapshot; import org.sonar.api.database.model.User; import org.sonar.api.notifications.Notification; @@ -39,6 +38,7 @@ import org.sonar.api.resources.ResourceUtils; import org.sonar.api.security.UserFinder; import org.sonar.batch.index.ResourcePersister; import org.sonar.core.NotDryRun; +import org.sonar.jpa.entity.Review; /** * Decorator that currently only closes a review when its corresponding violation has been fixed. @@ -117,13 +117,17 @@ public class CloseReviewsDecorator implements Decorator { protected int closeReviewsForDeletedResources(int projectId, int projectSnapshotId) { String conditions = " WHERE status!='CLOSED' AND project_id=" + projectId + " AND resource_id IN ( SELECT prev.project_id FROM snapshots prev WHERE prev.root_project_id=" + projectId - + " AND prev.islast=TRUE AND NOT EXISTS ( SELECT cur.id FROM snapshots cur WHERE cur.root_snapshot_id=" + projectSnapshotId + + " AND prev.islast=? AND NOT EXISTS ( SELECT cur.id FROM snapshots cur WHERE cur.root_snapshot_id=" + projectSnapshotId + " AND cur.created_at > prev.created_at AND cur.root_project_id=" + projectId + " AND cur.project_id=prev.project_id ) )"; - List<Review> reviews = databaseSession.getEntityManager().createNativeQuery("SELECT * FROM reviews " + conditions, Review.class).getResultList(); + List<Review> reviews = databaseSession.getEntityManager().createNativeQuery("SELECT * FROM reviews " + conditions, Review.class) + .setParameter(1, Boolean.TRUE) + .getResultList(); for (Review review : reviews) { notifyClosed(review); } - int rowUpdated = databaseSession.createNativeQuery("UPDATE reviews SET status='CLOSED', updated_at=CURRENT_TIMESTAMP" + conditions).executeUpdate(); + int rowUpdated = databaseSession.createNativeQuery("UPDATE reviews SET status='CLOSED', updated_at=CURRENT_TIMESTAMP" + conditions) + .setParameter(1, Boolean.TRUE) + .executeUpdate(); LOG.debug("- {} reviews set to 'closed' on project #{}", rowUpdated, projectSnapshotId); return rowUpdated; } |