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.sys.batch.dataaccess.impl;
017
018 import org.apache.commons.lang.StringUtils;
019 import org.kuali.kfs.sys.businessobject.SystemOptions;
020 import org.kuali.rice.kns.bo.PersistableBusinessObject;
021
022 /**
023 * Customizes new option records created by fiscal year process
024 */
025 public class SystemOptionsFiscalYearMakerImpl extends FiscalYearMakerImpl {
026
027 public SystemOptionsFiscalYearMakerImpl() {
028 super();
029
030 super.setAllowOverrideTargetYear(false);
031 }
032
033 /**
034 * @see org.kuali.kfs.coa.batch.dataaccess.impl.FiscalYearMakerHelperImpl#changeForNewYear(java.lang.Integer,
035 * org.kuali.rice.kns.bo.PersistableBusinessObject)
036 */
037 @Override
038 public void changeForNewYear(Integer baseFiscalYear, PersistableBusinessObject 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 }