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.util; 017 018 import java.util.ArrayList; 019 import java.util.HashMap; 020 import java.util.List; 021 import java.util.Map; 022 023 import org.kuali.kfs.module.ec.businessobject.EffortCertificationReportDefinition; 024 025 /** 026 * To group and hold the data presented to working reports of extract process 027 */ 028 public class ExtractProcessReportDataHolder { 029 private EffortCertificationReportDefinition reportDefinition; 030 private Map<String, Integer> basicStatistics; 031 private List<LedgerBalanceWithMessage> ledgerBalancesWithMessage; 032 033 private Map<String, Object> reportData; 034 035 public final static String KEY_OF_STATISTICS_ENTRY = "statistics"; 036 public final static String KEY_OF_ERRORS_ENTRY = "errors"; 037 public final static String REPORT_YEAR = "reportYear"; 038 public final static String REPORT_NUMBER = "reportNumber"; 039 public final static String REPORT_PERIOD_BEGIN = "reportPeriodBegin"; 040 public final static String REPORT_PERIOD_END = "reportPeriodEnd"; 041 042 /** 043 * Constructs a ExtractProcessReportDataHolder.java. 044 */ 045 public ExtractProcessReportDataHolder() { 046 this(null); 047 } 048 049 /** 050 * Constructs a ExtractProcessReportDataHolder.java. 051 * 052 * @param reportDefinition 053 */ 054 public ExtractProcessReportDataHolder(EffortCertificationReportDefinition reportDefinition) { 055 super(); 056 this.reportDefinition = reportDefinition; 057 this.basicStatistics = new HashMap<String, Integer>(); 058 this.ledgerBalancesWithMessage = new ArrayList<LedgerBalanceWithMessage>(); 059 this.reportData = new HashMap<String, Object>(); 060 } 061 062 /** 063 * update the value of the entry with the given key. If the key exists, the value will be the sum of the given and existing 064 * values; otherwise, create a new entry with the key and value. 065 * 066 * @param key the given key 067 * @param count the given count 068 */ 069 public void updateBasicStatistics(String key, Integer count) { 070 if (basicStatistics.containsKey(key)) { 071 Integer currentCount = basicStatistics.get(key); 072 count = currentCount + count; 073 } 074 basicStatistics.put(key, count); 075 } 076 077 /** 078 * Gets the reportDefinition attribute. 079 * 080 * @return Returns the reportDefinition. 081 */ 082 public EffortCertificationReportDefinition getReportDefinition() { 083 return reportDefinition; 084 } 085 086 /** 087 * Sets the reportDefinition attribute value. 088 * 089 * @param reportDefinition The reportDefinition to set. 090 */ 091 public void setReportDefinition(EffortCertificationReportDefinition reportDefinition) { 092 this.reportDefinition = reportDefinition; 093 } 094 095 /** 096 * Gets the basicStatistics attribute. 097 * 098 * @return Returns the basicStatistics. 099 */ 100 public Map<String, Integer> getBasicStatistics() { 101 return basicStatistics; 102 } 103 104 /** 105 * Sets the basicStatistics attribute value. 106 * 107 * @param basicStatistics The basicStatistics to set. 108 */ 109 public void setBasicStatistics(Map<String, Integer> basicStatistics) { 110 this.basicStatistics = basicStatistics; 111 } 112 113 /** 114 * Gets the ledgerBalancesWithMessage attribute. 115 * @return Returns the ledgerBalancesWithMessage. 116 */ 117 public List<LedgerBalanceWithMessage> getLedgerBalancesWithMessage() { 118 return ledgerBalancesWithMessage; 119 } 120 121 /** 122 * Sets the ledgerBalancesWithMessage attribute value. 123 * @param ledgerBalancesWithMessage The ledgerBalancesWithMessage to set. 124 */ 125 public void setLedgerBalancesWithMessage(List<LedgerBalanceWithMessage> ledgerBalancesWithMessage) { 126 this.ledgerBalancesWithMessage = ledgerBalancesWithMessage; 127 } 128 129 /** 130 * Gets the reportData attribute. 131 * @return Returns the reportData. 132 */ 133 public Map<String, Object> getReportData() { 134 reportData.put(REPORT_YEAR, reportDefinition.getUniversityFiscalYear()); 135 reportData.put(REPORT_NUMBER, reportDefinition.getEffortCertificationReportNumber()); 136 reportData.put(REPORT_PERIOD_BEGIN, reportDefinition.getEffortCertificationReportBeginPeriodCode() + "/" + reportDefinition.getEffortCertificationReportBeginFiscalYear()); 137 reportData.put(REPORT_PERIOD_END, reportDefinition.getEffortCertificationReportEndPeriodCode() + "/" + reportDefinition.getEffortCertificationReportEndFiscalYear()); 138 139 reportData.put(KEY_OF_STATISTICS_ENTRY, basicStatistics); 140 reportData.put(KEY_OF_ERRORS_ENTRY, ledgerBalancesWithMessage); 141 return reportData; 142 } 143 144 /** 145 * @see java.lang.Object#toString() 146 */ 147 @Override 148 public String toString() { 149 return this.getReportData().toString(); 150 } 151 }