]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-4716 Remove Technical Debt MyBatis classes and replace it by Rails
authorJulien Lancelot <julien.lancelot@gmail.com>
Fri, 11 Oct 2013 11:43:15 +0000 (13:43 +0200)
committerJulien Lancelot <julien.lancelot@gmail.com>
Fri, 11 Oct 2013 11:43:15 +0000 (13:43 +0200)
31 files changed:
sonar-core/src/main/java/org/sonar/core/persistence/DaoUtils.java
sonar-core/src/main/java/org/sonar/core/persistence/MyBatis.java
sonar-core/src/main/java/org/sonar/core/technicaldebt/DefaultCharacteristic.java [deleted file]
sonar-core/src/main/java/org/sonar/core/technicaldebt/DefaultRequirement.java [deleted file]
sonar-core/src/main/java/org/sonar/core/technicaldebt/DefaultRequirementProperty.java [deleted file]
sonar-core/src/main/java/org/sonar/core/technicaldebt/db/CharacteristicDto.java [deleted file]
sonar-core/src/main/java/org/sonar/core/technicaldebt/db/CharacteristicMapper.java [deleted file]
sonar-core/src/main/java/org/sonar/core/technicaldebt/db/RequirementDao.java [deleted file]
sonar-core/src/main/java/org/sonar/core/technicaldebt/db/RequirementDto.java [deleted file]
sonar-core/src/main/java/org/sonar/core/technicaldebt/db/RequirementMapper.java [deleted file]
sonar-core/src/main/java/org/sonar/core/technicaldebt/db/RequirementPropertyDto.java [deleted file]
sonar-core/src/main/java/org/sonar/core/technicaldebt/db/RequirementPropertyMapper.java [deleted file]
sonar-core/src/main/java/org/sonar/core/technicaldebt/db/package-info.java [deleted file]
sonar-core/src/main/resources/org/sonar/core/technicaldebt/db/CharacteristicMapper.xml [deleted file]
sonar-core/src/main/resources/org/sonar/core/technicaldebt/db/RequirementMapper.xml [deleted file]
sonar-core/src/main/resources/org/sonar/core/technicaldebt/db/RequirementPropertyMapper.xml [deleted file]
sonar-core/src/test/java/org/sonar/core/technicaldebt/DefaultRequirementTest.java [deleted file]
sonar-core/src/test/java/org/sonar/core/technicaldebt/db/CharacteristicDtoTest.java [deleted file]
sonar-core/src/test/java/org/sonar/core/technicaldebt/db/RequirementDaoTest.java [deleted file]
sonar-core/src/test/java/org/sonar/core/technicaldebt/db/RequirementDtoTest.java [deleted file]
sonar-core/src/test/resources/org/sonar/core/technicaldebt/db/RequirementDaoTest/select_requirement_from_rule.xml [deleted file]
sonar-core/src/test/resources/org/sonar/core/technicaldebt/db/RequirementDaoTest/select_requirement_from_rule_with_two_properties.xml [deleted file]
sonar-server/src/main/java/org/sonar/server/platform/Platform.java
sonar-server/src/main/java/org/sonar/server/technicaldebt/RubyTechnicalDebtService.java [deleted file]
sonar-server/src/main/java/org/sonar/server/technicaldebt/package-info.java [deleted file]
sonar-server/src/main/webapp/WEB-INF/app/controllers/issue_controller.rb
sonar-server/src/main/webapp/WEB-INF/app/models/characteristic.rb
sonar-server/src/main/webapp/WEB-INF/app/models/characteristic_property.rb
sonar-server/src/main/webapp/WEB-INF/app/models/internal.rb
sonar-server/src/main/webapp/WEB-INF/app/views/issue/_technicaldebt.html.erb
sonar-server/src/test/java/org/sonar/server/technicaldebt/RubyTechnicalDebtServiceTest.java [deleted file]

index 2787a3d9dcb17ce29436dfad0f002db31e42c054..bef01fc36d7594e61265eb8c350f6b488c8b6adf 100644 (file)
@@ -35,7 +35,6 @@ import org.sonar.core.resource.ResourceIndexerDao;
 import org.sonar.core.resource.ResourceKeyUpdaterDao;
 import org.sonar.core.rule.RuleDao;
 import org.sonar.core.source.jdbc.SnapshotDataDao;
-import org.sonar.core.technicaldebt.db.RequirementDao;
 import org.sonar.core.template.LoadedTemplateDao;
 import org.sonar.core.user.AuthorDao;
 import org.sonar.core.user.AuthorizationDao;
@@ -71,7 +70,6 @@ public final class DaoUtils {
       PermissionTemplateDao.class,
       PropertiesDao.class,
       PurgeDao.class,
-      RequirementDao.class,
       ResourceIndexerDao.class,
       ResourceDao.class,
       ResourceKeyUpdaterDao.class,
index 4669262c2d606b89cf7ec609f1fa22e529923603..fe97b91364d4b8955d6d1671330afd94cbb11fe1 100644 (file)
@@ -63,7 +63,6 @@ import org.sonar.core.rule.RuleMapper;
 import org.sonar.core.source.jdbc.SnapshotDataDto;
 import org.sonar.core.source.jdbc.SnapshotDataMapper;
 import org.sonar.core.source.jdbc.SnapshotSourceMapper;
-import org.sonar.core.technicaldebt.db.*;
 import org.sonar.core.template.LoadedTemplateDto;
 import org.sonar.core.template.LoadedTemplateMapper;
 import org.sonar.core.user.*;
@@ -131,9 +130,6 @@ public class MyBatis implements BatchComponent, ServerComponent {
     loadAlias(conf, "PermissionTemplate", PermissionTemplateDto.class);
     loadAlias(conf, "PermissionTemplateUser", PermissionTemplateUserDto.class);
     loadAlias(conf, "PermissionTemplateGroup", PermissionTemplateGroupDto.class);
-    loadAlias(conf, "Characteristic", CharacteristicDto.class);
-    loadAlias(conf, "Requirement", RequirementDto.class);
-    loadAlias(conf, "RequirementProperty", RequirementPropertyDto.class);
 
     // AuthorizationMapper has to be loaded before IssueMapper because this last one used it
     loadMapper(conf, "org.sonar.core.user.AuthorizationMapper");
@@ -147,7 +143,7 @@ public class MyBatis implements BatchComponent, ServerComponent {
       ResourceKeyUpdaterMapper.class, ResourceIndexerMapper.class, ResourceSnapshotMapper.class, RoleMapper.class, RuleMapper.class,
       SchemaMigrationMapper.class, SemaphoreMapper.class, UserMapper.class, WidgetMapper.class, WidgetPropertyMapper.class,
       MeasureMapper.class, SnapshotDataMapper.class, SnapshotSourceMapper.class, ActionPlanMapper.class, ActionPlanStatsMapper.class,
-      NotificationQueueMapper.class, CharacteristicMapper.class, RequirementPropertyMapper.class, RequirementMapper.class
+      NotificationQueueMapper.class
     };
     loadMappers(conf, mappers);
     configureLogback(mappers);
@@ -210,7 +206,7 @@ public class MyBatis implements BatchComponent, ServerComponent {
       new XMLMapperBuilder(input, configuration, mapperName, configuration.getSqlFragments()).parse();
       configuration.addLoadedResource(mapperName);
     } catch (Exception e) {
-      throw new RuntimeException("Unable to load mapper "+ mapperName, e);
+      throw new RuntimeException("Unable to load mapper " + mapperName, e);
     } finally {
       Closeables.closeQuietly(input);
     }
diff --git a/sonar-core/src/main/java/org/sonar/core/technicaldebt/DefaultCharacteristic.java b/sonar-core/src/main/java/org/sonar/core/technicaldebt/DefaultCharacteristic.java
deleted file mode 100644 (file)
index b599c5f..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2013 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.core.technicaldebt;
-
-import org.apache.commons.lang.StringUtils;
-import org.apache.commons.lang.builder.ToStringBuilder;
-import org.apache.commons.lang.builder.ToStringStyle;
-
-public class DefaultCharacteristic {
-
-  private String key;
-  private String name;
-
-  public String key() {
-    return key;
-  }
-
-  public DefaultCharacteristic setKey(String key) {
-    this.key = StringUtils.trimToNull(key);
-    return this;
-  }
-
-  public String name() {
-    return name;
-  }
-
-  public DefaultCharacteristic setName(String name) {
-    this.name = name;
-    return this;
-  }
-
-  @Override
-  public String toString() {
-    return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
-  }
-
-  @Override
-  public boolean equals(Object o) {
-    if (this == o) {
-      return true;
-    }
-    if (o == null || getClass() != o.getClass()) {
-      return false;
-    }
-    DefaultCharacteristic that = (DefaultCharacteristic) o;
-    return key.equals(that.key);
-  }
-
-  @Override
-  public int hashCode() {
-    return key.hashCode();
-  }
-}
diff --git a/sonar-core/src/main/java/org/sonar/core/technicaldebt/DefaultRequirement.java b/sonar-core/src/main/java/org/sonar/core/technicaldebt/DefaultRequirement.java
deleted file mode 100644 (file)
index 2d243e3..0000000
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2013 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.core.technicaldebt;
-
-import com.google.common.collect.ImmutableList;
-import org.apache.commons.lang.builder.ToStringBuilder;
-import org.apache.commons.lang.builder.ToStringStyle;
-import org.sonar.api.rule.RuleKey;
-
-import javax.annotation.CheckForNull;
-
-import java.util.List;
-
-public class DefaultRequirement {
-
-  public static final String FUNCTION_CONSTANT = "constant_resource";
-  public static final String FUNCTION_LINEAR = "linear";
-  public static final String FUNCTION_LINEAR_WITH_OFFSET = "linear_offset";
-  public static final String FUNCTION_LINEAR_WITH_THRESHOLD = "linear_threshold";
-
-  public static final List<String> FUNCTIONS = ImmutableList.of(FUNCTION_CONSTANT, FUNCTION_LINEAR, FUNCTION_LINEAR_WITH_OFFSET, FUNCTION_LINEAR_WITH_THRESHOLD);
-
-  private RuleKey ruleKey;
-  private DefaultCharacteristic rootCharacteristic;
-  private DefaultCharacteristic characteristic;
-
-  private String function;
-  private WorkUnit factor;
-  private WorkUnit offset;
-
-  public RuleKey ruleKey() {
-    return ruleKey;
-  }
-
-  public DefaultRequirement setRuleKey(RuleKey ruleKey) {
-    this.ruleKey = ruleKey;
-    return this;
-  }
-
-  public DefaultCharacteristic rootCharacteristic() {
-    return rootCharacteristic;
-  }
-
-  public DefaultRequirement setRootCharacteristic(DefaultCharacteristic rootCharacteristic) {
-    this.rootCharacteristic = rootCharacteristic;
-    return this;
-  }
-
-  public DefaultCharacteristic characteristic() {
-    return characteristic;
-  }
-
-  public DefaultRequirement setCharacteristic(DefaultCharacteristic characteristic) {
-    this.characteristic = characteristic;
-    return this;
-  }
-
-  public DefaultRequirement addProperty(DefaultRequirementProperty property) {
-    if (property.key().equals(DefaultRequirementProperty.PROPERTY_REMEDIATION_FUNCTION)) {
-      String textValue = property.textValue();
-      if (!FUNCTIONS.contains(textValue)) {
-        throw new IllegalArgumentException("Function is not valid. Should be one of : "+ FUNCTIONS);
-      }
-      this.function = property.textValue();
-    } else if (property.key().equals(DefaultRequirementProperty.PROPERTY_REMEDIATION_FACTOR)) {
-      this.factor = WorkUnit.create(property.value(), property.textValue());
-    } else if (property.key().equals(DefaultRequirementProperty.PROPERTY_OFFSET)) {
-      this.offset = WorkUnit.create(property.value(), property.textValue());
-    } else {
-      throw new IllegalArgumentException("Property key is not found");
-    }
-    return this;
-  }
-
-  public String function() {
-    return function;
-  }
-
-  public WorkUnit factor() {
-    return factor;
-  }
-
-  @CheckForNull
-  public WorkUnit offset() {
-    return offset;
-  }
-
-  public boolean isConstant(){
-    return FUNCTION_CONSTANT.equals(function);
-  }
-
-  public boolean isLinear(){
-    return FUNCTION_LINEAR.equals(function);
-  }
-
-  public boolean isLinearWithThreshold(){
-    return FUNCTION_LINEAR_WITH_THRESHOLD.equals(function);
-  }
-
-  public boolean isLinearWithOffset(){
-    return FUNCTION_LINEAR_WITH_OFFSET.equals(function);
-  }
-
-  @Override
-  public String toString() {
-    return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
-  }
-
-}
diff --git a/sonar-core/src/main/java/org/sonar/core/technicaldebt/DefaultRequirementProperty.java b/sonar-core/src/main/java/org/sonar/core/technicaldebt/DefaultRequirementProperty.java
deleted file mode 100644 (file)
index 0fffa6b..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2013 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.core.technicaldebt;
-
-import org.apache.commons.lang.builder.ToStringBuilder;
-import org.apache.commons.lang.builder.ToStringStyle;
-
-public class DefaultRequirementProperty {
-
-  public static final String PROPERTY_REMEDIATION_FUNCTION = "remediationFunction";
-  public static final String PROPERTY_REMEDIATION_FACTOR = "remediationFactor";
-  public static final String PROPERTY_OFFSET = "offset";
-
-  private String key;
-  private Double value;
-  private String textValue;
-
-  public String key() {
-    return key;
-  }
-
-  public DefaultRequirementProperty setKey(String key) {
-    this.key = key;
-    return this;
-  }
-
-  public Double value() {
-    return value;
-  }
-
-  public DefaultRequirementProperty setValue(Double value) {
-    this.value = value;
-    return this;
-  }
-
-  public String textValue() {
-    return textValue;
-  }
-
-  public DefaultRequirementProperty setTextValue(String textValue) {
-    this.textValue = textValue;
-    return this;
-  }
-
-  @Override
-  public String toString() {
-    return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
-  }
-}
diff --git a/sonar-core/src/main/java/org/sonar/core/technicaldebt/db/CharacteristicDto.java b/sonar-core/src/main/java/org/sonar/core/technicaldebt/db/CharacteristicDto.java
deleted file mode 100644 (file)
index 353d976..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2013 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.core.technicaldebt.db;
-
-import org.sonar.core.technicaldebt.DefaultCharacteristic;
-
-import java.io.Serializable;
-
-public class CharacteristicDto implements Serializable {
-
-  private Long id;
-  private String kee;
-  private String name;
-  private Integer depth;
-  private Integer order;
-
-  public Long getId() {
-    return id;
-  }
-
-  public CharacteristicDto setId(Long id) {
-    this.id = id;
-    return this;
-  }
-
-  public String getKey() {
-    return kee;
-  }
-
-  public CharacteristicDto setKey(String s) {
-    this.kee = s;
-    return this;
-  }
-
-  public String getName() {
-    return name;
-  }
-
-  public CharacteristicDto setName(String s) {
-    this.name = s;
-    return this;
-  }
-
-  public Integer getDepth() {
-    return depth;
-  }
-
-  public CharacteristicDto setDepth(Integer i) {
-    this.depth = i;
-    return this;
-  }
-
-  public int getOrder() {
-    return order;
-  }
-
-  public CharacteristicDto setOrder(Integer i) {
-    this.order = i;
-    return this;
-  }
-
-  public DefaultCharacteristic toDefaultCharacteristic() {
-    return new DefaultCharacteristic()
-      .setKey(kee)
-      .setName(name);
-  }
-
-}
diff --git a/sonar-core/src/main/java/org/sonar/core/technicaldebt/db/CharacteristicMapper.java b/sonar-core/src/main/java/org/sonar/core/technicaldebt/db/CharacteristicMapper.java
deleted file mode 100644 (file)
index 7e9fcd7..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2013 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.core.technicaldebt.db;
-
-public interface CharacteristicMapper {
-
-
-}
diff --git a/sonar-core/src/main/java/org/sonar/core/technicaldebt/db/RequirementDao.java b/sonar-core/src/main/java/org/sonar/core/technicaldebt/db/RequirementDao.java
deleted file mode 100644 (file)
index c377824..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2013 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.core.technicaldebt.db;
-
-import org.apache.ibatis.session.SqlSession;
-import org.sonar.api.ServerComponent;
-import org.sonar.core.persistence.MyBatis;
-
-import javax.annotation.CheckForNull;
-
-public class RequirementDao implements ServerComponent {
-
-  private final MyBatis mybatis;
-
-  public RequirementDao(MyBatis mybatis) {
-    this.mybatis = mybatis;
-  }
-
-  @CheckForNull
-  public RequirementDto selectByRuleId(long ruleId) {
-    SqlSession session = mybatis.openSession();
-    RequirementMapper mapper = session.getMapper(RequirementMapper.class);
-    try {
-      return mapper.selectByRuleId(ruleId);
-    } finally {
-      MyBatis.closeQuietly(session);
-    }
-  }
-
-}
diff --git a/sonar-core/src/main/java/org/sonar/core/technicaldebt/db/RequirementDto.java b/sonar-core/src/main/java/org/sonar/core/technicaldebt/db/RequirementDto.java
deleted file mode 100644 (file)
index 09ed625..0000000
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2013 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.core.technicaldebt.db;
-
-import org.sonar.api.rule.RuleKey;
-import org.sonar.core.rule.RuleDto;
-import org.sonar.core.technicaldebt.DefaultRequirement;
-
-import java.util.List;
-
-public class RequirementDto {
-
-  private Long id;
-  private RuleDto rule;
-  private List<RequirementPropertyDto> properties;
-  private CharacteristicDto characteristic;
-  private CharacteristicDto rootCharacteristic;
-
-  public Long getId() {
-    return id;
-  }
-
-  public RequirementDto setId(Long id) {
-    this.id = id;
-    return this;
-  }
-
-  public RuleDto getRule() {
-    return rule;
-  }
-
-  public RequirementDto setRule(RuleDto rule) {
-    this.rule = rule;
-    return this;
-  }
-
-  public CharacteristicDto getRootCharacteristic() {
-    return rootCharacteristic;
-  }
-
-  public RequirementDto setRootCharacteristic(CharacteristicDto rootCharacteristic) {
-    this.rootCharacteristic = rootCharacteristic;
-    return this;
-  }
-
-  public CharacteristicDto getCharacteristic() {
-    return characteristic;
-  }
-
-  public RequirementDto setCharacteristic(CharacteristicDto characteristic) {
-    this.characteristic = characteristic;
-
-    return this;
-  }
-
-  public List<RequirementPropertyDto> getProperties() {
-    return properties;
-  }
-
-  public RequirementDto setProperties(List<RequirementPropertyDto> properties) {
-    this.properties = properties;
-    return this;
-  }
-
-  public DefaultRequirement toDefaultRequirement() {
-    DefaultRequirement requirement = new DefaultRequirement()
-      .setRuleKey(RuleKey.of(rule.getRepositoryKey(), rule.getRuleKey()))
-      .setCharacteristic(characteristic.toDefaultCharacteristic())
-      .setRootCharacteristic(rootCharacteristic.toDefaultCharacteristic());
-    for (RequirementPropertyDto property : properties) {
-      requirement.addProperty(property.toDefaultRequirementProperty());
-    }
-    return requirement;
-  }
-}
diff --git a/sonar-core/src/main/java/org/sonar/core/technicaldebt/db/RequirementMapper.java b/sonar-core/src/main/java/org/sonar/core/technicaldebt/db/RequirementMapper.java
deleted file mode 100644 (file)
index d1f02e5..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2013 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.core.technicaldebt.db;
-
-import org.apache.ibatis.annotations.Param;
-
-public interface RequirementMapper {
-
-  RequirementDto selectByRuleId(@Param("ruleId") Long ruleId);
-
-}
diff --git a/sonar-core/src/main/java/org/sonar/core/technicaldebt/db/RequirementPropertyDto.java b/sonar-core/src/main/java/org/sonar/core/technicaldebt/db/RequirementPropertyDto.java
deleted file mode 100644 (file)
index bd801b6..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2013 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.core.technicaldebt.db;
-
-import org.sonar.core.technicaldebt.DefaultRequirementProperty;
-
-import java.io.Serializable;
-
-public class RequirementPropertyDto implements Serializable {
-
-  private Long id;
-  private String kee;
-  private Double value;
-  private String textValue;
-
-  public Long getId() {
-    return id;
-  }
-
-  public RequirementPropertyDto setId(Long id) {
-    this.id = id;
-    return this;
-  }
-
-  public String getKey() {
-    return kee;
-  }
-
-  public RequirementPropertyDto setKey(String key) {
-    this.kee = key;
-    return this;
-  }
-
-  public Double getValue() {
-    return value;
-  }
-
-  public RequirementPropertyDto setValue(Double value) {
-    this.value = value;
-    return this;
-  }
-
-  public String getTextValue() {
-    return textValue;
-  }
-
-  public RequirementPropertyDto setTextValue(String textValue) {
-    this.textValue = textValue;
-    return this;
-  }
-
-  public DefaultRequirementProperty toDefaultRequirementProperty() {
-    return new DefaultRequirementProperty()
-      .setKey(kee)
-      .setTextValue(textValue)
-      .setValue(value);
-  }
-
-}
diff --git a/sonar-core/src/main/java/org/sonar/core/technicaldebt/db/RequirementPropertyMapper.java b/sonar-core/src/main/java/org/sonar/core/technicaldebt/db/RequirementPropertyMapper.java
deleted file mode 100644 (file)
index 64b613b..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2013 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.core.technicaldebt.db;
-
-public interface RequirementPropertyMapper {
-
-
-}
diff --git a/sonar-core/src/main/java/org/sonar/core/technicaldebt/db/package-info.java b/sonar-core/src/main/java/org/sonar/core/technicaldebt/db/package-info.java
deleted file mode 100644 (file)
index 921c70d..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2013 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.core.technicaldebt.db;
-
-import javax.annotation.ParametersAreNonnullByDefault;
diff --git a/sonar-core/src/main/resources/org/sonar/core/technicaldebt/db/CharacteristicMapper.xml b/sonar-core/src/main/resources/org/sonar/core/technicaldebt/db/CharacteristicMapper.xml
deleted file mode 100644 (file)
index 0cf8652..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-
-<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mappei.dtd">
-
-<mapper namespace="org.sonar.core.technicaldebt.db.CharacteristicMapper">
-
-  <sql id="characteristicColumns">
-    c.id,
-    c.kee as kee,
-    c.name as name,
-    c.depth as depth,
-    c.order as order
-  </sql>
-
-</mapper>
-
diff --git a/sonar-core/src/main/resources/org/sonar/core/technicaldebt/db/RequirementMapper.xml b/sonar-core/src/main/resources/org/sonar/core/technicaldebt/db/RequirementMapper.xml
deleted file mode 100644 (file)
index 2560573..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-
-<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mappei.dtd">
-
-<mapper namespace="org.sonar.core.technicaldebt.db.RequirementMapper">
-
-  <select id="selectByRuleId" parameterType="int" resultMap="requirementResult">
-    select
-    req.id as id,
-    req.rule_id as rule_id,
-    req_rule.id as rule_id,
-    req_rule.plugin_rule_key as rule_key,
-    req_rule.plugin_name as rule_repository_key,
-    req_rule.name as rule_name,
-    prop.id as prop_id,
-    prop.kee as prop_kee,
-    prop.value as prop_value,
-    prop.text_value as prop_textValue,
-    root_char.id as root_char_id,
-    root_char.kee as root_char_kee,
-    root_char.name as root_char_name,
-    characteristic.id as char_id,
-    characteristic.kee as char_kee,
-    characteristic.name as char_name
-    from characteristics req
-    inner join quality_models on quality_models.id = req.quality_model_id and quality_models.name = 'SQALE'
-    inner join rules req_rule on req_rule.id = req.rule_id
-    inner join characteristic_properties prop on prop.characteristic_id = req.id
-    inner join characteristic_edges req_to_char on req_to_char.child_id = req.id
-    inner join characteristics characteristic on characteristic.id = req_to_char.parent_id and characteristic.enabled = ${_true}
-    inner join characteristic_edges char_to_root_char on char_to_root_char.child_id = characteristic.id
-    inner join characteristics root_char on root_char.id = char_to_root_char.parent_id and root_char.enabled = ${_true}
-    <where>
-      req.rule_id = #{ruleId}
-      and req.enabled = ${_true}
-    </where>
-  </select>
-
-  <resultMap id="requirementResult" type="Requirement">
-    <id property="id" column="id"/>
-
-    <association property="rule" javaType="Rule">
-      <id property="id" column="rule_id"/>
-      <result property="ruleKey" column="rule_key"/>
-      <result property="repositoryKey" column="rule_repository_key"/>
-      <result property="name" column="rule_name"/>
-    </association>
-
-    <association property="characteristic" javaType="Characteristic">
-      <id property="id" column="char_id"/>
-      <result property="key" column="char_kee"/>
-      <result property="name" column="char_name"/>
-    </association>
-
-    <association property="rootCharacteristic" javaType="Characteristic">
-      <id property="id" column="root_char_id"/>
-      <result property="key" column="root_char_kee"/>
-      <result property="name" column="root_char_name"/>
-    </association>
-
-    <collection property="properties" ofType="RequirementProperty">
-      <id property="id" column="prop_id"/>
-      <result property="key" column="prop_kee"/>
-      <result property="value" column="prop_value"/>
-      <result property="textValue" column="prop_textValue"/>
-    </collection>
-  </resultMap>
-
-</mapper>
-
diff --git a/sonar-core/src/main/resources/org/sonar/core/technicaldebt/db/RequirementPropertyMapper.xml b/sonar-core/src/main/resources/org/sonar/core/technicaldebt/db/RequirementPropertyMapper.xml
deleted file mode 100644 (file)
index 694647b..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-
-<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mappei.dtd">
-
-<mapper namespace="org.sonar.core.technicaldebt.db.RequirementPropertyMapper">
-
-  <sql id="requirementPropertyColumns">
-    p.id,
-    p.kee as kee,
-    p.value as value,
-    p.textValue as textValue
-  </sql>
-
-</mapper>
-
diff --git a/sonar-core/src/test/java/org/sonar/core/technicaldebt/DefaultRequirementTest.java b/sonar-core/src/test/java/org/sonar/core/technicaldebt/DefaultRequirementTest.java
deleted file mode 100644 (file)
index 3dcc271..0000000
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2013 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.core.technicaldebt;
-
-import org.junit.Test;
-
-import static org.fest.assertions.Assertions.assertThat;
-import static org.fest.assertions.Fail.fail;
-
-public class DefaultRequirementTest {
-
-  @Test
-  public void add_factor_property() {
-    DefaultRequirementProperty property = new DefaultRequirementProperty()
-      .setKey("remediationFactor")
-      .setValue(30d)
-      .setTextValue("mn");
-
-    DefaultRequirement requirement = new DefaultRequirement();
-    requirement.addProperty(property);
-
-    assertThat(requirement.factor()).isNotNull();
-    assertThat(requirement.factor().getUnit()).isEqualTo("mn");
-    assertThat(requirement.factor().getValue()).isEqualTo(30d);
-  }
-
-  @Test
-  public void add_offset_property() {
-    DefaultRequirementProperty property = new DefaultRequirementProperty()
-      .setKey("offset")
-      .setValue(30d)
-      .setTextValue("mn");
-
-    DefaultRequirement requirement = new DefaultRequirement();
-    requirement.addProperty(property);
-
-    assertThat(requirement.offset()).isNotNull();
-    assertThat(requirement.offset().getValue()).isEqualTo(30d);
-    assertThat(requirement.offset().getUnit()).isEqualTo("mn");
-  }
-
-  @Test
-  public void add_linear_function_property() {
-    DefaultRequirementProperty property = new DefaultRequirementProperty()
-      .setKey("remediationFunction")
-      .setTextValue("linear");
-
-    DefaultRequirement requirement = new DefaultRequirement();
-    requirement.addProperty(property);
-
-    assertThat(requirement.function()).isEqualTo("linear");
-  }
-
-  @Test
-  public void add_constant_function_property() {
-    DefaultRequirementProperty property = new DefaultRequirementProperty()
-      .setKey("remediationFunction")
-      .setTextValue("constant_resource");
-
-    DefaultRequirement requirement = new DefaultRequirement();
-    requirement.addProperty(property);
-
-    assertThat(requirement.function()).isEqualTo("constant_resource");
-    assertThat(requirement.factor()).isNull();
-    assertThat(requirement.offset()).isNull();
-  }
-
-  @Test
-  public void fail_on_invalid_function() {
-    DefaultRequirementProperty property = new DefaultRequirementProperty()
-      .setKey("remediationFunction")
-      .setTextValue("unknown");
-
-    DefaultRequirement requirement = new DefaultRequirement();
-    try {
-      requirement.addProperty(property);
-      fail();
-    } catch (Exception e) {
-      assertThat(e).isInstanceOf(IllegalArgumentException.class).hasMessage("Function is not valid. Should be one of : [constant_resource, linear, linear_offset, linear_threshold]");
-    }
-  }
-
-  @Test
-  public void fail_on_invalid_property_key() {
-    DefaultRequirementProperty property = new DefaultRequirementProperty()
-      .setKey("unknown");
-
-    DefaultRequirement requirement = new DefaultRequirement();
-    try {
-      requirement.addProperty(property);
-      fail();
-    } catch (Exception e) {
-      assertThat(e).isInstanceOf(IllegalArgumentException.class).hasMessage("Property key is not found");
-    }
-  }
-
-}
diff --git a/sonar-core/src/test/java/org/sonar/core/technicaldebt/db/CharacteristicDtoTest.java b/sonar-core/src/test/java/org/sonar/core/technicaldebt/db/CharacteristicDtoTest.java
deleted file mode 100644 (file)
index 0bb8f24..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2013 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.core.technicaldebt.db;
-
-import org.junit.Test;
-import org.sonar.core.technicaldebt.DefaultCharacteristic;
-
-import static org.fest.assertions.Assertions.assertThat;
-
-public class CharacteristicDtoTest {
-
-  @Test
-  public void to_default_characteristic(){
-    CharacteristicDto characteristicDto = new CharacteristicDto()
-      .setKey("COMPILER_RELATED_PORTABILITY")
-      .setName("Compiler");
-
-    DefaultCharacteristic defaultCharacteristic = characteristicDto.toDefaultCharacteristic();
-    assertThat(defaultCharacteristic.key()).isEqualTo("COMPILER_RELATED_PORTABILITY");
-    assertThat(defaultCharacteristic.name()).isEqualTo("Compiler");
-  }
-}
diff --git a/sonar-core/src/test/java/org/sonar/core/technicaldebt/db/RequirementDaoTest.java b/sonar-core/src/test/java/org/sonar/core/technicaldebt/db/RequirementDaoTest.java
deleted file mode 100644 (file)
index aa05277..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2013 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.core.technicaldebt.db;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.sonar.core.persistence.AbstractDaoTestCase;
-
-import static org.fest.assertions.Assertions.assertThat;
-
-public class RequirementDaoTest extends AbstractDaoTestCase {
-
-  RequirementDao dao;
-
-  @Before
-  public void createDao() {
-    dao = new RequirementDao(getMyBatis());
-  }
-
-  @Test
-  public void select_requirement_from_rule() {
-    setupData("select_requirement_from_rule");
-
-    RequirementDto requirementDto = dao.selectByRuleId(1L);
-
-    assertThat(requirementDto).isNotNull();
-    assertThat(requirementDto.getId()).isEqualTo(2);
-
-    assertThat(requirementDto.getRule().getId()).isEqualTo(1);
-    assertThat(requirementDto.getRule().getRepositoryKey()).isEqualTo("checkstyle");
-    assertThat(requirementDto.getRule().getRuleKey()).isEqualTo("import");
-    assertThat(requirementDto.getRule().getName()).isEqualTo("Regular exp");
-
-    assertThat(requirementDto.getRootCharacteristic().getId()).isEqualTo(3);
-    assertThat(requirementDto.getRootCharacteristic().getKey()).isEqualTo("PORTABILITY");
-
-    assertThat(requirementDto.getCharacteristic().getId()).isEqualTo(1);
-    assertThat(requirementDto.getCharacteristic().getKey()).isEqualTo("COMPILER_RELATED_PORTABILITY");
-
-    assertThat(requirementDto.getProperties()).hasSize(1);
-    RequirementPropertyDto prop = requirementDto.getProperties().get(0);
-    assertThat(prop.getId()).isEqualTo(1);
-    assertThat(prop.getKey()).isEqualTo("remediationFactor");
-    assertThat(prop.getValue()).isEqualTo(30d);
-    assertThat(prop.getTextValue()).isEqualTo("mn");
-  }
-
-  @Test
-  public void select_requirement_from_rule_with_two_properties(){
-    setupData("select_requirement_from_rule_with_two_properties");
-
-    RequirementDto requirementDto = dao.selectByRuleId(1L);
-
-    assertThat(requirementDto.getProperties()).hasSize(2);
-  }
-
-  @Test
-  public void return_null_on_unknown_rule(){
-    setupData("select_requirement_from_rule");
-
-    RequirementDto requirementDto = dao.selectByRuleId(999L);
-
-    assertThat(requirementDto).isNull();
-  }
-
-
-}
diff --git a/sonar-core/src/test/java/org/sonar/core/technicaldebt/db/RequirementDtoTest.java b/sonar-core/src/test/java/org/sonar/core/technicaldebt/db/RequirementDtoTest.java
deleted file mode 100644 (file)
index 6b332bf..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2013 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.core.technicaldebt.db;
-
-import org.junit.Test;
-import org.sonar.core.rule.RuleDto;
-import org.sonar.core.technicaldebt.DefaultRequirement;
-
-import static com.google.common.collect.Lists.newArrayList;
-import static org.fest.assertions.Assertions.assertThat;
-
-public class RequirementDtoTest {
-
-  @Test
-  public void to_default_requirement(){
-    RuleDto ruleDto = new RuleDto();
-    ruleDto.setRepositoryKey("squid");
-    ruleDto.setRuleKey("AvoidCycle");
-    CharacteristicDto characteristicDto = new CharacteristicDto();
-    CharacteristicDto rootCharacteristicDto = new CharacteristicDto();
-
-    RequirementPropertyDto requirementPropertyDto1 = new RequirementPropertyDto()
-      .setKey("remediationFactor")
-      .setValue(30d)
-      .setTextValue("mn");
-    RequirementPropertyDto requirementPropertyDto2 = new RequirementPropertyDto()
-      .setKey("remediationFunction")
-      .setTextValue("linear");
-
-    RequirementDto dto = new RequirementDto()
-      .setId(1L)
-      .setRule(ruleDto)
-      .setCharacteristic(characteristicDto)
-      .setRootCharacteristic(rootCharacteristicDto)
-      .setProperties(newArrayList(requirementPropertyDto1, requirementPropertyDto2));
-
-    DefaultRequirement result = dto.toDefaultRequirement();
-    assertThat(result).isNotNull();
-    assertThat(result.ruleKey()).isNotNull();
-    assertThat(result.characteristic()).isNotNull();
-    assertThat(result.rootCharacteristic()).isNotNull();
-    assertThat(result.function()).isNotNull();
-    assertThat(result.factor()).isNotNull();
-  }
-}
diff --git a/sonar-core/src/test/resources/org/sonar/core/technicaldebt/db/RequirementDaoTest/select_requirement_from_rule.xml b/sonar-core/src/test/resources/org/sonar/core/technicaldebt/db/RequirementDaoTest/select_requirement_from_rule.xml
deleted file mode 100644 (file)
index 57c6ceb..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-<dataset>
-
-  <quality_models id="1" name="SQALE"/>
-
-  <characteristics id="1" kee="COMPILER_RELATED_PORTABILITY" name="Compiler related portability" quality_model_id="1" rule_id="[null]" characteristic_order="1" depth="2"
-                   description="[null]" enabled="[true]"/>
-
-  <!-- requirement -->
-  <characteristics id="2" kee="[null]" name="[null]" quality_model_id="1" rule_id="1" characteristic_order="6" depth="3"
-                   description="[null]" enabled="[true]"/>
-
-  <characteristics id="3" kee="PORTABILITY" name="Portability" quality_model_id="1" rule_id="[null]" characteristic_order="2" depth="1" description="[null]" enabled="[true]"/>
-
-  <characteristic_edges child_id="1" parent_id="3"/>
-  <characteristic_edges child_id="2" parent_id="1"/>
-
-  <characteristic_properties id="1" characteristic_id="2" kee="remediationFactor" value="30.0" text_value="mn"/>
-
-  <rules id="1" plugin_rule_key="import" plugin_config_key="regexp" plugin_name="checkstyle" description="[null]" priority="3" status="READY" cardinality="SINGLE" parent_id="[null]" name="Regular exp"/>
-
-</dataset>
diff --git a/sonar-core/src/test/resources/org/sonar/core/technicaldebt/db/RequirementDaoTest/select_requirement_from_rule_with_two_properties.xml b/sonar-core/src/test/resources/org/sonar/core/technicaldebt/db/RequirementDaoTest/select_requirement_from_rule_with_two_properties.xml
deleted file mode 100644 (file)
index 643090b..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-<dataset>
-
-  <quality_models id="1" name="SQALE"/>
-
-  <characteristics id="1" kee="COMPILER_RELATED_PORTABILITY" name="Compiler related portability" quality_model_id="1" rule_id="[null]" characteristic_order="1" depth="2"
-                   description="[null]" enabled="[true]"/>
-
-  <!-- requirement -->
-  <characteristics id="2" kee="[null]" name="[null]" quality_model_id="1" rule_id="1" characteristic_order="6" depth="3"
-                   description="[null]" enabled="[true]"/>
-
-  <characteristics id="3" kee="PORTABILITY" name="Portability" quality_model_id="1" rule_id="[null]" characteristic_order="2" depth="1" description="[null]" enabled="[true]"/>
-
-  <characteristic_edges child_id="1" parent_id="3"/>
-  <characteristic_edges child_id="2" parent_id="1"/>
-
-  <characteristic_properties id="1" characteristic_id="2" kee="remediationFactor" value="30.0" text_value="mn"/>
-  <characteristic_properties id="2" characteristic_id="2" kee="remediationFunction" value="[null]" text_value="linear"/>
-
-  <rules id="1" plugin_rule_key="import" plugin_config_key="regexp" plugin_name="checkstyle" description="[null]" priority="3" status="READY" cardinality="SINGLE" parent_id="[null]" name="Regular exp"/>
-
-</dataset>
index 5de10e1e6e851df4e6a7892edff76b940e48f202..9658cf0aaa826cd4b2b9b324e23f485cad5a1038 100644 (file)
@@ -93,7 +93,6 @@ import org.sonar.server.rule.RubyRuleService;
 import org.sonar.server.rules.ProfilesConsole;
 import org.sonar.server.rules.RulesConsole;
 import org.sonar.server.startup.*;
-import org.sonar.server.technicaldebt.RubyTechnicalDebtService;
 import org.sonar.server.text.MacroInterpreter;
 import org.sonar.server.text.RubyTextService;
 import org.sonar.server.ui.*;
@@ -302,7 +301,6 @@ public final class Platform {
     servicesContainer.addSingleton(TechnicalDebtModelRepository.class);
     servicesContainer.addSingleton(TechnicalDebtXMLImporter.class);
     servicesContainer.addSingleton(TechnicalDebtConverter.class);
-    servicesContainer.addSingleton(RubyTechnicalDebtService.class);
 
     // text
     servicesContainer.addSingleton(MacroInterpreter.class);
diff --git a/sonar-server/src/main/java/org/sonar/server/technicaldebt/RubyTechnicalDebtService.java b/sonar-server/src/main/java/org/sonar/server/technicaldebt/RubyTechnicalDebtService.java
deleted file mode 100644 (file)
index 1509fad..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2013 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.server.technicaldebt;
-
-import org.sonar.api.ServerComponent;
-import org.sonar.api.rule.RuleKey;
-import org.sonar.api.rules.Rule;
-import org.sonar.api.rules.RuleFinder;
-import org.sonar.core.technicaldebt.DefaultRequirement;
-import org.sonar.core.technicaldebt.db.RequirementDao;
-import org.sonar.core.technicaldebt.db.RequirementDto;
-import org.sonar.server.exceptions.BadRequestException;
-
-import javax.annotation.CheckForNull;
-
-public class RubyTechnicalDebtService implements ServerComponent {
-
-  private final RequirementDao requirementDao;
-  private final RuleFinder rulefinder;
-
-  public RubyTechnicalDebtService(RequirementDao requirementDao, RuleFinder rulefinder) {
-    this.requirementDao = requirementDao;
-    this.rulefinder = rulefinder;
-  }
-
-  @CheckForNull
-  public DefaultRequirement requirement(RuleKey ruleKey) {
-    Rule rule = rulefinder.findByKey(ruleKey);
-    if (rule == null) {
-      throw new BadRequestException("Unknown rule: " + ruleKey);
-    }
-
-    RequirementDto dto = requirementDao.selectByRuleId(rule.getId());
-    return dto != null ? dto.toDefaultRequirement() : null;
-  }
-
-}
diff --git a/sonar-server/src/main/java/org/sonar/server/technicaldebt/package-info.java b/sonar-server/src/main/java/org/sonar/server/technicaldebt/package-info.java
deleted file mode 100644 (file)
index 1b1dff8..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2013 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.server.technicaldebt;
-
-import javax.annotation.ParametersAreNonnullByDefault;
-
index 24da16c16ffb154bedf8f2c60c15da5a9f71567a..5353b87f535b39237880e32cfb0022712f84a9b0 100644 (file)
@@ -206,7 +206,12 @@ class IssueController < ApplicationController
     require_parameters :id
     @issue_results = Api.issues.find(params[:id])
     @issue = @issue_results.first()
-    @requirement = Internal.technical_debt.requirement(@issue.ruleKey)
+
+    rule_id = @issue_results.rule(@issue).id
+    @requirement = Characteristic.first(
+        :conditions => ['quality_models.name=? AND characteristics.rule_id=? AND characteristics.enabled=?', 'SQALE', rule_id, true],
+        :include => [:quality_model, {:parents => :parents}, :characteristic_properties]
+    )
     render :partial => 'issue/technicaldebt'
   end
 
index 252d269021f3099bde028635f602c5f55f7a1658..acfa831fc8ea4e94289458bd9b00d468018db965 100644 (file)
@@ -97,4 +97,20 @@ class Characteristic < ActiveRecord::Base
       default_value
     end
   end
+
+
+  ### For Requirement
+
+  def function
+    property(CharacteristicProperty::PROPERTY_REMEDIATION_FUNCTION)
+  end
+
+  def factor
+    property(CharacteristicProperty::PROPERTY_REMEDIATION_FACTOR)
+  end
+
+  def offset
+    property(CharacteristicProperty::PROPERTY_OFFSET)
+  end
+
 end
index fbc729be87eaeec8acbbd980bab9bdef788152e4..fae9b0c2d6991793cf382560eb19fed3184b21aa 100644 (file)
 class CharacteristicProperty < ActiveRecord::Base
   KEY_MAX_SIZE=100
 
+  PROPERTY_REMEDIATION_FUNCTION = "remediationFunction";
+  PROPERTY_REMEDIATION_FACTOR = "remediationFactor";
+  PROPERTY_OFFSET = "offset";
+
+  FUNCTION_CONSTANT = "constant_resource";
+  FUNCTION_LINEAR = "linear";
+  FUNCTION_LINEAR_WITH_OFFSET = "linear_offset";
+  FUNCTION_LINEAR_WITH_THRESHOLD = "linear_threshold";
+
+  DAY = "d"
+  HOUR = "h"
+  MINUTE = "mn"
+
   belongs_to :characteristic
   validates_length_of :kee, :in => 1..KEY_MAX_SIZE, :allow_blank => false
   
@@ -27,4 +40,20 @@ class CharacteristicProperty < ActiveRecord::Base
     kee
   end
 
-end
\ No newline at end of file
+  def constant?
+    text_value == FUNCTION_CONSTANT
+  end
+
+  def linear?
+    text_value == FUNCTION_LINEAR
+  end
+
+  def linearWithThreshold?
+    text_value == FUNCTION_LINEAR_WITH_THRESHOLD
+  end
+
+  def linearWithOffset?
+    text_value == FUNCTION_LINEAR_WITH_OFFSET
+  end
+
+end
index d1428ef731d3a44d6d4763a9bc84c44e2f4bb5a4..7070f829c6e4dc33f45031ba1102f406b9700ea2 100644 (file)
@@ -54,12 +54,11 @@ class Internal
     component(Java::OrgSonarServerPermission::InternalPermissionTemplateService.java_class)
   end
 
-  def self.technical_debt
-    component(Java::OrgSonarServerTechnicaldebt::RubyTechnicalDebtService.java_class)
-  end
 
   private
+
   def self.component(component_java_class)
     Java::OrgSonarServerPlatform::Platform.component(component_java_class)
   end
+
 end
index 61634c7321a7ceb7c4d5d31ab48dfd1d96dd8ba8..f717d8e21bc51bfa61c682a528cd654727de9eeb 100644 (file)
@@ -1,18 +1,20 @@
-<div class="<%= @requirement.isLinear() ? '' : 'marginbottom10' %>">
-  <% if @requirement.isConstant() %>
+<% function = @requirement.function %>
+
+<div class="<%= function.linear? ? '' : 'marginbottom10' %>">
+  <% if function.constant? %>
     <%= message('issue.technical_debt.constant_resource') -%>
-  <% elsif @requirement.isLinearWithThreshold() or @requirement.isLinearWithOffset() %>
+  <% elsif function.linearWithThreshold? or function.linearWithOffset? %>
     <%
-       case @requirement.offset.unit
-         when 'd'
-           value = message('issue.technical_debt.x_days', :params => @requirement.factor.value)
-         when 'h'
-           value = message('issue.technical_debt.x_hours', :params => @requirement.factor.value)
-         when 'mn'
-           value = message('issue.technical_debt.x_minutes', :params => @requirement.factor.value)
+       case @requirement.offset.text_value
+         when CharacteristicProperty::DAY
+           value = message('issue.technical_debt.x_days', :params => @requirement.offset.value)
+         when CharacteristicProperty::HOUR
+           value = message('issue.technical_debt.x_hours', :params => @requirement.offset.value)
+         when CharacteristicProperty::MINUTE
+           value = message('issue.technical_debt.x_minutes', :params => @requirement.offset.value)
        end
     %>
-    <% if @requirement.isLinearWithThreshold() %>
+    <% if function.linearWithThreshold? %>
       <%= message('issue.technical_debt.linear_threshold', :params => value) -%>
     <% else %>
       <%= message('issue.technical_debt.linear_offset', :params => value) -%>
@@ -21,5 +23,5 @@
 </div>
 
 <div class="note">
-  <%= @requirement.rootCharacteristic.name %>&nbsp;&gt;&nbsp;<%= @requirement.characteristic.name %>
+  <%= @requirement.parent.parent.name %>&nbsp;&gt;&nbsp;<%= @requirement.parent.name %>
 </div>
diff --git a/sonar-server/src/test/java/org/sonar/server/technicaldebt/RubyTechnicalDebtServiceTest.java b/sonar-server/src/test/java/org/sonar/server/technicaldebt/RubyTechnicalDebtServiceTest.java
deleted file mode 100644 (file)
index abe8b26..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2013 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.server.technicaldebt;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.runners.MockitoJUnitRunner;
-import org.sonar.api.rule.RuleKey;
-import org.sonar.api.rules.Rule;
-import org.sonar.api.rules.RuleFinder;
-import org.sonar.core.technicaldebt.DefaultRequirement;
-import org.sonar.core.technicaldebt.db.RequirementDao;
-import org.sonar.core.technicaldebt.db.RequirementDto;
-import org.sonar.server.exceptions.BadRequestException;
-
-import static org.fest.assertions.Assertions.assertThat;
-import static org.fest.assertions.Fail.fail;
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-@RunWith(MockitoJUnitRunner.class)
-public class RubyTechnicalDebtServiceTest {
-
-
-  private RubyTechnicalDebtService service;
-
-  @Mock
-  private RequirementDao requirementDao;
-
-  @Mock
-  private RuleFinder rulefinder;
-
-  @Before
-  public void before() {
-    service = new RubyTechnicalDebtService(requirementDao, rulefinder);
-  }
-
-  @Test
-  public void return_requirement() {
-    RuleKey ruleKey = RuleKey.of("squid", "AvoidCycle");
-    Rule rule = Rule.create("squid", "AvoidCycle");
-    rule.setId(1);
-    when(rulefinder.findByKey(ruleKey)).thenReturn(rule);
-
-    DefaultRequirement defaultRequirement = mock(DefaultRequirement.class);
-    RequirementDto requirement = mock(RequirementDto.class);
-    when(requirement.toDefaultRequirement()).thenReturn(defaultRequirement);
-    when(requirementDao.selectByRuleId(1)).thenReturn(requirement);
-
-    DefaultRequirement result = service.requirement(ruleKey);
-    assertThat(result).isEqualTo(defaultRequirement);
-  }
-
-  @Test
-  public void return_null_requirement_if_rule_does_not_exists() {
-    when(rulefinder.findByKey(any(RuleKey.class))).thenReturn(null);
-
-    RequirementDto requirement = new RequirementDto();
-    when(requirementDao.selectByRuleId(1)).thenReturn(requirement);
-
-    try {
-      service.requirement(RuleKey.of("squid", "AvoidCycle"));
-      fail();
-    } catch (Exception e) {
-      assertThat(e).isInstanceOf(BadRequestException.class).hasMessage("Unknown rule: squid:AvoidCycle");
-    }
-  }
-
-}