params.put("status", Snapshot.STATUS_PROCESSED);
params.put("lib", Qualifiers.LIBRARY);
- sb.append(" AND m.characteristicId IS NULL");
+ sb.append(" AND m.characteristic IS NULL");
sb.append(" AND m.personId IS NULL");
sb.append(" AND m.ruleId IS NULL AND m.rulePriority IS NULL");
if (!metricIds.isEmpty()) {
measure.setVariation4(model.getVariationValue4());
measure.setVariation5(model.getVariationValue5());
measure.setUrl(model.getUrl());
+ measure.setCharacteristic(model.getCharacteristic());
+ measure.setPersonId(model.getPersonId());
return measure;
}
}
model.setVariationValue4(measure.getVariation4());
model.setVariationValue5(measure.getVariation5());
model.setUrl(measure.getUrl());
- if (measure.getCharacteristic()!=null) {
- model.setCharacteristicId(measure.getCharacteristic().getId());
- }
+ model.setCharacteristic(measure.getCharacteristic());
model.setPersonId(measure.getPersonId());
if (measure.getValue() != null) {
model.setValue(measure.getValue().doubleValue());
*/
package org.sonar.api.database.model;
-import com.google.common.base.Preconditions;
import org.apache.commons.lang.builder.ReflectionToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
import org.sonar.api.database.DatabaseSession;
import org.sonar.api.rules.RulePriority;
import javax.persistence.*;
+
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@OneToMany(mappedBy = "measure", fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REMOVE})
private List<MeasureData> measureData = new ArrayList<MeasureData>();
- @Column(name = "characteristic_id", updatable = true, nullable = true)
- private Integer characteristicId;
+ @ManyToOne(fetch = FetchType.EAGER)
+ @JoinColumn(name = "characteristic_id")
+ private Characteristic characteristic;
@Column(name = "person_id", updatable = true, nullable = true)
private Integer personId;
return this;
}
- public Integer getCharacteristicId() {
- return characteristicId;
- }
-
- public MeasureModel setCharacteristicId(Integer i) {
- this.characteristicId = i;
- return this;
- }
-
- /**
- * @deprecated replaced by {@link org.sonar.api.database.model.MeasureModel#getCharacteristicId()} since 3.3. See https://jira.codehaus.org/browse/SONAR-3778
- */
- @Deprecated
public Characteristic getCharacteristic() {
- Characteristic c = null;
- if (characteristicId != null) {
- c = Characteristic.create().setId(characteristicId);
- }
- return c;
+ return characteristic;
}
- /**
- * @deprecated replaced by {@link org.sonar.api.database.model.MeasureModel#setCharacteristicId(Integer)} since 3.3. See https://jira.codehaus.org/browse/SONAR-3778
- */
- @Deprecated
public MeasureModel setCharacteristic(Characteristic c) {
- if (c == null) {
- this.characteristicId = null;
- } else {
- Preconditions.checkArgument(c.getId()!=null, "Characteristic id must not be null");
- this.characteristicId = c.getId();
- }
+ this.characteristic = c;
return this;
}
clone.setSnapshotId(getSnapshotId());
clone.setMeasureDate(getMeasureDate());
clone.setUrl(getUrl());
- clone.setCharacteristicId(getCharacteristicId());
+ clone.setCharacteristic(getCharacteristic());
clone.setPersonId(getPersonId());
return clone;
}