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.external.kc.document;
017
018 import java.util.Map;
019
020 import org.kuali.kfs.coa.businessobject.Account;
021 import org.kuali.kfs.integration.cg.ContractsAndGrantsCfda;
022 import org.kuali.rice.kns.document.MaintenanceDocument;
023
024 /**
025 * This class overrides the saveBusinessObject() method which is called during post process from the KualiPostProcessor so that it
026 * can automatically deactivate the Sub-Accounts related to the account It also overrides the processAfterCopy so that it sets
027 * specific fields that shouldn't be copied to default values {@link KualiPostProcessor}
028 */
029 public class KualiAccountMaintainableImpl extends org.kuali.kfs.coa.document.KualiAccountMaintainableImpl {
030
031 /**
032 * @see org.kuali.kfs.coa.document.KualiAccountMaintainableImpl#lookupAccountCfda(java.lang.String, java.lang.String)
033 */
034
035 protected String lookupAccountCfda(String accountNumber, String currentCfda) {
036 Account account = (Account) this.getBusinessObject();
037 ContractsAndGrantsCfda cfda = account.getCfda();
038 if (cfda != null) return cfda.getCfdaNumber();
039 return "";
040 }
041
042 /**
043 * @see org.kuali.kfs.coa.document.KualiAccountMaintainableImpl#processAfterCopy(org.kuali.rice.kns.document.MaintenanceDocument, java.util.Map)
044 */
045 @Override
046 public void processAfterCopy(MaintenanceDocument document, Map<String, String[]> parameters) {
047 Account account = (Account) this.getBusinessObject();
048 account.setAccountCfdaNumber(lookupAccountCfda( account.getAccountNumber(), account.getAccountCfdaNumber()));
049 super.processAfterCopy(document, parameters);
050 }
051
052 /**
053 * @see org.kuali.kfs.coa.document.KualiAccountMaintainableImpl#retrieveExistingAccountFromDB()
054 */
055 @Override
056 protected Account retrieveExistingAccountFromDB() {
057 Account newAccount = (Account) getBusinessObject();
058 newAccount.setAccountCfdaNumber(lookupAccountCfda( newAccount.getAccountNumber(), newAccount.getAccountCfdaNumber()));
059 return super.retrieveExistingAccountFromDB();
060 }
061 }