-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement video data retrieval & saving (#35)
* Add Liquibase dependency * Add Liquibase migration to init schema & master changelog * Configure Liquibase to work with Spring * Add entities representing DB tables * Remove VideoImport entity * Add changeset into the master changelog * Add repositories for Playlists and Videos * Implement service allowing saving videos into the DB from a CVS file * Utilize ImportService in LibraryImportController * Add file to init DB schema & update docker-compose to use it * Add a changelog to populate the Playlists table with "Watch later" * Implement the ability to import also by providing a list of videos' IDs * Add more alignment rules into .editorconfig * Update gradle wrapper * Add a couple of ruled for Java in .editorconfig * Update Spring version to 3.3.4 * Move SecurityConfiguration to a different package * Add more rules to .editorconfig * Update exception handling * Finish import controller & corresponding services * Add indentation rule to .editorconfig * Extract interface & handle cases when video_id is already present in DB * Update event for saving videos VideoData is going to be saved only if it has changed or is not present for the given video * Fixed getting NPE when parsing tags * Disable liquibase for unit tests * Update dependencies * Remove H2 database dependency
- Loading branch information
Showing
31 changed files
with
652 additions
and
99 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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 |
---|---|---|
|
@@ -52,4 +52,6 @@ jobs: | |
createPR: false | ||
|
||
- name: Build with Gradle Wrapper | ||
env: | ||
SPRING_PROFILES_ACTIVE: test | ||
run: ./gradlew build |
This file contains 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
This file contains 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
Binary file not shown.
This file contains 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
This file contains 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 @@ | ||
CREATE SCHEMA IF NOT EXISTS ypm; |
2 changes: 1 addition & 1 deletion
2
...onfig/security/SecurityConfiguration.java → .../config/spring/SecurityConfiguration.java
This file contains 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
This file contains 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,8 @@ | ||
package com.ypm.constant; | ||
|
||
public enum ProcessingStatus { | ||
PROCESSING, | ||
COMPLETED, | ||
FAILED, | ||
NOT_FOUND | ||
} |
This file contains 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
This file contains 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,37 @@ | ||
package com.ypm.dto; | ||
|
||
import com.ypm.constant.ProcessingStatus; | ||
import lombok.Getter; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.Setter; | ||
import lombok.ToString; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
@Getter | ||
@ToString | ||
@RequiredArgsConstructor | ||
public final class BatchProcessingStatus { | ||
|
||
@Setter | ||
private ProcessingStatus status; | ||
|
||
@Setter | ||
private String errorMessage; | ||
|
||
private List<String> failedVideoIds; | ||
|
||
public BatchProcessingStatus(ProcessingStatus status) { | ||
this.status = status; | ||
this.failedVideoIds = new ArrayList<>(); | ||
} | ||
|
||
public void addFailedVideoId(String videoId) { | ||
failedVideoIds.add(videoId); | ||
} | ||
|
||
public void addFailedVideoIds(List<String> videoIds) { | ||
failedVideoIds.addAll(videoIds); | ||
} | ||
} |
This file contains 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,6 @@ | ||
package com.ypm.dto; | ||
|
||
import java.time.OffsetDateTime; | ||
|
||
public record VideoImportDto(String id, OffsetDateTime importDate) { | ||
} |
This file contains 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
This file contains 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
This file contains 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,32 @@ | ||
package com.ypm.persistence.entity; | ||
|
||
import jakarta.persistence.*; | ||
import lombok.Getter; | ||
import lombok.Setter; | ||
|
||
import java.util.LinkedHashSet; | ||
import java.util.Set; | ||
|
||
@Getter | ||
@Setter | ||
@Entity | ||
@Table(name = "playlists", schema = "ypm") | ||
public class Playlist { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "id", nullable = false) | ||
private Long id; | ||
|
||
@Column(name = "name", nullable = false) | ||
private String name; | ||
|
||
@Column(name = "description", length = Integer.MAX_VALUE) | ||
private String description; | ||
|
||
@Column(name = "status", length = Integer.MAX_VALUE) | ||
private String status; | ||
|
||
@OneToMany(mappedBy = "playlist") | ||
private Set<Video> videos = new LinkedHashSet<>(); | ||
} |
This file contains 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,45 @@ | ||
package com.ypm.persistence.entity; | ||
|
||
import jakarta.persistence.*; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
|
||
import java.time.LocalDate; | ||
|
||
@Getter | ||
@Setter | ||
@NoArgsConstructor | ||
@Entity | ||
@Table(name = "videos", schema = "ypm") | ||
public class Video { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "id", nullable = false) | ||
private Long id; | ||
|
||
@Column(name = "youtube_id", nullable = false, length = Integer.MAX_VALUE, unique = true) | ||
private String youtubeId; | ||
|
||
@Column(name = "import_date") | ||
private LocalDate importDate; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY, optional = false) | ||
@JoinColumn(name = "playlist_id", nullable = false) | ||
private Playlist playlist; | ||
|
||
@OneToOne(mappedBy = "video", cascade = CascadeType.ALL) | ||
private VideoData videoData; | ||
|
||
public Video(String youtubeId, LocalDate importDate) { | ||
this.youtubeId = youtubeId; | ||
this.importDate = importDate; | ||
} | ||
|
||
public Video(String youtubeId, LocalDate importDate, Playlist playlist) { | ||
this.youtubeId = youtubeId; | ||
this.importDate = importDate; | ||
this.playlist = playlist; | ||
} | ||
} |
Oops, something went wrong.