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.coa.service.impl;
017    
018    import java.util.Map;
019    
020    import org.kuali.kfs.coa.businessobject.ObjectCode;
021    import org.kuali.kfs.sys.service.UniversityDateService;
022    import org.kuali.rice.kns.bo.BusinessObject;
023    import org.kuali.rice.kns.datadictionary.InactivationBlockingMetadata;
024    import org.kuali.rice.kns.service.impl.InactivationBlockingDetectionServiceImpl;
025    
026    /**
027     * This class overrides the base Inactivation Blocking Detection Service.  It is intended to be used with ObjectCode or ObjectCodeCurrent BOs when they
028     * represent the BLOCKED bo.
029     */
030    public class ObjectCodeCurrentInactivationBlockingDetectionServiceImpl extends InactivationBlockingDetectionServiceImpl {
031        private UniversityDateService universityDateService;
032        
033        @Override
034        protected Map<String, String> buildInactivationBlockerQueryMap(BusinessObject blockedBo, InactivationBlockingMetadata inactivationBlockingMetadata) {
035            ObjectCode blockedObjectCode = (ObjectCode) blockedBo;
036            if (universityDateService.getCurrentFiscalYear().equals(blockedObjectCode.getUniversityFiscalYear())) {
037                return super.buildInactivationBlockerQueryMap(blockedBo, inactivationBlockingMetadata);
038            }
039            return null;
040            
041        }
042    
043        public void setUniversityDateService(UniversityDateService universityDateService) {
044            this.universityDateService = universityDateService;
045        }
046    
047    }