From cbbf76c875d35f39e5e4fec6919e8cc6d5296925 Mon Sep 17 00:00:00 2001 From: Alex Gonzalez Date: Tue, 14 May 2024 16:05:24 -0700 Subject: [PATCH] Add timestamp to ECE CSV filenames (#721) Co-authored-by: Lauren Kemperman --- .../app/cli/TransmitterCommands.java | 5 ++++- .../ladocuploader/app/csv/enums/CsvType.java | 18 +++++++++--------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/main/java/org/ladocuploader/app/cli/TransmitterCommands.java b/src/main/java/org/ladocuploader/app/cli/TransmitterCommands.java index 8455b3398..fad4dea1e 100644 --- a/src/main/java/org/ladocuploader/app/cli/TransmitterCommands.java +++ b/src/main/java/org/ladocuploader/app/cli/TransmitterCommands.java @@ -180,11 +180,14 @@ private static String createZipFilename(TransmissionType transmissionType, UUID private void addZipEntries(CsvPackage csvPackage, ZipOutputStream zipOutput){ CsvPackageType packageType = csvPackage.getPackageType(); List csvTypes = packageType.getCsvTypeList(); + DateTimeFormatter dtf = DateTimeFormatter.ofPattern("MMddyyyyHHmm"); + LocalDateTime now = LocalDateTime.now(); + String datePostfix = dtf.format(now); csvTypes.forEach(csvType -> { try { byte[] document = csvPackage.getCsvDocument(csvType).getCsvData(); - ZipEntry entry = new ZipEntry(csvType.getFileName()); + ZipEntry entry = new ZipEntry(csvType.getFileNamePrefix() + "-" + datePostfix + ".csv"); entry.setSize(document.length); zipOutput.putNextEntry(entry); zipOutput.write(document); diff --git a/src/main/java/org/ladocuploader/app/csv/enums/CsvType.java b/src/main/java/org/ladocuploader/app/csv/enums/CsvType.java index c23ec6a50..f1c58093d 100644 --- a/src/main/java/org/ladocuploader/app/csv/enums/CsvType.java +++ b/src/main/java/org/ladocuploader/app/csv/enums/CsvType.java @@ -4,18 +4,18 @@ @Getter public enum CsvType { - PARENT_GUARDIAN("ParentGuardian", "parent_guardian.csv"), - STUDENT("Student", "student.csv"), - RELATIONSHIP("Relationship", "relationship.csv"), - ECE_APPLICATION("ECE Application", "application.csv"), - JEFFERSON_ECE("Jefferson ECE", "jefferson_ece.csv"), - WIC_APPLICATION("WIC Application", "application.csv"); + PARENT_GUARDIAN("ParentGuardian", "parent_guardian"), + STUDENT("Student", "student"), + RELATIONSHIP("Relationship", "relationship"), + ECE_APPLICATION("ECE Application", "application"), + JEFFERSON_ECE("Jefferson ECE", "jefferson_ece"), + WIC_APPLICATION("WIC Application", "application"); private final String name; - private final String fileName; - CsvType(String name, String fileName) { + private final String fileNamePrefix; + CsvType(String name, String fileNamePrefix) { this.name = name; - this.fileName = fileName; + this.fileNamePrefix = fileNamePrefix; } }