您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

WidgetDao.java 2.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. * SonarQube, open source software quality management tool.
  3. * Copyright (C) 2008-2014 SonarSource
  4. * mailto:contact AT sonarsource DOT com
  5. *
  6. * SonarQube is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 3 of the License, or (at your option) any later version.
  10. *
  11. * SonarQube is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public License
  17. * along with this program; if not, write to the Free Software Foundation,
  18. * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  19. */
  20. package org.sonar.server.dashboard.db;
  21. import java.util.Collection;
  22. import org.sonar.db.dashboard.WidgetDto;
  23. import org.sonar.db.dashboard.WidgetMapper;
  24. import org.sonar.db.Dao;
  25. import org.sonar.db.DbSession;
  26. import org.sonar.db.MyBatis;
  27. public class WidgetDao implements Dao {
  28. private MyBatis myBatis;
  29. public WidgetDao(MyBatis myBatis) {
  30. this.myBatis = myBatis;
  31. }
  32. public WidgetDto getNullableByKey(Long widgetId) {
  33. DbSession session = myBatis.openSession(false);
  34. try {
  35. return getNullableByKey(session, widgetId);
  36. } finally {
  37. MyBatis.closeQuietly(session);
  38. }
  39. }
  40. public WidgetDto getNullableByKey(DbSession session, Long widgetId) {
  41. return mapper(session).selectById(widgetId);
  42. }
  43. public WidgetDto update(WidgetDto item) {
  44. DbSession session = myBatis.openSession(false);
  45. try {
  46. return update(session, item);
  47. } finally {
  48. MyBatis.closeQuietly(session);
  49. }
  50. }
  51. public WidgetDto update(DbSession session, WidgetDto item) {
  52. mapper(session).update(item);
  53. return item;
  54. }
  55. public Collection<WidgetDto> findByDashboard(DbSession session, long dashboardKey) {
  56. return mapper(session).selectByDashboard(dashboardKey);
  57. }
  58. public Collection<WidgetDto> findAll(DbSession session) {
  59. return mapper(session).selectAll();
  60. }
  61. private WidgetMapper mapper(DbSession session) {
  62. return session.getMapper(WidgetMapper.class);
  63. }
  64. }