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.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. /*
  2. * SonarQube
  3. * Copyright (C) 2009-2023 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 selectByKeyCaseInsensitive(@Param("key") String key);
  32. @CheckForNull
  33. ComponentDto selectByKeyAndBranchOrPr(@Param("key") String key, @Nullable @Param("branch") String branch, @Nullable @Param("pullRequest") String pullRequest);
  34. @CheckForNull
  35. ComponentDto selectByUuid(@Param("uuid") String uuid);
  36. /**
  37. * Return sub project of component keys
  38. */
  39. List<ComponentDto> selectSubProjectsByComponentUuids(@Param("uuids") Collection<String> uuids);
  40. List<ComponentDto> selectByKeysAndBranchOrPr(@Param("keys") Collection<String> keys,
  41. @Nullable @Param("branch") String branch, @Nullable @Param("pullRequest") String pullRequest);
  42. List<ComponentDto> selectByUuids(@Param("uuids") Collection<String> uuids);
  43. List<ComponentDto> selectByBranchUuid(@Param("branchUuid") String branchUuid);
  44. List<String> selectExistingUuids(@Param("uuids") Collection<String> uuids);
  45. List<ComponentDto> selectComponentsByQualifiers(@Param("qualifiers") Collection<String> qualifiers);
  46. List<ComponentDto> selectByQuery(@Param("query") ComponentQuery query, RowBounds rowBounds);
  47. int countByQuery(@Param("query") ComponentQuery query);
  48. List<ComponentDto> selectDescendants(@Param("query") ComponentTreeQuery query, @Param("baseUuid") String baseUuid, @Param("baseUuidPath") String baseUuidPath);
  49. List<ComponentDto> selectChildren(@Param("branchUuid") String branchUuid, @Param("uuidPaths") Set<String> uuidPaths);
  50. /**
  51. * Returns all enabled projects (Scope {@link org.sonar.api.resources.Scopes#PROJECT} and qualifier
  52. * {@link org.sonar.api.resources.Qualifiers#PROJECT}) no matter if they are ghost project, provisioned projects or
  53. * regular ones.
  54. */
  55. List<ComponentDto> selectProjects();
  56. /**
  57. * Return all descendant modules (including itself) from a given component uuid and scope
  58. */
  59. List<ComponentDto> selectDescendantModules(@Param("moduleUuid") String moduleUuid, @Param(value = "scope") String scope,
  60. @Param(value = "excludeDisabled") boolean excludeDisabled);
  61. /**
  62. * Return all files from a given project uuid and scope
  63. */
  64. List<FilePathWithHashDto> selectEnabledFilesFromProject(@Param("projectUuid") String projectUuid);
  65. /**
  66. * Return all descendant files from a given module uuid and scope
  67. */
  68. List<FilePathWithHashDto> selectDescendantFiles(@Param("moduleUuid") String moduleUuid, @Param(value = "scope") String scope,
  69. @Param(value = "excludeDisabled") boolean excludeDisabled);
  70. /**
  71. * Return uuids and project uuids from list of qualifiers
  72. * <p/>
  73. * It's using a join on snapshots in order to use he indexed columns snapshots.qualifier
  74. */
  75. List<UuidWithBranchUuidDto> selectUuidsForQualifiers(@Param("qualifiers") String... qualifiers);
  76. /**
  77. * Return components of a given scope of a project
  78. *
  79. * @param scope scope of components to return. If null, all components are returned
  80. */
  81. List<ComponentDto> selectComponentsFromProjectKeyAndScope(@Param("projectKey") String projectKey, @Nullable @Param("scope") String scope,
  82. @Param(value = "excludeDisabled") boolean excludeDisabled, @Nullable @Param("branch") String branch, @Nullable @Param("pullRequest") String pullRequest);
  83. /**
  84. * Return keys and UUIDs of all components belonging to a project
  85. */
  86. List<KeyWithUuidDto> selectUuidsByKeyFromProjectKeyAndBranchOrPr(@Param("projectKey") String projectKey,
  87. @Nullable @Param("branch") String branch, @Nullable @Param("pullRequest") String pullRequest);
  88. Set<String> selectViewKeysWithEnabledCopyOfProject(@Param("projectUuids") Collection<String> projectUuids);
  89. /**
  90. * Return technical projects from a view or a sub-view
  91. */
  92. List<String> selectProjectsFromView(@Param("viewUuidLikeQuery") String viewUuidLikeQuery, @Param("projectViewUuid") String projectViewUuid);
  93. void scrollForIndexing(@Param("projectUuid") @Nullable String projectUuid, ResultHandler<ComponentDto> handler);
  94. void scrollAllFilesForFileMove(@Param("branchUuid") String branchUuid, ResultHandler<FileMoveRowDto> handler);
  95. void insert(ComponentDto componentDto);
  96. void update(ComponentUpdateDto component);
  97. void updateBEnabledToFalse(@Param("uuids") List<String> uuids);
  98. void applyBChangesForRootComponentUuid(@Param("branchUuid") String branchUuid);
  99. void resetBChangedForRootComponentUuid(@Param("branchUuid") String branchUuid);
  100. void setPrivateForRootComponentUuid(@Param("branchUuid") String branchUuid, @Param("isPrivate") boolean isPrivate);
  101. List<KeyWithUuidDto> selectComponentsFromPullRequestsTargetingCurrentBranchThatHaveOpenIssues(@Param("referenceBranchUuid") String referenceBranchUuid,
  102. @Param("currentBranchUuid") String currentBranchUuid);
  103. List<KeyWithUuidDto> selectComponentsFromBranchesThatHaveOpenIssues(@Param("branchUuids") List<String> branchUuids);
  104. List<ProjectNclocDistributionDto> selectPrivateProjectsWithNcloc();
  105. short checkIfAnyOfComponentsWithQualifiers(@Param("componentKeys") Collection<String> componentKeys, @Param("qualifiers") Set<String> qualifiers);
  106. }