Search in sources :

Example 86 with StorageObject

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);
}
Also used : StorageObject(it.cnr.si.spring.storage.StorageObject) Report(it.cnr.contab.reports.bulk.Report) Lettera_pagam_esteroBulk(it.cnr.contab.docamm00.docs.bulk.Lettera_pagam_esteroBulk) DistintaCassiere1210Bulk(it.cnr.contab.doccont00.intcass.bulk.DistintaCassiere1210Bulk) PDFMergerUtility(org.apache.pdfbox.multipdf.PDFMergerUtility) Timestamp(java.sql.Timestamp) PrintService(it.cnr.contab.reports.service.PrintService) Print_spoolerBulk(it.cnr.contab.reports.bulk.Print_spoolerBulk) ApplicationException(it.cnr.jada.comp.ApplicationException) SimpleDateFormat(java.text.SimpleDateFormat)

Aggregations

StorageObject (it.cnr.si.spring.storage.StorageObject)86 ApplicationException (it.cnr.jada.comp.ApplicationException)48 ComponentException (it.cnr.jada.comp.ComponentException)36 BigInteger (java.math.BigInteger)34 StorageException (it.cnr.si.spring.storage.StorageException)31 RemoteException (java.rmi.RemoteException)27 StoragePropertyNames (it.cnr.si.spring.storage.config.StoragePropertyNames)25 SpringUtil (it.cnr.contab.service.SpringUtil)24 BusinessProcessException (it.cnr.jada.action.BusinessProcessException)24 HttpActionContext (it.cnr.jada.action.HttpActionContext)24 OggettoBulk (it.cnr.jada.bulk.OggettoBulk)23 StoreService (it.cnr.si.spring.storage.StoreService)21 java.util (java.util)20 ServletException (javax.servlet.ServletException)19 ActionContext (it.cnr.jada.action.ActionContext)18 Unita_organizzativaBulk (it.cnr.contab.config00.sto.bulk.Unita_organizzativaBulk)16 EJBCommonServices (it.cnr.jada.util.ejb.EJBCommonServices)16 Collectors (java.util.stream.Collectors)16 Print_spoolerBulk (it.cnr.contab.reports.bulk.Print_spoolerBulk)15 Report (it.cnr.contab.reports.bulk.Report)15