From 8c7b10b6bf2712e1d7201ebd025aed36fad7ead6 Mon Sep 17 00:00:00 2001 From: Julien Lancelot Date: Tue, 18 Mar 2014 09:34:41 +0100 Subject: SONAR-5056 Refactoring of DebtModelService to have a clean dedicated server side API of debt --- .../sonar/api/server/debt/DebtCharacteristic.java | 40 ++++++++++ .../java/org/sonar/api/server/debt/DebtModel.java | 38 ++++++++++ .../debt/internal/DefaultDebtCharacteristic.java | 85 ++++++++++++++++++++++ .../api/server/debt/internal/package-info.java | 24 ++++++ .../org/sonar/api/server/debt/package-info.java | 24 ++++++ .../api/technicaldebt/server/Characteristic.java | 4 +- .../technicaldebt/server/TechnicalDebtManager.java | 43 ----------- .../server/internal/DefaultCharacteristic.java | 2 + 8 files changed, 216 insertions(+), 44 deletions(-) create mode 100644 sonar-plugin-api/src/main/java/org/sonar/api/server/debt/DebtCharacteristic.java create mode 100644 sonar-plugin-api/src/main/java/org/sonar/api/server/debt/DebtModel.java create mode 100644 sonar-plugin-api/src/main/java/org/sonar/api/server/debt/internal/DefaultDebtCharacteristic.java create mode 100644 sonar-plugin-api/src/main/java/org/sonar/api/server/debt/internal/package-info.java create mode 100644 sonar-plugin-api/src/main/java/org/sonar/api/server/debt/package-info.java delete mode 100644 sonar-plugin-api/src/main/java/org/sonar/api/technicaldebt/server/TechnicalDebtManager.java (limited to 'sonar-plugin-api/src') diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/server/debt/DebtCharacteristic.java b/sonar-plugin-api/src/main/java/org/sonar/api/server/debt/DebtCharacteristic.java new file mode 100644 index 00000000000..8f3dd602d7b --- /dev/null +++ b/sonar-plugin-api/src/main/java/org/sonar/api/server/debt/DebtCharacteristic.java @@ -0,0 +1,40 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube 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. + * + * SonarQube 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.api.server.debt; + +import javax.annotation.CheckForNull; + +/** + * @since 4.3 + */ +public interface DebtCharacteristic { + Integer id(); + + String key(); + + String name(); + + @CheckForNull + Integer order(); + + @CheckForNull + Integer parentId(); +} diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/server/debt/DebtModel.java b/sonar-plugin-api/src/main/java/org/sonar/api/server/debt/DebtModel.java new file mode 100644 index 00000000000..e2bd93cba6c --- /dev/null +++ b/sonar-plugin-api/src/main/java/org/sonar/api/server/debt/DebtModel.java @@ -0,0 +1,38 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube 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. + * + * SonarQube 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.api.server.debt; + +import org.sonar.api.ServerComponent; + +import java.util.List; + +/** + * @since 4.3 + */ +public interface DebtModel extends ServerComponent { + + List characteristics(); + + List rootCharacteristics(); + + DebtCharacteristic characteristicById(int id); + +} diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/server/debt/internal/DefaultDebtCharacteristic.java b/sonar-plugin-api/src/main/java/org/sonar/api/server/debt/internal/DefaultDebtCharacteristic.java new file mode 100644 index 00000000000..6b6fce040f5 --- /dev/null +++ b/sonar-plugin-api/src/main/java/org/sonar/api/server/debt/internal/DefaultDebtCharacteristic.java @@ -0,0 +1,85 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube 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. + * + * SonarQube 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.api.server.debt.internal; + +import org.sonar.api.server.debt.DebtCharacteristic; + +/** + * @since 4.3 + */ +public class DefaultDebtCharacteristic implements DebtCharacteristic { + + private Integer id; + private String key; + private String name; + private Integer order; + private Integer parentId; + + @Override + public Integer id() { + return id; + } + + public DefaultDebtCharacteristic setId(Integer id) { + this.id = id; + return this; + } + + @Override + public String key() { + return key; + } + + public DefaultDebtCharacteristic setKey(String key) { + this.key = key; + return this; + } + + @Override + public String name() { + return name; + } + + public DefaultDebtCharacteristic setName(String name) { + this.name = name; + return this; + } + + @Override + public Integer order() { + return order; + } + + public DefaultDebtCharacteristic setOrder(Integer order) { + this.order = order; + return this; + } + + @Override + public Integer parentId() { + return parentId; + } + + public DefaultDebtCharacteristic setParentId(Integer parentId) { + this.parentId = parentId; + return this; + } +} diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/server/debt/internal/package-info.java b/sonar-plugin-api/src/main/java/org/sonar/api/server/debt/internal/package-info.java new file mode 100644 index 00000000000..fc333dadf16 --- /dev/null +++ b/sonar-plugin-api/src/main/java/org/sonar/api/server/debt/internal/package-info.java @@ -0,0 +1,24 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube 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. + * + * SonarQube 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. + */ + +@ParametersAreNonnullByDefault +package org.sonar.api.server.debt.internal; + +import javax.annotation.ParametersAreNonnullByDefault; diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/server/debt/package-info.java b/sonar-plugin-api/src/main/java/org/sonar/api/server/debt/package-info.java new file mode 100644 index 00000000000..296802f21d5 --- /dev/null +++ b/sonar-plugin-api/src/main/java/org/sonar/api/server/debt/package-info.java @@ -0,0 +1,24 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube 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. + * + * SonarQube 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. + */ + +@ParametersAreNonnullByDefault +package org.sonar.api.server.debt; + +import javax.annotation.ParametersAreNonnullByDefault; diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/technicaldebt/server/Characteristic.java b/sonar-plugin-api/src/main/java/org/sonar/api/technicaldebt/server/Characteristic.java index c39eba4108a..1e263a6fe20 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/technicaldebt/server/Characteristic.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/technicaldebt/server/Characteristic.java @@ -27,8 +27,10 @@ import org.sonar.api.utils.internal.WorkDuration; import javax.annotation.CheckForNull; /** - * @since 4.1 + * @since 4.1 * + * @deprecated since 4.3. */ +@Deprecated public interface Characteristic { Integer id(); diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/technicaldebt/server/TechnicalDebtManager.java b/sonar-plugin-api/src/main/java/org/sonar/api/technicaldebt/server/TechnicalDebtManager.java deleted file mode 100644 index e3b1d8465d6..00000000000 --- a/sonar-plugin-api/src/main/java/org/sonar/api/technicaldebt/server/TechnicalDebtManager.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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.api.technicaldebt.server; - -import org.sonar.api.ServerComponent; -import org.sonar.api.rules.Rule; - -import java.util.List; - -/** - * @since 4.1 - */ - -public interface TechnicalDebtManager extends ServerComponent { - - List findRootCharacteristics(); - - /** - * @deprecated since 4.3. Always return null - */ - @Deprecated - Characteristic findRequirementByRule(Rule rule); - - Characteristic findCharacteristicById(Integer id); -} diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/technicaldebt/server/internal/DefaultCharacteristic.java b/sonar-plugin-api/src/main/java/org/sonar/api/technicaldebt/server/internal/DefaultCharacteristic.java index 15a0e68dfd4..1c49df8a662 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/technicaldebt/server/internal/DefaultCharacteristic.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/technicaldebt/server/internal/DefaultCharacteristic.java @@ -32,7 +32,9 @@ import javax.annotation.Nullable; /** * @since 4.1 + * @deprecated since 4.3. */ +@Deprecated public class DefaultCharacteristic implements Characteristic { private Integer id; -- cgit v1.2.3