001 /* 002 * Copyright 2011 The Kuali Foundation. 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 package org.kuali.kfs.module.ec.service.impl; 017 018 import java.util.Date; 019 import java.util.Map; 020 import java.util.ResourceBundle; 021 022 import net.sf.jasperreports.engine.JRParameter; 023 024 import org.kuali.kfs.module.ec.service.EffortCertificationReportService; 025 import org.kuali.kfs.module.ec.util.ExtractProcessReportDataHolder; 026 import org.kuali.kfs.sys.KFSConstants.ReportGeneration; 027 import org.kuali.kfs.sys.report.ReportInfo; 028 import org.kuali.kfs.sys.service.ReportGenerationService; 029 import org.springframework.transaction.annotation.Transactional; 030 031 /** 032 * To generate the working progress reports for the effort certification 033 */ 034 @Transactional 035 public class EffortCertificationReportServiceImpl implements EffortCertificationReportService { 036 private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(EffortCertificationReportServiceImpl.class); 037 038 private ReportGenerationService reportGenerationService; 039 private ReportInfo effortExtractProcessReportInfo; 040 041 /** 042 * @see org.kuali.kfs.module.ec.service.EffortCertificationReportService#generateReportForExtractProcess(org.kuali.kfs.module.ec.util.ExtractProcessReportDataHolder, java.util.Date) 043 */ 044 public void generateReportForExtractProcess(ExtractProcessReportDataHolder reportDataHolder, Date runDate) { 045 String reportFileName = effortExtractProcessReportInfo.getReportFileName(); 046 String reportDirectory = effortExtractProcessReportInfo.getReportsDirectory(); 047 String reportTemplateClassPath = effortExtractProcessReportInfo.getReportTemplateClassPath(); 048 String reportTemplateName = effortExtractProcessReportInfo.getReportTemplateName(); 049 ResourceBundle resourceBundle = effortExtractProcessReportInfo.getResourceBundle(); 050 String subReportTemplateClassPath = effortExtractProcessReportInfo.getSubReportTemplateClassPath(); 051 Map<String, String> subReports = effortExtractProcessReportInfo.getSubReports(); 052 053 Map<String, Object> reportData = reportDataHolder.getReportData(); 054 reportData.put(JRParameter.REPORT_RESOURCE_BUNDLE, resourceBundle); 055 reportData.put(ReportGeneration.PARAMETER_NAME_SUBREPORT_DIR, subReportTemplateClassPath); 056 reportData.put(ReportGeneration.PARAMETER_NAME_SUBREPORT_TEMPLATE_NAME, subReports); 057 058 String template = reportTemplateClassPath + reportTemplateName; 059 String fullReportFileName = reportGenerationService.buildFullFileName(runDate, reportDirectory, reportFileName, ""); 060 reportGenerationService.generateReportToPdfFile(reportData, template, fullReportFileName); 061 } 062 063 /** 064 * Sets the effortExtractProcessReportInfo attribute value. 065 * 066 * @param effortExtractProcessReportInfo The effortExtractProcessReportInfo to set. 067 */ 068 public void setEffortExtractProcessReportInfo(ReportInfo effortExtractProcessReportInfo) { 069 this.effortExtractProcessReportInfo = effortExtractProcessReportInfo; 070 } 071 072 /** 073 * Sets the reportGenerationService attribute value. 074 * 075 * @param reportGenerationService The reportGenerationService to set. 076 */ 077 public void setReportGenerationService(ReportGenerationService reportGenerationService) { 078 this.reportGenerationService = reportGenerationService; 079 } 080 }