Skip to content

Commit

Permalink
Add timestamp to ECE CSV filenames (#721)
Browse files Browse the repository at this point in the history
Co-authored-by: Lauren Kemperman <lkemperman@codeforamerica.org>
  • Loading branch information
spokenbird and lkemperman-cfa authored May 14, 2024
1 parent 25befc0 commit cbbf76c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,14 @@ private static String createZipFilename(TransmissionType transmissionType, UUID
private void addZipEntries(CsvPackage csvPackage, ZipOutputStream zipOutput){
CsvPackageType packageType = csvPackage.getPackageType();
List<CsvType> 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);
Expand Down
18 changes: 9 additions & 9 deletions src/main/java/org/ladocuploader/app/csv/enums/CsvType.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

0 comments on commit cbbf76c

Please sign in to comment.