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.document;
017
018 import java.util.ArrayList;
019 import java.util.List;
020
021 import org.kuali.kfs.coa.businessobject.Account;
022 import org.kuali.kfs.coa.businessobject.AccountGlobal;
023 import org.kuali.kfs.coa.businessobject.AccountGlobalDetail;
024 import org.kuali.kfs.sys.KFSConstants;
025 import org.kuali.kfs.sys.document.FinancialSystemGlobalMaintainable;
026 import org.kuali.rice.kns.bo.PersistableBusinessObject;
027 import org.kuali.rice.kns.document.MaintenanceLock;
028
029 /**
030 * This class overrides the base {@link KualiGlobalMaintainableImpl} to generate the specific maintenance locks for Global accounts
031 */
032 public class AccountGlobalMaintainableImpl extends FinancialSystemGlobalMaintainable {
033
034 /**
035 * This creates the particular locking representation for this global document.
036 *
037 * @see org.kuali.rice.kns.maintenance.Maintainable#generateMaintenanceLocks()
038 */
039 @Override
040 public List<MaintenanceLock> generateMaintenanceLocks() {
041 AccountGlobal accountGlobal = (AccountGlobal) getBusinessObject();
042 List<MaintenanceLock> maintenanceLocks = new ArrayList();
043
044 for (AccountGlobalDetail detail : accountGlobal.getAccountGlobalDetails()) {
045 MaintenanceLock maintenanceLock = new MaintenanceLock();
046 StringBuffer lockrep = new StringBuffer();
047
048 lockrep.append(Account.class.getName() + KFSConstants.Maintenance.AFTER_CLASS_DELIM);
049 lockrep.append("chartOfAccountsCode" + KFSConstants.Maintenance.AFTER_FIELDNAME_DELIM);
050 lockrep.append(detail.getChartOfAccountsCode() + KFSConstants.Maintenance.AFTER_VALUE_DELIM);
051 lockrep.append("accountNumber" + KFSConstants.Maintenance.AFTER_FIELDNAME_DELIM);
052 lockrep.append(detail.getAccountNumber());
053
054 maintenanceLock.setDocumentNumber(accountGlobal.getDocumentNumber());
055 maintenanceLock.setLockingRepresentation(lockrep.toString());
056 maintenanceLocks.add(maintenanceLock);
057 }
058 return maintenanceLocks;
059 }
060
061 @Override
062 public Class<? extends PersistableBusinessObject> getPrimaryEditedBusinessObjectClass() {
063 return Account.class;
064 }
065 }