public ActionForward regenerateCorrespondence( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { MeetingHelperBase meetingHelper = ((MeetingFormBase) form).getMeetingHelper(); meetingHelper.setRegeneratedCorrespondences(new ArrayList<ProtocolCorrespondence>()); for (ProtocolCorrespondence protocolCorrespondence : meetingHelper.getCorrespondences()) { if (protocolCorrespondence.isRegenerateFlag()) { ProtocolBase protocol = protocolCorrespondence.getProtocol(); AttachmentDataSource dataSource = generateCorrespondenceDocumentAndAttach(protocol, protocolCorrespondence); PrintableAttachment source = new PrintableAttachment(); if (dataSource != null) { protocolCorrespondence.setCorrespondence(dataSource.getData()); protocolCorrespondence.setFinalFlag(false); protocolCorrespondence.setCreateUser(GlobalVariables.getUserSession().getPrincipalName()); protocolCorrespondence.setCreateTimestamp( KcServiceLocator.getService(DateTimeService.class).getCurrentTimestamp()); } meetingHelper.getRegeneratedCorrespondences().add(protocolCorrespondence); } } getBusinessObjectService().save(meetingHelper.getRegeneratedCorrespondences()); return mapping.findForward("correspondence"); }
public ActionForward printBudgetForm( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { BudgetForm budgetForm = (BudgetForm) form; Budget budget = budgetForm.getBudgetDocument().getBudget(); Integer selectedLine = getSelectedLine(request); String budgetFormToPrint = budget.getBudgetPrintForms().get(selectedLine).getBudgetReportId(); if (budgetForm.getSelectedToPrintComment() != null && budgetFormToPrint != null) { String forms[] = budgetForm.getSelectedToPrintComment(); if (forms[0].equals(budgetFormToPrint)) { budget.setPrintBudgetCommentFlag("true"); } } budgetForm.setSelectedToPrintComment(null); BudgetPrintService budgetPrintService = KcServiceLocator.getService(BudgetPrintService.class); ActionForward forward = mapping.findForward(MAPPING_BASIC); if (budgetFormToPrint != null) { AttachmentDataSource dataStream = budgetPrintService.readBudgetPrintStream(budget, budgetFormToPrint); if (dataStream.getData() != null) { streamToResponse(dataStream, response); forward = null; } } return forward; }
public ActionForward printQuestionnaireAnswer( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { // TODO : this is only available after questionnaire is saved ? ActionForward forward = mapping.findForward(Constants.MAPPING_BASIC); Map<String, Object> reportParameters = new HashMap<String, Object>(); ProtocolFormBase protocolForm = (ProtocolFormBase) form; ProtocolBase protocol = protocolForm.getActionHelper().getProtocol(); final int answerHeaderIndex = this.getSelectedLine(request); String methodToCall = (String) request.getAttribute(KRADConstants.METHOD_TO_CALL_ATTRIBUTE); String formProperty = StringUtils.substringBetween(methodToCall, ".printQuestionnaireAnswer.", ".line"); QuestionnaireHelperBase helper = (QuestionnaireHelperBase) BeanUtilsBean.getInstance().getPropertyUtils().getProperty(form, formProperty); AnswerHeader answerHeader = helper.getAnswerHeaders().get(answerHeaderIndex); // TODO : a flag to check whether to print answer or not // for release 3 : if questionnaire questions has answer, then print answer. reportParameters.put( QuestionnaireConstants.QUESTIONNAIRE_SEQUENCE_ID_PARAMETER_NAME, answerHeader.getQuestionnaire().getQuestionnaireSeqIdAsInteger()); reportParameters.put("template", answerHeader.getQuestionnaire().getTemplate()); reportParameters.put("coeusModuleSubItemCode", answerHeader.getModuleSubItemCode()); AttachmentDataSource dataStream = getQuestionnairePrintingService().printQuestionnaireAnswer(protocol, reportParameters); if (dataStream.getData() != null) { streamToResponse(dataStream, response); forward = null; } return forward; }
public AttachmentDataSource printAwardReportTracking(List<Printable> printableArtifactList) throws PrintingException { AttachmentDataSource attachmentDataSource = getPrintingService().print(printableArtifactList); String fileName = "ReportTrackingPrint" + Constants.PDF_FILE_EXTENSION; try { attachmentDataSource.setName(URLEncoder.encode(fileName, "UTF-8")); } catch (UnsupportedEncodingException e) { attachmentDataSource.setName(fileName); } attachmentDataSource.setType(Constants.PDF_REPORT_CONTENT_TYPE); return attachmentDataSource; }