Class CoverageViewModel
- java.lang.Object
-
- io.jenkins.plugins.datatables.DefaultAsyncTableContentProvider
-
- com.parasoft.findings.jenkins.coverage.api.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 Classes Modifier and Type Class Description static class
CoverageViewModel.CoverageOverview
UI model for the coverage overview bar chart.
-
Field Summary
Fields Modifier and Type Field Description static String
ABSOLUTE_COVERAGE_TABLE_ID
static String
MODIFIED_LINES_COVERAGE_TABLE_ID
static String
TABLE_ID
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getDisplayName()
Object
getDynamic(String link, org.kohsuke.stapler.StaplerRequest request, org.kohsuke.stapler.StaplerResponse response)
Returns a new sub-page for the selected link.String
getId()
Set<String>
getJenkinsColorIDs()
Gets a set of color IDs which can be used to dynamically load the defined Jenkins colors.Node
getNode()
CoverageViewModel.CoverageOverview
getOverview()
Run<?,?>
getOwner()
String
getSourceCode(String fileHash, String tableId)
Gets the source code of the file which is represented by the passed hash code.io.jenkins.plugins.datatables.TableModel
getTableModel(String tableId)
Returns the table model that matches with the passed table ID and shows the files along with the branch and line coverage.String
getTrendChart(String configuration)
Returns the trend chart configuration.String
getUrlForBuild(String selectedBuildDisplayName, String currentUrl)
Returns the URL for coverage results of the selected build.boolean
hasModifiedLinesCoverage()
Checks whether modified lines coverage exists.boolean
hasSourceCode()
Checks whether source files are stored.boolean
isSourceFileAvailable(FileNode coverageNode)
Returns whether the source file is available in Jenkins build folder.void
setJenkinsColors(String colors)
Creates a newColorProvider
based on the passed color json string which contains the set Jenkins colors.
-
-
-
Field Detail
-
TABLE_ID
public static final String TABLE_ID
- See Also:
- Constant Field Values
-
ABSOLUTE_COVERAGE_TABLE_ID
public static final String ABSOLUTE_COVERAGE_TABLE_ID
- See Also:
- Constant Field Values
-
MODIFIED_LINES_COVERAGE_TABLE_ID
public static final String MODIFIED_LINES_COVERAGE_TABLE_ID
- See Also:
- Constant Field Values
-
-
Method Detail
-
getId
public String getId()
-
getOwner
public Run<?,?> getOwner()
-
getNode
public Node getNode()
-
getDisplayName
public String getDisplayName()
- Specified by:
getDisplayName
in interfaceModelObject
-
getJenkinsColorIDs
@JavaScriptMethod public Set<String> getJenkinsColorIDs()
Gets a set of color IDs which can be used to dynamically load the defined Jenkins colors.- Returns:
- the available color IDs
-
setJenkinsColors
@JavaScriptMethod public void setJenkinsColors(String colors)
Creates a newColorProvider
based 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
@JavaScriptMethod public CoverageViewModel.CoverageOverview getOverview()
-
getTrendChart
@JavaScriptMethod public String getTrendChart(String configuration)
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)
-
getTableModel
public io.jenkins.plugins.datatables.TableModel getTableModel(String tableId)
Returns the table model that matches with the passed table ID and shows the files along with the branch and line coverage.- Specified by:
getTableModel
in interfaceio.jenkins.plugins.datatables.AsyncTableContentProvider
- Parameters:
tableId
- ID of the table model- Returns:
- the table model with the specified ID
-
getUrlForBuild
@JavaScriptMethod public String getUrlForBuild(String selectedBuildDisplayName, String currentUrl)
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
@JavaScriptMethod public String getSourceCode(String fileHash, String tableId)
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:
true
when source files are stored,false
otherwise
-
hasModifiedLinesCoverage
public boolean hasModifiedLinesCoverage()
Checks whether modified lines coverage exists.- Returns:
true
whether modified lines coverage exists, elsefalse
-
isSourceFileAvailable
public boolean isSourceFileAvailable(FileNode coverageNode)
Returns whether the source file is available in Jenkins build folder.- Parameters:
coverageNode
- TheNode
which is checked if there is a source file available- Returns:
true
if the source file is available,false
otherwise
-
getDynamic
@CheckForNull public Object getDynamic(String link, org.kohsuke.stapler.StaplerRequest request, org.kohsuke.stapler.StaplerResponse response)
Returns a new sub-page for the selected link.- Parameters:
link
- the link to identify the sub-page to showrequest
- Stapler requestresponse
- Stapler response- Returns:
- the new sub-page
-
-