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.ArrayList;
019 import java.util.List;
020 import java.util.Map;
021 import java.util.Set;
022
023 import org.kuali.kfs.integration.ec.EffortCertificationReport;
024 import org.kuali.kfs.integration.ec.EffortCertificationModuleService;
025 import org.kuali.kfs.module.ec.EffortConstants;
026 import org.kuali.kfs.module.ec.EffortConstants.SystemParameters;
027 import org.kuali.kfs.module.ec.batch.EffortCertificationExtractStep;
028 import org.kuali.kfs.module.ec.dataaccess.EffortCertificationReportDefinitionDao;
029 import org.kuali.kfs.module.ec.service.EffortCertificationReportDefinitionService;
030 import org.kuali.kfs.module.ec.util.AccountingPeriodMonth;
031 import org.kuali.kfs.sys.context.SpringContext;
032 import org.kuali.rice.kns.service.ParameterService;
033 import org.springframework.transaction.annotation.Transactional;
034
035 /**
036 * @see org.kuali.kfs.integration.service.EffortCertificationService
037 */
038 @Transactional
039 public class EffortCertificationModuleServiceImpl implements EffortCertificationModuleService {
040
041 /**
042 * @see org.kuali.kfs.integration.service.EffortCertificationService#findReportDefinitionsForPeriod(java.lang.Integer,
043 * java.lang.String, java.lang.String)
044 */
045 public List<EffortCertificationReport> findReportDefinitionsForPeriod(Integer fiscalYear, String periodCode, String positionObjectGroupCode) {
046 List<EffortCertificationReport> effortCertificationReports = this.getEffortCertificationReportDefinitionDao().getAllByYearAndPositionCode(fiscalYear, positionObjectGroupCode);
047
048 List<EffortCertificationReport> reportsContainingPeriod = new ArrayList<EffortCertificationReport>();
049 for (EffortCertificationReport report : effortCertificationReports) {
050 Map<Integer, Set<String>> reportPeriods = AccountingPeriodMonth.findAccountingPeriodsBetween(report.getEffortCertificationReportBeginFiscalYear(), report.getEffortCertificationReportBeginPeriodCode(), report.getEffortCertificationReportEndFiscalYear(), report.getEffortCertificationReportEndPeriodCode());
051 Set<String> periodsForYear = reportPeriods.get(fiscalYear);
052 if (periodsForYear.contains(periodCode)) {
053 reportsContainingPeriod.add(report);
054 }
055 }
056
057 return reportsContainingPeriod;
058 }
059
060 /**
061 * @see org.kuali.kfs.integration.service.EffortCertificationService#isEmployeeWithOpenCertification(java.util.List,
062 * java.lang.String)
063 */
064 public EffortCertificationReport isEmployeeWithOpenCertification(List<EffortCertificationReport> effortCertificationReports, String emplid) {
065 for (EffortCertificationReport report : effortCertificationReports) {
066 if (this.getEffortCertificationReportDefinitionService().hasBeenUsedForEffortCertificationGeneration(emplid, report)) {
067 return report;
068 }
069 }
070
071 return null;
072 }
073
074 /**
075 * @see org.kuali.kfs.integration.service.EffortCertificationService#getCostShareSubAccountTypeCodes()
076 */
077 public List<String> getCostShareSubAccountTypeCodes() {
078 return EffortConstants.ELIGIBLE_COST_SHARE_SUB_ACCOUNT_TYPE_CODES;
079 }
080
081 /**
082 * Gets the effortCertificationReportDefinitionService attribute.
083 *
084 * @return Returns the effortCertificationReportDefinitionService.
085 */
086 public EffortCertificationReportDefinitionService getEffortCertificationReportDefinitionService() {
087 return SpringContext.getBean(EffortCertificationReportDefinitionService.class);
088 }
089
090 /**
091 * Gets the effortCertificationReportDefinitionDao attribute.
092 *
093 * @return Returns the effortCertificationReportDefinitionDao.
094 */
095 public EffortCertificationReportDefinitionDao getEffortCertificationReportDefinitionDao() {
096 return SpringContext.getBean(EffortCertificationReportDefinitionDao.class);
097 }
098
099 /**
100 * Gets the parameterService attribute.
101 *
102 * @return Returns the parameterService.
103 */
104 public ParameterService getParameterService() {
105 return SpringContext.getBean(ParameterService.class);
106 }
107 }