use of com.axelor.apps.production.service.manuforder.ManufOrderPrintService in project axelor-open-suite by axelor.
the class ManufOrderController method print.
/**
* Method that generate a Pdf file for an manufacturing order
*
* @param request
* @param response
* @return
* @throws BirtException
* @throws IOException
*/
public void print(ActionRequest request, ActionResponse response) {
try {
ManufOrder manufOrder = request.getContext().asType(ManufOrder.class);
ManufOrderPrintService manufOrderPrintService = Beans.get(ManufOrderPrintService.class);
@SuppressWarnings("unchecked") List<Integer> selectedManufOrderList = (List<Integer>) request.getContext().get("_ids");
if (selectedManufOrderList != null) {
String name = manufOrderPrintService.getManufOrdersFilename();
String fileLink = manufOrderPrintService.printManufOrders(selectedManufOrderList.stream().map(Integer::longValue).collect(Collectors.toList()));
LOG.debug("Printing {}", name);
response.setView(ActionView.define(name).add("html", fileLink).map());
} else if (manufOrder != null) {
String name = manufOrderPrintService.getFileName(manufOrder);
String fileLink = manufOrderPrintService.printManufOrder(manufOrder);
LOG.debug("Printing {}", name);
response.setView(ActionView.define(name).add("html", fileLink).map());
} else {
response.setFlash(I18n.get(IExceptionMessage.MANUF_ORDER_1));
}
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
Aggregations