aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-core/src/main
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@gmail.com>2013-07-01 09:26:01 +0200
committerJulien Lancelot <julien.lancelot@gmail.com>2013-07-02 16:47:54 +0200
commit9707f7cb88c6042a5da87c27e3864f664b6567d7 (patch)
treefe37f97aaf78ef57d1ffdf140c82ade194126e5f /sonar-core/src/main
parent6f08f9ae68ee9c19d19e4aab66af10f3a5e533cf (diff)
downloadsonarqube-9707f7cb88c6042a5da87c27e3864f664b6567d7.tar.gz
sonarqube-9707f7cb88c6042a5da87c27e3864f664b6567d7.zip
SONAR-4469 Favourite issue filters still visible even if unshared
Diffstat (limited to 'sonar-core/src/main')
-rw-r--r--sonar-core/src/main/java/org/sonar/core/issue/db/IssueFilterDao.java28
-rw-r--r--sonar-core/src/main/java/org/sonar/core/issue/db/IssueFilterFavouriteDao.java14
-rw-r--r--sonar-core/src/main/java/org/sonar/core/issue/db/IssueFilterFavouriteMapper.java9
-rw-r--r--sonar-core/src/main/java/org/sonar/core/issue/db/IssueFilterMapper.java13
-rw-r--r--sonar-core/src/main/resources/org/sonar/core/issue/db/IssueFilterFavouriteMapper.xml7
-rw-r--r--sonar-core/src/main/resources/org/sonar/core/issue/db/IssueFilterMapper.xml32
6 files changed, 25 insertions, 78 deletions
diff --git a/sonar-core/src/main/java/org/sonar/core/issue/db/IssueFilterDao.java b/sonar-core/src/main/java/org/sonar/core/issue/db/IssueFilterDao.java
index 572d23e41ed..51ca69c6447 100644
--- a/sonar-core/src/main/java/org/sonar/core/issue/db/IssueFilterDao.java
+++ b/sonar-core/src/main/java/org/sonar/core/issue/db/IssueFilterDao.java
@@ -26,7 +26,6 @@ import org.sonar.api.ServerComponent;
import org.sonar.core.persistence.MyBatis;
import javax.annotation.CheckForNull;
-import javax.annotation.Nullable;
import java.util.List;
@@ -52,16 +51,6 @@ public class IssueFilterDao implements BatchComponent, ServerComponent {
}
}
- @CheckForNull
- public IssueFilterDto selectByNameAndUser(String name, String user, @Nullable Long existingId) {
- SqlSession session = mybatis.openSession();
- try {
- return getMapper(session).selectByNameAndUser(name, user, existingId);
- } finally {
- MyBatis.closeQuietly(session);
- }
- }
-
public List<IssueFilterDto> selectByUser(String user) {
SqlSession session = mybatis.openSession();
try {
@@ -71,28 +60,19 @@ public class IssueFilterDao implements BatchComponent, ServerComponent {
}
}
- public List<IssueFilterDto> selectByUserWithOnlyFavoriteFilters(String user) {
- SqlSession session = mybatis.openSession();
- try {
- return getMapper(session).selectByUserWithOnlyFavoriteFilters(user);
- } finally {
- MyBatis.closeQuietly(session);
- }
- }
-
- public List<IssueFilterDto> selectSharedWithoutUserFilters(String user) {
+ public List<IssueFilterDto> selectFavoriteFiltersByUser(String user) {
SqlSession session = mybatis.openSession();
try {
- return getMapper(session).selectSharedWithoutUserFilters(user);
+ return getMapper(session).selectFavoriteFiltersByUser(user);
} finally {
MyBatis.closeQuietly(session);
}
}
- public IssueFilterDto selectSharedWithoutUserFiltersByName(String name, String user, @Nullable Long existingId) {
+ public List<IssueFilterDto> selectSharedFilters() {
SqlSession session = mybatis.openSession();
try {
- return getMapper(session).selectSharedWithoutUserFiltersByName(name, user, existingId);
+ return getMapper(session).selectSharedFilters();
} finally {
MyBatis.closeQuietly(session);
}
diff --git a/sonar-core/src/main/java/org/sonar/core/issue/db/IssueFilterFavouriteDao.java b/sonar-core/src/main/java/org/sonar/core/issue/db/IssueFilterFavouriteDao.java
index 17e2b17b1de..1ee990aa254 100644
--- a/sonar-core/src/main/java/org/sonar/core/issue/db/IssueFilterFavouriteDao.java
+++ b/sonar-core/src/main/java/org/sonar/core/issue/db/IssueFilterFavouriteDao.java
@@ -25,6 +25,8 @@ import org.sonar.api.BatchComponent;
import org.sonar.api.ServerComponent;
import org.sonar.core.persistence.MyBatis;
+import java.util.List;
+
/**
* @since 3.7
*/
@@ -45,10 +47,10 @@ public class IssueFilterFavouriteDao implements BatchComponent, ServerComponent
}
}
- public IssueFilterFavouriteDto selectByUserAndIssueFilterId(String user, Long issueFilterId) {
+ public List<IssueFilterFavouriteDto> selectByFilterId(Long filterId) {
SqlSession session = mybatis.openSession();
try {
- return getMapper(session).selectByIssueFilterId(user, issueFilterId);
+ return getMapper(session).selectByFilterId(filterId);
} finally {
MyBatis.closeQuietly(session);
}
@@ -64,20 +66,20 @@ public class IssueFilterFavouriteDao implements BatchComponent, ServerComponent
}
}
- public void delete(Long issueFilterFavouriteId) {
+ public void delete(Long id) {
SqlSession session = mybatis.openSession();
try {
- getMapper(session).delete(issueFilterFavouriteId);
+ getMapper(session).delete(id);
session.commit();
} finally {
MyBatis.closeQuietly(session);
}
}
- public void deleteByIssueFilterId(Long issueFilterId) {
+ public void deleteByFilterId(Long filterId) {
SqlSession session = mybatis.openSession();
try {
- getMapper(session).deleteByIssueFilterId(issueFilterId);
+ getMapper(session).deleteByFilterId(filterId);
session.commit();
} finally {
MyBatis.closeQuietly(session);
diff --git a/sonar-core/src/main/java/org/sonar/core/issue/db/IssueFilterFavouriteMapper.java b/sonar-core/src/main/java/org/sonar/core/issue/db/IssueFilterFavouriteMapper.java
index d11fc9d1ca1..8890d613152 100644
--- a/sonar-core/src/main/java/org/sonar/core/issue/db/IssueFilterFavouriteMapper.java
+++ b/sonar-core/src/main/java/org/sonar/core/issue/db/IssueFilterFavouriteMapper.java
@@ -23,6 +23,8 @@ import org.apache.ibatis.annotations.Param;
import javax.annotation.CheckForNull;
+import java.util.List;
+
/**
* @since 3.7
*/
@@ -31,12 +33,11 @@ public interface IssueFilterFavouriteMapper {
@CheckForNull
IssueFilterFavouriteDto selectById(Long id);
- @CheckForNull
- IssueFilterFavouriteDto selectByIssueFilterId(@Param("userLogin") String userLogin, @Param("issueFilterId") Long issueFilterId);
+ List<IssueFilterFavouriteDto> selectByFilterId(@Param("filterId") Long filterId);
void insert(IssueFilterFavouriteDto filterFavourite);
- void delete(Long issueFilterFavouriteId);
+ void delete(Long id);
- void deleteByIssueFilterId(Long issueFilterId);
+ void deleteByFilterId(Long filterId);
}
diff --git a/sonar-core/src/main/java/org/sonar/core/issue/db/IssueFilterMapper.java b/sonar-core/src/main/java/org/sonar/core/issue/db/IssueFilterMapper.java
index eb634af22b6..052ad7d743c 100644
--- a/sonar-core/src/main/java/org/sonar/core/issue/db/IssueFilterMapper.java
+++ b/sonar-core/src/main/java/org/sonar/core/issue/db/IssueFilterMapper.java
@@ -19,10 +19,7 @@
*/
package org.sonar.core.issue.db;
-import org.apache.ibatis.annotations.Param;
-
import javax.annotation.CheckForNull;
-import javax.annotation.Nullable;
import java.util.List;
@@ -34,17 +31,11 @@ public interface IssueFilterMapper {
@CheckForNull
IssueFilterDto selectById(Long id);
- @CheckForNull
- IssueFilterDto selectByNameAndUser(@Param("name") String name, @Param("userLogin") String userLogin, @Nullable @Param("existingId") Long existingId);
-
List<IssueFilterDto> selectByUser(String user);
- List<IssueFilterDto> selectByUserWithOnlyFavoriteFilters(String user);
+ List<IssueFilterDto> selectFavoriteFiltersByUser(String user);
- List<IssueFilterDto> selectSharedWithoutUserFilters(String user);
-
- @CheckForNull
- IssueFilterDto selectSharedWithoutUserFiltersByName(@Param("name") String name, @Param("userLogin") String userLogin, @Nullable @Param("existingId") Long existingId);
+ List<IssueFilterDto> selectSharedFilters();
void insert(IssueFilterDto filter);
diff --git a/sonar-core/src/main/resources/org/sonar/core/issue/db/IssueFilterFavouriteMapper.xml b/sonar-core/src/main/resources/org/sonar/core/issue/db/IssueFilterFavouriteMapper.xml
index f8aaa53f945..15d9b8d9263 100644
--- a/sonar-core/src/main/resources/org/sonar/core/issue/db/IssueFilterFavouriteMapper.xml
+++ b/sonar-core/src/main/resources/org/sonar/core/issue/db/IssueFilterFavouriteMapper.xml
@@ -19,12 +19,11 @@
</where>
</select>
- <select id="selectByIssueFilterId" parameterType="long" resultType="issueFilterFavourite">
+ <select id="selectByFilterId" parameterType="long" resultType="issueFilterFavourite">
select <include refid="issueFilterFavouriteColumns"/>
from issue_filter_favourites filter_favourites
<where>
- filter_favourites.issue_filter_id=#{issueFilterId}
- and filter_favourites.user_login=#{userLogin}
+ filter_favourites.issue_filter_id=#{filterId}
</where>
</select>
@@ -37,7 +36,7 @@
delete from issue_filter_favourites where id=#{id}
</delete>
- <delete id="deleteByIssueFilterId" parameterType="int">
+ <delete id="deleteByFilterId" parameterType="int">
delete from issue_filter_favourites where issue_filter_id=#{issueFilterId}
</delete>
diff --git a/sonar-core/src/main/resources/org/sonar/core/issue/db/IssueFilterMapper.xml b/sonar-core/src/main/resources/org/sonar/core/issue/db/IssueFilterMapper.xml
index 21a2c87cfee..954c7af61f0 100644
--- a/sonar-core/src/main/resources/org/sonar/core/issue/db/IssueFilterMapper.xml
+++ b/sonar-core/src/main/resources/org/sonar/core/issue/db/IssueFilterMapper.xml
@@ -23,18 +23,6 @@
</where>
</select>
- <select id="selectByNameAndUser" parameterType="map" resultType="IssueFilter">
- select <include refid="issueFilterColumns"/>
- from issue_filters filters
- <where>
- and filters.name=#{name}
- and filters.user_login=#{userLogin}
- <if test="existingId != null">
- and filters.id&lt;&gt;#{existingId}
- </if>
- </where>
- </select>
-
<select id="selectByUser" parameterType="String" resultType="IssueFilter">
select <include refid="issueFilterColumns"/>
from issue_filters filters
@@ -43,7 +31,7 @@
</where>
</select>
- <select id="selectByUserWithOnlyFavoriteFilters" parameterType="String" resultType="IssueFilter">
+ <select id="selectFavoriteFiltersByUser" parameterType="String" resultType="IssueFilter">
select <include refid="issueFilterColumns"/>
from issue_filters filters
inner join issue_filter_favourites fav on fav.issue_filter_id = filters.id
@@ -52,25 +40,11 @@
</where>
</select>
- <select id="selectSharedWithoutUserFilters" parameterType="String" resultType="IssueFilter">
- select <include refid="issueFilterColumns"/>
- from issue_filters filters
- <where>
- filters.shared=${_true}
- and filters.user_login&lt;&gt;#{userLogin}
- </where>
- </select>
-
- <select id="selectSharedWithoutUserFiltersByName" parameterType="String" resultType="IssueFilter">
+ <select id="selectSharedFilters" parameterType="String" resultType="IssueFilter">
select <include refid="issueFilterColumns"/>
from issue_filters filters
<where>
- filters.shared=${_true}
- and filters.user_login&lt;&gt;#{userLogin}
- and filters.name=#{name}
- <if test="existingId != null">
- and filters.id&lt;&gt;#{existingId}
- </if>
+ and filters.shared=${_true}
</where>
</select>