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    
017    package org.kuali.kfs.module.ec.businessobject;
018    
019    import java.sql.Date;
020    import java.util.Collection;
021    import java.util.HashMap;
022    import java.util.LinkedHashMap;
023    import java.util.Map;
024    import java.util.Set;
025    
026    import org.kuali.kfs.coa.businessobject.AccountingPeriod;
027    import org.kuali.kfs.integration.ec.EffortCertificationReport;
028    import org.kuali.kfs.module.ec.EffortPropertyConstants;
029    import org.kuali.kfs.module.ec.util.AccountingPeriodMonth;
030    import org.kuali.kfs.sys.KFSPropertyConstants;
031    import org.kuali.kfs.sys.businessobject.SystemOptions;
032    import org.kuali.rice.kns.bo.Inactivateable;
033    import org.kuali.rice.kns.bo.PersistableBusinessObjectBase;
034    import org.kuali.rice.kns.util.TypedArrayList;
035    
036    /**
037     * Business Object for the Effort Certification Report Definition Table.
038     */
039    public class EffortCertificationReportDefinition extends PersistableBusinessObjectBase implements EffortCertificationReport, Inactivateable {
040    
041        private Integer universityFiscalYear;
042        private String effortCertificationReportNumber;
043        private String effortCertificationReportPeriodTitle;
044        private String effortCertificationReportPeriodStatusCode;
045        private Integer expenseTransferFiscalYear;
046        private String expenseTransferFiscalPeriodCode;
047        private String effortCertificationReportTypeCode;
048        private Date effortCertificationReportReturnDate;
049        private Integer effortCertificationReportBeginFiscalYear;
050        private String effortCertificationReportBeginPeriodCode;
051        private Integer effortCertificationReportEndFiscalYear;
052        private String effortCertificationReportEndPeriodCode;
053        private boolean active;
054    
055        private SystemOptions options;
056        private SystemOptions reportBeginFiscalYear;
057        private SystemOptions reportEndFiscalYear;
058        private AccountingPeriod reportBeginPeriod;
059        private AccountingPeriod reportEndPeriod;
060        private SystemOptions expenseTransferYear;
061        private AccountingPeriod expenseTransferFiscalPeriod;
062        private EffortCertificationPeriodStatusCode effortCertificationPeriodStatusCode;
063        private EffortCertificationReportType effortCertificationReportType;
064        private Collection<EffortCertificationReportPosition> effortCertificationReportPositions;
065    
066        private Map<Integer, Set<String>> reportPeriods;
067    
068        /**
069         * Constructs a EffortCertificationReportDefinition.java.
070         */
071        public EffortCertificationReportDefinition() {
072            super();
073            effortCertificationReportPositions = new TypedArrayList(EffortCertificationReportPosition.class);
074        }
075    
076        /**
077         * Gets the universityFiscalYear attribute.
078         * 
079         * @return Returns the universityFiscalYear.
080         */
081        public Integer getUniversityFiscalYear() {
082            return universityFiscalYear;
083        }
084    
085        /**
086         * Sets the universityFiscalYear attribute value.
087         * 
088         * @param universityFiscalYear The universityFiscalYear to set.
089         */
090        public void setUniversityFiscalYear(Integer universityFiscalYear) {
091            this.universityFiscalYear = universityFiscalYear;
092        }
093    
094        /**
095         * Gets the effortCertificationReportNumber attribute.
096         * 
097         * @return Returns the effortCertificationReportNumber.
098         */
099        public String getEffortCertificationReportNumber() {
100            return effortCertificationReportNumber;
101        }
102    
103        /**
104         * Sets the effortCertificationReportNumber attribute value.
105         * 
106         * @param effortCertificationReportNumber The effortCertificationReportNumber to set.
107         */
108        public void setEffortCertificationReportNumber(String effortCertificationReportNumber) {
109            this.effortCertificationReportNumber = effortCertificationReportNumber;
110        }
111    
112        /**
113         * Gets the effortCertificationReportPeriodTitle attribute.
114         * 
115         * @return Returns the effortCertificationReportPeriodTitle.
116         */
117        public String getEffortCertificationReportPeriodTitle() {
118            return effortCertificationReportPeriodTitle;
119        }
120    
121        /**
122         * Sets the effortCertificationReportPeriodTitle attribute value.
123         * 
124         * @param effortCertificationReportPeriodTitle The effortCertificationReportPeriodTitle to set.
125         */
126        public void setEffortCertificationReportPeriodTitle(String effortCertificationReportPeriodTitle) {
127            this.effortCertificationReportPeriodTitle = effortCertificationReportPeriodTitle;
128        }
129    
130        /**
131         * Gets the effortCertificationReportPeriodStatusCode attribute.
132         * 
133         * @return Returns the effortCertificationReportPeriodStatusCode.
134         */
135        public String getEffortCertificationReportPeriodStatusCode() {
136            return effortCertificationReportPeriodStatusCode;
137        }
138    
139        /**
140         * Sets the effortCertificationReportPeriodStatusCode attribute value.
141         * 
142         * @param effortCertificationReportPeriodStatusCode The effortCertificationReportPeriodStatusCode to set.
143         */
144        public void setEffortCertificationReportPeriodStatusCode(String effortCertificationReportPeriodStatusCode) {
145            this.effortCertificationReportPeriodStatusCode = effortCertificationReportPeriodStatusCode;
146        }
147    
148        /**
149         * Gets the expenseTransferFiscalYear attribute.
150         * 
151         * @return Returns the expenseTransferFiscalYear.
152         */
153        public Integer getExpenseTransferFiscalYear() {
154            return expenseTransferFiscalYear;
155        }
156    
157        /**
158         * Sets the expenseTransferFiscalYear attribute value.
159         * 
160         * @param expenseTransferFiscalYear The expenseTransferFiscalYear to set.
161         */
162        public void setExpenseTransferFiscalYear(Integer expenseTransferFiscalYear) {
163            this.expenseTransferFiscalYear = expenseTransferFiscalYear;
164        }
165    
166        /**
167         * Gets the expenseTransferFiscalPeriodCode attribute.
168         * 
169         * @return Returns the expenseTransferFiscalPeriodCode.
170         */
171        public String getExpenseTransferFiscalPeriodCode() {
172            return expenseTransferFiscalPeriodCode;
173        }
174    
175        /**
176         * Sets the expenseTransferFiscalPeriodCode attribute value.
177         * 
178         * @param expenseTransferFiscalPeriodCode The expenseTransferFiscalPeriodCode to set.
179         */
180        public void setExpenseTransferFiscalPeriodCode(String expenseTransferFiscalPeriodCode) {
181            this.expenseTransferFiscalPeriodCode = expenseTransferFiscalPeriodCode;
182        }
183    
184        /**
185         * Gets the effortCertificationReportTypeCode attribute.
186         * 
187         * @return Returns the effortCertificationReportTypeCode.
188         */
189        public String getEffortCertificationReportTypeCode() {
190            return effortCertificationReportTypeCode;
191        }
192    
193        /**
194         * Sets the effortCertificationReportTypeCode attribute value.
195         * 
196         * @param effortCertificationReportTypeCode The effortCertificationReportTypeCode to set.
197         */
198        public void setEffortCertificationReportTypeCode(String effortCertificationReportTypeCode) {
199            this.effortCertificationReportTypeCode = effortCertificationReportTypeCode;
200        }
201    
202        /**
203         * Gets the effortCertificationReportReturnDate attribute.
204         * 
205         * @return Returns the effortCertificationReportReturnDate.
206         */
207        public Date getEffortCertificationReportReturnDate() {
208            return effortCertificationReportReturnDate;
209        }
210    
211        /**
212         * Sets the effortCertificationReportReturnDate attribute value.
213         * 
214         * @param effortCertificationReportReturnDate The effortCertificationReportReturnDate to set.
215         */
216        public void setEffortCertificationReportReturnDate(Date effortCertificationReportReturnDate) {
217            this.effortCertificationReportReturnDate = effortCertificationReportReturnDate;
218        }
219    
220        /**
221         * Gets the effortCertificationReportBeginFiscalYear attribute.
222         * 
223         * @return Returns the effortCertificationReportBeginFiscalYear.
224         */
225        public Integer getEffortCertificationReportBeginFiscalYear() {
226            return effortCertificationReportBeginFiscalYear;
227        }
228    
229        /**
230         * Sets the effortCertificationReportBeginFiscalYear attribute value.
231         * 
232         * @param effortCertificationReportBeginFiscalYear The effortCertificationReportBeginFiscalYear to set.
233         */
234        public void setEffortCertificationReportBeginFiscalYear(Integer effortCertificationReportBeginFiscalYear) {
235            this.effortCertificationReportBeginFiscalYear = effortCertificationReportBeginFiscalYear;
236        }
237    
238        /**
239         * Gets the effortCertificationReportBeginPeriodCode attribute.
240         * 
241         * @return Returns the effortCertificationReportBeginPeriodCode.
242         */
243        public String getEffortCertificationReportBeginPeriodCode() {
244            return effortCertificationReportBeginPeriodCode;
245        }
246    
247        /**
248         * Sets the effortCertificationReportBeginPeriodCode attribute value.
249         * 
250         * @param effortCertificationReportBeginPeriodCode The effortCertificationReportBeginPeriodCode to set.
251         */
252        public void setEffortCertificationReportBeginPeriodCode(String effortCertificationReportBeginPeriodCode) {
253            this.effortCertificationReportBeginPeriodCode = effortCertificationReportBeginPeriodCode;
254        }
255    
256        /**
257         * Gets the effortCertificationReportEndFiscalYear attribute.
258         * 
259         * @return Returns the effortCertificationReportEndFiscalYear.
260         */
261        public Integer getEffortCertificationReportEndFiscalYear() {
262            return effortCertificationReportEndFiscalYear;
263        }
264    
265        /**
266         * Sets the effortCertificationReportEndFiscalYear attribute value.
267         * 
268         * @param effortCertificationReportEndFiscalYear The effortCertificationReportEndFiscalYear to set.
269         */
270        public void setEffortCertificationReportEndFiscalYear(Integer effortCertificationReportEndFiscalYear) {
271            this.effortCertificationReportEndFiscalYear = effortCertificationReportEndFiscalYear;
272        }
273    
274        /**
275         * Gets the effortCertificationReportEndPeriodCode attribute.
276         * 
277         * @return Returns the effortCertificationReportEndPeriodCode.
278         */
279        public String getEffortCertificationReportEndPeriodCode() {
280            return effortCertificationReportEndPeriodCode;
281        }
282    
283        /**
284         * Sets the effortCertificationReportEndPeriodCode attribute value.
285         * 
286         * @param effortCertificationReportEndPeriodCode The effortCertificationReportEndPeriodCode to set.
287         */
288        public void setEffortCertificationReportEndPeriodCode(String effortCertificationReportEndPeriodCode) {
289            this.effortCertificationReportEndPeriodCode = effortCertificationReportEndPeriodCode;
290        }
291    
292        /**
293         * Gets the expenseTransferFiscalPeriod attribute.
294         * 
295         * @return Returns the expenseTransferFiscalPeriod.
296         */
297        public AccountingPeriod getExpenseTransferFiscalPeriod() {
298            return expenseTransferFiscalPeriod;
299        }
300    
301        /**
302         * Sets the expenseTransferFiscalPeriod attribute value.
303         * 
304         * @param expenseTransferFiscalPeriod The expenseTransferFiscalPeriod to set.
305         */
306        @Deprecated
307        public void setExpenseTransferFiscalPeriod(AccountingPeriod expenseTransferFiscalPeriod) {
308            this.expenseTransferFiscalPeriod = expenseTransferFiscalPeriod;
309        }
310    
311        /**
312         * gets expenseTrasferYear
313         * @return
314         */
315        public SystemOptions getExpenseTransferYear() {
316            return expenseTransferYear;
317        }
318    
319        /**
320         * sets expenseTrasferYear attribute
321         * @param expenseTransferYear
322         */
323        @Deprecated
324        public void setExpenseTransferYear(SystemOptions expenseTransferYear) {
325            this.expenseTransferYear = expenseTransferYear;
326        }
327    
328        /**
329         * 
330         * gets reportBeginFiscalYear attribute value
331         * @return
332         */
333        public SystemOptions getReportBeginFiscalYear() {
334            return reportBeginFiscalYear;
335        }
336    
337        /**
338         * 
339         * sets the reportBeginFiscalYear attribute
340         * @param reportBeginFiscalYear
341         */
342        @Deprecated
343        public void setReportBeginFiscalYear(SystemOptions reportBeginFiscalYear) {
344            this.reportBeginFiscalYear = reportBeginFiscalYear;
345        }
346    
347        /**
348         * 
349         * gets reportEndFiscalYear attribute
350         * @return
351         */
352        public SystemOptions getReportEndFiscalYear() {
353            return reportEndFiscalYear;
354        }
355    
356        /**
357         * 
358         * sets reportEndFiscalYear attribute
359         * @param reportEndFiscalYear
360         */
361        @Deprecated
362        public void setReportEndFiscalYear(SystemOptions reportEndFiscalYear) {
363            this.reportEndFiscalYear = reportEndFiscalYear;
364        }
365    
366        /**
367         * 
368         * gets reportBeginPeriod
369         * @return
370         */
371        public AccountingPeriod getReportBeginPeriod() {
372            return reportBeginPeriod;
373        }
374    
375        /**
376         * sets reportBeginFiscalPeriod
377         * This method...
378         * @param reportBeginPeriod
379         */
380        @Deprecated
381        public void setReportBeginPeriod(AccountingPeriod reportBeginPeriod) {
382            this.reportBeginPeriod = reportBeginPeriod;
383        }
384    
385        /**
386         * gets reporEndPeriod
387         * @return
388         */
389        public AccountingPeriod getReportEndPeriod() {
390            return reportEndPeriod;
391        }
392    
393        /**
394         * sets reportEndPeriod
395         * @param reportEndPeriod
396         */
397        @Deprecated
398        public void setReportEndPeriod(AccountingPeriod reportEndPeriod) {
399            this.reportEndPeriod = reportEndPeriod;
400        }
401    
402        /**
403         * Gets the effortCertificationPeriodStatusCode attribute.
404         * 
405         * @return Returns the effortCertificationPeriodStatusCode.
406         */
407        public EffortCertificationPeriodStatusCode getEffortCertificationPeriodStatusCode() {
408            return effortCertificationPeriodStatusCode;
409        }
410    
411        /**
412         * Sets the effortCertificationPeriodStatusCode attribute value.
413         * 
414         * @param effortCertificationPeriodStatusCode The effortCertificationPeriodStatusCode to set.
415         */
416        @Deprecated
417        public void setEffortCertificationPeriodStatusCode(EffortCertificationPeriodStatusCode effortCertificationPeriodStatusCode) {
418            this.effortCertificationPeriodStatusCode = effortCertificationPeriodStatusCode;
419        }
420    
421        /**
422         * Gets the effortCertificationReportType attribute.
423         * 
424         * @return Returns the effortCertificationReportType.
425         */
426        public EffortCertificationReportType getEffortCertificationReportType() {
427            return effortCertificationReportType;
428        }
429    
430        /**
431         * Sets the effortCertificationReportType attribute value.
432         * 
433         * @param effortCertificationReportType The effortCertificationReportType to set.
434         */
435        @Deprecated
436        public void setEffortCertificationReportType(EffortCertificationReportType effortCertificationReportType) {
437            this.effortCertificationReportType = effortCertificationReportType;
438        }
439    
440        /**
441         * Gets the effortCertificationReportPositions attribute.
442         * 
443         * @return Returns the effortCertificationReportPositions.
444         */
445        public Collection<EffortCertificationReportPosition> getEffortCertificationReportPositions() {
446            return effortCertificationReportPositions;
447        }
448    
449        /**
450         * Sets the effortCertificationReportPositions attribute value.
451         * 
452         * @param effortCertificationReportPositions The effortCertificationReportPositions to set.
453         */
454        public void setEffortCertificationReportPositions(Collection<EffortCertificationReportPosition> effortCertificationReportPositions) {
455            this.effortCertificationReportPositions = effortCertificationReportPositions;
456        }
457    
458        /**
459         * Gets the active attribute.
460         * 
461         * @return Returns the active.
462         */
463        public boolean isActive() {
464            return active;
465        }
466    
467        /**
468         * Sets the active attribute value.
469         * 
470         * @param active The active to set.
471         */
472        public void setActive(boolean active) {
473            this.active = active;
474        }
475    
476        /**
477         * Gets the options attribute.
478         * 
479         * @return Returns the options.
480         */
481        public SystemOptions getOptions() {
482            return options;
483        }
484    
485        /**
486         * Sets the options attribute value.
487         * 
488         * @param options The options to set.
489         */
490        @Deprecated
491        public void setOptions(SystemOptions options) {
492            this.options = options;
493        }
494    
495        /**
496         * @see org.kuali.rice.kns.bo.BusinessObjectBase#toStringMapper()
497         */
498        protected LinkedHashMap toStringMapper() {
499            return new LinkedHashMap<String, String>(buildKeyMapForCurrentReportDefinition());
500        }
501    
502        /**
503         * build a primary key field map for the current report definition
504         * 
505         * @return a primary key field map for the current report definition
506         */
507        public Map<String, String> buildKeyMapForCurrentReportDefinition() {
508            return buildKeyMap(this.getUniversityFiscalYear(), this.getEffortCertificationReportNumber());
509        }
510    
511        /**
512         * build a primary key field map for a report definition from the given values
513         * 
514         * @param universityFiscalYear the given fiscal year
515         * @param reportNumber the given report number
516         * @return a primary key field map for a report definition
517         */
518        public static Map<String, String> buildKeyMap(Integer universityFiscalYear, String reportNumber) {
519            Map<String, String> primaryKeyMap = new HashMap<String, String>();
520    
521            String stringFiscalYear = (universityFiscalYear == null) ? "" : universityFiscalYear.toString();
522            primaryKeyMap.put(KFSPropertyConstants.UNIVERSITY_FISCAL_YEAR, stringFiscalYear);
523            primaryKeyMap.put(EffortPropertyConstants.EFFORT_CERTIFICATION_REPORT_NUMBER, reportNumber);
524    
525            return primaryKeyMap;
526        }
527    
528        /**
529         * build all report periods map covered by the specified report definition
530         */
531        public void buildReportPeriods() {
532            Integer beginYear = this.getEffortCertificationReportBeginFiscalYear();
533            String beginPeriodCode = this.getEffortCertificationReportBeginPeriodCode();
534            Integer endYear = this.getEffortCertificationReportEndFiscalYear();
535            String endPeriodCode = this.getEffortCertificationReportEndPeriodCode();
536    
537            this.setReportPeriods(AccountingPeriodMonth.findAccountingPeriodsBetween(beginYear, beginPeriodCode, endYear, endPeriodCode));
538        }
539    
540        /**
541         * Gets the reportPeriods attribute. 
542         * @return Returns the reportPeriods.
543         */
544        public Map<Integer, Set<String>> getReportPeriods() {
545            if (reportPeriods == null) {
546                this.buildReportPeriods();
547            }
548            return reportPeriods;
549        }
550    
551        /**
552         * Sets the reportPeriods attribute value.
553         * @param reportPeriods The reportPeriods to set.
554         */
555        public void setReportPeriods(Map<Integer, Set<String>> reportPeriods) {
556            this.reportPeriods = reportPeriods;
557        }
558    }