View Javadoc

1   /*
2    * Copyright 2007 The Kuali Foundation
3    * 
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    * http://www.opensource.org/licenses/ecl2.php
9    * 
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.ole.coa.document;
17  
18  import java.util.ArrayList;
19  import java.util.List;
20  
21  import org.kuali.ole.coa.businessobject.Account;
22  import org.kuali.ole.coa.businessobject.AccountGlobal;
23  import org.kuali.ole.coa.businessobject.AccountGlobalDetail;
24  import org.kuali.ole.sys.OLEConstants;
25  import org.kuali.ole.sys.document.FinancialSystemGlobalMaintainable;
26  import org.kuali.rice.krad.bo.PersistableBusinessObject;
27  import org.kuali.rice.krad.maintenance.MaintenanceLock;
28  
29  /**
30   * This class overrides the base {@link KualiGlobalMaintainableImpl} to generate the specific maintenance locks for Global accounts
31   */
32  public class AccountGlobalMaintainableImpl extends FinancialSystemGlobalMaintainable {
33  
34      /**
35       * This creates the particular locking representation for this global document.
36       * 
37       * @see org.kuali.rice.kns.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.getAccountGlobalDetails()) {
45              MaintenanceLock maintenanceLock = new MaintenanceLock();
46              StringBuffer lockrep = new StringBuffer();
47  
48              lockrep.append(Account.class.getName() + OLEConstants.Maintenance.AFTER_CLASS_DELIM);
49              lockrep.append("chartOfAccountsCode" + OLEConstants.Maintenance.AFTER_FIELDNAME_DELIM);
50              lockrep.append(detail.getChartOfAccountsCode() + OLEConstants.Maintenance.AFTER_VALUE_DELIM);
51              lockrep.append("accountNumber" + OLEConstants.Maintenance.AFTER_FIELDNAME_DELIM);
52              lockrep.append(detail.getAccountNumber());
53  
54              maintenanceLock.setDocumentNumber(accountGlobal.getDocumentNumber());
55              maintenanceLock.setLockingRepresentation(lockrep.toString());
56              maintenanceLocks.add(maintenanceLock);
57          }
58          return maintenanceLocks;
59      }
60  
61      @Override
62      public Class<? extends PersistableBusinessObject> getPrimaryEditedBusinessObjectClass() {
63          return Account.class;
64      }
65  }