-
Notifications
You must be signed in to change notification settings - Fork 1
Database implementation #39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ironpinguin
wants to merge
7
commits into
main
Choose a base branch
from
database_models-30
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
dab6f76
add database diagram and entity for event and style
ironpinguin a098517
Event, Room, Style, Sponsor & Session Entities added or updated
LauraSchl 18c49d7
add Entities for day, speaker, timeslot, timeslotSize
f39c343
Merge branch 'database_models-30' into database_models-30_entities
3d1bd32
fix entity mapping
dbd1bbb
Adds RoomController.kt; change hibernate config to update the database
40e999b
Merge pull request #43 from mayflower/database_models-30_entities
MareWalzl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,133 @@ | ||
| @startuml DatabaseModels | ||
|
|
||
| hide circle | ||
|
|
||
| skinparam linetype ortho | ||
|
|
||
| entity "Event" as e { | ||
| + id: ulid | ||
| + name: string | ||
| + description: string | ||
| + location: string | ||
| + startDate: date | ||
| + endDate: date | ||
| + style_id: ulid | ||
| + day_ids: ulid[] | ||
| + sponsor_ids: ulid[] | ||
| + session_ids: ulid[] | ||
| + timeslotSize_ids: ulid[] | ||
| -- | ||
| url: string | ||
| -- | ||
| + created_at: timestamp | ||
| + updated_at: timestamp | ||
| } | ||
|
|
||
| entity "style" as s { | ||
| + id: ulid | ||
| + name: string | ||
| + description: string | ||
| + color: string | ||
| + textColor: string | ||
| + image: string | ||
| + event_ids: ulid[] | ||
| -- | ||
| + created_at: timestamp | ||
| + updated_at: timestamp | ||
| } | ||
|
|
||
| entity "day" as d { | ||
| + id: ulid | ||
| + date: date | ||
| + note: string | ||
| + event_id: ulid | ||
| + room_ids: ulid[] | ||
| -- | ||
| + created_at: timestamp | ||
| + updated_at: timestamp | ||
| } | ||
|
|
||
| entity "room" as r { | ||
| + id: ulid | ||
| + name: string | ||
| + description: string | ||
| + day_ids: ulid[] | ||
| + timeslot_ids: ulid[] | ||
| -- | ||
| + created_at: timestamp | ||
| + updated_at: timestamp | ||
| } | ||
|
|
||
| entity "timeslot" as t { | ||
| + id: ulid | ||
| + start: time | ||
| + end: time | ||
| + room_id: ulid | ||
| + session_ids: ulid[] | ||
| + isBreak: boolean | ||
| + isBlocking: boolean | ||
| + isNoBlockingBreak: boolean | ||
| + timeslotSize_id: ulid | ||
| -- | ||
| + created_at: timestamp | ||
| + updated_at: timestamp | ||
| } | ||
|
|
||
| entity "timeslotSize" as ts { | ||
| + id: ulid | ||
| + name: string | ||
| + minutes: number | ||
| + timeslot_ids: ulid[] | ||
| -- | ||
| + created_at: timestamp | ||
| + updated_at: timestamp | ||
| } | ||
|
|
||
| entity "sponsor" as sp { | ||
| + id: ulid | ||
| + title: string | ||
| + description: string | ||
| + url: string | ||
| + image: string | ||
| + event_id: ulid | ||
| -- | ||
| + created_at: timestamp | ||
| + updated_at: timestamp | ||
| } | ||
|
|
||
| entity "session" as se { | ||
| + id: ulid | ||
| + name: string | ||
| + description: string | ||
| + timeslot_ids: ulid[] | ||
| + event_id: ulid | ||
| + speaker_ids: ulid[] | ||
| -- | ||
| + created_at: timestamp | ||
| + updated_at: timestamp | ||
| } | ||
|
|
||
| entity "speaker" as spk { | ||
| + id: ulid | ||
| + name: string | ||
| + description: string | ||
| + url: string | ||
| + image: string | ||
| + session_ids: ulid[] | ||
| -- | ||
| + created_at: timestamp | ||
| + updated_at: timestamp | ||
| } | ||
|
|
||
| e }o--|| s | ||
| e ||--|{ d | ||
| r }|--|{ d | ||
| r ||--|{ t | ||
| t }o--|| ts | ||
| e ||--|{ sp | ||
| e }|--|{ ts | ||
| e ||--|{ se | ||
| se ||--|{ spk | ||
| se |o--|| t | ||
|
|
||
| @enduml | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
packages/backend/src/main/kotlin/de/mayflower/backend/controller/RoomController.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| package de.mayflower.backend.controller | ||
|
|
||
| import de.mayflower.backend.entity.RoomEntity | ||
| import de.mayflower.backend.repository.RoomRepository | ||
| import de.mayflower.backend.stubs.api.RoomsControllerDelegate | ||
| import de.mayflower.backend.stubs.model.Room | ||
| import org.springframework.beans.factory.annotation.Autowired | ||
| import org.springframework.http.HttpStatus | ||
| import org.springframework.http.ResponseEntity | ||
| import org.springframework.stereotype.Component | ||
|
|
||
| @Component("roomsControllerDelegate") | ||
| class RoomController(private val roomRepository: RoomRepository) : RoomsControllerDelegate { | ||
|
|
||
| override fun getRooms(): ResponseEntity<List<Room>> { | ||
| val roomsEntityList = this.roomRepository.findAll() | ||
|
|
||
| val rooms = roomsEntityList.map { Room(it.id, it.name) } | ||
|
|
||
| return ResponseEntity(rooms, HttpStatus.OK) | ||
| } | ||
|
|
||
| override fun createRoom(room: Room?): ResponseEntity<Room> { | ||
|
|
||
| if(room === null) { | ||
| return ResponseEntity(HttpStatus.BAD_REQUEST) | ||
| } | ||
|
|
||
| val roomEntity = RoomEntity(room.name, "description") | ||
|
|
||
| this.roomRepository.save(roomEntity) | ||
|
|
||
| return ResponseEntity(room, HttpStatus.CREATED) | ||
| } | ||
| } |
29 changes: 29 additions & 0 deletions
29
packages/backend/src/main/kotlin/de/mayflower/backend/entity/DayEntity.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| package de.mayflower.backend.entity | ||
|
|
||
| import jakarta.persistence.* | ||
| import jakarta.validation.constraints.* | ||
| import org.hibernate.annotations.GenericGenerator | ||
| import java.util.Date | ||
|
|
||
| @Entity | ||
| @Table(name = "day") | ||
| class DayEntity( | ||
| @NotNull | ||
| val date: Date, | ||
|
|
||
| @NotNull | ||
| val note: String, | ||
|
|
||
| @ManyToOne(cascade = [CascadeType.ALL]) | ||
| val event: EventEntity = EventEntity(), | ||
|
|
||
| @ManyToMany(cascade = [CascadeType.ALL]) | ||
| val rooms: MutableSet<RoomEntity> = mutableSetOf() | ||
| ) { | ||
| @Id | ||
| @GenericGenerator(name = "ulid_generator", strategy = "de.mayflower.backend.helper.UlidGenerator") | ||
| @GeneratedValue(generator = "ulid_generator") | ||
| val id: String = String() | ||
|
|
||
| constructor() : this(Date(), String()) | ||
| } |
60 changes: 60 additions & 0 deletions
60
packages/backend/src/main/kotlin/de/mayflower/backend/entity/EventEntity.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| package de.mayflower.backend.entity | ||
|
|
||
| import jakarta.persistence.* | ||
| import jakarta.validation.constraints.* | ||
| import org.hibernate.annotations.GenericGenerator | ||
| import java.util.Date | ||
|
|
||
| @Entity | ||
| @Table(name = "event") | ||
| class EventEntity( | ||
| @NotNull | ||
| @NotBlank | ||
| var name: String, | ||
|
|
||
| @NotNull | ||
| var description: String, | ||
|
|
||
| @NotNull | ||
| var location: String, | ||
|
|
||
| @NotNull | ||
| var startDate: Date, | ||
|
|
||
| @NotNull | ||
| var endDate: Date, | ||
|
|
||
| var url: String, | ||
|
|
||
| @ManyToOne(cascade = [CascadeType.ALL]) | ||
| var style: Style = Style(), | ||
|
|
||
| @OneToMany( | ||
| //mappedBy = "event", | ||
| cascade = [CascadeType.ALL]) | ||
| var days: MutableSet<DayEntity> = mutableSetOf<DayEntity>(), | ||
|
|
||
| @OneToMany( | ||
| //mappedBy = "event", | ||
| cascade = [CascadeType.ALL]) | ||
| var sponsors: MutableSet<SponsorEntity> = mutableSetOf<SponsorEntity>(), | ||
|
|
||
| @OneToMany( | ||
| mappedBy = "event", | ||
| cascade = [CascadeType.ALL]) | ||
| var sessions: MutableSet<SessionEntity> = mutableSetOf(), | ||
|
|
||
| @OneToMany( | ||
| //mappedBy = "event", | ||
| cascade = [CascadeType.ALL]) | ||
| var timeSlotSizes: MutableSet<TimeslotSizeEntity> = mutableSetOf(), | ||
|
|
||
| ) { | ||
| @Id | ||
| @GenericGenerator(name = "ulid_generator", strategy = "de.mayflower.backend.helper.UlidGenerator") | ||
| @GeneratedValue(generator = "ulid_generator") | ||
| val id: String = String() | ||
|
|
||
| constructor() : this(String(), String(), String(), Date(), Date(), String()) | ||
|
|
||
| } |
15 changes: 12 additions & 3 deletions
15
packages/backend/src/main/kotlin/de/mayflower/backend/entity/RoomEntity.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,22 +1,31 @@ | ||
| package de.mayflower.backend.entity | ||
|
|
||
| import jakarta.persistence.* | ||
| import jakarta.validation.constraints.NotNull | ||
| import org.hibernate.annotations.GenericGenerator | ||
|
|
||
| @Entity | ||
| @Table(name = "room") | ||
| class RoomEntity( | ||
| val name: String, | ||
| @NotNull | ||
| var name: String, | ||
|
|
||
| var description: String, | ||
|
|
||
| @ManyToMany( | ||
| //mappedBy = "room", | ||
| cascade = [CascadeType.ALL]) | ||
| val days: MutableSet<DayEntity> = mutableSetOf(), | ||
|
|
||
| @OneToMany( | ||
| mappedBy = "room", | ||
| cascade = [CascadeType.ALL]) | ||
| val sessions: MutableSet<SessionEntity> = mutableSetOf<SessionEntity>() | ||
| val timeslots: MutableSet<TimeslotEntity> = mutableSetOf() | ||
| ) { | ||
| @Id | ||
| @GenericGenerator(name = "ulid_generator", strategy = "de.mayflower.backend.helper.UlidGenerator") | ||
| @GeneratedValue(generator = "ulid_generator") | ||
| val id: String = String() | ||
|
|
||
| constructor() : this(String()) | ||
| constructor() : this(String(), String()) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
packages/backend/src/main/kotlin/de/mayflower/backend/entity/SpeakerEntity.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| package de.mayflower.backend.entity | ||
|
|
||
| import jakarta.persistence.* | ||
| import jakarta.validation.constraints.* | ||
| import org.hibernate.annotations.GenericGenerator | ||
|
|
||
| @Entity | ||
| @Table(name = "speaker") | ||
| class SpeakerEntity( | ||
| @NotNull | ||
| val name: String, | ||
|
|
||
| @NotNull | ||
| val description: String, | ||
|
|
||
| @NotNull | ||
| val url: String, | ||
|
|
||
| @NotNull | ||
| val image: String, | ||
|
|
||
| @ManyToMany(cascade = [CascadeType.ALL]) | ||
| val sessions: MutableSet<SessionEntity> = mutableSetOf() | ||
| ) { | ||
| @Id | ||
| @GenericGenerator(name = "ulid_generator", strategy = "de.mayflower.backend.helper.UlidGenerator") | ||
| @GeneratedValue(generator = "ulid_generator") | ||
| val id: String = String() | ||
|
|
||
| constructor() : this(String(), String(), String(), String(), mutableSetOf()) | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are the above entries separated from the entries above? created_at and updated_at not implemented at this state.