Search in sources :

Example 6 with ReportRunContext

use of io.jmix.reports.runner.ReportRunContext in project jmix by jmix-framework.

the class EmailTemplatesImpl method generateEmailInfoWithoutAttachments.

protected EmailInfo generateEmailInfoWithoutAttachments(ReportWithParams reportWithParams) {
    String body = "";
    String subject = "";
    if (reportWithParams != null && reportWithParams.getReport() != null) {
        ReportOutputDocument outputDocument = reportRunner.run(new ReportRunContext(reportWithParams.getReport()).setParams(reportWithParams.getParams()));
        body = new String(outputDocument.getContent(), UTF_8);
        subject = outputDocument.getDocumentName();
    }
    return EmailInfoBuilder.create().setSubject(subject).setBody(body).setBodyContentType(EmailInfo.HTML_CONTENT_TYPE).build();
}
Also used : ReportOutputDocument(com.haulmont.yarg.reporting.ReportOutputDocument) ReportRunContext(io.jmix.reports.runner.ReportRunContext)

Example 7 with ReportRunContext

use of io.jmix.reports.runner.ReportRunContext in project jmix by jmix-framework.

the class UiReportRunnerImpl method multiRunSync.

protected List<ReportOutputDocument> multiRunSync(UiReportRunContext uiReportRunContext, String multiParamName, Collection<Object> multiParamValues) {
    List<ReportOutputDocument> outputDocuments = new ArrayList<>();
    if (CollectionUtils.isNotEmpty(multiParamValues)) {
        multiParamValues.forEach(paramValue -> {
            Map<String, Object> map = new HashMap<>();
            map.put(multiParamName, paramValue);
            if (CollectionUtils.isNotEmpty(multiParamValues)) {
                map.putAll(uiReportRunContext.getParams());
            }
            ReportRunContext reportRunContext = new ReportRunContext(uiReportRunContext.getReport()).setReportTemplate(uiReportRunContext.getReportTemplate()).setParams(map).setOutputType(uiReportRunContext.getOutputType()).setOutputNamePattern(uiReportRunContext.getOutputNamePattern());
            ReportOutputDocument reportOutputDocument = reportRunner.run(reportRunContext);
            outputDocuments.add(reportOutputDocument);
        });
    }
    return outputDocuments;
}
Also used : ReportOutputDocument(com.haulmont.yarg.reporting.ReportOutputDocument) ReportRunContext(io.jmix.reports.runner.ReportRunContext)

Aggregations

ReportOutputDocument (com.haulmont.yarg.reporting.ReportOutputDocument)7 ReportRunContext (io.jmix.reports.runner.ReportRunContext)7 Report (io.jmix.reports.entity.Report)3 ReportTemplate (io.jmix.reports.entity.ReportTemplate)2 UiReportRunContext (io.jmix.reportsui.runner.UiReportRunContext)2 Subscribe (io.jmix.ui.screen.Subscribe)2 HashMap (java.util.HashMap)2 LiteratureType (reports.ex2.entity.LiteratureType)2 JsonSyntaxException (com.google.gson.JsonSyntaxException)1 OpenOfficeException (com.haulmont.yarg.exception.OpenOfficeException)1 ReportingInterruptedException (com.haulmont.yarg.exception.ReportingInterruptedException)1 NoFreePortsException (com.haulmont.yarg.formatters.impl.doc.connector.NoFreePortsException)1 ReportingAPI (com.haulmont.yarg.reporting.ReportingAPI)1 RunParams (com.haulmont.yarg.reporting.RunParams)1 DataManager (io.jmix.core.DataManager)1 EntityStates (io.jmix.core.EntityStates)1 Id (io.jmix.core.Id)1 EmailAttachment (io.jmix.email.EmailAttachment)1 PrototypesLoader (io.jmix.reports.PrototypesLoader)1 ReportExecutionHistoryRecorder (io.jmix.reports.ReportExecutionHistoryRecorder)1