import org.sonar.api.resources.Resource;
import org.sonar.api.resources.Scopes;
import org.sonar.api.technicaldebt.batch.Characteristic;
-import org.sonar.api.technicaldebt.batch.Requirement;
import org.sonar.batch.components.PastMeasuresLoader;
import org.sonar.batch.components.PastSnapshot;
import org.sonar.batch.components.TimeMachineConfiguration;
// compare with past measure
Integer metricId = measure.getMetric().getId() != null ? measure.getMetric().getId() : metricFinder.findByKey(measure.getMetric().getKey()).getId();
Characteristic characteristic = measure.getCharacteristic();
- Requirement requirement = measure.getRequirement();
- Integer characteristicId = characteristic != null ? characteristic.id() : requirement != null ? requirement.id() : null;
+ Integer characteristicId = characteristic != null ? characteristic.id() : null;
Integer personId = measure.getPersonId();
Integer ruleId = measure instanceof RuleMeasure ? ((RuleMeasure) measure).getRule().getId() : null;
import org.sonar.api.rules.Rule;
import org.sonar.api.rules.RuleFinder;
import org.sonar.api.technicaldebt.batch.Characteristic;
-import org.sonar.api.technicaldebt.batch.Requirement;
import org.sonar.api.utils.SonarException;
import org.sonar.core.persistence.MyBatis;
!(ResourceUtils.isEntity(resource) && measure.isBestValue()) && isMeasureNotEmpty(measure);
}
- private static boolean isMeasureNotEmpty(Measure measure){
+ private static boolean isMeasureNotEmpty(Measure measure) {
boolean isNotEmpty = false;
- for (int i = 1; i<=5; i++) {
+ for (int i = 1; i <= 5; i++) {
isNotEmpty = isNotEmpty || measure.getVariation(i) != null;
}
return measure.getValue() != null || measure.getData() != null
model.setVariationValue5(measure.getVariation5());
model.setUrl(measure.getUrl());
Characteristic characteristic = measure.getCharacteristic();
- Requirement requirement = measure.getRequirement();
if (characteristic != null) {
model.setCharacteristicId(characteristic.id());
- } else if (requirement != null) {
- model.setCharacteristicId(requirement.id());
}
model.setPersonId(measure.getPersonId());
Double value = measure.getValue();
if (value != null) {
- model.setValue(value.doubleValue());
+ model.setValue(value);
} else {
model.setValue(null);
}
private static boolean isZeroVariation(Double... variations) {
for (Double variation : variations) {
- if (!((variation == null) || NumberUtils.compare(variation.doubleValue(), 0.0) == 0)) {
+ if (!((variation == null) || NumberUtils.compare(variation, 0.0) == 0)) {
return false;
}
}
if (characteristic != null ? !characteristic.equals(measure.characteristic) : measure.characteristic != null) {
return false;
}
- if (requirement != null ? !requirement.equals(measure.requirement) : measure.requirement != null) {
- return false;
- }
if (personId != null ? !personId.equals(measure.personId) : measure.personId != null) {
return false;
}
public int hashCode() {
int result = metricKey != null ? metricKey.hashCode() : 0;
result = 31 * result + (characteristic != null ? characteristic.hashCode() : 0);
- result = 31 * result + (requirement != null ? requirement.hashCode() : 0);
result = 31 * result + (personId != null ? personId.hashCode() : 0);
return result;
}
measureCharacteristic.equals(characteristic);
}
+ /**
+ * @deprecated since 4.3
+ */
+ @Deprecated
public static MeasuresFilter<Measure> requirement(final Metric metric, final Requirement requirement) {
return new MetricFilter<Measure>(metric) {