XLS import playlist logic first look
authorVásáry Dániel <vasary@elgekko.net>
Fri, 3 Nov 2023 20:04:01 +0000 (21:04 +0100)
committerVásáry Dániel <vasary@elgekko.net>
Fri, 3 Nov 2023 20:04:01 +0000 (21:04 +0100)
mc-vod-sync/mc-vod-sync-db/src/main/java/hu/user/mcvodsync/db/PlaylistSync.java [new file with mode: 0644]
mc-vod-sync/mc-vod-sync-service/src/main/java/hu/user/mcvodsync/service/xls/ImportSummary.java [new file with mode: 0644]

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 (file)
index 0000000..9d7072e
--- /dev/null
@@ -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 (file)
index 0000000..172206d
--- /dev/null
@@ -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++;
+    }
+}