summaryrefslogtreecommitdiffstats
path: root/sonar-plugin-api
diff options
context:
space:
mode:
authorEvgeny Mandrikov <mandrikov@gmail.com>2011-04-19 19:36:14 +0400
committerEvgeny Mandrikov <mandrikov@gmail.com>2011-04-20 13:32:53 +0400
commitee7b180068da45ddbe70031a4d2cdd94c6c377d3 (patch)
tree5b60ef6ee0d89a935c249b4df79165c63b53a6c9 /sonar-plugin-api
parentc6d954e8c39d9d9555ceb2e966feefef1c6b3c0b (diff)
downloadsonarqube-ee7b180068da45ddbe70031a4d2cdd94c6c377d3.tar.gz
sonarqube-ee7b180068da45ddbe70031a4d2cdd94c6c377d3.zip
Fix crlf
Diffstat (limited to 'sonar-plugin-api')
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/DecoratorContext.java318
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/SonarIndex.java364
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/database/DatabaseSession.java160
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/rules/Violation.java506
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/violations/ViolationQuery.java178
5 files changed, 763 insertions, 763 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/DecoratorContext.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/DecoratorContext.java
index af59b924da7..57103c691d0 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/DecoratorContext.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/DecoratorContext.java
@@ -1,159 +1,159 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2011 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * Sonar is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
- */
-package org.sonar.api.batch;
-
-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.Project;
-import org.sonar.api.resources.Resource;
-import org.sonar.api.rules.Violation;
-import org.sonar.api.violations.ViolationQuery;
-
-import java.util.Collection;
-import java.util.Date;
-import java.util.List;
-import java.util.Set;
-
-/**
- * @since 1.10
- */
-public interface DecoratorContext {
-
- /**
- * @return the project in which the decorator is
- */
- Project getProject();
-
- /**
- * @return the resource that is currently decorated
- */
- Resource getResource();
-
- /**
- * Child contexts are read only
- */
- List<DecoratorContext> getChildren();
-
- // MEASURES
-
- /**
- * Find a measure for the resource
- */
- Measure getMeasure(Metric metric);
-
- /**
- * Never return null.
- */
- <M> M getMeasures(MeasuresFilter<M> filter);
-
- /**
- * Never return null.
- */
- Collection<Measure> getChildrenMeasures(MeasuresFilter filter);
-
- /**
- * @return the resource children measures for the given metric
- */
- Collection<Measure> getChildrenMeasures(Metric metric);
-
- /**
- * Add a measure on the current resource. It can not be executed from children contexts.
- *
- * @return the same context
- */
- DecoratorContext saveMeasure(Measure measure);
-
- /**
- * Add a measure on the current resource. It can not be executed from children contexts.
- *
- * @return the current object
- */
- DecoratorContext saveMeasure(Metric metric, Double value);
-
- // DEPENDENCIES
-
- Dependency saveDependency(Dependency dependency);
-
- Set<Dependency> getDependencies();
-
- Collection<Dependency> getIncomingDependencies();
-
- Collection<Dependency> getOutgoingDependencies();
-
- // RULES
-
- /**
- * Returns the violations that match the {@link ViolationQuery} parameters.
- *
- * @since 2.8
- * @param violationQuery
- * the request parameters specified as a {@link ViolationQuery}
- * @return the list of violations that match those parameters
- */
- public abstract List<Violation> getViolations(ViolationQuery violationQuery);
-
- /**
- * Returns all the active (= non switched-off) violations found on the current resource.
- *
- * @return the list of violations
- */
- List<Violation> getViolations();
-
- /**
- * Save a coding rule violation. The decorator which calls this method must be depended upon BatchBarriers.END_OF_VIOLATIONS_GENERATION.
- *
- * @since 2.5
- * @param force allows to force creation of violation even if it was suppressed by {@link org.sonar.api.rules.ViolationFilter}
- */
- DecoratorContext saveViolation(Violation violation, boolean force);
-
- /**
- * Save a coding rule violation. The decorator which calls this method must be depended upon BatchBarriers.END_OF_VIOLATIONS_GENERATION.
- */
- DecoratorContext saveViolation(Violation violation);
-
- // EVENTS
-
- /**
- * @return the list of events associated to the current resource
- */
- List<Event> getEvents();
-
- /**
- * Creates an event for a given date
- *
- * @param name the event name
- * @param description the event description
- * @param category the event category
- * @param date the event date
- * @return the created event
- */
- Event createEvent(String name, String description, String category, Date date);
-
- /**
- * Deletes an event
- *
- * @param event the event to delete
- */
- void deleteEvent(Event event);
-
-}
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * Sonar is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.api.batch;
+
+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.Project;
+import org.sonar.api.resources.Resource;
+import org.sonar.api.rules.Violation;
+import org.sonar.api.violations.ViolationQuery;
+
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * @since 1.10
+ */
+public interface DecoratorContext {
+
+ /**
+ * @return the project in which the decorator is
+ */
+ Project getProject();
+
+ /**
+ * @return the resource that is currently decorated
+ */
+ Resource getResource();
+
+ /**
+ * Child contexts are read only
+ */
+ List<DecoratorContext> getChildren();
+
+ // MEASURES
+
+ /**
+ * Find a measure for the resource
+ */
+ Measure getMeasure(Metric metric);
+
+ /**
+ * Never return null.
+ */
+ <M> M getMeasures(MeasuresFilter<M> filter);
+
+ /**
+ * Never return null.
+ */
+ Collection<Measure> getChildrenMeasures(MeasuresFilter filter);
+
+ /**
+ * @return the resource children measures for the given metric
+ */
+ Collection<Measure> getChildrenMeasures(Metric metric);
+
+ /**
+ * Add a measure on the current resource. It can not be executed from children contexts.
+ *
+ * @return the same context
+ */
+ DecoratorContext saveMeasure(Measure measure);
+
+ /**
+ * Add a measure on the current resource. It can not be executed from children contexts.
+ *
+ * @return the current object
+ */
+ DecoratorContext saveMeasure(Metric metric, Double value);
+
+ // DEPENDENCIES
+
+ Dependency saveDependency(Dependency dependency);
+
+ Set<Dependency> getDependencies();
+
+ Collection<Dependency> getIncomingDependencies();
+
+ Collection<Dependency> getOutgoingDependencies();
+
+ // RULES
+
+ /**
+ * Returns the violations that match the {@link ViolationQuery} parameters.
+ *
+ * @since 2.8
+ * @param violationQuery
+ * the request parameters specified as a {@link ViolationQuery}
+ * @return the list of violations that match those parameters
+ */
+ public abstract List<Violation> getViolations(ViolationQuery violationQuery);
+
+ /**
+ * Returns all the active (= non switched-off) violations found on the current resource.
+ *
+ * @return the list of violations
+ */
+ List<Violation> getViolations();
+
+ /**
+ * Save a coding rule violation. The decorator which calls this method must be depended upon BatchBarriers.END_OF_VIOLATIONS_GENERATION.
+ *
+ * @since 2.5
+ * @param force allows to force creation of violation even if it was suppressed by {@link org.sonar.api.rules.ViolationFilter}
+ */
+ DecoratorContext saveViolation(Violation violation, boolean force);
+
+ /**
+ * Save a coding rule violation. The decorator which calls this method must be depended upon BatchBarriers.END_OF_VIOLATIONS_GENERATION.
+ */
+ DecoratorContext saveViolation(Violation violation);
+
+ // EVENTS
+
+ /**
+ * @return the list of events associated to the current resource
+ */
+ List<Event> getEvents();
+
+ /**
+ * Creates an event for a given date
+ *
+ * @param name the event name
+ * @param description the event description
+ * @param category the event category
+ * @param date the event date
+ * @return the created event
+ */
+ Event createEvent(String name, String description, String category, Date date);
+
+ /**
+ * Deletes an event
+ *
+ * @param event the event to delete
+ */
+ void deleteEvent(Event event);
+
+}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/SonarIndex.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/SonarIndex.java
index f2a09f9a6ce..89133b1c6b8 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/SonarIndex.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/SonarIndex.java
@@ -1,182 +1,182 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2011 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * Sonar is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
- */
-package org.sonar.api.batch;
-
-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.DuplicatedSourceException;
-import org.sonar.api.resources.Project;
-import org.sonar.api.resources.ProjectLink;
-import org.sonar.api.resources.Resource;
-import org.sonar.api.rules.Violation;
-import org.sonar.api.violations.ViolationQuery;
-import org.sonar.graph.DirectedGraphAccessor;
-
-import java.util.Collection;
-import java.util.Date;
-import java.util.List;
-import java.util.Set;
-
-public abstract class SonarIndex implements DirectedGraphAccessor<Resource, Dependency> {
-
- /**
- * Indexes a resource as a direct child of project. This method does nothing and returns true if the resource already indexed.
- * If the method resource.getParent() does not return null, then this parent will be indexed too.
- *
- * @return false if the resource is excluded
- * @since 2.6
- */
- public abstract boolean index(Resource resource);
-
-
- /**
- * Indexes a resource. This method does nothing if the resource is already indexed.
- *
- * @param resource the resource to index. Not nullable
- * @param parentReference a reference to the indexed parent. If null, the resource is indexed as a direct child of project.
- * @return false if the parent is not indexed or if the resource is excluded
- * @since 2.6
- */
- public abstract boolean index(Resource resource, Resource parentReference);
-
- /**
- * Returns true if the referenced resource is excluded. An excluded resource is not indexed.
- * @since 2.6
- */
- public abstract boolean isExcluded(Resource reference);
-
- /**
- * @since 2.6
- */
- public abstract boolean isIndexed(Resource reference, boolean acceptExcluded);
-
- /**
- * Search for an indexed resource.
- *
- * @param reference the resource reference
- * @return the indexed resource, null if it's not indexed
- * @since 1.10. Generic types since 2.6.
- */
- public abstract <R extends Resource> R getResource(R reference);
-
- /**
- * @since 2.6
- */
- public abstract Resource getParent(Resource reference);
-
- /**
- * @since 2.6
- */
-
- public abstract Collection<Resource> getChildren(Resource reference);
-
- /**
- * Save the source code of a file. The file must be have been indexed before.
- * Note: the source stream is not closed.
- *
- * @return false if the resource is excluded or not indexed
- * @throws org.sonar.api.resources.DuplicatedSourceException
- * if the source has already been set on this resource
- */
- public abstract void setSource(Resource reference, String source) throws DuplicatedSourceException;
-
- public abstract Project getProject();
-
- public final Collection<Resource> getResources() {
- return getVertices();
- }
-
- /**
- * Indexes the resource.
- * @return the indexed resource, even if it's excluded
- * @deprecated since 2.6. Use methods index()
- */
- @Deprecated
- public abstract Resource addResource(Resource resource);
-
- public abstract Measure getMeasure(Resource resource, Metric metric);
-
- public abstract <M> M getMeasures(Resource resource, MeasuresFilter<M> filter);
-
- /**
- * Returns the violations that match the {@link ViolationQuery} parameters.
- *
- * @since 2.8
- * @param violationQuery
- * the request parameters specified as a {@link ViolationQuery}
- * @return the list of violations that match those parameters
- */
- public abstract List<Violation> getViolations(ViolationQuery violationQuery);
-
- /**
- * Returns all the active (= non switched-off) violations found on the given resource. Equivalent to
- * {@link #getViolations(ViolationQuery)} called with <code>ViolationQuery.create().forResource(resource).ignoreSwitchedOff(true)</code>
- * as a parameter.
- *
- * @since 2.7
- * @param the
- * resource on which violations are searched
- * @return the list of violations
- */
- public final List<Violation> getViolations(Resource resource) {
- return getViolations(ViolationQuery.create().forResource(resource).ignoreSwitchedOff(true));
- }
-
- /**
- * @since 2.5
- */
- public abstract void addViolation(Violation violation, boolean force);
-
- public final void addViolation(Violation violation) {
- addViolation(violation, false);
- }
-
- /**
- * Warning: the resource is automatically indexed for backward-compatibility, but it should be explictly
- * indexed before. Next versions will deactivate this automatic indexation.
- *
- * @throws SonarException if the metric is unknown.
- */
- public abstract Measure addMeasure(Resource resource, Measure measure);
-
- public abstract Dependency addDependency(Dependency dependency);
-
- public abstract Set<Dependency> getDependencies();
-
- public abstract void addLink(ProjectLink link);
-
- public abstract void deleteLink(String key);
-
- public abstract List<Event> getEvents(Resource resource);
-
- public abstract void deleteEvent(Event event);
-
- public abstract Event addEvent(Resource resource, String name, String description, String category, Date date);
-
- public final Collection<Dependency> getOutgoingDependencies(Resource from) {
- return getOutgoingEdges(from);
- }
-
- public final Collection<Dependency> getIncomingDependencies(Resource to) {
- return getIncomingEdges(to);
- }
-}
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * Sonar is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.api.batch;
+
+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.DuplicatedSourceException;
+import org.sonar.api.resources.Project;
+import org.sonar.api.resources.ProjectLink;
+import org.sonar.api.resources.Resource;
+import org.sonar.api.rules.Violation;
+import org.sonar.api.violations.ViolationQuery;
+import org.sonar.graph.DirectedGraphAccessor;
+
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+import java.util.Set;
+
+public abstract class SonarIndex implements DirectedGraphAccessor<Resource, Dependency> {
+
+ /**
+ * Indexes a resource as a direct child of project. This method does nothing and returns true if the resource already indexed.
+ * If the method resource.getParent() does not return null, then this parent will be indexed too.
+ *
+ * @return false if the resource is excluded
+ * @since 2.6
+ */
+ public abstract boolean index(Resource resource);
+
+
+ /**
+ * Indexes a resource. This method does nothing if the resource is already indexed.
+ *
+ * @param resource the resource to index. Not nullable
+ * @param parentReference a reference to the indexed parent. If null, the resource is indexed as a direct child of project.
+ * @return false if the parent is not indexed or if the resource is excluded
+ * @since 2.6
+ */
+ public abstract boolean index(Resource resource, Resource parentReference);
+
+ /**
+ * Returns true if the referenced resource is excluded. An excluded resource is not indexed.
+ * @since 2.6
+ */
+ public abstract boolean isExcluded(Resource reference);
+
+ /**
+ * @since 2.6
+ */
+ public abstract boolean isIndexed(Resource reference, boolean acceptExcluded);
+
+ /**
+ * Search for an indexed resource.
+ *
+ * @param reference the resource reference
+ * @return the indexed resource, null if it's not indexed
+ * @since 1.10. Generic types since 2.6.
+ */
+ public abstract <R extends Resource> R getResource(R reference);
+
+ /**
+ * @since 2.6
+ */
+ public abstract Resource getParent(Resource reference);
+
+ /**
+ * @since 2.6
+ */
+
+ public abstract Collection<Resource> getChildren(Resource reference);
+
+ /**
+ * Save the source code of a file. The file must be have been indexed before.
+ * Note: the source stream is not closed.
+ *
+ * @return false if the resource is excluded or not indexed
+ * @throws org.sonar.api.resources.DuplicatedSourceException
+ * if the source has already been set on this resource
+ */
+ public abstract void setSource(Resource reference, String source) throws DuplicatedSourceException;
+
+ public abstract Project getProject();
+
+ public final Collection<Resource> getResources() {
+ return getVertices();
+ }
+
+ /**
+ * Indexes the resource.
+ * @return the indexed resource, even if it's excluded
+ * @deprecated since 2.6. Use methods index()
+ */
+ @Deprecated
+ public abstract Resource addResource(Resource resource);
+
+ public abstract Measure getMeasure(Resource resource, Metric metric);
+
+ public abstract <M> M getMeasures(Resource resource, MeasuresFilter<M> filter);
+
+ /**
+ * Returns the violations that match the {@link ViolationQuery} parameters.
+ *
+ * @since 2.8
+ * @param violationQuery
+ * the request parameters specified as a {@link ViolationQuery}
+ * @return the list of violations that match those parameters
+ */
+ public abstract List<Violation> getViolations(ViolationQuery violationQuery);
+
+ /**
+ * Returns all the active (= non switched-off) violations found on the given resource. Equivalent to
+ * {@link #getViolations(ViolationQuery)} called with <code>ViolationQuery.create().forResource(resource).ignoreSwitchedOff(true)</code>
+ * as a parameter.
+ *
+ * @since 2.7
+ * @param the
+ * resource on which violations are searched
+ * @return the list of violations
+ */
+ public final List<Violation> getViolations(Resource resource) {
+ return getViolations(ViolationQuery.create().forResource(resource).ignoreSwitchedOff(true));
+ }
+
+ /**
+ * @since 2.5
+ */
+ public abstract void addViolation(Violation violation, boolean force);
+
+ public final void addViolation(Violation violation) {
+ addViolation(violation, false);
+ }
+
+ /**
+ * Warning: the resource is automatically indexed for backward-compatibility, but it should be explictly
+ * indexed before. Next versions will deactivate this automatic indexation.
+ *
+ * @throws SonarException if the metric is unknown.
+ */
+ public abstract Measure addMeasure(Resource resource, Measure measure);
+
+ public abstract Dependency addDependency(Dependency dependency);
+
+ public abstract Set<Dependency> getDependencies();
+
+ public abstract void addLink(ProjectLink link);
+
+ public abstract void deleteLink(String key);
+
+ public abstract List<Event> getEvents(Resource resource);
+
+ public abstract void deleteEvent(Event event);
+
+ public abstract Event addEvent(Resource resource, String name, String description, String category, Date date);
+
+ public final Collection<Dependency> getOutgoingDependencies(Resource from) {
+ return getOutgoingEdges(from);
+ }
+
+ public final Collection<Dependency> getIncomingDependencies(Resource to) {
+ return getIncomingEdges(to);
+ }
+}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/database/DatabaseSession.java b/sonar-plugin-api/src/main/java/org/sonar/api/database/DatabaseSession.java
index dc416bc5257..19bf31cd5c6 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/database/DatabaseSession.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/database/DatabaseSession.java
@@ -1,80 +1,80 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2011 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * Sonar is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
- */
-package org.sonar.api.database;
-
-import org.sonar.api.BatchComponent;
-
-import javax.persistence.EntityManager;
-import javax.persistence.Query;
-import java.util.List;
-
-/**
- * This component should not accessible from plugin API
- *
- * @since 1.10
- */
-public abstract class DatabaseSession implements BatchComponent {
-
-
- // IMPORTANT : this value must be the same than the property
- // hibernate.jdbc.batch_size from /META-INF/persistence.xml (module sonar-database)
- public static final int BATCH_SIZE = 30;
-
-
- public abstract EntityManager getEntityManager();
-
- public abstract void start();
-
- public abstract void stop();
-
- public abstract void commit();
-
- public abstract void rollback();
-
- public abstract <T> T save(T entity);
-
- public abstract Object saveWithoutFlush(Object entity);
-
- public abstract boolean contains(Object entity);
-
- public abstract void save(Object... entities);
-
- public abstract Object merge(Object entity);
-
- public abstract void remove(Object entity);
-
- public abstract void removeWithoutFlush(Object entity);
-
- public abstract <T> T reattach(Class<T> entityClass, Object primaryKey);
-
- public abstract Query createQuery(String hql);
-
- public abstract Query createNativeQuery(String sql);
-
- public abstract <T> T getSingleResult(Query query, T defaultValue);
-
- public abstract <T> T getEntity(Class<T> entityClass, Object id);
-
- public abstract <T> T getSingleResult(Class<T> entityClass, Object... criterias);
-
- public abstract <T> List<T> getResults(Class<T> entityClass, Object... criterias);
-
- public abstract <T> List<T> getResults(Class<T> entityClass);
-}
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * Sonar is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.api.database;
+
+import org.sonar.api.BatchComponent;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+import java.util.List;
+
+/**
+ * This component should not accessible from plugin API
+ *
+ * @since 1.10
+ */
+public abstract class DatabaseSession implements BatchComponent {
+
+
+ // IMPORTANT : this value must be the same than the property
+ // hibernate.jdbc.batch_size from /META-INF/persistence.xml (module sonar-database)
+ public static final int BATCH_SIZE = 30;
+
+
+ public abstract EntityManager getEntityManager();
+
+ public abstract void start();
+
+ public abstract void stop();
+
+ public abstract void commit();
+
+ public abstract void rollback();
+
+ public abstract <T> T save(T entity);
+
+ public abstract Object saveWithoutFlush(Object entity);
+
+ public abstract boolean contains(Object entity);
+
+ public abstract void save(Object... entities);
+
+ public abstract Object merge(Object entity);
+
+ public abstract void remove(Object entity);
+
+ public abstract void removeWithoutFlush(Object entity);
+
+ public abstract <T> T reattach(Class<T> entityClass, Object primaryKey);
+
+ public abstract Query createQuery(String hql);
+
+ public abstract Query createNativeQuery(String sql);
+
+ public abstract <T> T getSingleResult(Query query, T defaultValue);
+
+ public abstract <T> T getEntity(Class<T> entityClass, Object id);
+
+ public abstract <T> T getSingleResult(Class<T> entityClass, Object... criterias);
+
+ public abstract <T> List<T> getResults(Class<T> entityClass, Object... criterias);
+
+ public abstract <T> List<T> getResults(Class<T> entityClass);
+}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/rules/Violation.java b/sonar-plugin-api/src/main/java/org/sonar/api/rules/Violation.java
index fd2b06ec1c2..3e4aa063a8b 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/rules/Violation.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/rules/Violation.java
@@ -1,253 +1,253 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2011 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * Sonar is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
- */
-package org.sonar.api.rules;
-
-import org.apache.commons.lang.builder.EqualsBuilder;
-import org.apache.commons.lang.builder.HashCodeBuilder;
-import org.apache.commons.lang.builder.ReflectionToStringBuilder;
-import org.sonar.api.resources.Resource;
-
-import java.util.Date;
-
-/**
- * A class that represents a violation. A violation happens when a resource does not respect a defined rule.
- */
-public class Violation {
-
- private Resource resource;
- private Rule rule;
- private String message;
- private RulePriority severity;
- private Integer lineId;
- private Double cost;
- private Date createdAt;
- private boolean switchedOff;
-
- /**
- * Creates of a violation from a rule. Will need to define the resource later on
- *
- * @deprecated since 2.3. Use the factory method create()
- */
- @Deprecated
- public Violation(Rule rule) {
- this.rule = rule;
- }
-
- /**
- * Creates a fully qualified violation
- *
- * @param rule
- * the rule that has been violated
- * @param resource
- * the resource the violation should be attached to
- * @deprecated since 2.3. Use the factory method create()
- */
- @Deprecated
- public Violation(Rule rule, Resource resource) {
- this.resource = resource;
- this.rule = rule;
- }
-
- public Resource getResource() {
- return resource;
- }
-
- /**
- * Sets the resource the violation applies to
- *
- * @return the current object
- */
- public Violation setResource(Resource resource) {
- this.resource = resource;
- return this;
- }
-
- public Rule getRule() {
- return rule;
- }
-
- /**
- * Sets the rule violated
- *
- * @return the current object
- */
- public Violation setRule(Rule rule) {
- this.rule = rule;
- return this;
- }
-
- public String getMessage() {
- return message;
- }
-
- /**
- * Sets the violation message
- *
- * @return the current object
- */
- public Violation setMessage(String message) {
- this.message = message;
- return this;
- }
-
- /**
- * @see #setLineId(Integer)
- */
- public Integer getLineId() {
- return lineId;
- }
-
- /**
- * Sets the violation line. Note that numbering starts from 1.
- *
- * @return the current object
- */
- public Violation setLineId(Integer lineId) {
- this.lineId = lineId;
- return this;
- }
-
- /**
- * @since 2.5
- */
- public RulePriority getSeverity() {
- return severity;
- }
-
- /**
- * For internal use only.
- *
- * @since 2.5
- */
- public Violation setSeverity(RulePriority severity) {
- this.severity = severity;
- return this;
- }
-
- /**
- * @deprecated since 2.5 use {@link #getSeverity()} instead. See http://jira.codehaus.org/browse/SONAR-1829
- */
- @Deprecated
- public RulePriority getPriority() {
- return severity;
- }
-
- /**
- * For internal use only
- *
- * @deprecated since 2.5 use {@link #setSeverity(RulePriority)} instead. See http://jira.codehaus.org/browse/SONAR-1829
- */
- @Deprecated
- public Violation setPriority(RulePriority priority) {
- this.severity = priority;
- return this;
- }
-
- /**
- * @see #setCost(Double)
- * @since 2.4
- */
- public Double getCost() {
- return cost;
- }
-
- /**
- * The cost to fix a violation can't be precisely computed without this information. Let's take the following example : a rule forbids to
- * have methods whose complexity is greater than 10. Without this field "cost", the same violation is created with a method whose
- * complexity is 15 and a method whose complexity is 100. If the cost to fix one point of complexity is 0.05h, then 15mn is necessary to
- * fix the method whose complexity is 15, and 3h5mn is required to fix the method whose complexity is 100.
- *
- * @since 2.4
- */
- public Violation setCost(Double d) {
- this.cost = d;
- return this;
- }
-
- /**
- * @since 2.5
- */
- public Date getCreatedAt() {
- return createdAt;
- }
-
- /**
- * For internal use only
- *
- * @since 2.5
- */
- public Violation setCreatedAt(Date createdAt) {
- this.createdAt = createdAt;
- return this;
- }
-
- /**
- * Switches off the current violation. This is a kind of "mute", which means the violation exists but won't be counted as an active
- * violation (and thus, won't be counted in the total number of violations).
- *
- * @since 2.8
- * @param switchedOff
- * if true, the violation is considered OFF
- */
- public void setSwitchedOff(boolean switchedOff) {
- this.switchedOff = switchedOff;
- }
-
- /**
- * Tells wether this violation is ON or OFF.
- *
- * @since 2.8
- * @return true if the violation has been switched off
- */
- public boolean isSwitchedOff() {
- return switchedOff;
- }
-
- @Override
- public boolean equals(Object obj) {
- if ( !(obj instanceof Violation)) {
- return false;
- }
- if (this == obj) {
- return true;
- }
- Violation other = (Violation) obj;
- return new EqualsBuilder().append(rule, other.getRule()).append(resource, other.getResource()).isEquals();
- }
-
- @Override
- public int hashCode() {
- return new HashCodeBuilder(17, 37).append(getRule()).append(getResource()).toHashCode();
- }
-
- @Override
- public String toString() {
- return ReflectionToStringBuilder.toString(this);
- }
-
- public static Violation create(ActiveRule activeRule, Resource resource) {
- return new Violation(activeRule.getRule()).setResource(resource);
- }
-
- public static Violation create(Rule rule, Resource resource) {
- return new Violation(rule).setResource(resource);
- }
-
-}
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * Sonar is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.api.rules;
+
+import org.apache.commons.lang.builder.EqualsBuilder;
+import org.apache.commons.lang.builder.HashCodeBuilder;
+import org.apache.commons.lang.builder.ReflectionToStringBuilder;
+import org.sonar.api.resources.Resource;
+
+import java.util.Date;
+
+/**
+ * A class that represents a violation. A violation happens when a resource does not respect a defined rule.
+ */
+public class Violation {
+
+ private Resource resource;
+ private Rule rule;
+ private String message;
+ private RulePriority severity;
+ private Integer lineId;
+ private Double cost;
+ private Date createdAt;
+ private boolean switchedOff;
+
+ /**
+ * Creates of a violation from a rule. Will need to define the resource later on
+ *
+ * @deprecated since 2.3. Use the factory method create()
+ */
+ @Deprecated
+ public Violation(Rule rule) {
+ this.rule = rule;
+ }
+
+ /**
+ * Creates a fully qualified violation
+ *
+ * @param rule
+ * the rule that has been violated
+ * @param resource
+ * the resource the violation should be attached to
+ * @deprecated since 2.3. Use the factory method create()
+ */
+ @Deprecated
+ public Violation(Rule rule, Resource resource) {
+ this.resource = resource;
+ this.rule = rule;
+ }
+
+ public Resource getResource() {
+ return resource;
+ }
+
+ /**
+ * Sets the resource the violation applies to
+ *
+ * @return the current object
+ */
+ public Violation setResource(Resource resource) {
+ this.resource = resource;
+ return this;
+ }
+
+ public Rule getRule() {
+ return rule;
+ }
+
+ /**
+ * Sets the rule violated
+ *
+ * @return the current object
+ */
+ public Violation setRule(Rule rule) {
+ this.rule = rule;
+ return this;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ /**
+ * Sets the violation message
+ *
+ * @return the current object
+ */
+ public Violation setMessage(String message) {
+ this.message = message;
+ return this;
+ }
+
+ /**
+ * @see #setLineId(Integer)
+ */
+ public Integer getLineId() {
+ return lineId;
+ }
+
+ /**
+ * Sets the violation line. Note that numbering starts from 1.
+ *
+ * @return the current object
+ */
+ public Violation setLineId(Integer lineId) {
+ this.lineId = lineId;
+ return this;
+ }
+
+ /**
+ * @since 2.5
+ */
+ public RulePriority getSeverity() {
+ return severity;
+ }
+
+ /**
+ * For internal use only.
+ *
+ * @since 2.5
+ */
+ public Violation setSeverity(RulePriority severity) {
+ this.severity = severity;
+ return this;
+ }
+
+ /**
+ * @deprecated since 2.5 use {@link #getSeverity()} instead. See http://jira.codehaus.org/browse/SONAR-1829
+ */
+ @Deprecated
+ public RulePriority getPriority() {
+ return severity;
+ }
+
+ /**
+ * For internal use only
+ *
+ * @deprecated since 2.5 use {@link #setSeverity(RulePriority)} instead. See http://jira.codehaus.org/browse/SONAR-1829
+ */
+ @Deprecated
+ public Violation setPriority(RulePriority priority) {
+ this.severity = priority;
+ return this;
+ }
+
+ /**
+ * @see #setCost(Double)
+ * @since 2.4
+ */
+ public Double getCost() {
+ return cost;
+ }
+
+ /**
+ * The cost to fix a violation can't be precisely computed without this information. Let's take the following example : a rule forbids to
+ * have methods whose complexity is greater than 10. Without this field "cost", the same violation is created with a method whose
+ * complexity is 15 and a method whose complexity is 100. If the cost to fix one point of complexity is 0.05h, then 15mn is necessary to
+ * fix the method whose complexity is 15, and 3h5mn is required to fix the method whose complexity is 100.
+ *
+ * @since 2.4
+ */
+ public Violation setCost(Double d) {
+ this.cost = d;
+ return this;
+ }
+
+ /**
+ * @since 2.5
+ */
+ public Date getCreatedAt() {
+ return createdAt;
+ }
+
+ /**
+ * For internal use only
+ *
+ * @since 2.5
+ */
+ public Violation setCreatedAt(Date createdAt) {
+ this.createdAt = createdAt;
+ return this;
+ }
+
+ /**
+ * Switches off the current violation. This is a kind of "mute", which means the violation exists but won't be counted as an active
+ * violation (and thus, won't be counted in the total number of violations).
+ *
+ * @since 2.8
+ * @param switchedOff
+ * if true, the violation is considered OFF
+ */
+ public void setSwitchedOff(boolean switchedOff) {
+ this.switchedOff = switchedOff;
+ }
+
+ /**
+ * Tells wether this violation is ON or OFF.
+ *
+ * @since 2.8
+ * @return true if the violation has been switched off
+ */
+ public boolean isSwitchedOff() {
+ return switchedOff;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if ( !(obj instanceof Violation)) {
+ return false;
+ }
+ if (this == obj) {
+ return true;
+ }
+ Violation other = (Violation) obj;
+ return new EqualsBuilder().append(rule, other.getRule()).append(resource, other.getResource()).isEquals();
+ }
+
+ @Override
+ public int hashCode() {
+ return new HashCodeBuilder(17, 37).append(getRule()).append(getResource()).toHashCode();
+ }
+
+ @Override
+ public String toString() {
+ return ReflectionToStringBuilder.toString(this);
+ }
+
+ public static Violation create(ActiveRule activeRule, Resource resource) {
+ return new Violation(activeRule.getRule()).setResource(resource);
+ }
+
+ public static Violation create(Rule rule, Resource resource) {
+ return new Violation(rule).setResource(resource);
+ }
+
+}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/violations/ViolationQuery.java b/sonar-plugin-api/src/main/java/org/sonar/api/violations/ViolationQuery.java
index e9f5ebdbdfa..10be756b640 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/violations/ViolationQuery.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/violations/ViolationQuery.java
@@ -1,89 +1,89 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2011 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * Sonar is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
- */
-package org.sonar.api.violations;
-
-import org.sonar.api.resources.Resource;
-
-/**
- * Class that allows to query the Sonar index about violations.
- *
- * @since 2.8
- */
-public final class ViolationQuery {
-
- private boolean ignoreSwitchedOff;
- private Resource resource;
-
- /**
- * Use the factory method <code>create()</code>
- */
- ViolationQuery() {
- }
-
- /**
- * Creates a new {@link ViolationQuery} object.
- *
- * @return the new query
- */
- public static ViolationQuery create() {
- return new ViolationQuery();
- }
-
- /**
- * Specifies if the query should returned switched-off violations or not.
- *
- * @param ignore
- * if true, the query will return only active violations.
- * @return the current violation query
- */
- public ViolationQuery ignoreSwitchedOff(boolean ignore) {
- this.ignoreSwitchedOff = ignore;
- return this;
- }
-
- /**
- * Tells if the query should returned switched-off violations or not.
- *
- * @return
- */
- public boolean ignoreSwitchedOff() {
- return ignoreSwitchedOff;
- }
-
- /**
- * Specifies the resource which violations are search from.
- *
- * @param resource
- * the resource
- */
- public ViolationQuery forResource(Resource resource) {
- this.resource = resource;
- return this;
- }
-
- /**
- * Returns the resource which violations are search from.
- *
- * @return the resource
- */
- public Resource getResource() {
- return resource;
- }
-}
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * Sonar is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.api.violations;
+
+import org.sonar.api.resources.Resource;
+
+/**
+ * Class that allows to query the Sonar index about violations.
+ *
+ * @since 2.8
+ */
+public final class ViolationQuery {
+
+ private boolean ignoreSwitchedOff;
+ private Resource resource;
+
+ /**
+ * Use the factory method <code>create()</code>
+ */
+ ViolationQuery() {
+ }
+
+ /**
+ * Creates a new {@link ViolationQuery} object.
+ *
+ * @return the new query
+ */
+ public static ViolationQuery create() {
+ return new ViolationQuery();
+ }
+
+ /**
+ * Specifies if the query should returned switched-off violations or not.
+ *
+ * @param ignore
+ * if true, the query will return only active violations.
+ * @return the current violation query
+ */
+ public ViolationQuery ignoreSwitchedOff(boolean ignore) {
+ this.ignoreSwitchedOff = ignore;
+ return this;
+ }
+
+ /**
+ * Tells if the query should returned switched-off violations or not.
+ *
+ * @return
+ */
+ public boolean ignoreSwitchedOff() {
+ return ignoreSwitchedOff;
+ }
+
+ /**
+ * Specifies the resource which violations are search from.
+ *
+ * @param resource
+ * the resource
+ */
+ public ViolationQuery forResource(Resource resource) {
+ this.resource = resource;
+ return this;
+ }
+
+ /**
+ * Returns the resource which violations are search from.
+ *
+ * @return the resource
+ */
+ public Resource getResource() {
+ return resource;
+ }
+}