From 42f705b26a09bbcea0adf097b3bb89007b976ae8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=A1s=C3=A1ry=20D=C3=A1niel?= Date: Fri, 3 Nov 2023 21:04:01 +0100 Subject: [PATCH] XLS import playlist logic first look --- .../hu/user/mcvodsync/db/PlaylistSync.java | 33 ++++++++++ .../mcvodsync/service/xls/ImportSummary.java | 66 +++++++++++++++++++ 2 files changed, 99 insertions(+) create mode 100644 mc-vod-sync/mc-vod-sync-db/src/main/java/hu/user/mcvodsync/db/PlaylistSync.java create mode 100644 mc-vod-sync/mc-vod-sync-service/src/main/java/hu/user/mcvodsync/service/xls/ImportSummary.java diff --git a/mc-vod-sync/mc-vod-sync-db/src/main/java/hu/user/mcvodsync/db/PlaylistSync.java b/mc-vod-sync/mc-vod-sync-db/src/main/java/hu/user/mcvodsync/db/PlaylistSync.java new file mode 100644 index 00000000..9d7072ef --- /dev/null +++ b/mc-vod-sync/mc-vod-sync-db/src/main/java/hu/user/mcvodsync/db/PlaylistSync.java @@ -0,0 +1,33 @@ +package hu.user.mcvodsync.db; + +import lombok.*; + +import javax.persistence.*; +import java.io.Serializable; +import java.util.Date; + +@Getter +@Setter +@Entity +@Builder +@ToString +@NoArgsConstructor +@AllArgsConstructor +public class PlaylistSync implements Serializable { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + Long id; + + private String playlist; + + @Column(nullable = false) + private Date imported; + + @Enumerated(EnumType.STRING) + @Column(nullable = false) + private SyncType syncType; + + private Date exportedSuccess; + + private Date exportedError; +} diff --git a/mc-vod-sync/mc-vod-sync-service/src/main/java/hu/user/mcvodsync/service/xls/ImportSummary.java b/mc-vod-sync/mc-vod-sync-service/src/main/java/hu/user/mcvodsync/service/xls/ImportSummary.java new file mode 100644 index 00000000..172206da --- /dev/null +++ b/mc-vod-sync/mc-vod-sync-service/src/main/java/hu/user/mcvodsync/service/xls/ImportSummary.java @@ -0,0 +1,66 @@ +package hu.user.mcvodsync.service.xls; + +import lombok.Builder; +import lombok.Getter; +import lombok.Setter; +import org.apache.commons.lang3.time.DurationFormatUtils; + +import java.time.Duration; +import java.time.Instant; + +@Getter +@Setter +@Builder +public class ImportSummary { + private Instant started; + + private Instant finished; + + private long all; + + private long success; + + private long error; + + private long inserted; + + private long updated; + + private long deleted; + + public String toString() { + Duration executionDuration = Duration.between(started, finished); + String duration = DurationFormatUtils.formatDuration(executionDuration.toMillis(), "H:mm:ss", true); + return String.format("Execution started at %s, finished at %s.", started, finished) + + System.lineSeparator() + + String.format("Process execution took %s on %d rows", duration, all) + + System.lineSeparator() + + String.format("Success count is %d, error count is %d", success, error) + + System.lineSeparator() + + String.format("Insert count is %d, update count is %d, delete count is %d", inserted, updated, deleted); + } + + public void incError() { + error++; + } + + public void incSuccess() { + success++; + } + + public void incInserted() { + inserted++; + } + + public void incUpdated() { + updated++; + } + + public void incDeleted() { + inserted++; + } + + public void incAll() { + all++; + } +} -- 2.54.0