Class CoverageViewModel
java.lang.Object
io.jenkins.plugins.datatables.DefaultAsyncTableContentProvider
io.jenkins.plugins.coverage.metrics.steps.CoverageViewModel
- All Implemented Interfaces:
ModelObject,io.jenkins.plugins.datatables.AsyncTableContentProvider
public class CoverageViewModel
extends io.jenkins.plugins.datatables.DefaultAsyncTableContentProvider
implements ModelObject
Server side model that provides the data for the details view of the coverage results. The layout of the associated
view is defined corresponding jelly view 'index.jelly'.
- Author:
- Ullrich Hafner, Florian Orendi
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classUI model for the coverage overview bar chart. -
Method Summary
Modifier and TypeMethodDescriptiongetApi()Gets the remote API for this action.List<edu.hm.hafner.coverage.Metric> Returns the metrics that are available for the trend chart.edu.hm.hafner.echarts.LabeledTreeMapNodegetCoverageTree(String coverageMetric) Returns the root of the tree of nodes for the ECharts treemap.getDynamic(String link, org.kohsuke.stapler.StaplerRequest2 request, org.kohsuke.stapler.StaplerResponse2 response) Returns a new subpage for the selected link.getId()Gets a set of color IDs which can be used to dynamically load the defined Jenkins colors.getMetricsTrendChart(String configuration) Returns the metrics trend chart configuration.edu.hm.hafner.coverage.NodegetNode()Run<?, ?> getOwner()List<edu.hm.hafner.coverage.Metric> Returns the metrics that are available for the trend chart.getSourceCode(String fileHash, String tableId) Gets the source code of the file which is represented by the passed hash code.io.jenkins.plugins.datatables.TableModelgetTableModel(String tableId) Returns the table model that matches with the passed table ID and shows the files along with the branch and line coverage.NavigableSet<edu.hm.hafner.coverage.Metric> Returns the value metrics that should be visualized in a tree map.getTrendChart(String configuration) Returns the trend chart configuration.getUrlForBuild(String selectedBuildDisplayName, String currentUrl) Returns the URL for coverage results of the selected build.booleanReturns if the model has any coverage data.booleanChecks whether indirect coverage changes exist.booleanReturns whether there are metrics available.booleanChecks whether modified lines coverage exists.booleanChecks whether source files are stored.booleanisSourceFileAvailable(edu.hm.hafner.coverage.FileNode coverageNode) Returns whether the source file is available in Jenkins build folder.voidsetJenkinsColors(String colors) Creates a newColorProviderbased on the passed color JSON string which contains the set Jenkins colors.Methods inherited from class io.jenkins.plugins.datatables.DefaultAsyncTableContentProvider
getTableRows
-
Method Details
-
getId
-
getOwner
-
getNode
public edu.hm.hafner.coverage.Node getNode() -
getFormatter
-
getTreeMetrics
Returns the value metrics that should be visualized in a tree map.- Returns:
- the value metrics
-
getCoverageMetrics
Returns the metrics that are available for the trend chart.- Returns:
- the available metrics
-
getSoftwareMetrics
Returns the metrics that are available for the trend chart.- Returns:
- the available metrics
-
getDisplayName
- Specified by:
getDisplayNamein interfaceModelObject
-
getApi
Gets the remote API for this action. Depending on the path, a different result is selected.- Returns:
- the remote API
-
getJenkinsColorIDs
Gets a set of color IDs which can be used to dynamically load the defined Jenkins colors.- Returns:
- the available color IDs
-
setJenkinsColors
Creates a newColorProviderbased on the passed color JSON string which contains the set Jenkins colors.- Parameters:
colors- The dynamically loaded Jenkins colors to be used for highlighting the coverage tree as JSON string
-
getOverview
-
getTrendChart
Returns the trend chart configuration.- Parameters:
configuration- JSON object to configure optional properties for the trend chart- Returns:
- the trend chart model (converted to a JSON string)
-
getMetricsTrendChart
Returns the metrics trend chart configuration.- Parameters:
configuration- JSON object to configure optional properties for the metrics trend chart- Returns:
- the metrics trend chart model (converted to a JSON string)
-
hasCoverage
public boolean hasCoverage()Returns if the model has any coverage data.- Returns:
- if the last job has coverage data
-
hasMetrics
public boolean hasMetrics()Returns whether there are metrics available.- Returns:
trueif there are metrics available,falseotherwise
-
getCoverageTree
@JavaScriptMethod public edu.hm.hafner.echarts.LabeledTreeMapNode getCoverageTree(String coverageMetric) Returns the root of the tree of nodes for the ECharts treemap. This tree is used as a model for the chart on the client side.- Parameters:
coverageMetric- the used coverage metric (line, branch, instruction, mutation)- Returns:
- the tree of nodes for the ECharts treemap
-
getTableModel
Returns the table model that matches with the passed table ID and shows the files along with the branch and line coverage.- Specified by:
getTableModelin interfaceio.jenkins.plugins.datatables.AsyncTableContentProvider- Parameters:
tableId- ID of the table model- Returns:
- the table model with the specified ID
-
getUrlForBuild
Returns the URL for coverage results of the selected build. Based on the current URL, the new URL will be composed by replacing the current build number with the selected build number.- Parameters:
selectedBuildDisplayName- the selected build to open the new results forcurrentUrl- the absolute URL to this details view results- Returns:
- the URL to the results or an empty string if the results are not available
-
getSourceCode
Gets the source code of the file which is represented by the passed hash code. The coverage of the source code is highlighted by using HTML. Depending on the passed table ID, the source code is returned filtered with only the relevant lines of code.- Parameters:
fileHash- The hash code of the requested filetableId- The ID of the source file table- Returns:
- the highlighted source code
-
hasSourceCode
@JavaScriptMethod public boolean hasSourceCode()Checks whether source files are stored.- Returns:
truewhen source files are stored,falseotherwise
-
hasModifiedLinesCoverage
public boolean hasModifiedLinesCoverage()Checks whether modified lines coverage exists.- Returns:
truewhether modified lines coverage exists, elsefalse
-
hasIndirectCoverageChanges
public boolean hasIndirectCoverageChanges()Checks whether indirect coverage changes exist.- Returns:
truewhether indirect coverage changes exist, elsefalse
-
isSourceFileAvailable
public boolean isSourceFileAvailable(edu.hm.hafner.coverage.FileNode coverageNode) Returns whether the source file is available in Jenkins build folder.- Parameters:
coverageNode- TheNodewhich is checked if there is a source file available- Returns:
trueif the source file is available,falseotherwise
-
getDynamic
@CheckForNull public Object getDynamic(String link, org.kohsuke.stapler.StaplerRequest2 request, org.kohsuke.stapler.StaplerResponse2 response) Returns a new subpage for the selected link.- Parameters:
link- the link to identify the subpage to showrequest- Stapler requestresponse- Stapler response- Returns:
- the new subpage
-