Search in sources :

Example 1 with DeclarationOfExchanges

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);
    }
}
Also used : DeclarationOfExchanges(com.axelor.apps.supplychain.db.DeclarationOfExchanges) Path(java.nio.file.Path) DeclarationOfExchangesService(com.axelor.apps.supplychain.service.declarationofexchanges.DeclarationOfExchangesService) ActionViewBuilder(com.axelor.meta.schema.actions.ActionView.ActionViewBuilder)

Aggregations

DeclarationOfExchanges (com.axelor.apps.supplychain.db.DeclarationOfExchanges)1 DeclarationOfExchangesService (com.axelor.apps.supplychain.service.declarationofexchanges.DeclarationOfExchangesService)1 ActionViewBuilder (com.axelor.meta.schema.actions.ActionView.ActionViewBuilder)1 Path (java.nio.file.Path)1