From: Julien Lancelot Date: Mon, 7 Nov 2016 14:54:16 +0000 (+0100) Subject: SONAR-8354 Remove dao related to dashboards X-Git-Tag: 6.2-RC1~162 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=6d53f242b31429e30df708d258e7fe78a1079062;p=sonarqube.git SONAR-8354 Remove dao related to dashboards --- diff --git a/server/sonar-ce/src/test/java/org/sonar/ce/container/ComputeEngineContainerImplTest.java b/server/sonar-ce/src/test/java/org/sonar/ce/container/ComputeEngineContainerImplTest.java index 97bab6ac4bb..e92a53e3395 100644 --- a/server/sonar-ce/src/test/java/org/sonar/ce/container/ComputeEngineContainerImplTest.java +++ b/server/sonar-ce/src/test/java/org/sonar/ce/container/ComputeEngineContainerImplTest.java @@ -106,7 +106,7 @@ public class ComputeEngineContainerImplTest { assertThat(picoContainer.getParent().getParent().getParent().getComponentAdapters()).hasSize( COMPONENTS_IN_LEVEL_1_AT_CONSTRUCTION + 24 // level 1 - + 52 // content of DaoModule + + 48 // content of DaoModule + 2 // content of EsSearchModule + 62 // content of CorePropertyDefinitions + 1 // content of CePropertyDefinitions diff --git a/sonar-db/src/main/java/org/sonar/db/DaoModule.java b/sonar-db/src/main/java/org/sonar/db/DaoModule.java index 7a11ad95208..17fb1ec6268 100644 --- a/sonar-db/src/main/java/org/sonar/db/DaoModule.java +++ b/sonar-db/src/main/java/org/sonar/db/DaoModule.java @@ -32,10 +32,6 @@ import org.sonar.db.component.ComponentLinkDao; import org.sonar.db.component.ResourceDao; import org.sonar.db.component.ResourceIndexDao; import org.sonar.db.component.SnapshotDao; -import org.sonar.db.dashboard.ActiveDashboardDao; -import org.sonar.db.dashboard.DashboardDao; -import org.sonar.db.dashboard.WidgetDao; -import org.sonar.db.dashboard.WidgetPropertyDao; import org.sonar.db.duplication.DuplicationDao; import org.sonar.db.event.EventDao; import org.sonar.db.issue.IssueChangeDao; @@ -77,7 +73,6 @@ import org.sonar.db.user.UserTokenDao; public class DaoModule extends Module { private static final List> classes = ImmutableList.>builder().add( - ActiveDashboardDao.class, AuthorDao.class, AuthorizationDao.class, CeActivityDao.class, @@ -86,7 +81,6 @@ public class DaoModule extends Module { ComponentDao.class, ComponentLinkDao.class, CustomMeasureDao.class, - DashboardDao.class, DuplicationDao.class, EventDao.class, FileSourceDao.class, @@ -126,9 +120,7 @@ public class DaoModule extends Module { UserDao.class, UserGroupDao.class, UserPermissionDao.class, - UserTokenDao.class, - WidgetDao.class, - WidgetPropertyDao.class).build(); + UserTokenDao.class).build(); @Override protected void configureModule() { diff --git a/sonar-db/src/main/java/org/sonar/db/DbClient.java b/sonar-db/src/main/java/org/sonar/db/DbClient.java index 16eaa687271..a4aebb92ea1 100644 --- a/sonar-db/src/main/java/org/sonar/db/DbClient.java +++ b/sonar-db/src/main/java/org/sonar/db/DbClient.java @@ -32,10 +32,6 @@ import org.sonar.db.component.ComponentLinkDao; import org.sonar.db.component.ResourceDao; import org.sonar.db.component.ResourceIndexDao; import org.sonar.db.component.SnapshotDao; -import org.sonar.db.dashboard.ActiveDashboardDao; -import org.sonar.db.dashboard.DashboardDao; -import org.sonar.db.dashboard.WidgetDao; -import org.sonar.db.dashboard.WidgetPropertyDao; import org.sonar.db.duplication.DuplicationDao; import org.sonar.db.event.EventDao; import org.sonar.db.issue.IssueChangeDao; @@ -108,10 +104,6 @@ public class DbClient { private final CeQueueDao ceQueueDao; private final CeTaskInputDao ceTaskInputDao; private final CeScannerContextDao ceScannerContextDao; - private final DashboardDao dashboardDao; - private final ActiveDashboardDao activeDashboardDao; - private final WidgetDao widgetDao; - private final WidgetPropertyDao widgetPropertyDao; private final FileSourceDao fileSourceDao; private final AuthorDao authorDao; private final ResourceIndexDao componentIndexDao; @@ -169,10 +161,6 @@ public class DbClient { ceQueueDao = getDao(map, CeQueueDao.class); ceTaskInputDao = getDao(map, CeTaskInputDao.class); ceScannerContextDao = getDao(map, CeScannerContextDao.class); - dashboardDao = getDao(map, DashboardDao.class); - activeDashboardDao = getDao(map, ActiveDashboardDao.class); - widgetDao = getDao(map, WidgetDao.class); - widgetPropertyDao = getDao(map, WidgetPropertyDao.class); fileSourceDao = getDao(map, FileSourceDao.class); authorDao = getDao(map, AuthorDao.class); componentIndexDao = getDao(map, ResourceIndexDao.class); @@ -322,22 +310,6 @@ public class DbClient { return ceScannerContextDao; } - public DashboardDao dashboardDao() { - return dashboardDao; - } - - public ActiveDashboardDao activeDashboardDao() { - return activeDashboardDao; - } - - public WidgetDao widgetDao() { - return widgetDao; - } - - public WidgetPropertyDao widgetPropertyDao() { - return widgetPropertyDao; - } - public FileSourceDao fileSourceDao() { return fileSourceDao; } diff --git a/sonar-db/src/main/java/org/sonar/db/MyBatis.java b/sonar-db/src/main/java/org/sonar/db/MyBatis.java index cd885f5c3c1..ba299882dda 100644 --- a/sonar-db/src/main/java/org/sonar/db/MyBatis.java +++ b/sonar-db/src/main/java/org/sonar/db/MyBatis.java @@ -48,14 +48,6 @@ import org.sonar.db.component.SnapshotDto; import org.sonar.db.component.SnapshotMapper; import org.sonar.db.component.UuidWithProjectUuidDto; import org.sonar.db.component.ViewsSnapshotDto; -import org.sonar.db.dashboard.ActiveDashboardDto; -import org.sonar.db.dashboard.ActiveDashboardMapper; -import org.sonar.db.dashboard.DashboardDto; -import org.sonar.db.dashboard.DashboardMapper; -import org.sonar.db.dashboard.WidgetDto; -import org.sonar.db.dashboard.WidgetMapper; -import org.sonar.db.dashboard.WidgetPropertyDto; -import org.sonar.db.dashboard.WidgetPropertyMapper; import org.sonar.db.debt.RequirementMigrationDto; import org.sonar.db.duplication.DuplicationMapper; import org.sonar.db.duplication.DuplicationUnitDto; @@ -166,7 +158,6 @@ public class MyBatis { MyBatisConfBuilder confBuilder = new MyBatisConfBuilder(database); // DTO aliases, keep them sorted alphabetically - confBuilder.loadAlias("ActiveDashboard", ActiveDashboardDto.class); confBuilder.loadAlias("ActiveRule", ActiveRuleDto.class); confBuilder.loadAlias("ActiveRuleParam", ActiveRuleParamDto.class); confBuilder.loadAlias("Author", AuthorDto.class); @@ -174,7 +165,6 @@ public class MyBatis { confBuilder.loadAlias("ComponentLink", ComponentLinkDto.class); confBuilder.loadAlias("ComponentWithSnapshot", ComponentDtoWithSnapshotId.class); confBuilder.loadAlias("CustomMeasure", CustomMeasureDto.class); - confBuilder.loadAlias("Dashboard", DashboardDto.class); confBuilder.loadAlias("DuplicationUnit", DuplicationUnitDto.class); confBuilder.loadAlias("Event", EventDto.class); confBuilder.loadAlias("FilePathWithHash", FilePathWithHashDto.class); @@ -217,15 +207,12 @@ public class MyBatis { confBuilder.loadAlias("User", UserDto.class); confBuilder.loadAlias("UuidWithProjectUuid", UuidWithProjectUuidDto.class); confBuilder.loadAlias("ViewsSnapshot", ViewsSnapshotDto.class); - confBuilder.loadAlias("WidgetProperty", WidgetPropertyDto.class); - confBuilder.loadAlias("Widget", WidgetDto.class); // ResourceMapper has to be loaded before IssueMapper because this last one used it confBuilder.loadMapper(ResourceMapper.class); // keep them sorted alphabetically Class[] mappers = { - ActiveDashboardMapper.class, ActiveRuleMapper.class, AuthorMapper.class, AuthorizationMapper.class, @@ -237,7 +224,6 @@ public class MyBatis { ComponentLinkMapper.class, ComponentMapper.class, CustomMeasureMapper.class, - DashboardMapper.class, DuplicationMapper.class, EventMapper.class, FileSourceMapper.class, @@ -278,9 +264,7 @@ public class MyBatis { UserGroupMapper.class, UserMapper.class, UserPermissionMapper.class, - UserTokenMapper.class, - WidgetMapper.class, - WidgetPropertyMapper.class + UserTokenMapper.class }; confBuilder.loadMappers(mappers); diff --git a/sonar-db/src/main/java/org/sonar/db/dashboard/ActiveDashboardDao.java b/sonar-db/src/main/java/org/sonar/db/dashboard/ActiveDashboardDao.java deleted file mode 100644 index ab72f8f98b3..00000000000 --- a/sonar-db/src/main/java/org/sonar/db/dashboard/ActiveDashboardDao.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2016 SonarSource SA - * mailto:contact AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.db.dashboard; - -import java.util.List; -import javax.annotation.CheckForNull; -import javax.annotation.Nullable; -import org.apache.ibatis.session.SqlSession; -import org.sonar.db.Dao; -import org.sonar.db.DbSession; -import org.sonar.db.MyBatis; - -public class ActiveDashboardDao implements Dao { - - private MyBatis mybatis; - - public ActiveDashboardDao(MyBatis mybatis) { - this.mybatis = mybatis; - } - - public void insert(DbSession session, ActiveDashboardDto activeDashboardDto) { - mapper(session).insert(activeDashboardDto); - session.commit(); - } - - public void insert(ActiveDashboardDto activeDashboardDto) { - DbSession session = mybatis.openSession(false); - try { - insert(session, activeDashboardDto); - session.commit(); - } finally { - MyBatis.closeQuietly(session); - } - } - - @CheckForNull - public ActiveDashboardDto selectById(DbSession session, long id){ - return mapper(session).selectById(id); - } - - public int selectMaxOrderIndexForNullUser() { - SqlSession session = mybatis.openSession(false); - try { - Integer max = mapper(session).selectMaxOrderIndexForNullUser(); - return max != null ? max.intValue() : 0; - } finally { - session.close(); - } - - } - - public List selectGlobalDashboardsForUserLogin(@Nullable String login) { - SqlSession session = mybatis.openSession(false); - try { - return mapper(session).selectGlobalDashboardsForUserLogin(login); - } finally { - session.close(); - } - } - - public List selectProjectDashboardsForUserLogin(@Nullable String login) { - SqlSession session = mybatis.openSession(false); - try { - return selectProjectDashboardsForUserLogin(session, login); - } finally { - session.close(); - } - } - - public List selectProjectDashboardsForUserLogin(SqlSession session, @Nullable String login) { - return mapper(session).selectProjectDashboardsForUserLogin(login); - } - - private static ActiveDashboardMapper mapper(SqlSession session) { - return session.getMapper(ActiveDashboardMapper.class); - } -} diff --git a/sonar-db/src/main/java/org/sonar/db/dashboard/ActiveDashboardDto.java b/sonar-db/src/main/java/org/sonar/db/dashboard/ActiveDashboardDto.java deleted file mode 100644 index 6db7d489c61..00000000000 --- a/sonar-db/src/main/java/org/sonar/db/dashboard/ActiveDashboardDto.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2016 SonarSource SA - * mailto:contact AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.db.dashboard; - -import java.util.Objects; - -public final class ActiveDashboardDto { - private Long id; - private Long dashboardId; - private Long userId; - private Integer orderIndex; - - /** - * @return the id - */ - public Long getId() { - return id; - } - - /** - * @param id the id to set - */ - public ActiveDashboardDto setId(Long id) { - this.id = id; - return this; - } - - /** - * @return the dashboardId - */ - public Long getDashboardId() { - return dashboardId; - } - - /** - * @param dashboardId the dashboardId to set - */ - public ActiveDashboardDto setDashboardId(Long dashboardId) { - this.dashboardId = dashboardId; - return this; - } - - /** - * @return the userId - */ - public Long getUserId() { - return userId; - } - - /** - * @param userId the userId to set - */ - public ActiveDashboardDto setUserId(Long userId) { - this.userId = userId; - return this; - } - - /** - * @return the orderIndex - */ - public Integer getOrderIndex() { - return orderIndex; - } - - /** - * @param orderIndex the orderIndex to set - */ - public ActiveDashboardDto setOrderIndex(Integer orderIndex) { - this.orderIndex = orderIndex; - return this; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - ActiveDashboardDto that = (ActiveDashboardDto) o; - return !(id != null ? !id.equals(that.id) : that.id != null); - } - - @Override - public int hashCode() { - return Objects.hashCode(id); - } -} diff --git a/sonar-db/src/main/java/org/sonar/db/dashboard/ActiveDashboardMapper.java b/sonar-db/src/main/java/org/sonar/db/dashboard/ActiveDashboardMapper.java deleted file mode 100644 index d0f3d834ff5..00000000000 --- a/sonar-db/src/main/java/org/sonar/db/dashboard/ActiveDashboardMapper.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2016 SonarSource SA - * mailto:contact AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.db.dashboard; - -import java.util.List; -import javax.annotation.CheckForNull; -import javax.annotation.Nullable; -import org.apache.ibatis.annotations.Param; - -public interface ActiveDashboardMapper { - - void insert(ActiveDashboardDto activeDashboardDto); - - ActiveDashboardDto selectById(long id); - - @CheckForNull - Integer selectMaxOrderIndexForNullUser(); - - List selectGlobalDashboardsForUserLogin(@Nullable @Param("login") String login); - - List selectProjectDashboardsForUserLogin(@Nullable @Param("login") String login); -} diff --git a/sonar-db/src/main/java/org/sonar/db/dashboard/DashboardDao.java b/sonar-db/src/main/java/org/sonar/db/dashboard/DashboardDao.java deleted file mode 100644 index 8e2a90ff2ce..00000000000 --- a/sonar-db/src/main/java/org/sonar/db/dashboard/DashboardDao.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2016 SonarSource SA - * mailto:contact AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.db.dashboard; - -import javax.annotation.CheckForNull; -import javax.annotation.Nullable; -import org.apache.ibatis.session.SqlSession; -import org.sonar.db.Dao; -import org.sonar.db.DbSession; -import org.sonar.db.MyBatis; - -public class DashboardDao implements Dao { - - private MyBatis mybatis; - - public DashboardDao(MyBatis mybatis) { - this.mybatis = mybatis; - } - - public DashboardDto selectGlobalDashboard(String name) { - SqlSession session = mybatis.openSession(false); - try { - DashboardMapper mapper = session.getMapper(DashboardMapper.class); - return mapper.selectGlobalDashboard(name); - } finally { - MyBatis.closeQuietly(session); - } - } - - public void insert(DbSession session, DashboardDto dashboardDto) { - DashboardMapper dashboardMapper = session.getMapper(DashboardMapper.class); - WidgetMapper widgetMapper = session.getMapper(WidgetMapper.class); - WidgetPropertyMapper widgetPropertyMapper = session.getMapper(WidgetPropertyMapper.class); - dashboardMapper.insert(dashboardDto); - for (WidgetDto widgetDto : dashboardDto.getWidgets()) { - widgetDto.setDashboardId(dashboardDto.getId()); - widgetMapper.insert(widgetDto); - for (WidgetPropertyDto widgetPropertyDto : widgetDto.getWidgetProperties()) { - widgetPropertyDto.setWidgetId(widgetDto.getId()); - widgetPropertyMapper.insert(widgetPropertyDto); - } - } - } - - public void insert(DashboardDto dashboardDto) { - DbSession session = mybatis.openSession(false); - try { - insert(session, dashboardDto); - session.commit(); - } finally { - MyBatis.closeQuietly(session); - } - } - - @CheckForNull - public DashboardDto selectById(DbSession session, long id) { - return mapper(session).selectById(id); - } - - /** - * Get dashboard if allowed : shared or owned by logged-in user - * @param userId id of logged-in user, null if anonymous - */ - @CheckForNull - public DashboardDto selectAllowedByKey(DbSession session, Long key, @Nullable Long userId) { - return mapper(session).selectAllowedById(key, userId != null ? userId : -1L); - } - - private static DashboardMapper mapper(DbSession session) { - return session.getMapper(DashboardMapper.class); - } -} diff --git a/sonar-db/src/main/java/org/sonar/db/dashboard/DashboardDto.java b/sonar-db/src/main/java/org/sonar/db/dashboard/DashboardDto.java deleted file mode 100644 index a70ad3f6b6c..00000000000 --- a/sonar-db/src/main/java/org/sonar/db/dashboard/DashboardDto.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2016 SonarSource SA - * mailto:contact AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.db.dashboard; - -import com.google.common.collect.Lists; -import java.util.Collection; -import java.util.List; -import org.sonar.db.Dto; - -public final class DashboardDto extends Dto { - - private Long id; - private Long userId; - private String name; - private String description; - private String columnLayout; - private boolean shared; - private List widgetDtos = Lists.newArrayList(); - - public Long getId() { - return id; - } - - @Override - public Long getKey() { - return id; - } - - public DashboardDto setId(Long id) { - this.id = id; - return this; - } - - public Long getUserId() { - return userId; - } - - public DashboardDto setUserId(Long userId) { - this.userId = userId; - return this; - } - - public String getName() { - return name; - } - - public DashboardDto setName(String name) { - this.name = name; - return this; - } - - public String getDescription() { - return description; - } - - public DashboardDto setDescription(String description) { - this.description = description; - return this; - } - - public String getColumnLayout() { - return columnLayout; - } - - public DashboardDto setColumnLayout(String columnLayout) { - this.columnLayout = columnLayout; - return this; - } - - public boolean getShared() { - return shared; - } - - public DashboardDto setShared(boolean shared) { - this.shared = shared; - return this; - } - - public Collection getWidgets() { - return widgetDtos; - } - - public DashboardDto addWidget(WidgetDto widgetDto) { - widgetDtos.add(widgetDto); - return this; - } - -} diff --git a/sonar-db/src/main/java/org/sonar/db/dashboard/DashboardMapper.java b/sonar-db/src/main/java/org/sonar/db/dashboard/DashboardMapper.java deleted file mode 100644 index 720ceb5b770..00000000000 --- a/sonar-db/src/main/java/org/sonar/db/dashboard/DashboardMapper.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2016 SonarSource SA - * mailto:contact AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.db.dashboard; - -import javax.annotation.CheckForNull; -import org.apache.ibatis.annotations.Insert; -import org.apache.ibatis.annotations.Options; -import org.apache.ibatis.annotations.Param; -import org.apache.ibatis.annotations.Select; - -public interface DashboardMapper { - - String COLUMNS = "id, user_id as \"userId\", name, description, column_layout as \"columnLayout\", " + - "shared, created_at as \"createdAt\", updated_at as \"updatedAt\""; - - @CheckForNull - @Select("select " + COLUMNS + " from dashboards where id=#{id}") - DashboardDto selectById(long id); - - @CheckForNull - @Select("select " + COLUMNS + " from dashboards where id=#{id} and (shared=${_true} or user_id=${userId})") - DashboardDto selectAllowedById(@Param("id") long id, @Param("userId") long userId); - - @CheckForNull - @Select("select " + COLUMNS + " from dashboards WHERE name=#{id} and user_id is null") - DashboardDto selectGlobalDashboard(String name); - - @Insert("INSERT INTO dashboards (user_id, name, description, column_layout, shared, created_at, updated_at) " + - "VALUES (#{userId}, #{name}, #{description}, #{columnLayout}, #{shared}, #{createdAt}, #{updatedAt})") - @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") - void insert(DashboardDto dashboardDto); -} diff --git a/sonar-db/src/main/java/org/sonar/db/dashboard/WidgetDao.java b/sonar-db/src/main/java/org/sonar/db/dashboard/WidgetDao.java deleted file mode 100644 index 0b39fccf929..00000000000 --- a/sonar-db/src/main/java/org/sonar/db/dashboard/WidgetDao.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2016 SonarSource SA - * mailto:contact AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.db.dashboard; - -import java.util.Collection; -import org.sonar.db.Dao; -import org.sonar.db.DbSession; -import org.sonar.db.MyBatis; - -public class WidgetDao implements Dao { - - private MyBatis myBatis; - - public WidgetDao(MyBatis myBatis) { - this.myBatis = myBatis; - } - - public WidgetDto selectByKey(Long widgetId) { - DbSession session = myBatis.openSession(false); - try { - return selectByKey(session, widgetId); - } finally { - MyBatis.closeQuietly(session); - } - } - - public WidgetDto selectByKey(DbSession session, Long widgetId) { - return mapper(session).selectById(widgetId); - } - - public WidgetDto update(WidgetDto item) { - DbSession session = myBatis.openSession(false); - try { - return update(session, item); - } finally { - MyBatis.closeQuietly(session); - } - } - - public WidgetDto update(DbSession session, WidgetDto item) { - mapper(session).update(item); - return item; - } - - public Collection findByDashboard(DbSession session, long dashboardKey) { - return mapper(session).selectByDashboard(dashboardKey); - } - - public Collection findAll(DbSession session) { - return mapper(session).selectAll(); - } - - private static WidgetMapper mapper(DbSession session) { - return session.getMapper(WidgetMapper.class); - } - -} diff --git a/sonar-db/src/main/java/org/sonar/db/dashboard/WidgetDto.java b/sonar-db/src/main/java/org/sonar/db/dashboard/WidgetDto.java deleted file mode 100644 index d44d5dc678c..00000000000 --- a/sonar-db/src/main/java/org/sonar/db/dashboard/WidgetDto.java +++ /dev/null @@ -1,205 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2016 SonarSource SA - * mailto:contact AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.db.dashboard; - -import com.google.common.collect.Lists; -import java.util.Collection; -import java.util.Date; -import java.util.List; - -public class WidgetDto { - private Long id; - private Long dashboardId; - private String widgetKey; - private String name; - private String description; - private Integer columnIndex; - private Integer rowIndex; - private boolean configured; - private Integer resourceId; - private Date createdAt; - private Date updatedAt; - private List widgetPropertyDtos = Lists.newArrayList(); - - /** - * @return the id - */ - public Long getId() { - return id; - } - - /** - * @param id the id to set - */ - public WidgetDto setId(Long id) { - this.id = id; - return this; - } - - /** - * @return the dashboardId - */ - public Long getDashboardId() { - return dashboardId; - } - - /** - * @param dashboardId the dashboardId to set - */ - public WidgetDto setDashboardId(Long dashboardId) { - this.dashboardId = dashboardId; - return this; - } - - public String getWidgetKey() { - return widgetKey; - } - - public WidgetDto setWidgetKey(String s) { - this.widgetKey = s; - return this; - } - - /** - * @return the name - */ - public String getName() { - return name; - } - - /** - * @param name the name to set - */ - public WidgetDto setName(String name) { - this.name = name; - return this; - } - - /** - * @return the description - */ - public String getDescription() { - return description; - } - - /** - * @param description the description to set - */ - public WidgetDto setDescription(String description) { - this.description = description; - return this; - } - - /** - * @return the columnIndex - */ - public Integer getColumnIndex() { - return columnIndex; - } - - /** - * @param columnIndex the columnIndex to set - */ - public WidgetDto setColumnIndex(Integer columnIndex) { - this.columnIndex = columnIndex; - return this; - } - - /** - * @return the rowIndex - */ - public Integer getRowIndex() { - return rowIndex; - } - - /** - * @param rowIndex the rowIndex to set - */ - public WidgetDto setRowIndex(Integer rowIndex) { - this.rowIndex = rowIndex; - return this; - } - - /** - * @return the configured - */ - public boolean getConfigured() { - return configured; - } - - /** - * @param configured the configured to set - */ - public WidgetDto setConfigured(boolean configured) { - this.configured = configured; - return this; - } - - /** - * @return the widgetProperties - */ - public Collection getWidgetProperties() { - return widgetPropertyDtos; - } - - /** - * @param widgetPropertyDto the widgetProperty to set - */ - public WidgetDto addWidgetProperty(WidgetPropertyDto widgetPropertyDto) { - widgetPropertyDtos.add(widgetPropertyDto); - return this; - } - - /** - * @return the resourceId - * @since 3.1 - */ - public Integer getResourceId() { - return resourceId; - } - - /** - * @param resourceId the resourceId to set - * @since 3.1 - */ - public WidgetDto setResourceId(Integer resourceId) { - this.resourceId = resourceId; - return this; - } - - public WidgetDto setCreatedAt(Date datetime) { - this.createdAt = datetime; - return this; - } - - public WidgetDto setUpdatedAt(Date datetime) { - this.updatedAt = datetime; - return this; - } - - public final Date getCreatedAt() { - return this.createdAt; - } - - public final Date getUpdatedAt() { - return this.updatedAt; - } - -} diff --git a/sonar-db/src/main/java/org/sonar/db/dashboard/WidgetMapper.java b/sonar-db/src/main/java/org/sonar/db/dashboard/WidgetMapper.java deleted file mode 100644 index a169f5d8028..00000000000 --- a/sonar-db/src/main/java/org/sonar/db/dashboard/WidgetMapper.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2016 SonarSource SA - * mailto:contact AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.db.dashboard; - -import java.util.Collection; -import org.apache.ibatis.annotations.Insert; -import org.apache.ibatis.annotations.Options; -import org.apache.ibatis.annotations.Update; - -public interface WidgetMapper { - - @Insert("insert into widgets (dashboard_id, widget_key, name, description, column_index, " + - " row_index, configured, created_at, updated_at, resource_id)" + - " values (#{dashboardId,jdbcType=INTEGER}, #{widgetKey,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, " + - " #{description,jdbcType=VARCHAR}, #{columnIndex,jdbcType=INTEGER}, " + - " #{rowIndex,jdbcType=INTEGER}, #{configured,jdbcType=BOOLEAN}, #{createdAt,jdbcType=TIMESTAMP}, #{updatedAt,jdbcType=TIMESTAMP}, #{resourceId,jdbcType=INTEGER})") - @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") - void insert(WidgetDto widgetDto); - - WidgetDto selectById(long widgetId); - - Collection selectByDashboard(long dashboardKey); - - Collection selectAll(); - - @Update("UPDATE widgets SET " + - "dashboard_id=#{dashboardId,jdbcType=INTEGER}, " + - "widget_key=#{widgetKey,jdbcType=VARCHAR}, " + - "name=#{name,jdbcType=VARCHAR}, " + - "description=#{description,jdbcType=VARCHAR}, " + - "column_index=#{columnIndex,jdbcType=INTEGER}, " + - "row_index=#{rowIndex,jdbcType=INTEGER}, " + - "configured=#{configured,jdbcType=BOOLEAN}, " + - "created_at=#{createdAt,jdbcType=TIMESTAMP}, " + - "updated_at=#{updatedAt,jdbcType=TIMESTAMP}, " + - "resource_id=#{resourceId,jdbcType=INTEGER} " + - "WHERE id=#{id}") - @Options(useGeneratedKeys = false) - void update(WidgetDto item); -} diff --git a/sonar-db/src/main/java/org/sonar/db/dashboard/WidgetPropertyDao.java b/sonar-db/src/main/java/org/sonar/db/dashboard/WidgetPropertyDao.java deleted file mode 100644 index 7f1a66c54e3..00000000000 --- a/sonar-db/src/main/java/org/sonar/db/dashboard/WidgetPropertyDao.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2016 SonarSource SA - * mailto:contact AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.db.dashboard; - -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import org.sonar.db.Dao; -import org.sonar.db.DbSession; -import org.sonar.db.MyBatis; - -import static org.sonar.db.DatabaseUtils.executeLargeInputs; - -public class WidgetPropertyDao implements Dao { - - private final MyBatis myBatis; - - public WidgetPropertyDao(MyBatis myBatis) { - this.myBatis = myBatis; - } - - public WidgetPropertyDto insert(WidgetPropertyDto item) { - DbSession session = myBatis.openSession(false); - try { - return insert(session, item); - } finally { - MyBatis.closeQuietly(session); - } - } - - public WidgetPropertyDto insert(DbSession session, WidgetPropertyDto item) { - mapper(session).insert(item); - return item; - } - - public void insert(DbSession session, Collection items) { - for (WidgetPropertyDto item : items) { - insert(session, item); - } - } - - public WidgetPropertyDto selectByKey(Long propertyId) { - DbSession session = myBatis.openSession(false); - try { - return selectByKey(session, propertyId); - } finally { - MyBatis.closeQuietly(session); - } - } - - public WidgetPropertyDto selectByKey(DbSession session, Long propertyId) { - return mapper(session).selectById(propertyId); - } - - public Collection selectByDashboard(DbSession session, long dashboardKey) { - return mapper(session).selectByDashboard(dashboardKey); - } - - public void deleteByWidgetIds(DbSession session, List widgetIdsWithPropertiesToDelete) { - executeLargeInputs( - widgetIdsWithPropertiesToDelete, - input -> { - mapper(session).deleteByWidgetIds(input); - return Collections.emptyList(); - }); - } - - private static WidgetPropertyMapper mapper(DbSession session) { - return session.getMapper(WidgetPropertyMapper.class); - } -} diff --git a/sonar-db/src/main/java/org/sonar/db/dashboard/WidgetPropertyDto.java b/sonar-db/src/main/java/org/sonar/db/dashboard/WidgetPropertyDto.java deleted file mode 100644 index 55f975a8833..00000000000 --- a/sonar-db/src/main/java/org/sonar/db/dashboard/WidgetPropertyDto.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2016 SonarSource SA - * mailto:contact AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.db.dashboard; - -import com.google.common.collect.ArrayListMultimap; -import com.google.common.collect.ListMultimap; -import java.util.Collection; - -public class WidgetPropertyDto { - private Long id; - private Long widgetId; - private String propertyKey; - private String textValue; - - public Long getId() { - return id; - } - - public WidgetPropertyDto setId(Long id) { - this.id = id; - return this; - } - - public Long getWidgetId() { - return widgetId; - } - - public WidgetPropertyDto setWidgetId(Long widgetId) { - this.widgetId = widgetId; - return this; - } - - public String getPropertyKey() { - return propertyKey; - } - - public WidgetPropertyDto setPropertyKey(String s) { - this.propertyKey = s; - return this; - } - - public String getTextValue() { - return textValue; - } - - public WidgetPropertyDto setTextValue(String s) { - this.textValue = s; - return this; - } - - public static ListMultimap groupByWidgetId(Collection properties) { - ListMultimap group = ArrayListMultimap.create(); - for (WidgetPropertyDto property : properties) { - group.put(property.getWidgetId(), property); - } - return group; - } -} diff --git a/sonar-db/src/main/java/org/sonar/db/dashboard/WidgetPropertyMapper.java b/sonar-db/src/main/java/org/sonar/db/dashboard/WidgetPropertyMapper.java deleted file mode 100644 index 8c962eced8e..00000000000 --- a/sonar-db/src/main/java/org/sonar/db/dashboard/WidgetPropertyMapper.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2016 SonarSource SA - * mailto:contact AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.db.dashboard; - -import java.util.Collection; -import java.util.List; -import javax.annotation.CheckForNull; -import org.apache.ibatis.annotations.Insert; -import org.apache.ibatis.annotations.Options; -import org.apache.ibatis.annotations.Select; - -public interface WidgetPropertyMapper { - - String COLUMNS = "wp.id, wp.widget_id as \"widgetId\", wp.kee as \"propertyKey\", wp.text_value as \"textValue\""; - - @Insert("insert into widget_properties (widget_id, kee, text_value) values (#{widgetId}, #{propertyKey}, #{textValue})") - @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") - void insert(WidgetPropertyDto dto); - - @CheckForNull - @Select("select " + COLUMNS + " from widget_properties wp where wp.id=#{id}") - WidgetPropertyDto selectById(long propertyId); - - @Select("select " + COLUMNS + " from widget_properties wp " + - "inner join widgets w on w.id=wp.widget_id where w.dashboard_id=#{id}") - Collection selectByDashboard(long dashboardKey); - - void deleteByWidgetIds(List widgetIds); -} diff --git a/sonar-db/src/main/java/org/sonar/db/dashboard/package-info.java b/sonar-db/src/main/java/org/sonar/db/dashboard/package-info.java deleted file mode 100644 index 10b4706f3bc..00000000000 --- a/sonar-db/src/main/java/org/sonar/db/dashboard/package-info.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2016 SonarSource SA - * mailto:contact AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -@ParametersAreNonnullByDefault -package org.sonar.db.dashboard; - -import javax.annotation.ParametersAreNonnullByDefault; - diff --git a/sonar-db/src/main/java/org/sonar/db/user/UserDao.java b/sonar-db/src/main/java/org/sonar/db/user/UserDao.java index b75b14d7ce9..74bd4355b9f 100644 --- a/sonar-db/src/main/java/org/sonar/db/user/UserDao.java +++ b/sonar-db/src/main/java/org/sonar/db/user/UserDao.java @@ -157,8 +157,6 @@ public class UserDao implements Dao { } mapper.removeUserFromGroups(dto.getId()); - mapper.deleteUserActiveDashboards(dto.getId()); - mapper.deleteUnsharedUserDashboards(dto.getId()); mapper.deleteUnsharedUserIssueFilters(dto.getLogin()); mapper.deleteUserIssueFilterFavourites(dto.getLogin()); mapper.deleteUnsharedUserMeasureFilters(dto.getId()); diff --git a/sonar-db/src/main/java/org/sonar/db/user/UserMapper.java b/sonar-db/src/main/java/org/sonar/db/user/UserMapper.java index 9088a71b618..8795c1e4c7e 100644 --- a/sonar-db/src/main/java/org/sonar/db/user/UserMapper.java +++ b/sonar-db/src/main/java/org/sonar/db/user/UserMapper.java @@ -66,10 +66,6 @@ public interface UserMapper { void removeUserFromGroups(long userId); - void deleteUserActiveDashboards(long userId); - - void deleteUnsharedUserDashboards(long userId); - void deleteUnsharedUserIssueFilters(String login); void deleteUserIssueFilterFavourites(String login); diff --git a/sonar-db/src/main/resources/org/sonar/db/dashboard/ActiveDashboardMapper.xml b/sonar-db/src/main/resources/org/sonar/db/dashboard/ActiveDashboardMapper.xml deleted file mode 100644 index 9349e3c8bdb..00000000000 --- a/sonar-db/src/main/resources/org/sonar/db/dashboard/ActiveDashboardMapper.xml +++ /dev/null @@ -1,73 +0,0 @@ - - - - - - - ad.id, - ad.user_id as "userId", - ad.dashboard_id as "dashboardId", - ad.order_index as "orderIndex" - - - - INSERT INTO active_dashboards (dashboard_id, user_id, order_index) - VALUES (#{dashboardId}, #{userId}, #{orderIndex}) - - - - - - - - d.id, d.user_id as "userId", d.name, d.description, d.column_layout as "columnLayout", - d.shared, d.created_at as "createdAt", d.updated_at as "updatedAt" - - - - - - - diff --git a/sonar-db/src/main/resources/org/sonar/db/dashboard/DashboardMapper.xml b/sonar-db/src/main/resources/org/sonar/db/dashboard/DashboardMapper.xml deleted file mode 100644 index ce27a44c73b..00000000000 --- a/sonar-db/src/main/resources/org/sonar/db/dashboard/DashboardMapper.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/sonar-db/src/main/resources/org/sonar/db/dashboard/WidgetMapper.xml b/sonar-db/src/main/resources/org/sonar/db/dashboard/WidgetMapper.xml deleted file mode 100644 index a631f84b6a7..00000000000 --- a/sonar-db/src/main/resources/org/sonar/db/dashboard/WidgetMapper.xml +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - w.id as "id", - w.dashboard_id as "dashboardId", - w.widget_key as "widgetKey", - w.name as "name", - w.description as "description", - w.column_index as "columnIndex", - w.row_index as "rowIndex", - w.configured as "configured", - w.created_at as "createdAt", - w.updated_at as "updatedAt", - w.resource_id as "resourceId" - - - - - - - - - diff --git a/sonar-db/src/main/resources/org/sonar/db/dashboard/WidgetPropertyMapper.xml b/sonar-db/src/main/resources/org/sonar/db/dashboard/WidgetPropertyMapper.xml deleted file mode 100644 index a2bf8024a7f..00000000000 --- a/sonar-db/src/main/resources/org/sonar/db/dashboard/WidgetPropertyMapper.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - DELETE FROM widget_properties - WHERE widget_id IN - #{wid} - - - diff --git a/sonar-db/src/main/resources/org/sonar/db/user/UserMapper.xml b/sonar-db/src/main/resources/org/sonar/db/user/UserMapper.xml index cde781fd0ab..7087a0a4b2f 100644 --- a/sonar-db/src/main/resources/org/sonar/db/user/UserMapper.xml +++ b/sonar-db/src/main/resources/org/sonar/db/user/UserMapper.xml @@ -127,14 +127,6 @@ DELETE FROM properties WHERE user_id=#{id} - - DELETE FROM dashboards WHERE user_id=#{id} and shared <> ${_true} - - - - DELETE FROM active_dashboards WHERE user_id=#{id} - - DELETE FROM measure_filters WHERE user_id=#{id} and shared <> ${_true} diff --git a/sonar-db/src/test/java/org/sonar/db/DaoModuleTest.java b/sonar-db/src/test/java/org/sonar/db/DaoModuleTest.java index a87ffc547e0..f653c76bfce 100644 --- a/sonar-db/src/test/java/org/sonar/db/DaoModuleTest.java +++ b/sonar-db/src/test/java/org/sonar/db/DaoModuleTest.java @@ -29,6 +29,6 @@ public class DaoModuleTest { public void verify_count_of_added_components() { ComponentContainer container = new ComponentContainer(); new DaoModule().configure(container); - assertThat(container.size()).isEqualTo(2 + 52); + assertThat(container.size()).isEqualTo(2 + 48); } } diff --git a/sonar-db/src/test/java/org/sonar/db/dashboard/ActiveDashboardDaoTest.java b/sonar-db/src/test/java/org/sonar/db/dashboard/ActiveDashboardDaoTest.java deleted file mode 100644 index 36e8e2ff401..00000000000 --- a/sonar-db/src/test/java/org/sonar/db/dashboard/ActiveDashboardDaoTest.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2016 SonarSource SA - * mailto:contact AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.db.dashboard; - -import org.junit.Rule; -import org.junit.Test; -import org.sonar.api.utils.System2; -import org.sonar.db.DbSession; -import org.sonar.db.DbTester; - -import static org.assertj.core.api.Assertions.assertThat; - - -public class ActiveDashboardDaoTest { - - @Rule - public DbTester dbTester = DbTester.create(System2.INSTANCE); - - DbSession session = dbTester.getSession(); - - ActiveDashboardDao underTest = dbTester.getDbClient().activeDashboardDao(); - - @Test - public void shouldInsert() { - dbTester.prepareDbUnit(getClass(), "shouldInsert.xml"); - - ActiveDashboardDto dashboard = new ActiveDashboardDto(); - dashboard.setDashboardId(2L); - dashboard.setUserId(3L); - dashboard.setOrderIndex(4); - underTest.insert(dashboard); - - dbTester.assertDbUnit(getClass(), "shouldInsert-result.xml", "active_dashboards"); - } - - @Test - public void shouldInsertWithNoUser() { - dbTester.prepareDbUnit(getClass(), "shouldInsert.xml"); - - ActiveDashboardDto dashboard = new ActiveDashboardDto(); - dashboard.setDashboardId(2L); - dashboard.setOrderIndex(4); - underTest.insert(dashboard); - - dbTester.assertDbUnit(getClass(), "shouldInsertWithNoUser-result.xml", "active_dashboards"); - } - - @Test - public void shouldGetMaxOrderIndexForNullUser() { - dbTester.prepareDbUnit(getClass(), "shouldGetMaxOrderIndexForNullUser.xml"); - - int index = underTest.selectMaxOrderIndexForNullUser(); - - assertThat(index).isEqualTo(15); - } - - @Test - public void shouldGetZeroMaxOrderIndex() { - dbTester.prepareDbUnit(getClass(), "empty.xml"); - - int index = underTest.selectMaxOrderIndexForNullUser(); - - assertThat(index).isZero(); - } - - @Test - public void should_get_dashboards_for_anonymous() { - dbTester.prepareDbUnit(getClass(), "shouldSelectDashboardsForAnonymous.xml"); - - assertThat(underTest.selectGlobalDashboardsForUserLogin(null)).hasSize(2).extracting("id").containsExactly(2L, 1L); - } - - @Test - public void should_get_dashboards_for_user() { - dbTester.prepareDbUnit(getClass(), "shouldSelectDashboardsForUser.xml"); - - assertThat(underTest.selectGlobalDashboardsForUserLogin("obiwan")).hasSize(2).extracting("id").containsExactly(2L, 1L); - } - - @Test - public void select_by_id() throws Exception { - ActiveDashboardDto dto = new ActiveDashboardDto() - .setDashboardId(10L) - .setOrderIndex(2) - .setUserId(5L); - underTest.insert(session, dto); - session.commit(); - - ActiveDashboardDto dtoReloaded = underTest.selectById(session, dto.getId()); - assertThat(dtoReloaded).isNotNull(); - assertThat(dtoReloaded.getDashboardId()).isEqualTo(10L); - assertThat(dtoReloaded.getUserId()).isEqualTo(5L); - assertThat(dtoReloaded.getOrderIndex()).isEqualTo(2); - - assertThat(underTest.selectById(session, 123L)).isNull(); - } -} diff --git a/sonar-db/src/test/java/org/sonar/db/dashboard/DashboardDaoTest.java b/sonar-db/src/test/java/org/sonar/db/dashboard/DashboardDaoTest.java deleted file mode 100644 index 95a8cd0503d..00000000000 --- a/sonar-db/src/test/java/org/sonar/db/dashboard/DashboardDaoTest.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2016 SonarSource SA - * mailto:contact AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.db.dashboard; - -import java.util.Date; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.api.utils.System2; -import org.sonar.db.DbTester; - -import static org.hamcrest.Matchers.is; -import static org.hamcrest.Matchers.nullValue; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertThat; - - -public class DashboardDaoTest { - - @Rule - public DbTester dbTester = DbTester.create(System2.INSTANCE); - - DashboardDao underTest = dbTester.getDbClient().dashboardDao(); - - @Test - public void shouldSelectGlobalDashboard() { - dbTester.prepareDbUnit(getClass(), "shouldSelectGlobalDashboard.xml"); - DashboardDto dashboard = underTest.selectGlobalDashboard("SQALE"); - assertThat(dashboard.getId(), is(2L)); - assertThat(dashboard.getUserId(), nullValue()); - - assertNull(underTest.selectGlobalDashboard("unknown")); - } - - @Test - public void shouldInsert() { - dbTester.prepareDbUnit(getClass(), "shouldInsert.xml"); - Date aDate = new Date(); - - DashboardDto dashboardDto = new DashboardDto(); - dashboardDto.setUserId(6L); - dashboardDto.setName("My Dashboard"); - dashboardDto.setDescription("This is a dashboard"); - dashboardDto.setColumnLayout("100%"); - dashboardDto.setShared(true); - dashboardDto.setCreatedAt(aDate); - dashboardDto.setUpdatedAt(aDate); - - WidgetDto widgetDto = new WidgetDto(); - widgetDto.setWidgetKey("code_coverage"); - widgetDto.setName("Code coverage"); - widgetDto.setDescription("Widget for code coverage"); - widgetDto.setColumnIndex(13); - widgetDto.setRowIndex(14); - widgetDto.setConfigured(true); - widgetDto.setCreatedAt(aDate); - widgetDto.setUpdatedAt(aDate); - dashboardDto.addWidget(widgetDto); - - WidgetPropertyDto property = new WidgetPropertyDto(); - property.setPropertyKey("displayITs"); - property.setTextValue("true"); - widgetDto.addWidgetProperty(property); - - underTest.insert(dashboardDto); - - dbTester.assertDbUnit(getClass(), "shouldInsert-result.xml", new String[] {"created_at", "updated_at"}, "dashboards", "widgets", "widget_properties"); - } - - @Test - public void shouldInsertWithNullableColumns() { - dbTester.prepareDbUnit(getClass(), "shouldInsert.xml"); - - DashboardDto dashboardDto = new DashboardDto(); - dashboardDto.setUserId(null); - dashboardDto.setName(null); - dashboardDto.setDescription(null); - dashboardDto.setColumnLayout(null); - dashboardDto.setShared(true); - dashboardDto.setCreatedAt(null); - dashboardDto.setUpdatedAt(null); - - WidgetDto widgetDto = new WidgetDto(); - widgetDto.setWidgetKey("code_coverage"); - widgetDto.setName(null); - widgetDto.setDescription(null); - widgetDto.setColumnIndex(null); - widgetDto.setRowIndex(null); - widgetDto.setConfigured(true); - widgetDto.setCreatedAt(null); - widgetDto.setUpdatedAt(null); - dashboardDto.addWidget(widgetDto); - - WidgetPropertyDto property = new WidgetPropertyDto(); - property.setPropertyKey(null); - property.setTextValue(null); - widgetDto.addWidgetProperty(property); - - underTest.insert(dashboardDto); - - dbTester.assertDbUnit(getClass(), "shouldInsertWithNullableColumns-result.xml", "dashboards", "widgets", "widget_properties"); - } - -} diff --git a/sonar-db/src/test/java/org/sonar/db/dashboard/WidgetDaoTest.java b/sonar-db/src/test/java/org/sonar/db/dashboard/WidgetDaoTest.java deleted file mode 100644 index 813e3272353..00000000000 --- a/sonar-db/src/test/java/org/sonar/db/dashboard/WidgetDaoTest.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2016 SonarSource SA - * mailto:contact AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.db.dashboard; - -import java.util.Collection; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.api.utils.System2; -import org.sonar.db.DbSession; -import org.sonar.db.DbTester; - -import static org.assertj.core.api.Assertions.assertThat; - -public class WidgetDaoTest { - - @Rule - public DbTester db = DbTester.create(System2.INSTANCE); - DbSession dbSession = db.getSession(); - - WidgetDao underTest = db.getDbClient().widgetDao(); - - @Test - public void should_select_all() { - db.prepareDbUnit(this.getClass(), "before.xml"); - - Collection widgets = underTest.findAll(db.getSession()); - assertThat(widgets).hasSize(5); - for (WidgetDto widget : widgets) { - assertThat(widget.getId()).isNotNull(); - assertThat(widget.getName()).isNotNull(); - assertThat(widget.getDescription()).isNotNull(); - } - } - - @Test - public void select_by_dashboard_key() { - db.prepareDbUnit(this.getClass(), "before.xml"); - - Collection result = underTest.findByDashboard(dbSession, 1L); - - assertThat(result).hasSize(5); - } - - @Test - public void select_by_key() { - db.prepareDbUnit(this.getClass(), "before.xml"); - - WidgetDto result = underTest.selectByKey(dbSession, 1L); - - assertThat(result).isNotNull(); - } -} diff --git a/sonar-db/src/test/java/org/sonar/db/user/UserDaoTest.java b/sonar-db/src/test/java/org/sonar/db/user/UserDaoTest.java index dc1114eef2f..39a771d08e2 100644 --- a/sonar-db/src/test/java/org/sonar/db/user/UserDaoTest.java +++ b/sonar-db/src/test/java/org/sonar/db/user/UserDaoTest.java @@ -33,14 +33,11 @@ import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.DbTester; import org.sonar.db.RowNotFoundException; -import org.sonar.db.dashboard.ActiveDashboardDto; -import org.sonar.db.dashboard.DashboardDto; import org.sonar.db.issue.IssueFilterDto; import org.sonar.db.issue.IssueFilterFavouriteDto; import org.sonar.db.measure.MeasureFilterDto; import org.sonar.db.measure.MeasureFilterFavouriteDto; import org.sonar.db.organization.OrganizationDto; -import org.sonar.db.permission.UserPermissionDto; import org.sonar.db.property.PropertyDto; import org.sonar.db.property.PropertyQuery; @@ -400,8 +397,6 @@ public class UserDaoTest { @Test public void deactivate_user() throws Exception { UserDto user = newActiveUser(); - DashboardDto dashboard = insertDashboard(user, false); - ActiveDashboardDto activeDashboard = insertActiveDashboard(dashboard, user); IssueFilterDto issueFilter = insertIssueFilter(user, false); IssueFilterFavouriteDto issueFilterFavourite = insertIssueFilterFavourite(issueFilter, user); MeasureFilterDto measureFilter = insertMeasureFilter(user, false); @@ -430,8 +425,6 @@ public class UserDaoTest { assertThat(underTest.selectUserById(session, otherUser.getId())).isNotNull(); - assertThat(dbClient.dashboardDao().selectById(session, dashboard.getId())).isNull(); - assertThat(dbClient.activeDashboardDao().selectById(session, activeDashboard.getId())).isNull(); assertThat(dbClient.issueFilterDao().selectById(session, issueFilter.getId())).isNull(); assertThat(dbClient.issueFilterFavouriteDao().selectById(session, issueFilterFavourite.getId())).isNull(); assertThat(dbClient.measureFilterDao().selectById(session, measureFilter.getId())).isNull(); @@ -441,22 +434,6 @@ public class UserDaoTest { assertThat(dbClient.groupMembershipDao().countGroups(session, builder().login(user.getLogin()).membership(IN).build(), user.getId())).isZero(); } - @Test - public void deactivate_user_does_not_remove_shared_dashboard() throws Exception { - UserDto user = newActiveUser(); - DashboardDto notSharedDashboard = insertDashboard(user, false); - DashboardDto sharedDashboard = insertDashboard(user, true); - session.commit(); - - boolean deactivated = underTest.deactivateUserByLogin(session, user.getLogin()); - assertThat(deactivated).isTrue(); - - assertThat(dbClient.dashboardDao().selectById(session, notSharedDashboard.getId())).isNull(); - DashboardDto sharedDashboardReloaded = dbClient.dashboardDao().selectById(session, sharedDashboard.getId()); - assertThat(sharedDashboardReloaded).isNotNull(); - assertThat(sharedDashboardReloaded.getUserId()).isEqualTo(user.getId()); - } - @Test public void deactivate_user_does_not_remove_shared_issue_filter() throws Exception { UserDto user = newActiveUser(); @@ -788,18 +765,6 @@ public class UserDaoTest { return dto; } - private DashboardDto insertDashboard(UserDto user, boolean shared) { - DashboardDto dto = new DashboardDto().setUserId(user.getId()).setShared(shared); - dbClient.dashboardDao().insert(session, dto); - return dto; - } - - private ActiveDashboardDto insertActiveDashboard(DashboardDto dashboard, UserDto user) { - ActiveDashboardDto dto = new ActiveDashboardDto().setDashboardId(dashboard.getId()).setUserId(user.getId()); - dbClient.activeDashboardDao().insert(session, dto); - return dto; - } - private IssueFilterDto insertIssueFilter(UserDto user, boolean shared) { IssueFilterDto dto = new IssueFilterDto().setUserLogin(user.getLogin()).setName(randomAlphanumeric(100)).setShared(shared); dbClient.issueFilterDao().insert(session, dto); diff --git a/sonar-db/src/test/resources/org/sonar/db/dashboard/ActiveDashboardDaoTest/empty.xml b/sonar-db/src/test/resources/org/sonar/db/dashboard/ActiveDashboardDaoTest/empty.xml deleted file mode 100644 index 871dedcb5e9..00000000000 --- a/sonar-db/src/test/resources/org/sonar/db/dashboard/ActiveDashboardDaoTest/empty.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/sonar-db/src/test/resources/org/sonar/db/dashboard/ActiveDashboardDaoTest/shouldGetMaxOrderIndexForNullUser.xml b/sonar-db/src/test/resources/org/sonar/db/dashboard/ActiveDashboardDaoTest/shouldGetMaxOrderIndexForNullUser.xml deleted file mode 100644 index 1a3d92374b6..00000000000 --- a/sonar-db/src/test/resources/org/sonar/db/dashboard/ActiveDashboardDaoTest/shouldGetMaxOrderIndexForNullUser.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - diff --git a/sonar-db/src/test/resources/org/sonar/db/dashboard/ActiveDashboardDaoTest/shouldInsert-result.xml b/sonar-db/src/test/resources/org/sonar/db/dashboard/ActiveDashboardDaoTest/shouldInsert-result.xml deleted file mode 100644 index 75fb1670ce7..00000000000 --- a/sonar-db/src/test/resources/org/sonar/db/dashboard/ActiveDashboardDaoTest/shouldInsert-result.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - diff --git a/sonar-db/src/test/resources/org/sonar/db/dashboard/ActiveDashboardDaoTest/shouldInsert.xml b/sonar-db/src/test/resources/org/sonar/db/dashboard/ActiveDashboardDaoTest/shouldInsert.xml deleted file mode 100644 index 871dedcb5e9..00000000000 --- a/sonar-db/src/test/resources/org/sonar/db/dashboard/ActiveDashboardDaoTest/shouldInsert.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/sonar-db/src/test/resources/org/sonar/db/dashboard/ActiveDashboardDaoTest/shouldInsertWithNoUser-result.xml b/sonar-db/src/test/resources/org/sonar/db/dashboard/ActiveDashboardDaoTest/shouldInsertWithNoUser-result.xml deleted file mode 100644 index a247a4f7c4d..00000000000 --- a/sonar-db/src/test/resources/org/sonar/db/dashboard/ActiveDashboardDaoTest/shouldInsertWithNoUser-result.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - diff --git a/sonar-db/src/test/resources/org/sonar/db/dashboard/ActiveDashboardDaoTest/shouldSelectDashboardsForAnonymous.xml b/sonar-db/src/test/resources/org/sonar/db/dashboard/ActiveDashboardDaoTest/shouldSelectDashboardsForAnonymous.xml deleted file mode 100644 index ef64957570f..00000000000 --- a/sonar-db/src/test/resources/org/sonar/db/dashboard/ActiveDashboardDaoTest/shouldSelectDashboardsForAnonymous.xml +++ /dev/null @@ -1,56 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/sonar-db/src/test/resources/org/sonar/db/dashboard/ActiveDashboardDaoTest/shouldSelectDashboardsForUser.xml b/sonar-db/src/test/resources/org/sonar/db/dashboard/ActiveDashboardDaoTest/shouldSelectDashboardsForUser.xml deleted file mode 100644 index 5b57ddfa5d5..00000000000 --- a/sonar-db/src/test/resources/org/sonar/db/dashboard/ActiveDashboardDaoTest/shouldSelectDashboardsForUser.xml +++ /dev/null @@ -1,78 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/sonar-db/src/test/resources/org/sonar/db/dashboard/DashboardDaoTest/shouldInsert-result.xml b/sonar-db/src/test/resources/org/sonar/db/dashboard/DashboardDaoTest/shouldInsert-result.xml deleted file mode 100644 index 30969fc7570..00000000000 --- a/sonar-db/src/test/resources/org/sonar/db/dashboard/DashboardDaoTest/shouldInsert-result.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - diff --git a/sonar-db/src/test/resources/org/sonar/db/dashboard/DashboardDaoTest/shouldInsert.xml b/sonar-db/src/test/resources/org/sonar/db/dashboard/DashboardDaoTest/shouldInsert.xml deleted file mode 100644 index 871dedcb5e9..00000000000 --- a/sonar-db/src/test/resources/org/sonar/db/dashboard/DashboardDaoTest/shouldInsert.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/sonar-db/src/test/resources/org/sonar/db/dashboard/DashboardDaoTest/shouldInsertWithNullableColumns-result.xml b/sonar-db/src/test/resources/org/sonar/db/dashboard/DashboardDaoTest/shouldInsertWithNullableColumns-result.xml deleted file mode 100644 index 67181df8d48..00000000000 --- a/sonar-db/src/test/resources/org/sonar/db/dashboard/DashboardDaoTest/shouldInsertWithNullableColumns-result.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - - - diff --git a/sonar-db/src/test/resources/org/sonar/db/dashboard/DashboardDaoTest/shouldSelectGlobalDashboard.xml b/sonar-db/src/test/resources/org/sonar/db/dashboard/DashboardDaoTest/shouldSelectGlobalDashboard.xml deleted file mode 100644 index 110e760f9ad..00000000000 --- a/sonar-db/src/test/resources/org/sonar/db/dashboard/DashboardDaoTest/shouldSelectGlobalDashboard.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - diff --git a/sonar-db/src/test/resources/org/sonar/db/dashboard/WidgetDaoTest/before.xml b/sonar-db/src/test/resources/org/sonar/db/dashboard/WidgetDaoTest/before.xml deleted file mode 100644 index a942341e3d4..00000000000 --- a/sonar-db/src/test/resources/org/sonar/db/dashboard/WidgetDaoTest/before.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - -