001/*
002 * Copyright 2008-2009 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 */
016package org.kuali.ole.sys.batch.dataaccess.impl;
017
018import org.apache.commons.lang.StringUtils;
019import org.kuali.ole.sys.businessobject.FiscalYearBasedBusinessObject;
020import org.kuali.ole.sys.businessobject.SystemOptions;
021
022/**
023 * Customizes new option records created by fiscal year process
024 */
025public class SystemOptionsFiscalYearMakerImpl extends FiscalYearMakerImpl {
026
027    public SystemOptionsFiscalYearMakerImpl() {
028        super();
029        
030        super.setAllowOverrideTargetYear(false);
031    }
032
033    /**
034     * @see org.kuali.ole.coa.batch.dataaccess.impl.FiscalYearMakerHelperImpl#changeForNewYear(java.lang.Integer,
035     *      org.kuali.rice.krad.bo.PersistableBusinessObject)
036     */
037    @Override
038    public void changeForNewYear(Integer baseFiscalYear, FiscalYearBasedBusinessObject currentRecord) {
039        super.changeForNewYear(baseFiscalYear, currentRecord);
040        
041        SystemOptions options = (SystemOptions) currentRecord;
042        options.setUniversityFiscalYearStartYr(baseFiscalYear);
043
044        // name string contains previous fiscal year start and end year that needs updated
045        Integer previousStartYear = baseFiscalYear - 1;
046        Integer nextEndYear = baseFiscalYear + 1;
047
048        String universityFiscalYearName = options.getUniversityFiscalYearName();
049        universityFiscalYearName = StringUtils.replace(universityFiscalYearName, baseFiscalYear.toString(), nextEndYear.toString());
050        universityFiscalYearName = StringUtils.replace(universityFiscalYearName, previousStartYear.toString(), baseFiscalYear.toString());
051
052        options.setUniversityFiscalYearName(universityFiscalYearName);
053    }
054
055}