Table of Contents |
---|
Overview
YC The platform provides a flexible mechanism to create report plugins that will naturally fit into existing report wizard interface, thus system integrator only need to concentrate on the business functionality around generating specific report.
...
By default most of the reports would be configured for the Admin app to provide business users with various statistical and accounting data. All out of the box report definitions are specified in Spring context file manager-report.xml. For customisations it is advisable to create your own maven module that would have core-module-reports as a dependency and would specify adm-servlet-ext.xml to naturally be included in the application.
Namely reportDescriptors list and reportWorkers map would need to be extended in order to include Spring beans of your custom reports.
...
Delivery report represents a PDF invoice that can be generated for any given order. We will look into the particulars of the report configuration, which should give an idea of how the whole report framework works both in Admin app and the storefront.
Admin app
Custom
...
implementation Label Body 3.6.0 Colour danger
Body | 3.6.0 |
---|---|
Colour | danger |
Info |
---|
This is old style method which is not recommended anymore. It does however show some concepts of reporting framework which are useful. The user is advised to use extension point (see next section) to create custom report implementations and inject additional custom reports. |
...
ReportDescriptor bean which is part of the reportDescriptors list
Code Block | ||
---|---|---|
| ||
<bean id="reportDelivery" class="org.yes.cart.report.ReportDescriptor"> <property name="reportId" value="reportDelivery"/> <property name="xslfoBase" value="client/order/delivery"/> <property name="parameters"> <list> <bean class="org.yes.cart.report.ReportParameter"> <property name="parameterId" value="orderNumber"/> <property name="businesstype" value="String"/> <property name="mandatory" value="true"/> </bean> </list> </property> </bean> |
...
DeliveryReportWorker bean which is part of the reportWorkers map
Code Block | ||
---|---|---|
| ||
<entry key="reportDelivery"> <bean class="org.yes.cart.report.impl.DeliveryReportWorker"> <constructor-arg index="0" ref="customerOrderService"/> <constructor-arg index="1" ref="shopService"/> <constructor-arg index="2" ref="shopFederationStrategy"/> </bean> </entry> |
...
Tip |
---|
For generating alternative report files (e.g. CSV, Image charts) you need to override the reportGenerator bean and provide a composite ReportGeneratorimplementation that can switch between the different report generator implementation depending on the report descriptor configurations. |
Reports via
...
extension Label Body 3.7.0+
Body | 3.7.0+ |
---|
...
Reports framework has been simplified in
...
version 3.7.0
...
.to to fully use extensions capability..
There are three extension points to allow to reconfigure the system without any changes to the core: reportDescriptors, reportWorkers and reportGenerators.
...
Out of the doc the platform now support two kinds of generator plug-ins: PDF and Excel report generators.
Storefront
Normally storefront would not need custom reports. However there are some cases when a report file needs to be generated. Such as the case with delivery report that can be used for providing customers with downloadable PDF invoice files for the orders they have placed.
...
Delivery report is fully configured in the CheckoutServiceFacadeImpl.printOrderByReference() method that programmatically creates a report descriptor and then triggers the PDF report generator with this descriptor object and the order object from the order history page.
Code Block | ||
---|---|---|
| ||
| ||
private ReportDescriptor createReceiptDescriptor() {
final ReportDescriptor receipt = new ReportDescriptor();
receipt.setReportId("reportDelivery");
receipt.setXslfoBase("client/order/delivery");
final ReportParameter param1 = new ReportParameter();
param1.setParameterId("orderNumber");
param1.setBusinesstype("String");
param1.setMandatory(true);
receipt.setParameters(Collections.singletonList(param1));
return receipt;
}
@Override
public void printOrderByReference(final String reference, final OutputStream outputStream) {
final CustomerOrder order = customerOrderService.findByReference(reference);
if (order != null) {
final Pair data = new Pair(order, order.getDelivery());
final Map<String, Object> values = new HashMap<>();
values.put("orderNumber", order.getOrdernum());
values.put("shop", order.getShop());
reportGenerator.generateReport(
createReceiptDescriptor(),
values,
data,
order.getLocale(),
outputStream
);
}
} |
Resulting file is sent to the output stream thus allowing this method to be used with URL mapping for a downloadable PDF link.
...