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.

ComponentDoc.java 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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.server.component.index;
  21. import java.util.HashMap;
  22. import java.util.Map;
  23. import org.sonar.server.es.BaseDoc;
  24. import org.sonar.server.permission.index.AuthorizationDoc;
  25. import static org.sonar.server.component.index.ComponentIndexDefinition.FIELD_KEY;
  26. import static org.sonar.server.component.index.ComponentIndexDefinition.FIELD_NAME;
  27. import static org.sonar.server.component.index.ComponentIndexDefinition.FIELD_PROJECT_UUID;
  28. import static org.sonar.server.component.index.ComponentIndexDefinition.FIELD_QUALIFIER;
  29. import static org.sonar.server.component.index.ComponentIndexDefinition.FIELD_UUID;
  30. import static org.sonar.server.component.index.ComponentIndexDefinition.TYPE_COMPONENT;
  31. public class ComponentDoc extends BaseDoc {
  32. public ComponentDoc() {
  33. super(TYPE_COMPONENT, new HashMap<>(6));
  34. }
  35. public ComponentDoc(Map<String, Object> fields) {
  36. super(TYPE_COMPONENT, fields);
  37. }
  38. @Override
  39. public String getId() {
  40. return getField(FIELD_UUID);
  41. }
  42. public ComponentDoc setId(String s) {
  43. setField(FIELD_UUID, s);
  44. return this;
  45. }
  46. public String getProjectUuid() {
  47. return getField(FIELD_PROJECT_UUID);
  48. }
  49. public ComponentDoc setProjectUuid(String s) {
  50. setField(FIELD_PROJECT_UUID, s);
  51. setParent(AuthorizationDoc.idOf(s));
  52. return this;
  53. }
  54. public String getKey() {
  55. return getField(FIELD_KEY);
  56. }
  57. public ComponentDoc setKey(String s) {
  58. setField(FIELD_KEY, s);
  59. return this;
  60. }
  61. public String getName() {
  62. return getField(FIELD_NAME);
  63. }
  64. public ComponentDoc setName(String s) {
  65. setField(FIELD_NAME, s);
  66. return this;
  67. }
  68. public String getQualifier() {
  69. return getField(FIELD_QUALIFIER);
  70. }
  71. public ComponentDoc setQualifier(String s) {
  72. setField(FIELD_QUALIFIER, s);
  73. return this;
  74. }
  75. }