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.AccountGlobalDetail;
22  import org.kuali.ole.coa.businessobject.SubObjectCode;
23  import org.kuali.ole.coa.businessobject.SubObjectCodeGlobal;
24  import org.kuali.ole.coa.businessobject.SubObjectCodeGlobalDetail;
25  import org.kuali.ole.sys.OLEConstants;
26  import org.kuali.ole.sys.document.FinancialSystemGlobalMaintainable;
27  import org.kuali.rice.krad.bo.PersistableBusinessObject;
28  import org.kuali.rice.krad.maintenance.MaintenanceLock;
29  
30  /**
31   * This class provides some specific functionality for the {@link SubObjCdGlobal} maintenance document generateMaintenanceLocks -
32   * generates maintenance locks on {@link SubObjCd}
33   */
34  public class SubObjCdGlobalMaintainableImpl extends FinancialSystemGlobalMaintainable {
35  
36      /**
37       * This generates maintenance locks on {@link SubObjCd}
38       * 
39       * @see org.kuali.rice.kns.maintenance.Maintainable#generateMaintenanceLocks()
40       */
41      @Override
42      public List<MaintenanceLock> generateMaintenanceLocks() {
43          // create locking rep for each combination of account and object code
44          List<MaintenanceLock> maintenanceLocks = new ArrayList();
45          SubObjectCodeGlobal subObjCdGlobal = (SubObjectCodeGlobal) getBusinessObject();
46  
47          for (AccountGlobalDetail accountGlobalDetail : subObjCdGlobal.getAccountGlobalDetails()) {
48              for (SubObjectCodeGlobalDetail subObjCdGlobalDetail : subObjCdGlobal.getSubObjCdGlobalDetails()) {
49                  MaintenanceLock maintenanceLock = new MaintenanceLock();
50                  maintenanceLock.setDocumentNumber(subObjCdGlobal.getDocumentNumber());
51  
52                  StringBuffer lockrep = new StringBuffer();
53                  lockrep.append(SubObjectCode.class.getName() + OLEConstants.Maintenance.AFTER_CLASS_DELIM);
54                  lockrep.append("fiscalYear" + OLEConstants.Maintenance.AFTER_FIELDNAME_DELIM);
55                  lockrep.append(subObjCdGlobalDetail.getUniversityFiscalYear() + OLEConstants.Maintenance.AFTER_VALUE_DELIM);
56                  lockrep.append("chartOfAccountsCode" + OLEConstants.Maintenance.AFTER_FIELDNAME_DELIM);
57                  lockrep.append(accountGlobalDetail.getChartOfAccountsCode() + OLEConstants.Maintenance.AFTER_VALUE_DELIM);
58                  lockrep.append("accountNumber" + OLEConstants.Maintenance.AFTER_FIELDNAME_DELIM);
59                  lockrep.append(accountGlobalDetail.getAccountNumber() + OLEConstants.Maintenance.AFTER_VALUE_DELIM);
60                  lockrep.append("financialObjectCode" + OLEConstants.Maintenance.AFTER_FIELDNAME_DELIM);
61                  lockrep.append(subObjCdGlobalDetail.getFinancialObjectCode() + OLEConstants.Maintenance.AFTER_VALUE_DELIM);
62                  lockrep.append("financialSubObjectCode" + OLEConstants.Maintenance.AFTER_FIELDNAME_DELIM);
63                  lockrep.append(subObjCdGlobal.getFinancialSubObjectCode());
64  
65                  maintenanceLock.setLockingRepresentation(lockrep.toString());
66                  maintenanceLocks.add(maintenanceLock);
67              }
68          }
69          return maintenanceLocks;
70      }
71  
72      @Override
73      public Class<? extends PersistableBusinessObject> getPrimaryEditedBusinessObjectClass() {
74          return SubObjectCode.class;
75      }
76  }