diff --git a/README.md b/README.md index d4d8562..6e34c44 100644 --- a/README.md +++ b/README.md @@ -1 +1,38 @@ # Template de projet pour le TP JPA UniR + +```mermaid +classDiagram + Utilisateur "*" -- "*" Session + Session "*" -- "1" Quizz + Quizz "1" -- "1..*" Question + Utilisateur "1" -- "*" Quizz + Question "1" -- "1..*" Reponse + Reponse <|-- ReponseCourte + Reponse <|-- Choix + + + class Utilisateur { + -id : int + name : String + } + class Session{ + -id : int + } + class Quizz{ + -id : int + } + class Reponse{ + - id : int + } + class Choix{ + - id : int + choix : List + } + class ReponseCourte{ + - id : int + value : String + } + class Question{ + - id : int + } +``` \ No newline at end of file diff --git a/src/main/java/metier/Choix.java b/src/main/java/metier/Choix.java index 826879a..05d5068 100644 --- a/src/main/java/metier/Choix.java +++ b/src/main/java/metier/Choix.java @@ -9,7 +9,7 @@ public class Choix extends Reponse{ @Id @GeneratedValue - int id; + private int id; ArrayList choix; @@ -17,6 +17,14 @@ public class Choix extends Reponse{ super(); } + + public void setId(int id){ + this.id=id; + } + + public int getId(){ + return this.id; + } diff --git a/src/main/java/metier/Question.java b/src/main/java/metier/Question.java index 039aff4..e5ede42 100644 --- a/src/main/java/metier/Question.java +++ b/src/main/java/metier/Question.java @@ -12,10 +12,12 @@ public class Question { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private int id; + + @OneToMany(mappedBy ="reponse", cascade = CascadeType.DETACH) private Reponse reponse; - @Id - @GeneratedValue + + public int getId() { return id; } @@ -23,7 +25,6 @@ public class Question { this.id = id; } - @OneToMany(mappedBy ="reponse", cascade = CascadeType.DETACH) public Reponse getReponse() { return reponse; } @@ -31,4 +32,5 @@ public class Question { public void setReponse(Reponse reponse) { this.reponse = reponse; } + } diff --git a/src/main/java/metier/Quizz.java b/src/main/java/metier/Quizz.java index 951d141..a705891 100644 --- a/src/main/java/metier/Quizz.java +++ b/src/main/java/metier/Quizz.java @@ -10,7 +10,7 @@ public class Quizz{ @Id @GeneratedValue - public int id; + private int id; @ManyToOne @JoinColumn(name="id_utilisateur") @@ -19,4 +19,21 @@ public class Quizz{ public Quizz(){ super(); } + + + public void setId(int id){ + this.id=id; + } + + public int getId(){ + return this.id; + } + + public void setutilisateur(Utilisateur utilisateur){ + this.utilisateur=utilisateur; + } + + public Utilisateur getUtilisateur(){ + return this.utilisateur; + } } diff --git a/src/main/java/metier/Reponse.java b/src/main/java/metier/Reponse.java index 2f72ba5..20d537f 100644 --- a/src/main/java/metier/Reponse.java +++ b/src/main/java/metier/Reponse.java @@ -2,7 +2,6 @@ package metier; import java.util.ArrayList; -import javax.annotation.processing.Generated; import jakarta.persistence.GeneratedValue; import jakarta.persistence.GenerationType; @@ -19,4 +18,21 @@ public abstract class Reponse { public Reponse(){ } + + public void setId(int id){ + this.id=id; + } + + public int getId(){ + return this.id; + } + + public void setReponses(ArrayList reponses){ + this.reponses=reponses; + } + + public ArrayList getReponses(){ + return this.reponses; + } + } \ No newline at end of file diff --git a/src/main/java/metier/ReponseCourte.java b/src/main/java/metier/ReponseCourte.java index 96a25d6..c2497a6 100644 --- a/src/main/java/metier/ReponseCourte.java +++ b/src/main/java/metier/ReponseCourte.java @@ -8,7 +8,7 @@ public class ReponseCourte extends Reponse{ @Id @GeneratedValue - int id; + private int id; String value; @@ -17,4 +17,21 @@ public class ReponseCourte extends Reponse{ super(); } + + public void setId(int id){ + this.id=id; + } + + public int getId(){ + return this.id; + } + + public void setValue(String value){ + this.value=value; + } + + public String getValue(){ + return this.value; + } + } diff --git a/src/main/java/metier/Utilisateur.java b/src/main/java/metier/Utilisateur.java index 6df573b..c54b4b7 100644 --- a/src/main/java/metier/Utilisateur.java +++ b/src/main/java/metier/Utilisateur.java @@ -9,6 +9,7 @@ public class Utilisateur{ @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private int id; + private String name; @ManyToMany @@ -42,4 +43,24 @@ public class Utilisateur{ public Session getSession() { return session; } + + public void setSession(Session session){ + this.session = session; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public String getPassword() { + return this.password; + } + + public void setPassword(String password) { + this.password = password; + } } \ No newline at end of file diff --git a/target/classes/metier/Choix.class b/target/classes/metier/Choix.class index a454f3e..b830259 100644 Binary files a/target/classes/metier/Choix.class and b/target/classes/metier/Choix.class differ diff --git a/target/classes/metier/Question.class b/target/classes/metier/Question.class index 141de72..aecb986 100644 Binary files a/target/classes/metier/Question.class and b/target/classes/metier/Question.class differ diff --git a/target/classes/metier/Quizz.class b/target/classes/metier/Quizz.class index 5c9be08..26c5555 100644 Binary files a/target/classes/metier/Quizz.class and b/target/classes/metier/Quizz.class differ diff --git a/target/classes/metier/Reponse.class b/target/classes/metier/Reponse.class index 924af11..8fc77d3 100644 Binary files a/target/classes/metier/Reponse.class and b/target/classes/metier/Reponse.class differ diff --git a/target/classes/metier/ReponseCourte.class b/target/classes/metier/ReponseCourte.class index b49b6c0..32a4cb2 100644 Binary files a/target/classes/metier/ReponseCourte.class and b/target/classes/metier/ReponseCourte.class differ diff --git a/target/classes/metier/Utilisateur.class b/target/classes/metier/Utilisateur.class index 1e716ed..6e71183 100644 Binary files a/target/classes/metier/Utilisateur.class and b/target/classes/metier/Utilisateur.class differ