PageRenderTime 68ms CodeModel.GetById 19ms RepoModel.GetById 1ms app.codeStats 0ms

/src/main/java/com/atlassian/bamboo/plugin/dotnet/ncover/ViewNCoverCoverageSummary.java

https://bitbucket.org/atlassian/bamboo-dotnet-plugin/
Java | 121 lines | 68 code | 21 blank | 32 comment | 5 complexity | 00823bbd60b36696748f8b10a001a578 MD5 | raw file
Possible License(s): BSD-3-Clause
  1. package com.atlassian.bamboo.plugin.dotnet.ncover;
  2. import com.atlassian.bamboo.build.FilterController;
  3. import com.atlassian.bamboo.plugin.dotnet.DotNetPlugin;
  4. import com.atlassian.bamboo.reports.collector.ReportCollector;
  5. import com.atlassian.bamboo.ww2.actions.BuildActionSupport;
  6. import com.atlassian.bamboo.ww2.aware.ResultsListAware;
  7. import com.atlassian.bamboo.ww2.aware.permissions.PlanReadSecurityAware;
  8. import com.atlassian.plugin.ModuleDescriptor;
  9. import org.jfree.data.time.TimeTableXYDataset;
  10. import org.jfree.data.xy.XYDataset;
  11. import java.util.Collections;
  12. import java.util.List;
  13. /**
  14. * Action class used as part of NCover report display.
  15. *
  16. * @author Ross Rowe
  17. *
  18. */
  19. public class ViewNCoverCoverageSummary extends BuildActionSupport implements ResultsListAware, PlanReadSecurityAware
  20. {
  21. private static final long serialVersionUID = -3731695875856341713L;
  22. private static final String COVERAGE_REPORT_KEY = DotNetPlugin.PLUGIN_KEY + ":ncoverCoverage";
  23. // --------------------------------------------------------------------------------------------------Dependencies
  24. // --------------------------------------------------------------------------------------------------
  25. // Charting
  26. List resultsList;
  27. XYDataset dataset;
  28. String reportKey = COVERAGE_REPORT_KEY; // default.
  29. // --------------------------------------------------------------------------------------------------
  30. // Filter
  31. FilterController filterController;
  32. /**
  33. * Runs the viewCoverage action.
  34. *
  35. * @return the success status
  36. * @throws Exception
  37. * if any errors are thrown during the action processing
  38. */
  39. public String doViewCoverage() throws Exception {
  40. setReportKey(COVERAGE_REPORT_KEY);
  41. return run();
  42. }
  43. /**
  44. *
  45. * @return the success status
  46. * @throws Exception
  47. * if any errors are thrown during the action processing
  48. */
  49. @Override
  50. public String execute() throws Exception {
  51. return run();
  52. }
  53. /**
  54. * Sets the dataset variable as per the <code>ReportCollector</code> that
  55. * is applicable for the plugin descriptor.
  56. *
  57. * @return the success status
  58. */
  59. private String run() {
  60. if (resultsList != null && !resultsList.isEmpty()) {
  61. ModuleDescriptor descriptor = getPluginAccessor().getPluginModule(getReportKey());
  62. if (descriptor != null) {
  63. ReportCollector collector = (ReportCollector) descriptor
  64. .getModule();
  65. collector.setResultsList(getResultsList());
  66. collector.setParams(Collections.EMPTY_MAP);
  67. dataset = (TimeTableXYDataset) collector.getDataset();
  68. }
  69. }
  70. return SUCCESS;
  71. }
  72. @Override
  73. public List getResultsList() {
  74. return resultsList;
  75. }
  76. @Override
  77. public void setResultsList(List resultsList) {
  78. this.resultsList = resultsList;
  79. }
  80. public XYDataset getDataset() {
  81. return dataset;
  82. }
  83. public void setDataset(XYDataset dataset) {
  84. this.dataset = dataset;
  85. }
  86. public String getReportKey() {
  87. return reportKey;
  88. }
  89. public void setReportKey(String reportKey) {
  90. this.reportKey = reportKey;
  91. }
  92. // --------------------------------------------------------------------------------------------------
  93. // Dependencies
  94. public FilterController getFilterController() {
  95. return filterController;
  96. }
  97. public void setFilterController(FilterController filterController) {
  98. this.filterController = filterController;
  99. }
  100. }