org.sonar.api.database.model
Class MeasureModel

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

public class MeasureModel
extends java.lang.Object
implements java.lang.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, java.lang.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, java.lang.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
 java.lang.Object clone()
           
 Metric.Level getAlertStatus()
           
 java.lang.String getAlertText()
           
 java.lang.String getData()
           
 java.lang.String getDescription()
           
 java.lang.Double getDiffValue1()
           
 java.lang.Double getDiffValue2()
           
 java.lang.Double getDiffValue3()
           
 java.lang.Long getId()
           
 Metric.Level getLevelValue()
           
 MeasureData getMeasureData()
          Use getData() instead
 java.util.Date getMeasureDate()
           
 Metric getMetric()
           
 java.lang.Integer getProjectId()
           
 Rule getRule()
           
 java.lang.Integer getRuleId()
           
 RulePriority getRulePriority()
           
 java.lang.Integer getRulesCategoryId()
           
 java.lang.Integer getSnapshotId()
           
 java.lang.Integer getTendency()
           
 java.lang.String getTextValue()
          Use getData() instead
 java.lang.String getUrl()
           
 java.lang.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(java.lang.String alertText)
          Sets the text for the alert
 void setData(java.lang.String data)
          Sets the measure data
 void setDescription(java.lang.String description)
          Sets the measure description
 void setDiffValue1(java.lang.Double diffValue1)
          Sets the diffValue1
 void setDiffValue2(java.lang.Double diffValue2)
          Sets the diffValue2
 void setDiffValue3(java.lang.Double diffValue3)
          Sets the diffValue3
 void setId(java.lang.Long id)
           
 void setMeasureData(MeasureData data)
          Use setData() instead
 MeasureModel setMeasureDate(java.util.Date measureDate)
          Sets the date for the measure
 void setMetric(Metric metric)
          Sets the measure metric
 void setProjectId(java.lang.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(java.lang.Integer id)
          Sets the rule category id
 MeasureModel setSnapshotId(java.lang.Integer snapshotId)
          Sets the snapshot id
 MeasureModel setTendency(java.lang.Integer tendency)
          Sets the measure tendency
 void setTextValue(java.lang.String textValue)
          Use setData() instead
 void setUrl(java.lang.String url)
          Sets the measure URL
 MeasureModel setValue(java.lang.Double value)
          Sets the measure value
 Measure toMeasure()
           
static java.util.List<Measure> toMeasures(java.util.List<MeasureModel> models)
          Transforms a list of MeasureModel into a list of Measure
 java.lang.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,
                    java.lang.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,
                    java.lang.String val)
Creates a measure based on a metric and a string value


MeasureModel

public MeasureModel()
Creates an empty measure

Method Detail

getId

public java.lang.Long getId()

setId

public void setId(java.lang.Long id)

getValue

public java.lang.Double getValue()
Returns:
the measure double value

getDescription

public java.lang.String getDescription()
Returns:
the measure description

setDescription

public void setDescription(java.lang.String description)
Sets the measure description


setValue

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

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

getLevelValue

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

getTextValue

public java.lang.String getTextValue()
Use getData() instead


setTextValue

public void setTextValue(java.lang.String textValue)
Use setData() instead


getTendency

public java.lang.Integer getTendency()
Returns:
the measure tendency

isRuleMeasure

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

setTendency

public MeasureModel setTendency(java.lang.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 java.lang.Integer getSnapshotId()
Returns:
the snapshot id the measure is attached to

setSnapshotId

public MeasureModel setSnapshotId(java.lang.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 java.lang.Integer getRulesCategoryId()
Returns:
the rule category id

setRulesCategoryId

public MeasureModel setRulesCategoryId(java.lang.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 java.lang.Integer getProjectId()
Returns:
the project id

setProjectId

public void setProjectId(java.lang.Integer projectId)
Sets the project id


getMeasureDate

public java.util.Date getMeasureDate()
Returns:
the date of the measure

setMeasureDate

public MeasureModel setMeasureDate(java.util.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 java.lang.String getData()
Returns:
the measure data

setData

public final void setData(java.lang.String data)
Sets the measure data


getMeasureData

public MeasureData getMeasureData()
Use getData() instead


setMeasureData

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


getAlertText

public java.lang.String getAlertText()
Returns:
the text of the alert

setAlertText

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


getUrl

public java.lang.String getUrl()
Returns:
the measure URL

setUrl

public void setUrl(java.lang.String url)
Sets the measure URL


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getRuleId

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

getDiffValue1

public java.lang.Double getDiffValue1()
Returns:
diffValue1

setDiffValue1

public void setDiffValue1(java.lang.Double diffValue1)
Sets the diffValue1


getDiffValue2

public java.lang.Double getDiffValue2()
Returns:
diffValue2

setDiffValue2

public void setDiffValue2(java.lang.Double diffValue2)
Sets the diffValue2


getDiffValue3

public java.lang.Double getDiffValue3()
Returns:
diffValue3

setDiffValue3

public void setDiffValue3(java.lang.Double diffValue3)
Sets the diffValue3


save

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

Returns:
the current object

clone

public java.lang.Object clone()
Overrides:
clone in class java.lang.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 java.util.List<Measure> toMeasures(java.util.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.