Search in sources :

Example 16 with Subscribe

use of io.jmix.ui.screen.Subscribe in project jmix-docs by Haulmont.

the class PivotSample method onInit.

// tag::pivot-table2[]
@Subscribe
protected void onInit(InitEvent event) {
    // ...
    // end::pivot-table2[]
    List<TipInfo> items = new ArrayList<>();
    items.add(tips(16.99, 1.01, Sex.FEMALE, false, Day.FRIDAY, Time.DINNER, 2));
    items.add(tips(10.34, 1.66, Sex.FEMALE, true, Day.THURSDAY, Time.LUNCH, 3));
    items.add(tips(21.01, 3.5, Sex.MALE, true, Day.FRIDAY, Time.LUNCH, 3));
    items.add(tips(23.68, 3.31, Sex.FEMALE, false, Day.MONDAY, Time.DINNER, 2));
    items.add(tips(24.59, 3.61, Sex.MALE, false, Day.TUESDAY, Time.LUNCH, 4));
    tipsDc.setItems(items);
    // tag::pivot-table3[]
    tipsCustomAggregatorPivotTable.setSortersFunction(new JsFunction("function(attr){if(attr == \"Day\"){return $.pivotUtilities.sortAs([\"Mon\",\"Tue\",\"Wed\",\"Thu\",\"Fri\",\"Sat\",\"Sun\"]);}}"));
    tipsCustomAggregatorPivotTable.getAggregation().setFunction(new JsFunction("$.pivotUtilities.aggregators[\"Sum\"]([\"Tip\"])"));
    DerivedProperties derivedProperties = new DerivedProperties();
    derivedProperties.addAttribute("Smokes", new JsFunction("function(record) {return record.Smoker == \"Yes\" ? \"True\" : \"False\";}"));
    tipsCustomAggregatorPivotTable.setDerivedProperties(derivedProperties);
}
Also used : JsFunction(io.jmix.pivottable.model.JsFunction) ArrayList(java.util.ArrayList) DerivedProperties(io.jmix.pivottable.model.DerivedProperties) TipInfo(pivottable.ex1.entity.TipInfo) Subscribe(io.jmix.ui.screen.Subscribe)

Example 17 with Subscribe

use of io.jmix.ui.screen.Subscribe in project jmix-docs by Haulmont.

the class RunReportScreen method onUrrBtn2Click.

@Subscribe("urrBtn2")
protected void onUrrBtn2Click(Button.ClickEvent event) {
    Report report = getReportByCode("BOOK_COUNT");
    // tag::in-background[]
    uiReportRunner.byReportEntity(report).withParametersDialogShowMode(ParametersDialogShowMode.IF_REQUIRED).inBackground(RunReportScreen.this).runAndShow();
// end::in-background[]
}
Also used : Report(io.jmix.reports.entity.Report) Subscribe(io.jmix.ui.screen.Subscribe)

Example 18 with Subscribe

use of io.jmix.ui.screen.Subscribe in project jmix-docs by Haulmont.

the class RunReportScreen method onRrcBtn1Click.

@Subscribe("rrcBtn1")
protected void onRrcBtn1Click(Button.ClickEvent event) {
    Report report = getReportByCode("BOOKS");
    LiteratureType type = dataManager.load(LiteratureType.class).query("select c from jmxrpr_LiteratureType c where c.name = :name").parameter("name", "Art").one();
    // tag::report-run-context-v1[]
    ReportRunContext context = new ReportRunContext(report).addParam("type", type).setOutputNamePattern("Books");
    // end::report-run-context-v1[]
    ReportOutputDocument document = reportRunner.run(context);
    List<ReportOutputDocument> documents = new ArrayList<>();
    documents.add(document);
    // tag::report-zip-utils[]
    byte[] zipArchiveContent = reportZipUtils.createZipArchive(documents);
    downloader.download(zipArchiveContent, "Reports.zip", DownloadFormat.ZIP);
// end::report-zip-utils[]
}
Also used : UiReportRunContext(io.jmix.reportsui.runner.UiReportRunContext) ReportRunContext(io.jmix.reports.runner.ReportRunContext) ReportOutputDocument(com.haulmont.yarg.reporting.ReportOutputDocument) Report(io.jmix.reports.entity.Report) ArrayList(java.util.ArrayList) LiteratureType(reports.ex2.entity.LiteratureType) Subscribe(io.jmix.ui.screen.Subscribe)

Example 19 with Subscribe

use of io.jmix.ui.screen.Subscribe in project jmix-docs by Haulmont.

the class RunReportScreen method onRrBtn2Click.

// end::rr-btn1-end[]
// tag::rr-btn2-start[]
@Subscribe("rrBtn2")
protected void onRrBtn2Click(Button.ClickEvent event) {
    // end::rr-btn2-start[]
    Report report = getReportByCode("BOOKS");
    LiteratureType type = dataManager.load(LiteratureType.class).query("select c from jmxrpr_LiteratureType c where c.name = :name").parameter("name", "Art").one();
    // tag::report-runner-v3[]
    ReportOutputDocument document = reportRunner.byReportEntity(report).addParam("type", type).withOutputType(// <1>
    ReportOutputType.PDF).withOutputNamePattern(// <2>
    "Books").run();
    // end::report-runner-v3[]
    // tag::get-content[]
    String documentName = document.getDocumentName();
    byte[] content = document.getContent();
// end::get-content[]
// tag::rr-btn2-end[]
}
Also used : ReportOutputDocument(com.haulmont.yarg.reporting.ReportOutputDocument) Report(io.jmix.reports.entity.Report) LiteratureType(reports.ex2.entity.LiteratureType) Subscribe(io.jmix.ui.screen.Subscribe)

Example 20 with Subscribe

use of io.jmix.ui.screen.Subscribe in project jmix-docs by Haulmont.

the class RunReportScreen method onRrcBtn2Click.

// tag::rrc-btn2-start[]
@Subscribe("rrcBtn2")
protected void onRrcBtn2Click(Button.ClickEvent event) {
    // end::rrc-btn2-start[]
    Report report = getReportByCode("BOOKS");
    LiteratureType type = dataManager.load(LiteratureType.class).query("select c from jmxrpr_LiteratureType c where c.name = :name").parameter("name", "Art").one();
    Map<String, Object> paramsMap = new HashMap<>();
    paramsMap.put("type", type);
    ReportTemplate template = dataManager.load(ReportTemplate.class).query("select c from report_ReportTemplate c where c.code = :code and c.report = :report").parameter("code", "DEFAULT").parameter("report", report).one();
    // tag::report-run-context-v2[]
    ReportRunContext context = new ReportRunContext(report).setReportTemplate(template).setOutputType(ReportOutputType.PDF).setParams(paramsMap);
    // end::report-run-context-v2[]
    // tag::report-runner-v1[]
    ReportOutputDocument document = reportRunner.run(// <1>
    new ReportRunContext(report).setParams(paramsMap));
// end::report-runner-v1[]
// ReportOutputDocument document = reportRunner.run(context);
// tag::rrc-btn2-end[]
}
Also used : UiReportRunContext(io.jmix.reportsui.runner.UiReportRunContext) ReportRunContext(io.jmix.reports.runner.ReportRunContext) ReportOutputDocument(com.haulmont.yarg.reporting.ReportOutputDocument) Report(io.jmix.reports.entity.Report) HashMap(java.util.HashMap) ReportTemplate(io.jmix.reports.entity.ReportTemplate) LiteratureType(reports.ex2.entity.LiteratureType) Subscribe(io.jmix.ui.screen.Subscribe)

Aggregations

Subscribe (io.jmix.ui.screen.Subscribe)79 Report (io.jmix.reports.entity.Report)8 Screen (io.jmix.ui.screen.Screen)8 ListDataProvider (io.jmix.ui.data.impl.ListDataProvider)5 UiController (io.jmix.ui.screen.UiController)5 UiDescriptor (io.jmix.ui.screen.UiDescriptor)5 UUID (java.util.UUID)5 Autowired (org.springframework.beans.factory.annotation.Autowired)5 ReportOutputDocument (com.haulmont.yarg.reporting.ReportOutputDocument)4 FileRef (io.jmix.core.FileRef)4 BigDecimal (java.math.BigDecimal)4 Date (java.util.Date)4 List (java.util.List)4 Order (test_support.entity.sales.Order)4 Metadata (io.jmix.core.Metadata)3 Visit (io.jmix.petclinic.entity.visit.Visit)3 UiReportRunContext (io.jmix.reportsui.runner.UiReportRunContext)3 FilterCondition (io.jmix.ui.entity.FilterCondition)3 GroupFilterCondition (io.jmix.ui.entity.GroupFilterCondition)3 LogicalFilterCondition (io.jmix.ui.entity.LogicalFilterCondition)3