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.

IndexedIssueDto.java 8.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  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.issue;
  21. import java.util.Collections;
  22. import java.util.EnumMap;
  23. import java.util.HashSet;
  24. import java.util.Map;
  25. import java.util.Optional;
  26. import java.util.Set;
  27. import javax.annotation.CheckForNull;
  28. import org.sonar.api.issue.impact.Severity;
  29. import org.sonar.api.issue.impact.SoftwareQuality;
  30. import org.sonar.core.issue.status.SimpleStatus;
  31. import static com.google.common.base.Preconditions.checkArgument;
  32. public final class IndexedIssueDto {
  33. private String issueKey = null;
  34. private String assignee = null;
  35. private Integer line = null;
  36. private String resolution = null;
  37. private String cleanCodeAttribute = null;
  38. private String ruleCleanCodeAttribute = null;
  39. private String severity = null;
  40. private String status = null;
  41. private Long effort = null;
  42. private String authorLogin = null;
  43. private Long issueCloseDate = null;
  44. private Long issueCreationDate = null;
  45. private Long issueUpdateDate = null;
  46. private String ruleUuid = null;
  47. private String language = null;
  48. private String componentUuid = null;
  49. private String path = null;
  50. private String scope = null;
  51. private String branchUuid = null;
  52. private boolean isMain = false;
  53. private String projectUuid = null;
  54. private String tags = null;
  55. private Integer issueType = null;
  56. private String securityStandards = null;
  57. private String qualifier = null;
  58. private boolean isNewCodeReferenceIssue = false;
  59. private String codeVariants = null;
  60. private Set<ImpactDto> impacts = new HashSet<>();
  61. private Set<ImpactDto> ruleDefaultImpacts = new HashSet<>();
  62. public IndexedIssueDto() {
  63. // empty constructor
  64. }
  65. public String getIssueKey() {
  66. return issueKey;
  67. }
  68. public IndexedIssueDto setIssueKey(String issueKey) {
  69. this.issueKey = issueKey;
  70. return this;
  71. }
  72. public String getAssignee() {
  73. return assignee;
  74. }
  75. public IndexedIssueDto setAssignee(String assignee) {
  76. this.assignee = assignee;
  77. return this;
  78. }
  79. public Integer getLine() {
  80. return line;
  81. }
  82. public IndexedIssueDto setLine(Integer line) {
  83. this.line = line;
  84. return this;
  85. }
  86. public String getResolution() {
  87. return resolution;
  88. }
  89. public IndexedIssueDto setResolution(String resolution) {
  90. this.resolution = resolution;
  91. return this;
  92. }
  93. public String getSeverity() {
  94. return severity;
  95. }
  96. public IndexedIssueDto setSeverity(String severity) {
  97. this.severity = severity;
  98. return this;
  99. }
  100. public String getStatus() {
  101. return status;
  102. }
  103. public IndexedIssueDto setStatus(String status) {
  104. this.status = status;
  105. return this;
  106. }
  107. @CheckForNull
  108. public String getSimpleStatus() {
  109. checkArgument(status != null, "Status must be initialized to retrieve simple status");
  110. return Optional.ofNullable(SimpleStatus.of(status, resolution)).map(SimpleStatus::name).orElse(null);
  111. }
  112. public Long getEffort() {
  113. return effort;
  114. }
  115. public IndexedIssueDto setEffort(Long effort) {
  116. this.effort = effort;
  117. return this;
  118. }
  119. public String getAuthorLogin() {
  120. return authorLogin;
  121. }
  122. public IndexedIssueDto setAuthorLogin(String authorLogin) {
  123. this.authorLogin = authorLogin;
  124. return this;
  125. }
  126. public Long getIssueCloseDate() {
  127. return issueCloseDate;
  128. }
  129. public IndexedIssueDto setIssueCloseDate(Long issueCloseDate) {
  130. this.issueCloseDate = issueCloseDate;
  131. return this;
  132. }
  133. public Long getIssueCreationDate() {
  134. return issueCreationDate;
  135. }
  136. public IndexedIssueDto setIssueCreationDate(Long issueCreationDate) {
  137. this.issueCreationDate = issueCreationDate;
  138. return this;
  139. }
  140. public Long getIssueUpdateDate() {
  141. return issueUpdateDate;
  142. }
  143. public IndexedIssueDto setIssueUpdateDate(Long issueUpdateDate) {
  144. this.issueUpdateDate = issueUpdateDate;
  145. return this;
  146. }
  147. public String getRuleUuid() {
  148. return ruleUuid;
  149. }
  150. public IndexedIssueDto setRuleUuid(String ruleUuid) {
  151. this.ruleUuid = ruleUuid;
  152. return this;
  153. }
  154. public String getLanguage() {
  155. return language;
  156. }
  157. public IndexedIssueDto setLanguage(String language) {
  158. this.language = language;
  159. return this;
  160. }
  161. public String getComponentUuid() {
  162. return componentUuid;
  163. }
  164. public IndexedIssueDto setComponentUuid(String componentUuid) {
  165. this.componentUuid = componentUuid;
  166. return this;
  167. }
  168. public String getPath() {
  169. return path;
  170. }
  171. public IndexedIssueDto setPath(String path) {
  172. this.path = path;
  173. return this;
  174. }
  175. public String getScope() {
  176. return scope;
  177. }
  178. public IndexedIssueDto setScope(String scope) {
  179. this.scope = scope;
  180. return this;
  181. }
  182. public String getBranchUuid() {
  183. return branchUuid;
  184. }
  185. public IndexedIssueDto setBranchUuid(String branchUuid) {
  186. this.branchUuid = branchUuid;
  187. return this;
  188. }
  189. public boolean isMain() {
  190. return isMain;
  191. }
  192. public IndexedIssueDto setIsMain(boolean isMain) {
  193. this.isMain = isMain;
  194. return this;
  195. }
  196. public String getProjectUuid() {
  197. return projectUuid;
  198. }
  199. public IndexedIssueDto setProjectUuid(String projectUuid) {
  200. this.projectUuid = projectUuid;
  201. return this;
  202. }
  203. public String getTags() {
  204. return tags;
  205. }
  206. public IndexedIssueDto setTags(String tags) {
  207. this.tags = tags;
  208. return this;
  209. }
  210. /**
  211. * @deprecated since 10.2
  212. */
  213. @Deprecated(since = "10.2")
  214. public Integer getIssueType() {
  215. return issueType;
  216. }
  217. /**
  218. * @deprecated since 10.2
  219. */
  220. @Deprecated(since = "10.2")
  221. public IndexedIssueDto setIssueType(Integer issueType) {
  222. this.issueType = issueType;
  223. return this;
  224. }
  225. public String getSecurityStandards() {
  226. return securityStandards;
  227. }
  228. public IndexedIssueDto setSecurityStandards(String securityStandards) {
  229. this.securityStandards = securityStandards;
  230. return this;
  231. }
  232. public String getQualifier() {
  233. return qualifier;
  234. }
  235. public IndexedIssueDto setQualifier(String qualifier) {
  236. this.qualifier = qualifier;
  237. return this;
  238. }
  239. public boolean isNewCodeReferenceIssue() {
  240. return isNewCodeReferenceIssue;
  241. }
  242. public IndexedIssueDto setNewCodeReferenceIssue(boolean newCodeReferenceIssue) {
  243. isNewCodeReferenceIssue = newCodeReferenceIssue;
  244. return this;
  245. }
  246. public String getCodeVariants() {
  247. return codeVariants;
  248. }
  249. public IndexedIssueDto setCodeVariants(String codeVariants) {
  250. this.codeVariants = codeVariants;
  251. return this;
  252. }
  253. public Set<ImpactDto> getImpacts() {
  254. return impacts;
  255. }
  256. public Set<ImpactDto> getRuleDefaultImpacts() {
  257. return ruleDefaultImpacts;
  258. }
  259. public Map<SoftwareQuality, Severity> getEffectiveImpacts() {
  260. EnumMap<SoftwareQuality, Severity> effectiveImpacts = new EnumMap<>(SoftwareQuality.class);
  261. ruleDefaultImpacts.forEach(impact -> effectiveImpacts.put(impact.getSoftwareQuality(), impact.getSeverity()));
  262. impacts.forEach(impact -> effectiveImpacts.put(impact.getSoftwareQuality(), impact.getSeverity()));
  263. return Collections.unmodifiableMap(effectiveImpacts);
  264. }
  265. public String getCleanCodeAttribute() {
  266. if (cleanCodeAttribute != null) {
  267. return cleanCodeAttribute;
  268. }
  269. return ruleCleanCodeAttribute;
  270. }
  271. public IndexedIssueDto setCleanCodeAttribute(String cleanCodeAttribute) {
  272. this.cleanCodeAttribute = cleanCodeAttribute;
  273. return this;
  274. }
  275. public String getRuleCleanCodeAttribute() {
  276. return ruleCleanCodeAttribute;
  277. }
  278. public IndexedIssueDto setRuleCleanCodeAttribute(String ruleCleanCodeAttribute) {
  279. this.ruleCleanCodeAttribute = ruleCleanCodeAttribute;
  280. return this;
  281. }
  282. }