org.sonar.plugins.api.jobs
Class JobContextImpl

java.lang.Object
  extended by org.sonar.plugins.api.jobs.JobContextImpl
All Implemented Interfaces:
JobContext

public class JobContextImpl
extends java.lang.Object
implements JobContext


Constructor Summary
JobContextImpl(DatabaseSession session, Snapshot snapshot, DaoFacade dao)
           
 
Method Summary
 Measure addMeasure(Measure measure)
          Adds a measure
 Measure addMeasure(Metric metric, java.lang.Double value)
          Adds a measure for the given metric and numeric value
 Measure addMeasure(Metric metric, java.lang.String value)
          Adds a measure for the given metric and string value
 void clear()
           
 Event createEvent(java.lang.String name, java.lang.String description, java.lang.String category, java.util.Date date)
          Creates an event for a given date
 Event createEventOnCurrentSnapshot(java.lang.String name, java.lang.String description, java.lang.String category)
          Creates an event for the given analysis
 void deleteEvent(Event event)
          Deletes an event
 java.util.List<JobContext> getChildren()
          The list of child job contexts
 java.util.List<Measure> getChildrenMeasures()
          The list of children measures (first child level)
 java.util.List<Measure> getChildrenMeasures(MeasureKey key)
          The list of children measures (first child level) for a given key
 java.util.List<Measure> getChildrenMeasures(Metric metric)
          The list of children measures (first child level) for a given key
 java.util.List<Event> getEvents()
          All events, on projects only
 Measure getMeasure(MeasureKey key)
          Find a measure for the given key
 Measure getMeasure(Metric metric)
          Find a measure for the given metric
 java.util.List<Measure> getMeasures()
          Read-only measures
 java.util.List<Measure> getMeasures(MeasureKey key)
          Finds measures for the given key
 java.util.List<Measure> getMeasures(Metric metric)
          Finds measures for the given metric
 Measure getPastMeasure(Metric metric)
          Find the previous analysis measure for a given metric
 Resource getResource()
          The currently analysed resource
 java.lang.String getResourceVersion()
          The version of the job context resource
 java.util.List<RuleFailure> getRuleFailures()
          Read-only rule failures.
 Snapshot getSnapshot()
           
 java.util.Date getSnapshotDate()
          The snapshot creation date
 boolean isRootProject()
           
 void keepChild(JobContext context)
           
protected  void keepChildren()
           
 java.util.List<JobContextImpl> loadChildren()
           
 java.lang.String toString()
           
 Measure updateMeasure(Measure measure)
          Update a measure
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JobContextImpl

public JobContextImpl(DatabaseSession session,
                      Snapshot snapshot,
                      DaoFacade dao)
Method Detail

loadChildren

public java.util.List<JobContextImpl> loadChildren()

getRuleFailures

public java.util.List<RuleFailure> getRuleFailures()
Description copied from interface: JobContext
Read-only rule failures.

Specified by:
getRuleFailures in interface JobContext
Returns:
the rule failures for file/classes resources, null for the others

addMeasure

public Measure addMeasure(Measure measure)
Description copied from interface: JobContext
Adds a measure

Specified by:
addMeasure in interface JobContext
Parameters:
measure - the measure to add
Returns:
the added measure object

addMeasure

public Measure addMeasure(Metric metric,
                          java.lang.Double value)
Description copied from interface: JobContext
Adds a measure for the given metric and numeric value

Specified by:
addMeasure in interface JobContext
Parameters:
metric - the measure metric
value - the measure value
Returns:
the added measure object

addMeasure

public Measure addMeasure(Metric metric,
                          java.lang.String value)
Description copied from interface: JobContext
Adds a measure for the given metric and string value

Specified by:
addMeasure in interface JobContext
Parameters:
metric - the measure metric
value - the measure value
Returns:
the added measure object

updateMeasure

public Measure updateMeasure(Measure measure)
Description copied from interface: JobContext
Update a measure

Specified by:
updateMeasure in interface JobContext
Parameters:
measure - the measure to update
Returns:
the updated measure

getChildren

public java.util.List<JobContext> getChildren()
Description copied from interface: JobContext
The list of child job contexts

Specified by:
getChildren in interface JobContext
Returns:
the children, or an emtpy list

getSnapshot

public Snapshot getSnapshot()

getMeasures

public java.util.List<Measure> getMeasures()
Description copied from interface: JobContext
Read-only measures

Specified by:
getMeasures in interface JobContext
Returns:
the measures, cannot be null

getChildrenMeasures

public java.util.List<Measure> getChildrenMeasures()
Description copied from interface: JobContext
The list of children measures (first child level)

Specified by:
getChildrenMeasures in interface JobContext
Returns:
the list of measures, or an empty list

getMeasures

public java.util.List<Measure> getMeasures(MeasureKey key)
Description copied from interface: JobContext
Finds measures for the given key

Specified by:
getMeasures in interface JobContext
Parameters:
key - the measure key
Returns:
a list containing matching measures, or an empty list

getMeasures

public java.util.List<Measure> getMeasures(Metric metric)
Description copied from interface: JobContext
Finds measures for the given metric

Specified by:
getMeasures in interface JobContext
Parameters:
metric - the measure metric
Returns:
a list containing matching measures, or an empty list

getChildrenMeasures

public java.util.List<Measure> getChildrenMeasures(MeasureKey key)
Description copied from interface: JobContext
The list of children measures (first child level) for a given key

Specified by:
getChildrenMeasures in interface JobContext
Parameters:
key - the measure key
Returns:
the list of matching child measures, or an empty list

getChildrenMeasures

public java.util.List<Measure> getChildrenMeasures(Metric metric)
Description copied from interface: JobContext
The list of children measures (first child level) for a given key

Specified by:
getChildrenMeasures in interface JobContext
Parameters:
metric - the measure metric
Returns:
the list of matching child measures, or an empty list

getResource

public Resource getResource()
Description copied from interface: JobContext
The currently analysed resource

Specified by:
getResource in interface JobContext
Returns:
the resource cannot be null

getResourceVersion

public java.lang.String getResourceVersion()
Description copied from interface: JobContext
The version of the job context resource

Specified by:
getResourceVersion in interface JobContext
Returns:
the version, cannot be null

getSnapshotDate

public java.util.Date getSnapshotDate()
Description copied from interface: JobContext
The snapshot creation date

Specified by:
getSnapshotDate in interface JobContext
Returns:
creation date

getMeasure

public Measure getMeasure(MeasureKey key)
Description copied from interface: JobContext
Find a measure for the given key

Specified by:
getMeasure in interface JobContext
Parameters:
key - the measure key
Returns:
the matching measure or null

getMeasure

public Measure getMeasure(Metric metric)
Description copied from interface: JobContext
Find a measure for the given metric

Specified by:
getMeasure in interface JobContext
Parameters:
metric - the measure metric
Returns:
the matching measure or null if nothing found

getEvents

public java.util.List<Event> getEvents()
Description copied from interface: JobContext
All events, on projects only

Specified by:
getEvents in interface JobContext
Returns:
the events list, or an empty list

deleteEvent

public void deleteEvent(Event event)
Description copied from interface: JobContext
Deletes an event

Specified by:
deleteEvent in interface JobContext
Parameters:
event - the event to delete

createEvent

public Event createEvent(java.lang.String name,
                         java.lang.String description,
                         java.lang.String category,
                         java.util.Date date)
Description copied from interface: JobContext
Creates an event for a given date

Specified by:
createEvent in interface JobContext
Parameters:
name - the event name
description - the event description
category - the event category
date - the event date
Returns:
the created event

createEventOnCurrentSnapshot

public Event createEventOnCurrentSnapshot(java.lang.String name,
                                          java.lang.String description,
                                          java.lang.String category)
Description copied from interface: JobContext
Creates an event for the given analysis

Specified by:
createEventOnCurrentSnapshot in interface JobContext
Parameters:
name - the event name
description - the event description
category - the event category
Returns:
the created event

getPastMeasure

public Measure getPastMeasure(Metric metric)
Description copied from interface: JobContext
Find the previous analysis measure for a given metric

Specified by:
getPastMeasure in interface JobContext
Parameters:
metric - the metric
Returns:
the past measure or null if nothing found

clear

public void clear()

keepChild

public void keepChild(JobContext context)

keepChildren

protected void keepChildren()

isRootProject

public boolean isRootProject()

toString

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


Copyright © 2009 SonarSource SA. All Rights Reserved.