From d963e3db6cfbff28f191e2220b2123551ebdc40c Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=A1s=C3=A1ry=20D=C3=A1niel?= Date: Tue, 5 Dec 2023 22:27:31 +0100 Subject: [PATCH] UI extended, scheduled execution built in --- mc-vod-sync/QUESTIONS.md | 31 ++- .../src/main/resources/application-dev.yaml | 17 +- .../user/mcvodsync/AssetImportExportBase.java | 119 ++++++++- .../user/mcvodsync/AssetImportExportIT.java | 23 +- .../hu/user/mcvodsync/BrightCoveClientIT.java | 250 +++++++++--------- .../java/hu/user/mcvodsync/RepositoryIT.java | 21 +- .../brightcove/BrightCoveClient.java | 93 ++++++- .../scripts/003_create_business_tables.sql | 2 +- .../java/hu/user/mcvodsync/db/UploadFile.java | 8 +- .../db/repository/AssetRepository.java | 6 + .../db/repository/AssetSyncRepository.java | 10 +- .../db/repository/PlaylistSyncRepository.java | 6 + .../db/repository/UploadFileRepository.java | 3 + .../mcvodsync/service/ServiceProperties.java | 19 ++ .../service/config/ScheduledTasks.java | 59 ++++- .../service/event/ExportCompletedEvent.java | 18 ++ .../service/event/ImportCompletedEvent.java | 18 ++ .../service/event/ImportStartedEvent.java | 14 + .../service/in/AssetImportService.java | 2 +- .../service/out/AssetExportService.java | 97 ++++--- .../mcvodsync/service/out/VideoMapper.java | 38 ++- .../service/schedule/ScheduledExport.java | 28 +- .../service/schedule/ScheduledImport.java | 40 ++- .../java/hu/user/mcvodsync/ui/Constants.java | 4 +- .../ui/config/ResourceConfigurer.java | 2 +- .../ui/config/WebSecurityConfig.java | 2 +- .../ui/data/BrightCovePlaylistDataModel.java | 36 +++ .../ui/data/BrightCoveVideoDataModel.java | 49 ++++ ...ataModel.java => ImportFileDataModel.java} | 2 +- .../ui/view/BrowseRemoteViewModel.java | 46 ++++ .../ui/view/ExportDataViewModel.java | 45 ++++ .../mcvodsync/ui/view/ImportEventHandler.java | 37 +++ ...iewModel.java => ImportFileViewModel.java} | 34 ++- .../mcvodsync/ui/view/IndexViewModel.java | 98 ++++++- .../src/main/resources/metainfo/zk/zk.xml | 10 + .../src/main/resources/web/browse-remote.zul | 48 ++++ .../src/main/resources/web/export-data.zul | 14 + .../src/main/resources/web/import-file.zul | 131 +++++++++ .../src/main/resources/web/index.zul | 22 +- .../src/main/resources/web/upload-files.zul | 36 --- 40 files changed, 1232 insertions(+), 306 deletions(-) create mode 100644 mc-vod-sync/mc-vod-sync-service/src/main/java/hu/user/mcvodsync/service/event/ExportCompletedEvent.java create mode 100644 mc-vod-sync/mc-vod-sync-service/src/main/java/hu/user/mcvodsync/service/event/ImportCompletedEvent.java create mode 100644 mc-vod-sync/mc-vod-sync-service/src/main/java/hu/user/mcvodsync/service/event/ImportStartedEvent.java create mode 100644 mc-vod-sync/mc-vod-sync-ui/src/main/java/hu/user/mcvodsync/ui/data/BrightCovePlaylistDataModel.java create mode 100644 mc-vod-sync/mc-vod-sync-ui/src/main/java/hu/user/mcvodsync/ui/data/BrightCoveVideoDataModel.java rename mc-vod-sync/mc-vod-sync-ui/src/main/java/hu/user/mcvodsync/ui/data/{UploadFileDataModel.java => ImportFileDataModel.java} (96%) create mode 100644 mc-vod-sync/mc-vod-sync-ui/src/main/java/hu/user/mcvodsync/ui/view/BrowseRemoteViewModel.java create mode 100644 mc-vod-sync/mc-vod-sync-ui/src/main/java/hu/user/mcvodsync/ui/view/ExportDataViewModel.java create mode 100644 mc-vod-sync/mc-vod-sync-ui/src/main/java/hu/user/mcvodsync/ui/view/ImportEventHandler.java rename mc-vod-sync/mc-vod-sync-ui/src/main/java/hu/user/mcvodsync/ui/view/{UploadFilesViewModel.java => ImportFileViewModel.java} (69%) create mode 100644 mc-vod-sync/mc-vod-sync-ui/src/main/resources/web/browse-remote.zul create mode 100644 mc-vod-sync/mc-vod-sync-ui/src/main/resources/web/export-data.zul create mode 100644 mc-vod-sync/mc-vod-sync-ui/src/main/resources/web/import-file.zul delete mode 100644 mc-vod-sync/mc-vod-sync-ui/src/main/resources/web/upload-files.zul diff --git a/mc-vod-sync/QUESTIONS.md b/mc-vod-sync/QUESTIONS.md index 196c36f8..d1c780a2 100644 --- a/mc-vod-sync/QUESTIONS.md +++ b/mc-vod-sync/QUESTIONS.md @@ -1,6 +1,33 @@ -* A custom fields API kellhet? Ott be lehet állítani a custom filed-re pl. azt, hogy kötelező e, így amíg nincs értéke +actors_talent, Actors/Talent, , string, null required: false +director, Director, , string, null required: false +episode, Episode, , +enum, [1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 2, 20, 21, 22, 23, 24, 25, 26, 3, 4, 5, 6, 7, 8, 9] required: false +genre, Genre, , enum, [Novel, Spektrum saját gyártás, Thriller, action, adnimation, adult, adventure, animals, comedy] +required: false +notes, Notes, , string, null required: false +parent_network, Parent Network, , enum, [AMC+ Hungary (Selekt), Selekt] required: false +production_year, Production Year, , string, null required: false +rating_tv, Rating TV, , enum, [18, 18+] required: false +season, Season, , enum, [1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 2, 20, 3, 4, 5, 6, 7, 8, 9, Special] required: false +show, Show, , string, null required: false +tms_episode_id, TMS Episode ID, , string, null required: false +tms_movie_id, TMS Movie ID, , string, null required: false +tms_series_id, TMS Series ID, , string, null required: false +tms_season_id, TMS Season ID, , string, null required: false +video_category, Video Category, , enum, [Movie, Series] required: false +video_type, Video Type, , enum, [Full Episode, Full Movie, Sports] required: false +s3_captions_url, S3 Captions URL, , string, null required: false +s3_video_url, S3 Video URL, , string, null required: false +downloadable, Downloadable, , enum, [NO, YES] required: false +MaxCustomFields: 30 + +- Az age_rating jelenleg 18,18+. Adjam hozzá az újakat, vagy dobjam el a nem jó értékeket? A többi enumra is ez a + kérdés (episode, season) +- Mit jelent a season Special? +- A playlist neve nem kötelezően egyedi, de kezelhető egyedinek? Az update miatt érdekes (episode, season) +- A custom fields API kellhet? Ott be lehet állítani a custom filed-re pl. azt, hogy kötelező e, így amíg nincs értéke addig a videó nem aktív. Ennek használata nélkül is létrehozható video? -* + * A sunset kezelése is kell, tehát jöhet adat későbbi sunset-el? * A sunset és sunrise formátuma legyen egyforma (mindegy melyik) minden sorra! * Mik a kötelező mezők? Most: playlist, sunset, sunrise, title diff --git a/mc-vod-sync/mc-vod-sync-app/src/main/resources/application-dev.yaml b/mc-vod-sync/mc-vod-sync-app/src/main/resources/application-dev.yaml index 7a5ee750..e5fc5a9c 100644 --- a/mc-vod-sync/mc-vod-sync-app/src/main/resources/application-dev.yaml +++ b/mc-vod-sync/mc-vod-sync-app/src/main/resources/application-dev.yaml @@ -34,11 +34,20 @@ spring: logging: level: org.hibernate.engine.jdbc.spi.SqlExceptionHelper: ERROR +# org.springframework.web.client.RestTemplate: DEBUG +# org.apache.http: DEBUG +# httpclient.wire: DEBUG mc-vod-sync: - scheduler: - import: true - export: true - sunrise-checker: true + service: + target-video-insert-enabled: true + target-playlist-insert-enabled: true + scheduler: + import-enabled: false + export-enabled: false + sunrise-checker-enabled: false + import-cron: 0 0 4 1/1 * ? * + export-cron: 0 0 4 1/1 * ? * + sunrise-checker-cron: 0 0 4 1/1 * ? * application: user-name: user password: password diff --git a/mc-vod-sync/mc-vod-sync-app/src/test/java/hu/user/mcvodsync/AssetImportExportBase.java b/mc-vod-sync/mc-vod-sync-app/src/test/java/hu/user/mcvodsync/AssetImportExportBase.java index 7d50548a..050b363e 100644 --- a/mc-vod-sync/mc-vod-sync-app/src/test/java/hu/user/mcvodsync/AssetImportExportBase.java +++ b/mc-vod-sync/mc-vod-sync-app/src/test/java/hu/user/mcvodsync/AssetImportExportBase.java @@ -5,13 +5,21 @@ package hu.user.mcvodsync; +import com.brightcove.cms.client.model.Playlist; +import com.brightcove.cms.client.model.Video; +import hu.user.mcvodsync.brightcove.BrightCoveClient; +import hu.user.mcvodsync.brightcove.PagedSearch; +import hu.user.mcvodsync.db.Asset; import hu.user.mcvodsync.db.PlaylistSync; import hu.user.mcvodsync.db.SyncType; import hu.user.mcvodsync.db.repository.AssetRepository; import hu.user.mcvodsync.db.repository.AssetSyncRepository; import hu.user.mcvodsync.db.repository.PlaylistSyncRepository; +import hu.user.mcvodsync.service.in.AssetImportService; import hu.user.mcvodsync.service.in.ImportSummary; import hu.user.mcvodsync.service.in.VodXlsProcessor; +import hu.user.mcvodsync.service.out.AssetExportService; +import hu.user.mcvodsync.service.out.VideoMapper; import lombok.extern.log4j.Log4j2; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -21,8 +29,12 @@ import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.stream.Collectors; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; @Log4j2 @@ -39,6 +51,18 @@ public class AssetImportExportBase { @Autowired private PlaylistSyncRepository playlistSyncRepository; + @Autowired + private AssetImportService assetImportService; + + @Autowired + private AssetExportService assetExportService; + + @Autowired + private BrightCoveClient brightCoveClient; + + @Autowired + private VideoMapper videoMapper; + protected String getPlaylistSyncIds(String name) { List playlists = playlistSyncRepository.findAllByName(name); assertEquals(1, playlists.size()); @@ -46,17 +70,64 @@ public class AssetImportExportBase { } protected void cleanup() { - cleanupSync(); + cleanupLocal(); + cleanupRemote(); assetRepository.deleteAllInBatch(); } - protected void cleanupSync() { + protected void cleanupRemote() { + log.info("cleanupRemote"); + cleanupRemotePlaylists(); + cleanupRemoteVideos(); + log.info("cleanupRemote OK"); + } + + private void cleanupRemoteVideos() { + PagedSearch