import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
-import javax.persistence.*;
-
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.persistence.FetchType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.OneToMany;
+import javax.persistence.Table;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+import javax.persistence.Transient;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@Column(name = "updated_at", updatable = true, nullable = true)
private Date updatedAt;
+ @Transient
+ private String defaultCharacteristic;
+ @Transient
+ private String defaultSubCharacteristic;
+ @Transient
+ private String characteristic;
+ @Transient
+ private String subCharacteristic;
+
private transient String[] tags = DEFAULT_TAGS;
/**
/**
* For internal use only.
*
+ * @deprecated since 4.4, use {@link #getCharacteristic()}
* @since 4.3
*/
@CheckForNull
+ @Deprecated
public Integer getCharacteristicId() {
return characteristicId;
}
/**
* For internal use only.
*
+ * @deprecated since 4.4, use {@link #setCharacteristic(@Nullable String characteristic)}
* @since 4.3
*/
+ @Deprecated
public Rule setCharacteristicId(@Nullable Integer characteristicId) {
this.characteristicId = characteristicId;
return this;
/**
* For internal use only.
*
+ * @deprecated since 4.4, use {@link #getDefaultCharacteristic()}
* @since 4.3
*/
@CheckForNull
+ @Deprecated
public Integer getDefaultCharacteristicId() {
return defaultCharacteristicId;
}
/**
* For internal use only.
*
+ * @deprecated since 4.4, use {@link #setDefaultCharacteristic(@Nullable String defaultCharacteristic)}
* @since 4.3
*/
+ @Deprecated
public Rule setDefaultCharacteristicId(@Nullable Integer defaultCharacteristicId) {
this.defaultCharacteristicId = defaultCharacteristicId;
return this;
public RuleKey ruleKey() {
return RuleKey.of(getRepositoryKey(), getKey());
}
+
+ /**
+ * @since 4.4
+ */
+ @CheckForNull
+ public String getDefaultCharacteristic() {
+ return defaultCharacteristic;
+ }
+
+ /**
+ * @since 4.4
+ */
+ public Rule setDefaultCharacteristic(@Nullable String defaultCharacteristic) {
+ this.defaultCharacteristic = defaultCharacteristic;
+ return this;
+ }
+
+ /**
+ * @since 4.4
+ */
+ @CheckForNull
+ public String getDefaultSubCharacteristic() {
+ return defaultSubCharacteristic;
+ }
+
+ /**
+ * @since 4.4
+ */
+ public Rule setDefaultSubCharacteristic(@Nullable String defaultSubCharacteristic) {
+ this.defaultSubCharacteristic = defaultSubCharacteristic;
+ return this;
+ }
+
+ /**
+ * @since 4.4
+ */
+ @CheckForNull
+ public String getCharacteristic() {
+ return characteristic;
+ }
+
+ /**
+ * @since 4.4
+ */
+ public Rule setCharacteristic(@Nullable String characteristic) {
+ this.characteristic = characteristic;
+ return this;
+ }
+
+ /**
+ * @since 4.4
+ */
+ @CheckForNull
+ public String getSubCharacteristic() {
+ return subCharacteristic;
+ }
+
+ /**
+ * @since 4.4
+ */
+ public Rule setSubCharacteristic(@Nullable String subCharacteristic) {
+ this.subCharacteristic = subCharacteristic;
+ return this;
+ }
}
import com.google.common.io.Resources;
import org.sonar.api.component.Component;
import org.sonar.api.i18n.I18n;
-import org.sonar.api.issue.*;
+import org.sonar.api.issue.ActionPlan;
+import org.sonar.api.issue.Issue;
+import org.sonar.api.issue.IssueComment;
+import org.sonar.api.issue.IssueFinder;
+import org.sonar.api.issue.IssueQuery;
+import org.sonar.api.issue.IssueQueryResult;
import org.sonar.api.issue.internal.DefaultIssue;
import org.sonar.api.issue.internal.FieldDiffs;
-import org.sonar.api.server.debt.DebtCharacteristic;
-import org.sonar.api.server.debt.internal.DefaultDebtCharacteristic;
import org.sonar.api.server.ws.Request;
import org.sonar.api.server.ws.RequestHandler;
import org.sonar.api.server.ws.Response;
import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
-
import java.util.Arrays;
import java.util.Date;
import java.util.List;
}
private void addCharacteristics(IssueQueryResult result, DefaultIssue issue, JsonWriter json) {
- Integer subCharacteristicId = result.rule(issue).getCharacteristicId() != null ? result.rule(issue).getCharacteristicId() : result.rule(issue).getDefaultCharacteristicId();
- DebtCharacteristic subCharacteristic = characteristicById(subCharacteristicId);
- if (subCharacteristic != null) {
- json.prop("subCharacteristic", subCharacteristic.name());
- DebtCharacteristic characteristic = characteristicById(((DefaultDebtCharacteristic) subCharacteristic).parentId());
- json.prop("characteristic", characteristic != null ? characteristic.name() : null);
- }
- }
+ String subCharacteristic = result.rule(issue).getSubCharacteristic() != null ? result.rule(issue).getSubCharacteristic() : result.rule(issue).getDefaultSubCharacteristic();
+ String characteristic = result.rule(issue).getCharacteristic() != null ? result.rule(issue).getCharacteristic() : result.rule(issue).getDefaultCharacteristic();
- @CheckForNull
- private DebtCharacteristic characteristicById(@Nullable Integer id) {
- if (id != null) {
- return debtModel.characteristicById(id);
+ if (subCharacteristic != null) {
+ json.prop("subCharacteristic", subCharacteristic);
+ json.prop("characteristic", characteristic != null ? characteristic : null);
}
- return null;
}
}