001 /*
002 * Sonar, open source software quality management tool.
003 * Copyright (C) 2009 SonarSource SA
004 * mailto:contact AT sonarsource DOT com
005 *
006 * Sonar is free software; you can redistribute it and/or
007 * modify it under the terms of the GNU Lesser General Public
008 * License as published by the Free Software Foundation; either
009 * version 3 of the License, or (at your option) any later version.
010 *
011 * Sonar is distributed in the hope that it will be useful,
012 * but WITHOUT ANY WARRANTY; without even the implied warranty of
013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014 * Lesser General Public License for more details.
015 *
016 * You should have received a copy of the GNU Lesser General Public
017 * License along with Sonar; if not, write to the Free Software
018 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
019 */
020 package org.sonar.api.batch;
021
022 import org.sonar.api.measures.Measure;
023 import org.sonar.api.measures.MeasuresFilter;
024 import org.sonar.api.measures.Metric;
025 import org.sonar.api.resources.Project;
026 import org.sonar.api.resources.Resource;
027 import org.sonar.api.rules.Violation;
028
029 import java.util.Collection;
030 import java.util.Date;
031 import java.util.List;
032
033 /**
034 * @since 1.10
035 */
036 public interface DecoratorContext {
037
038 Project getProject();
039
040 Resource getResource();
041
042 /**
043 * Child contexts are read only
044 */
045
046 List<DecoratorContext> getChildren();
047
048
049 // MEASURES
050
051 Measure getMeasure(Metric metric);
052
053 /**
054 * Never return null.
055 */
056 <M> M getMeasures(MeasuresFilter<M> filter);
057
058 /**
059 * Never return null.
060 */
061 Collection<Measure> getChildrenMeasures(MeasuresFilter filter);
062
063 Collection<Measure> getChildrenMeasures(Metric metric);
064
065
066 /**
067 * Add a measure on the current resource. It can not be executed from children contexts.
068 *
069 * @return the same context
070 */
071 DecoratorContext saveMeasure(Measure measure);
072
073 DecoratorContext saveMeasure(Metric metric, Double value);
074
075
076 // RULES
077
078 /**
079 * Read-only rule failures.
080 *
081 * @return the rule failures for file/classes resources, null for the others
082 */
083 List<Violation> getViolations();
084
085
086 List<Event> getEvents();
087
088 /**
089 * Creates an event for a given date
090 *
091 * @param name the event name
092 * @param description the event description
093 * @param category the event category
094 * @param date the event date
095 * @return the created event
096 */
097 Event createEvent(String name, String description, String category, Date date);
098
099 /**
100 * Deletes an event
101 *
102 * @param event the event to delete
103 */
104 void deleteEvent(Event event);
105
106 }