Search in sources :

Example 1 with DefaultLoaderFactory

use of com.haulmont.yarg.loaders.factory.DefaultLoaderFactory in project tutorials by eugenp.

the class DocumentController method generateDocument.

@RequestMapping(path = "/generate/doc", method = RequestMethod.GET)
public void generateDocument(HttpServletResponse response) throws IOException {
    ReportBuilder reportBuilder = new ReportBuilder();
    ReportTemplateBuilder reportTemplateBuilder = new ReportTemplateBuilder().documentPath("./src/main/resources/Letter.docx").documentName("Letter.docx").outputType(ReportOutputType.docx).readFileFromPath();
    reportBuilder.template(reportTemplateBuilder.build());
    BandBuilder bandBuilder = new BandBuilder();
    String json = FileUtils.readFileToString(new File("./src/main/resources/Data.json"));
    ReportBand main = bandBuilder.name("Main").query("Main", "parameter=param1 $.main", "json").build();
    reportBuilder.band(main);
    Report report = reportBuilder.build();
    Reporting reporting = new Reporting();
    reporting.setFormatterFactory(new DefaultFormatterFactory());
    reporting.setLoaderFactory(new DefaultLoaderFactory().setJsonDataLoader(new JsonDataLoader()));
    response.setContentType("application/vnd.openxmlformats-officedocument.wordprocessingml.document");
    reporting.runReport(new RunParams(report).param("param1", json), response.getOutputStream());
}
Also used : RunParams(com.haulmont.yarg.reporting.RunParams) ReportBuilder(com.haulmont.yarg.structure.impl.ReportBuilder) BandBuilder(com.haulmont.yarg.structure.impl.BandBuilder) Report(com.haulmont.yarg.structure.Report) JsonDataLoader(com.haulmont.yarg.loaders.impl.JsonDataLoader) ReportTemplateBuilder(com.haulmont.yarg.structure.impl.ReportTemplateBuilder) DefaultFormatterFactory(com.haulmont.yarg.formatters.factory.DefaultFormatterFactory) Reporting(com.haulmont.yarg.reporting.Reporting) File(java.io.File) DefaultLoaderFactory(com.haulmont.yarg.loaders.factory.DefaultLoaderFactory) ReportBand(com.haulmont.yarg.structure.ReportBand) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with DefaultLoaderFactory

use of com.haulmont.yarg.loaders.factory.DefaultLoaderFactory in project jmix by jmix-framework.

the class ReportsConfiguration method loaderFactory.

@Bean("report_LoaderFactory")
public ReportLoaderFactory loaderFactory(JmixSqlDataLoader sqlDataLoader, JmixGroovyDataLoader groovyDataLoader, JpqlDataLoader jpqlDataLoader, JmixJsonDataLoader jsonDataLoader, SingleEntityDataLoader singleEntityDataLoader, MultiEntityDataLoader multiEntityDataLoader) {
    DefaultLoaderFactory loaderFactory = new DefaultLoaderFactory();
    Map<String, ReportDataLoader> dataLoaders = new HashMap<>();
    dataLoaders.put("sql", sqlDataLoader);
    dataLoaders.put("groovy", groovyDataLoader);
    dataLoaders.put("jpql", jpqlDataLoader);
    dataLoaders.put("json", jsonDataLoader);
    dataLoaders.put("single", singleEntityDataLoader);
    dataLoaders.put("multi", multiEntityDataLoader);
    loaderFactory.setDataLoaders(dataLoaders);
    return loaderFactory;
}
Also used : HashMap(java.util.HashMap) ReportDataLoader(com.haulmont.yarg.loaders.ReportDataLoader) DefaultLoaderFactory(com.haulmont.yarg.loaders.factory.DefaultLoaderFactory)

Aggregations

DefaultLoaderFactory (com.haulmont.yarg.loaders.factory.DefaultLoaderFactory)2 DefaultFormatterFactory (com.haulmont.yarg.formatters.factory.DefaultFormatterFactory)1 ReportDataLoader (com.haulmont.yarg.loaders.ReportDataLoader)1 JsonDataLoader (com.haulmont.yarg.loaders.impl.JsonDataLoader)1 Reporting (com.haulmont.yarg.reporting.Reporting)1 RunParams (com.haulmont.yarg.reporting.RunParams)1 Report (com.haulmont.yarg.structure.Report)1 ReportBand (com.haulmont.yarg.structure.ReportBand)1 BandBuilder (com.haulmont.yarg.structure.impl.BandBuilder)1 ReportBuilder (com.haulmont.yarg.structure.impl.ReportBuilder)1 ReportTemplateBuilder (com.haulmont.yarg.structure.impl.ReportTemplateBuilder)1 File (java.io.File)1 HashMap (java.util.HashMap)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1