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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. /*
  2. * SonarQube
  3. * Copyright (C) 2009-2018 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. import org.sonar.db.KeyLongValue;
  30. public interface ComponentMapper {
  31. @CheckForNull
  32. ComponentDto selectByKey(String key);
  33. @CheckForNull
  34. ComponentDto selectByKeyAndBranchKey(@Param("key") String key, @Param("dbKey") String dbKey, @Param("branch") String branch);
  35. @CheckForNull
  36. ComponentDto selectById(long id);
  37. @CheckForNull
  38. ComponentDto selectByUuid(String uuid);
  39. /**
  40. * Return sub project of component keys
  41. */
  42. List<ComponentDto> selectSubProjectsByComponentUuids(@Param("uuids") Collection<String> uuids);
  43. List<ComponentDto> selectByKeys(@Param("keys") Collection<String> keys);
  44. List<ComponentDto> selectByDbKeys(@Param("dbKeys") Collection<String> dbKeys);
  45. List<ComponentDto> selectByKeysAndBranch(@Param("keys") Collection<String> keys, @Param("branch") String branch);
  46. List<ComponentDto> selectByIds(@Param("ids") Collection<Long> ids);
  47. List<ComponentDto> selectByUuids(@Param("uuids") Collection<String> uuids);
  48. List<ComponentDto> selectByProjectUuid(@Param("projectUuid") String projectUuid);
  49. List<String> selectExistingUuids(@Param("uuids") Collection<String> uuids);
  50. List<ComponentDto> selectComponentsByQualifiers(@Param("qualifiers") Collection<String> qualifiers);
  51. /**
  52. * Counts the number of components with the specified id belonging to the specified organization.
  53. *
  54. * @return 1 or 0. Either because the organization uuid is not the one of the component or because the component does
  55. * not exist.
  56. */
  57. int countComponentByOrganizationAndId(@Param("organizationUuid") String organizationUuid, @Param("componentId") long componentId);
  58. List<ComponentDto> selectByQuery(@Nullable @Param("organizationUuid") String organizationUuid, @Param("query") ComponentQuery query, RowBounds rowBounds);
  59. int countByQuery(@Nullable @Param("organizationUuid") String organizationUuid, @Param("query") ComponentQuery query);
  60. List<KeyLongValue> countByNclocRanges();
  61. long countPublicNcloc();
  62. List<ComponentDto> selectDescendants(@Param("query") ComponentTreeQuery query, @Param("baseUuid") String baseUuid, @Param("baseUuidPath") String baseUuidPath);
  63. /**
  64. * Returns all enabled projects (Scope {@link org.sonar.api.resources.Scopes#PROJECT} and qualifier
  65. * {@link org.sonar.api.resources.Qualifiers#PROJECT}) no matter if they are ghost project, provisioned projects or
  66. * regular ones.
  67. */
  68. List<ComponentDto> selectProjects();
  69. List<ComponentDto> selectProjectsByOrganization(@Param("organizationUuid") String organizationUuid);
  70. /**
  71. * Return all descendant modules (including itself) from a given component uuid and scope
  72. */
  73. List<ComponentDto> selectDescendantModules(@Param("moduleUuid") String moduleUuid, @Param(value = "scope") String scope,
  74. @Param(value = "excludeDisabled") boolean excludeDisabled);
  75. /**
  76. * Return all files from a given project uuid and scope
  77. */
  78. List<FilePathWithHashDto> selectEnabledFilesFromProject(@Param("projectUuid") String projectUuid);
  79. /**
  80. * Return all descendant files from a given module uuid and scope
  81. */
  82. List<FilePathWithHashDto> selectDescendantFiles(@Param("moduleUuid") String moduleUuid, @Param(value = "scope") String scope,
  83. @Param(value = "excludeDisabled") boolean excludeDisabled);
  84. /**
  85. * Return uuids and project uuids from list of qualifiers
  86. * <p/>
  87. * It's using a join on snapshots in order to use he indexed columns snapshots.qualifier
  88. */
  89. List<UuidWithProjectUuidDto> selectUuidsForQualifiers(@Param("qualifiers") String... qualifiers);
  90. /**
  91. * Return components of a given scope of a project
  92. *
  93. * @param scope scope of components to return. If null, all components are returned
  94. */
  95. List<ComponentDto> selectComponentsFromProjectKeyAndScope(@Param("projectKey") String projectKey, @Nullable @Param("scope") String scope,
  96. @Param(value = "excludeDisabled") boolean excludeDisabled);
  97. /**
  98. * Return keys and UUIDs of all components belonging to a project
  99. */
  100. List<KeyWithUuidDto> selectUuidsByKeyFromProjectKey(@Param("projectKey") String projectKey);
  101. Set<String> selectViewKeysWithEnabledCopyOfProject(@Param("projectUuids") Collection<String> projectUuids);
  102. /**
  103. * Return technical projects from a view or a sub-view
  104. */
  105. List<String> selectProjectsFromView(@Param("viewUuidLikeQuery") String viewUuidLikeQuery, @Param("projectViewUuid") String projectViewUuid);
  106. List<ComponentDto> selectGhostProjects(@Param("organizationUuid") String organizationUuid, @Nullable @Param("query") String query, RowBounds rowBounds);
  107. long countGhostProjects(@Param("organizationUuid") String organizationUuid, @Nullable @Param("query") String query);
  108. List<ComponentDto> selectComponentsHavingSameKeyOrderedById(String key);
  109. List<ComponentDto> selectProjectsByNameQuery(@Param("nameQuery") @Nullable String nameQuery, @Param("includeModules") boolean includeModules);
  110. void scrollForIndexing(@Param("projectUuid") @Nullable String projectUuid, ResultHandler<ComponentDto> handler);
  111. void scrollAllFilesForFileMove(@Param("projectUuid") String projectUuid, ResultHandler<FileMoveRowDto> handler);
  112. void insert(ComponentDto componentDto);
  113. void update(ComponentUpdateDto component);
  114. void updateBEnabledToFalse(@Param("uuids") List<String> uuids);
  115. void applyBChangesForRootComponentUuid(@Param("projectUuid") String projectUuid);
  116. void resetBChangedForRootComponentUuid(@Param("projectUuid") String projectUuid);
  117. void setPrivateForRootComponentUuid(@Param("projectUuid") String projectUuid, @Param("isPrivate") boolean isPrivate);
  118. void delete(long componentId);
  119. void updateTags(ComponentDto component);
  120. List<KeyWithUuidDto> selectComponentKeysHavingIssuesToMerge(@Param("mergeBranchUuid") String mergeBranchUuid);
  121. List<ProjectNclocDistributionDto> selectPrivateProjectsWithNcloc(@Param("organizationUuid") String organizationUuid);
  122. }