hudson.plugins.pmd.util
Class HealthReportBuilder

java.lang.Object
  extended by hudson.plugins.pmd.util.HealthReportBuilder
All Implemented Interfaces:
java.io.Serializable

public class HealthReportBuilder
extends java.lang.Object
implements java.io.Serializable

Creates a health report for integer values based on healthy and unhealthy thresholds.

Author:
Ulli Hafner
See Also:
HealthReport, Serialized Form

Constructor Summary
HealthReportBuilder()
          Creates a new dummy instance of HealthReportBuilder.
HealthReportBuilder(boolean isFailureThresholdEnabled, int threshold, boolean isHealthyReportEnabled, int healthy, int unHealthy, java.lang.String reportSingleCount, java.lang.String reportMultipleCount)
          Creates a new instance of HealthReportBuilder.
 
Method Summary
 hudson.model.HealthReport computeHealth(int counter, int total, int high, int normal, int low)
          Computes the healthiness of a build based on the specified counter.
 org.jfree.chart.JFreeChart createGraph(boolean useHealthBuilder, java.lang.String url, org.jfree.data.category.CategoryDataset dataset, ToolTipProvider toolTipProvider)
          Creates a trend graph for the corresponding action using the thresholds of this health builder.
 java.util.List<java.lang.Integer> createSeries(int totalCount)
          Creates a list of integer values used to create a three color graph showing the items per build.
 int getHealthy()
          Returns the healthy.
 java.lang.String getItemName()
          Returns the itemName.
 java.lang.String getReportName()
          Returns the reportName.
 int getThreshold()
          Returns the threshold.
 int getUnHealthy()
          Returns the unHealthy.
 boolean isEnabled()
          Returns whether this health report build is enabled, i.e.
 boolean isFailureThresholdEnabled()
          Returns the isThresholdEnabled.
 boolean isHealthyReportEnabled()
          Returns the isHealthyReportEnabled.
 void setFailureThresholdEnabled(boolean isFailureThresholdEnabled)
          Sets the isThresholdEnabled to the specified value.
 void setHealthy(int healthy)
          Sets the healthy to the specified value.
 void setHealthyReportEnabled(boolean isHealthyReportEnabled)
          Sets the isHealthyReportEnabled to the specified value.
 void setItemName(java.lang.String itemName)
          Sets the itemName to the specified value.
 void setReportName(java.lang.String reportName)
          Sets the reportName to the specified value.
 void setThreshold(int threshold)
          Sets the threshold to the specified value.
 void setUnHealthy(int unHealthy)
          Sets the unHealthy to the specified value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HealthReportBuilder

public HealthReportBuilder(boolean isFailureThresholdEnabled,
                           int threshold,
                           boolean isHealthyReportEnabled,
                           int healthy,
                           int unHealthy,
                           java.lang.String reportSingleCount,
                           java.lang.String reportMultipleCount)
Creates a new instance of HealthReportBuilder.

Parameters:
isFailureThresholdEnabled - determines whether to use the provided unstable threshold
threshold - bug threshold to be reached if a build should be considered as unstable.
isHealthyReportEnabled - determines whether to use the provided healthy thresholds.
healthy - report health as 100% when the number of warnings is less than this value
unHealthy - report health as 0% when the number of warnings is greater than this value
reportSingleCount - message to be shown if there is exactly one item found
reportMultipleCount - message to be shown if there are zero or more than one items found

HealthReportBuilder

public HealthReportBuilder()
Creates a new dummy instance of HealthReportBuilder.

Method Detail

computeHealth

public hudson.model.HealthReport computeHealth(int counter,
                                               int total,
                                               int high,
                                               int normal,
                                               int low)
Computes the healthiness of a build based on the specified counter. Reports a health of 100% when the specified counter is less than healthy. Reports a health of 0% when the specified counter is greater than unHealthy.

Parameters:
counter - the number of items in a build that should be considered for health computation
total - all items in a build
high - items with priority high
normal - items with priority normal
low - items with priority low
Returns:
the healthiness of a build

isEnabled

public boolean isEnabled()
Returns whether this health report build is enabled, i.e. at least one of the health or failed thresholds are provided.

Returns:
true if health or failed thresholds are provided

getHealthy

public final int getHealthy()
Returns the healthy.

Returns:
the healthy

setHealthy

public final void setHealthy(int healthy)
Sets the healthy to the specified value.

Parameters:
healthy - the value to set

getUnHealthy

public final int getUnHealthy()
Returns the unHealthy.

Returns:
the unHealthy

setUnHealthy

public final void setUnHealthy(int unHealthy)
Sets the unHealthy to the specified value.

Parameters:
unHealthy - the value to set

isHealthyReportEnabled

public final boolean isHealthyReportEnabled()
Returns the isHealthyReportEnabled.

Returns:
the isHealthyReportEnabled

setHealthyReportEnabled

public final void setHealthyReportEnabled(boolean isHealthyReportEnabled)
Sets the isHealthyReportEnabled to the specified value.

Parameters:
isHealthyReportEnabled - the value to set

isFailureThresholdEnabled

public boolean isFailureThresholdEnabled()
Returns the isThresholdEnabled.

Returns:
the isThresholdEnabled

setFailureThresholdEnabled

public void setFailureThresholdEnabled(boolean isFailureThresholdEnabled)
Sets the isThresholdEnabled to the specified value.

Parameters:
isFailureThresholdEnabled - the value to set

getReportName

public final java.lang.String getReportName()
Returns the reportName.

Returns:
the reportName

setReportName

public final void setReportName(java.lang.String reportName)
Sets the reportName to the specified value.

Parameters:
reportName - the value to set

getItemName

public final java.lang.String getItemName()
Returns the itemName.

Returns:
the itemName

setItemName

public final void setItemName(java.lang.String itemName)
Sets the itemName to the specified value.

Parameters:
itemName - the value to set

getThreshold

public int getThreshold()
Returns the threshold.

Returns:
the threshold

setThreshold

public void setThreshold(int threshold)
Sets the threshold to the specified value.

Parameters:
threshold - the value to set

createSeries

public java.util.List<java.lang.Integer> createSeries(int totalCount)
Creates a list of integer values used to create a three color graph showing the items per build.

Parameters:
totalCount - total number of items
Returns:
the list of values

createGraph

public org.jfree.chart.JFreeChart createGraph(boolean useHealthBuilder,
                                              java.lang.String url,
                                              org.jfree.data.category.CategoryDataset dataset,
                                              ToolTipProvider toolTipProvider)
Creates a trend graph for the corresponding action using the thresholds of this health builder.

Parameters:
useHealthBuilder - if the health thresholds should be used at all
url - the URL shown in the tool tips
dataset - the data set of the values to render
toolTipProvider - tooltip provider for the clickable map
Returns:
the created graph


Copyright © 2008. All Rights Reserved.