Search in sources :

Example 1 with ReportData

use of io.jmix.reports.entity.wizard.ReportData in project jmix by jmix-framework.

the class ReportWizardCreator method buildReport.

@Nullable
public Report buildReport(boolean temporary) {
    ReportData reportData = reportDataDc.getItem();
    // be sure that reportData.name and reportData.outputFileFormat is not null before generation of template
    try {
        byte[] templateByteArray = reportWizard.generateTemplate(reportData, reportData.getTemplateFileType());
        reportData.setTemplateContent(templateByteArray);
    } catch (TemplateGenerationException e) {
        notifications.create(Notifications.NotificationType.WARNING).withCaption(messages.getMessage("templateGenerationException")).show();
        return null;
    }
    MetaClass entityMetaClass = metadata.getClass(reportData.getEntityName());
    String storeName = entityMetaClass.getStore().getName();
    if (!Stores.isMain(storeName)) {
        reportData.setDataStore(storeName);
    }
    Report report = reportWizard.toReport(reportData, temporary);
    reportData.setGeneratedReport(report);
    return report;
}
Also used : MetaClass(io.jmix.core.metamodel.model.MetaClass) Report(io.jmix.reports.entity.Report) ReportData(io.jmix.reports.entity.wizard.ReportData) TemplateGenerationException(io.jmix.reports.exception.TemplateGenerationException) Nullable(javax.annotation.Nullable)

Example 2 with ReportData

use of io.jmix.reports.entity.wizard.ReportData in project jmix by jmix-framework.

the class DetailsStepFragment method clearQuery.

protected void clearQuery() {
    ReportData reportData = reportDataDc.getItem();
    reportData.setQuery(null);
    reportData.setQueryParameters(null);
}
Also used : ReportData(io.jmix.reports.entity.wizard.ReportData)

Example 3 with ReportData

use of io.jmix.reports.entity.wizard.ReportData in project jmix by jmix-framework.

the class SaveStepFragment method onDownloadTemplateFileClick.

@Subscribe("downloadTemplateFile")
public void onDownloadTemplateFileClick(Button.ClickEvent event) {
    ReportData reportData = reportDataDc.getItem();
    try {
        TemplateFileType templateFileType = reportData.getTemplateFileType();
        byte[] newTemplate = reportWizardService.generateTemplate(reportData, templateFileType);
        downloader.download(new ByteArrayDataProvider(newTemplate, uiProperties.getSaveExportedByteArrayDataThresholdBytes(), coreProperties.getTempDir()), downloadTemplateFile.getCaption(), DownloadFormat.getByExtension(templateFileType.toString().toLowerCase()));
    } catch (TemplateGenerationException e) {
        notifications.create(Notifications.NotificationType.WARNING).withCaption(messages.getMessage(getClass(), "templateGenerationException")).show();
    }
}
Also used : ByteArrayDataProvider(io.jmix.ui.download.ByteArrayDataProvider) TemplateFileType(io.jmix.reports.entity.wizard.TemplateFileType) ReportData(io.jmix.reports.entity.wizard.ReportData) TemplateGenerationException(io.jmix.reports.exception.TemplateGenerationException)

Example 4 with ReportData

use of io.jmix.reports.entity.wizard.ReportData in project jmix by jmix-framework.

the class SaveStepFragment method beforeShow.

@Override
public void beforeShow() {
    if (StringUtils.isEmpty(outputFileName.getValue())) {
        ReportData reportData = reportDataDc.getItem();
        outputFileName.setValue(generateOutputFileName(reportData.getTemplateFileType().toString().toLowerCase()));
    }
    initChartPreview();
}
Also used : ReportData(io.jmix.reports.entity.wizard.ReportData)

Example 5 with ReportData

use of io.jmix.reports.entity.wizard.ReportData in project jmix by jmix-framework.

the class DetailsStepFragment method onEntityValueChange.

@Subscribe("entityField")
public void onEntityValueChange(HasValue.ValueChangeEvent<MetaClass> event) {
    ReportData reportData = reportDataDc.getItem();
    updateReportEntity(event.getPrevValue(), event.getValue(), reportData);
}
Also used : ReportData(io.jmix.reports.entity.wizard.ReportData) Subscribe(io.jmix.ui.screen.Subscribe)

Aggregations

ReportData (io.jmix.reports.entity.wizard.ReportData)8 MetaClass (io.jmix.core.metamodel.model.MetaClass)2 TemplateGenerationException (io.jmix.reports.exception.TemplateGenerationException)2 Subscribe (io.jmix.ui.screen.Subscribe)2 Report (io.jmix.reports.entity.Report)1 ReportTypeGenerate (io.jmix.reports.entity.wizard.ReportTypeGenerate)1 TemplateFileType (io.jmix.reports.entity.wizard.TemplateFileType)1 JpqlQueryBuilder (io.jmix.reportsui.screen.report.wizard.query.JpqlQueryBuilder)1 ByteArrayDataProvider (io.jmix.ui.download.ByteArrayDataProvider)1 Nullable (javax.annotation.Nullable)1