* Remove unused method DefaultDecoratorContext#getSession() and as a result dependency on DatabaseSession
* Replace DefaultIndex by SonarIndex in DefaultDecoratorContext and in DefaultSensorContext
*/
package org.sonar.batch;
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+import java.util.Set;
+
import com.google.common.collect.Lists;
import org.sonar.api.batch.DecoratorContext;
import org.sonar.api.batch.Event;
-import org.sonar.api.database.DatabaseSession;
+import org.sonar.api.batch.SonarIndex;
import org.sonar.api.design.Dependency;
import org.sonar.api.measures.Measure;
import org.sonar.api.measures.MeasuresFilter;
import org.sonar.api.resources.Project;
import org.sonar.api.resources.Resource;
import org.sonar.api.rules.Violation;
-import org.sonar.batch.index.DefaultIndex;
-
-import java.util.Collection;
-import java.util.Date;
-import java.util.List;
-import java.util.Set;
public class DefaultDecoratorContext implements DecoratorContext {
- private DatabaseSession session;
- private DefaultIndex index;
+ private SonarIndex index;
private Resource resource;
private boolean readOnly = false;
private List<DecoratorContext> childrenContexts;
public DefaultDecoratorContext(Resource resource,
- DefaultIndex index,
- List<DecoratorContext> childrenContexts,
- DatabaseSession session) {
+ SonarIndex index,
+ List<DecoratorContext> childrenContexts) {
this.index = index;
- this.session = session;
this.resource = resource;
this.childrenContexts = childrenContexts;
}
return this;
}
-
public List<Violation> getViolations() {
return index.getViolations(resource);
}
return index.getOutgoingEdges(resource);
}
- protected DatabaseSession getSession() {
- return session;
- }
-
public List<Event> getEvents() {
return index.getEvents(resource);
}
public void deleteEvent(Event event) {
index.deleteEvent(event);
}
-
+
public DefaultDecoratorContext saveViolation(Violation violation, boolean force) {
if (violation.getResource() == null) {
violation.setResource(resource);
import org.sonar.api.batch.Event;
import org.sonar.api.batch.SensorContext;
+import org.sonar.api.batch.SonarIndex;
import org.sonar.api.design.Dependency;
import org.sonar.api.measures.Measure;
import org.sonar.api.measures.MeasuresFilter;
import org.sonar.api.measures.Metric;
import org.sonar.api.resources.*;
import org.sonar.api.rules.Violation;
-import org.sonar.batch.index.DefaultIndex;
import java.util.Collection;
import java.util.Date;
public class DefaultSensorContext implements SensorContext {
- private DefaultIndex index;
+ private SonarIndex index;
private Project project;
- public DefaultSensorContext(DefaultIndex index, Project project) {
+ public DefaultSensorContext(SonarIndex index, Project project) {
this.index = index;
this.project = project;
}
// the Snapshot component will be removed when asynchronous measures are improved (required for AsynchronousMeasureSensor)
addComponent(getComponent(DefaultResourcePersister.class).getSnapshot(project));
- // TODO was addComponent(globalComponents.getComponent(DefaultResourcePersister.class).getSnapshot(project));
addComponent(org.sonar.api.database.daos.MeasuresDao.class);
addComponent(ProfilesDao.class);
*/
package org.sonar.batch.phases;
-import java.util.Collection;
-import java.util.List;
-
import com.google.common.collect.Lists;
import org.sonar.api.BatchComponent;
import org.sonar.api.batch.BatchExtensionDictionnary;
import org.sonar.api.batch.Decorator;
import org.sonar.api.batch.DecoratorContext;
-import org.sonar.api.database.DatabaseSession;
+import org.sonar.api.batch.SonarIndex;
import org.sonar.api.resources.Project;
import org.sonar.api.resources.Resource;
import org.sonar.batch.DecoratorsSelector;
import org.sonar.batch.events.DecoratorExecutionEvent;
import org.sonar.batch.events.DecoratorsPhaseEvent;
import org.sonar.batch.events.EventBus;
-import org.sonar.batch.index.DefaultIndex;
+
+import java.util.Collection;
+import java.util.List;
public class DecoratorsExecutor implements BatchComponent {
private DecoratorsSelector decoratorsSelector;
- private DatabaseSession session;
- private DefaultIndex index;
+ private SonarIndex index;
private EventBus eventBus;
- public DecoratorsExecutor(BatchExtensionDictionnary extensionDictionnary, DefaultIndex index, DatabaseSession session, EventBus eventBus) {
+ public DecoratorsExecutor(BatchExtensionDictionnary extensionDictionnary, SonarIndex index, EventBus eventBus) {
this.decoratorsSelector = new DecoratorsSelector(extensionDictionnary);
- this.session = session;
this.index = index;
this.eventBus = eventBus;
}
childrenContexts.add(childContext.setReadOnly(true));
}
- DefaultDecoratorContext context = new DefaultDecoratorContext(resource, index, childrenContexts, session);
+ DefaultDecoratorContext context = new DefaultDecoratorContext(resource, index, childrenContexts);
if (executeDecorators) {
for (Decorator decorator : decorators) {
eventBus.fireEvent(new DecoratorExecutionEvent(decorator, true));
public abstract <M> M getMeasures(Resource resource, MeasuresFilter<M> filter);
+ /**
+ * @since 2.7
+ */
+ public abstract List<Violation> getViolations(Resource resource);
+
/**
* @since 2.5
*/