use of it.cnr.si.spring.storage.StorageObject in project sigla-main by consiglionazionaledellericerche.
the class CRUDDistintaCassiere1210BP method generaDistinta.
public void generaDistinta(ActionContext actionContext) throws IOException, ComponentException {
DistintaCassiere1210Bulk distintaCassiere1210Bulk = (DistintaCassiere1210Bulk) getModel();
Timestamp currentTimestamp = EJBCommonServices.getServerTimestamp();
SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy");
Print_spoolerBulk print = new Print_spoolerBulk();
print.setPgStampa(UUID.randomUUID().getLeastSignificantBits());
print.setFlEmail(false);
print.setReport("/doccont/doccont/distinta_cassiere_1210.jasper");
print.setNomeFile("Distinta 1210 n. " + distintaCassiere1210Bulk.getPgDistinta() + ".pdf");
print.setUtcr(actionContext.getUserContext().getUser());
print.addParam("esercizio", String.valueOf(distintaCassiere1210Bulk.getEsercizio()), String.class);
print.addParam("pg_distinta", String.valueOf(distintaCassiere1210Bulk.getPgDistinta()), String.class);
print.addParam("DT_EMISSIONE", format.format(distintaCassiere1210Bulk.getDtEmissione()), String.class);
print.addParam("DT_INVIO", format.format(currentTimestamp), String.class);
Report report = SpringUtil.getBean("printService", PrintService.class).executeReport(actionContext.getUserContext(), print);
StorageObject node = documentiContabiliService.restoreSimpleDocument(distintaCassiere1210Bulk, report.getInputStream(), report.getContentType(), report.getName(), distintaCassiere1210Bulk.getStorePath(), false);
PDFMergerUtility ut = new PDFMergerUtility();
ByteArrayOutputStream out = new ByteArrayOutputStream();
ut.setDestinationStream(out);
ut.addSource(documentiContabiliService.getResource(node));
for (int i = 0; i < distintaCassiere1210LettereCollegate.countDetails(); i++) {
Lettera_pagam_esteroBulk lettera_pagam_esteroBulk = distintaCassiere1210LettereCollegate.getLettera(i);
ut.addSource(documentiContabiliService.getStreamDocumento(lettera_pagam_esteroBulk));
}
try {
ut.mergeDocuments(MemoryUsageSetting.setupMainMemoryOnly());
} catch (IOException _ex) {
throw new ApplicationException("\nAlla distinta risulta allegato un documento non in formato PDF" + ", pertanto รจ stato escluso dalla selezione.");
}
documentiContabiliService.restoreSimpleDocument(distintaCassiere1210Bulk, new ByteArrayInputStream(out.toByteArray()), MimeTypes.PDF.mimetype(), DocumentiContabiliService.DISTINTA_PEC_PDF, distintaCassiere1210Bulk.getStorePath(), false);
}
Aggregations