/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
+ * (C) 2015 EDF
*/
package com.edf.gde.entities;
-import com.edf.gde.transferables.ChunkTO;
import com.edf.gde.transferables.FileTO;
import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Collection;
import java.util.Date;
import java.util.Objects;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
-import javax.persistence.OneToMany;
+import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
* @author F62173
*/
@Entity(name = "File")
-@Table(name = "file")
+@Table(name = "gde_file")
@XmlRootElement
@NamedQueries({
@NamedQuery(name = "File.findAll", query = "SELECT f FROM File f"),
@NamedQuery(name = "File.findById", query = "SELECT f FROM File f WHERE f.id = :id"),
@NamedQuery(name = "File.findByName", query = "SELECT f FROM File f WHERE f.name = :name"),
- //@NamedQuery(name = "File.findByLength", query = "SELECT f FROM File f WHERE f.length = :length"),
- //@NamedQuery(name = "File.findByChecksum", query = "SELECT f FROM File f WHERE f.checksum = :checksum"),
@NamedQuery(name = "File.findByCreationDate", query = "SELECT f FROM File f WHERE f.creationDate = :creationDate"),
@NamedQuery(name = "File.findByUpdateDate", query = "SELECT f FROM File f WHERE f.updateDate = :updateDate"),
- //@NamedQuery(name = "File.findByValid", query = "SELECT f FROM File f WHERE f.valid = :valid"),
- //@NamedQuery(name = "File.findByDeleted", query = "SELECT f FROM File f WHERE f.deleted = :deleted"),
@NamedQuery(name = "File.findByDeletionDate", query = "SELECT f FROM File f WHERE f.deletionDate = :deletionDate")
})
public class GDEFile implements Serializable {
private static final long serialVersionUID = 1L;
-
@Id
@Basic(optional = false)
@NotNull
@Column(name = "id")
+ @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_GEN_SEQUENCE")
+ @SequenceGenerator(name = "SEQ_GEN_SEQUENCE", allocationSize = 50)
private long id;
@Size(max = 255)
@Column(name = "name")
@Temporal(TemporalType.TIMESTAMP)
private Date updateDate;
@Column(name = "valid")
- private Boolean valid;
+ private boolean valid;
@Column(name = "deleted")
- private Boolean deleted;
+ private boolean deleted;
@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;
+ @Column(name = "attribute_group_id")
+ private long attributeGroupId;
+ @Column(name = "data_profile_id")
+ private long dataProfileId;
+ // No member for chunks: data are accessed with SQL requests
public GDEFile() {
}
this.updateDate = updateDate;
}
- public Boolean getValid() {
+ public boolean isValid() {
return valid;
}
- public void setValid(Boolean valid) {
+ public void setValid(boolean valid) {
this.valid = valid;
}
- public Boolean getDeleted() {
+ public boolean isDeleted() {
return deleted;
}
- public void setDeleted(Boolean deleted) {
+ public void setDeleted(boolean deleted) {
this.deleted = deleted;
}
this.deletionDate = deletionDate;
}
- public long getGroupId() {
- return groupId;
+ public long getAttributeGroupId() {
+ return attributeGroupId;
}
- public void setGroupId(long groupId) {
- this.groupId = groupId;
+ public void setAttributeGroupId(long attributeGroupId) {
+ this.attributeGroupId = attributeGroupId;
}
- public Collection<Chunk> getChunks() {
- return chunks;
+ public long getDataProfileId() {
+ return dataProfileId;
}
- public void setChunks(Collection<Chunk> chunks) {
- this.chunks = chunks;
+ public void setDataProfileId(long dataProfileId) {
+ this.dataProfileId = dataProfileId;
}
public static GDEFile fromFileTO(FileTO fto) {
GDEFile f = new GDEFile();
f.checksum = fto.getChecksum();
-
- f.chunks = new ArrayList<>();
- Collection<ChunkTO> chunks = fto.getChunks();
- for (ChunkTO cto : chunks) {
- f.chunks.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();
f.updateDate = fto.getUpdateDate();
f.valid = fto.getValid();
+ f.dataProfileId = fto.getDataProfileId();
return f;
}
public FileTO toFileTO() {
FileTO fto = new FileTO();
fto.setChecksum(this.checksum);
-
- Collection<ChunkTO> ctos = new ArrayList<>();
- for (Chunk c : this.chunks) {
- ctos.add(c.toChunkTO());
- }
- fto.setChunks(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);
fto.setUpdateDate(this.updateDate);
fto.setValid(this.valid);
+ fto.setDataProfileId(this.dataProfileId);
return fto;
}
@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);
+ hash = 23 * hash + (int) (this.id ^ (this.id >>> 32));
+ hash = 23 * hash + Objects.hashCode(this.name);
+ hash = 23 * hash + (int) (this.length ^ (this.length >>> 32));
+ hash = 23 * hash + Objects.hashCode(this.checksum);
+ hash = 23 * hash + Objects.hashCode(this.creationDate);
+ hash = 23 * hash + Objects.hashCode(this.updateDate);
+ hash = 23 * hash + Objects.hashCode(this.valid);
+ hash = 23 * hash + Objects.hashCode(this.deleted);
+ hash = 23 * hash + Objects.hashCode(this.deletionDate);
+ hash = 23 * hash + (int) (this.attributeGroupId ^ (this.attributeGroupId >>> 32));
+ hash = 23 * hash + (int) (this.dataProfileId ^ (this.dataProfileId >>> 32));
return hash;
}