PageRenderTime 45ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

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

https://bitbucket.org/atlassian/bamboo-dotnet-plugin/
Java | 58 lines | 33 code | 11 blank | 14 comment | 7 complexity | b651480eddb5ca33068cfa727d8701e0 MD5 | raw file
Possible License(s): BSD-3-Clause
  1. package com.atlassian.bamboo.plugin.dotnet.ncover;
  2. import com.atlassian.bamboo.plan.PlanKeys;
  3. import com.atlassian.bamboo.plan.PlanResultKey;
  4. import com.atlassian.bamboo.resultsummary.ResultsSummary;
  5. import com.atlassian.bamboo.resultsummary.ResultsSummaryManager;
  6. import com.atlassian.plugin.PluginParseException;
  7. import com.atlassian.plugin.web.Condition;
  8. import java.util.Map;
  9. /**
  10. * Contains logic to control whether a 'NCover' tab is displayed on the Results
  11. * results page.
  12. *
  13. * @author Ross Rowe
  14. *
  15. */
  16. public class NCoverResultWebItemCondition implements Condition {
  17. private ResultsSummaryManager resultsSummaryManager;
  18. @Override
  19. public void init(Map map) throws PluginParseException {
  20. }
  21. /**
  22. * Only display the NCover tab item if the appropriate configuration
  23. * settings have been set.
  24. *
  25. * @param context
  26. * @return boolean indicating whether NCover tab item should be displayed
  27. */
  28. @Override
  29. public boolean shouldDisplay(Map<String, Object> context) {
  30. String planKey = (String) context.get(NCoverBuildProcessor.BUILD_KEY);
  31. String buildNumber = (String) context.get(NCoverBuildProcessor.BUILD_NUMBER);
  32. if (planKey == null || buildNumber == null)
  33. return false;
  34. PlanResultKey planResultKey = PlanKeys.getPlanResultKey(planKey, Integer.parseInt(buildNumber));
  35. ResultsSummary summary = resultsSummaryManager.getResultsSummary(planResultKey);
  36. if (summary == null) {
  37. return false;
  38. } else {
  39. Map<String, String> customData = summary.getCustomBuildData();
  40. return customData.containsKey(NCoverBuildProcessor.NCOVER_LINE_RATE);
  41. }
  42. }
  43. public void setResultsSummaryManager(ResultsSummaryManager resultsSummaryManager)
  44. {
  45. this.resultsSummaryManager = resultsSummaryManager;
  46. }
  47. }