1 /* 2 * The Kuali Financial System, a comprehensive financial management system for higher education. 3 * 4 * Copyright 2005-2014 The Kuali Foundation 5 * 6 * This program is free software: you can redistribute it and/or modify 7 * it under the terms of the GNU Affero General Public License as 8 * published by the Free Software Foundation, either version 3 of the 9 * License, or (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU Affero General Public License for more details. 15 * 16 * You should have received a copy of the GNU Affero General Public License 17 * along with this program. If not, see <http://www.gnu.org/licenses/>. 18 */ 19 package org.kuali.kfs.module.external.kc.document; 20 21 import java.util.Map; 22 23 import org.kuali.kfs.coa.businessobject.Account; 24 import org.kuali.kfs.integration.cg.ContractsAndGrantsCfda; 25 import org.kuali.rice.kns.document.MaintenanceDocument; 26 27 /** 28 * This class overrides the saveBusinessObject() method which is called during post process from the KualiPostProcessor so that it 29 * can automatically deactivate the Sub-Accounts related to the account It also overrides the processAfterCopy so that it sets 30 * specific fields that shouldn't be copied to default values {@link KualiPostProcessor} 31 */ 32 public class KualiAccountMaintainableImpl extends org.kuali.kfs.coa.document.KualiAccountMaintainableImpl { 33 34 /** 35 * @see org.kuali.kfs.coa.document.KualiAccountMaintainableImpl#lookupAccountCfda(java.lang.String, java.lang.String) 36 */ 37 38 protected String lookupAccountCfda(String accountNumber, String currentCfda) { 39 Account account = (Account) this.getBusinessObject(); 40 ContractsAndGrantsCfda cfda = account.getCfda(); 41 if (cfda != null) { 42 return cfda.getCfdaNumber(); 43 } 44 return null; 45 } 46 47 /** 48 * @see org.kuali.kfs.coa.document.KualiAccountMaintainableImpl#processAfterCopy(org.kuali.rice.kns.document.MaintenanceDocument, java.util.Map) 49 */ 50 @Override 51 public void processAfterCopy(MaintenanceDocument document, Map<String, String[]> parameters) { 52 Account account = (Account) this.getBusinessObject(); 53 account.setAccountCfdaNumber(lookupAccountCfda( account.getAccountNumber(), account.getAccountCfdaNumber())); 54 super.processAfterCopy(document, parameters); 55 } 56 57 /** 58 * @see org.kuali.kfs.coa.document.KualiAccountMaintainableImpl#retrieveExistingAccountFromDB() 59 */ 60 @Override 61 protected Account retrieveExistingAccountFromDB() { 62 Account newAccount = (Account) getBusinessObject(); 63 newAccount.setAccountCfdaNumber(lookupAccountCfda( newAccount.getAccountNumber(), newAccount.getAccountCfdaNumber())); 64 return super.retrieveExistingAccountFromDB(); 65 } 66 }