-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TMI2-422 download spotlight files in zip folder (#83)
* download spotlight files in zip folder * Update src/main/java/gov/cabinetoffice/gap/adminbackend/services/GrantMandatoryQuestionService.java Co-authored-by: dominicwest <[email protected]> * pr comments --------- Co-authored-by: dominicwest <[email protected]>
- Loading branch information
1 parent
35c8f97
commit eccf93b
Showing
8 changed files
with
365 additions
and
122 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
src/main/java/gov/cabinetoffice/gap/adminbackend/constants/DueDiligenceHeaders.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package gov.cabinetoffice.gap.adminbackend.constants; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
public class DueDiligenceHeaders { | ||
|
||
public static final List<String> DUE_DILIGENCE_HEADERS = Arrays.asList("Application number (required)", | ||
"Organisation name (required)", "Address street (optional)", "Address town (optional)", | ||
"Address county (optional)", "Address postcode (required)", "Application amount (required)", | ||
"Charity Commission registration number (required - if applicable)", | ||
"Companies House registration number (required - if applicable)", "Organisation type (required)", | ||
"Similarities to other applications (optional)"); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
src/main/java/gov/cabinetoffice/gap/adminbackend/services/ZipService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package gov.cabinetoffice.gap.adminbackend.services; | ||
|
||
import gov.cabinetoffice.gap.adminbackend.utils.XlsxGenerator; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.io.ByteArrayOutputStream; | ||
import java.io.IOException; | ||
import java.util.List; | ||
import java.util.zip.ZipEntry; | ||
import java.util.zip.ZipOutputStream; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class ZipService { | ||
|
||
public ByteArrayOutputStream createZip(List<String> headersList, List<List<List<String>>> dataList, | ||
List<String> filenames) { | ||
ByteArrayOutputStream zipStream = new ByteArrayOutputStream(); | ||
|
||
try (ZipOutputStream zipOut = new ZipOutputStream(zipStream)) { | ||
for (int i = 0; i < dataList.size(); i++) { | ||
List<List<String>> data = dataList.get(i); | ||
if (!data.isEmpty()) { | ||
final String filename = filenames.get(i); | ||
|
||
final ByteArrayOutputStream excelStream = XlsxGenerator.createResource(headersList, data); | ||
|
||
final ZipEntry entry = new ZipEntry(filename); | ||
zipOut.putNextEntry(entry); | ||
zipOut.write(excelStream.toByteArray()); | ||
zipOut.closeEntry(); | ||
} | ||
} | ||
} | ||
catch (IOException e) { | ||
throw new RuntimeException("Failed to create ZIP file: " + e.getMessage()); | ||
} | ||
|
||
return zipStream; | ||
} | ||
|
||
} |
Oops, something went wrong.