reduced duplicate code.
This commit is contained in:
@@ -8,10 +8,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.eclipse.hawkbit.repository.model;
|
package org.eclipse.hawkbit.repository.model;
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
import javax.persistence.Basic;
|
|
||||||
import javax.persistence.Column;
|
|
||||||
import javax.persistence.ConstraintMode;
|
import javax.persistence.ConstraintMode;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.FetchType;
|
import javax.persistence.FetchType;
|
||||||
@@ -29,24 +25,16 @@ import javax.persistence.Table;
|
|||||||
@IdClass(DsMetadataCompositeKey.class)
|
@IdClass(DsMetadataCompositeKey.class)
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "sp_ds_metadata")
|
@Table(name = "sp_ds_metadata")
|
||||||
public class DistributionSetMetadata implements Serializable {
|
public class DistributionSetMetadata extends MetaData {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@Id
|
|
||||||
@Column(name = "meta_key", length = 128)
|
|
||||||
private String key;
|
|
||||||
|
|
||||||
@Column(name = "meta_value", length = 4000)
|
|
||||||
@Basic
|
|
||||||
private String value;
|
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@ManyToOne(fetch = FetchType.LAZY)
|
@ManyToOne(fetch = FetchType.LAZY)
|
||||||
@JoinColumn(name = "ds_id", foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_metadata_ds"))
|
@JoinColumn(name = "ds_id", foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_metadata_ds"))
|
||||||
private DistributionSet distributionSet;
|
private DistributionSet distributionSet;
|
||||||
|
|
||||||
public DistributionSetMetadata() {
|
public DistributionSetMetadata() {
|
||||||
// Default constructor for JPA.
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -57,35 +45,18 @@ public class DistributionSetMetadata implements Serializable {
|
|||||||
* @param value
|
* @param value
|
||||||
*/
|
*/
|
||||||
public DistributionSetMetadata(final String key, final DistributionSet distributionSet, final String value) {
|
public DistributionSetMetadata(final String key, final DistributionSet distributionSet, final String value) {
|
||||||
this.key = key;
|
super(key, value);
|
||||||
this.distributionSet = distributionSet;
|
this.distributionSet = distributionSet;
|
||||||
this.value = value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public DsMetadataCompositeKey getId() {
|
public DsMetadataCompositeKey getId() {
|
||||||
return new DsMetadataCompositeKey(distributionSet, key);
|
return new DsMetadataCompositeKey(distributionSet, getKey());
|
||||||
}
|
|
||||||
|
|
||||||
public String getKey() {
|
|
||||||
return key;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setKey(final String key) {
|
|
||||||
this.key = key;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDistributionSet(final DistributionSet distributionSet) {
|
public void setDistributionSet(final DistributionSet distributionSet) {
|
||||||
this.distributionSet = distributionSet;
|
this.distributionSet = distributionSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getValue() {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setValue(final String value) {
|
|
||||||
this.value = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DistributionSet getDistributionSet() {
|
public DistributionSet getDistributionSet() {
|
||||||
return distributionSet;
|
return distributionSet;
|
||||||
}
|
}
|
||||||
@@ -93,9 +64,8 @@ public class DistributionSetMetadata implements Serializable {
|
|||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
final int prime = 31;
|
final int prime = 31;
|
||||||
int result = 1;
|
int result = super.hashCode();
|
||||||
result = prime * result + (distributionSet == null ? 0 : distributionSet.hashCode());
|
result = prime * result + ((distributionSet == null) ? 0 : distributionSet.hashCode());
|
||||||
result = prime * result + (key == null ? 0 : key.hashCode());
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,7 +74,7 @@ public class DistributionSetMetadata implements Serializable {
|
|||||||
if (this == obj) {
|
if (this == obj) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (obj == null) {
|
if (!super.equals(obj)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!(obj instanceof DistributionSetMetadata)) {
|
if (!(obj instanceof DistributionSetMetadata)) {
|
||||||
@@ -118,14 +88,6 @@ public class DistributionSetMetadata implements Serializable {
|
|||||||
} else if (!distributionSet.equals(other.distributionSet)) {
|
} else if (!distributionSet.equals(other.distributionSet)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (key == null) {
|
|
||||||
if (other.key != null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} else if (!key.equals(other.key)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,98 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
|
||||||
|
*
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*/
|
||||||
|
package org.eclipse.hawkbit.repository.model;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
import javax.persistence.Basic;
|
||||||
|
import javax.persistence.Column;
|
||||||
|
import javax.persistence.Id;
|
||||||
|
import javax.persistence.MappedSuperclass;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Meta data for entities.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@MappedSuperclass
|
||||||
|
public abstract class MetaData implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@Column(name = "meta_key", length = 128)
|
||||||
|
private String key;
|
||||||
|
|
||||||
|
@Column(name = "meta_value", length = 4000)
|
||||||
|
@Basic
|
||||||
|
private String value;
|
||||||
|
|
||||||
|
public MetaData(final String key, final String value) {
|
||||||
|
super();
|
||||||
|
this.key = key;
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MetaData() {
|
||||||
|
// Default constructor needed for JPA entities
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getKey() {
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setKey(final String key) {
|
||||||
|
this.key = key;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValue(final String value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = 1;
|
||||||
|
result = prime * result + ((key == null) ? 0 : key.hashCode());
|
||||||
|
result = prime * result + ((value == null) ? 0 : value.hashCode());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(final Object obj) {
|
||||||
|
if (this == obj) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (obj == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!(obj instanceof MetaData)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
final MetaData other = (MetaData) obj;
|
||||||
|
if (key == null) {
|
||||||
|
if (other.key != null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else if (!key.equals(other.key)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (value == null) {
|
||||||
|
if (other.value != null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else if (!value.equals(other.value)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -8,9 +8,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.eclipse.hawkbit.repository.model;
|
package org.eclipse.hawkbit.repository.model;
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
import javax.persistence.Column;
|
|
||||||
import javax.persistence.ConstraintMode;
|
import javax.persistence.ConstraintMode;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.FetchType;
|
import javax.persistence.FetchType;
|
||||||
@@ -28,16 +25,9 @@ import javax.persistence.Table;
|
|||||||
@IdClass(SwMetadataCompositeKey.class)
|
@IdClass(SwMetadataCompositeKey.class)
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "sp_sw_metadata")
|
@Table(name = "sp_sw_metadata")
|
||||||
public class SoftwareModuleMetadata implements Serializable {
|
public class SoftwareModuleMetadata extends MetaData {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@Id
|
|
||||||
@Column(name = "meta_key", length = 128)
|
|
||||||
private String key;
|
|
||||||
|
|
||||||
@Column(name = "meta_value", length = 4000)
|
|
||||||
private String value;
|
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@ManyToOne(targetEntity = SoftwareModule.class, fetch = FetchType.LAZY)
|
@ManyToOne(targetEntity = SoftwareModule.class, fetch = FetchType.LAZY)
|
||||||
@JoinColumn(name = "sw_id", foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_metadata_sw"))
|
@JoinColumn(name = "sw_id", foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_metadata_sw"))
|
||||||
@@ -47,7 +37,7 @@ public class SoftwareModuleMetadata implements Serializable {
|
|||||||
* Default constructor for JPA.
|
* Default constructor for JPA.
|
||||||
*/
|
*/
|
||||||
public SoftwareModuleMetadata() {
|
public SoftwareModuleMetadata() {
|
||||||
// default constructor for JPA.
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -60,21 +50,12 @@ public class SoftwareModuleMetadata implements Serializable {
|
|||||||
* of the meta data element
|
* of the meta data element
|
||||||
*/
|
*/
|
||||||
public SoftwareModuleMetadata(final String key, final SoftwareModule softwareModule, final String value) {
|
public SoftwareModuleMetadata(final String key, final SoftwareModule softwareModule, final String value) {
|
||||||
this.key = key;
|
super(key, value);
|
||||||
this.softwareModule = softwareModule;
|
this.softwareModule = softwareModule;
|
||||||
this.value = value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public SwMetadataCompositeKey getId() {
|
public SwMetadataCompositeKey getId() {
|
||||||
return new SwMetadataCompositeKey(softwareModule, key);
|
return new SwMetadataCompositeKey(softwareModule, getKey());
|
||||||
}
|
|
||||||
|
|
||||||
public String getValue() {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setValue(final String value) {
|
|
||||||
this.value = value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public SoftwareModule getSoftwareModule() {
|
public SoftwareModule getSoftwareModule() {
|
||||||
@@ -85,24 +66,10 @@ public class SoftwareModuleMetadata implements Serializable {
|
|||||||
this.softwareModule = softwareModule;
|
this.softwareModule = softwareModule;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getKey() {
|
|
||||||
return key;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setKey(final String key) {
|
|
||||||
this.key = key;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "SoftwareModuleMetadata [key=" + key + ", value=" + value + ", softwareModule=" + softwareModule + "]";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
final int prime = 31;
|
final int prime = 31;
|
||||||
int result = 1;
|
int result = super.hashCode();
|
||||||
result = prime * result + ((key == null) ? 0 : key.hashCode());
|
|
||||||
result = prime * result + ((softwareModule == null) ? 0 : softwareModule.hashCode());
|
result = prime * result + ((softwareModule == null) ? 0 : softwareModule.hashCode());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -112,20 +79,13 @@ public class SoftwareModuleMetadata implements Serializable {
|
|||||||
if (this == obj) {
|
if (this == obj) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (obj == null) {
|
if (!super.equals(obj)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!(obj instanceof SoftwareModuleMetadata)) {
|
if (!(obj instanceof SoftwareModuleMetadata)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final SoftwareModuleMetadata other = (SoftwareModuleMetadata) obj;
|
final SoftwareModuleMetadata other = (SoftwareModuleMetadata) obj;
|
||||||
if (key == null) {
|
|
||||||
if (other.key != null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} else if (!key.equals(other.key)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (softwareModule == null) {
|
if (softwareModule == null) {
|
||||||
if (other.softwareModule != null) {
|
if (other.softwareModule != null) {
|
||||||
return false;
|
return false;
|
||||||
@@ -135,5 +95,4 @@ public class SoftwareModuleMetadata implements Serializable {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user