Search in sources :

Example 1 with DisbursementVoucherCoverSheetService

use of org.kuali.kfs.fp.document.service.DisbursementVoucherCoverSheetService in project cu-kfs by CU-CommunityApps.

the class DisbursementVoucherAction method printDisbursementVoucherCoverSheet.

/**
 * Calls service to generate the disbursement voucher cover sheet as a pdf.
 */
public ActionForward printDisbursementVoucherCoverSheet(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    DisbursementVoucherForm dvForm = (DisbursementVoucherForm) form;
    // get directory of template
    String directory = SpringContext.getBean(ConfigurationService.class).getPropertyValueAsString(KFSConstants.EXTERNALIZABLE_HELP_URL_KEY);
    DisbursementVoucherDocument document = (DisbursementVoucherDocument) SpringContext.getBean(DocumentService.class).getByDocumentHeaderId(request.getParameter(KFSPropertyConstants.DOCUMENT_NUMBER));
    // set workflow document back into form to prevent document authorizer "invalid (null)
    // document.documentHeader.workflowDocument" since we are bypassing form submit and just linking directly to the action
    dvForm.getDocument().getDocumentHeader().setWorkflowDocument(document.getDocumentHeader().getWorkflowDocument());
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    DisbursementVoucherCoverSheetService coverSheetService = SpringContext.getBean(DisbursementVoucherCoverSheetService.class);
    coverSheetService.generateDisbursementVoucherCoverSheet(document, baos);
    String fileName = document.getDocumentNumber() + "_cover_sheet.pdf";
    WebUtils.saveMimeOutputStreamAsFile(response, "application/pdf", baos, fileName);
    return (null);
}
Also used : DisbursementVoucherCoverSheetService(org.kuali.kfs.fp.document.service.DisbursementVoucherCoverSheetService) ConfigurationService(org.kuali.rice.core.api.config.property.ConfigurationService) ByteArrayOutputStream(java.io.ByteArrayOutputStream) DisbursementVoucherDocument(org.kuali.kfs.fp.document.DisbursementVoucherDocument)

Aggregations

ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 DisbursementVoucherDocument (org.kuali.kfs.fp.document.DisbursementVoucherDocument)1 DisbursementVoucherCoverSheetService (org.kuali.kfs.fp.document.service.DisbursementVoucherCoverSheetService)1 ConfigurationService (org.kuali.rice.core.api.config.property.ConfigurationService)1