Search in sources :

Example 1 with ApplicationAttestationInstanceSummary

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);
}
Also used : EntityReference(org.finos.waltz.model.EntityReference) ApplicationAttestationInstanceSummary(org.finos.waltz.model.attestation.ApplicationAttestationInstanceSummary)

Example 2 with ApplicationAttestationInstanceSummary

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();
}
Also used : CellType(org.apache.poi.ss.usermodel.CellType) Spark.get(spark.Spark.get) APPLICATION(org.finos.waltz.schema.tables.Application.APPLICATION) EntityKind(org.finos.waltz.model.EntityKind) Spark.post(spark.Spark.post) CsvPreference(org.supercsv.prefs.CsvPreference) SXSSFWorkbook(org.apache.poi.xssf.streaming.SXSSFWorkbook) SelectConditionStep(org.jooq.SelectConditionStep) Tuple3(org.jooq.lambda.tuple.Tuple3) ExtractorUtilities.sanitizeSheetName(org.finos.waltz.web.endpoints.extracts.ExtractorUtilities.sanitizeSheetName) ExtractorUtilities.convertExcelToByteArray(org.finos.waltz.web.endpoints.extracts.ExtractorUtilities.convertExcelToByteArray) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Service(org.springframework.stereotype.Service) CsvListWriter(org.supercsv.io.CsvListWriter) ATTESTATION_INSTANCE_RECIPIENT(org.finos.waltz.schema.tables.AttestationInstanceRecipient.ATTESTATION_INSTANCE_RECIPIENT) Cell(org.apache.poi.ss.usermodel.Cell) SXSSFSheet(org.apache.poi.xssf.streaming.SXSSFSheet) DSLContext(org.jooq.DSLContext) StringUtilities(org.finos.waltz.common.StringUtilities) CellRangeAddress(org.apache.poi.ss.util.CellRangeAddress) ApplicationAttestationInstanceSummary(org.finos.waltz.model.attestation.ApplicationAttestationInstanceSummary) Record(org.jooq.Record) StringWriter(java.io.StringWriter) ATTESTATION_INSTANCE(org.finos.waltz.schema.tables.AttestationInstance.ATTESTATION_INSTANCE) Set(java.util.Set) IOException(java.io.IOException) ATTESTATION_RUN(org.finos.waltz.schema.tables.AttestationRun.ATTESTATION_RUN) String.format(java.lang.String.format) ApplicationAttestationInstanceInfo(org.finos.waltz.model.attestation.ApplicationAttestationInstanceInfo) Objects(java.util.Objects) List(java.util.List) Checks.checkNotNull(org.finos.waltz.common.Checks.checkNotNull) ExternalIdValue(org.finos.waltz.model.external_identifier.ExternalIdValue) CheckedConsumer.unchecked(org.jooq.lambda.fi.util.function.CheckedConsumer.unchecked) Tuple.tuple(org.jooq.lambda.tuple.Tuple.tuple) ListUtilities.asList(org.finos.waltz.common.ListUtilities.asList) ListUtilities(org.finos.waltz.common.ListUtilities) AttestationInstanceService(org.finos.waltz.service.attestation.AttestationInstanceService) WebUtilities(org.finos.waltz.web.WebUtilities) Row(org.apache.poi.ss.usermodel.Row) EntityReference(org.finos.waltz.model.EntityReference) Optional(java.util.Optional) StringWriter(java.io.StringWriter) List(java.util.List) ListUtilities.asList(org.finos.waltz.common.ListUtilities.asList) CsvListWriter(org.supercsv.io.CsvListWriter)

Aggregations

EntityReference (org.finos.waltz.model.EntityReference)2 ApplicationAttestationInstanceSummary (org.finos.waltz.model.attestation.ApplicationAttestationInstanceSummary)2 IOException (java.io.IOException)1 StringWriter (java.io.StringWriter)1 String.format (java.lang.String.format)1 List (java.util.List)1 Objects (java.util.Objects)1 Optional (java.util.Optional)1 Set (java.util.Set)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 Cell (org.apache.poi.ss.usermodel.Cell)1 CellType (org.apache.poi.ss.usermodel.CellType)1 Row (org.apache.poi.ss.usermodel.Row)1 CellRangeAddress (org.apache.poi.ss.util.CellRangeAddress)1 SXSSFSheet (org.apache.poi.xssf.streaming.SXSSFSheet)1 SXSSFWorkbook (org.apache.poi.xssf.streaming.SXSSFWorkbook)1 Checks.checkNotNull (org.finos.waltz.common.Checks.checkNotNull)1 ListUtilities (org.finos.waltz.common.ListUtilities)1 ListUtilities.asList (org.finos.waltz.common.ListUtilities.asList)1 StringUtilities (org.finos.waltz.common.StringUtilities)1