From b7a729c899e59a353e3a6241549ec2c02039b0f7 Mon Sep 17 00:00:00 2001 From: Bartha Maxime <231026@umons.ac.be> Date: Tue, 9 Apr 2024 19:52:31 +0200 Subject: [PATCH] added extention entities --- .../ovh/herisson/Clyde/Tables/FileType.java | 4 +- .../Tables/ScientificPublications/Access.java | 7 +++ .../ScientificPublications/Article.java | 51 +++++++++++++++++++ .../ArticleCoAuthors.java | 27 ++++++++++ .../ScientificPublications/PublishType.java | 6 +++ .../ScientificPublications/Researcher.java | 25 +++++++++ .../java/ovh/herisson/Clyde/Tables/User.java | 2 +- 7 files changed, 120 insertions(+), 2 deletions(-) create mode 100644 backend/src/main/java/ovh/herisson/Clyde/Tables/ScientificPublications/Access.java create mode 100644 backend/src/main/java/ovh/herisson/Clyde/Tables/ScientificPublications/Article.java create mode 100644 backend/src/main/java/ovh/herisson/Clyde/Tables/ScientificPublications/ArticleCoAuthors.java create mode 100644 backend/src/main/java/ovh/herisson/Clyde/Tables/ScientificPublications/PublishType.java create mode 100644 backend/src/main/java/ovh/herisson/Clyde/Tables/ScientificPublications/Researcher.java diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/FileType.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/FileType.java index 18ce1be..a89de1f 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Tables/FileType.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/FileType.java @@ -4,5 +4,7 @@ public enum FileType { ProfilePicture, - EducationCertificate + EducationCertificate, + + Article, } diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/ScientificPublications/Access.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/ScientificPublications/Access.java new file mode 100644 index 0000000..7914d22 --- /dev/null +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/ScientificPublications/Access.java @@ -0,0 +1,7 @@ +package ovh.herisson.Clyde.Tables.ScientificPublications; + +public enum Access { + OpenSource, + Restricted, + Private, +} diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/ScientificPublications/Article.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/ScientificPublications/Article.java new file mode 100644 index 0000000..dd5504c --- /dev/null +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/ScientificPublications/Article.java @@ -0,0 +1,51 @@ +package ovh.herisson.Clyde.Tables.ScientificPublications; + +import jakarta.persistence.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import org.hibernate.annotations.CreationTimestamp; +import org.hibernate.annotations.OnDelete; +import org.hibernate.annotations.OnDeleteAction; +import ovh.herisson.Clyde.Tables.User; +import java.util.Date; +@Getter +@Setter +@NoArgsConstructor +@AllArgsConstructor +@Entity +public class Article { + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private Long id; + + private String title; + + @ManyToOne(fetch = FetchType.EAGER) + @OnDelete(action = OnDeleteAction.CASCADE) + @JoinColumn(name ="Users") + private User author; + + //todo change user to Researcher + @CreationTimestamp + @Column(nullable = false) + private Date releaseDate; + + private PublishType publishType; + + private String pdfLocation; + + private String bibTexLocation; + + private String language; + + private Access access; + + private String domain; + + private String summary; + + private int views; +} + diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/ScientificPublications/ArticleCoAuthors.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/ScientificPublications/ArticleCoAuthors.java new file mode 100644 index 0000000..5407a4b --- /dev/null +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/ScientificPublications/ArticleCoAuthors.java @@ -0,0 +1,27 @@ +package ovh.herisson.Clyde.Tables.ScientificPublications; + +import jakarta.persistence.FetchType; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import org.hibernate.annotations.OnDelete; +import org.hibernate.annotations.OnDeleteAction; + +@Getter +@Setter +@NoArgsConstructor +@AllArgsConstructor +public class ArticleCoAuthors { + + @ManyToOne(fetch = FetchType.EAGER) + @JoinColumn(name = "Researcher") + private Researcher coAuthor; + + @ManyToOne(fetch = FetchType.EAGER) + @OnDelete(action = OnDeleteAction.CASCADE) + @JoinColumn(name = "Article") + private Article article; +} diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/ScientificPublications/PublishType.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/ScientificPublications/PublishType.java new file mode 100644 index 0000000..9f84e79 --- /dev/null +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/ScientificPublications/PublishType.java @@ -0,0 +1,6 @@ +package ovh.herisson.Clyde.Tables.ScientificPublications; + +public enum PublishType { + article, + slides, +} diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/ScientificPublications/Researcher.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/ScientificPublications/Researcher.java new file mode 100644 index 0000000..6366641 --- /dev/null +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/ScientificPublications/Researcher.java @@ -0,0 +1,25 @@ +package ovh.herisson.Clyde.Tables.ScientificPublications; + +import jakarta.persistence.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import ovh.herisson.Clyde.Tables.User; + + +@Getter +@Setter +@NoArgsConstructor +@AllArgsConstructor +@Entity +public class Researcher { + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private long id; + @OneToOne + private User user; + private String orcidId; + private String site; + private String Domain; +} diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/User.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/User.java index 2badd32..ba645c8 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Tables/User.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/User.java @@ -28,11 +28,11 @@ public class User { ////// Extension Messagerie ///// @OneToMany(mappedBy = "author", cascade = CascadeType.ALL) private List msgs; - ///////////////////////////////// @ManyToMany( mappedBy = "members" ) private List discussions; + ///////////////////////////////// public User(String lastName, String firstName, String email, String address, String country, Date birthDate, String profilePictureUrl, Role role, String password) {