From 7922539ad4f8343870af0a19a96bdafbee81e3d9 Mon Sep 17 00:00:00 2001 From: Egzon94 Date: Sat, 12 Oct 2024 16:36:51 +0200 Subject: [PATCH] done --- pom.xml | 78 ++++++++++++++++ src/main/java/com/example/demo/Chapter.java | 83 +++++++++++++++++ .../java/com/example/demo/Conference.java | 30 +++++++ .../com/example/demo/Demo13Application.java | 13 +++ src/main/java/com/example/demo/Event.java | 89 +++++++++++++++++++ .../java/com/example/demo/Exposition.java | 20 +++++ src/main/java/com/example/demo/Guest.java | 54 +++++++++++ src/main/java/com/example/demo/Member.java | 69 ++++++++++++++ src/main/java/com/example/demo/Speaker.java | 50 +++++++++++ src/main/resources/application.properties | 6 ++ .../example/demo/Demo13ApplicationTests.java | 13 +++ 11 files changed, 505 insertions(+) create mode 100644 pom.xml create mode 100644 src/main/java/com/example/demo/Chapter.java create mode 100644 src/main/java/com/example/demo/Conference.java create mode 100644 src/main/java/com/example/demo/Demo13Application.java create mode 100644 src/main/java/com/example/demo/Event.java create mode 100644 src/main/java/com/example/demo/Exposition.java create mode 100644 src/main/java/com/example/demo/Guest.java create mode 100644 src/main/java/com/example/demo/Member.java create mode 100644 src/main/java/com/example/demo/Speaker.java create mode 100644 src/main/resources/application.properties create mode 100644 src/test/java/com/example/demo/Demo13ApplicationTests.java diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..3d0f01f --- /dev/null +++ b/pom.xml @@ -0,0 +1,78 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 3.3.4 + + + com.Activity + demo13 + 0.0.1-SNAPSHOT + demo13 + demo13 + + + + + + + + + + + + + + + 17 + + + + org.springframework.boot + spring-boot-starter-data-jpa + + + + org.springframework.boot + spring-boot-devtools + runtime + true + + + com.mysql + mysql-connector-j + runtime + + + org.projectlombok + lombok + true + + + org.springframework.boot + spring-boot-starter-test + test + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + org.projectlombok + lombok + + + + + + + + diff --git a/src/main/java/com/example/demo/Chapter.java b/src/main/java/com/example/demo/Chapter.java new file mode 100644 index 0000000..ed3ef07 --- /dev/null +++ b/src/main/java/com/example/demo/Chapter.java @@ -0,0 +1,83 @@ +package com.example.demo; + + +import jakarta.persistence.*; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.RequiredArgsConstructor; + +import java.util.List; + +@Entity +@Data +@RequiredArgsConstructor + + +public class Chapter { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + + private Long id; + private String name; + + private String district; + + @OneToOne + @JoinColumn(name = "president_id") + private Member president; + + @OneToMany + @JoinColumn(name = "chapter_id") + private List members; + + + public Chapter(Long id, String name, String district, Member president, List members) { + this.id = id; + this.name = name; + this.district = district; + this.president = president; + this.members = members; + + } + + 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 String getDistrict() { + return district; + } + + public void setDistrict(String district) { + this.district = district; + } + + public Member getPresident() { + return president; + } + + public void setPresident(Member president) { + this.president = president; + } + + public List getMembers() { + return members; + } + + public void setMembers(List members) { + this.members = members; + } +} diff --git a/src/main/java/com/example/demo/Conference.java b/src/main/java/com/example/demo/Conference.java new file mode 100644 index 0000000..6fedd1a --- /dev/null +++ b/src/main/java/com/example/demo/Conference.java @@ -0,0 +1,30 @@ +package com.example.demo; + +import jakarta.persistence.Entity; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.OneToMany; + +import java.time.LocalDate; +import java.util.List; + +@Entity +public class Conference extends Event{ + + + @OneToMany + @JoinColumn(name = "conference_id") + private List speakers; + + public Conference(Long id, LocalDate date, int duration, String location, String title, List guests, List speakers) { + super(id, date, duration, location, title, guests); + this.speakers = speakers; + } + + public List getSpeakers() { + return speakers; + } + + public void setSpeakers(List speakers) { + this.speakers = speakers; + } +} diff --git a/src/main/java/com/example/demo/Demo13Application.java b/src/main/java/com/example/demo/Demo13Application.java new file mode 100644 index 0000000..9cf8c94 --- /dev/null +++ b/src/main/java/com/example/demo/Demo13Application.java @@ -0,0 +1,13 @@ +package com.example.demo; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class Demo13Application { + + public static void main(String[] args) { + SpringApplication.run(Demo13Application.class, args); + } + +} diff --git a/src/main/java/com/example/demo/Event.java b/src/main/java/com/example/demo/Event.java new file mode 100644 index 0000000..9cde8bd --- /dev/null +++ b/src/main/java/com/example/demo/Event.java @@ -0,0 +1,89 @@ +package com.example.demo; + + +import jakarta.persistence.*; + +import java.time.LocalDate; +import java.util.List; + +@Entity +public abstract class Event { + + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + private LocalDate date; + + private int duration; // duration in hours + + private String location; + + private String title; + + @OneToMany + @JoinColumn(name = "event_id") + private List guests; + + public Event(Long id, LocalDate date, int duration, String location, String title, List guests) { + this.id = id; + this.date = date; + this.duration = duration; + this.location = location; + this.title = title; + this.guests = guests; + } + + public Event() { + + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public LocalDate getDate() { + return date; + } + + public void setDate(LocalDate date) { + this.date = date; + } + + public int getDuration() { + return duration; + } + + public void setDuration(int duration) { + this.duration = duration; + } + + public String getLocation() { + return location; + } + + public void setLocation(String location) { + this.location = location; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public List getGuests() { + return guests; + } + + public void setGuests(List guests) { + this.guests = guests; + } +} diff --git a/src/main/java/com/example/demo/Exposition.java b/src/main/java/com/example/demo/Exposition.java new file mode 100644 index 0000000..a99a170 --- /dev/null +++ b/src/main/java/com/example/demo/Exposition.java @@ -0,0 +1,20 @@ +package com.example.demo; + + +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jdk.jfr.Enabled; + +import java.time.LocalDate; +import java.util.List; + +@Enabled +public class Exposition extends Event { + + public Exposition(Long id, LocalDate date, int duration, String location, String title, List guests) { + super(id, date, duration, location, title, guests); + } +} + + diff --git a/src/main/java/com/example/demo/Guest.java b/src/main/java/com/example/demo/Guest.java new file mode 100644 index 0000000..8bcdeb9 --- /dev/null +++ b/src/main/java/com/example/demo/Guest.java @@ -0,0 +1,54 @@ +package com.example.demo; + + +import jakarta.persistence.*; + +@Entity +public class Guest { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + + private Long id; + private String name; + + @Enumerated(EnumType.STRING) + private ResponseStatus status; + + public Guest(Long id, String name, ResponseStatus status) { + this.id = id; + this.name = name; + this.status = status; + } + + 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 ResponseStatus getStatus() { + return status; + } + + public void setStatus(ResponseStatus status) { + this.status = status; + } + + public enum ResponseStatus { + ATENDING, + NOT_ATENDING, + NO_RESPONSE, + } +} + diff --git a/src/main/java/com/example/demo/Member.java b/src/main/java/com/example/demo/Member.java new file mode 100644 index 0000000..5062c4d --- /dev/null +++ b/src/main/java/com/example/demo/Member.java @@ -0,0 +1,69 @@ +package com.example.demo; + + +import ch.qos.logback.core.status.Status; +import jakarta.persistence.*; + +import java.time.LocalDate; + +@Entity + +public class Member { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + + private Long id; + + private String name; + + @Enumerated(EnumType.STRING) + + private Status status; + + private LocalDate renewalDate; + + public Member(Long id, String name, Status status, LocalDate renewalDate) { + this.id = id; + this.name = name; + this.status = status; + this.renewalDate = renewalDate; + } + + 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 Status getStatus() { + return status; + } + + public void setStatus(Status status) { + this.status = status; + } + + public LocalDate getRenewalDate() { + return renewalDate; + } + + public void setRenewalDate(LocalDate renewalDate) { + this.renewalDate = renewalDate; + } + public enum Status { + ACTIVE, + LAPSED, + + } +} diff --git a/src/main/java/com/example/demo/Speaker.java b/src/main/java/com/example/demo/Speaker.java new file mode 100644 index 0000000..27c7363 --- /dev/null +++ b/src/main/java/com/example/demo/Speaker.java @@ -0,0 +1,50 @@ +package com.example.demo; + + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; + +@Entity +public class Speaker { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + + private Long id; + + private String name; + + private int presentationDuration; + + public Speaker(String name, Long id, int presentationDuration) { + this.name = name; + this.id = id; + this.presentationDuration = presentationDuration; + } + + 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 int getPresentationDuration() { + return presentationDuration; + } + + public void setPresentationDuration(int presentationDuration) { + this.presentationDuration = presentationDuration; + } +} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties new file mode 100644 index 0000000..2e65423 --- /dev/null +++ b/src/main/resources/application.properties @@ -0,0 +1,6 @@ +spring.application.name=demo13 +spring.datasource.username=root +spring.datasource.password=Ei28021994@ +spring.jpa.hibernate.ddl-auto=create +spring.jpa.show-sql=true +spring.datasource.url=jdbc:mysql://localhost:3306/book_db diff --git a/src/test/java/com/example/demo/Demo13ApplicationTests.java b/src/test/java/com/example/demo/Demo13ApplicationTests.java new file mode 100644 index 0000000..0609c75 --- /dev/null +++ b/src/test/java/com/example/demo/Demo13ApplicationTests.java @@ -0,0 +1,13 @@ +package com.example.demo; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class Demo13ApplicationTests { + + @Test + void contextLoads() { + } + +}