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.design.Dependency;
023 import org.sonar.api.measures.Measure;
024 import org.sonar.api.measures.MeasuresFilter;
025 import org.sonar.api.measures.Metric;
026 import org.sonar.api.resources.Project;
027 import org.sonar.api.resources.ProjectLink;
028 import org.sonar.api.resources.Resource;
029 import org.sonar.api.rules.Violation;
030 import org.sonar.graph.DirectedGraphAccessor;
031
032 import java.util.Collection;
033 import java.util.Date;
034 import java.util.List;
035 import java.util.Set;
036
037 public abstract class SonarIndex implements DirectedGraphAccessor<Resource, Dependency> {
038
039 public abstract Project getRootProject();
040
041 public abstract Project getProject();
042
043 public abstract Resource getResource(Resource resource);
044
045 public final Collection<Resource> getResources() {
046 return getVertices();
047 }
048
049 public abstract List<Resource> getChildren(Resource resource);
050
051 public abstract Resource addResource(Resource resource);
052
053 public abstract Measure getMeasure(Resource resource, Metric metric);
054
055 public abstract <M> M getMeasures(Resource resource, MeasuresFilter<M> filter);
056
057 public abstract void setSource(Resource resource, String source);
058
059 public abstract void addViolation(Violation violation);
060
061 public abstract Measure saveMeasure(Resource resource, Measure measure);
062
063 public abstract Dependency saveDependency(Dependency dependency);
064
065 public abstract Set<Dependency> getDependencies();
066
067 public abstract void saveLink(ProjectLink link);
068
069 public abstract void deleteLink(String key);
070
071 public abstract List<Event> getEvents(Resource resource);
072
073 public abstract void deleteEvent(Event event);
074
075 public abstract Event createEvent(Resource resource, String name, String description, String category, Date date);
076
077 public final Collection<Dependency> getOutgoingDependencies(Resource from) {
078 return getOutgoingEdges(from);
079 }
080
081 public final Collection<Dependency> getIncomingDependencies(Resource to) {
082 return getIncomingEdges(to);
083 }
084 }