import java.util.Date;
import java.util.Objects;
import javax.persistence.Basic;
+import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlTransient;
/**
*
* @author F62173
*/
@Entity(name = "File")
-@Table(name = "file")
+@Table(name = "gde_file")
@XmlRootElement
@NamedQueries({
@NamedQuery(name = "File.findAll", query = "SELECT f FROM File f"),
})
public class GDEFile implements Serializable {
private static final long serialVersionUID = 1L;
-
@Id
@Basic(optional = false)
@NotNull
@Column(name = "deletion_date")
@Temporal(TemporalType.TIMESTAMP)
private Date deletionDate;
- //@JoinColumn(name = "group_id", referencedColumnName = "id", nullable = false)
- @Column(name = "group_id", nullable = false)
- //@ManyToOne
- private long groupId;
- @OneToMany
- private Collection<Chunk> chunks;
-
+ @OneToMany(cascade = CascadeType.ALL)
+ private Collection<Chunk> chunkCollection;
+ @Column(name = "attribute_group_id")
+ private long attributeGroupId;
+
public GDEFile() {
}
this.deletionDate = deletionDate;
}
- public long getGroupId() {
- return groupId;
+ @XmlTransient
+ public Collection<Chunk> getChunkCollection() {
+ return chunkCollection;
}
- public void setGroupId(long groupId) {
- this.groupId = groupId;
+ public void setChunkCollection(Collection<Chunk> chunkCollection) {
+ this.chunkCollection = chunkCollection;
}
- public Collection<Chunk> getChunks() {
- return chunks;
+ public long getAttributeGroupId() {
+ return attributeGroupId;
}
- public void setChunks(Collection<Chunk> chunks) {
- this.chunks = chunks;
+ public void setAttributeGroupId(long attributeGroupId) {
+ this.attributeGroupId = attributeGroupId;
}
public static GDEFile fromFileTO(FileTO fto) {
GDEFile f = new GDEFile();
f.checksum = fto.getChecksum();
- f.chunks = new ArrayList<>();
- Collection<ChunkTO> chunks = fto.getChunks();
+ f.chunkCollection = new ArrayList<>();
+ Collection<ChunkTO> chunks = fto.getChunkCollection();
for (ChunkTO cto : chunks) {
- f.chunks.add(Chunk.fromChunkTO(cto));
+ f.chunkCollection.add(Chunk.fromChunkTO(cto));
}
f.creationDate = fto.getCreationDate();
f.deleted = fto.getDeleted();
f.deletionDate = fto.getDeletionDate();
- f.groupId = fto.getAttributeGroupId();
+ f.attributeGroupId = fto.getAttributeGroupId();
f.id = fto.getId();
f.length = fto.getLength();
f.name = fto.getName();
fto.setChecksum(this.checksum);
Collection<ChunkTO> ctos = new ArrayList<>();
- for (Chunk c : this.chunks) {
+ for (Chunk c : this.chunkCollection) {
ctos.add(c.toChunkTO());
}
- fto.setChunks(ctos);
+ fto.setChunkCollection(ctos);
fto.setCreationDate(this.creationDate);
fto.setDeleted(this.deleted);
fto.setDeletionDate(this.deletionDate);
- fto.setAttributeGroupId(this.groupId);
+ fto.setAttributeGroupId(this.attributeGroupId);
fto.setId(this.id);
fto.setLength(this.length);
fto.setName(this.name);
@Override
public String toString() {
- return "com.edf.gde.entities.File[ id=" + id + " ]";
+ return "com.edf.gde.entities.GDEFile[ id=" + id + " ]";
}
@Override
public int hashCode() {
- int hash = 5;
- hash = 41 * hash + (int) (this.id ^ (this.id >>> 32));
- hash = 41 * hash + Objects.hashCode(this.name);
- hash = 41 * hash + (int) (this.length ^ (this.length >>> 32));
- hash = 41 * hash + Objects.hashCode(this.checksum);
- hash = 41 * hash + Objects.hashCode(this.creationDate);
- hash = 41 * hash + Objects.hashCode(this.updateDate);
- hash = 41 * hash + Objects.hashCode(this.valid);
- hash = 41 * hash + Objects.hashCode(this.deleted);
- hash = 41 * hash + Objects.hashCode(this.deletionDate);
- hash = 41 * hash + (int) (this.groupId ^ (this.groupId >>> 32));
- hash = 41 * hash + Objects.hashCode(this.chunks);
+ int hash = 3;
+ hash = 29 * hash + (int) (this.id ^ (this.id >>> 32));
+ hash = 29 * hash + Objects.hashCode(this.name);
+ hash = 29 * hash + (int) (this.length ^ (this.length >>> 32));
+ hash = 29 * hash + Objects.hashCode(this.checksum);
+ hash = 29 * hash + Objects.hashCode(this.creationDate);
+ hash = 29 * hash + Objects.hashCode(this.updateDate);
+ hash = 29 * hash + Objects.hashCode(this.valid);
+ hash = 29 * hash + Objects.hashCode(this.deleted);
+ hash = 29 * hash + Objects.hashCode(this.deletionDate);
+ hash = 29 * hash + Objects.hashCode(this.chunkCollection);
+ hash = 29 * hash + (int) (this.attributeGroupId ^ (this.attributeGroupId >>> 32));
return hash;
}