Commit 78294e2c4ab4f35bda1ced137fe8704da250a402

Authored by jcartign
1 parent 0bd6dc75

Add clean domain objects

src/main/java/fr/plil/sio/persistence/api/Group.java
1 package fr.plil.sio.persistence.api; 1 package fr.plil.sio.persistence.api;
2 2
3 -import javax.persistence.*;  
4 import java.util.LinkedList; 3 import java.util.LinkedList;
5 import java.util.List; 4 import java.util.List;
6 5
@@ -9,28 +8,20 @@ import java.util.List; @@ -9,28 +8,20 @@ import java.util.List;
9 * A group contains a list of rights unique by their ID (no two groups with the same ID can exist in the database). 8 * A group contains a list of rights unique by their ID (no two groups with the same ID can exist in the database).
10 */ 9 */
11 10
12 -@Entity  
13 -@Table(name = "GROUP_T")  
14 public class Group { 11 public class Group {
15 12
16 - @Id  
17 - @GeneratedValue(strategy = GenerationType.AUTO)  
18 - @Column(name = "GROUP_ID")  
19 private Long id; 13 private Long id;
20 14
21 - @Column(name = "NAME_C")  
22 private String name; 15 private String name;
23 16
24 /** 17 /**
25 * Users in the group. 18 * Users in the group.
26 */ 19 */
27 - @OneToMany(mappedBy = "group")  
28 private List<User> users = new LinkedList<>(); 20 private List<User> users = new LinkedList<>();
29 21
30 /** 22 /**
31 * List of rights. The list CANNOT contains duplicate rights. 23 * List of rights. The list CANNOT contains duplicate rights.
32 */ 24 */
33 - @OneToMany  
34 private List<Right> rights = new LinkedList<>(); 25 private List<Right> rights = new LinkedList<>();
35 26
36 public List<Right> getRights() { 27 public List<Right> getRights() {
src/main/java/fr/plil/sio/persistence/api/Right.java
1 package fr.plil.sio.persistence.api; 1 package fr.plil.sio.persistence.api;
2 2
3 -import javax.persistence.*;  
4 import java.util.LinkedList; 3 import java.util.LinkedList;
5 import java.util.List; 4 import java.util.List;
6 5
@@ -10,25 +9,16 @@ import java.util.List; @@ -10,25 +9,16 @@ import java.util.List;
10 * A right can have zero, one or more siblings. 9 * A right can have zero, one or more siblings.
11 */ 10 */
12 11
13 -@Entity  
14 -@Table(name = "RIGHT_T")  
15 public class Right { 12 public class Right {
16 13
17 - @Id  
18 - @GeneratedValue(strategy = GenerationType.AUTO)  
19 - @Column(name = "RIGHT_ID")  
20 private Long id; 14 private Long id;
21 15
22 - @Column(name = "NAME_C")  
23 private String name; 16 private String name;
24 17
25 /// the parent right 18 /// the parent right
26 - @ManyToOne  
27 - @JoinColumn(name = "PARENT_C")  
28 private Right parent; 19 private Right parent;
29 20
30 /// the sibling right(s), eventually empty 21 /// the sibling right(s), eventually empty
31 - @OneToMany(mappedBy = "parent")  
32 private List<Right> siblings = new LinkedList<>(); 22 private List<Right> siblings = new LinkedList<>();
33 23
34 public List<Right> getSiblings() { 24 public List<Right> getSiblings() {
src/main/java/fr/plil/sio/persistence/api/User.java
1 package fr.plil.sio.persistence.api; 1 package fr.plil.sio.persistence.api;
2 2
3 -import javax.persistence.*;  
4 -  
5 /** 3 /**
6 * An user MUST have a group in the database. 4 * An user MUST have a group in the database.
7 * An user is unique by it name, i.e. database cannot contain two user with the same name or the same ID. 5 * An user is unique by it name, i.e. database cannot contain two user with the same name or the same ID.
8 */ 6 */
9 7
10 -@Entity  
11 -@Table(name = "USER_T")  
12 public class User { 8 public class User {
13 9
14 - @Id  
15 - @GeneratedValue(strategy = GenerationType.AUTO)  
16 - @Column(name = "USER_ID")  
17 private Long id; 10 private Long id;
18 11
19 - @Column(name = "NAME_C")  
20 private String name; 12 private String name;
21 13
22 - @ManyToOne  
23 - @JoinColumn(name = "GROUP_C")  
24 private Group group; 14 private Group group;
25 15
26 public Long getId() { 16 public Long getId() {