]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-3755 Issues tables creation and first API draft
authorJulien Lancelot <julien.lancelot@gmail.com>
Fri, 5 Apr 2013 15:39:19 +0000 (17:39 +0200)
committerJulien Lancelot <julien.lancelot@gmail.com>
Fri, 5 Apr 2013 15:39:19 +0000 (17:39 +0200)
13 files changed:
sonar-core/src/main/java/org/sonar/core/issue/DefaultIssuable.java [new file with mode: 0644]
sonar-core/src/main/java/org/sonar/core/issue/DefaultIssue.java [new file with mode: 0644]
sonar-core/src/main/java/org/sonar/core/issue/DefaultIssueChangelog.java [new file with mode: 0644]
sonar-core/src/main/java/org/sonar/core/persistence/DatabaseUtils.java
sonar-core/src/main/java/org/sonar/core/persistence/DatabaseVersion.java
sonar-core/src/main/resources/org/sonar/core/persistence/rows-h2.sql
sonar-core/src/main/resources/org/sonar/core/persistence/schema-h2.ddl
sonar-core/src/test/java/org/sonar/core/issue/DefaultIssuableTest.java [new file with mode: 0644]
sonar-plugin-api/src/main/java/org/sonar/api/issue/Issuable.java [new file with mode: 0644]
sonar-plugin-api/src/main/java/org/sonar/api/issue/Issue.java [new file with mode: 0644]
sonar-plugin-api/src/main/java/org/sonar/api/issue/IssueChangelog.java [new file with mode: 0644]
sonar-server/src/main/webapp/WEB-INF/db/migrate/385_create_issues.rb [new file with mode: 0644]
sonar-server/src/main/webapp/WEB-INF/db/migrate/386_create_issue_changelog.rb [new file with mode: 0644]

diff --git a/sonar-core/src/main/java/org/sonar/core/issue/DefaultIssuable.java b/sonar-core/src/main/java/org/sonar/core/issue/DefaultIssuable.java
new file mode 100644 (file)
index 0000000..4fe7c72
--- /dev/null
@@ -0,0 +1,80 @@
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2012 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
+ */
+
+package org.sonar.core.issue;
+
+import com.google.common.base.Objects;
+import com.google.common.base.Predicate;
+import com.google.common.collect.Iterables;
+import org.sonar.api.component.Component;
+import org.sonar.api.issue.Issuable;
+import org.sonar.api.issue.Issue;
+import org.sonar.api.issue.IssueChangelog;
+
+import java.util.List;
+
+/**
+ * @since 3.6
+ */
+public class DefaultIssuable implements Issuable {
+
+  public List<Issue> issues;
+
+  public DefaultIssuable(List<Issue> issues) {
+    this.issues = issues;
+  }
+
+  public Issue apply(Issue issue, IssueChangelog issueChangelog) {
+    DefaultIssue defaultIssue = findIssue(issue);
+
+    if (!Objects.equal(defaultIssue.severity(), issueChangelog.severity())) {
+      defaultIssue.severity(issueChangelog.severity());
+    }
+    if (!Objects.equal(defaultIssue.status(), issueChangelog.status())) {
+      defaultIssue.status(issueChangelog.status());
+    }
+    if (!Objects.equal(defaultIssue.resolution(), issueChangelog.resolution())) {
+      defaultIssue.resolution(issueChangelog.resolution());
+    }
+    if (!Objects.equal(defaultIssue.line(), issueChangelog.line())) {
+      defaultIssue.line(issueChangelog.line());
+      // Do not add changelog if only line has changed
+    }
+
+    defaultIssue.addIssueChangelog(issueChangelog);
+    return defaultIssue;
+  }
+
+  private DefaultIssue findIssue(final Issue issue) {
+    return (DefaultIssue) Iterables.find(issues, new Predicate<Issue>() {
+      public boolean apply(Issue currentIssue) {
+        return currentIssue.uuid().equals(issue.uuid());
+      }
+    });
+  }
+
+  public List<Issue> issues() {
+    return issues;
+  }
+
+  public Component component() {
+    return null;
+  }
+}
diff --git a/sonar-core/src/main/java/org/sonar/core/issue/DefaultIssue.java b/sonar-core/src/main/java/org/sonar/core/issue/DefaultIssue.java
new file mode 100644 (file)
index 0000000..b9a5efa
--- /dev/null
@@ -0,0 +1,210 @@
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2012 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
+ */
+
+package org.sonar.core.issue;
+
+import org.sonar.api.issue.Issue;
+import org.sonar.api.issue.IssueChangelog;
+
+import java.util.Date;
+import java.util.List;
+import java.util.UUID;
+
+import static com.google.common.collect.Lists.newArrayList;
+
+/**
+ * @since 3.6
+ */
+public class DefaultIssue implements Issue {
+
+  private String uuid;
+  private String componentKey;
+  private String ruleKey;
+  private String ruleRepositoryKey;
+  private String severity;
+  private String message;
+  private Integer line;
+  private Double cost;
+  private String status;
+  private String resolution;
+  private Date createdAt;
+
+  private List<IssueChangelog> issueChangelogList;
+
+  private DefaultIssue(Builder builder) {
+    this.uuid = builder.uuid;
+    this.componentKey = builder.componentKey;
+    this.ruleKey = builder.ruleKey;
+    this.ruleRepositoryKey = builder.ruleRepositoryKey;
+    this.severity = builder.severity;
+    this.message = builder.message;
+    this.line = builder.line;
+    this.cost = builder.cost;
+    this.status = builder.status;
+    this.resolution = builder.resolution;
+    this.createdAt = builder.createdAt;
+
+    this.issueChangelogList= newArrayList();
+  }
+
+  public String uuid() {
+    return uuid;
+  }
+
+  public String componentKey() {
+    return componentKey;
+  }
+
+  public String ruleKey() {
+    return ruleKey;
+  }
+
+  public String ruleRepositoryKey() {
+    return ruleRepositoryKey;
+  }
+
+  public String severity() {
+    return severity;
+  }
+
+  public DefaultIssue severity(String severity){
+    this.severity = severity;
+    return this;
+  }
+
+  public String message() {
+    return message;
+  }
+
+  public Integer line() {
+    return line;
+  }
+
+  public DefaultIssue line(Integer line){
+    this.line = line;
+    return this;
+  }
+
+  public Double cost() {
+    return cost;
+  }
+
+  public String status() {
+    return status;
+  }
+
+  public DefaultIssue status(String status){
+    this.status = status;
+    return this;
+  }
+
+  public String resolution() {
+    return resolution;
+  }
+
+  public DefaultIssue resolution(String resolution){
+    this.resolution = resolution;
+    return this;
+  }
+
+  public Date createdAt() {
+    return createdAt;
+  }
+
+  public List<IssueChangelog> issueChangelogList() {
+    return issueChangelogList;
+  }
+
+  public DefaultIssue addIssueChangelog(IssueChangelog issueChangelog) {
+    issueChangelogList.add(issueChangelog);
+    return this;
+  }
+
+  /**
+   * @since 3.6
+   */
+  public static class Builder {
+    private String uuid;
+    private String componentKey;
+    private String ruleKey;
+    private String ruleRepositoryKey;
+    private String severity;
+    private String message;
+    private Integer line;
+    private Double cost;
+    private String status;
+    private String resolution;
+    private Date createdAt;
+
+    public Builder() {
+      uuid = UUID.randomUUID().toString();
+      createdAt = new Date();
+    }
+
+    public Builder componentKey(String componentKey) {
+      this.componentKey = componentKey;
+      return this;
+    }
+
+    public Builder ruleKey(String ruleKey) {
+      this.ruleKey = ruleKey;
+      return this;
+    }
+
+    public Builder ruleRepositoryKey(String ruleRepositoryKey) {
+      this.ruleRepositoryKey = ruleRepositoryKey;
+      return this;
+    }
+
+    public Builder severity(String severity) {
+      this.severity = severity;
+      return this;
+    }
+
+    public Builder message(String message) {
+      this.message = message;
+      return this;
+    }
+
+    public Builder line(Integer line) {
+      this.line = line;
+      return this;
+    }
+
+    public Builder cost(Double cost) {
+      this.cost = cost;
+      return this;
+    }
+
+    public Builder status(String status) {
+      this.status = status;
+      return this;
+    }
+
+    public Builder resolution(String resolution) {
+      this.resolution = resolution;
+      return this;
+    }
+
+    public DefaultIssue build() {
+      return new DefaultIssue(this);
+    }
+  }
+}
diff --git a/sonar-core/src/main/java/org/sonar/core/issue/DefaultIssueChangelog.java b/sonar-core/src/main/java/org/sonar/core/issue/DefaultIssueChangelog.java
new file mode 100644 (file)
index 0000000..5a38478
--- /dev/null
@@ -0,0 +1,118 @@
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2012 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
+ */
+
+package org.sonar.core.issue;
+
+import org.sonar.api.issue.IssueChangelog;
+
+import java.util.Date;
+
+/**
+ * @since 3.6
+ */
+public class DefaultIssueChangelog implements IssueChangelog {
+
+  private String severity;
+  private String status;
+  private String resolution;
+  private String message;
+  private Integer line;
+
+  private Date createdAt;
+
+  private DefaultIssueChangelog(Builder builder) {
+    this.severity = builder.severity;
+    this.status = builder.status;
+    this.resolution = builder.resolution;
+    this.message = builder.message;
+    this.line = builder.line;
+    this.createdAt = builder.createdAt;
+  }
+
+  public String severity() {
+    return severity;
+  }
+
+  public String status() {
+    return status;
+  }
+
+  public String resolution() {
+    return resolution;
+  }
+
+  public String message() {
+    return message;
+  }
+
+  public Integer line() {
+    return line;
+  }
+
+  public Date createdAt() {
+    return createdAt;
+  }
+
+  /**
+   * @since 3.6
+   */
+  public static class Builder {
+    private String severity;
+    private String status;
+    private String resolution;
+    private String message;
+    private Integer line;
+
+    private Date createdAt;
+
+    public Builder() {
+      createdAt = new Date();
+    }
+
+    public Builder severity(String severity) {
+      this.severity = severity;
+      return this;
+    }
+
+    public Builder status(String status) {
+      this.status = status;
+      return this;
+    }
+
+    public Builder resolution(String resolution) {
+      this.resolution = resolution;
+      return this;
+    }
+
+    public Builder message(String message) {
+      this.message = message;
+      return this;
+    }
+
+    public Builder line(Integer line) {
+      this.line = line;
+      return this;
+    }
+
+    public DefaultIssueChangelog build() {
+      return new DefaultIssueChangelog(this);
+    }
+  }
+}
index 2707689c3409c23c699ae00e64d826e0a4889ddb..e034bbf0042a57bcc2050a61835ddf6c79b9fbeb 100644 (file)
@@ -61,6 +61,8 @@ public final class DatabaseUtils {
     "groups",
     "groups_users",
     "group_roles",
+    "issues",
+    "issue_changelog",
     "loaded_templates",
     "manual_measures",
     "measure_data",
index f5f870b9e4810666c97fa20f4d17d49ddf508d89..38048ab3934aad797014f8e90bd949f307fac458 100644 (file)
@@ -32,7 +32,7 @@ import java.util.List;
  */
 public class DatabaseVersion implements BatchComponent, ServerComponent {
 
-  public static final int LAST_VERSION = 384;
+  public static final int LAST_VERSION = 386;
 
   public static enum Status {
     UP_TO_DATE, REQUIRES_UPGRADE, REQUIRES_DOWNGRADE, FRESH_INSTALL
index 8e4d9de536672b6b345f0b7f43c67c420aeabc76..f5e2d9b85155425dc396177fe04c80c74027da7d 100644 (file)
@@ -154,6 +154,8 @@ INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('381');
 INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('382');
 INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('383');
 INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('384');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('385');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('386');
 
 INSERT INTO USERS(ID, LOGIN, NAME, EMAIL, CRYPTED_PASSWORD, SALT, CREATED_AT, UPDATED_AT, REMEMBER_TOKEN, REMEMBER_TOKEN_EXPIRES_AT) VALUES (1, 'admin', 'Administrator', '', 'a373a0e667abb2604c1fd571eb4ad47fe8cc0878', '48bc4b0d93179b5103fd3885ea9119498e9d161b', '2011-09-26 22:27:48.0', '2011-09-26 22:27:48.0', null, null);
 ALTER TABLE USERS ALTER COLUMN ID RESTART WITH 2;
index aed8cc2b178c22286c35f6a2e0556204f0ba3f22..6b4402a5445b69bbcdffa5458c0d8d39065f78d6 100644 (file)
@@ -515,6 +515,41 @@ CREATE TABLE "GRAPHS" (
   "UPDATED_AT" TIMESTAMP
 );
 
+CREATE TABLE "ISSUES" (
+  "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
+  "UUID" VARCHAR(36) NOT NULL,
+  "RESOURCE_ID" INTEGER NOT NULL,
+  "RULE_ID" INTEGER NOT NULL,
+  "SEVERITY" VARCHAR(10),
+  "MANUAL_SEVERITY" BOOLEAN NOT NULL,
+  "MANUAL_ISSUE" BOOLEAN NOT NULL,
+  "TITLE" VARCHAR(500),
+  "MESSAGE" VARCHAR(4000),
+  "LINE" INTEGER,
+  "COST" DOUBLE,
+  "STATUS" VARCHAR(10),
+  "RESOLUTION" VARCHAR(200),
+  "CHECKSUM" VARCHAR(1000),
+  "ASSIGNEE_USER_ID" INTEGER,
+  "PERSON_ID" INTEGER,
+  "USER_ID" INTEGER,
+  "DATA" VARCHAR(1000),
+  "CREATED_AT" TIMESTAMP,
+  "UPDATED_AT" TIMESTAMP,
+  "CLOSED_AT" TIMESTAMP,
+);
+
+CREATE TABLE "ISSUE_CHANGELOG" (
+  "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
+  "ISSUE_ID" INTEGER NOT NULL,
+  "USER_ID" INTEGER,
+  "CHANGE_TYPE" VARCHAR(50),
+  "CHANGE_DATA" VARCHAR(4000),
+  "MESSAGE"  VARCHAR(16777215),
+  "CREATED_AT" TIMESTAMP,
+  "UPDATED_AT" TIMESTAMP,
+);
+
 -- ----------------------------------------------
 -- DDL Statements for indexes
 -- ----------------------------------------------
@@ -625,4 +660,8 @@ CREATE INDEX "MEASURE_FILTERS_NAME" ON "MEASURE_FILTERS" ("NAME");
 
 CREATE INDEX "MEASURE_FILTER_FAVS_USERID" ON "MEASURE_FILTER_FAVOURITES" ("USER_ID");
 
-CREATE UNIQUE INDEX "GRAPHS_PERSPECTIVES" ON "GRAPHS" ("SNAPSHOT_ID", "PERSPECTIVE");
\ No newline at end of file
+CREATE UNIQUE INDEX "GRAPHS_PERSPECTIVES" ON "GRAPHS" ("SNAPSHOT_ID", "PERSPECTIVE");
+
+--CREATE INDEX "ISSUES_RESOURCE_ID" ON "ISSUES" ("RESOURCE_ID");
+
+--CREATE INDEX "ISSUES_RULE_ID" ON "ISSUES" ("RULE_ID");
diff --git a/sonar-core/src/test/java/org/sonar/core/issue/DefaultIssuableTest.java b/sonar-core/src/test/java/org/sonar/core/issue/DefaultIssuableTest.java
new file mode 100644 (file)
index 0000000..d11bb43
--- /dev/null
@@ -0,0 +1,73 @@
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2012 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
+ */
+
+package org.sonar.core.issue;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.sonar.api.issue.Issue;
+
+import java.util.List;
+
+import static com.google.common.collect.Lists.newArrayList;
+import static org.fest.assertions.Assertions.assertThat;
+
+public class DefaultIssuableTest {
+
+  private DefaultIssuable issuable;
+  private List<Issue> issueList;
+
+  @Before
+  public void before(){
+    issueList = newArrayList();
+    issuable = new DefaultIssuable(issueList);
+  }
+
+  @Test
+  public void should_apply_issue() throws Exception {
+    DefaultIssue issue = new DefaultIssue.Builder()
+        .ruleKey("ruleKey")
+        .ruleRepositoryKey("ruleRepositoryKey")
+        .severity(Issue.SEVERITY_BLOCKER)
+        .status(Issue.STATUS_REOPENED)
+        .resolution(Issue.RESOLUTION_FALSE_POSITIVE)
+        .line(10)
+        .componentKey("componentKey")
+        .cost(10.0)
+        .message("issue message")
+        .build();
+    issueList.add(issue);
+
+    DefaultIssueChangelog issueChangelog = new DefaultIssueChangelog.Builder()
+        .severity(Issue.SEVERITY_MAJOR)
+        .status(Issue.STATUS_CLOSED)
+        .resolution(Issue.RESOLUTION_FIXED)
+        .message("changelog message")
+        .line(1)
+        .build();
+
+    Issue resultIssue = issuable.apply(issue, issueChangelog);
+    assertThat(resultIssue).isNotNull();
+    assertThat(resultIssue.severity()).isEqualTo(Issue.SEVERITY_MAJOR);
+    assertThat(resultIssue.status()).isEqualTo(Issue.STATUS_CLOSED);
+    assertThat(resultIssue.resolution()).isEqualTo(Issue.RESOLUTION_FIXED);
+    assertThat(resultIssue.line()).isEqualTo(1);
+  }
+}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/issue/Issuable.java b/sonar-plugin-api/src/main/java/org/sonar/api/issue/Issuable.java
new file mode 100644 (file)
index 0000000..ffbda13
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2012 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
+ */
+
+package org.sonar.api.issue;
+
+import org.sonar.api.component.Component;
+import org.sonar.api.component.Perspective;
+
+/**
+ * @since 3.6
+ */
+public interface Issuable extends Perspective {
+
+  Issue apply(Issue issue, IssueChangelog issueChangelog);
+
+  @Override
+  Component component();
+
+}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/issue/Issue.java b/sonar-plugin-api/src/main/java/org/sonar/api/issue/Issue.java
new file mode 100644 (file)
index 0000000..25ea1c9
--- /dev/null
@@ -0,0 +1,68 @@
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2012 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
+ */
+
+package org.sonar.api.issue;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * @since 3.6
+ */
+public interface Issue {
+
+  String STATUS_REOPENED = "REOPENED";
+  String STATUS_RESOLVED = "RESOLVED";
+  String STATUS_CLOSED = "CLOSED";
+
+  String RESOLUTION_FALSE_POSITIVE = "FALSE-POSITIVE";
+  String RESOLUTION_FIXED = "FIXED";
+
+  String SEVERITY_INFO = "INFO";
+  String SEVERITY_MINOR = "MINOR";
+  String SEVERITY_MAJOR = "MAJOR";
+  String SEVERITY_CRITICAL = "CRITICAL";
+  String SEVERITY_BLOCKER = "BLOCKER";
+
+  String uuid();
+
+  String componentKey();
+
+  String ruleKey();
+
+  String ruleRepositoryKey();
+
+  String severity();
+
+  String message();
+
+  Integer line();
+
+  Double cost();
+
+  String status();
+
+  String resolution();
+
+  Date createdAt();
+
+  List<IssueChangelog> issueChangelogList();
+
+}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/issue/IssueChangelog.java b/sonar-plugin-api/src/main/java/org/sonar/api/issue/IssueChangelog.java
new file mode 100644 (file)
index 0000000..34286f0
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2012 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
+ */
+
+package org.sonar.api.issue;
+
+import java.util.Date;
+
+/**
+ * @since 3.6
+ */
+public interface IssueChangelog {
+
+  String severity();
+
+  String status();
+
+  String resolution();
+
+  String message();
+
+  Integer line();
+
+  Date createdAt();
+
+}
diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/385_create_issues.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/385_create_issues.rb
new file mode 100644 (file)
index 0000000..7503dfd
--- /dev/null
@@ -0,0 +1,55 @@
+#
+# Sonar, entreprise quality control tool.
+# Copyright (C) 2008-2012 SonarSource
+# mailto:contact AT sonarsource DOT com
+#
+# Sonar 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.
+#
+# Sonar 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 Sonar; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
+#
+
+#
+# Sonar 3.6
+#
+class CreateIssues < ActiveRecord::Migration
+
+  def self.up
+    create_table :issues do |t|
+      t.column :uuid,               :string,    :null => false,   :limit => 36
+      t.column :resource_id,        :integer,   :null => false
+      t.column :rule_id,            :integer,   :null => false
+      t.column :severity,                                      :string,          :null => true,          :limit => 10
+      t.column :manual_severity,    :boolean,   :null => false
+      t.column :manual_issue,       :boolean,   :null => false
+      t.column :title,              :string ,   :null => true,    :limit => 500
+      t.column :message,            :string,    :null => true,    :limit => 4000
+      t.column :line,               :integer,   :null => true
+      t.column :cost,               :decimal,   :null => true,    :precision => 30,   :scale => 20
+      t.column :status,             :string ,   :null => true,    :limit => 10
+      t.column :resolution,         :string ,   :null => true,    :limit => 200
+      t.column :checksum,           :string ,   :null => true,    :limit => 1000
+      t.column :assignee_user_id,   :integer,   :null => true
+      t.column :person_id,          :integer,   :null => true
+      t.column :user_id,            :integer,   :null => true
+      t.column :data,               :string,    :null => true,    :limit => 1000
+      t.column :created_at,         :datetime,  :null => true
+      t.column :updated_at,         :datetime,  :null => true
+      t.column :closed_at,          :datetime,  :null => true
+    end
+
+    #add_index :issues,  :resource_id,   :name => 'issues_resource_id'
+    #add_index :issues,  :rule_id,       :name => 'issues_rule_id'
+  end
+
+end
+
diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/386_create_issue_changelog.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/386_create_issue_changelog.rb
new file mode 100644 (file)
index 0000000..da718b0
--- /dev/null
@@ -0,0 +1,39 @@
+#
+# Sonar, entreprise quality control tool.
+# Copyright (C) 2008-2012 SonarSource
+# mailto:contact AT sonarsource DOT com
+#
+# Sonar 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.
+#
+# Sonar 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 Sonar; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
+#
+
+#
+# Sonar 3.6
+#
+class CreateIssueChangelog < ActiveRecord::Migration
+
+  def self.up
+    create_table :issue_changelog do |t|
+      t.column :issue_id,           :integer,   :null => false
+      t.column :user_id,            :integer,   :null => true
+      t.column :change_type,                           :string,          :null => true,          :limit => 50
+      t.column :change_data,        :string,    :null => true,    :limit => 4000
+      t.column :message,            :text,      :null => true
+      t.column :created_at,         :datetime,  :null => true
+      t.column :updated_at,         :datetime,  :null => true
+    end
+  end
+
+end
+