]> SALOME platform Git repositories - modules/gde.git/commitdiff
Salome HOME
Fixe entities
authormordicus <mordicus@HP-8560w>
Fri, 17 Jul 2015 09:19:27 +0000 (11:19 +0200)
committermordicus <mordicus@HP-8560w>
Fri, 17 Jul 2015 09:19:27 +0000 (11:19 +0200)
projects/GDE_App/GDE-ejb/nbproject/project.xml
projects/GDE_App/GDE-ejb/src/conf/persistence.xml
projects/GDE_App/GDE-ejb/src/java/com/edf/gde/entities/GDEFile.java
projects/GDE_App/GDE-ejb/src/java/com/edf/gde/entities/Study.java
projects/GDE_App/src/GDE_DB_Init.sql

index c07a94ac21c0cd3edecddaafe819d9c46a6f9ae0..312bb1dca8903ecf896a5d299914dd92ef9828b3 100644 (file)
@@ -6,10 +6,10 @@
             <name>GDE-ejb</name>
             <minimum-ant-version>1.6.5</minimum-ant-version>
             <source-roots>
-                <root id="src.dir" name="Source Packages"/>
+                <root id="src.dir"/>
             </source-roots>
             <test-roots>
-                <root id="test.src.dir" name="Test Packages"/>
+                <root id="test.src.dir"/>
             </test-roots>
         </data>
     </configuration>
index 8e8fefcc13024b755fdc57270f9c68c701f372cc..775e7498c60a7ecb6fdc2a702928a4ee70e44bba 100644 (file)
@@ -1,8 +1,11 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
   <persistence-unit name="GDE-ejbPU" transaction-type="JTA">
+    <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
     <jta-data-source>jdbc/gdedb</jta-data-source>
     <exclude-unlisted-classes>false</exclude-unlisted-classes>
-    <properties/>
+    <properties>
+      <property name="eclipselink.target-database" value="PostgreSQL"/>
+    </properties>
   </persistence-unit>
 </persistence>
index ce7e0a126a003851a2a329ff51cbdd66fd531900..580658f0dec147de7eeffe31ed89936196bd949d 100644 (file)
@@ -16,10 +16,13 @@ import javax.persistence.Basic;
 import javax.persistence.CascadeType;
 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;
@@ -53,6 +56,8 @@ public class GDEFile implements Serializable {
     @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")
@@ -75,8 +80,6 @@ public class GDEFile implements Serializable {
     @Column(name = "deletion_date")
     @Temporal(TemporalType.TIMESTAMP)
     private Date deletionDate;
-    @OneToMany(cascade = CascadeType.ALL)
-    private Collection<Chunk> chunkCollection;
     @Column(name = "attribute_group_id")
     private long attributeGroupId;
 
@@ -159,15 +162,6 @@ public class GDEFile implements Serializable {
         this.deletionDate = deletionDate;
     }
 
-    @XmlTransient
-    public Collection<Chunk> getChunkCollection() {
-        return chunkCollection;
-    }
-
-    public void setChunkCollection(Collection<Chunk> chunkCollection) {
-        this.chunkCollection = chunkCollection;
-    }
-
     public long getAttributeGroupId() {
         return attributeGroupId;
     }
@@ -179,12 +173,6 @@ public class GDEFile implements Serializable {
     public static GDEFile fromFileTO(FileTO fto) {
         GDEFile f = new GDEFile();
         f.checksum = fto.getChecksum();
-
-        f.chunkCollection = new ArrayList<>();
-        Collection<ChunkTO> chunks = fto.getChunkCollection();
-        for (ChunkTO cto : chunks) {
-            f.chunkCollection.add(Chunk.fromChunkTO(cto));
-        }
         
         f.creationDate = fto.getCreationDate();
         f.deleted = fto.getDeleted();
@@ -201,13 +189,7 @@ public class GDEFile implements Serializable {
     public FileTO toFileTO() {
         FileTO fto = new FileTO();
         fto.setChecksum(this.checksum);
-        
-        Collection<ChunkTO> ctos = new ArrayList<>();
-        for (Chunk c : this.chunkCollection) {
-            ctos.add(c.toChunkTO());
-        }
-        fto.setChunkCollection(ctos);
-        
+                
         fto.setCreationDate(this.creationDate);
         fto.setDeleted(this.deleted);
         fto.setDeletionDate(this.deletionDate);
@@ -237,7 +219,6 @@ public class GDEFile implements Serializable {
         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;
     }
index 681c30dbe37c6e038c0b0eb4dc62bf08ad340e5a..6f1fc71c3830cd7da839c31005d8f14242a3f5ae 100644 (file)
@@ -12,11 +12,14 @@ 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.JoinColumn;
 import javax.persistence.ManyToOne;
 import javax.persistence.NamedQueries;
 import javax.persistence.NamedQuery;
+import javax.persistence.SequenceGenerator;
 import javax.persistence.Table;
 import javax.persistence.Temporal;
 import javax.persistence.TemporalType;
@@ -47,6 +50,8 @@ public class Study implements Serializable {
     @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")
index 905fa03d81312c98fc92077f9fc70c04cf4dbcef..25d0435d9c65ed8f14990ee19e3587b0bae7685f 100644 (file)
@@ -1,8 +1,8 @@
-/*
+
 drop sequence SEQ_GEN_SEQUENCE;
 create sequence SEQ_GEN_SEQUENCE INCREMENT BY 50;
-*/
 
+    
 /* METADATA */
 
 DROP TABLE IF EXISTS attribute_group CASCADE;
@@ -20,6 +20,7 @@ CREATE TABLE attribute (
     mandatory boolean
 );
 
+
 /* DATA */
 
 DROP TABLE IF EXISTS gde_file CASCADE;