01: /*
02: * Copyright 2007 The Kuali Foundation.
03: *
04: * Licensed under the Educational Community License, Version 1.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.opensource.org/licenses/ecl1.php
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package org.kuali.module.chart.maintenance;
17:
18: import java.util.ArrayList;
19: import java.util.List;
20:
21: import org.kuali.core.document.MaintenanceLock;
22: import org.kuali.core.maintenance.KualiGlobalMaintainableImpl;
23: import org.kuali.kfs.KFSConstants;
24: import org.kuali.module.chart.bo.Account;
25: import org.kuali.module.chart.bo.AccountGlobal;
26: import org.kuali.module.chart.bo.AccountGlobalDetail;
27:
28: /**
29: * This class overrides the base {@link KualiGlobalMaintainableImpl} to generate the specific maintenance locks for Global accounts
30: */
31: public class AccountGlobalMaintainableImpl extends
32: KualiGlobalMaintainableImpl {
33:
34: /**
35: * This creates the particular locking representation for this global document.
36: *
37: * @see org.kuali.core.maintenance.Maintainable#generateMaintenanceLocks()
38: */
39: @Override
40: public List<MaintenanceLock> generateMaintenanceLocks() {
41: AccountGlobal accountGlobal = (AccountGlobal) getBusinessObject();
42: List<MaintenanceLock> maintenanceLocks = new ArrayList();
43:
44: for (AccountGlobalDetail detail : accountGlobal
45: .getAccountGlobalDetails()) {
46: MaintenanceLock maintenanceLock = new MaintenanceLock();
47: StringBuffer lockrep = new StringBuffer();
48:
49: lockrep.append(Account.class.getName()
50: + KFSConstants.Maintenance.AFTER_CLASS_DELIM);
51: lockrep.append("chartOfAccountsCode"
52: + KFSConstants.Maintenance.AFTER_FIELDNAME_DELIM);
53: lockrep.append(detail.getChartOfAccountsCode()
54: + KFSConstants.Maintenance.AFTER_VALUE_DELIM);
55: lockrep.append("accountNumber"
56: + KFSConstants.Maintenance.AFTER_FIELDNAME_DELIM);
57: lockrep.append(detail.getAccountNumber());
58:
59: maintenanceLock.setDocumentNumber(accountGlobal
60: .getDocumentNumber());
61: maintenanceLock
62: .setLockingRepresentation(lockrep.toString());
63: maintenanceLocks.add(maintenanceLock);
64: }
65: return maintenanceLocks;
66: }
67: }
|