From 654cbe68f4214a08381ebbb12e62bc324720061b Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Wed, 20 May 2015 23:39:43 +0200 Subject: [PATCH] Remove Hibernate model Property --- .../api/database/configuration/Property.java | 146 ------------------ .../main/java/org/sonar/api/package-info.java | 24 --- .../main/resources/META-INF/persistence.xml | 1 - .../org/sonar/jpa/entity/PropertyTest.java | 39 ----- 4 files changed, 210 deletions(-) delete mode 100644 sonar-core/src/main/java/org/sonar/api/database/configuration/Property.java delete mode 100644 sonar-core/src/main/java/org/sonar/api/package-info.java delete mode 100644 sonar-core/src/test/java/org/sonar/jpa/entity/PropertyTest.java diff --git a/sonar-core/src/main/java/org/sonar/api/database/configuration/Property.java b/sonar-core/src/main/java/org/sonar/api/database/configuration/Property.java deleted file mode 100644 index 568e97b35d7..00000000000 --- a/sonar-core/src/main/java/org/sonar/api/database/configuration/Property.java +++ /dev/null @@ -1,146 +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.configuration; - -import org.apache.commons.lang.builder.ReflectionToStringBuilder; -import org.apache.commons.lang.builder.ToStringStyle; -import org.sonar.api.database.BaseIdentifiable; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Lob; -import javax.persistence.Table; - -/** - * IMPORTANT : This class can't be moved to org.sonar.jpa.dao for backward-compatibility reasons. - * This class is still used in some plugins. - * - * @since 1.10 - * @deprecated since 5.0 Hibernate is deprecated - */ -@Deprecated -@Entity -@Table(name = "properties") -public class Property extends BaseIdentifiable { - - @Column(name = "prop_key", updatable = true, nullable = true) - private String key; - - @Column(name = "text_value", updatable = true, nullable = true, length = 167772150) - @Lob - private char[] value; - - @Column(name = "resource_id", updatable = true, nullable = true) - private Integer resourceId; - - @Column(name = "user_id", updatable = true, nullable = true) - private Integer userId; - - public Property(String key, String value) { - this(key, value, null); - } - - public Property(String key, String value, Integer resourceId) { - this.key = key; - if (value != null) { - this.value = value.toCharArray(); - - } else { - this.value = null; - } - this.resourceId = resourceId; - } - - public Property() { - } - - public String getKey() { - return key; - } - - public void setKey(String key) { - this.key = key; - } - - public String getValue() { - if (value != null) { - return new String(value); - } - return null; - } - - public void setValue(String value) { - if (value != null) { - this.value = value.toCharArray(); - } else { - this.value = null; - } - } - - public Integer getResourceId() { - return resourceId; - } - - public void setResourceId(Integer resourceId) { - this.resourceId = resourceId; - } - - public Integer getUserId() { - return userId; - } - - public Property setUserId(Integer userId) { - this.userId = userId; - return this; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - - Property property = (Property) o; - if (!key.equals(property.key)) { - return false; - } - if (resourceId != null ? !resourceId.equals(property.resourceId) : property.resourceId != null) { - return false; - } - return !(userId != null ? !userId.equals(property.userId) : property.userId != null); - - } - - @Override - public int hashCode() { - int result = key.hashCode(); - result = 31 * result + (resourceId != null ? resourceId.hashCode() : 0); - result = 31 * result + (userId != null ? userId.hashCode() : 0); - return result; - } - - @Override - public String toString() { - return new ReflectionToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE).toString(); - } -} diff --git a/sonar-core/src/main/java/org/sonar/api/package-info.java b/sonar-core/src/main/java/org/sonar/api/package-info.java deleted file mode 100644 index 8e7e23ac52d..00000000000 --- a/sonar-core/src/main/java/org/sonar/api/package-info.java +++ /dev/null @@ -1,24 +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. - */ - -@ParametersAreNonnullByDefault -package org.sonar.api; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/sonar-core/src/main/resources/META-INF/persistence.xml b/sonar-core/src/main/resources/META-INF/persistence.xml index 7ec76949f11..06f3a3131f5 100644 --- a/sonar-core/src/main/resources/META-INF/persistence.xml +++ b/sonar-core/src/main/resources/META-INF/persistence.xml @@ -7,7 +7,6 @@ org.hibernate.ejb.HibernatePersistence org.sonar.jpa.entity.ManualMeasure - org.sonar.api.database.configuration.Property org.sonar.api.database.model.User org.sonar.api.database.model.Snapshot org.sonar.api.database.model.MeasureModel diff --git a/sonar-core/src/test/java/org/sonar/jpa/entity/PropertyTest.java b/sonar-core/src/test/java/org/sonar/jpa/entity/PropertyTest.java deleted file mode 100644 index 3f4635cca55..00000000000 --- a/sonar-core/src/test/java/org/sonar/jpa/entity/PropertyTest.java +++ /dev/null @@ -1,39 +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.jpa.entity; - -import org.junit.Test; -import org.sonar.api.database.configuration.Property; - -import static org.hamcrest.Matchers.is; -import static org.hamcrest.Matchers.nullValue; -import static org.junit.Assert.assertThat; - -public class PropertyTest { - - @Test - public void encodeBlob() { - Property prop = new Property("key1", "value1"); - assertThat(prop.getValue(), is("value1")); - - prop.setValue(null); - assertThat(prop.getValue(), nullValue()); - } -} -- 2.39.5