use of org.finos.waltz.model.attestation.ApplicationAttestationInstanceSummary in project waltz by khartec.
the class AttestationExtractor method prepareReport.
private Tuple3<ExtractFormat, String, byte[]> prepareReport(ExtractFormat format, EntityKind attestedKind, Long attestedId, ApplicationAttestationInstanceInfo applicationAttestationInstanceInfo) throws IOException {
Set<ApplicationAttestationInstanceSummary> attestationInstances = attestationInstanceService.findApplicationAttestationInstancesForKindAndSelector(attestedKind, attestedId, applicationAttestationInstanceInfo);
EntityReference entityReference = applicationAttestationInstanceInfo.selectionOptions().entityReference();
String fileName = format("%s-attestations-for-%s-%s", attestedKind, entityReference.kind().name().toLowerCase(), entityReference.id());
List<String> columnDefinitions = ListUtilities.asList("Application Id", "Application Name", "Asset Code", "Criticality", "Lifecycle Phase", "Kind", "Attested At", "Attested By");
return formatReport(format, fileName, columnDefinitions, attestationInstances);
}
use of org.finos.waltz.model.attestation.ApplicationAttestationInstanceSummary in project waltz by khartec.
the class AttestationExtractor method mkCSVReport.
private byte[] mkCSVReport(List<String> columnDefinitions, Set<ApplicationAttestationInstanceSummary> reportRows) throws IOException {
StringWriter writer = new StringWriter();
CsvListWriter csvWriter = new CsvListWriter(writer, CsvPreference.EXCEL_PREFERENCE);
csvWriter.write(columnDefinitions);
reportRows.forEach(unchecked(r -> {
List<Object> values = asList(r.appRef().id(), r.appRef().name().get(), r.appAssetCode(), r.appCriticality(), r.appLifecyclePhase(), r.appKind(), r.attestedAt(), r.attestedBy());
csvWriter.write(values);
}));
csvWriter.flush();
return writer.toString().getBytes();
}
Aggregations