From 42759e578f13c7647e60889c6088d1309e535456 Mon Sep 17 00:00:00 2001 From: =?utf8?q?C=C3=A9dric=20Aguerre?= Date: Wed, 15 Jul 2015 10:11:20 +0200 Subject: [PATCH] Add study --- .../src/java/com/edf/gde/ejb/MetadataDAO.java | 98 ++++++++- .../src/java/com/edf/gde/ejb/StudyDAO.java | 57 +++++ .../java/com/edf/gde/entities/Attribute.java | 44 ++-- .../com/edf/gde/entities/AttributeGroup.java | 31 ++- .../java/com/edf/gde/entities/GDEFile.java | 74 +++---- .../src/java/com/edf/gde/entities/Study.java | 201 ++++++++++++++++++ .../com/edf/gde/transferables/FileTO.java | 16 +- .../com/edf/gde/transferables/StudyTO.java | 106 +++++++++ projects/GDE_App/nbproject/project.properties | 3 +- projects/GDE_App/src/GDE_DB_Init.sql | 57 +++-- 10 files changed, 603 insertions(+), 84 deletions(-) create mode 100644 projects/GDE_App/GDE-ejb/src/java/com/edf/gde/entities/Study.java create mode 100644 projects/GDE_App/GDE-ejb/src/java/com/edf/gde/transferables/StudyTO.java diff --git a/projects/GDE_App/GDE-ejb/src/java/com/edf/gde/ejb/MetadataDAO.java b/projects/GDE_App/GDE-ejb/src/java/com/edf/gde/ejb/MetadataDAO.java index e836599..8ebc7a8 100644 --- a/projects/GDE_App/GDE-ejb/src/java/com/edf/gde/ejb/MetadataDAO.java +++ b/projects/GDE_App/GDE-ejb/src/java/com/edf/gde/ejb/MetadataDAO.java @@ -5,8 +5,14 @@ */ package com.edf.gde.ejb; +import com.edf.gde.entities.Attribute; +import com.edf.gde.entities.AttributeGroup; +import com.edf.gde.transferables.AttributeGroupTO; +import com.edf.gde.transferables.AttributeTO; import javax.ejb.Stateless; import javax.ejb.LocalBean; +import javax.persistence.EntityManager; +import javax.persistence.PersistenceContext; /** * @@ -15,7 +21,95 @@ import javax.ejb.LocalBean; @Stateless @LocalBean public class MetadataDAO { + @PersistenceContext(unitName = "GDE-ejbPU") + private EntityManager em; - // Add business logic below. (Right-click in editor and choose - // "Insert Code > Add Business Method") + /* Attributes */ + + public AttributeTO createAttribute(AttributeTO ato) { + Attribute a = Attribute.fromAttributeTO(ato); + em.persist(a); + return a.toAttributeTO(); + } + + public void deleteAttribute(AttributeTO ato) { + Attribute a = Attribute.fromAttributeTO(ato); + em.remove(a); + } + + public AttributeTO updateAttribute(AttributeTO ato) { + Attribute a = Attribute.fromAttributeTO(ato); + Attribute up = em.merge(a); + return up.toAttributeTO(); + } + + public AttributeTO findAttribute(AttributeTO ato) { + Attribute found = em.find(Attribute.class, ato.getId()); + return found.toAttributeTO(); + } + + private AttributeTO findBy(String queryName, String varName, T value) { + try { + Attribute found = (Attribute) em.createNamedQuery(queryName) + .setParameter(varName, value) + .getSingleResult(); + return found.toAttributeTO(); + } + catch (Exception e) { + return null; + } + } + + public AttributeTO findById(long id) { + return findBy("Attribute.findById", "id", id); + } + + public AttributeTO findByName(String name) { + return findBy("Attribute.findByName", "name", name); + } + + public AttributeTO findByType(String type) { + return findBy("Attribute.findByType", "type", type); + } + + public AttributeTO findByValue(String value) { + return findBy("Attribute.findByValue", "value", value); + } + + /* Attributes Groups */ + + public AttributeGroupTO createAttributeGroup(AttributeGroupTO agto) { + AttributeGroup group = AttributeGroup.fromAttributeGroupTO(agto); + em.persist(group); + return group.toAttributeGroupTO(); + } + + public void deleteAttributeGroup(AttributeGroupTO agto) { + AttributeGroup group = AttributeGroup.fromAttributeGroupTO(agto); + em.remove(group); + } + + public AttributeGroupTO updateAttributeGroup(AttributeGroupTO agto) { + AttributeGroup group = AttributeGroup.fromAttributeGroupTO(agto); + AttributeGroup up = em.merge(group); + return up.toAttributeGroupTO(); + } + + public AttributeGroupTO findAttributeGroup(AttributeGroupTO agto) { + AttributeGroup found = em.find(AttributeGroup.class, agto.getId()); + return found.toAttributeGroupTO(); + } + + public AttributeGroupTO findGroupById(long groupId) { + try { + AttributeGroup found = (AttributeGroup) em.createNamedQuery("AttributeGroup.findById") + .setParameter("id", groupId) + .getSingleResult(); + return found.toAttributeGroupTO(); + } + catch (Exception e) { + return null; + } + } + } diff --git a/projects/GDE_App/GDE-ejb/src/java/com/edf/gde/ejb/StudyDAO.java b/projects/GDE_App/GDE-ejb/src/java/com/edf/gde/ejb/StudyDAO.java index dec6c15..4dacf5f 100644 --- a/projects/GDE_App/GDE-ejb/src/java/com/edf/gde/ejb/StudyDAO.java +++ b/projects/GDE_App/GDE-ejb/src/java/com/edf/gde/ejb/StudyDAO.java @@ -5,6 +5,9 @@ */ package com.edf.gde.ejb; +import com.edf.gde.entities.Study; +import com.edf.gde.transferables.StudyTO; +import java.util.Date; import javax.ejb.Stateless; import javax.ejb.LocalBean; import javax.persistence.EntityManager; @@ -20,4 +23,58 @@ public class StudyDAO { @PersistenceContext(unitName = "GDE-ejbPU") private EntityManager em; + public StudyTO createStudy(StudyTO sto) { + Study s = Study.fromStudyTO(sto); + em.persist(s); + return s.toStudyTO(); + } + + public void deleteStudy(StudyTO sto) { + Study s = Study.fromStudyTO(sto); + em.remove(s); + } + + public StudyTO updateStudy(StudyTO sto) { + Study s = Study.fromStudyTO(sto); + Study up = em.merge(s); + return up.toStudyTO(); + } + + public StudyTO findStudy(StudyTO sto) { + Study found = em.find(Study.class, sto.getId()); + return found.toStudyTO(); + } + + private StudyTO findBy(String queryName, String varName, T value) { + try { + Study found = (Study) em.createNamedQuery(queryName) + .setParameter(varName, value) + .getSingleResult(); + return found.toStudyTO(); + } + catch (Exception e) { + return null; + } + } + + public StudyTO findById(long id) { + return findBy("Study.findById", "id", id); + } + + public StudyTO findByName(String name) { + return findBy("Study.findByName", "name", name); + } + + public StudyTO findByCreationDate(Date creationDate) { + return findBy("Study.findByCreationDate", "creationDate", creationDate); + } + + public StudyTO findByUpdateDate(Date updateDate) { + return findBy("Study.findByUpdateDate", "updateDate", updateDate); + } + + public StudyTO findByDeletionDate(Date deletionDate) { + return findBy("Study.findByDeletionDate", "deletionDate", deletionDate); + } + } diff --git a/projects/GDE_App/GDE-ejb/src/java/com/edf/gde/entities/Attribute.java b/projects/GDE_App/GDE-ejb/src/java/com/edf/gde/entities/Attribute.java index c08faf5..486d2d5 100644 --- a/projects/GDE_App/GDE-ejb/src/java/com/edf/gde/entities/Attribute.java +++ b/projects/GDE_App/GDE-ejb/src/java/com/edf/gde/entities/Attribute.java @@ -5,6 +5,7 @@ */ package com.edf.gde.entities; +import com.edf.gde.transferables.AttributeTO; import java.io.Serializable; import java.util.Objects; import javax.persistence.Basic; @@ -13,8 +14,6 @@ import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; import javax.persistence.NamedQueries; import javax.persistence.NamedQuery; import javax.persistence.SequenceGenerator; @@ -58,9 +57,8 @@ public class Attribute implements Serializable { private String value; @Column(name = "mandatory") private Boolean mandatory; - @JoinColumn(name = "group_id", referencedColumnName = "id", nullable = false) - @ManyToOne - private AttributeGroup groupId; + @Column(name = "attribute_group_id") + private long attributeGroupId; public Attribute() { } @@ -109,14 +107,36 @@ public class Attribute implements Serializable { this.mandatory = mandatory; } - public AttributeGroup getGroupId() { - return groupId; + public long getAttributeGroupId() { + return attributeGroupId; } - public void setGroupId(AttributeGroup groupId) { - this.groupId = groupId; + public void setAttributeGroupId(long groupId) { + this.attributeGroupId = groupId; } + public static Attribute fromAttributeTO(AttributeTO ato) { + Attribute attribute = new Attribute(); + attribute.id = ato.getId(); + attribute.name = ato.getName(); + attribute.type = ato.getType(); + attribute.value = ato.getValue(); + attribute.mandatory = ato.getMandatory(); + attribute.attributeGroupId = ato.getGroupId(); + return attribute; + } + + public AttributeTO toAttributeTO() { + AttributeTO ato = new AttributeTO(); + ato.setId(this.id); + ato.setName(this.name); + ato.setType(this.type); + ato.setValue(this.value); + ato.setMandatory(this.mandatory); + ato.setGroupId(this.attributeGroupId); + return ato; + } + @Override public String toString() { return "com.edf.gde.entities.Attribute[ id=" + id + " ]"; @@ -124,13 +144,13 @@ public class Attribute implements Serializable { @Override public int hashCode() { - int hash = 5; + int hash = 7; hash = 29 * hash + (int) (this.id ^ (this.id >>> 32)); hash = 29 * hash + Objects.hashCode(this.name); hash = 29 * hash + Objects.hashCode(this.type); hash = 29 * hash + Objects.hashCode(this.value); hash = 29 * hash + Objects.hashCode(this.mandatory); - hash = 29 * hash + Objects.hashCode(this.groupId); + hash = 29 * hash + (int) (this.attributeGroupId ^ (this.attributeGroupId >>> 32)); return hash; } @@ -148,5 +168,5 @@ public class Attribute implements Serializable { } return true; } - + } diff --git a/projects/GDE_App/GDE-ejb/src/java/com/edf/gde/entities/AttributeGroup.java b/projects/GDE_App/GDE-ejb/src/java/com/edf/gde/entities/AttributeGroup.java index 53809f3..b69d6a6 100644 --- a/projects/GDE_App/GDE-ejb/src/java/com/edf/gde/entities/AttributeGroup.java +++ b/projects/GDE_App/GDE-ejb/src/java/com/edf/gde/entities/AttributeGroup.java @@ -5,7 +5,10 @@ */ package com.edf.gde.entities; +import com.edf.gde.transferables.AttributeGroupTO; +import com.edf.gde.transferables.AttributeTO; import java.io.Serializable; +import java.util.ArrayList; import java.util.Collection; import java.util.Objects; import javax.persistence.Basic; @@ -14,7 +17,6 @@ import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; -import javax.persistence.ManyToMany; import javax.persistence.NamedQueries; import javax.persistence.NamedQuery; import javax.persistence.OneToMany; @@ -44,7 +46,7 @@ public class AttributeGroup implements Serializable { @SequenceGenerator(name = "SEQ_GEN_SEQUENCE", allocationSize = 50) @Column(name = "id") private long id; - @OneToMany(mappedBy = "groupId") + @OneToMany private Collection attributeCollection; public AttributeGroup() { @@ -71,6 +73,31 @@ public class AttributeGroup implements Serializable { this.attributeCollection = attributeCollection; } + public static AttributeGroup fromAttributeGroupTO(AttributeGroupTO agto) { + AttributeGroup group = new AttributeGroup(); + group.id = agto.getId(); + + group.attributeCollection = new ArrayList<>(); + Collection attributes = agto.getAttributeCollection(); + for (AttributeTO ato : attributes) { + group.attributeCollection.add(Attribute.fromAttributeTO(ato)); + } + + return group; + } + + public AttributeGroupTO toAttributeGroupTO() { + AttributeGroupTO agto = new AttributeGroupTO(); + agto.setId(this.id); + + Collection atos = new ArrayList<>(); + for (Attribute a : this.attributeCollection) { + atos.add(a.toAttributeTO()); + } + agto.setAttributeCollection(atos); + return agto; + } + @Override public String toString() { return "com.edf.gde.entities.AttributeGroup[ id=" + id + " ]"; diff --git a/projects/GDE_App/GDE-ejb/src/java/com/edf/gde/entities/GDEFile.java b/projects/GDE_App/GDE-ejb/src/java/com/edf/gde/entities/GDEFile.java index 4596b6e..ce7e0a1 100644 --- a/projects/GDE_App/GDE-ejb/src/java/com/edf/gde/entities/GDEFile.java +++ b/projects/GDE_App/GDE-ejb/src/java/com/edf/gde/entities/GDEFile.java @@ -13,6 +13,7 @@ import java.util.Collection; 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; @@ -25,13 +26,14 @@ import javax.persistence.TemporalType; 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"), @@ -47,7 +49,6 @@ import javax.xml.bind.annotation.XmlRootElement; }) public class GDEFile implements Serializable { private static final long serialVersionUID = 1L; - @Id @Basic(optional = false) @NotNull @@ -74,13 +75,11 @@ public class GDEFile implements Serializable { @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 chunks; - + @OneToMany(cascade = CascadeType.ALL) + private Collection chunkCollection; + @Column(name = "attribute_group_id") + private long attributeGroupId; + public GDEFile() { } @@ -160,36 +159,37 @@ public class GDEFile implements Serializable { this.deletionDate = deletionDate; } - public long getGroupId() { - return groupId; + @XmlTransient + public Collection getChunkCollection() { + return chunkCollection; } - public void setGroupId(long groupId) { - this.groupId = groupId; + public void setChunkCollection(Collection chunkCollection) { + this.chunkCollection = chunkCollection; } - public Collection getChunks() { - return chunks; + public long getAttributeGroupId() { + return attributeGroupId; } - public void setChunks(Collection 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 chunks = fto.getChunks(); + f.chunkCollection = new ArrayList<>(); + Collection 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(); @@ -203,15 +203,15 @@ public class GDEFile implements Serializable { fto.setChecksum(this.checksum); Collection 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); @@ -222,23 +222,23 @@ public class GDEFile implements Serializable { @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; } diff --git a/projects/GDE_App/GDE-ejb/src/java/com/edf/gde/entities/Study.java b/projects/GDE_App/GDE-ejb/src/java/com/edf/gde/entities/Study.java new file mode 100644 index 0000000..681c30d --- /dev/null +++ b/projects/GDE_App/GDE-ejb/src/java/com/edf/gde/entities/Study.java @@ -0,0 +1,201 @@ +/* + * 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. + */ +package com.edf.gde.entities; + +import com.edf.gde.transferables.StudyTO; +import java.io.Serializable; +import java.util.Date; +import java.util.Objects; +import javax.persistence.Basic; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.NamedQueries; +import javax.persistence.NamedQuery; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; +import javax.xml.bind.annotation.XmlRootElement; + +/** + * + * @author F62173 + */ +@Entity(name = "Study") +@Table(name = "study") +@XmlRootElement +@NamedQueries({ + @NamedQuery(name = "Study.findAll", query = "SELECT s FROM Study s"), + @NamedQuery(name = "Study.findById", query = "SELECT s FROM Study s WHERE s.id = :id"), + @NamedQuery(name = "Study.findByName", query = "SELECT s FROM Study s WHERE s.name = :name"), + @NamedQuery(name = "Study.findByCreationDate", query = "SELECT s FROM Study s WHERE s.creationDate = :creationDate"), + @NamedQuery(name = "Study.findByUpdateDate", query = "SELECT s FROM Study s WHERE s.updateDate = :updateDate"), + //@NamedQuery(name = "Study.findByValid", query = "SELECT s FROM Study s WHERE s.valid = :valid"), + //@NamedQuery(name = "Study.findByDeleted", query = "SELECT s FROM Study s WHERE s.deleted = :deleted"), + @NamedQuery(name = "Study.findByDeletionDate", query = "SELECT s FROM Study s WHERE s.deletionDate = :deletionDate") +}) +public class Study implements Serializable { + private static final long serialVersionUID = 1L; + @Id + @Basic(optional = false) + @NotNull + @Column(name = "id") + private long id; + @Size(max = 255) + @Column(name = "name") + private String name; + @Column(name = "creation_date") + @Temporal(TemporalType.TIMESTAMP) + private Date creationDate; + @Column(name = "update_date") + @Temporal(TemporalType.TIMESTAMP) + private Date updateDate; + @Column(name = "valid") + private Boolean valid; + @Column(name = "deleted") + private Boolean deleted; + @Column(name = "deletion_date") + @Temporal(TemporalType.TIMESTAMP) + private Date deletionDate; + @Column(name = "attribute_group_id") + private long attributeGroupId; + + public Study() { + } + + public Study(long id) { + this.id = id; + } + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Date getCreationDate() { + return creationDate; + } + + public void setCreationDate(Date creationDate) { + this.creationDate = creationDate; + } + + public Date getUpdateDate() { + return updateDate; + } + + public void setUpdateDate(Date updateDate) { + this.updateDate = updateDate; + } + + public Boolean getValid() { + return valid; + } + + public void setValid(Boolean valid) { + this.valid = valid; + } + + public Boolean getDeleted() { + return deleted; + } + + public void setDeleted(Boolean deleted) { + this.deleted = deleted; + } + + public Date getDeletionDate() { + return deletionDate; + } + + public void setDeletionDate(Date deletionDate) { + this.deletionDate = deletionDate; + } + + public long getAttributeGroupId() { + return attributeGroupId; + } + + public void setAttributeGroupId(long attributeGroupId) { + this.attributeGroupId = attributeGroupId; + } + + public static Study fromStudyTO(StudyTO sto) { + Study s = new Study(); + s.creationDate = sto.getCreationDate(); + s.deleted = sto.getDeleted(); + s.deletionDate = sto.getDeletionDate(); + s.attributeGroupId = sto.getAttributeGroupId(); + s.id = sto.getId(); + s.name = sto.getName(); + s.updateDate = sto.getUpdateDate(); + s.valid = sto.getValid(); + return s; + } + + public StudyTO toStudyTO() { + StudyTO sto = new StudyTO(); + sto.setCreationDate(this.creationDate); + sto.setDeleted(this.deleted); + sto.setDeletionDate(this.deletionDate); + sto.setAttributeGroupId(this.attributeGroupId); + sto.setId(this.id); + sto.setName(this.name); + sto.setUpdateDate(this.updateDate); + sto.setValid(this.valid); + return sto; + } + + @Override + public String toString() { + return "com.edf.gde.entities.Study[ id=" + id + " ]"; + } + + @Override + public int hashCode() { + int hash = 7; + hash = 17 * hash + (int) (this.id ^ (this.id >>> 32)); + hash = 17 * hash + Objects.hashCode(this.name); + hash = 17 * hash + Objects.hashCode(this.creationDate); + hash = 17 * hash + Objects.hashCode(this.updateDate); + hash = 17 * hash + Objects.hashCode(this.valid); + hash = 17 * hash + Objects.hashCode(this.deleted); + hash = 17 * hash + Objects.hashCode(this.deletionDate); + hash = 17 * hash + Objects.hashCode(this.attributeGroupId); + return hash; + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final Study other = (Study) obj; + if (this.id != other.id) { + return false; + } + return true; + } + +} diff --git a/projects/GDE_App/GDE-ejb/src/java/com/edf/gde/transferables/FileTO.java b/projects/GDE_App/GDE-ejb/src/java/com/edf/gde/transferables/FileTO.java index 98121e4..a48b145 100644 --- a/projects/GDE_App/GDE-ejb/src/java/com/edf/gde/transferables/FileTO.java +++ b/projects/GDE_App/GDE-ejb/src/java/com/edf/gde/transferables/FileTO.java @@ -26,12 +26,12 @@ public class FileTO implements Serializable { private Boolean deleted; private Date deletionDate; private long attributeGroupId; - private Collection chunks; + private Collection chunkCollection; public FileTO() { } - public FileTO(long id, String name, long length, String checksum, Date creationDate, Date updateDate, Boolean valid, Boolean deleted, Date deletionDate, long attributeGroupId, Collection chunks) { + public FileTO(long id, String name, long length, String checksum, Date creationDate, Date updateDate, Boolean valid, Boolean deleted, Date deletionDate, long attributeGroupId, Collection chunkCollection) { this.id = id; this.name = name; this.length = length; @@ -42,7 +42,7 @@ public class FileTO implements Serializable { this.deleted = deleted; this.deletionDate = deletionDate; this.attributeGroupId = attributeGroupId; - this.chunks = chunks; + this.chunkCollection = chunkCollection; } public long getId() { @@ -125,12 +125,12 @@ public class FileTO implements Serializable { this.attributeGroupId = attributeGroupId; } - public Collection getChunks() { - return chunks; + public Collection getChunkCollection() { + return chunkCollection; } - public void setChunks(Collection chunks) { - this.chunks = chunks; + public void setChunkCollection(Collection chunkCollection) { + this.chunkCollection = chunkCollection; } - + } diff --git a/projects/GDE_App/GDE-ejb/src/java/com/edf/gde/transferables/StudyTO.java b/projects/GDE_App/GDE-ejb/src/java/com/edf/gde/transferables/StudyTO.java new file mode 100644 index 0000000..8edead3 --- /dev/null +++ b/projects/GDE_App/GDE-ejb/src/java/com/edf/gde/transferables/StudyTO.java @@ -0,0 +1,106 @@ +/* + * 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. + */ +package com.edf.gde.transferables; + +import java.io.Serializable; +import java.util.Collection; +import java.util.Date; + +/** + * + * @author F62173 + */ +public class StudyTO implements Serializable { + + private static final long serialVersionUID = 1L; + private long id; + private String name; + private Date creationDate; + private Date updateDate; + private Boolean valid; + private Boolean deleted; + private Date deletionDate; + private long attributeGroupId; + + public StudyTO() { + } + + public StudyTO(long id, String name, Date creationDate, Date updateDate, Boolean valid, Boolean deleted, Date deletionDate, long attributeGroupId) { + this.id = id; + this.name = name; + this.creationDate = creationDate; + this.updateDate = updateDate; + this.valid = valid; + this.deleted = deleted; + this.deletionDate = deletionDate; + this.attributeGroupId = attributeGroupId; + } + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Date getCreationDate() { + return creationDate; + } + + public void setCreationDate(Date creationDate) { + this.creationDate = creationDate; + } + + public Date getUpdateDate() { + return updateDate; + } + + public void setUpdateDate(Date updateDate) { + this.updateDate = updateDate; + } + + public Boolean getValid() { + return valid; + } + + public void setValid(Boolean valid) { + this.valid = valid; + } + + public Boolean getDeleted() { + return deleted; + } + + public void setDeleted(Boolean deleted) { + this.deleted = deleted; + } + + public Date getDeletionDate() { + return deletionDate; + } + + public void setDeletionDate(Date deletionDate) { + this.deletionDate = deletionDate; + } + + public long getAttributeGroupId() { + return attributeGroupId; + } + + public void setAttributeGroupId(long attributeGroupId) { + this.attributeGroupId = attributeGroupId; + } + +} diff --git a/projects/GDE_App/nbproject/project.properties b/projects/GDE_App/nbproject/project.properties index 16c226d..864c306 100644 --- a/projects/GDE_App/nbproject/project.properties +++ b/projects/GDE_App/nbproject/project.properties @@ -11,7 +11,7 @@ endorsed.classpath=\ ${libs.javaee-endorsed-api-6.0.classpath} j2ee.appclient.mainclass.args=${j2ee.appclient.tool.args} j2ee.compile.on.save=true -j2ee.deploy.on.save=true +j2ee.deploy.on.save=false j2ee.platform=1.7 j2ee.platform.classpath=${j2ee.server.middleware}/mq/lib/jaxm-api.jar:${j2ee.server.home}/modules/endorsed/webservices-api-osgi.jar:${j2ee.server.home}/modules/endorsed/jaxb-api.jar:${j2ee.server.home}/modules/endorsed/javax.annotation-api.jar:${j2ee.server.home}/modules/javax.servlet-api.jar:${j2ee.server.home}/modules/javax.security.auth.message-api.jar:${j2ee.server.home}/modules/javax.servlet.jsp.jar:${j2ee.server.home}/modules/javax.persistence.jar:${j2ee.server.home}/modules/javax.inject.jar:${j2ee.server.home}/modules/javax.enterprise.deploy-api.jar:${j2ee.server.home}/modules/javax.el.jar:${j2ee.server.home}/modules/javax.mail.jar:${j2ee.server.home}/modules/javax.servlet.jsp-api.jar:${j2ee.server.home}/modules/javax.json.jar:${j2ee.server.home}/modules/javax.resource-api.jar:${j2ee.server.home}/modules/javax.enterprise.concurrent-api.jar:${j2ee.server.home}/modules/javax.ejb-api.jar:${j2ee.server.home}/modules/javax.xml.registry-api.jar:${j2ee.server.home}/modules/javax.transaction-api.jar:${j2ee.server.home}/modules/bean-validator.jar:${j2ee.server.home}/modules/javax.faces.jar:${j2ee.server.home}/modules/webservices-osgi.jar:${j2ee.server.home}/modules/javax.ws.rs-api.jar:${j2ee.server.home}/modules/javax.websocket-api.jar:${j2ee.server.home}/modules/javax.batch-api.jar:${j2ee.server.home}/modules/jaxb-osgi.jar:${j2ee.server.home}/modules/javax.enterprise.concurrent.jar:${j2ee.server.home}/modules/javax.xml.rpc-api.jar:${j2ee.server.home}/modules/javax.interceptor-api.jar:${j2ee.server.home}/modules/javax.management.j2ee-api.jar:${j2ee.server.home}/modules/javax.servlet.jsp.jstl-api.jar:${j2ee.server.home}/modules/weld-osgi-bundle.jar:${j2ee.server.home}/modules/javax.jms-api.jar:${j2ee.server.home}/modules/javax.servlet.jsp.jstl.jar:${j2ee.server.home}/modules/javax.security.jacc-api.jar j2ee.platform.embeddableejb.classpath=${j2ee.server.home}/lib/embedded/glassfish-embedded-static-shell.jar @@ -37,4 +37,5 @@ project.GDE-war=GDE-war reference.GDE-ejb.dist-ear=${project.GDE-ejb}/dist/GDE-ejb.jar reference.GDE-war.dist-ear=${project.GDE-war}/dist/GDE-war.war resource.dir=setup +run.classpath= source.root=. diff --git a/projects/GDE_App/src/GDE_DB_Init.sql b/projects/GDE_App/src/GDE_DB_Init.sql index 212a859..caf7323 100644 --- a/projects/GDE_App/src/GDE_DB_Init.sql +++ b/projects/GDE_App/src/GDE_DB_Init.sql @@ -1,63 +1,76 @@ drop sequence SEQ_GEN_SEQUENCE; create sequence SEQ_GEN_SEQUENCE INCREMENT BY 50; +/* METADATA */ + DROP TABLE attribute_group CASCADE; CREATE TABLE attribute_group ( - id int8 PRIMARY KEY + id bigint NOT NULL PRIMARY KEY ); DROP TABLE attribute CASCADE; CREATE TABLE attribute ( - id int8 PRIMARY KEY, + id bigint NOT NULL PRIMARY KEY, name varchar(255), type varchar(255), value varchar(255), - group_id int8 REFERENCES attribute_group (id), + attribute_group_id bigint REFERENCES attribute_group (id), mandatory boolean ); -DROP TABLE file CASCADE; -CREATE TABLE file ( - id int8 PRIMARY KEY, +/* DATA */ + +DROP TABLE gde_file CASCADE; +CREATE TABLE gde_file ( + id bigint NOT NULL PRIMARY KEY, name varchar(255), - length int8, + length bigint, checksum varchar(255), creation_date timestamp, update_date timestamp, valid boolean, deleted boolean, deletion_date timestamp, - group_id int8 REFERENCES attribute_group (id) + attribute_group_id bigint REFERENCES attribute_group (id) ); DROP TABLE chunk CASCADE; CREATE TABLE chunk ( - id int8 PRIMARY KEY, - file_id int8 REFERENCES file (id), - rank int8, + id bigint NOT NULL PRIMARY KEY, + file_id bigint NOT NULL REFERENCES gde_file (id), + rank bigint, checksum varchar(255), - size int8, + size bigint, data bytea ); -/* -DROP TABLE data CASCADE; -CREATE TABLE data ( - file_id int8 REFERENCES file (id), - metadata_id int8 REFERENCES attribute_group (id), - PRIMARY KEY (file_id, metadata_id) + +/* STUDIES */ + +DROP TABLE study CASCADE; +CREATE TABLE study ( + id bigint NOT NULL PRIMARY KEY, + name varchar(255), + creation_date timestamp, + update_date timestamp, + valid boolean, + deleted boolean, + deletion_date timestamp, + attribute_group_id bigint REFERENCES attribute_group (id) ); -*/ + +/* PROFILES */ + DROP TABLE profile CASCADE; CREATE TABLE profile ( - id int8 PRIMARY KEY, + id bigint NOT NULL PRIMARY KEY, name varchar(255) ); DROP TABLE profile_attribute CASCADE; CREATE TABLE profile_attribute ( - id int8 PRIMARY KEY, + id bigint NOT NULL PRIMARY KEY, name varchar(255), type varchar(255), mandatory boolean, - profile_id int8 REFERENCES profile (id) + profile_id bigint REFERENCES profile (id) ); -- 2.39.2