org.sonar.api.database.model
Class MeasureModel

java.lang.Object
  extended by org.sonar.api.database.model.MeasureModel
All Implemented Interfaces:
Cloneable

public class MeasureModel
extends Object
implements Cloneable

This class is the Hibernate model to store a measure in the DB


Field Summary
static int TEXT_VALUE_LENGTH
           
 
Constructor Summary
MeasureModel()
          Creates an empty measure
MeasureModel(Metric metric, Double val)
          Creates a measure based on a metric and a double value
MeasureModel(Metric metric, Metric.Level level)
          Creates a measure based on a metric and an alert level
MeasureModel(Metric metric, String val)
          Creates a measure based on a metric and a string value
 
Method Summary
static MeasureModel build(Measure measure)
          Builds a MeasureModel from a Measure
static MeasureModel build(Measure measure, MeasureModel merge)
          Merges a Measure into a MeasureModel
 Object clone()
           
 Metric.Level getAlertStatus()
           
 String getAlertText()
           
 Characteristic getCharacteristic()
           
 String getData()
           
 String getDescription()
           
 Double getDiffValue1()
           
 Double getDiffValue2()
           
 Double getDiffValue3()
           
 Long getId()
           
 Metric.Level getLevelValue()
           
 MeasureData getMeasureData()
          Use getData() instead
 Date getMeasureDate()
           
 Metric getMetric()
           
 Integer getProjectId()
           
 Rule getRule()
           
 Integer getRuleId()
           
 RulePriority getRulePriority()
           
 Integer getRulesCategoryId()
           
 Integer getSnapshotId()
           
 Integer getTendency()
           
 String getTextValue()
          Use getData() instead
 String getUrl()
           
 Double getValue()
           
 boolean hasOptionalData()
          True if other fields than 'value' are set.
 boolean isRuleMeasure()
           
 MeasureModel save(DatabaseSession session)
          Saves the current object to database
 MeasureModel setAlertStatus(Metric.Level level)
          Sets the measure alert status
 void setAlertText(String alertText)
          Sets the text for the alert
 MeasureModel setCharacteristic(Characteristic c)
           
 void setData(String data)
          Sets the measure data
 void setDescription(String description)
          Sets the measure description
 void setDiffValue1(Double diffValue1)
          Sets the diffValue1
 void setDiffValue2(Double diffValue2)
          Sets the diffValue2
 void setDiffValue3(Double diffValue3)
          Sets the diffValue3
 void setId(Long id)
           
 void setMeasureData(MeasureData data)
          Use setData() instead
 MeasureModel setMeasureDate(Date measureDate)
          Sets the date for the measure
 void setMetric(Metric metric)
          Sets the measure metric
 void setProjectId(Integer projectId)
          Sets the project id
 MeasureModel setRule(Rule rule)
          Sets the rule for the measure
 void setRulePriority(RulePriority rulePriority)
          Sets the rule priority
 MeasureModel setRulesCategoryId(Integer id)
          Sets the rule category id
 MeasureModel setSnapshotId(Integer snapshotId)
          Sets the snapshot id
 MeasureModel setTendency(Integer tendency)
          Sets the measure tendency
 void setTextValue(String textValue)
          Use setData() instead
 void setUrl(String url)
          Sets the measure URL
 MeasureModel setValue(Double value)
          Sets the measure value
 Measure toMeasure()
           
static List<Measure> toMeasures(List<MeasureModel> models)
          Transforms a list of MeasureModel into a list of Measure
 String toString()
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

TEXT_VALUE_LENGTH

public static final int TEXT_VALUE_LENGTH
See Also:
Constant Field Values
Constructor Detail

MeasureModel

public MeasureModel(Metric metric,
                    Double val)
Creates a measure based on a metric and a double value


MeasureModel

public MeasureModel(Metric metric,
                    Metric.Level level)
Creates a measure based on a metric and an alert level


MeasureModel

public MeasureModel(Metric metric,
                    String val)
Creates a measure based on a metric and a string value


MeasureModel

public MeasureModel()
Creates an empty measure

Method Detail

getId

public Long getId()

setId

public void setId(Long id)

getValue

public Double getValue()
Returns:
the measure double value

getDescription

public String getDescription()
Returns:
the measure description

setDescription

public void setDescription(String description)
Sets the measure description


setValue

public MeasureModel setValue(Double value)
                      throws IllegalArgumentException
Sets the measure value

Throws:
IllegalArgumentException - in case value is not a valid double

getLevelValue

public Metric.Level getLevelValue()
Returns:
the measure alert level

getTextValue

public String getTextValue()
Use getData() instead


setTextValue

public void setTextValue(String textValue)
Use setData() instead


getTendency

public Integer getTendency()
Returns:
the measure tendency

isRuleMeasure

public boolean isRuleMeasure()
Returns:
whether the measure is about rule

setTendency

public MeasureModel setTendency(Integer tendency)
Sets the measure tendency

Returns:
the current object

getMetric

public Metric getMetric()
Returns:
the measure metric

setMetric

public void setMetric(Metric metric)
Sets the measure metric


getSnapshotId

public Integer getSnapshotId()
Returns:
the snapshot id the measure is attached to

setSnapshotId

public MeasureModel setSnapshotId(Integer snapshotId)
Sets the snapshot id

Returns:
the current object

getRule

public Rule getRule()
Returns:
the rule

setRule

public MeasureModel setRule(Rule rule)
Sets the rule for the measure

Returns:
the current object

getRulesCategoryId

public Integer getRulesCategoryId()
Returns:
the rule category id

setRulesCategoryId

public MeasureModel setRulesCategoryId(Integer id)
Sets the rule category id

Returns:
the current object

getRulePriority

public RulePriority getRulePriority()
Returns:
the rule priority

setRulePriority

public void setRulePriority(RulePriority rulePriority)
Sets the rule priority


getProjectId

public Integer getProjectId()
Returns:
the project id

setProjectId

public void setProjectId(Integer projectId)
Sets the project id


getMeasureDate

public Date getMeasureDate()
Returns:
the date of the measure

setMeasureDate

public MeasureModel setMeasureDate(Date measureDate)
Sets the date for the measure

Returns:
the current object

getAlertStatus

public Metric.Level getAlertStatus()
Returns:
the alert status if there is one, null otherwise

setAlertStatus

public MeasureModel setAlertStatus(Metric.Level level)
Sets the measure alert status

Returns:
the current object

getData

public String getData()
Returns:
the measure data

setData

public final void setData(String data)
Sets the measure data


getMeasureData

public MeasureData getMeasureData()
Use getData() instead


setMeasureData

public void setMeasureData(MeasureData data)
Use setData() instead


getAlertText

public String getAlertText()
Returns:
the text of the alert

setAlertText

public void setAlertText(String alertText)
Sets the text for the alert


getUrl

public String getUrl()
Returns:
the measure URL

setUrl

public void setUrl(String url)
Sets the measure URL


toString

public String toString()
Overrides:
toString in class Object

getRuleId

public Integer getRuleId()
Returns:
the rule id of the measure

getDiffValue1

public Double getDiffValue1()
Returns:
diffValue1

setDiffValue1

public void setDiffValue1(Double diffValue1)
Sets the diffValue1


getDiffValue2

public Double getDiffValue2()
Returns:
diffValue2

setDiffValue2

public void setDiffValue2(Double diffValue2)
Sets the diffValue2


getDiffValue3

public Double getDiffValue3()
Returns:
diffValue3

setDiffValue3

public void setDiffValue3(Double diffValue3)
Sets the diffValue3


save

public MeasureModel save(DatabaseSession session)
Saves the current object to database

Returns:
the current object

getCharacteristic

public Characteristic getCharacteristic()

setCharacteristic

public MeasureModel setCharacteristic(Characteristic c)

clone

public Object clone()
Overrides:
clone in class Object

hasOptionalData

public boolean hasOptionalData()
True if other fields than 'value' are set.


build

public static MeasureModel build(Measure measure)
Builds a MeasureModel from a Measure


build

public static MeasureModel build(Measure measure,
                                 MeasureModel merge)
Merges a Measure into a MeasureModel


toMeasure

public Measure toMeasure()
Returns:
a measure from the current object

toMeasures

public static List<Measure> toMeasures(List<MeasureModel> models)
Transforms a list of MeasureModel into a list of Measure

Returns:
an empty list if models is null


Copyright © 2009-2010 SonarSource. All Rights Reserved.