diff options
Diffstat (limited to 'sonar-plugin-api')
7 files changed, 1 insertions, 316 deletions
diff --git a/sonar-plugin-api/pom.xml b/sonar-plugin-api/pom.xml index c8d352db49a..bb4634befcb 100644 --- a/sonar-plugin-api/pom.xml +++ b/sonar-plugin-api/pom.xml @@ -124,28 +124,6 @@ <artifactId>jsr305</artifactId> <scope>provided</scope> </dependency> - - - <!-- TODO we can't remove hibernate-annotations, because currently it's used - moreover it contains transitive dependency on dom4j, which is used in some plugins - --> - <dependency> - <groupId>org.hibernate</groupId> - <artifactId>hibernate-annotations</artifactId> - <scope>provided</scope> - <exclusions> - <exclusion> - <groupId>org.hibernate</groupId> - <artifactId>hibernate-core</artifactId> - </exclusion> - <exclusion> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-api</artifactId> - </exclusion> - </exclusions> - </dependency> - - <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/RequiresDB.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/RequiresDB.java deleted file mode 100644 index 8e42b40ab1e..00000000000 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/RequiresDB.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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 this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.api.batch; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * The presence of this annotation on an extension class indicates that the extension - * requires database access. As a result such extension will be disabled in preview mode. - * - * - * @since 5.1 - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.TYPE) -public @interface RequiresDB { -} diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/database/BaseIdentifiable.java b/sonar-plugin-api/src/main/java/org/sonar/api/database/BaseIdentifiable.java index a1a4eb688c3..92198acc80b 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/database/BaseIdentifiable.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/database/BaseIdentifiable.java @@ -19,17 +19,8 @@ */ package org.sonar.api.database; -import javax.persistence.Column; -import javax.persistence.GeneratedValue; -import javax.persistence.Id; -import javax.persistence.MappedSuperclass; - -@MappedSuperclass public class BaseIdentifiable<G> { - @Id - @Column(name = "id") - @GeneratedValue private Integer id; public Integer getId() { 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 deleted file mode 100644 index 4e9f696baa7..00000000000 --- a/sonar-plugin-api/src/main/java/org/sonar/api/database/DatabaseSession.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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 this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.api.database; - -import org.sonar.api.batch.BatchSide; - -import javax.persistence.EntityManager; -import javax.persistence.Query; - -import java.util.List; - -/** - * This component should not be accessed by plugins. Database is not an API. - * - * @since 1.10 - */ -@BatchSide -public abstract class DatabaseSession { - - // 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(); - - /** - * This method should be called before a long period were database will not be accessed - * in order to close database connection and avoid timeout. Next use of the - * database will automatically open a new connection. - */ - public abstract void commitAndClose(); - - 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/database/model/ResourceModel.java b/sonar-plugin-api/src/main/java/org/sonar/api/database/model/ResourceModel.java index b66e440dba8..942b9657ab4 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/database/model/ResourceModel.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/database/model/ResourceModel.java @@ -22,22 +22,12 @@ package org.sonar.api.database.model; import java.io.Serializable; import java.util.Date; import javax.annotation.Nullable; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Table; -import javax.persistence.Temporal; -import javax.persistence.TemporalType; import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.builder.EqualsBuilder; import org.apache.commons.lang.builder.HashCodeBuilder; import org.apache.commons.lang.builder.ToStringBuilder; import org.sonar.api.database.BaseIdentifiable; -/** - * Class to map resource with hibernate model - */ -@Entity -@Table(name = "projects") public class ResourceModel extends BaseIdentifiable implements Cloneable, Serializable { public static final String SCOPE_PROJECT = "PRJ"; @@ -48,59 +38,23 @@ public class ResourceModel extends BaseIdentifiable implements Cloneable, Serial public static final int KEY_SIZE = 400; public static final int PATH_SIZE = 2000; - @Column(name = "name", updatable = true, nullable = true, length = NAME_COLUMN_SIZE) private String name; - - @Column(name = "long_name", updatable = true, nullable = true, length = NAME_COLUMN_SIZE) private String longName; - - @Column(name = "description", updatable = true, nullable = true, length = DESCRIPTION_COLUMN_SIZE) private String description; - - @Column(name = "enabled", updatable = true, nullable = false) private Boolean enabled = Boolean.TRUE; - - @Column(name = "scope", updatable = true, nullable = false, length = 3) private String scope; - - @Column(name = "qualifier", updatable = true, nullable = false, length = 10) private String qualifier; - - @Column(name = "kee", updatable = true, nullable = false, length = KEY_SIZE) private String key; - - @Column(name = "deprecated_kee", updatable = true, nullable = true, length = KEY_SIZE) private String deprecatedKey; - - @Column(name = "language", updatable = true, nullable = true, length = 20) private String languageKey; - - @Column(name = "root_id", updatable = true, nullable = true) private Integer rootId; - - @Column(name = "path", updatable = true, nullable = true, length = PATH_SIZE) private String path; - - @Column(name = "copy_resource_id", updatable = true, nullable = true) private Integer copyResourceId; - - @Column(name = "person_id", updatable = true, nullable = true) private Integer personId; - - @Temporal(TemporalType.TIMESTAMP) - @Column(name = "created_at", updatable = true, nullable = true) private Date createdAt; - - @Column(name = "uuid", updatable = false, nullable = true, length = 50) private String uuid; - - @Column(name = "project_uuid", updatable = true, nullable = true, length = 50) private String projectUuid; - - @Column(name = "module_uuid", updatable = true, nullable = true, length = 50) private String moduleUuid; - - @Column(name = "module_uuid_path", updatable = true, nullable = true, length = 4000) private String moduleUuidPath; /** diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/database/model/Snapshot.java b/sonar-plugin-api/src/main/java/org/sonar/api/database/model/Snapshot.java index 3faf0a24764..a8294b03edc 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/database/model/Snapshot.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/database/model/Snapshot.java @@ -21,9 +21,6 @@ package org.sonar.api.database.model; import java.io.Serializable; import java.util.Date; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Table; import org.apache.commons.lang.builder.EqualsBuilder; import org.apache.commons.lang.builder.HashCodeBuilder; import org.apache.commons.lang.builder.ReflectionToStringBuilder; @@ -33,11 +30,6 @@ import org.sonar.api.database.BaseIdentifiable; import static org.sonar.api.utils.DateUtils.dateToLong; import static org.sonar.api.utils.DateUtils.longToDate; -/** - * A class to map a snapshot with its hibernate model - */ -@Entity -@Table(name = "snapshots") public class Snapshot extends BaseIdentifiable<Snapshot> implements Serializable { /** @@ -50,91 +42,34 @@ public class Snapshot extends BaseIdentifiable<Snapshot> implements Serializable */ public static final String STATUS_PROCESSED = "P"; - @Column(name = "project_id", updatable = true, nullable = true) private Integer resourceId; - - @Column(name = "build_date", updatable = true, nullable = true) private Long buildDate; - - @Column(name = "created_at", updatable = true, nullable = true) private Long createdAt; - - @Column(name = "version", updatable = true, nullable = true, length = 500) private String version; - - @Column(name = "islast") private Boolean last = Boolean.FALSE; - - @Column(name = "status") private String status = STATUS_UNPROCESSED; - - @Column(name = "purge_status", updatable = true, nullable = true) private Integer purgeStatus; - - @Column(name = "scope", updatable = true, nullable = true, length = 3) private String scope; - - @Column(name = "path", updatable = true, nullable = true, length = 500) private String path; - - @Column(name = "depth", updatable = true, nullable = true) private Integer depth; - - @Column(name = "qualifier", updatable = true, nullable = true, length = 10) private String qualifier; - - @Column(name = "root_snapshot_id", updatable = true, nullable = true) private Integer rootId; - - @Column(name = "parent_snapshot_id", updatable = true, nullable = true) private Integer parentId; - - @Column(name = "root_project_id", updatable = true, nullable = true) private Integer rootProjectId; - - @Column(name = "period1_mode", updatable = true, nullable = true, length = 100) private String period1Mode; - - @Column(name = "period2_mode", updatable = true, nullable = true, length = 100) private String period2Mode; - - @Column(name = "period3_mode", updatable = true, nullable = true, length = 100) private String period3Mode; - - @Column(name = "period4_mode", updatable = true, nullable = true, length = 100) private String period4Mode; - - @Column(name = "period5_mode", updatable = true, nullable = true, length = 100) private String period5Mode; - - @Column(name = "period1_param", updatable = true, nullable = true, length = 100) private String period1Param; - - @Column(name = "period2_param", updatable = true, nullable = true, length = 100) private String period2Param; - - @Column(name = "period3_param", updatable = true, nullable = true, length = 100) private String period3Param; - - @Column(name = "period4_param", updatable = true, nullable = true, length = 100) private String period4Param; - - @Column(name = "period5_param", updatable = true, nullable = true, length = 100) private String period5Param; - - @Column(name = "period1_date", updatable = true, nullable = true) private Long period1Date; - - @Column(name = "period2_date", updatable = true, nullable = true) private Long period2Date; - - @Column(name = "period3_date", updatable = true, nullable = true) private Long period3Date; - - @Column(name = "period4_date", updatable = true, nullable = true) private Long period4Date; - - @Column(name = "period5_date", updatable = true, nullable = true) private Long period5Date; public Snapshot() { diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/measures/Metric.java b/sonar-plugin-api/src/main/java/org/sonar/api/measures/Metric.java index 57f3fec83a2..8e54fe1c7bc 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/measures/Metric.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/measures/Metric.java @@ -27,14 +27,6 @@ import java.util.List; import javax.annotation.CheckForNull; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.EnumType; -import javax.persistence.Enumerated; -import javax.persistence.GeneratedValue; -import javax.persistence.Id; -import javax.persistence.Table; -import javax.persistence.Transient; import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.builder.ReflectionToStringBuilder; import org.apache.commons.lang.builder.ToStringStyle; @@ -42,13 +34,6 @@ import org.sonar.api.batch.BatchSide; import org.sonar.api.batch.InstantiationStrategy; import org.sonar.api.server.ServerSide; -/** - * This class represents the definition of a metric in Sonar. - * - * @since 1.10 - */ -@Table(name = "metrics") -@Entity(name = "Metric") @BatchSide @InstantiationStrategy(InstantiationStrategy.PER_BATCH) @ServerSide @@ -125,55 +110,21 @@ public class Metric<G extends Serializable> implements Serializable, org.sonar.a } } - @Id - @Column(name = "id") - @GeneratedValue private Integer id; - - @Transient private transient Formula formula; - - @Column(name = "name", updatable = false, nullable = false, length = 64) private String key; - - @Column(name = "description", updatable = true, nullable = true, length = 255) private String description; - - @Column(name = "val_type", updatable = true, nullable = true) - @Enumerated(EnumType.STRING) private ValueType type; - - @Column(name = "direction", updatable = true, nullable = true) private Integer direction; - - @Column(name = "domain", updatable = true, nullable = true, length = 60) private String domain; - - @Column(name = "short_name", updatable = true, nullable = true, length = 64) private String name; - - @Column(name = "qualitative", updatable = true, nullable = true) private Boolean qualitative = Boolean.FALSE; - - @Column(name = "user_managed", updatable = true, nullable = true) private Boolean userManaged = Boolean.FALSE; - - @Column(name = "enabled", updatable = true, nullable = true) private Boolean enabled = Boolean.TRUE; - - @Column(name = "worst_value", updatable = true, nullable = true, precision = 30, scale = 20) private Double worstValue; - - @Column(name = "best_value", updatable = true, nullable = true, precision = 30, scale = 20) private Double bestValue; - - @Column(name = "optimized_best_value", updatable = true, nullable = true) private Boolean optimizedBestValue; - - @Column(name = "hidden", updatable = true, nullable = true) private Boolean hidden = Boolean.FALSE; - - @Column(name = "delete_historical_data", updatable = true, nullable = true) private Boolean deleteHistoricalData; private Metric(Builder builder) { @@ -195,7 +146,7 @@ public class Metric<G extends Serializable> implements Serializable, org.sonar.a } /** - * Creates an empty metric. Required for Hibernate. + * Creates an empty metric * * @deprecated in 1.12. Use the {@link Builder} factory. */ |