diff options
author | Belen Pruvost <belen.pruvost@sonarsource.com> | 2022-01-13 16:42:20 +0100 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2022-01-21 20:03:22 +0000 |
commit | 573f47d57bc4cc52235a22066d81b6be7dee4f3c (patch) | |
tree | 59444eac11c580e23bf1c22e8a2f2d61428d879a /server/sonar-db-dao/src/main/java/org | |
parent | 3ec97d1a4368fdd3212d524aacfc73403ed709ce (diff) | |
download | sonarqube-573f47d57bc4cc52235a22066d81b6be7dee4f3c.tar.gz sonarqube-573f47d57bc4cc52235a22066d81b6be7dee4f3c.zip |
SONAR-14929 - Save a new issue as new on branch using reference branch
Diffstat (limited to 'server/sonar-db-dao/src/main/java/org')
4 files changed, 79 insertions, 0 deletions
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/MyBatis.java b/server/sonar-db-dao/src/main/java/org/sonar/db/MyBatis.java index 691ce4c137b..19916bb3e24 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/MyBatis.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/MyBatis.java @@ -73,6 +73,7 @@ import org.sonar.db.issue.IssueChangeDto; import org.sonar.db.issue.IssueChangeMapper; import org.sonar.db.issue.IssueDto; import org.sonar.db.issue.IssueMapper; +import org.sonar.db.issue.NewCodeReferenceIssueDto; import org.sonar.db.issue.PrIssueDto; import org.sonar.db.mapping.ProjectMappingDto; import org.sonar.db.mapping.ProjectMappingsMapper; @@ -197,6 +198,7 @@ public class MyBatis implements Startable { confBuilder.loadAlias("IssueChange", IssueChangeDto.class); confBuilder.loadAlias("KeyLongValue", KeyLongValue.class); confBuilder.loadAlias("Issue", IssueDto.class); + confBuilder.loadAlias("NewCodeReferenceIssue", NewCodeReferenceIssueDto.class); confBuilder.loadAlias("Measure", MeasureDto.class); confBuilder.loadAlias("NotificationQueue", NotificationQueueDto.class); confBuilder.loadAlias("PermissionTemplateCharacteristic", PermissionTemplateCharacteristicDto.class); diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/issue/IssueDao.java b/server/sonar-db-dao/src/main/java/org/sonar/db/issue/IssueDao.java index 52ef7a4f10c..bb9a136b987 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/issue/IssueDao.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/issue/IssueDao.java @@ -58,6 +58,10 @@ public class IssueDao implements Dao { return executeLargeInputs(keys, mapper(session)::selectByKeys); } + public boolean isNewCodeOnReferencedBranch(DbSession session, String issueKey) { + return mapper(session).isNewCodeOnReferencedBranch(issueKey); + } + public Set<String> selectIssueKeysByComponentUuid(DbSession session, String componentUuid) { return mapper(session).selectIssueKeysByComponentUuid(componentUuid); } diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/issue/IssueMapper.java b/server/sonar-db-dao/src/main/java/org/sonar/db/issue/IssueMapper.java index 80ea1be570c..49399d49cf9 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/issue/IssueMapper.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/issue/IssueMapper.java @@ -37,6 +37,8 @@ public interface IssueMapper { List<IssueDto> selectByKeys(List<String> keys); + boolean isNewCodeOnReferencedBranch(@Param("issueKey") String issueKey); + Set<String> selectIssueKeysByComponentUuid(@Param("componentUuid") String componentUuid); List<IssueDto> selectByComponentUuidPaginated(@Param("componentUuid") String componentUuid, @@ -50,6 +52,8 @@ public interface IssueMapper { int update(IssueDto issue); + void insertAsNewOnReferenceBranch(NewCodeReferenceIssueDto issue); + int updateIfBeforeSelectedDate(IssueDto issue); void scrollNonClosedByComponentUuid(@Param("componentUuid") String componentUuid, ResultHandler<IssueDto> handler); diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/issue/NewCodeReferenceIssueDto.java b/server/sonar-db-dao/src/main/java/org/sonar/db/issue/NewCodeReferenceIssueDto.java new file mode 100644 index 00000000000..3b870154465 --- /dev/null +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/issue/NewCodeReferenceIssueDto.java @@ -0,0 +1,69 @@ +/* + * SonarQube + * Copyright (C) 2009-2021 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.db.issue; + +import java.io.Serializable; +import org.sonar.core.util.UuidFactory; + +public final class NewCodeReferenceIssueDto implements Serializable { + private String uuid; + private String issueKey; + + // technical date + private Long createdAt; + + public NewCodeReferenceIssueDto() { + // nothing to do + } + + public String getUuid() { + return uuid; + } + + public NewCodeReferenceIssueDto setUuid(String uuid) { + this.uuid = uuid; + return this; + } + + public String getIssueKey() { + return issueKey; + } + + public NewCodeReferenceIssueDto setIssueKey(String issueKey) { + this.issueKey = issueKey; + return this; + } + + public Long getCreatedAt() { + return createdAt; + } + + public NewCodeReferenceIssueDto setCreatedAt(Long createdAt) { + this.createdAt = createdAt; + return this; + } + + public static NewCodeReferenceIssueDto fromIssueDto(IssueDto issue, long now, UuidFactory uuidFactory) { + return new NewCodeReferenceIssueDto() + .setUuid(uuidFactory.create()) + .setIssueKey(issue.getKey()) + .setCreatedAt(now); + } +} |