You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ComponentMapper.java 6.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. /*
  2. * SonarQube
  3. * Copyright (C) 2009-2021 SonarSource SA
  4. * mailto:info AT sonarsource DOT com
  5. *
  6. * This program 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. * This program 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.db.component;
  21. import java.util.Collection;
  22. import java.util.List;
  23. import java.util.Set;
  24. import javax.annotation.CheckForNull;
  25. import javax.annotation.Nullable;
  26. import org.apache.ibatis.annotations.Param;
  27. import org.apache.ibatis.session.ResultHandler;
  28. import org.apache.ibatis.session.RowBounds;
  29. public interface ComponentMapper {
  30. @CheckForNull
  31. ComponentDto selectByKey(String key);
  32. @CheckForNull
  33. ComponentDto selectBranchByKeyAndBranchKey(@Param("key") String key, @Param("dbKey") String dbKey, @Param("branch") String branch);
  34. @CheckForNull
  35. ComponentDto selectPrByKeyAndBranchKey(@Param("key") String key, @Param("dbKey") String dbKey, @Param("branch") String branch);
  36. @CheckForNull
  37. ComponentDto selectByUuid(String uuid);
  38. /**
  39. * Return sub project of component keys
  40. */
  41. List<ComponentDto> selectSubProjectsByComponentUuids(@Param("uuids") Collection<String> uuids);
  42. List<ComponentDto> selectByKeys(@Param("keys") Collection<String> keys);
  43. List<ComponentDto> selectByDbKeys(@Param("dbKeys") Collection<String> dbKeys);
  44. List<ComponentDto> selectByKeysAndBranch(@Param("keys") Collection<String> keys, @Param("branch") String branch);
  45. List<ComponentDto> selectByUuids(@Param("uuids") Collection<String> uuids);
  46. List<ComponentDto> selectByProjectUuid(@Param("projectUuid") String projectUuid);
  47. List<String> selectExistingUuids(@Param("uuids") Collection<String> uuids);
  48. List<ComponentDto> selectComponentsByQualifiers(@Param("qualifiers") Collection<String> qualifiers);
  49. int countEnabledModulesByProjectUuid(@Param("projectUuid") String projectUuid);
  50. List<ComponentDto> selectByQuery(@Param("query") ComponentQuery query, RowBounds rowBounds);
  51. int countByQuery(@Param("query") ComponentQuery query);
  52. List<ComponentDto> selectDescendants(@Param("query") ComponentTreeQuery query, @Param("baseUuid") String baseUuid, @Param("baseUuidPath") String baseUuidPath);
  53. /**
  54. * Returns all enabled projects (Scope {@link org.sonar.api.resources.Scopes#PROJECT} and qualifier
  55. * {@link org.sonar.api.resources.Qualifiers#PROJECT}) no matter if they are ghost project, provisioned projects or
  56. * regular ones.
  57. */
  58. List<ComponentDto> selectProjects();
  59. /**
  60. * Return all descendant modules (including itself) from a given component uuid and scope
  61. */
  62. List<ComponentDto> selectDescendantModules(@Param("moduleUuid") String moduleUuid, @Param(value = "scope") String scope,
  63. @Param(value = "excludeDisabled") boolean excludeDisabled);
  64. /**
  65. * Return all files from a given project uuid and scope
  66. */
  67. List<FilePathWithHashDto> selectEnabledFilesFromProject(@Param("projectUuid") String projectUuid);
  68. /**
  69. * Return all descendant files from a given module uuid and scope
  70. */
  71. List<FilePathWithHashDto> selectDescendantFiles(@Param("moduleUuid") String moduleUuid, @Param(value = "scope") String scope,
  72. @Param(value = "excludeDisabled") boolean excludeDisabled);
  73. /**
  74. * Return uuids and project uuids from list of qualifiers
  75. * <p/>
  76. * It's using a join on snapshots in order to use he indexed columns snapshots.qualifier
  77. */
  78. List<UuidWithProjectUuidDto> selectUuidsForQualifiers(@Param("qualifiers") String... qualifiers);
  79. /**
  80. * Return components of a given scope of a project
  81. *
  82. * @param scope scope of components to return. If null, all components are returned
  83. */
  84. List<ComponentDto> selectComponentsFromProjectKeyAndScope(@Param("projectKey") String projectKey, @Nullable @Param("scope") String scope,
  85. @Param(value = "excludeDisabled") boolean excludeDisabled);
  86. /**
  87. * Return keys and UUIDs of all components belonging to a project
  88. */
  89. List<KeyWithUuidDto> selectUuidsByKeyFromProjectKey(@Param("projectKey") String projectKey);
  90. Set<String> selectViewKeysWithEnabledCopyOfProject(@Param("projectUuids") Collection<String> projectUuids);
  91. /**
  92. * Return technical projects from a view or a sub-view
  93. */
  94. List<String> selectProjectsFromView(@Param("viewUuidLikeQuery") String viewUuidLikeQuery, @Param("projectViewUuid") String projectViewUuid);
  95. void scrollForIndexing(@Param("projectUuid") @Nullable String projectUuid, ResultHandler<ComponentDto> handler);
  96. void scrollAllFilesForFileMove(@Param("projectUuid") String projectUuid, ResultHandler<FileMoveRowDto> handler);
  97. void insert(ComponentDto componentDto);
  98. void update(ComponentUpdateDto component);
  99. void updateBEnabledToFalse(@Param("uuids") List<String> uuids);
  100. void applyBChangesForRootComponentUuid(@Param("projectUuid") String projectUuid);
  101. void resetBChangedForRootComponentUuid(@Param("projectUuid") String projectUuid);
  102. void setPrivateForRootComponentUuid(@Param("projectUuid") String projectUuid, @Param("isPrivate") boolean isPrivate);
  103. void delete(String componentUuid);
  104. List<KeyWithUuidDto> selectAllSiblingComponentKeysHavingOpenIssues(@Param("referenceBranchUuid") String referenceBranchUuid,
  105. @Param("currentBranchUuid") String currentBranchUuid);
  106. List<ProjectNclocDistributionDto> selectPrivateProjectsWithNcloc();
  107. List<ComponentWithModuleUuidDto> selectEnabledComponentsWithModuleUuidFromProjectKey(String projectKey);
  108. short checkIfAnyOfComponentsWithQualifiers(@Param("componentKeys") Collection<String> componentKeys, @Param("qualifiers") Set<String> qualifiers);
  109. }