use of com.axelor.apps.supplychain.db.DeclarationOfExchanges in project axelor-open-suite by axelor.
the class DeclarationOfExchangesController method export.
public void export(ActionRequest request, ActionResponse response) {
try {
DeclarationOfExchanges declarationOfExchanges = request.getContext().asType(DeclarationOfExchanges.class);
declarationOfExchanges = Beans.get(DeclarationOfExchangesRepository.class).find(declarationOfExchanges.getId());
Pair<Path, String> result = Beans.get(DeclarationOfExchangesService.class).export(declarationOfExchanges);
String fileLink = result.getLeft().toString();
String name = result.getRight();
ActionViewBuilder actionViewBuilder = ActionView.define(name).add("html", fileLink);
if (!"pdf".equalsIgnoreCase(declarationOfExchanges.getFormatSelect())) {
actionViewBuilder.param("download", "true");
}
response.setView(actionViewBuilder.map());
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
Aggregations