@Override protected Object formBackingObject(HttpServletRequest request) throws Exception { ReviewAeReportCommand command = new ReviewAeReportCommand(expeditedAdverseEventReportDao, reportDao); String aeReportId = request.getParameter("aeReport"); String reportId = request.getParameter("report"); ExpeditedAdverseEventReport aeReport = expeditedAdverseEventReportDao.getById(Integer.parseInt(aeReportId)); Report report = reportDao.getById(Integer.parseInt(reportId)); if (report.isWorkflowEnabled() && report.getLastVersion().getReportStatus().equals(ReportStatus.COMPLETED) && report.getWorkflowId() != null) { User user = workflowService.findCoordinatingCenterReviewer(report.getWorkflowId()); if (user != null) { Reporter r = new Reporter(); r.copy(user); aeReport.setReviewer(r); } } else { aeReport.setReviewer(aeReport.getReporter()); } String xml = adeersReportGenerator.generateCaaersXml(aeReport, report); String pngOutFile = WebUtils.getBaseFileName(aeReportId, reportId); // CAAERS-5904, see report as per the report definition format List<String> list = adeersReportGenerator.generateImage(xml, tempDir + File.separator + pngOutFile, report); command.addFiles(aeReportId, reportId, list); if (reportId != null && !reportId.equals("") && !reportId.equals("null")) command.setReportId(Integer.parseInt(reportId)); else command.setReportId(null); // (CAAERS-5865)to perform sync only for ctep-esys studies, // set studyOutOfSync to false, so sync will not run for non-ctep-esys studies if (aeReport.getStudy().getCtepEsysIdentifier() == null) { command.setStudyOutOfSync(false); } command.setAeReport(aeReport); for (Report r : aeReport.getReports()) { if (r.getId().equals(Integer.parseInt(reportId))) command.setWorkflowEnabled(r.getReportDefinition().getWorkflowEnabled()); } return command; }
@SuppressWarnings("unchecked") @Override protected Map referenceData( final HttpServletRequest request, final Object cmd, final Errors errors) throws Exception { ReviewAeReportCommand command = (ReviewAeReportCommand) cmd; Map<String, Object> refdata = new HashMap<String, Object>(); Map<Integer, ReportSubmittability> reportMessages = new HashMap<Integer, ReportSubmittability>(); // evaluate business rules. ReportSubmittability reportSubmittability = new ReportSubmittability(); for (ExpeditedReportSection section : ExpeditedReportSection.values()) { if (!section.isAssociatedToBusinessRules()) continue; ValidationErrors validationErrors = evaluationService.validateReportingBusinessRules(command.getAeReport(), section); for (ValidationError vError : validationErrors.getErrors()) { reportSubmittability.addValidityMessage( section, messageSource.getMessage( vError.getCode(), vError.getReplacementVariables(), vError.getMessage(), Locale.getDefault())); } } reportMessages.put(ExpeditedAdverseEventInputCommand.ZERO, reportSubmittability); // -- check the report submittability for (Report report : command.getAeReport().getReports()) { reportMessages.put(report.getId(), reportValidationService.isSubmittable(report)); } refdata.put("reportMessages", reportMessages); // This is to check if the logged in person is SAE-Coordinator. // Data coordinator cannot submit a report. boolean isReportReviewer = SecurityUtils.hasAuthorityOf(UserGroupType.ae_expedited_report_reviewer); // boolean canSubmit = false; // if(reportMessages.get(command.ZERO).isSubmittable() && // reportMessages.get(command.getReportId()).isSubmittable() && isReportReviewer) // canSubmit = true; // refdata.put("canSubmit", canSubmit); refdata.put("isUserSAECoordinato", isReportReviewer); // additional information documents Integer additionalInformationId = command.getAeReport().getAdditionalInformation().getId(); List<AdditionalInformationDocument> additionalInformationDocuments = additionalInformationDocumentService.findByAdditionalInformationId(additionalInformationId); Map<String, List<AdditionalInformationDocument>> documents = AdditionalInformationDocument.groupDocumentsByDocumentType(additionalInformationDocuments); refdata.put("documents", documents); refdata.put("additionalInformationId", additionalInformationId); return refdata; }