You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

DecoratorContext.java 4.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. /*
  2. * Sonar, open source software quality management tool.
  3. * Copyright (C) 2008-2011 SonarSource
  4. * mailto:contact AT sonarsource DOT com
  5. *
  6. * Sonar is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 3 of the License, or (at your option) any later version.
  10. *
  11. * Sonar is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with Sonar; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
  19. */
  20. package org.sonar.api.batch;
  21. import org.sonar.api.design.Dependency;
  22. import org.sonar.api.measures.Measure;
  23. import org.sonar.api.measures.MeasuresFilter;
  24. import org.sonar.api.measures.Metric;
  25. import org.sonar.api.resources.Project;
  26. import org.sonar.api.resources.Resource;
  27. import org.sonar.api.rules.Violation;
  28. import org.sonar.api.violations.ViolationQuery;
  29. import java.util.Collection;
  30. import java.util.Date;
  31. import java.util.List;
  32. import java.util.Set;
  33. /**
  34. * @since 1.10
  35. */
  36. public interface DecoratorContext {
  37. /**
  38. * @return the project in which the decorator is
  39. */
  40. Project getProject();
  41. /**
  42. * @return the resource that is currently decorated
  43. */
  44. Resource getResource();
  45. /**
  46. * Child contexts are read only
  47. */
  48. List<DecoratorContext> getChildren();
  49. // MEASURES
  50. /**
  51. * Find a measure for the resource
  52. */
  53. Measure getMeasure(Metric metric);
  54. /**
  55. * Never return null.
  56. */
  57. <M> M getMeasures(MeasuresFilter<M> filter);
  58. /**
  59. * Never return null.
  60. */
  61. Collection<Measure> getChildrenMeasures(MeasuresFilter filter);
  62. /**
  63. * @return the resource children measures for the given metric
  64. */
  65. Collection<Measure> getChildrenMeasures(Metric metric);
  66. /**
  67. * Add a measure on the current resource. It can not be executed from children contexts.
  68. *
  69. * @return the same context
  70. */
  71. DecoratorContext saveMeasure(Measure measure);
  72. /**
  73. * Add a measure on the current resource. It can not be executed from children contexts.
  74. *
  75. * @return the current object
  76. */
  77. DecoratorContext saveMeasure(Metric metric, Double value);
  78. // DEPENDENCIES
  79. Dependency saveDependency(Dependency dependency);
  80. Set<Dependency> getDependencies();
  81. Collection<Dependency> getIncomingDependencies();
  82. Collection<Dependency> getOutgoingDependencies();
  83. // RULES
  84. /**
  85. * Returns the violations that match the {@link ViolationQuery} parameters.
  86. *
  87. * @since 2.8
  88. * @param violationQuery
  89. * the request parameters specified as a {@link ViolationQuery}
  90. * @return the list of violations that match those parameters
  91. */
  92. public abstract List<Violation> getViolations(ViolationQuery violationQuery);
  93. /**
  94. * Returns all the active (= non switched-off) violations found on the current resource.
  95. *
  96. * @return the list of violations
  97. */
  98. List<Violation> getViolations();
  99. /**
  100. * Save a coding rule violation. The decorator which calls this method must be depended upon BatchBarriers.END_OF_VIOLATIONS_GENERATION.
  101. *
  102. * @since 2.5
  103. * @param force allows to force creation of violation even if it was suppressed by {@link org.sonar.api.rules.ViolationFilter}
  104. */
  105. DecoratorContext saveViolation(Violation violation, boolean force);
  106. /**
  107. * Save a coding rule violation. The decorator which calls this method must be depended upon BatchBarriers.END_OF_VIOLATIONS_GENERATION.
  108. */
  109. DecoratorContext saveViolation(Violation violation);
  110. // EVENTS
  111. /**
  112. * @return the list of events associated to the current resource
  113. */
  114. List<Event> getEvents();
  115. /**
  116. * Creates an event for a given date
  117. *
  118. * @param name the event name
  119. * @param description the event description
  120. * @param category the event category
  121. * @param date the event date
  122. * @return the created event
  123. */
  124. Event createEvent(String name, String description, String category, Date date);
  125. /**
  126. * Deletes an event
  127. *
  128. * @param event the event to delete
  129. */
  130. void deleteEvent(Event event);
  131. }