diff options
author | Simon Brandhof <simon.brandhof@gmail.com> | 2013-04-10 18:45:12 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@gmail.com> | 2013-04-10 18:45:12 +0200 |
commit | 6be3704e4893ef793f8152175286b0bd5d13beac (patch) | |
tree | 9a77f8b9b8536d3064e7a47da0291e58f7b186ad /sonar-plugin-api/src/main | |
parent | 8a15d3f31793c98907f77843f1c269de0a1450ed (diff) | |
download | sonarqube-6be3704e4893ef793f8152175286b0bd5d13beac.tar.gz sonarqube-6be3704e4893ef793f8152175286b0bd5d13beac.zip |
SONAR-3755 refactor the way to persist component perspectives
Diffstat (limited to 'sonar-plugin-api/src/main')
7 files changed, 149 insertions, 339 deletions
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 index 98f0dfe54e1..76a0c3af066 100644 --- 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 @@ -23,16 +23,36 @@ package org.sonar.api.issue; import org.sonar.api.component.Component; import org.sonar.api.component.Perspective; -import java.util.List; +import java.util.Collection; /** * @since 3.6 */ public interface Issuable extends Perspective { - Issue apply(Issue issue, IssueChange issueChangelog); + interface IssueBuilder { + IssueBuilder rule(String repository, String key); - List<Issue> issues(); + IssueBuilder line(Integer line); + + IssueBuilder message(String message); + + IssueBuilder title(String title); + + IssueBuilder severity(String severity); + + IssueBuilder cost(Double cost); + + IssueBuilder manual(boolean b); + + Issue create(); + } + + IssueBuilder newIssue(); + + Issue apply(Issue issue, IssueAction action); + + Collection<Issue> issues(); @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 index d7c38486e4e..07079570e57 100644 --- 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 @@ -17,252 +17,69 @@ * 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.UUID; +import java.util.Map; /** * @since 3.6 */ -public class Issue { - - public static final String STATUS_REOPENED = "REOPENED"; - public static final String STATUS_RESOLVED = "RESOLVED"; - public static final String STATUS_CLOSED = "CLOSED"; - - public static final String RESOLUTION_FALSE_POSITIVE = "FALSE-POSITIVE"; - public static final String RESOLUTION_FIXED = "FIXED"; +public interface Issue { - public static final String SEVERITY_INFO = "INFO"; - public static final String SEVERITY_MINOR = "MINOR"; - public static final String SEVERITY_MAJOR = "MAJOR"; - public static final String SEVERITY_CRITICAL = "CRITICAL"; - public static final String SEVERITY_BLOCKER = "BLOCKER"; + String STATUS_OPEN = "OPEN"; + String STATUS_REOPENED = "REOPENED"; + String STATUS_RESOLVED = "RESOLVED"; + String STATUS_CLOSED = "CLOSED"; - private String key; - private String componentKey; - private String ruleKey; - private String ruleRepositoryKey; - private String severity; - private String title; - private String message; - private Integer line; - private Double cost; - private String status; - private String resolution; - private String userLogin; - private String assigneeLogin; - private Date createdAt; - private Date updatedAt; - private Date closedAt; + String RESOLUTION_FALSE_POSITIVE = "FALSE-POSITIVE"; + String RESOLUTION_FIXED = "FIXED"; - private Issue(Builder builder) { - this.key = builder.key; - 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.userLogin = builder.userLogin; - this.assigneeLogin = builder.assigneeLogin; - this.createdAt = builder.createdAt; - this.updatedAt = builder.updatedAt; - this.closedAt = builder.closedAt; - } + String SEVERITY_INFO = "INFO"; + String SEVERITY_MINOR = "MINOR"; + String SEVERITY_MAJOR = "MAJOR"; + String SEVERITY_CRITICAL = "CRITICAL"; + String SEVERITY_BLOCKER = "BLOCKER"; - public String key() { - return key; - } - - public String componentKey() { - return componentKey; - } - - public String ruleKey() { - return ruleKey; - } + /** + * Unique key + */ + String key(); - public String ruleRepositoryKey() { - return ruleRepositoryKey; - } + String componentKey(); - public String severity() { - return severity; - } + String ruleKey(); - public String title() { - return title; - } + String ruleRepositoryKey(); - public String message() { - return message; - } + String severity(); - public Integer line() { - return line; - } + String title(); - public Double cost() { - return cost; - } + String message(); - public String status() { - return status; - } + Integer line(); - public String resolution() { - return resolution; - } + Double cost(); - public String userLogin() { - return userLogin; - } + String status(); - public String assigneeLogin() { - return assigneeLogin; - } + String resolution(); - public Date createdAt() { - return createdAt; - } + String userLogin(); - public Date updatedAt() { - return updatedAt; - } + String assigneeLogin(); - public Date closedAt() { - return closedAt; - } + Date createdAt(); - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } + Date updatedAt(); - Issue issue = (Issue) o; - return !(key != null ? !key.equals(issue.key()) : issue.key() != null); - } + Date closedAt(); - @Override - public int hashCode() { - return key != null ? key.hashCode() : 0; - } + String attribute(String key); /** - * @since 3.6 + * Used only during project scan. */ - public static class Builder { - private String key; - private String componentKey; - private String ruleKey; - private String ruleRepositoryKey; - private String severity; - private String title; - private String message; - private Integer line; - private Double cost; - private String status; - private String resolution; - private String userLogin; - private String assigneeLogin; - private Date createdAt; - private Date updatedAt; - private Date closedAt; - - public Builder() { - key = UUID.randomUUID().toString(); - createdAt = new Date(); - } - - public Builder(Issue issue) { - this.key = issue.key(); - this.componentKey = issue.componentKey(); - this.ruleKey = issue.ruleKey(); - this.ruleRepositoryKey = issue.ruleRepositoryKey(); - this.severity = issue.severity(); - this.title = title; - this.message = issue.message(); - this.line = issue.line(); - this.cost = issue.cost(); - this.status = issue.status(); - this.resolution = issue.resolution(); - this.createdAt = issue.createdAt(); - this.updatedAt = issue.updatedAt(); - this.closedAt = issue.closedAt(); - } - - 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 title(String title) { - this.title = title; - 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 Builder userLogin(String userLogin) { - this.userLogin = userLogin; - return this; - } - - public Builder assigneeLogin(String assigneeLogin) { - this.assigneeLogin = assigneeLogin; - return this; - } - - public Issue build() { - return new Issue(this); - } - } + boolean isNew(); } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/issue/IssueAction.java b/sonar-plugin-api/src/main/java/org/sonar/api/issue/IssueAction.java new file mode 100644 index 00000000000..ca3c3fb6fe2 --- /dev/null +++ b/sonar-plugin-api/src/main/java/org/sonar/api/issue/IssueAction.java @@ -0,0 +1,28 @@ +/* + * 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; + +/** + * @since 3.6 + */ +public interface IssueAction { + // TO BE DEFINED +}
\ No newline at end of file diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/issue/IssueChange.java b/sonar-plugin-api/src/main/java/org/sonar/api/issue/IssueChange.java deleted file mode 100644 index 806ecf7fa22..00000000000 --- a/sonar-plugin-api/src/main/java/org/sonar/api/issue/IssueChange.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * 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 class IssueChange { - - private String severity; - private String status; - private String resolution; - private String message; - private Integer line; - - private Date createdAt; - - private IssueChange(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 IssueChange build() { - return new IssueChange(this); - } - } -} diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/issue/IssueFinder.java b/sonar-plugin-api/src/main/java/org/sonar/api/issue/IssueFinder.java index c944d8813b9..1d8a69d2b88 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/issue/IssueFinder.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/issue/IssueFinder.java @@ -21,14 +21,13 @@ package org.sonar.api.issue; import org.sonar.api.ServerComponent; -import org.sonar.api.task.TaskComponent; import java.util.List; /** * @since 3.6 */ -public interface IssueFinder extends TaskComponent, ServerComponent { +public interface IssueFinder extends ServerComponent { List<Issue> find(IssueQuery issueQuery); diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/scan/event/ModuleScanPhaseHandler.java b/sonar-plugin-api/src/main/java/org/sonar/api/scan/event/ModuleScanPhaseHandler.java new file mode 100644 index 00000000000..929695dcf0f --- /dev/null +++ b/sonar-plugin-api/src/main/java/org/sonar/api/scan/event/ModuleScanPhaseHandler.java @@ -0,0 +1,30 @@ +/* + * 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.scan.event; + +import org.sonar.api.batch.events.EventHandler; + +public interface ModuleScanPhaseHandler extends EventHandler { + interface ModuleScanPhaseEvent { + + } + + void onModuleScanPhase(ModuleScanPhaseEvent event); +} diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/scan/event/ProjectScanHandler.java b/sonar-plugin-api/src/main/java/org/sonar/api/scan/event/ProjectScanHandler.java new file mode 100644 index 00000000000..35f0f6cc5c9 --- /dev/null +++ b/sonar-plugin-api/src/main/java/org/sonar/api/scan/event/ProjectScanHandler.java @@ -0,0 +1,32 @@ +/* + * 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.scan.event; + +import org.sonar.api.batch.events.EventHandler; + +public interface ProjectScanHandler extends EventHandler { + interface ProjectScanEvent { + boolean isStart(); + + boolean isEnd(); + } + + void onProjectScan(ProjectScanEvent event); +} |