View Javadoc
1   /*
2    * Copyright 2009 The Kuali Foundation
3    * 
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    * http://www.opensource.org/licenses/ecl2.php
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.ole.sys.service.impl;
17  
18  import java.io.File;
19  
20  import org.kuali.ole.sys.service.FiscalYearAwareReportWriterService;
21  
22  /**
23   * Ensures that balance summary reports have the fiscal year included in the filename.
24   */
25  public class BalanceSummaryReportWriterTextServiceImpl extends ReportWriterTextServiceImpl implements FiscalYearAwareReportWriterService {
26      private Integer fiscalYear;
27      
28      /**
29       * @see org.kuali.ole.sys.service.impl.ReportWriterTextServiceImpl#destroy()
30       */
31      @Override
32      public void destroy() {
33          super.destroy();
34          
35          fiscalYear = null;
36      }
37  
38      /**
39       * @see org.kuali.ole.sys.service.impl.ReportWriterTextServiceImpl#initialize()
40       */
41      @Override
42      public void initialize() {
43          super.initialize();
44      }
45  
46      /**
47       * @see org.kuali.ole.sys.service.FiscalYearAwareReportWriterService#setFiscalYear(java.lang.Integer)
48       */
49      public void setFiscalYear(Integer fiscalYear) {
50          this.fiscalYear = fiscalYear;
51      }
52  
53      @Override
54      protected String generateFullFilePath() {
55          if (fiscalYear == null) {
56              throw new RuntimeException("fiscal year is blank");
57          }
58          if (isAggregationModeOn()) {
59              return filePath + File.separator + this.fileNamePrefix + fiscalYear.toString() + fileNameSuffix;            
60          }
61          else {
62              return filePath + File.separator + this.fileNamePrefix + fiscalYear.toString() + "_" + dateTimeService.toDateTimeStringForFilename(dateTimeService.getCurrentDate()) + fileNameSuffix;
63          }
64      }
65  }