aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-server-common/src
diff options
context:
space:
mode:
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>2018-07-03 10:39:42 +0200
committersonartech <sonartech@sonarsource.com>2018-07-09 10:39:32 +0200
commit12349c8c275dc316e09451c4f468376e26be53b3 (patch)
treefd002acfd218ee326a9d14fe12a0043bbaf6ca8d /server/sonar-server-common/src
parent9fe95670207d2943eef87452dbc5b840faf1df65 (diff)
downloadsonarqube-12349c8c275dc316e09451c4f468376e26be53b3.tar.gz
sonarqube-12349c8c275dc316e09451c4f468376e26be53b3.zip
clean up dependency on static IssueStorage#insertChanges
and move IssueStorage to server-common
Diffstat (limited to 'server/sonar-server-common/src')
-rw-r--r--server/sonar-server-common/src/main/java/org/sonar/server/issue/IssueStorage.java47
1 files changed, 47 insertions, 0 deletions
diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/issue/IssueStorage.java b/server/sonar-server-common/src/main/java/org/sonar/server/issue/IssueStorage.java
new file mode 100644
index 00000000000..b7c6cbec18a
--- /dev/null
+++ b/server/sonar-server-common/src/main/java/org/sonar/server/issue/IssueStorage.java
@@ -0,0 +1,47 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2018 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.server.issue;
+
+import org.sonar.core.issue.DefaultIssue;
+import org.sonar.core.issue.DefaultIssueComment;
+import org.sonar.core.issue.FieldDiffs;
+import org.sonar.db.issue.IssueChangeDto;
+import org.sonar.db.issue.IssueChangeMapper;
+
+public class IssueStorage {
+ public void insertChanges(IssueChangeMapper mapper, DefaultIssue issue) {
+ for (DefaultIssueComment comment : issue.defaultIssueComments()) {
+ if (comment.isNew()) {
+ IssueChangeDto changeDto = IssueChangeDto.of(comment);
+ mapper.insert(changeDto);
+ }
+ }
+ FieldDiffs diffs = issue.currentChange();
+ if (issue.isCopied()) {
+ for (FieldDiffs d : issue.changes()) {
+ IssueChangeDto changeDto = IssueChangeDto.of(issue.key(), d);
+ mapper.insert(changeDto);
+ }
+ } else if (!issue.isNew() && diffs != null) {
+ IssueChangeDto changeDto = IssueChangeDto.of(issue.key(), diffs);
+ mapper.insert(changeDto);
+ }
+ }
+}