diff options
author | Teryk Bellahsene <teryk.bellahsene@sonarsource.com> | 2015-08-25 10:52:01 +0200 |
---|---|---|
committer | Teryk Bellahsene <teryk.bellahsene@sonarsource.com> | 2015-08-26 08:20:29 +0200 |
commit | 90f74707a9248d3041c98cf7791de936cdc901f8 (patch) | |
tree | fdb681eb9ed96e077c4db9efb55d87ddb2fc52dd /sonar-db | |
parent | a5bdd33c82ff1e82dfffd93c41b1db2885b15bd2 (diff) | |
download | sonarqube-90f74707a9248d3041c98cf7791de936cdc901f8.tar.gz sonarqube-90f74707a9248d3041c98cf7791de936cdc901f8.zip |
SONAR-6693 WS issue_filters/search rewrite WS
* return user filters and all shared filters
* add the favorite info on each filter
* requires authentication
* return [SonarQube] when it's a system issue filter
Diffstat (limited to 'sonar-db')
4 files changed, 61 insertions, 12 deletions
diff --git a/sonar-db/src/main/java/org/sonar/db/issue/IssueFilterDao.java b/sonar-db/src/main/java/org/sonar/db/issue/IssueFilterDao.java index bdb26dfa746..6a6b6fb86bf 100644 --- a/sonar-db/src/main/java/org/sonar/db/issue/IssueFilterDao.java +++ b/sonar-db/src/main/java/org/sonar/db/issue/IssueFilterDao.java @@ -24,6 +24,7 @@ import java.util.List; import javax.annotation.CheckForNull; import org.apache.ibatis.session.SqlSession; import org.sonar.db.Dao; +import org.sonar.db.DbSession; import org.sonar.db.MyBatis; public class IssueFilterDao implements Dao { @@ -45,15 +46,23 @@ public class IssueFilterDao implements Dao { } } + /** + * @deprecated since 5.2 use {@link #selectByUser(DbSession, String)} + */ + @Deprecated public List<IssueFilterDto> selectByUser(String user) { - SqlSession session = mybatis.openSession(false); + DbSession session = mybatis.openSession(false); try { - return mapper(session).selectByUser(user); + return selectByUser(session, user); } finally { MyBatis.closeQuietly(session); } } + public List<IssueFilterDto> selectByUser(DbSession session, String user) { + return mapper(session).selectByUser(user); + } + public List<IssueFilterDto> selectFavoriteFiltersByUser(String user) { SqlSession session = mybatis.openSession(false); try { @@ -72,27 +81,45 @@ public class IssueFilterDao implements Dao { } } + /** + * @deprecated since 5.2 use {@link #selectSharedFilters(DbSession)} + */ + @Deprecated public List<IssueFilterDto> selectSharedFilters() { - SqlSession session = mybatis.openSession(false); + DbSession session = mybatis.openSession(false); try { - return mapper(session).selectSharedFilters(); + return selectSharedFilters(session); } finally { MyBatis.closeQuietly(session); } } + public List<IssueFilterDto> selectSharedFilters(DbSession session) { + return mapper(session).selectSharedFilters(); + } + + /** + * @deprecated since 5.2 use {@link #insert(DbSession, IssueFilterDto)} + */ + @Deprecated public void insert(IssueFilterDto filter) { - SqlSession session = mybatis.openSession(false); + DbSession session = mybatis.openSession(false); try { - mapper(session).insert(filter); - session.commit(); + insert(session, filter); } finally { MyBatis.closeQuietly(session); } } + public IssueFilterDto insert(DbSession session, IssueFilterDto filter) { + mapper(session).insert(filter); + session.commit(); + + return filter; + } + public void update(IssueFilterDto filter) { - SqlSession session = mybatis.openSession(false); + DbSession session = mybatis.openSession(false); try { mapper(session).update(filter); session.commit(); @@ -102,7 +129,7 @@ public class IssueFilterDao implements Dao { } public void delete(long id) { - SqlSession session = mybatis.openSession(false); + DbSession session = mybatis.openSession(false); try { mapper(session).delete(id); session.commit(); diff --git a/sonar-db/src/main/java/org/sonar/db/issue/IssueFilterFavouriteDao.java b/sonar-db/src/main/java/org/sonar/db/issue/IssueFilterFavouriteDao.java index 7e7e20b634b..4253844e253 100644 --- a/sonar-db/src/main/java/org/sonar/db/issue/IssueFilterFavouriteDao.java +++ b/sonar-db/src/main/java/org/sonar/db/issue/IssueFilterFavouriteDao.java @@ -23,6 +23,7 @@ package org.sonar.db.issue; import java.util.List; import org.apache.ibatis.session.SqlSession; import org.sonar.db.Dao; +import org.sonar.db.DbSession; import org.sonar.db.MyBatis; public class IssueFilterFavouriteDao implements Dao { @@ -51,16 +52,24 @@ public class IssueFilterFavouriteDao implements Dao { } } + /** + * @deprecated since 5.2 use {@link #insert(DbSession, IssueFilterFavouriteDto)} + */ + @Deprecated public void insert(IssueFilterFavouriteDto filter) { - SqlSession session = mybatis.openSession(false); + DbSession session = mybatis.openSession(false); try { - mapper(session).insert(filter); - session.commit(); + insert(session, filter); } finally { MyBatis.closeQuietly(session); } } + public void insert(DbSession session, IssueFilterFavouriteDto filter) { + mapper(session).insert(filter); + session.commit(); + } + public void delete(long id) { SqlSession session = mybatis.openSession(false); try { @@ -84,4 +93,8 @@ public class IssueFilterFavouriteDao implements Dao { private IssueFilterFavouriteMapper mapper(SqlSession session) { return session.getMapper(IssueFilterFavouriteMapper.class); } + + public List<IssueFilterFavouriteDto> selectByUser(DbSession dbSession, String login) { + return mapper(dbSession).selectByUser(login); + } } diff --git a/sonar-db/src/main/java/org/sonar/db/issue/IssueFilterFavouriteMapper.java b/sonar-db/src/main/java/org/sonar/db/issue/IssueFilterFavouriteMapper.java index 62bd124174b..947bd799e34 100644 --- a/sonar-db/src/main/java/org/sonar/db/issue/IssueFilterFavouriteMapper.java +++ b/sonar-db/src/main/java/org/sonar/db/issue/IssueFilterFavouriteMapper.java @@ -33,6 +33,8 @@ public interface IssueFilterFavouriteMapper { List<IssueFilterFavouriteDto> selectByFilterId(@Param("filterId") long filterId); + List<IssueFilterFavouriteDto> selectByUser(String login); + void insert(IssueFilterFavouriteDto filterFavourite); void delete(long id); diff --git a/sonar-db/src/main/resources/org/sonar/db/issue/IssueFilterFavouriteMapper.xml b/sonar-db/src/main/resources/org/sonar/db/issue/IssueFilterFavouriteMapper.xml index 77db11f635c..cdcf51ee499 100644 --- a/sonar-db/src/main/resources/org/sonar/db/issue/IssueFilterFavouriteMapper.xml +++ b/sonar-db/src/main/resources/org/sonar/db/issue/IssueFilterFavouriteMapper.xml @@ -25,6 +25,13 @@ where filter_favourites.issue_filter_id=#{filterId} </select> + <select id="selectByUser" parameterType="string" resultType="issueFilterFavourite"> + select + <include refid="issueFilterFavouriteColumns"/> + from issue_filter_favourites filter_favourites + where filter_favourites.user_login=#{login} + </select> + <insert id="insert" parameterType="issueFilterFavourite" keyColumn="id" useGeneratedKeys="true" keyProperty="id"> INSERT INTO issue_filter_favourites (user_login, issue_filter_id, created_at) VALUES (#{userLogin}, #{issueFilterId}, current_timestamp) |